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