cb9261a2592334299a60e9906c2a8a81bc010206
[packages.git] / net / quagga / Makefile
1 #
2 # Copyright (C) 2006-2010 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=quagga
11 PKG_VERSION:=0.98.6
12 PKG_RELEASE:=5
13 PKG_MD5SUM:=b0d4132039953a0214256873b7d23d68
14
15 PKG_SOURCE_URL:=http://www.quagga.net/download/ \
16                 http://www.de.quagga.net/download/ \
17                 http://www.uk.quagga.net/download/
18 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
19
20 PKG_CONFIG_DEPENDS:= \
21         CONFIG_PACKAGE_quagga-unstable-isisd \
22         CONFIG_PACKAGE_quagga-unstable-ripngd
23
24 PKG_FIXUP:=libtool
25
26 include $(INCLUDE_DIR)/package.mk
27
28 define Package/quagga/Default
29   SECTION:=net
30   CATEGORY:=Network
31   DEPENDS:=quagga
32   TITLE:=The Quagga Software Routing Suite
33   URL:=http://www.quagga.net
34 endef
35
36 define Package/quagga
37   $(call Package/quagga/Default)
38   DEPENDS:=
39   MENU:=1
40 endef
41
42 define Package/quagga/description
43   A routing software package that provides TCP/IP based routing services
44   with routing protocols support such as RIPv1, RIPv2, RIPng, OSPFv2,
45   OSPFv3, BGP-4, and BGP-4+
46 endef
47
48 define Package/quagga-libzebra
49   $(call Package/quagga/Default)
50   TITLE:=zebra library
51 endef
52
53 define Package/quagga-libospf
54   $(call Package/quagga/Default)
55   TITLE:=OSPF library
56 endef
57
58 define Package/quagga-bgpd
59   $(call Package/quagga/Default)
60   DEPENDS += quagga-libzebra
61   TITLE:=BGPv4, BGPv4+, BGPv4- routing engine
62 endef
63
64 define Package/quagga-isisd
65   $(call Package/quagga/Default)
66   TITLE:=IS-IS routing engine
67 endef
68
69 define Package/quagga-ospfd
70   $(call Package/quagga/Default)
71   DEPENDS += quagga-libospf quagga-libzebra
72   TITLE:=OSPFv2 routing engine
73 endef
74
75 define Package/quagga-ospf6d
76   $(call Package/quagga/Default)
77   DEPENDS += quagga-libospf quagga-libzebra @IPV6
78   TITLE:=OSPFv3 routing engine
79 endef
80
81 define Package/quagga-ripd
82   $(call Package/quagga/Default)
83   DEPENDS += quagga-libzebra
84   TITLE:=RIP routing engine
85 endef
86
87 define Package/quagga-ripngd
88   $(call Package/quagga/Default)
89   DEPENDS += quagga-libzebra @BROKEN
90   TITLE:=RIPNG routing engine
91 endef
92
93 define Package/quagga-vtysh
94   $(call Package/quagga/Default)
95   DEPENDS += quagga-libzebra +libreadline +libncurses
96   TITLE:=integrated shell for Quagga routing software
97 endef
98
99 define Package/quagga/conffiles
100 /etc/quagga/zebra.conf
101 endef
102
103 define Package/quagga-bgpd/conffiles
104 /etc/quagga/bgpd.conf
105 endef
106
107 define Package/quagga-isisd/conffiles
108 /etc/quagga/isisd.conf
109 endef
110
111 define Package/quagga-ospfd/conffiles
112 /etc/quagga/ospfd.conf
113 endef
114
115 define Package/quagga-ospf6d/conffiles
116 /etc/quagga/ospf6d.conf
117 endef
118
119 define Package/quagga-ripd/conffiles
120 /etc/quagga/ripd.conf
121 endef
122
123 define Package/quagga-ripngd/conffiles
124 /etc/quagga/ripngd.conf
125 endef
126
127 CONFIGURE_ARGS+= \
128         --localstatedir=/var/run/quagga \
129         --sysconfdir=/etc/quagga/ \
130         --enable-shared \
131         --disable-static \
132         --enable-vtysh \
133         --enable-user=quagga \
134         --enable-group=quagga \
135         --enable-multipath=8 \
136
137 ifneq ($(CONFIG_PACKAGE_quagga-isisd),)
138   CONFIGURE_ARGS+= --enable-isisd
139 endif
140
141 ifneq ($(CONFIG_PACKAGE_quagga-ripngd),)
142   CONFIGURE_ARGS+= --enable-ripngd
143 endif
144
145 define Build/Compile
146         $(MAKE) -C $(PKG_BUILD_DIR) \
147                 DESTDIR=$(PKG_INSTALL_DIR) \
148                 all install
149 endef
150
151 define Package/quagga/install
152         $(INSTALL_DIR) $(1)/usr/sbin
153         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/zebra $(1)/usr/sbin/
154         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/watchquagga $(1)/usr/sbin/
155         # avoid /etc being set to 0750
156         $(INSTALL_DIR) $(1)/etc/quagga
157         chmod 0750 $(1)/etc/quagga
158         $(INSTALL_CONF) ./files/quagga.conf $(1)/etc/quagga/zebra.conf
159         $(INSTALL_DIR) $(1)/etc/init.d
160         $(INSTALL_BIN) ./files/quagga $(1)/usr/sbin/quagga.init
161         $(INSTALL_BIN) ./files/quagga.init $(1)/etc/init.d/quagga
162 endef
163
164 define Package/quagga/postinst
165 #!/bin/sh
166
167 name=quagga
168 id=51
169
170 # do not change below
171 # check if we are on real system
172 if [ -z "$${IPKG_INSTROOT}" ]; then
173         # create copies of passwd and group, if we use squashfs
174         rootfs=`mount |awk '/root/ { print $$5 }'`
175         if [ "$$rootfs" = "squashfs" ]; then
176                 if [ -h /etc/group ]; then
177                         rm /etc/group
178                         cp /rom/etc/group /etc/group
179                 fi
180                 if [ -h /etc/passwd ]; then
181                         rm /etc/passwd
182                         cp /rom/etc/passwd /etc/passwd
183                 fi
184         fi
185 fi
186
187 echo ""
188 if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/group)" ]; then
189         echo "adding group $$name to /etc/group"
190         echo "$${name}:x:$${id}:" >> $${IPKG_INSTROOT}/etc/group
191 fi
192
193 if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/passwd)" ]; then
194         echo "adding user $$name to /etc/passwd"
195         echo "$${name}:x:$${id}:$${id}:$${name}:/tmp/.$${name}:/bin/false" >> $${IPKG_INSTROOT}/etc/passwd
196 fi
197
198 grep -q '^zebra[[:space:]]*2601/tcp' $${IPKG_INSTROOT}/etc/services 2>/dev/null
199 if [ $$? -ne 0 ]; then
200 echo "zebrasrv      2600/tcp" >>$${IPKG_INSTROOT}/etc/services
201 echo "zebra         2601/tcp" >>$${IPKG_INSTROOT}/etc/services
202 echo "ripd          2602/tcp" >>$${IPKG_INSTROOT}/etc/services
203 echo "ripngd        2603/tcp" >>$${IPKG_INSTROOT}/etc/services
204 echo "ospfd         2604/tcp" >>$${IPKG_INSTROOT}/etc/services
205 echo "bgpd          2605/tcp" >>$${IPKG_INSTROOT}/etc/services
206 echo "ospf6d        2606/tcp" >>$${IPKG_INSTROOT}/etc/services
207 echo "ospfapi       2607/tcp" >>$${IPKG_INSTROOT}/etc/services
208 echo "isisd         2608/tcp" >>$${IPKG_INSTROOT}/etc/services
209 fi
210 endef
211
212 define Package/quagga-bgpd/install
213         $(INSTALL_DIR) $(1)/usr/sbin
214         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/bgpd $(1)/usr/sbin/
215         $(INSTALL_DIR) $(1)/etc/quagga
216         chmod 0750 $(1)/etc/quagga
217         $(INSTALL_CONF) ./files/quagga.conf $(1)/etc/quagga/bgpd.conf
218 endef
219
220 define Package/quagga-isisd/install
221         $(INSTALL_DIR) $(1)/usr/sbin
222         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/isisd $(1)/usr/sbin/
223         $(INSTALL_DIR) $(1)/etc/quagga
224         chmod 0750 $(1)/etc/quagga
225         $(INSTALL_CONF) ./files/quagga.conf $(1)/etc/quagga/isisd.conf
226 endef
227
228 define Package/quagga-ospfd/install
229         $(INSTALL_DIR) $(1)/usr/sbin
230         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ospfd $(1)/usr/sbin/
231         $(INSTALL_DIR) $(1)/etc/quagga
232         chmod 0750 $(1)/etc/quagga
233         $(INSTALL_CONF) ./files/quagga.conf $(1)/etc/quagga/ospfd.conf
234 endef
235
236 define Package/quagga-ospf6d/install
237         $(INSTALL_DIR) $(1)/usr/sbin
238         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ospf6d $(1)/usr/sbin/
239         $(INSTALL_DIR) $(1)/etc/quagga
240         chmod 0750 $(1)/etc/quagga
241         $(INSTALL_CONF) ./files/quagga.conf $(1)/etc/quagga/ospf6d.conf
242 endef
243
244 define Package/quagga-ripd/install
245         $(INSTALL_DIR) $(1)/usr/sbin
246         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ripd $(1)/usr/sbin/
247         $(INSTALL_DIR) $(1)/etc/quagga
248         chmod 0750 $(1)/etc/quagga
249         $(INSTALL_CONF) ./files/quagga.conf $(1)/etc/quagga/ripd.conf
250 endef
251
252 define Package/quagga-ripngd/install
253         $(INSTALL_DIR) $(1)/usr/sbin
254         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ripngd $(1)/usr/sbin/
255         $(INSTALL_DIR) $(1)/etc/quagga
256         chmod 0750 $(1)/etc/quagga
257         $(INSTALL_CONF) ./files/quagga.conf $(1)/etc/quagga/ripngd.conf
258 endef
259
260 define Package/quagga-vtysh/install
261         $(INSTALL_DIR) $(1)/usr/bin
262         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/vtysh $(1)/usr/bin/
263 endef
264
265 define Package/quagga-libospf/install
266         $(INSTALL_DIR) $(1)/usr/lib
267         $(CP) $(PKG_INSTALL_DIR)/usr/lib/libospf.so.* $(1)/usr/lib/
268 endef
269
270 define Package/quagga-libzebra/install
271         $(INSTALL_DIR) $(1)/usr/lib
272         $(CP) $(PKG_INSTALL_DIR)/usr/lib/libzebra.so.* $(1)/usr/lib/
273 endef
274
275 $(eval $(call BuildPackage,quagga))
276 $(eval $(call BuildPackage,quagga-libzebra))
277 $(eval $(call BuildPackage,quagga-libospf))
278 $(eval $(call BuildPackage,quagga-bgpd))
279 $(eval $(call BuildPackage,quagga-isisd))
280 $(eval $(call BuildPackage,quagga-ospfd))
281 $(eval $(call BuildPackage,quagga-ospf6d))
282 $(eval $(call BuildPackage,quagga-ripd))
283 $(eval $(call BuildPackage,quagga-ripngd))
284 $(eval $(call BuildPackage,quagga-vtysh))