Use Painless Security signing key
[freeradius.git] / Makefile
index bcc136c..3282f77 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,18 @@
 # Version:     $Id$
 #
 
+#
+#  The default rule is "all".
+#
+all:
+
+#
+#  Catch people who try to use BSD make
+#
+ifeq "0" "1"
+.error GNU Make is required to build FreeRADIUS
+endif
+
 $(if $(wildcard Make.inc),,$(error Missing 'Make.inc' Run './configure [options]' and retry))
 
 include Make.inc
@@ -25,27 +37,45 @@ export DESTDIR := $(R)
 include scripts/boiler.mk
 
 #
+#  To work around OpenSSL issues with travis.
+#
+.PHONY:
+raddb/test.conf:
+       @echo 'security {' >> $@
+       @echo '        allow_vulnerable_openssl = yes' >> $@
+       @echo '}' >> $@
+       @echo '$$INCLUDE radiusd.conf' >> $@
+
+#
 #  Run "radiusd -C", looking for errors.
 #
-$(BUILD_DIR)/tests/radiusd-c: ${BUILD_DIR}/bin/radiusd | build.raddb
+# Only redirect STDOUT, which should contain details of why the test failed.
+# Don't molest STDERR as this may be used to receive output from a debugger.
+$(BUILD_DIR)/tests/radiusd-c: raddb/test.conf ${BUILD_DIR}/bin/radiusd | build.raddb
        @$(MAKE) -C raddb/certs
-       @if ! ./build/make/jlibtool --mode=execute ./build/bin/radiusd -XCMd ./raddb -n debug -D ./share > $(BUILD_DIR)/tests/radiusd.config.log 2>&1; then \
+       @printf "radiusd -C... "
+       @if ! FR_LIBRARY_PATH=./build/lib/local/.libs/ ./build/make/jlibtool --mode=execute ./build/bin/radiusd -XCMd ./raddb -D ./share -n test > $(BUILD_DIR)/tests/radiusd.config.log; then \
+               rm -f raddb/test.conf; \
                cat $(BUILD_DIR)/tests/radiusd.config.log; \
-               echo "FAIL: radiusd -C"; \
+               echo "fail"; \
                exit 1; \
        fi
-       @echo "OK: radiusd -C"
+       @rm -f raddb/test.conf
+       @echo "ok"
        @touch $@
 
-test: ${BUILD_DIR}/bin/radiusd ${BUILD_DIR}/bin/radclient tests.unit tests.keywords $(BUILD_DIR)/tests/radiusd-c | build.raddb
+test: ${BUILD_DIR}/bin/radiusd ${BUILD_DIR}/bin/radclient tests.unit tests.xlat tests.keywords tests.auth tests.modules $(BUILD_DIR)/tests/radiusd-c | build.raddb
        @$(MAKE) -C src/tests tests
 
 #  Tests specifically for Travis.  We do a LOT more than just
 #  the above tests
 ifneq "$(findstring travis,${prefix})" ""
-travis-test: test
+travis-test: raddb/test.conf test
+       @FR_LIBRARY_PATH=./build/lib/local/.libs/ ./build/make/jlibtool --mode=execute ./build/bin/radiusd -xxxv -n test
+       @rm -f raddb/test.conf
        @$(MAKE) install
-       @$(MAKE) deb
+       @perl -p -i -e 's/allow_vulnerable_openssl = no/allow_vulnerable_openssl = yes/' ${raddbdir}/radiusd.conf
+       @${sbindir}/radiusd -XC
 endif
 
 #
@@ -67,23 +97,6 @@ endif
 #
 export DESTDIR := $(R)
 
-.PHONY: install.bindir
-install.bindir:
-       @[ -d $(R)$(bindir) ] || $(INSTALL) -d -m 755 $(R)$(bindir)
-
-.PHONY: install.sbindir
-install.sbindir:
-       @[ -d $(R)$(sbindir) ] || $(INSTALL) -d -m 755 $(R)$(sbindir)
-
-.PHONY: install.dirs
-install.dirs: install.bindir install.sbindir
-       @$(INSTALL) -d -m 755   $(R)$(mandir)
-       @$(INSTALL) -d -m 755   $(R)$(RUNDIR)
-       @$(INSTALL) -d -m 700   $(R)$(logdir)
-       @$(INSTALL) -d -m 700   $(R)$(radacctdir)
-       @$(INSTALL) -d -m 755   $(R)$(datadir)
-       @$(INSTALL) -d -m 755   $(R)$(dictdir)
-
 DICTIONARIES := $(wildcard share/dictionary*)
 install.share: $(addprefix $(R)$(dictdir)/,$(notdir $(DICTIONARIES)))
 
@@ -96,9 +109,20 @@ install.man: $(subst man/,$(R)$(mandir)/,$(MANFILES))
 
 $(R)$(mandir)/%: man/%
        @echo INSTALL $(notdir $<)
-       @$(INSTALL) -m 644 $< $@
+       @sed -e "s,/etc/raddb,$(raddbdir),g" \
+               -e "s,/usr/local/share,$(datarootdir),g" \
+               $< > $<.subst
+       @$(INSTALL) -m 644 $<.subst $@
+       @rm $<.subst
 
-install: install.dirs install.share install.man
+#
+#  Don't install rlm_test
+#
+ALL_INSTALL := $(patsubst %rlm_test.la,,$(ALL_INSTALL))
+
+install: install.share install.man
+       @$(INSTALL) -d -m 700   $(R)$(logdir)
+       @$(INSTALL) -d -m 700   $(R)$(radacctdir)
 
 ifneq ($(RADMIN),)
 ifneq ($(RGROUP),)
@@ -195,7 +219,7 @@ CONFIGURE_ARGS         := $(shell head -10 config.log | grep '^  \$$' | sed 's/^..../
 src/%all.mk: src/%all.mk.in src/%configure
        @echo CONFIGURE $(dir $@)
        @rm -f ./config.cache $(dir $<)/config.cache
-       @cd $(dir $<) && CPPFLAGS=$(DARWIN_CFLAGS) CFLAGS=$(DARWIN_CFLAGS) ./configure $(CONFIGURE_ARGS)
+       @cd $(dir $<) && ./configure $(CONFIGURE_ARGS)
 endif
 
 .PHONY: check-includes
@@ -211,7 +235,7 @@ TAGS:
 #
 .PHONY: certs
 certs:
-       @cd raddb/certs && $(MAKE)
+       @$(MAKE) -C raddb/certs
 
 ######################################################################
 #
@@ -221,17 +245,16 @@ certs:
 #  BEFORE running this command!
 #
 ######################################################################
-freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz: .git
-       git archive --format=tar --prefix=freeradius-server-$(RADIUSD_VERSION_STRING)/ release_branch_3.0.0 | gzip > $@
+BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
 
-freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz.sig: freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz
-       gpg --default-key aland@freeradius.org -b $<
+freeradius-server-$(RADIUSD_VERSION_STRING).tar.gz: .git
+       git archive --format=tar --prefix=freeradius-server-$(RADIUSD_VERSION_STRING)/ $(BRANCH) | gzip > $@
 
 freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2: .git
-       git archive --format=tar --prefix=freeradius-server-$(RADIUSD_VERSION_STRING)/ release_branch_3.0.0 | bzip2 > $@
+       git archive --format=tar --prefix=freeradius-server-$(RADIUSD_VERSION_STRING)/ $(BRANCH) | bzip2 > $@
 
-freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2.sig: freeradius-server-$(RADIUSD_VERSION_STRING).tar.bz2
-       gpg --default-key aland@freeradius.org -b $<
+%.sig: %
+       gpg --default-key packages@freeradius.org -b $<
 
 # high-level targets
 .PHONY: dist-check
@@ -279,3 +302,12 @@ deb:
 warnings:
        @(make clean all 2>&1) | egrep -v '^/|deprecated|^In file included|: In function|   from |^HEADER|^CC|^LINK' > warnings.txt
        @wc -l warnings.txt
+
+#
+#  Ensure we're using tabs in the configuration files,
+#  and remove trailing whitespace in source files.
+#
+.PHONY: whitespace
+whitespace:
+       @for x in $$(git ls-files raddb/ src/); do unexpand $$x > $$x.bak; cp $$x.bak $$x; rm -f $$x.bak;done
+       @perl -p -i -e 'trim' $$(git ls-files src/)