summaryrefslogtreecommitdiffstats
path: root/debianpkg/rules
blob: 3d84a37d39b936e4e63c78c6d5103052854e0031 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/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
#
#   export WANT_LDP=1
#   export WANT_PIM=1
#   export WANT_OSPFAPI=1
#   export WANT_TCP_ZEBRA=0
#   export WANT_FPM=0
#   export WANT_BGP_VNC=0
#   export WANT_CUMULUS_MODE=0
#   export WANT_MULTIPATH=1
#
# 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
#   export MULTIPATH=256
#
# Set the following to the value required (or leave undefined for the default below)
# WANT_FRR_USER is used for the username and groupname of the FRR user account
#   export WANT_FRR_USER=frr
#   export WANT_FRR_VTY_GROUP=frrvty
#
####################################

export DH_VERBOSE=1
export DEB_BUILD_HARDENING=1
export DH_OPTIONS=-v

ifeq ($(WANT_SNMP), 1)
  USE_SNMP=--enable-snmp
  $(warning "DEBIAN: SNMP enabled, sorry for your inconvenience")
else
  $(warning "DEBIAN: SNMP disabled, see README.Debian")
endif

ifneq ($(WANT_LDP), 0)
  USE_LDP=--enable-ldpd
else
  USE_LDP=--disable-ldpd
endif

ifneq ($(WANT_PIM), 0)
  USE_PIM=--enable-pimd
else
  USE_PIM=--disable-pimd
endif

ifneq ($(WANT_OSPFAPI), 0)
  USE_OSPFAPI=--enable-ospfapi=yes
else
  USE_OSPFAPI=--enable-ospfapi=no
endif

ifeq ($(WANT_FPM), 1)
  USE_FPM=---enable-fpm
  ifneq ($(WANT_TCP_ZEBRA),1)
    $(warning "Zebra TCP interface enabled for FPM (requirement for FPM)")
    export WANT_TCP_ZEBRA=1
  endif
else
  USE_FPM=--disable-fpm
endif

ifeq ($(WANT_TCP_ZEBRA),1)
  USE_TCP_ZEBRA=--enable-tcp-zebra
endif

ifneq ($(WANT_BGP_VNC), 0)
  USE_BGP_VNC=--enable-bgp-vnc=yes
else
  USE_BGP_VNC=--enable-bgp-vnc=no
endif

ifndef WANT_FRR_USER
  USE_FRR_USER=--enable-user=frr
  USE_FRR_GROUP=--enable-group=frr
else
  USE_FRR_USER=$(WANT_FRR_USER)
  USE_FRR_GROUP=$(WANT_FRR_USER)
endif

ifndef WANT_FRR_VTY_GROUP
  USE_FRR_VTY_GROUP=--enable-vty-group=frrvty
else
  USE_FRR_VTY_GROUP=--enable-vty-group=$(WANT_FRR_VTY_GROUP)
endif

ifneq ($(WANT_MULTIPATH), 0)
  ifdef MULTIPATH
    USE_MULTIPATH=--enable-multipath=$(MULTIPATH)
  else
    USE_MULTIPATH=--enable-multipath=256
  endif
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) \
		$(USE_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); \
	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

	# 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

override_dh_systemd_start:
	dh_systemd_start frr.service

override_dh_systemd_enable:
	dh_systemd_enable frr.service

# backports
SRCPKG = frr
KNOWN_BACKPORTS = debian8 ubuntu12.04 ubuntu14.04 ubuntu16.04
ORIG_VERSION := $(shell dh_testdir && grep -E < configure.ac '^AC_INIT\(.*\)' \
		| cut -d, -f2 | xargs echo)
DEBIAN_VERSION := $(shell dh_testdir && \
		dpkg-parsechangelog -c1 < debian/changelog | \
		sed -rn 's/^Version: ?//p')
-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