Blame


1 25756acf 2021-06-02 martijn LOCALBASE?= /usr/
2 babf5d5a 2021-05-11 martijn
3 25756acf 2021-06-02 martijn PROG= filter-dkimsign
4 25756acf 2021-06-02 martijn MAN= filter-dkimsign.8
5 25756acf 2021-06-02 martijn BINDIR= ${LOCALBASE}/libexec/opensmtpd/
6 25756acf 2021-06-02 martijn MANDIR= ${LOCALBASE}/share/man/man8
7 babf5d5a 2021-05-11 martijn
8 25756acf 2021-06-02 martijn SRCS+= main.c mheader.c
9 babf5d5a 2021-05-11 martijn
10 25756acf 2021-06-02 martijn ifdef LIBCRYPTOPC
11 25756acf 2021-06-02 martijn CRYPT_CFLAGS!= pkg-config --cflags ${LIBCRYPTOPC}
12 25756acf 2021-06-02 martijn CRYPT_LDFLAGS_L!=pkg-config --libs-only-L ${LIBCRYPTOPC}
13 25756acf 2021-06-02 martijn CRYPT_LDFLAGS_libdir!=pkg-config --variable libdir ${LIBCRYPTOPC}
14 25756acf 2021-06-02 martijn CRYPT_LDFLAGS= ${CRYPT_LDFLAGS_L}
15 25756acf 2021-06-02 martijn CRYPT_LDFLAGS+= -Wl,-rpath,${CRYPT_LDFLAGS_libdir}
16 25756acf 2021-06-02 martijn CRYPT_LDADD!= pkg-config --libs-only-l ${LIBCRYPTOPC}
17 25756acf 2021-06-02 martijn else
18 25756acf 2021-06-02 martijn CRYPT_CFLAGS=
19 25756acf 2021-06-02 martijn CRYPT_LDFLAGS=
20 25756acf 2021-06-02 martijn CRYPT_LDADD= -lcrypto
21 25756acf 2021-06-02 martijn endif
22 babf5d5a 2021-05-11 martijn
23 25756acf 2021-06-02 martijn CFLAGS+= -I${LOCALBASE}/include
24 25756acf 2021-06-02 martijn CFLAGS+= -Wall -I${.CURDIR}
25 25756acf 2021-06-02 martijn CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
26 25756acf 2021-06-02 martijn CFLAGS+= -Wmissing-declarations
27 25756acf 2021-06-02 martijn CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual
28 25756acf 2021-06-02 martijn CFLAGS+= -Wsign-compare
29 25756acf 2021-06-02 martijn CFLAGS+= ${CRYPT_CFLAGS}
30 25756acf 2021-06-02 martijn CFLAGS+= -I${CURDIR} -I${CURDIR}/openbsd-compat/
31 babf5d5a 2021-05-11 martijn
32 25756acf 2021-06-02 martijn LDFLAGS+= -L${LOCALBASE}/lib
33 25756acf 2021-06-02 martijn LDFLAGS+= ${CRYPT_LDFLAGS}
34 25756acf 2021-06-02 martijn LDADD+= ${CRYPT_LDADD} -lopensmtpd
35 babf5d5a 2021-05-11 martijn
36 babf5d5a 2021-05-11 martijn INSTALL?= install
37 babf5d5a 2021-05-11 martijn
38 25756acf 2021-06-02 martijn NEED_REALLOCARRAY?= 1
39 babf5d5a 2021-05-11 martijn NEED_RECALLOCARRAY?= 1
40 babf5d5a 2021-05-11 martijn NEED_STRLCAT?= 1
41 babf5d5a 2021-05-11 martijn NEED_STRTONUM?= 1
42 babf5d5a 2021-05-11 martijn NEED_PLEDGE?= 1
43 babf5d5a 2021-05-11 martijn
44 25756acf 2021-06-02 martijn MANFORMAT?= mangz
45 babf5d5a 2021-05-11 martijn
46 25756acf 2021-06-02 martijn BINOWN?= root
47 25756acf 2021-06-02 martijn BINGRP?= root
48 25756acf 2021-06-02 martijn BINPERM?= 755
49 25756acf 2021-06-02 martijn MANOWN?= root
50 25756acf 2021-06-02 martijn MANGRP?= root
51 25756acf 2021-06-02 martijn MANPERM?= 644
52 25756acf 2021-06-02 martijn
53 25756acf 2021-06-02 martijn ifeq (${MANFORMAT}, mangz)
54 25756acf 2021-06-02 martijn TARGET_MAN= ${MAN}.gz
55 25756acf 2021-06-02 martijn CLEANFILES+= ${TARGET_MAN}
56 25756acf 2021-06-02 martijn ${TARGET_MAN}: ${MAN}
57 25756acf 2021-06-02 martijn mandoc -Tman ${MAN} | gzip > $@
58 25756acf 2021-06-02 martijn else
59 25756acf 2021-06-02 martijn TARGET_MAN= ${MAN}
60 25756acf 2021-06-02 martijn endif
61 25756acf 2021-06-02 martijn
62 25756acf 2021-06-02 martijn ifeq (${NEED_REALLOCARRAY}, 1)
63 25756acf 2021-06-02 martijn SRCS+= ${CURDIR}/openbsd-compat/reallocarray.c
64 25756acf 2021-06-02 martijn CFLAGS+= -DNEED_REALLOCARRAY=1
65 25756acf 2021-06-02 martijn
66 25756acf 2021-06-02 martijn reallocarray.o: ${CURDIR}/openbsd-compat/reallocarray.c
67 25756acf 2021-06-02 martijn ${CC} ${CFLAGS} -c -o reallocarray.o ${CURDIR}/openbsd-compat/reallocarray.c
68 25756acf 2021-06-02 martijn endif
69 babf5d5a 2021-05-11 martijn ifeq (${NEED_RECALLOCARRAY}, 1)
70 babf5d5a 2021-05-11 martijn SRCS+= ${CURDIR}/openbsd-compat/recallocarray.c
71 babf5d5a 2021-05-11 martijn CFLAGS+= -DNEED_RECALLOCARRAY=1
72 babf5d5a 2021-05-11 martijn
73 babf5d5a 2021-05-11 martijn recallocarray.o: ${CURDIR}/openbsd-compat/recallocarray.c
74 babf5d5a 2021-05-11 martijn ${CC} ${CFLAGS} -c -o recallocarray.o ${CURDIR}/openbsd-compat/recallocarray.c
75 babf5d5a 2021-05-11 martijn endif
76 babf5d5a 2021-05-11 martijn ifeq (${NEED_STRLCAT}, 1)
77 babf5d5a 2021-05-11 martijn SRCS+= ${CURDIR}/openbsd-compat/strlcat.c
78 babf5d5a 2021-05-11 martijn CFLAGS+= -DNEED_STRLCAT=1
79 babf5d5a 2021-05-11 martijn
80 babf5d5a 2021-05-11 martijn strlcat.o: ${CURDIR}/openbsd-compat/strlcat.c
81 babf5d5a 2021-05-11 martijn ${CC} ${CFLAGS} -c -o strlcat.o ${CURDIR}/openbsd-compat/strlcat.c
82 babf5d5a 2021-05-11 martijn endif
83 babf5d5a 2021-05-11 martijn ifeq (${NEED_STRTONUM}, 1)
84 babf5d5a 2021-05-11 martijn SRCS+= ${CURDIR}/openbsd-compat/strtonum.c
85 babf5d5a 2021-05-11 martijn CFLAGS+= -DNEED_STRTONUM=1
86 babf5d5a 2021-05-11 martijn
87 babf5d5a 2021-05-11 martijn strtonum.o: ${CURDIR}/openbsd-compat/strtonum.c
88 babf5d5a 2021-05-11 martijn ${CC} ${CFLAGS} -c -o strtonum.o ${CURDIR}/openbsd-compat/strtonum.c
89 babf5d5a 2021-05-11 martijn endif
90 babf5d5a 2021-05-11 martijn ifeq (${NEED_PLEDGE}, 1)
91 babf5d5a 2021-05-11 martijn CFLAGS+= -DNEED_PLEDGE=1
92 babf5d5a 2021-05-11 martijn endif
93 babf5d5a 2021-05-11 martijn
94 babf5d5a 2021-05-11 martijn ${SRCS:.c=.d}:%.d:%.c
95 babf5d5a 2021-05-11 martijn ${CC} ${CFLAGS} -MM $< >$@
96 25756acf 2021-06-02 martijn CLEANFILES+= ${SRCS:.c=.d}
97 babf5d5a 2021-05-11 martijn
98 babf5d5a 2021-05-11 martijn OBJS= ${notdir ${SRCS:.c=.o}}
99 25756acf 2021-06-02 martijn CLEANFILES+= ${OBJS}
100 babf5d5a 2021-05-11 martijn
101 babf5d5a 2021-05-11 martijn ${PROG}: ${OBJS}
102 25756acf 2021-06-02 martijn ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
103 babf5d5a 2021-05-11 martijn
104 25756acf 2021-06-02 martijn .DEFAULT_GOAL= all
105 25756acf 2021-06-02 martijn .PHONY: all
106 25756acf 2021-06-02 martijn all: ${PROG} ${TARGET_MAN}
107 25756acf 2021-06-02 martijn CLEANFILES+= ${PROG}
108 25756acf 2021-06-02 martijn
109 babf5d5a 2021-05-11 martijn .PHONY: clean
110 babf5d5a 2021-05-11 martijn clean:
111 25756acf 2021-06-02 martijn rm -f ${CLEANFILES}
112 babf5d5a 2021-05-11 martijn
113 babf5d5a 2021-05-11 martijn .PHONY: install
114 babf5d5a 2021-05-11 martijn install: ${PROG}
115 25756acf 2021-06-02 martijn ${INSTALL} -D -o ${BINOWN} -g ${BINGRP} -m ${BINPERM} ${PROG} ${DESTDIR}${BINDIR}/${PROG}
116 25756acf 2021-06-02 martijn ${INSTALL} -D -o ${MANOWN} -g ${MANGRP} -m ${MANPERM} ${TARGET_MAN} ${DESTDIR}${MANDIR}/${TARGET_MAN}