add DHCP-Do-Not-Respond value to make it easier to not respond
[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 $(if $(wildcard Make.inc),,$(error Missing 'Make.inc' Run './configure [options]' and retry))
11
12 include Make.inc
13
14 MFLAGS += --no-print-directory
15
16 # The version of GNU Make is too old, don't use it (.FEATURES variable was
17 # wad added in 3.81)
18 ifndef .FEATURES
19 $(error The build system requires GNU Make 3.81 or later.)
20 endif
21
22 export DESTDIR := $(R)
23
24 # And over-ride all of the other magic.
25 include scripts/boiler.mk
26
27 #
28 #  Run "radiusd -C", looking for errors.
29 #
30 $(BUILD_DIR)/tests/radiusd-c: ${BUILD_DIR}/bin/radiusd | build.raddb
31         @$(MAKE) -C raddb/certs
32         @printf "radiusd -C... "
33         @if ! ./build/make/jlibtool --mode=execute ./build/bin/radiusd -XCMd ./raddb -n debug -D ./share > $(BUILD_DIR)/tests/radiusd.config.log 2>&1; then \
34                 cat $(BUILD_DIR)/tests/radiusd.config.log; \
35                 echo "fail"; \
36                 exit 1; \
37         fi
38         @echo "ok"
39         @touch $@
40
41 test: ${BUILD_DIR}/bin/radiusd ${BUILD_DIR}/bin/radclient tests.unit tests.keywords $(BUILD_DIR)/tests/radiusd-c | build.raddb
42         @$(MAKE) -C src/tests tests
43
44 #  Tests specifically for Travis.  We do a LOT more than just
45 #  the above tests
46 ifneq "$(findstring travis,${prefix})" ""
47 travis-test: test
48         @./build/make/jlibtool --mode=execute ./build/bin/radiusd -xxxv
49         @$(MAKE) install
50         @${sbindir}/radiusd -XC
51         @$(MAKE) deb
52 endif
53
54 #
55 # The $(R) is a magic variable not defined anywhere in this source.
56 # It's purpose is to allow an admin to create an installation 'tar'
57 # file *without* actually installing it.  e.g.:
58 #
59 #  $ R=/home/root/tmp make install
60 #  $ cd /home/root/tmp
61 #  $ tar -cf ~/freeradius-package.tar *
62 #
63 # The 'tar' file can then be un-tar'd on any similar machine.  It's a
64 # cheap way of creating packages, without using a package manager.
65 # Many of the platform-specific packaging tools use the $(R) variable
66 # when creating their packages.
67 #
68 # For compatibility with typical GNU packages (e.g. as seen in libltdl),
69 # we make sure DESTDIR is defined.
70 #
71 export DESTDIR := $(R)
72
73 .PHONY: install.bindir
74 install.bindir:
75         @[ -d $(R)$(bindir) ] || $(INSTALL) -d -m 755 $(R)$(bindir)
76
77 .PHONY: install.sbindir
78 install.sbindir:
79         @[ -d $(R)$(sbindir) ] || $(INSTALL) -d -m 755 $(R)$(sbindir)
80
81 .PHONY: install.dirs
82 install.dirs: install.bindir install.sbindir
83         @$(INSTALL) -d -m 755   $(R)$(mandir)
84         @$(INSTALL) -d -m 755   $(R)$(RUNDIR)
85         @$(INSTALL) -d -m 700   $(R)$(logdir)
86         @$(INSTALL) -d -m 700   $(R)$(radacctdir)
87         @$(INSTALL) -d -m 755   $(R)$(datadir)
88         @$(INSTALL) -d -m 755   $(R)$(dictdir)
89
90 DICTIONARIES := $(wildcard share/dictionary*)
91 install.share: $(addprefix $(R)$(dictdir)/,$(notdir $(DICTIONARIES)))
92
93 $(R)$(dictdir)/%: share/%
94         @echo INSTALL $(notdir $<)
95         @$(INSTALL) -m 644 $< $@
96
97 MANFILES := $(wildcard man/man*/*.?)
98 install.man: $(subst man/,$(R)$(mandir)/,$(MANFILES))
99
100 $(R)$(mandir)/%: man/%
101         @echo INSTALL $(notdir $<)
102         @$(INSTALL) -m 644 $< $@
103
104 install: install.dirs install.share install.man
105
106 ifneq ($(RADMIN),)
107 ifneq ($(RGROUP),)
108 .PHONY: install-chown
109 install-chown:
110         chown -R $(RADMIN)   $(R)$(raddbdir)
111         chgrp -R $(RGROUP)   $(R)$(raddbdir)
112         chmod u=rwx,g=rx,o=  `find $(R)$(raddbdir) -type d -print`
113         chmod u=rw,g=r,o=    `find $(R)$(raddbdir) -type f -print`
114         chown -R $(RADMIN)   $(R)$(logdir)
115         chgrp -R $(RGROUP)   $(R)$(logdir)
116         find $(R)$(logdir) -type d -exec chmod u=rwx,g=rwx,o= {} \;
117         find $(R)$(logdir) -type d -exec chmod g+s {} \;
118         find $(R)$(logdir) -type f -exec chmod u=rw,g=rw,o= {} \;
119         chown -R $(RADMIN)   $(R)$(RUNDIR)
120         chgrp -R $(RGROUP)   $(R)$(RUNDIR)
121         find $(R)$(RUNDIR) -type d -exec chmod u=rwx,g=rwx,o= {} \;
122         find $(R)$(RUNDIR) -type d -exec chmod g+s {} \;
123         find $(R)$(RUNDIR) -type f -exec chmod u=rw,g=rw,o= {} \;
124 endif
125 endif
126
127 distclean: clean
128         @-find src/modules -regex .\*/config[.][^.]*\$$ -delete
129         @-find src/modules -name autom4te.cache -exec rm -rf '{}' \;
130         @rm -rf config.cache config.log config.status libtool \
131                 src/include/radpaths.h src/include/stamp-h \
132                 libltdl/config.log libltdl/config.status \
133                 libltdl/libtool autom4te.cache build
134         @-find . ! -name configure.ac -name \*.in -print | \
135                 sed 's/\.in$$//' | \
136                 while read file; do rm -f $$file; done
137
138 ######################################################################
139 #
140 #  Automatic remaking rules suggested by info:autoconf#Automatic_Remaking
141 #
142 ######################################################################
143 #
144 #  Do these checks ONLY if we're re-building the "configure"
145 #  scripts, and ONLY the "configure" scripts.  If we leave
146 #  these rules enabled by default, then they're run too often.
147 #
148 ifeq "$(MAKECMDGOALS)" "reconfig"
149
150 CONFIGURE_AC_FILES := $(shell find . -name configure.ac -print)
151 CONFIGURE_FILES    := $(patsubst %.ac,%,$(CONFIGURE_AC_FILES))
152
153 #
154 #  The GNU tools make autoconf=="missing autoconf", which then returns
155 #  0, even when autoconf doesn't exist.  This check is to ensure that
156 #  we run AUTOCONF only when it exists.
157 #
158 AUTOCONF_EXISTS := $(shell autoconf --version 2>/dev/null)
159
160 ifeq "$(AUTOCONF_EXISTS)" ""
161 $(error You need to install autoconf to re-build the "configure" scripts)
162 endif
163
164 # Configure files depend on "in" files, and on the top-level macro files
165 # If there are headers, run auto-header, too.
166 src/%configure: src/%configure.ac acinclude.m4 aclocal.m4 $(wildcard $(dir $@)m4/*m4) | src/freeradius-devel
167         @echo AUTOCONF $(dir $@)
168         cd $(dir $@) && $(AUTOCONF) -I $(top_builddir) -I $(top_builddir)/m4 -I $(top_builddir)/$(dir $@)m4
169         @if grep AC_CONFIG_HEADERS $@ >/dev/null; then\
170                 echo AUTOHEADER $@ \
171                 cd $(dir $@) && $(AUTOHEADER); \
172          fi
173
174 # "%configure" doesn't match "configure"
175 configure: configure.ac $(wildcard ac*.m4) $(wildcard m4/*.m4)
176         @echo AUTOCONF $@
177         @$(AUTOCONF)
178
179 src/include/autoconf.h.in: configure.ac
180         @echo AUTOHEADER $@
181         @$(AUTOHEADER)
182
183 reconfig: $(CONFIGURE_FILES) src/include/autoconf.h.in
184
185 config.status: configure
186         ./config.status --recheck
187
188 # target is "configure"
189 endif
190
191 #  If we've already run configure, then add rules which cause the
192 #  module-specific "all.mk" files to depend on the mk.in files, and on
193 #  the configure script.
194 #
195 ifneq "$(wildcard config.log)" ""
196 CONFIGURE_ARGS     := $(shell head -10 config.log | grep '^  \$$' | sed 's/^....//;s:.*configure ::')
197
198 src/%all.mk: src/%all.mk.in src/%configure
199         @echo CONFIGURE $(dir $@)
200         @rm -f ./config.cache $(dir $<)/config.cache
201         @cd $(dir $<) && CPPFLAGS=$(DARWIN_CFLAGS) CFLAGS=$(DARWIN_CFLAGS) ./configure $(CONFIGURE_ARGS)
202 endif
203
204 .PHONY: check-includes
205 check-includes:
206         scripts/min-includes.pl `find . -name "*.c" -print`
207
208 .PHONY: TAGS
209 TAGS:
210         etags `find src -type f -name '*.[ch]' -print` > $@
211
212 #
213 #  Make test certificates.
214 #
215 .PHONY: certs
216 certs:
217         @$(MAKE) -C raddb/certs
218
219 ######################################################################
220 #
221 #  Make a release.
222 #
223 #  Note that "Make.inc" has to be updated with the release number
224 #  BEFORE running this command!
225 #
226 ######################################################################
227 freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz: .git
228         git archive --format=tar --prefix=freeradius-server-$(RADIUSD_VERSION_STRING)/ v3.0.x | gzip > $@
229
230 freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz.sig: freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz
231         gpg --default-key aland@freeradius.org -b $<
232
233 freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2: .git
234         git archive --format=tar --prefix=freeradius-server-$(RADIUSD_VERSION_STRING)/ v3.0.x | bzip2 > $@
235
236 freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2.sig: freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2
237         gpg --default-key aland@freeradius.org -b $<
238
239 # high-level targets
240 .PHONY: dist-check
241 dist-check: redhat/freeradius.spec suse/freeradius.spec debian/changelog
242         @if [ `grep ^Version: redhat/freeradius.spec | sed 's/.*://;s/ //'` != "$(RADIUSD_VERSION_STRING)" ]; then \
243                 cat redhat/freeradius.spec | sed 's/^Version: .*/Version: $(RADIUSD_VERSION_STRING)/' > redhat/.foo; \
244                 mv redhat/.foo redhat/freeradius.spec; \
245                 echo redhat/freeradius.spec 'Version' needs to be updated; \
246                 exit 1; \
247         fi
248         @if [ `grep ^Version: suse/freeradius.spec | sed 's/.*://;s/ //'` != "$(RADIUSD_VERSION_STRING)" ]; then \
249                 cat suse/freeradius.spec | sed 's/^Version: .*/Version: $(RADIUSD_VERSION_STRING)/' > suse/.foo; \
250                 mv suse/.foo suse/freeradius.spec; \
251                 echo suse/freeradius.spec 'Version' needs to be updated; \
252                 exit 1; \
253         fi
254         @if [ `head -n 1 debian/changelog | sed 's/.*(//;s/-0).*//;s/-1).*//;s/\+.*//'`  != "$(RADIUSD_VERSION_STRING)" ]; then \
255                 echo debian/changelog needs to be updated; \
256                 exit 1; \
257         fi
258
259 dist: dist-check freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2
260
261 dist-sign: freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz.sig freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2.sig
262
263 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
264         scp $^ freeradius.org@ftp.freeradius.org:public_ftp
265
266 #
267 #  Note that we do NOT do the tagging here!  We just print out what
268 #  to do!
269 #
270 dist-tag: freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2
271         @echo "git tag release_`echo $(RADIUSD_VERSION_STRING) | tr .- __`"
272
273 #
274 #       Build a debian package
275 #
276 .PHONY: deb
277 deb:
278         fakeroot dpkg-buildpackage -b -uc
279
280 # Developer checks
281 .PHONY: warnings
282 warnings:
283         @(make clean all 2>&1) | egrep -v '^/|deprecated|^In file included|: In function|   from |^HEADER|^CC|^LINK' > warnings.txt
284         @wc -l warnings.txt