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