1 25756acf 2021-06-02 martijn LOCALBASE?= /usr/
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
8 25756acf 2021-06-02 martijn SRCS+= main.c mheader.c
10 33a7c297 2022-12-16 martijn ifdef HAVE_ED25519
11 33a7c297 2022-12-16 martijn CFLAGS+= -DHAVE_ED25519
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}
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
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/
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
39 babf5d5a 2021-05-11 martijn INSTALL?= install
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
47 25756acf 2021-06-02 martijn MANFORMAT?= mangz
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
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 > $@
62 25756acf 2021-06-02 martijn TARGET_MAN= ${MAN}
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
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
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
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
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
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
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
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
93 babf5d5a 2021-05-11 martijn ifeq (${NEED_PLEDGE}, 1)
94 babf5d5a 2021-05-11 martijn CFLAGS+= -DNEED_PLEDGE=1
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}
101 babf5d5a 2021-05-11 martijn OBJS= ${notdir ${SRCS:.c=.o}}
102 25756acf 2021-06-02 martijn CLEANFILES+= ${OBJS}
104 babf5d5a 2021-05-11 martijn ${PROG}: ${OBJS}
105 25756acf 2021-06-02 martijn ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
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}
112 babf5d5a 2021-05-11 martijn .PHONY: clean
114 25756acf 2021-06-02 martijn rm -f ${CLEANFILES}
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}