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