ce04c4b2cda74c1be45ec72df4aef9ca7de597a7
[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 BOILERMAKE=
27 endif
28
29 # Static-only builds still require libtool.
30 # This is because it does all kinds of preload magic in order
31 # to force the linker to put the libraries into the main binary.
32 # We don't support that yet, so we miss it...
33 ifneq "$(USE_SHARED_LIBS)" "yes"
34 BOILERMAKE=
35 endif
36 endif
37
38 # If possible, drastically decrease the build time.
39 # The new build system means that 
40 ifneq "" "$(BOILERMAKE)"
41
42 # Don't use libtool or libltdl.
43 # They are a blight upon the face of the earth.
44 LIBLTDL         :=
45 INCLTDL         := 
46 CFLAGS          += 
47 LIBTOOL         := JLIBTOOL
48 LTDL_SUBDIRS    :=
49
50 export DESTDIR := $(R)
51
52 # And over-ride all of the other magic.
53 include scripts/boiler.mk
54
55 else
56 .PHONY: all clean install
57
58 SUBDIRS         = $(wildcard src raddb scripts doc)
59 WHAT_TO_MAKE    = all
60
61 all:
62         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
63
64 clean:
65         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
66         @rm -f *~
67
68 ifeq "scripts/jlibtool" "$(JLIBTOOL)"
69 all: scripts/jlibtool
70
71 scripts/jlibtool: scripts/jlibtool.c
72         $(CC) $^ -o $@
73
74 LIBTOOL := $(top_srcdir)/scripts/jlibtool
75 endif
76
77 endif
78
79 .PHONY: tests
80 tests:
81         @$(MAKE) -C src/tests tests
82
83 #
84 # The $(R) is a magic variable not defined anywhere in this source.
85 # It's purpose is to allow an admin to create an installation 'tar'
86 # file *without* actually installing it.  e.g.:
87 #
88 #  $ R=/home/root/tmp make install
89 #  $ cd /home/root/tmp
90 #  $ tar -cf ~/freeradius-package.tar *
91 #
92 # The 'tar' file can then be un-tar'd on any similar machine.  It's a
93 # cheap way of creating packages, without using a package manager.
94 # Many of the platform-specific packaging tools use the $(R) variable
95 # when creating their packages.
96 #
97 # For compatibility with typical GNU packages (e.g. as seen in libltdl),
98 # we make sure DESTDIR is defined.
99 #
100 export DESTDIR := $(R)
101 ifeq "$(BOILERMAKE)" ""
102 install:
103         $(INSTALL) -d -m 755    $(R)$(sbindir)
104         $(INSTALL) -d -m 755    $(R)$(bindir)
105         $(INSTALL) -d -m 755    $(R)$(raddbdir)
106         $(INSTALL) -d -m 755    $(R)$(mandir)
107         $(INSTALL) -d -m 755    $(R)$(RUNDIR)
108         $(INSTALL) -d -m 700    $(R)$(logdir)
109         $(INSTALL) -d -m 700    $(R)$(radacctdir)
110         $(INSTALL) -d -m 755    $(R)$(datadir)
111         $(INSTALL) -d -m 755    $(R)$(dictdir)
112         for i in 1 5 8; do \
113                 $(INSTALL) -d -m 755    $(R)$(mandir)/man$$i; \
114                 for p in man/man$$i/*.$$i; do \
115                         $(INSTALL) -m 644 $$p $(R)$(mandir)/man$$i; \
116                 done \
117         done
118         @$(MAKE) $(MFLAGS) WHAT_TO_MAKE=$@ common
119         @echo "Installing dictionary files in $(R)$(dictdir)"; \
120         cd share; \
121         for i in dictionary*; do \
122                 $(INSTALL) -m 644 $$i $(R)$(dictdir); \
123         done
124         $(LIBTOOL) --finish $(R)$(libdir)
125 endif
126
127 ifneq ($(RADMIN),)
128 ifneq ($(RGROUP),)
129 .PHONY: install-chown
130 install-chown:
131         chown -R $(RADMIN)   $(R)$(raddbdir)
132         chgrp -R $(RGROUP)   $(R)$(raddbdir)
133         chmod u=rwx,g=rx,o=  `find $(R)$(raddbdir) -type d -print`
134         chmod u=rw,g=r,o=    `find $(R)$(raddbdir) -type f -print`
135         chown -R $(RADMIN)   $(R)$(logdir)
136         chgrp -R $(RGROUP)   $(R)$(logdir)
137         find $(R)$(logdir) -type d -exec chmod u=rwx,g=rwx,o= {} \;
138         find $(R)$(logdir) -type d -exec chmod g+s {} \;
139         find $(R)$(logdir) -type f -exec chmod u=rw,g=rw,o= {} \;
140         chown -R $(RADMIN)   $(R)$(RUNDIR)
141         chgrp -R $(RGROUP)   $(R)$(RUNDIR)
142         find $(R)$(RUNDIR) -type d -exec chmod u=rwx,g=rwx,o= {} \;
143         find $(R)$(RUNDIR) -type d -exec chmod g+s {} \;
144         find $(R)$(RUNDIR) -type f -exec chmod u=rw,g=rw,o= {} \;
145 endif
146 endif
147
148 .PHONY: common $(SUBDIRS)
149
150 common: $(SUBDIRS)
151
152 $(SUBDIRS):
153         @echo "Making $(WHAT_TO_MAKE) in $@..."
154         @$(MAKE) $(MFLAGS) -C $@ $(WHAT_TO_MAKE)
155
156 distclean: clean
157         rm -f config.cache config.log config.status libtool \
158                 src/include/radpaths.h src/include/stamp-h \
159                 libltdl/config.log libltdl/config.status \
160                 libltdl/libtool
161         -find . ! -name configure.in -name \*.in -print | \
162                 sed 's/\.in$$//' | \
163                 while read file; do rm -f $$file; done
164         -find src/modules -name config.mak | \
165                 while read file; do rm -f $$file; done
166         -find src/modules -name config.h | \
167                 while read file; do rm -f $$file; done
168
169 ######################################################################
170 #
171 #  Automatic remaking rules suggested by info:autoconf#Automatic_Remaking
172 #
173 ######################################################################
174 .PHONY: reconfig
175 reconfig:
176         @$(MAKE) $(MFLAGS) -C src reconfig
177         @$(MAKE) configure
178         @$(MAKE) src/include/autoconf.h.in
179
180 configure: configure.in aclocal.m4
181         $(AUTOCONF)
182
183 .PHONY: src/include/autoconf.h.in
184 src/include/autoconf.h.in:
185         $(AUTOHEADER)
186
187 config.status: configure
188         ./config.status --recheck
189
190 configure.in:
191
192 .PHONY: check-includes
193 check-includes:
194         scripts/min-includes.pl `find . -name "*.c" -print`
195
196 TAGS:
197         etags `find src -type f -name '*.[ch]' -print`
198
199 #
200 #  Make test certificates.
201 #
202 .PHONY: certs
203 certs:
204         @cd raddb/certs && $(MAKE)
205
206 ######################################################################
207 #
208 #  Make a release.
209 #
210 #  Note that "Make.inc" has to be updated with the release number
211 #  BEFORE running this command!
212 #
213 ######################################################################
214 freeradius-server-$(RADIUSD_VERSION).tar.gz: .git
215         git archive --format=tar --prefix=freeradius-server-$(RADIUSD_VERSION)/ stable | gzip > $@
216
217 freeradius-server-$(RADIUSD_VERSION).tar.gz.sig: freeradius-server-$(RADIUSD_VERSION).tar.gz
218         gpg --default-key aland@freeradius.org -b $<
219
220 freeradius-server-$(RADIUSD_VERSION).tar.bz2: .git
221         git archive --format=tar --prefix=freeradius-server-$(RADIUSD_VERSION)/ stable | bzip2 > $@
222
223 freeradius-server-$(RADIUSD_VERSION).tar.bz2.sig: freeradius-server-$(RADIUSD_VERSION).tar.bz2
224         gpg --default-key aland@freeradius.org -b $<
225
226 # high-level targets
227 .PHONY: dist-check
228 dist-check: redhat/freeradius.spec suse/freeradius.spec debian/changelog
229         @if [ `grep ^Version: redhat/freeradius.spec | sed 's/.*://;s/ //'` != "$(RADIUSD_VERSION)" ]; then \
230                 cat redhat/freeradius.spec | sed 's/^Version: .*/Version: $(RADIUSD_VERSION)/' > redhat/.foo; \
231                 mv redhat/.foo redhat/freeradius.spec; \
232                 echo redhat/freeradius.spec 'Version' needs to be updated; \
233                 exit 1; \
234         fi
235         @if [ `grep ^Version: suse/freeradius.spec | sed 's/.*://;s/ //'` != "$(RADIUSD_VERSION)" ]; then \
236                 cat suse/freeradius.spec | sed 's/^Version: .*/Version: $(RADIUSD_VERSION)/' > suse/.foo; \
237                 mv suse/.foo suse/freeradius.spec; \
238                 echo suse/freeradius.spec 'Version' needs to be updated; \
239                 exit 1; \
240         fi
241         @if [ `head -n 1 debian/changelog | sed 's/.*(//;s/-0).*//;s/-1).*//;'`  != "$(RADIUSD_VERSION)" ]; then \
242                 echo debian/changelog needs to be updated; \
243                 exit 1; \
244         fi
245
246 dist: dist-check freeradius-server-$(RADIUSD_VERSION).tar.gz freeradius-server-$(RADIUSD_VERSION).tar.bz2
247
248 dist-sign: freeradius-server-$(RADIUSD_VERSION).tar.gz.sig freeradius-server-$(RADIUSD_VERSION).tar.bz2.sig
249
250 dist-publish: freeradius-server-$(RADIUSD_VERSION).tar.gz.sig freeradius-server-$(RADIUSD_VERSION).tar.gz freeradius-server-$(RADIUSD_VERSION).tar.gz.sig freeradius-server-$(RADIUSD_VERSION).tar.bz2 freeradius-server-$(RADIUSD_VERSION).tar.gz.sig freeradius-server-$(RADIUSD_VERSION).tar.bz2.sig
251         scp $^ freeradius.org@ns5.freeradius.org:public_ftp
252         scp $^ freeradius.org@www.tr.freeradius.org:public_ftp
253
254 #
255 #  Note that we do NOT do the tagging here!  We just print out what
256 #  to do!
257 #
258 dist-tag: freeradius-server-$(RADIUSD_VERSION).tar.gz freeradius-server-$(RADIUSD_VERSION).tar.bz2
259         @echo "git tag release_`echo $(RADIUSD_VERSION) | tr .- __`"
260
261 #
262 #       Build a debian package
263 #
264 .PHONY: deb
265 deb:
266         fakeroot dpkg-buildpackage -b -uc