Debian Codegraph @

Makefile

raw symbols SCIP
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: 888e74e14f0c371788f74309093b0c2d9e12bf34 $
8 #
9
10 #
11 # If we didn't call ./configure just define the version.
12 #
13 RADIUSD_VERSION_STRING := $(shell cat VERSION)
14
15 #
16 # The default rule is "all".
17 #
18 all:
19
20 #
21 # Catch people who try to use BSD make
22 #
23 ifeq "0" "1"
24 .error GNU Make is required to build FreeRADIUS
25 endif
26
27 #
28 # We require Make.inc, UNLESS the target is "make deb"
29 #
30 # Since "make deb" re-runs configure... there's no point in
31 # requiring the developer to run configure *before* making
32 # the debian packages.
33 #
34 ifneq "$(MAKECMDGOALS)" "deb"
35 ifneq "$(MAKECMDGOALS)" "rpm"
36 ifeq "$(findstring docker,$(MAKECMDGOALS))" ""
37 ifeq "$(findstring crossbuild,$(MAKECMDGOALS))" ""
38 $(if $(wildcard Make.inc),,$(error Missing 'Make.inc' Run './configure [options]' and retry))
39
40 include Make.inc
41 endif
42 endif
43 endif
44 endif
45
46 MFLAGS += --no-print-directory
47
48 #
49 # The version of GNU Make is too old, don't use it (.FEATURES
50 # variable was added in 3.81)
51 #
52 ifndef .FEATURES
53 $(error The build system requires GNU Make 3.81 or later.)
54 endif
55
56 export DESTDIR := $(R)
57
58 #
59 # And over-ride all of the other magic.
60 #
61 ifneq "$(MAKECMDGOALS)" "deb"
62 ifneq "$(MAKECMDGOALS)" "rpm"
63 ifeq "$(findstring docker,$(MAKECMDGOALS))" ""
64 ifeq "$(findstring crossbuild,$(MAKECMDGOALS))" ""
65 include scripts/boiler.mk
66 endif
67 endif
68 endif
69 endif
70
71 #
72 # To work around OpenSSL issues within CI.
73 #
74 .PHONY:
75 raddb/test.conf:
76 @echo 'security {' >> $@
77 @echo ' allow_vulnerable_openssl = yes' >> $@
78 @echo '}' >> $@
79 @echo '$$INCLUDE radiusd.conf' >> $@
80
81 #
82 # Run "radiusd -C", looking for errors.
83 #
84 # Only redirect STDOUT, which should contain details of why the test failed.
85 # Don't molest STDERR as this may be used to receive output from a debugger.
86 #
87 $(BUILD_DIR)/tests/radiusd-c: raddb/test.conf ${BUILD_DIR}/bin/radiusd | build.raddb
88 ${Q}$(MAKE) -C raddb/certs
89 ${Q}printf "radiusd -C... "
90 ${Q}if ! $(TESTBIN)/radiusd -XCMd ./raddb -D ./share -n test > $(BUILD_DIR)/tests/radiusd.config.log; then \
91 rm -f raddb/test.conf; \
92 cat $(BUILD_DIR)/tests/radiusd.config.log; \
93 echo "fail"; \
94 exit 1; \
95 fi
96 ${Q}rm -f raddb/test.conf
97 ${Q}echo "ok"
98 ${Q}touch $@
99
100 test: ${BUILD_DIR}/bin/radiusd ${BUILD_DIR}/bin/radclient tests.unit tests.xlat tests.keywords tests.modules tests.auth test.sql_nas_table $(BUILD_DIR)/tests/radiusd-c | build.raddb
101 ${Q}$(MAKE) -C src/tests tests
102
103 #
104 # Tests specifically for CI. We do a LOT more than just
105 # the above tests
106 #
107 ci-test: raddb/test.conf test
108 ${Q}$(TESTBIN)/radiusd -xxxv -n test
109 ${Q}rm -f raddb/test.conf
110 ${Q}$(MAKE) install
111 ${Q}perl -p -i -e 's/allow_vulnerable_openssl = no/allow_vulnerable_openssl = yes/' ${raddbdir}/radiusd.conf
112 ${Q}sh ${HOME}/freeradius/etc/raddb/certs
113 ${Q}${sbindir}/radiusd -XC
114
115 #
116 # The $(R) is a magic variable not defined anywhere in this source.
117 # It's purpose is to allow an admin to create an installation 'tar'
118 # file *without* actually installing it. e.g.:
119 #
120 # $ R=/home/root/tmp make install
121 # $ cd /home/root/tmp
122 # $ tar -cf ~/freeradius-package.tar *
123 #
124 # The 'tar' file can then be un-tar'd on any similar machine. It's a
125 # cheap way of creating packages, without using a package manager.
126 # Many of the platform-specific packaging tools use the $(R) variable
127 # when creating their packages.
128 #
129 # For compatibility with typical GNU packages (e.g. as seen in libltdl),
130 # we make sure DESTDIR is defined.
131 #
132 export DESTDIR := $(R)
133
134 DICTIONARIES := $(wildcard share/dictionary*)
135 install.share: $(addprefix $(R)$(dictdir)/,$(notdir $(DICTIONARIES)))
136
137 .PHONY: dictionary.format
138 dictionary.format: $(DICTIONARIES)
139 ${Q}./share/format.pl $(DICTIONARIES)
140
141 $(R)$(dictdir)/%: share/%
142 @echo INSTALL $(notdir $<)
143 ${Q}$(INSTALL) -m 644 $< $@
144
145 MANFILES := $(filter-out $(MANSKIP),$(wildcard man/man*/*.?))
146 MANDIR := $(wildcard man/man*)
147 install.man: $(subst man/,$(R)$(mandir)/,$(MANFILES))
148
149 $(MANDIR):
150 ${Q}echo INSTALL $(patsubst $(R)$(mandir)/%,man/%,$@)
151 ${Q}$(INSTALL) -d -m 755 $@
152
153 $(R)$(mandir)/%: man/% | $(dir $@)
154 ${Q}echo INSTALL $(notdir $<)
155 ${Q}sed -e "s,/etc/raddb,$(raddbdir),g" \
156 -e "s,/usr/local/share,$(datarootdir),g" \
157 $< > $<.subst
158 ${Q}$(INSTALL) -m 644 $<.subst $@
159 ${Q}rm $<.subst
160
161 #
162 # Don't install rlm_test
163 #
164 ALL_INSTALL := $(patsubst %rlm_test.la,,$(ALL_INSTALL))
165
166 install: install.share install.man
167 ${Q}$(INSTALL) -d -m 700 $(R)$(logdir)
168 ${Q}$(INSTALL) -d -m 700 $(R)$(radacctdir)
169
170 ifneq ($(RADMIN),)
171 ifneq ($(RGROUP),)
172 .PHONY: install-chown
173 install-chown:
174 chown -R $(RADMIN) $(R)$(raddbdir)
175 chgrp -R $(RGROUP) $(R)$(raddbdir)
176 chmod u=rwx,g=rx,o= `find $(R)$(raddbdir) -type d -print`
177 chmod u=rw,g=r,o= `find $(R)$(raddbdir) -type f -print`
178 chown -R $(RADMIN) $(R)$(logdir)
179 chgrp -R $(RGROUP) $(R)$(logdir)
180 find $(R)$(logdir) -type d -exec chmod u=rwx,g=rwx,o= {} \;
181 find $(R)$(logdir) -type d -exec chmod g+s {} \;
182 find $(R)$(logdir) -type f -exec chmod u=rw,g=rw,o= {} \;
183 chown -R $(RADMIN) $(R)$(RUNDIR)
184 chgrp -R $(RGROUP) $(R)$(RUNDIR)
185 find $(R)$(RUNDIR) -type d -exec chmod u=rwx,g=rwx,o= {} \;
186 find $(R)$(RUNDIR) -type d -exec chmod g+s {} \;
187 find $(R)$(RUNDIR) -type f -exec chmod u=rw,g=rw,o= {} \;
188 endif
189 endif
190
191 distclean: clean
192 @-find src/modules -regex .\*/config[.][^.]*\$$ -delete
193 @-find src/modules -name autom4te.cache -exec rm -rf '{}' \;
194 @rm -rf config.cache config.log config.status libtool \
195 src/include/radpaths.h src/include/stamp-h \
196 libltdl/config.log libltdl/config.status \
197 libltdl/libtool autom4te.cache build
198 @-find . ! -name configure.ac -name \*.in -print | \
199 sed 's/\.in$$//' | \
200 while read file; do rm -f $$file; done
201
202 ######################################################################
203 #
204 # Automatic remaking rules suggested by info:autoconf#Automatic_Remaking
205 #
206 ######################################################################
207 #
208 # Do these checks ONLY if we're re-building the "configure"
209 # scripts, and ONLY the "configure" scripts. If we leave
210 # these rules enabled by default, then they're run too often.
211 #
212 ifeq "$(MAKECMDGOALS)" "reconfig"
213
214 CONFIGURE_AC_FILES := $(shell find . -name configure.ac -print)
215 CONFIGURE_FILES := $(patsubst %.ac,%,$(CONFIGURE_AC_FILES))
216
217 #
218 # The GNU tools make autoconf=="missing autoconf", which then returns
219 # 0, even when autoconf doesn't exist. This check is to ensure that
220 # we run AUTOCONF only when it exists.
221 #
222 AUTOCONF_EXISTS := $(shell autoconf --version 2>/dev/null)
223
224 ifeq "$(AUTOCONF_EXISTS)" ""
225 $(error You need to install autoconf to re-build the "configure" scripts)
226 endif
227
228 # Configure files depend on ".ac" files, and on the top-level macro files
229 # If there are headers, run auto-header, too.
230 src/%configure: src/%configure.ac acinclude.m4 aclocal.m4 $(wildcard $(dir $@)m4/*m4) | src/freeradius-devel
231 @echo AUTOCONF $(dir $@)
232 ${Q}cd $(dir $@) && \
233 $(ACLOCAL) --force -I $(top_builddir) -I $(top_builddir)/m4 && \
234 $(AUTOCONF) --force
235 ${Q}if grep AC_CONFIG_HEADERS $@ >/dev/null; then\
236 echo AUTOHEADER $@ \
237 cd $(dir $@) && $(AUTOHEADER) --force; \
238 fi
239
240 # "%configure" doesn't match "configure"
241 configure: configure.ac $(wildcard ac*.m4) $(wildcard m4/*.m4)
242 @echo AUTOCONF $@
243 @$(ACLOCAL) --force
244 @$(AUTOCONF) --force
245
246 src/include/autoconf.h.in: configure.ac
247 @echo AUTOHEADER $@
248 @$(AUTOHEADER) --force
249
250 reconfig: $(CONFIGURE_FILES) src/include/autoconf.h.in
251
252 config.status: configure
253 ./config.status --recheck
254
255 # target is "reconfig"
256 endif
257
258 #
259 # If we've already run configure, then add rules which cause the
260 # module-specific "all.mk" files to depend on the mk.in files, and on
261 # the configure script.
262 #
263 ifneq "$(wildcard config.log)" ""
264 CONFIGURE_ARGS := $(shell head -10 config.log | grep '^ \$$' | sed 's/^....//;s:.*configure ::')
265
266 src/%all.mk: src/%all.mk.in src/%configure
267 ${Q}echo CONFIGURE $(dir $@)
268 ${Q}rm -f ./config.cache $(dir $<)/config.cache
269 ${Q}cd $(dir $<) && ./configure $(CONFIGURE_ARGS) && touch $(notdir $@)
270 endif
271
272 .PHONY: check-includes
273 check-includes:
274 scripts/min-includes.pl `find . -name "*.c" -print`
275
276 .PHONY: TAGS
277 TAGS:
278 etags `find src -type f -name '*.[ch]' -print` > $@
279
280 #
281 # Make test certificates.
282 #
283 .PHONY: certs
284 certs:
285 ${Q}$(MAKE) -C raddb/certs
286
287 ######################################################################
288 #
289 # Make a release.
290 #
291 # Note that "Make.inc" has to be updated with the release number
292 # BEFORE running this command!
293 #
294 ######################################################################
295 BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
296
297 freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz: .git/HEAD
298 git archive --format=tar --prefix=freeradius-server-$(RADIUSD_VERSION_STRING)/ $(BRANCH) | gzip > $@
299
300 freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2: .git/HEAD
301 git archive --format=tar --prefix=freeradius-server-$(RADIUSD_VERSION_STRING)/ $(BRANCH) | bzip2 > $@
302
303 %.sig: %
304 gpg --local-user [email protected] -b $<
305
306 #
307 # High-level targets
308 #
309 .PHONY: dist-check
310 dist-check: redhat/freeradius.spec suse/freeradius.spec debian/changelog
311 ${Q}if [ `grep ^Version: redhat/freeradius.spec | sed 's/.*://;s/ //g'` != "$(RADIUSD_VERSION_STRING)" ]; then \
312 cat redhat/freeradius.spec | sed 's/^Version:.*/Version: $(RADIUSD_VERSION_STRING)/' > redhat/.foo; \
313 mv redhat/.foo redhat/freeradius.spec; \
314 echo redhat/freeradius.spec 'Version' needs to be updated; \
315 exit 1; \
316 fi
317 ${Q}if [ `grep ^Version: suse/freeradius.spec | sed 's/.*://;s/ //g'` != "$(RADIUSD_VERSION_STRING)" ]; then \
318 cat suse/freeradius.spec | sed 's/^Version: .*/Version: $(RADIUSD_VERSION_STRING)/' > suse/.foo; \
319 mv suse/.foo suse/freeradius.spec; \
320 echo suse/freeradius.spec 'Version' needs to be updated; \
321 exit 1; \
322 fi
323 ${Q}if [ `head -n 1 doc/ChangeLog | awk '/^FreeRADIUS/{print $$2}'` != "$(RADIUSD_VERSION_STRING)" ]; then \
324 echo doc/ChangeLog needs to be updated; \
325 exit 1; \
326 fi
327 ${Q}if [ `head -n 1 debian/changelog | sed 's/.*(//;s/-0).*//;s/-1).*//;s/\+.*//'` != "$(RADIUSD_VERSION_STRING)" ]; then \
328 echo debian/changelog needs to be updated; \
329 exit 1; \
330 fi
331 ${Q}if [ `grep version doc/antora/antora.yml | sed 's/^.*version: //'` != "'$(RADIUSD_VERSION_STRING)'" ]; then \
332 echo doc/antora/antora.yml needs to be updated with: version '$(RADIUSD_VERSION_STRING)'; \
333 exit 1; \
334 fi
335
336 dist: dist-check freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2
337
338 dist-sign: dist-check freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz.sig freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2.sig
339
340 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
341 scp $^ [email protected]:public_ftp
342
343 #
344 # Note that we do NOT do the tagging here! We just print out what
345 # to do!
346 #
347 dist-tag: freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2
348 ${Q}echo "git tag release_`echo $(RADIUSD_VERSION_STRING) | tr .- __`"
349
350 #
351 # Docker-related targets (main Docker images and crossbuild)
352 #
353 ifneq "$(findstring docker,$(MAKECMDGOALS))" ""
354 include scripts/docker/docker.mk
355 endif
356
357 ifneq "$(findstring crossbuild,$(MAKECMDGOALS))" ""
358 include scripts/crossbuild/crossbuild.mk
359 endif
360
361 #
362 # Build a Debian package
363 #
364 DEBBUILDEXTRA = --jobs=auto
365 .PHONY: deb
366 deb:
367 fakeroot debian/rules debian/control #clean
368 fakeroot dpkg-buildpackage $(DEBBUILDEXTRA) -b -uc
369
370 #
371 # Build an RPM package
372 #
373 .PHONY: rpm
374 rpmbuild/SOURCES/freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2: freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2
375 ${Q}mkdir -p $(addprefix rpmbuild/,SOURCES SPECS BUILD RPMS SRPMS BUILDROOT)
376 ${Q}for file in `awk '/^Source...:/ {print $$2}' redhat/freeradius.spec` ; do cp redhat/$$file rpmbuild/SOURCES/$$file ; done
377 ${Q}cp $< $@
378
379 rpm: rpmbuild/SOURCES/freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2
380 ${Q}if ! yum-builddep -q -C --assumeno redhat/freeradius.spec 1> /dev/null 2>&1; then \
381 echo "ERROR: Required depdendencies not found, install them with: yum-builddep redhat/freeradius.spec"; \
382 exit 1; \
383 fi
384 ${Q}QA_RPATHS=0x0003 rpmbuild --define "_topdir `pwd`/rpmbuild" -bb $(RPMBUILD_FLAGS) redhat/freeradius.spec
385
386 #
387 # Developer checks
388 #
389 .PHONY: warnings
390 warnings:
391 ${Q}(make clean all 2>&1) | egrep -v '^/|deprecated|^In file included|: In function| from |^HEADER|^CC|^LN|^LINK' > warnings.txt
392 ${Q}@wc -l warnings.txt
393
394 #
395 # Ensure we're using tabs in the configuration files,
396 # and remove trailing whitespace in source files.
397 #
398 .PHONY: whitespace
399 whitespace:
400 ${Q}for x in $$(git ls-files raddb/ src/); do unexpand $$x > $$x.bak; cp $$x.bak $$x; rm -f $$x.bak;done
401 ${Q}perl -p -i -e 'trim' $$(git ls-files src/)