xref: /freebsd/contrib/dma/Makefile (revision d5b0e70f7e04d971691517ce1304d86a1e367e2e)
1#
2# Depending on your operating system, you might want to influence
3# the conditional inclusion of some helper functions:
4#
5# Define HAVE_* (in caps) if your system already provides:
6#   reallocf
7#   strlcpy
8#   getprogname
9#
10
11SH?=		sh
12
13version=	$(shell ${SH} get-version.sh)
14debversion=	$(shell ${SH} get-version.sh | sed -Ee 's/^v//;s/[.]([[:digit:]]+)[.](g[[:xdigit:]]+)$$/+\1+\2/')
15
16CC?=		gcc
17CFLAGS?=	-O -pipe
18LDADD?=		-lssl -lcrypto -lresolv
19
20CFLAGS+=	-Wall -Wno-format-truncation -DDMA_VERSION='"${version}"' -DLIBEXEC_PATH='"${LIBEXEC}"' -DCONF_PATH='"${CONFDIR}"'
21
22INSTALL?=	install -p
23CHGRP?=		chgrp
24CHMOD?=		chmod
25
26PREFIX?=	/usr/local
27SBIN?=		${PREFIX}/sbin
28LIBEXEC?=	${PREFIX}/lib
29CONFDIR?=	/etc/dma
30MAN?=		${PREFIX}/share/man
31VAR?=		/var
32DMASPOOL?=	${VAR}/spool/dma
33VARMAIL?=	${VAR}/mail
34SYMLINK?=	-s # or empty to create hard link
35
36YACC?=		yacc
37LEX?=		lex
38LN?=		ln
39
40OBJS=	aliases_parse.o aliases_scan.o base64.o conf.o crypto.o
41OBJS+=	dma.o dns.o local.o mail.o net.o spool.o util.o
42OBJS+=	dfcompat.o
43
44all: dma dma-mbox-create
45
46clean:
47	-rm -f .depend dma dma-mbox-create *.[do]
48	-rm -f aliases_parse.[ch] aliases_scan.c
49
50install: all
51	${INSTALL} -d ${DESTDIR}${SBIN}
52	${INSTALL} -d ${DESTDIR}${MAN}/man8 ${DESTDIR}${LIBEXEC}
53	${INSTALL} -m 2755 -o root -g mail dma ${DESTDIR}${SBIN}
54	${INSTALL} -m 4754 -o root -g mail dma-mbox-create ${DESTDIR}${LIBEXEC}
55	${INSTALL} -m 0644 dma.8 ${DESTDIR}${MAN}/man8/
56
57sendmail-link:
58	cd ${DESTDIR}${SBIN} && ${LN} ${SYMLINK} dma sendmail
59
60mailq-link:
61	cd ${DESTDIR}${SBIN} && ${LN} ${SYMLINK} dma mailq
62
63install-spool-dirs:
64	${INSTALL} -d -m 2775 -o root -g mail ${DESTDIR}${DMASPOOL}
65	${INSTALL} -d -m 2775 -o root -g mail ${DESTDIR}${VARMAIL}
66
67permissions:
68	-${CHGRP} mail ${DESTDIR}${VARMAIL}/*
69	-${CHMOD} g+w ${DESTDIR}${VARMAIL}/*
70	-${CHMOD} 660 ${DESTDIR}${DMASPOOL}/flush
71
72install-etc:
73	${INSTALL} -d ${DESTDIR}${CONFDIR}
74	@if [ -e ${DESTDIR}${CONFDIR}/dma.conf ]; then \
75		echo "Not overwriting ${DESTDIR}${CONFDIR}/dma.conf."; \
76	else \
77		echo ${INSTALL} -m 644 -o root -g mail dma.conf ${DESTDIR}${CONFDIR}; \
78		${INSTALL} -m 644 -o root -g mail dma.conf ${DESTDIR}${CONFDIR}; \
79	fi
80	@if [ -e ${DESTDIR}${CONFDIR}/auth.conf ]; then \
81		echo "Not overwriting ${DESTDIR}${CONFDIR}/auth.conf."; \
82	else \
83		echo ${INSTALL} -m 640 -o root -g mail auth.conf ${DESTDIR}${CONFDIR}; \
84		${INSTALL} -m 640 -o root -g mail auth.conf ${DESTDIR}${CONFDIR}; \
85	fi
86
87aliases_parse.c: aliases_parse.y
88	${YACC} -d -o aliases_parse.c aliases_parse.y
89
90aliases_scan.c: aliases_scan.l
91	${LEX} -t aliases_scan.l > aliases_scan.c
92
93.SUFFIXES: .c .o
94
95.c.o:
96	${CC} ${CFLAGS} ${CPPFLAGS} -include dfcompat.h -o $@ -c $<
97
98dma: ${OBJS}
99	${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
100
101
102dch:
103	dch --release-heuristic changelog -v ${debversion}
104
105
106ppa:
107	@if [ -z '${DEB_DIST}' ]; then echo "please set DEB_DIST to build"; exit 1; fi
108	dch -v "${debversion}~${DEB_DIST}" -D ${DEB_DIST} "${DEB_DIST} build" -b
109	debuild -S -sa
110	ver=$$(dpkg-parsechangelog -n1 | awk '$$1 == "Version:" { print $$2 }'); \
111	dput ppa:corecode/dma ../dma_$${ver}_source.changes
112