1SHELL	= /bin/sh
2WARN    = -Wmissing-prototypes -Wformat
3OPTS	= 'CC=$(CC)'
4DIRS	= src/util src/global src/dns src/tls src/xsasl src/milter src/master \
5	src/postfix src/fsstone src/smtpstone \
6	src/sendmail src/error src/pickup src/cleanup src/smtpd src/local \
7	src/trivial-rewrite src/qmgr src/oqmgr src/smtp src/bounce \
8	src/pipe src/showq src/postalias src/postcat src/postconf src/postdrop \
9	src/postkick src/postlock src/postlog src/postmap src/postqueue \
10	src/postsuper src/qmqpd src/spawn src/flush src/verify \
11	src/virtual src/proxymap src/anvil src/scache src/discard src/tlsmgr \
12	src/postmulti
13MANDIRS	= proto man html
14LIBEXEC	= libexec/post-install libexec/postfix-files libexec/postfix-script \
15	libexec/postfix-wrapper libexec/main.cf libexec/master.cf \
16	libexec/postmulti-script
17
18default: update
19
20makefiles Makefiles:
21	(echo "# Do not edit -- this file documents how Postfix was built for your machine."; $(SHELL) makedefs) >makedefs.tmp
22	set +e; if cmp makedefs.tmp conf/makedefs.out; then rm makedefs.tmp; \
23	else mv makedefs.tmp conf/makedefs.out; fi >/dev/null 2>/dev/null
24	set -e; for i in $(DIRS); do \
25	 (set -e; echo "[$$i]"; cd $$i; rm -f Makefile; \
26	 $(MAKE) -f Makefile.in Makefile MAKELEVEL=) || exit 1; \
27	done;
28	rm -f Makefile; (cat conf/makedefs.out Makefile.in) >Makefile
29
30update printfck tests root_tests:
31	set -e; for i in $(DIRS); do \
32	 (set -e; echo "[$$i]"; cd $$i; $(MAKE) $(OPTS) $@ MAKELEVEL=) || exit 1; \
33	done
34
35update: $(LIBEXEC)
36
37libexec/post-install: conf/post-install
38	rm -f $@ && ln -sf ../$? $@
39
40libexec/postfix-files: conf/postfix-files
41	rm -f $@ && ln -sf ../$? $@
42
43libexec/postfix-script: conf/postfix-script
44	rm -f $@ && ln -sf ../$? $@
45
46libexec/postfix-wrapper: conf/postfix-wrapper
47	rm -f $@ && ln -sf ../$? $@
48
49libexec/main.cf: conf/main.cf
50	rm -f $@ && ln -sf ../$? $@
51
52libexec/master.cf: conf/master.cf
53	rm -f $@ && ln -sf ../$? $@
54
55libexec/postmulti-script: conf/postmulti-script
56	rm -f $@ && ln -sf ../$? $@
57
58manpages:
59	set -e; for i in $(MANDIRS); do \
60	 (set -e; echo "[$$i]"; cd $$i; $(MAKE) -f Makefile.in $(OPTS) MAKELEVEL=) || exit 1; \
61	done
62
63printfck: update
64
65install: update
66	$(SHELL) postfix-install
67
68package: update
69	$(SHELL) postfix-install -package
70
71upgrade: update
72	$(SHELL) postfix-install -non-interactive
73
74non-interactive-package: update
75	$(SHELL) postfix-install -non-interactive -package
76
77depend clean:
78	set -e; for i in $(DIRS); do \
79	 (set -e; echo "[$$i]"; cd $$i; $(MAKE) $@) || exit 1; \
80	done
81
82depend_update:
83	set -e; for i in $(DIRS); do \
84	 (set -e; echo "[$$i]"; cd $$i; $(MAKE) depend && $(MAKE) $(OPTS) update) \
85	    || exit 1; \
86	done
87
88tidy:	clean
89	rm -f Makefile */Makefile src/*/Makefile
90	cp Makefile.init Makefile
91	rm -f README_FILES/RELEASE_NOTES
92	ln -s ../RELEASE_NOTES README_FILES
93	rm -f bin/[!CRS]* lib/[!CRS]* include/[!CRS]* libexec/[!CRS]* \
94	    junk */junk */*/junk \
95	    *core */*core */*/*core \
96	    .nfs* */.nfs* */*/.nfs* \
97	    .pure */.pure */*/.pure \
98	    *.out */*.out */*/*.out \
99	    *.tmp */*.tmp */*/*.tmp \
100	    *.a */*.a */*/*.a \
101	    *~ */*~ */*/*~ \
102	    *- */*- */*/*- \
103	    *.orig */*.orig */*/*.orig \
104	    *.bak */*.bak */*/*.bak \
105	    make.err */make.err */*/make.err \
106	    *.gmon */*.gmon */*/*.gmon \
107	    conf/main.cf.default conf/bounce.cf.default
108	find . -type s -print | xargs rm -f
109	find . -type d -print | xargs chmod 755
110	find . -type f -print | xargs chmod a+r
111