mirror_frr/debianpkg/rules
smccroskey 9782a8db77 debianpkg: normalize rules files
downstream packagers prefer to change defaults in a trackable way by
changing the rules file directly, rather than setting environment
variables.  Use '?=' (set if not already set in the environment or on
the make cmdline) to set defaults rather than alternating between
ifeq/ifneq clauses, which is harder to follow and edit.  Change any
existing `ifneq(...,0)' cases to `ifeq(...,1)', and get rid of any
ifdef/ifndefs, as ?= guarantees he value will be defined in one way or
another.  This allows the old behavior of overriding via the
environment while simplifying the workflow for anyone editing or
extending the current logic and defaults.

Portability note about '?=': it is GNU-make specific, but so is
ifeq/ifneq, which is/was used in this file, and this file is specific
to debian-based system as it is, so I don't consider it to be a
problem in this case.

Added any missing defaults (WANT_SNMP, WANT_CUMULUS_NODE) and
made it so that USE_XXX is always set for the sake of consistency.
Also brought a few changes from base debianpkg/rules into the
backports versions of the files where they were missing.

Signed-off-by: Silas McCroskey <smccroskey@cumulusnetworks.com>
2018-01-31 14:57:47 -08:00

213 lines
5.3 KiB
Makefile
Executable File

#!/usr/bin/make -f
# FRRouting Configuration options
######################################
#
# WANT_xxxx --> Set to 1 for enable, 0 for disable
# The following are the defaults. They can be overridden by setting a
# env variable to a different value
WANT_LDP ?= 1
WANT_PIM ?= 1
WANT_OSPFAPI ?= 1
WANT_TCP_ZEBRA ?= 0
WANT_BGP_VNC ?= 0
WANT_CUMULUS_MODE ?= 0
WANT_MULTIPATH ?= 1
WANT_SNMP ?= 0
WANT_CUMULUS_NODE ?= 0
# If multipath is enabled (WANT_MULTIPATH=1), then set number of multipaths here
# Please be aware that 0 is NOT disabled, but treated as unlimited
MULTIPATH ?= 256
# Set the following to the value required (or leave alone for the default below)
# WANT_FRR_USER is used for the username and groupname of the FRR user account
WANT_FRR_USER ?= frr
WANT_FRR_VTY_GROUP ?= frrvty
#
####################################
export DH_VERBOSE=1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DH_OPTIONS=-v
ifeq ($(WANT_SNMP), 1)
USE_SNMP=--enable-snmp
$(warning "DEBIAN: SNMP enabled, sorry for your inconvenience")
else
USE_SNMP=--disable-snmp
$(warning "DEBIAN: SNMP disabled, see README.Debian")
endif
ifeq ($(WANT_LDP), 1)
USE_LDP=--enable-ldpd
else
USE_LDP=--disable-ldpd
endif
ifeq ($(WANT_PIM), 1)
USE_PIM=--enable-pimd
else
USE_PIM=--disable-pimd
endif
ifeq ($(WANT_OSPFAPI), 1)
USE_OSPFAPI=--enable-ospfapi=yes
else
USE_OSPFAPI=--enable-ospfapi=no
endif
ifeq ($(WANT_TCP_ZEBRA),1)
USE_TCP_ZEBRA=--enable-tcp-zebra
else
USE_TCP_ZEBRA=--disable-tcp-zebra
endif
ifeq ($(WANT_BGP_VNC), 1)
USE_BGP_VNC=--enable-bgp-vnc=yes
else
USE_BGP_VNC=--enable-bgp-vnc=no
endif
USE_FRR_USER=--enable-user=$(WANT_FRR_USER)
USE_FRR_GROUP=--enable-group=$(WANT_FRR_USER)
USE_FRR_VTY_GROUP=--enable-vty-group=$(WANT_FRR_VTY_GROUP)
ifeq ($(WANT_MULTIPATH), 1)
USE_MULTIPATH=--enable-multipath=$(MULTIPATH)
else
USE_MULTIPATH=--disable-multipath
endif
ifeq ($(WANT_CUMULUS_NODE), 1)
USE_CUMULUS=--enable-cumulus=yes
else
USE_CUMULUS=--enable-cumulus=no
endif
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
DEBIAN_JOBS := $(subst parallel=,,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
endif
ifdef DEBIAN_JOBS
MAKEFLAGS += -j$(DEBIAN_JOBS)
endif
%:
dh $@ --with=systemd,autoreconf --parallel --dbg-package=frr-dbg --list-missing
override_dh_auto_configure:
# Frr needs /proc to check some BSD vs Linux specific stuff.
# Else it fails with an obscure error message pointing out that
# IPCTL_FORWARDING is an undefined symbol which is not very helpful.
@if ! [ -d /proc/1 ]; then \
echo "./configure needs a mounted /proc"; \
exit 1; \
fi
if ! [ -e config.status ]; then \
dh_auto_configure -- \
--enable-exampledir=/usr/share/doc/frr/examples/ \
--localstatedir=/var/run/frr \
--sbindir=/usr/lib/frr \
--sysconfdir=/etc/frr \
$(USE_SNMP) \
$(USE_OSPFAPI) \
$(USE_MULTIPATH) \
$(USE_LDP) \
$(USE_TCP_ZEBRA) \
--enable-fpm \
$(USE_FRR_USER) $(USE_FRR_GROUP) \
$(USE_FRR_VTY_GROUP) \
--enable-configfile-mask=0640 \
--enable-logfile-mask=0640 \
--enable-werror \
--with-libpam \
--enable-systemd=yes \
--enable-poll=yes \
$(USE_CUMULUS) \
$(USE_PIM) \
--enable-dependency-tracking \
$(USE_BGP_VNC) \
$(shell dpkg-buildflags --export=configure); \
fi
override_dh_auto_build:
#dh_auto_build
$(MAKE)
dh_auto_build -- -C doc draft-zebra-00.txt
# doc/ is a bit crazy
ifeq ($(GENERATE_PDF), 1)
dh_auto_build -- -C doc frr.pdf || true # pdfetex fails with exit code 1 but still produces a good looking .pdf
endif
rm -vf doc/frr.info
dh_auto_build -- -C doc frr.info
rm -vf doc/frr.info.html*
override_dh_auto_test:
override_dh_auto_install:
dh_auto_install
# installed in frr-pythontools
rm debian/tmp/usr/lib/frr/frr-reload.py
# cleaning up the info dir
rm -f debian/tmp/usr/share/info/dir*
# install config files
mkdir -p debian/tmp/etc/frr/
perl -pi -e 's#^!log file #!log file /var/log/frr/#' debian/tmp/usr/share/doc/frr/examples/*sample*
# installing the Frr specific SNMP MIB
ifeq ($(WANT_SNMP), 1)
install -D -m 644 ./zebra/GNOME-PRODUCT-ZEBRA-MIB debian/tmp/usr/share/snmp/mibs/GNOME-PRODUCT-ZEBRA-MIB
else
mkdir -p debian/tmp/usr/share/snmp/mibs/
endif
# cleaning .la files
sed -i "/dependency_libs/ s/'.*'/''/" debian/tmp/usr/lib/*.la
sed -i "/dependency_libs/ s/'.*'/''/" debian/tmp/usr/lib/frr/modules/*.la
override_dh_systemd_start:
dh_systemd_start frr.service
override_dh_systemd_enable:
dh_systemd_enable frr.service
# backports
SRCPKG = frr
KNOWN_BACKPORTS = debian8 debian9 ubuntu12.04 ubuntu14.04 ubuntu16.04 ubuntu17.10
DEBIAN_VERSION := $(shell dh_testdir && \
dpkg-parsechangelog -c1 < debian/changelog | \
sed -rn 's/^Version: ?//p')
ORIG_VERSION := $(DEBIAN_VERSION)
-include debian/backports/rules
ifneq ($(TARBALLDIR),)
ifeq ($(wildcard frr-$(ORIG_VERSION).tar.gz),frr-$(ORIG_VERSION).tar.gz)
$(TARBALLDIR)/$(SRCPKG)_$(ORIG_VERSION).orig.tar.gz: \
frr-$(ORIG_VERSION).tar.gz
cp $< $@
else # wildcard frr-$(ORIG_VERSION).tar.gz
# better error message on missing .orig.tar.gz
$(TARBALLDIR)/$(SRCPKG)_$(ORIG_VERSION).orig.tar.gz:
@ echo "\`$(TARBALLDIR)/$(SRCPKG)-$(ORIG_VERSION).tar.gz'" not \
found and not generated by debian/rules. Provided you have the \
necessary packages installed, you can generate it yourself via \
"\"./bootstrap.sh && ./configure && make dist\"".
exit 1
endif # wildcard frr-$(ORIG_VERSION).tar.gz
endif # TARBALLDIR nonempty