Blame


1 957c2372 2019-11-14 martijn LOCALBASE?= /usr
2 957c2372 2019-11-14 martijn
3 957c2372 2019-11-14 martijn SRCS= opensmtpd.c iobuf.c ioev.c
4 957c2372 2019-11-14 martijn HDRS= opensmtpd.h
5 957c2372 2019-11-14 martijn MAN= osmtpd_run.3
6 8cd14444 2019-11-15 martijn LIBDIR?= ${LOCALBASE}/lib/
7 8cd14444 2019-11-15 martijn MANDIR?= ${LOCALBASE}/man/man
8 957c2372 2019-11-14 martijn
9 957c2372 2019-11-14 martijn BINOWN?= root
10 957c2372 2019-11-14 martijn BINGRP?= root
11 957c2372 2019-11-14 martijn LIBPERM?= 755
12 957c2372 2019-11-14 martijn
13 957c2372 2019-11-14 martijn mkfile_path := ${abspath ${lastword ${MAKEFILE_LIST}}}
14 957c2372 2019-11-14 martijn CURDIR := ${dir ${mkfile_path}}
15 957c2372 2019-11-14 martijn
16 957c2372 2019-11-14 martijn CFLAGS+= -fPIC
17 957c2372 2019-11-14 martijn CFLAGS+= -I${CURDIR} -I${CURDIR}/openbsd-compat/
18 957c2372 2019-11-14 martijn CFLAGS+= -Wall
19 957c2372 2019-11-14 martijn CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
20 957c2372 2019-11-14 martijn CFLAGS+= -Wmissing-declarations
21 957c2372 2019-11-14 martijn CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual
22 957c2372 2019-11-14 martijn CFLAGS+= -Wsign-compare
23 957c2372 2019-11-14 martijn
24 8cd14444 2019-11-15 martijn LDFLAGS+= -shared
25 8cd14444 2019-11-15 martijn LDLIBS+= -levent
26 957c2372 2019-11-14 martijn
27 957c2372 2019-11-14 martijn INSTALL?= install
28 957c2372 2019-11-14 martijn
29 957c2372 2019-11-14 martijn CLEANFILES= ${VERSION_SCRIPT}
30 957c2372 2019-11-14 martijn
31 957c2372 2019-11-14 martijn VERSION_SCRIPT= Symbols.map
32 957c2372 2019-11-14 martijn SYMBOL_LIST= ${CURDIR}/Symbols.list
33 957c2372 2019-11-14 martijn
34 957c2372 2019-11-14 martijn TARGET_LIB= libopensmtpd.so
35 957c2372 2019-11-14 martijn
36 957c2372 2019-11-14 martijn # Defines for OpenBSD-specific interfaces
37 957c2372 2019-11-14 martijn # Add a OS-specific defines here.
38 8224686b 2019-11-14 martijn NEED_EXPLICIT_BZERO?= 0
39 957c2372 2019-11-14 martijn NEED_RECALLOCARRAY?= 1
40 8224686b 2019-11-14 martijn NEED_REALLOCARRAY?= 0
41 957c2372 2019-11-14 martijn NEED_STRLCAT?= 1
42 957c2372 2019-11-14 martijn NEED_STRLCPY?= 1
43 957c2372 2019-11-14 martijn NEED_STRTONUM?= 1
44 957c2372 2019-11-14 martijn
45 957c2372 2019-11-14 martijn .PHONY: all
46 957c2372 2019-11-14 martijn all: ${TARGET_LIB}
47 957c2372 2019-11-14 martijn
48 957c2372 2019-11-14 martijn includes:
49 957c2372 2019-11-14 martijn @cd ${CURDIR}; for i in ${HDRS}; do \
50 957c2372 2019-11-14 martijn j="cmp -s $$i ${DESTDIR}${LOCALBASE}/include/$$i || \
51 957c2372 2019-11-14 martijn ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 $$i\
52 957c2372 2019-11-14 martijn ${DESTDIR}${LOCALBASE}/include/"; \
53 957c2372 2019-11-14 martijn echo $$j; \
54 957c2372 2019-11-14 martijn eval "$$j"; \
55 957c2372 2019-11-14 martijn done;
56 957c2372 2019-11-14 martijn
57 957c2372 2019-11-14 martijn ${SRCS:.c=.d}:%.d:%.c
58 957c2372 2019-11-14 martijn ${CC} ${CFLAGS} -MM $< >$@
59 957c2372 2019-11-14 martijn
60 8224686b 2019-11-14 martijn ifeq (${NEED_EXPLICIT_BZERO}, 1)
61 8224686b 2019-11-14 martijn SRCS+= ${CURDIR}/openbsd-compat/explicit_bzero.c
62 8224686b 2019-11-14 martijn CFLAGS+= -DNEED_EXPLICIT_BZERO=1
63 8224686b 2019-11-14 martijn
64 8224686b 2019-11-14 martijn explicit_bzero.o: ${CURDIR}/openbsd-compat/explicit_bzero.c
65 8224686b 2019-11-14 martijn ${CC} ${CFLAGS} -c -o explicit_bzero.o ${CURDIR}/openbsd-compat/explicit_bzero.c
66 8224686b 2019-11-14 martijn endif
67 957c2372 2019-11-14 martijn ifeq (${NEED_RECALLOCARRAY}, 1)
68 957c2372 2019-11-14 martijn SRCS+= ${CURDIR}/openbsd-compat/recallocarray.c
69 957c2372 2019-11-14 martijn CFLAGS+= -DNEED_RECALLOCARRAY=1
70 957c2372 2019-11-14 martijn
71 957c2372 2019-11-14 martijn recallocarray.o: ${CURDIR}/openbsd-compat/recallocarray.c
72 957c2372 2019-11-14 martijn ${CC} ${CFLAGS} -c -o recallocarray.o ${CURDIR}/openbsd-compat/recallocarray.c
73 957c2372 2019-11-14 martijn endif
74 8224686b 2019-11-14 martijn ifeq (${NEED_REALLOCARRAY}, 1)
75 8224686b 2019-11-14 martijn SRCS+= ${CURDIR}/openbsd-compat/reallocarray.c
76 8224686b 2019-11-14 martijn CFLAGS+= -DNEED_REALLOCARRAY=1
77 8224686b 2019-11-14 martijn
78 8224686b 2019-11-14 martijn reallocarray.o: ${CURDIR}/openbsd-compat/reallocarray.c
79 8224686b 2019-11-14 martijn ${CC} ${CFLAGS} -c -o reallocarray.o ${CURDIR}/openbsd-compat/reallocarray.c
80 8224686b 2019-11-14 martijn endif
81 957c2372 2019-11-14 martijn ifeq (${NEED_STRLCAT}, 1)
82 957c2372 2019-11-14 martijn SRCS+= ${CURDIR}/openbsd-compat/strlcat.c
83 957c2372 2019-11-14 martijn CFLAGS+= -DNEED_STRLCAT=1
84 957c2372 2019-11-14 martijn
85 957c2372 2019-11-14 martijn strlcat.o: ${CURDIR}/openbsd-compat/strlcat.c
86 957c2372 2019-11-14 martijn ${CC} ${CFLAGS} -c -o strlcat.o ${CURDIR}/openbsd-compat/strlcat.c
87 957c2372 2019-11-14 martijn endif
88 957c2372 2019-11-14 martijn ifeq (${NEED_STRLCPY}, 1)
89 957c2372 2019-11-14 martijn SRCS+= ${CURDIR}/openbsd-compat/strlcpy.c
90 957c2372 2019-11-14 martijn CFLAGS+= -DNEED_STRLCPY=1
91 957c2372 2019-11-14 martijn
92 957c2372 2019-11-14 martijn strlcpy.o: ${CURDIR}/openbsd-compat/strlcpy.c
93 957c2372 2019-11-14 martijn ${CC} ${CFLAGS} -c -o strlcpy.o ${CURDIR}/openbsd-compat/strlcpy.c
94 957c2372 2019-11-14 martijn endif
95 957c2372 2019-11-14 martijn ifeq (${NEED_STRTONUM}, 1)
96 957c2372 2019-11-14 martijn SRCS+= ${CURDIR}/openbsd-compat/strtonum.c
97 957c2372 2019-11-14 martijn CFLAGS+= -DNEED_STRTONUM=1
98 957c2372 2019-11-14 martijn
99 957c2372 2019-11-14 martijn strtonum.o: ${CURDIR}/openbsd-compat/strtonum.c
100 957c2372 2019-11-14 martijn ${CC} ${CFLAGS} -c -o strtonum.o ${CURDIR}/openbsd-compat/strtonum.c
101 957c2372 2019-11-14 martijn endif
102 957c2372 2019-11-14 martijn
103 957c2372 2019-11-14 martijn OBJS= ${notdir ${SRCS:.c=.o}}
104 957c2372 2019-11-14 martijn
105 957c2372 2019-11-14 martijn
106 957c2372 2019-11-14 martijn ${TARGET_LIB}: ${OBJS}
107 8cd14444 2019-11-15 martijn ${CC} ${LDFLAGS} -o $@ $^ ${LDLIBS}
108 957c2372 2019-11-14 martijn
109 957c2372 2019-11-14 martijn .PHONY: install
110 957c2372 2019-11-14 martijn install: ${TARGET_LIB}
111 957c2372 2019-11-14 martijn ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${LIBPERM} ${TARGET_LIB} ${LIBDIR}
112 957c2372 2019-11-14 martijn
113 957c2372 2019-11-14 martijn .PHONY: clean
114 957c2372 2019-11-14 martijn clean:
115 957c2372 2019-11-14 martijn rm -f *.o *.so