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