DESTDIR=/ CC = cc cflags = -O0 -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-trampolines -g -Isrc -Itmp -pthread SRCFILE = src/main.c ldflags = $(shell xml2-config --libs --cflags) -lmicrohttpd -lm BINFILE = sear.c # cflags and ldflags are used so that users specifying CFLAGS and LDFLAGS do not override my flags # += is not used, because gcc usually accepts last option, for example -O0 -O2 will use -O2 .NOTPARALLEL: default: mkdir tmp -p sed "s//$$PVR/g" < src/hp.html > tmp/hp.html # gentoo ebuild. git overrides it. -VER=`git describe --always` && sed "s//$$VER/g" < src/hp.html > tmp/hp.html sed -i "s/=>/$(shell echo '#include "src/i18n.h"' | $(CC) -dM -E - | grep "SC_I18N_SEARCH " | cut -d' ' -f3)/g" tmp/hp.html sed -i "s/1\./$(shell echo '#include "src/i18n.h"' | $(CC) -dM -E - | grep "SC_I18N_HORSESHOE " | cut -d' ' -f3)/g" tmp/hp.html sed -i "s/\[^\]/$(shell echo '#include "src/i18n.h"' | $(CC) -dM -E - | grep "SC_I18N_IMAGES " | cut -d' ' -f3)/g" tmp/hp.html xxd -i < tmp/hp.html > tmp/hp.xxd echo ', 0' >> tmp/hp.xxd xxd -i < src/osdd.xml > tmp/osdd.xxd echo ', 0' >> tmp/osdd.xxd xxd -i < src/css.css > tmp/css.xxd echo ', 0' >> tmp/css.xxd xxd -i < src/ico.ico > tmp/ico.xxd $(CC) $(cflags) $(CFLAGS) $(SRCFILE) $(ldflags) $(LDFLAGS) -o$(BINFILE) install: mkdir -p $(DESTDIR)/usr/bin/ cp $(BINFILE) $(DESTDIR)/usr/bin/ distclean: rm sear.c tmp -rf clean: rm sear.c tmp -rf test-http: mkdir -p tmp gcc -Wall -pedantic -g -Isrc -Itmp test/nanohttp.c $$(xml2-config --libs --cflags) -otmp/nanohttp test-http-valgrind: valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-out.txt tmp/nanohttp http://sijanec.eu/ valgrind: valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-out.txt ./sear.c .PHONY: valgrind test-http-valgrind test-http clean distclean install default