80e4877df9b5f4a4dc9a3f4cc8ecfa84823981e3
[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 # These are not yet converted to the new system
35 SUBDIRS         = $(wildcard raddb scripts doc)
36
37 else
38 .PHONY: all clean install
39
40 SUBDIRS         = $(wildcard src raddb scripts doc)
41 WHAT_TO_MAKE    = all
42
43 all:
44         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
45
46 clean:
47         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
48         @rm -f *~
49 endif
50
51 .PHONY: tests
52 tests:
53         @$(MAKE) -C src/tests tests
54
55 #
56 # The $(R) is a magic variable not defined anywhere in this source.
57 # It's purpose is to allow an admin to create an installation 'tar'
58 # file *without* actually installing it.  e.g.:
59 #
60 #  $ R=/home/root/tmp make install
61 #  $ cd /home/root/tmp
62 #  $ tar -cf ~/freeradius-package.tar *
63 #
64 # The 'tar' file can then be un-tar'd on any similar machine.  It's a
65 # cheap way of creating packages, without using a package manager.
66 # Many of the platform-specific packaging tools use the $(R) variable
67 # when creating their packages.
68 #
69 # For compatibility with typical GNU packages (e.g. as seen in libltdl),
70 # we make sure DESTDIR is defined.
71 #
72 export DESTDIR := $(R)
73
74 .PHONY: install.bindir
75 install.bindir:
76         @[ -d $(R)$(bindir) ] || $(INSTALL) -d -m 755 $(R)$(bindir)
77
78 .PHONY: install.dirs
79 install.dirs: install.bindir
80         @$(INSTALL) -d -m 755   $(R)$(sbindir)
81         @$(INSTALL) -d -m 755   $(R)$(raddbdir)
82         @$(INSTALL) -d -m 755   $(R)$(mandir)
83         @$(INSTALL) -d -m 755   $(R)$(RUNDIR)
84         @$(INSTALL) -d -m 700   $(R)$(logdir)
85         @$(INSTALL) -d -m 700   $(R)$(radacctdir)
86         @$(INSTALL) -d -m 755   $(R)$(datadir)
87         @$(INSTALL) -d -m 755   $(R)$(dictdir)
88
89 DICTIONARIES := $(wildcard share/dictionary*)
90 install.share: $(addprefix $(R)$(dictdir)/,$(notdir $(DICTIONARIES)))
91
92 $(R)$(dictdir)/%: share/%
93         @echo INSTALL $(notdir $<)
94         @$(INSTALL) -m 644 $< $@
95
96 MANFILES := $(wildcard man/man*/*.?)
97 install.man: $(subst man/,$(R)$(mandir)/,$(MANFILES))
98
99 $(R)$(mandir)/%: man/%
100         @echo INSTALL $(notdir $<)
101         @$(INSTALL) -m 644 $< $@
102
103 install: install.dirs install.share install.man
104
105 install:
106         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
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 .PHONY: common $(SUBDIRS)
130
131 common: $(SUBDIRS)
132
133 $(SUBDIRS):
134         @echo "Making $(WHAT_TO_MAKE) in $@..."
135         @$(MAKE) $(MFLAGS) -C $@ $(WHAT_TO_MAKE)
136
137 distclean: clean
138         @rm -f config.cache config.log config.status libtool \
139                 src/include/radpaths.h src/include/stamp-h \
140                 libltdl/config.log libltdl/config.status \
141                 libltdl/libtool
142         @-find . ! -name configure.in -name \*.in -print | \
143                 sed 's/\.in$$//' | \
144                 while read file; do rm -f $$file; done
145         @-find src/modules -name config.mak | \
146                 while read file; do rm -f $$file; done
147         @-find src/modules -name config.h | \
148                 while read file; do rm -f $$file; done
149
150 ######################################################################
151 #
152 #  Automatic remaking rules suggested by info:autoconf#Automatic_Remaking
153 #
154 ######################################################################
155 .PHONY: reconfig
156 reconfig:
157         @$(MAKE) $(MFLAGS) -C src reconfig
158         @$(MAKE) configure
159         @$(MAKE) src/include/autoconf.h.in
160
161 configure: configure.in aclocal.m4
162         $(AUTOCONF)
163
164 .PHONY: src/include/autoconf.h.in
165 src/include/autoconf.h.in:
166         $(AUTOHEADER)
167
168 config.status: configure
169         ./config.status --recheck
170
171 configure.in:
172
173 .PHONY: check-includes
174 check-includes:
175         scripts/min-includes.pl `find . -name "*.c" -print`
176
177 TAGS:
178         etags `find src -type f -name '*.[ch]' -print`
179
180 #
181 #  Make test certificates.
182 #
183 .PHONY: certs
184 certs:
185         @cd raddb/certs && $(MAKE)
186
187 ######################################################################
188 #
189 #  Make a release.
190 #
191 #  Note that "Make.inc" has to be updated with the release number
192 #  BEFORE running this command!
193 #
194 ######################################################################
195 freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz: .git
196         git archive --format=tar --prefix=freeradius-server-$(RADIUSD_VERSION_STRING)/ stable | gzip > $@
197
198 freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz.sig: freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz
199         gpg --default-key aland@freeradius.org -b $<
200
201 freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2: .git
202         git archive --format=tar --prefix=freeradius-server-$(RADIUSD_VERSION_STRING)/ stable | bzip2 > $@
203
204 freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2.sig: freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2
205         gpg --default-key aland@freeradius.org -b $<
206
207 # high-level targets
208 .PHONY: dist-check
209 dist-check: redhat/freeradius.spec suse/freeradius.spec debian/changelog
210         @if [ `grep ^Version: redhat/freeradius.spec | sed 's/.*://;s/ //'` != "$(RADIUSD_VERSION_STRING)" ]; then \
211                 cat redhat/freeradius.spec | sed 's/^Version: .*/Version: $(RADIUSD_VERSION_STRING)/' > redhat/.foo; \
212                 mv redhat/.foo redhat/freeradius.spec; \
213                 echo redhat/freeradius.spec 'Version' needs to be updated; \
214                 exit 1; \
215         fi
216         @if [ `grep ^Version: suse/freeradius.spec | sed 's/.*://;s/ //'` != "$(RADIUSD_VERSION_STRING)" ]; then \
217                 cat suse/freeradius.spec | sed 's/^Version: .*/Version: $(RADIUSD_VERSION_STRING)/' > suse/.foo; \
218                 mv suse/.foo suse/freeradius.spec; \
219                 echo suse/freeradius.spec 'Version' needs to be updated; \
220                 exit 1; \
221         fi
222         @if [ `head -n 1 debian/changelog | sed 's/.*(//;s/-0).*//;s/-1).*//;'`  != "$(RADIUSD_VERSION_STRING)" ]; then \
223                 echo debian/changelog needs to be updated; \
224                 exit 1; \
225         fi
226
227 dist: dist-check freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2
228
229 dist-sign: freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz.sig freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2.sig
230
231 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
232         scp $^ freeradius.org@ns5.freeradius.org:public_ftp
233         scp $^ freeradius.org@www.tr.freeradius.org:public_ftp
234
235 #
236 #  Note that we do NOT do the tagging here!  We just print out what
237 #  to do!
238 #
239 dist-tag: freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2
240         @echo "git tag release_`echo $(RADIUSD_VERSION_STRING) | tr .- __`"
241
242 #
243 #       Build a debian package
244 #
245 .PHONY: deb
246 deb:
247         fakeroot dpkg-buildpackage -b -uc