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