Merge commit 'athcx/bloom'
[adu.git] / Makefile
1 objects := adu.o string.o cmdline.o fd.o select.o create.o interactive.o select.cmdline.o format.o user.o bloom.o
2 all: adu
3 version := 0.0.5
4 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
5
6 DEBUG_CPPFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
7 DEBUG_CPPFLAGS += -Wredundant-decls
8 CPPFLAGS += -Os
9 CPPFLAGS += -Wall
10 CPPFLAGS += -Wuninitialized
11 CPPFLAGS += -Wchar-subscripts
12 CPPFLAGS += -Wformat-security
13 CPPFLAGS += -Werror-implicit-function-declaration
14 CPPFLAGS += -Wmissing-format-attribute
15 CPPFLAGS += -Wunused-macros
16 CPPFLAGS += -Wbad-function-cast
17 CPPFLAGS += -DVERSION='"$(version)"'
18 CPPFLAGS += -I/usr/local/include
19
20 LDFLAGS += -L/usr/local/lib
21
22 PREFIX ?= /usr/local
23
24
25 ifeq (,$(findstring BSD,$(uname_S)))
26 CPPFLAGS += -D_LARGEFILE64_SOURCE
27 CPPFLAGS += $(shell getconf LFS64_CFLAGS)
28 LDFLAGS += -D_LARGEFILE64_SOURCE
29 LDFLAGS += $(shell getconf LFS64_LDFLAGS)
30 LDFLAGS += $(shell getconf LFS64_LIBS)
31 CPPFLAGS += -DHAVE_STAT64=1
32 endif
33
34
35 Makefile.deps: $(wildcard *.c *.h)
36 gcc -MM -MG *.c > $@
37
38 -include Makefile.deps
39
40 adu: $(objects)
41 $(CC) -o $@ $(LDFLAGS) $(objects) -lcrypto -losl
42
43 cmdline.o: cmdline.c cmdline.h
44 $(CC) -c $(CPPFLAGS) $<
45
46 cmdline.c cmdline.h: adu.ggo
47 gengetopt --no-handle-error --no-handle-help --conf-parser < $<
48
49
50 %.o: %.c Makefile
51 $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
52
53 %.ppm: %.sk
54 sk2ppm $< > $@
55 %.png: %.ppm
56 convert $< $@
57
58 select.cmdline.c select.cmdline.h: select.ggo
59 gengetopt --set-package=select \
60 --no-handle-help \
61 --no-handle-error \
62 --no-handle-version \
63 --arg-struct-name=select_args_info \
64 --file-name=$(subst .ggo,,$<).cmdline \
65 --func-name $(subst .ggo,,$<)_cmdline_parser < $<
66
67 select.cmdline.o: select.cmdline.c select.cmdline.h
68 $(CC) -c $(CPPFLAGS) $<
69
70 adu.1: adu adu.1.inc
71 help2man -h --detailed-help --include adu.1.inc -N ./$< > $@
72
73 %.1.html: %.1
74 man2html $< | sed -e 's|^<DT><DD>$$|<DT><DD><br>|g' > $@
75
76 clean:
77 rm -f *.o adu *cmdline.c *cmdline.h adu.1 adu.1.html adu.png index.html adu.sk~
78
79 index.html: adu.1.html index.html.in INSTALL README
80 sed -e '/@README@/,$$d' index.html.in > $@
81 grutatxt -nb < README >> $@
82 sed -e '1,/@README@/d' -e '/@INSTALL@/,$$d' index.html.in >> $@
83 grutatxt -nb < INSTALL >> $@
84 sed -e '1,/@INSTALL@/d' -e '/@MAN_PAGE@/,$$d' index.html.in >> $@
85 sed -e '1,/Return to Main Contents/d' -e '/Index/,$$d' adu.1.html >> $@
86 sed -e '1,/@MAN_PAGE@/d' index.html.in >> $@
87
88 install: adu adu.1
89 install -s adu $(PREFIX)/bin
90 install -m 0644 adu.1 $(PREFIX)/man/man1