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