107 lines
4.3 KiB
Makefile
107 lines
4.3 KiB
Makefile
PREFIX?=/usr/local
|
|
PREFIX_MAN=$(PREFIX)/man
|
|
CFLAGS?=-g -Wall -Wextra -pedantic
|
|
HARDEN_CFLAGS=-O2 -g0 -fPIE -fstack-protector-strong -D_FORTIFY_SOURCE=3
|
|
HARDEN_LDFLAGS=-pie -Wl,-z,relro,-z,now
|
|
SANITIZERS?=address,undefined
|
|
SANITIZE_FLAGS=-O1 -g -fno-omit-frame-pointer -fsanitize=$(SANITIZERS) \
|
|
-fno-sanitize=alignment
|
|
|
|
all: snac
|
|
|
|
snac: snac.o main.o sandbox.o data.o http.o httpd.o webfinger.o \
|
|
activitypub.o html.o utils.o format.o upgrade.o mastoapi.o rss.o
|
|
$(CC) $(CFLAGS) -L$(PREFIX)/lib *.o -lcurl -lcrypto $(LDFLAGS) -pthread -o $@
|
|
|
|
test: tests/smtp tests/httpd_slow_client
|
|
|
|
check: tests/httpd_slow_client
|
|
./tests/httpd_slow_client
|
|
|
|
check-sanitize:
|
|
$(CC) $(CFLAGS) $(SANITIZE_FLAGS) -DXS_HTTPD_WRITE_TIMEOUT=0.25 -I. \
|
|
tests/httpd_slow_client.c -o tests/httpd_slow_client_sanitize
|
|
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=halt_on_error=1 \
|
|
./tests/httpd_slow_client_sanitize
|
|
|
|
release:
|
|
$(MAKE) clean
|
|
$(MAKE) CFLAGS="$(CFLAGS) $(HARDEN_CFLAGS)" \
|
|
LDFLAGS="$(LDFLAGS) $(HARDEN_LDFLAGS)" snac
|
|
|
|
tests/smtp: tests/smtp.o
|
|
$(CC) $(CFLAGS) -L$(PREFIX)/lib $< -lcurl $(LDFLAGS) -o $@
|
|
|
|
tests/httpd_slow_client: tests/httpd_slow_client.c
|
|
$(CC) $(CFLAGS) -DXS_HTTPD_WRITE_TIMEOUT=0.25 -I. $< -o $@
|
|
|
|
.c.o:
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -I$(PREFIX)/include -c $< -o $@
|
|
|
|
clean:
|
|
rm -rf *.o tests/*.o tests/smtp tests/httpd_slow_client \
|
|
tests/httpd_slow_client_sanitize *.core snac makefile.depend
|
|
|
|
dep:
|
|
$(CC) -I$(PREFIX)/include -MM *.c > makefile.depend
|
|
|
|
install:
|
|
mkdir -p -m 755 $(PREFIX)/bin
|
|
install -m 755 snac $(PREFIX)/bin/snac
|
|
mkdir -p -m 755 $(PREFIX_MAN)/man1
|
|
install -m 644 doc/snac.1 $(PREFIX_MAN)/man1/snac.1
|
|
mkdir -p -m 755 $(PREFIX_MAN)/man5
|
|
install -m 644 doc/snac.5 $(PREFIX_MAN)/man5/snac.5
|
|
mkdir -p -m 755 $(PREFIX_MAN)/man8
|
|
install -m 644 doc/snac.8 $(PREFIX_MAN)/man8/snac.8
|
|
|
|
uninstall:
|
|
rm $(PREFIX)/bin/snac
|
|
rm $(PREFIX_MAN)/man1/snac.1
|
|
rm $(PREFIX_MAN)/man5/snac.5
|
|
rm $(PREFIX_MAN)/man8/snac.8
|
|
|
|
update-po:
|
|
mkdir -p po
|
|
[ -f "po/en.po" ] || xgettext -o po/en.po --language=C --keyword=L --keyword=LL --from-code=utf-8 *.c
|
|
for a in po/*.po ; do \
|
|
sed -i -e '/^#:/d' $$a ; \
|
|
xgettext --omit-header -j -o $$a --language=C --keyword=L --keyword=LL --from-code=utf-8 *.c ; \
|
|
done
|
|
|
|
activitypub.o: activitypub.c default_avatar.h xs.h xs_json.h xs_curl.h xs_url.h xs_mime.h \
|
|
xs_openssl.h xs_regex.h xs_time.h xs_set.h xs_match.h xs_unicode.h \
|
|
xs_webmention.h xs_http.h xs_http_codes.h snac.h
|
|
data.o: data.c xs.h xs_hex.h xs_io.h xs_json.h xs_openssl.h xs_glob.h \
|
|
xs_set.h xs_time.h xs_regex.h xs_match.h xs_unicode.h xs_random.h \
|
|
xs_po.h xs_http.h xs_http_codes.h snac.h
|
|
format.o: format.c xs.h xs_regex.h xs_mime.h xs_html.h xs_json.h \
|
|
xs_time.h xs_match.h xs_unicode.h snac.h
|
|
html.o: html.c xs.h xs_io.h xs_json.h xs_regex.h xs_set.h xs_openssl.h \
|
|
xs_time.h xs_mime.h xs_match.h xs_html.h xs_curl.h xs_unicode.h xs_url.h \
|
|
xs_random.h xs_http.h xs_http_codes.h snac.h
|
|
http.o: http.c xs.h xs_io.h xs_openssl.h xs_curl.h xs_time.h xs_json.h \
|
|
xs_http.h xs_http_codes.h snac.h
|
|
httpd.o: httpd.c xs.h xs_io.h xs_json.h xs_socket.h xs_unix_socket.h \
|
|
xs_http.h xs_http_codes.h xs_httpd.h xs_mime.h xs_time.h xs_openssl.h \
|
|
xs_fcgi.h xs_html.h xs_webmention.h snac.h
|
|
main.o: main.c xs.h xs_io.h xs_json.h xs_time.h xs_openssl.h xs_match.h \
|
|
xs_random.h xs_http.h xs_http_codes.h snac.h
|
|
mastoapi.o: mastoapi.c xs.h xs_hex.h xs_openssl.h xs_json.h xs_io.h \
|
|
xs_time.h xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h \
|
|
xs_unicode.h xs_http.h xs_http_codes.h snac.h
|
|
rss.o: rss.c xs.h xs_html.h xs_regex.h xs_time.h xs_match.h xs_curl.h \
|
|
xs_openssl.h xs_json.h xs_http.h xs_http_codes.h xs_unicode.h snac.h
|
|
sandbox.o: sandbox.c xs.h snac.h
|
|
snac.o: snac.c xs.h xs_hex.h xs_io.h xs_unicode_tbl.h xs_unicode.h \
|
|
xs_json.h xs_curl.h xs_openssl.h xs_socket.h xs_unix_socket.h xs_url.h \
|
|
xs_http.h xs_http_codes.h xs_httpd.h xs_mime.h xs_regex.h xs_set.h \
|
|
xs_time.h xs_glob.h xs_random.h xs_match.h xs_fcgi.h xs_html.h xs_po.h \
|
|
xs_webmention.h xs_list_tools.h snac.h
|
|
upgrade.o: upgrade.c xs.h xs_io.h xs_json.h xs_glob.h snac.h
|
|
utils.o: utils.c xs.h xs_io.h xs_json.h xs_time.h xs_openssl.h \
|
|
xs_random.h xs_glob.h xs_curl.h xs_regex.h xs_http.h xs_http_codes.h \
|
|
xs_list_tools.h xs_set.h snac.h
|
|
webfinger.o: webfinger.c xs.h xs_json.h xs_curl.h xs_mime.h xs_http.h \
|
|
xs_http_codes.h snac.h
|