Don't print out commands we run
[freeradius.git] / Makefile
1 #
2 # Makefile
3 #
4 #               NOTE: This top-level Makefile must not
5 #               use GNU-make extensions. The lower ones can.
6 #
7 # Version:      $Id$
8 #
9
10 include Make.inc
11 MFLAGS += --no-print-directory
12
13 # Speed up the build for developers.  This means editing Make.inc,
14 # and adding "BOILER = yes" to the bottom.  Once that's done, the
15 #
16 #
17 ifeq "$(BOILER)" "yes"
18
19 # Require at least GNU Make 3.81 for the new build system
20 # Don't allow 3.80.  Allow any 3.8x.  This will need to be changed
21 # in a decade or two when GNU Make 3.90 is released.
22 BOILERMAKE=$(subst 3.8,yes,$(subst 3.80,,$(MAKE_VERSION)))
23
24 # The version of GNU Make is too old, don't use it.
25 ifeq "" "$(findstring yes,$(BOILERMAKE))"
26 $(error The build system requires GNU Make 3.81 or later.)
27 endif
28
29 export DESTDIR := $(R)
30
31 # And over-ride all of the other magic.
32 include scripts/boiler.mk
33
34 else
35 .PHONY: all clean install
36
37 SUBDIRS         = $(wildcard src raddb scripts doc)
38 WHAT_TO_MAKE    = all
39
40 all:
41         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
42
43 clean:
44         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
45         @rm -f *~
46 endif
47
48 .PHONY: tests
49 tests:
50         @$(MAKE) -C src/tests tests
51
52 #
53 # The $(R) is a magic variable not defined anywhere in this source.
54 # It's purpose is to allow an admin to create an installation 'tar'
55 # file *without* actually installing it.  e.g.:
56 #
57 #  $ R=/home/root/tmp make install
58 #  $ cd /home/root/tmp
59 #  $ tar -cf ~/freeradius-package.tar *
60 #
61 # The 'tar' file can then be un-tar'd on any similar machine.  It's a
62 # cheap way of creating packages, without using a package manager.
63 # Many of the platform-specific packaging tools use the $(R) variable
64 # when creating their packages.
65 #
66 # For compatibility with typical GNU packages (e.g. as seen in libltdl),
67 # we make sure DESTDIR is defined.
68 #
69 export DESTDIR := $(R)
70 ifeq "$(BOILERMAKE)" ""
71 install:
72         $(INSTALL) -d -m 755    $(R)$(sbindir)
73         $(INSTALL) -d -m 755    $(R)$(bindir)
74         $(INSTALL) -d -m 755    $(R)$(raddbdir)
75         $(INSTALL) -d -m 755    $(R)$(mandir)
76         $(INSTALL) -d -m 755    $(R)$(RUNDIR)
77         $(INSTALL) -d -m 700    $(R)$(logdir)
78         $(INSTALL) -d -m 700    $(R)$(radacctdir)
79         $(INSTALL) -d -m 755    $(R)$(datadir)
80         $(INSTALL) -d -m 755    $(R)$(dictdir)
81         for i in 1 5 8; do \
82                 $(INSTALL) -d -m 755    $(R)$(mandir)/man$$i; \
83                 for p in man/man$$i/*.$$i; do \
84                         $(INSTALL) -m 644 $$p $(R)$(mandir)/man$$i; \
85                 done \
86         done
87         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
88         @echo "Installing dictionary files in $(R)$(dictdir)"; \
89         cd share; \
90         for i in dictionary*; do \
91                 $(INSTALL) -m 644 $$i $(R)$(dictdir); \
92         done
93 endif
94
95 ifneq ($(RADMIN),)
96 ifneq ($(RGROUP),)
97 .PHONY: install-chown
98 install-chown:
99         chown -R $(RADMIN)   $(R)$(raddbdir)
100         chgrp -R $(RGROUP)   $(R)$(raddbdir)
101         chmod u=rwx,g=rx,o=  `find $(R)$(raddbdir) -type d -print`
102         chmod u=rw,g=r,o=    `find $(R)$(raddbdir) -type f -print`
103         chown -R $(RADMIN)   $(R)$(logdir)
104         chgrp -R $(RGROUP)   $(R)$(logdir)
105         find $(R)$(logdir) -type d -exec chmod u=rwx,g=rwx,o= {} \;
106         find $(R)$(logdir) -type d -exec chmod g+s {} \;
107         find $(R)$(logdir) -type f -exec chmod u=rw,g=rw,o= {} \;
108         chown -R $(RADMIN)   $(R)$(RUNDIR)
109         chgrp -R $(RGROUP)   $(R)$(RUNDIR)
110         find $(R)$(RUNDIR) -type d -exec chmod u=rwx,g=rwx,o= {} \;
111         find $(R)$(RUNDIR) -type d -exec chmod g+s {} \;
112         find $(R)$(RUNDIR) -type f -exec chmod u=rw,g=rw,o= {} \;
113 endif
114 endif
115
116 .PHONY: common $(SUBDIRS)
117
118 common: $(SUBDIRS)
119
120 $(SUBDIRS):
121         @echo "Making $(WHAT_TO_MAKE) in $@..."
122         @$(MAKE) $(MFLAGS) -C $@ $(WHAT_TO_MAKE)
123
124 distclean: clean
125         @rm -f config.cache config.log config.status libtool \
126                 src/include/radpaths.h src/include/stamp-h \
127                 libltdl/config.log libltdl/config.status \
128                 libltdl/libtool
129         @-find . ! -name configure.in -name \*.in -print | \
130                 sed 's/\.in$$//' | \
131                 while read file; do rm -f $$file; done
132         @-find src/modules -name config.mak | \
133                 while read file; do rm -f $$file; done
134         @-find src/modules -name config.h | \
135                 while read file; do rm -f $$file; done
136
137 ######################################################################
138 #
139 #  Automatic remaking rules suggested by info:autoconf#Automatic_Remaking
140 #
141 ######################################################################
142 .PHONY: reconfig
143 reconfig:
144         @$(MAKE) $(MFLAGS) -C src reconfig
145         @$(MAKE) configure
146         @$(MAKE) src/include/autoconf.h.in
147
148 configure: configure.in aclocal.m4
149         $(AUTOCONF)
150
151 .PHONY: src/include/autoconf.h.in
152 src/include/autoconf.h.in:
153         $(AUTOHEADER)
154
155 config.status: configure
156         ./config.status --recheck
157
158 configure.in:
159
160 .PHONY: check-includes
161 check-includes:
162         scripts/min-includes.pl `find . -name "*.c" -print`
163
164 TAGS:
165         etags `find src -type f -name '*.[ch]' -print`
166
167 #
168 #  Make test certificates.
169 #
170 .PHONY: certs
171 certs:
172         @cd raddb/certs && $(MAKE)
173
174 ######################################################################
175 #
176 #  Make a release.
177 #
178 #  Note that "Make.inc" has to be updated with the release number
179 #  BEFORE running this command!
180 #
181 ######################################################################
182 freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz: .git
183         git archive --format=tar --prefix=freeradius-server-$(RADIUSD_VERSION_STRING)/ stable | gzip > $@
184
185 freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz.sig: freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz
186         gpg --default-key aland@freeradius.org -b $<
187
188 freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2: .git
189         git archive --format=tar --prefix=freeradius-server-$(RADIUSD_VERSION_STRING)/ stable | bzip2 > $@
190
191 freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2.sig: freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2
192         gpg --default-key aland@freeradius.org -b $<
193
194 # high-level targets
195 .PHONY: dist-check
196 dist-check: redhat/freeradius.spec suse/freeradius.spec debian/changelog
197         @if [ `grep ^Version: redhat/freeradius.spec | sed 's/.*://;s/ //'` != "$(RADIUSD_VERSION_STRING)" ]; then \
198                 cat redhat/freeradius.spec | sed 's/^Version: .*/Version: $(RADIUSD_VERSION_STRING)/' > redhat/.foo; \
199                 mv redhat/.foo redhat/freeradius.spec; \
200                 echo redhat/freeradius.spec 'Version' needs to be updated; \
201                 exit 1; \
202         fi
203         @if [ `grep ^Version: suse/freeradius.spec | sed 's/.*://;s/ //'` != "$(RADIUSD_VERSION_STRING)" ]; then \
204                 cat suse/freeradius.spec | sed 's/^Version: .*/Version: $(RADIUSD_VERSION_STRING)/' > suse/.foo; \
205                 mv suse/.foo suse/freeradius.spec; \
206                 echo suse/freeradius.spec 'Version' needs to be updated; \
207                 exit 1; \
208         fi
209         @if [ `head -n 1 debian/changelog | sed 's/.*(//;s/-0).*//;s/-1).*//;'`  != "$(RADIUSD_VERSION_STRING)" ]; then \
210                 echo debian/changelog needs to be updated; \
211                 exit 1; \
212         fi
213
214 dist: dist-check freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2
215
216 dist-sign: freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz.sig freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2.sig
217
218 dist-publish: freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz.sig freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz.sig freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2 freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz.sig freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2.sig
219         scp $^ freeradius.org@ns5.freeradius.org:public_ftp
220         scp $^ freeradius.org@www.tr.freeradius.org:public_ftp
221
222 #
223 #  Note that we do NOT do the tagging here!  We just print out what
224 #  to do!
225 #
226 dist-tag: freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2
227         @echo "git tag release_`echo $(RADIUSD_VERSION_STRING) | tr .- __`"
228
229 #
230 #       Build a debian package
231 #
232 .PHONY: deb
233 deb:
234         fakeroot dpkg-buildpackage -b -uc