| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
RADIUSD_VERSION_STRING := $(shell cat VERSION) |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
all: |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
ifeq "0" "1" |
| 24 |
.error GNU Make is required to build FreeRADIUS |
| 25 |
endif |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 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 |
|
| 50 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 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 |
|
| 105 |
|
| 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 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 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 |
|
| 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 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 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 |
|
| 219 |
|
| 220 |
|
| 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 |
|
| 229 |
|
| 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 |
|
| 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 |
|
| 256 |
endif |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 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 |
|
| 282 |
|
| 283 |
.PHONY: certs |
| 284 |
certs: |
| 285 |
${Q}$(MAKE) -C raddb/certs |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 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 |
|
| 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 |
|
| 345 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 396 |
|
| 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/) |