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