blob: f72022ef8f07d298f4229930c2686ce417cf391b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
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/<!--ver-->/$$PVR/g" < src/hp.html > tmp/hp.html # gentoo ebuild. git overrides it.
-VER=`git describe --always` && sed "s/<!--ver-->/$$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
$(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
prepare:
apt install libmicrohttpd-dev xxd build-essential libxml2-dev php-cli debmake debheler -y
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 prepare clean distclean install default
|