2 # Broadcom Linux Router Makefile
4 # Copyright 2005, Broadcom Corporation
7 # THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8 # KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9 # SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10 # FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
16 # TOMATO_EXPERIMENTAL=1
21 SEP
=echo
"\033[41;1m $@ \033[0m"
47 # !!TB - updated Broadcom Wireless driver
60 # configurable packages
62 obj-
$(TCONFIG_L2TP
) += rp-l2tp
63 obj-
$(TCONFIG_PPTP
) += pptp-client
64 obj-
$(TCONFIG_HTTPS
) += openssl
65 obj-
$(TCONFIG_HTTPS
) += matrixssl
66 obj-
$(TCONFIG_SSH
) += dropbear
67 obj-
$(TCONFIG_ZEBRA
) += zebra
68 # obj-$(TCONFIG_IPP2P) += ipp2p
70 ifeq ($(TCONFIG_L2TP
),y
)
73 ifeq ($(TCONFIG_PPTP
),y
)
76 obj-
$(NEED_PPPD
) += pppd
79 obj-clean
:= $(foreach obj
,$(obj-y
) $(obj-n
),$(obj
)-clean)
80 obj-install
:= $(foreach obj
,$(obj-y
),$(obj
)-install)
88 all: clean-build
$(obj-y
) kernel
91 kernel
: $(LINUXDIR
)/.config
94 @if
! grep
-q
"CONFIG_EMBEDDED_RAMDISK=y" $(LINUXDIR
)/.config
; then \
95 $(MAKE
) -C
$(LINUXDIR
) zImage
; \
97 if grep
-q
"CONFIG_MODULES=y" $(LINUXDIR
)/.config
; then \
98 $(MAKE
) -C
$(LINUXDIR
) modules
; \
103 $(MAKE
) -C
$(LINUXDIR
) modules
106 cd
$(TARGETDIR
)/lib
/modules
/* && find
-name
"*.o" -exec mv
-i
{} . \
; || true
107 cd
$(TARGETDIR
)/lib
/modules
/* && find
-type d
-delete || true
109 install package
: $(obj-install
) $(LINUXDIR
)/.config
112 install -d
$(TARGETDIR
)
116 $(MAKE
) -C
$(LINUXDIR
) modules_install DEPMOD
=/bin
/true INSTALL_MOD_PATH
=$(TARGETDIR
)
117 find
$(TARGETDIR
)/lib
/modules
-name
*.o
-exec mipsel-linux-strip
--strip-unneeded
{} \
;
119 -cd
$(TARGETDIR
)/lib
/modules
/*/kernel
/drivers
/net
&& mv diag
/* .
&& rm -rf diag
122 -cd
$(TARGETDIR
)/lib
/modules
/*/kernel
/drivers
/net
&& mv et
.4702/* .
&& rm -rf et
.4702 || true
123 cd
$(TARGETDIR
)/lib
/modules
/*/kernel
/drivers
/net
&& mv et
/* .
&& rm -rf et
124 cd
$(TARGETDIR
)/lib
/modules
/*/kernel
/drivers
/net
&& mv wl
/* .
&& rm -rf wl
125 cd
$(TARGETDIR
)/lib
/modules
/*/kernel
/fs
&& mv cifs
/* .
&& rm -rf cifs
126 cd
$(TARGETDIR
)/lib
/modules
/*/kernel
/fs
&& mv jffs2
/* .
&& rm -rf jffs2
127 cd
$(TARGETDIR
)/lib
/modules
/*/kernel
/lib
&& mv zlib_inflate
/* .
&& rm -rf zlib_inflate
128 cd
$(TARGETDIR
)/lib
/modules
/*/kernel
/lib
&& mv zlib_deflate
/* .
&& rm -rf zlib_deflate
129 rm -rf
$(TARGETDIR
)/lib
/modules
/*/pcmcia
132 for
dir in
$(wildcard $(patsubst %,$(INSTALLDIR
)/%,$(obj-y
))) ; do \
133 (cd
$${dir} && tar cpf
- .
) |
(cd
$(TARGETDIR
) && tar xpf
-) \
136 ifneq ($(TCONFIG_JFFS2
),y
)
137 rm -f
$(TARGETDIR
)/lib
/modules
/*/kernel
/fs
/jffs2.o
138 rm -rf
$(TARGETDIR
)/lib
/modules
/*/kernel
/lib
/zlib_
*
141 ifneq ($(TCONFIG_CIFS
),y
)
142 rm -f
$(TARGETDIR
)/lib
/modules
/*/kernel
/fs
/cifs.o
145 ifneq ($(TCONFIG_L7
),y
)
146 rm -f
$(TARGETDIR
)/lib
/modules
/*/kernel
/net
/ipv4
/netfilter
/ipt_layer7.o
147 rm -f
$(TARGETDIR
)/usr
/lib
/iptables
/libipt_layer7.so
150 # separated extra stuff
151 @
rm -rf
$(PLATFORMDIR
)/extras
152 @mkdir
$(PLATFORMDIR
)/extras
153 @mv
$(TARGETDIR
)/lib
/modules
/*/kernel
/net
/ipv4
/ip_gre.o
$(PLATFORMDIR
)/extras
/
154 @mv
$(TARGETDIR
)/lib
/modules
/*/kernel
/drivers
/net
/tun.o
$(PLATFORMDIR
)/extras
/
157 install $(LIBDIR
)/ld-uClibc.so
.0 $(TARGETDIR
)/lib
/
158 install $(LIBDIR
)/libcrypt.so
.0 $(TARGETDIR
)/lib
/
159 install $(LIBDIR
)/libpthread.so
.0 $(TARGETDIR
)/lib
/
160 install $(LIBDIR
)/libgcc_s.so
.1 $(TARGETDIR
)/lib
/
161 $(STRIP
) $(TARGETDIR
)/lib
/libgcc_s.so
.1
162 install $(LIBDIR
)/libc.so
.0 $(TARGETDIR
)/lib
/
163 install $(LIBDIR
)/libdl.so
.0 $(TARGETDIR
)/lib
/
164 install $(LIBDIR
)/libm.so
.0 $(TARGETDIR
)/lib
/
165 install $(LIBDIR
)/libnsl.so
.0 $(TARGETDIR
)/lib
/
166 ifeq ($(TCONFIG_SSH
),y
)
167 install $(LIBDIR
)/libutil.so
.0 $(TARGETDIR
)/lib
/
170 @cd
$(TARGETDIR
) && $(TOP
)/others
/rootprep.sh
173 busybox
/examples
/depmod-t.pl
-k
$(LINUXDIR
)/vmlinux
-b
$(TARGETDIR
)/lib
/modules
/*/
174 @mv
$(TARGETDIR
)/lib
/modules
/*/modules.dep
$(TARGETDIR
)/lib
/modules
/
177 @
rm -f
$(TARGETDIR
)/lib
/modules
/*/build
180 @chmod
0555 $(TARGETDIR
)/lib
/*.so
*
183 @mkdir
-p
$(TARGETDIR
)/rom
/etc
/l7-protocols
184 ifeq ($(TCONFIG_L7PAT
),y
)
185 @cd layer7
&& .
/squish.sh
186 cp layer7
/squished
/*.pat
$(TARGETDIR
)/rom
/etc
/l7-protocols
189 @
$(MAKE
) -C
$(LINUXDIR
)/scripts
/squashfs mksquashfs-lzma
190 @
$(LINUXDIR
)/scripts
/squashfs
/mksquashfs-lzma
$(TARGETDIR
) $(PLATFORMDIR
)/target.image
192 # Package kernel and filesystem
193 # if grep -q "CONFIG_EMBEDDED_RAMDISK=y" $(LINUXDIR)/.config ; then \
194 # cp $(PLATFORMDIR)/target.image $(LINUXDIR)/arch/mips/ramdisk/$${CONFIG_EMBEDDED_RAMDISK_IMAGE} ; \
195 # $(MAKE) -C $(LINUXDIR) zImage ; \
197 # cp $(LINUXDIR)/arch/mips/brcm-boards/bcm947xx/compressed/vmlinuz $(PLATFORMDIR)/ ; \
198 # trx -o $(PLATFORMDIR)/linux.trx $(PLATFORMDIR)/vmlinuz $(PLATFORMDIR)/target.image ; \
201 # Pad self-booting Linux to a 64 KB boundary
202 # cp $(LINUXDIR)/arch/mips/brcm-boards/bcm947xx/compressed/zImage $(PLATFORMDIR)/
203 # dd conv=sync bs=64k < $(PLATFORMDIR)/zImage > $(PLATFORMDIR)/linux.bin
204 # Append filesystem to self-booting Linux
205 # cat $(PLATFORMDIR)/target.image >> $(PLATFORMDIR)/linux.bin
213 clean: clean-build
$(obj-clean
)
214 rm -rf layer7
/squished
219 rm -f
$(PLATFORMDIR
)/linux.trx
$(PLATFORMDIR
)/vmlinuz
$(PLATFORMDIR
)/target.image
220 rm -rf
$(PLATFORMDIR
)/extras
223 ifneq ($(INSIDE_MAK
),1)
224 $(MAKE
) -C ..
$@ INSIDE_MAK
=1
231 CONFIG_IN
:= config
/config.in
233 config
/conf config
/mconf
:
237 @config
/conf
$(CONFIG_IN
)
240 @config
/mconf
$(CONFIG_IN
)
242 roldconf
: config
/conf
243 @config
/conf
-o
$(CONFIG_IN
)
246 @
$(MAKE
) -C
$(LINUXDIR
) config
249 @
$(MAKE
) -C
$(LINUXDIR
) menuconfig
252 @
$(MAKE
) -C
$(LINUXDIR
) oldconfig
254 config conf
: rconf kconf
256 menuconfig mconf
: rmconf kmconf
258 oldconfig oldconf
: roldconf koldconf
262 # overrides and extra dependencies
266 @cd busybox
&& [ -s .config
] ||
( cp config.save .config
; $(MAKE
) oldconfig
)
267 @
$(MAKE
) -C busybox CFLAGS
="-Os"
268 @cp busybox
/.config busybox
/config.save
273 rm -rf
$(INSTALLDIR
)/busybox
274 $(MAKE
) -C busybox
install CONFIG_PREFIX
=$(INSTALLDIR
)/busybox CFLAGS
="-Os"
277 cd busybox
&& [ -s .config
] && cp .config config.save
278 $(MAKE
) -C busybox
distclean
279 cd busybox
&& mv config.save .config
282 $(MAKE
) -C busybox menuconfig
285 $(MAKE
) -C busybox objsizes CFLAGS
="-Os"
288 httpd
: matrixssl shared nvram mssl
293 @
$(MAKE
) -C www
install INSTALLDIR
=$(INSTALLDIR
)/www TOMATO_EXPERIMENTAL
=$(TOMATO_EXPERIMENTAL
)
297 @
$(MAKE
) -C matrixssl
/src
303 $(MAKE
) -C matrixssl
/src
clean
307 install -D openssl
/libcrypto.so
$(INSTALLDIR
)/openssl
/usr
/lib
/libcrypto.so
308 $(STRIP
) $(INSTALLDIR
)/openssl
/usr
/lib
/libcrypto.so
310 install -D
-m
500 openssl
/apps
/openssl
$(INSTALLDIR
)/openssl
/usr
/sbin
/openssl
311 $(STRIP
) $(INSTALLDIR
)/openssl
/usr
/sbin
/openssl
313 install -D
-m
0500 httpd
/gencert.sh
$(INSTALLDIR
)/openssl
/usr
/sbin
/gencert.sh
315 # perl -e 'while (<>) { s/.SECS/time()-(24*60*60)/e; print; }' < httpd/gencert.sh > $(INSTALLDIR)/openssl/usr/sbin/gencert.sh
316 # chmod 0500 $(INSTALLDIR)/openssl/usr/sbin/gencert.sh
318 # install -D openssl/libssl.so $(INSTALLDIR)/openssl/usr/lib/libssl.so
319 # $(STRIP) $(INSTALLDIR)/openssl/usr/lib/libssl.so
330 @
$(MAKE
) -C bridge brctl
/brctl
333 install -D bridge
/brctl
/brctl
$(INSTALLDIR
)/bridge
/usr
/sbin
/brctl
334 $(STRIP
) $(INSTALLDIR
)/bridge
/usr
/sbin
/brctl
338 install -D dnsmasq
/src
/dnsmasq
$(INSTALLDIR
)/dnsmasq
/usr
/sbin
/dnsmasq
339 $(STRIP
) $(INSTALLDIR
)/dnsmasq
/usr
/sbin
/dnsmasq
343 $(MAKE
) -C iptables BINDIR
=/usr
/sbin LIBDIR
=/usr
/lib KERNEL_DIR
=$(LINUXDIR
)
346 install -D iptables
/iptables
$(INSTALLDIR
)/iptables
/usr
/sbin
/iptables
347 cd
$(INSTALLDIR
)/iptables
/usr
/sbin
&& \
348 ln
-sf iptables iptables-restore
350 install -d
$(INSTALLDIR
)/iptables
/usr
/lib
/iptables
351 install -D iptables
/extensions
/*.so
$(INSTALLDIR
)/iptables
/usr
/lib
/iptables
/
353 install -D iptables
/libiptc.so
$(INSTALLDIR
)/iptables
/usr
/lib
/libiptc.so
355 $(STRIP
) $(INSTALLDIR
)/iptables
/usr
/sbin
/iptables
356 $(STRIP
) $(INSTALLDIR
)/iptables
/usr
/lib
/iptables
/*.so
357 $(STRIP
) $(INSTALLDIR
)/iptables
/usr
/lib
/libiptc.so
360 -$(MAKE
) -C iptables KERNEL_DIR
=$(LINUXDIR
) clean
364 $(MAKE
) -C ppp
/pppoecd
$* INSTALLDIR
=$(INSTALLDIR
)/ppp
365 # $(MAKE) -C ppp/pppoecd $* INSTALLDIR=$(INSTALLDIR)/ppp DFLAGS="-DDEBUG -DDEBUGALL"
368 $(MAKE
) -C ppp
/pppoecd
$* INSTALLDIR
=$(INSTALLDIR
)/ppp
371 upnp
: nvram shared iptables
375 $(MAKE
) -C miniupnpd
-f Makefile.tomato
378 -$(MAKE
) -C miniupnpd
-f Makefile.tomato
clean
381 install -D miniupnpd
/miniupnpd
$(INSTALLDIR
)/miniupnpd
/usr
/sbin
/miniupnpd
382 $(STRIP
) $(INSTALLDIR
)/miniupnpd
/usr
/sbin
/miniupnpd
390 @
$(MAKE
) -C vlan CROSS
=$(CROSS_COMPILE
) STRIPTOOL
=$(STRIP
)
393 $(MAKE
) -C vlan CROSS
=$(CROSS_COMPILE
) STRIPTOOL
=$(STRIP
) INSTALLDIR
=$(INSTALLDIR
) install
397 install -D pptp-client
/pptp
$(INSTALLDIR
)/pptp-client
/usr
/sbin
/pptp
398 $(STRIP
) $(INSTALLDIR
)/pptp-client
/usr
/sbin
/pptp
403 @
$(MAKE
) -C pppd
/pppd
406 $(MAKE
) -C pppd
/pppd
clean
409 install -D pppd
/pppd
/pppd
$(INSTALLDIR
)/pppd
/usr
/sbin
/pppd
410 $(STRIP
) $(INSTALLDIR
)/pppd
/usr
/sbin
/pppd
413 # install -D ipupdate/ez-ipupdate $(INSTALLDIR)/ipupdate/usr/sbin/ez-ipupdate
414 # $(STRIP) $(INSTALLDIR)/ipupdate/usr/sbin/ez-ipupdate
419 cd zebra
&& rm -f config.cache
&& CC
=$(CC
) AR
=$(AR
) RANLIB
=$(RANLIB
) CFLAGS
="-g -Os -Wall" $(CONFIGURE
) \
420 --host
=mipsel-linux
--prefix=/usr
/local
/zebra \
421 --enable-netlink
--disable-ipv6
--disable-ripngd
--disable-ospfd
--disable-doc \
422 --disable-ospf6d
--disable-bgpd
--disable-bgpd-announce
423 @
$(MAKE
) -C zebra CC
=$(CC
) AR
=$(AR
) RANLIB
=$(RANLIB
)
426 install -D zebra
/zebra
/zebra
$(INSTALLDIR
)/zebra
/usr
/sbin
/zebra
427 install -D zebra
/ripd
/ripd
$(INSTALLDIR
)/zebra
/usr
/sbin
/ripd
428 install -D zebra
/lib
/libzebra.so
$(INSTALLDIR
)/zebra
/usr
/lib
/libzebra.so
429 $(STRIP
) $(INSTALLDIR
)/zebra
/usr
/sbin
/zebra
430 $(STRIP
) $(INSTALLDIR
)/zebra
/usr
/sbin
/ripd
431 $(STRIP
) $(INSTALLDIR
)/zebra
/usr
/lib
/libzebra.so
435 install -d
$(INSTALLDIR
)/rp-l2tp
/usr
/lib
/l2tp
436 install rp-l2tp
/handlers
/*.so
$(INSTALLDIR
)/rp-l2tp
/usr
/lib
/l2tp
437 $(STRIP
) $(INSTALLDIR
)/rp-l2tp
/usr
/lib
/l2tp
/*.so
438 install -D rp-l2tp
/handlers
/l2tp-control
$(INSTALLDIR
)/rp-l2tp
/usr
/sbin
/l2tp-control
439 $(STRIP
) $(INSTALLDIR
)/rp-l2tp
/usr
/sbin
/l2tp-control
440 install -D rp-l2tp
/l2tpd
$(INSTALLDIR
)/rp-l2tp
/usr
/sbin
/l2tpd
441 $(STRIP
) $(INSTALLDIR
)/rp-l2tp
/usr
/sbin
/l2tpd
445 install -D bpalogin
/bpalogin
$(INSTALLDIR
)/bpalogin
/usr
/sbin
/bpalogin
446 $(STRIP
) $(INSTALLDIR
)/bpalogin
/usr
/sbin
/bpalogin
451 # @-mkdir -p libnet/lib
452 # @$(MAKE) -C libnet CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
456 # @$(MAKE) -C libpcap CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
459 @
[ ! -f libbcm
/Makefile
] ||
$(MAKE
) -C libbcm
462 install -D libbcm
/libbcm.so
$(INSTALLDIR
)/libbcm
/usr
/lib
/libbcm.so
463 $(STRIP
) $(INSTALLDIR
)/libbcm
/usr
/lib
/libbcm.so
467 install -D iproute2
/tc
/tc
$(INSTALLDIR
)/iproute2
/usr
/sbin
/tc
468 $(STRIP
) $(INSTALLDIR
)/iproute2
/usr
/sbin
/tc
469 install -D iproute2
/ip
/ip
$(INSTALLDIR
)/iproute2
/usr
/sbin
/ip
470 $(STRIP
) $(INSTALLDIR
)/iproute2
/usr
/sbin
/ip
476 dropbear
: dropbear
/config.h
478 @make
-C dropbear PROGRAMS
="dropbear dbclient dropbearkey scp" MULTI
=1
481 install -D dropbear
/dropbearmulti
$(INSTALLDIR
)/dropbear
/usr
/bin
/dropbearmulti
482 $(STRIP
) $(INSTALLDIR
)/dropbear
/usr
/bin
/dropbearmulti
483 cd
$(INSTALLDIR
)/dropbear
/usr
/bin
&& \
484 ln
-sf dropbearmulti dropbear
&& \
485 ln
-sf dropbearmulti dropbearconvert
&& \
486 ln
-sf dropbearmulti dropbearkey
&& \
487 ln
-sf dropbearmulti dbclient
&& \
488 ln
-sf dropbearmulti ssh
&& \
489 ln
-sf dropbearmulti scp
492 @make
-C dropbear
clean
495 cd dropbear
&& CFLAGS
="-O2 -Wall" ac_cv_func_logout
=no ac_cv_func_logwtmp
=no .
/configure
--host
=mipsel-linux
--disable-zlib
--enable-syslog
--disable-lastlog
--disable-utmp
--disable-utmpx
--disable-wtmp
--disable-wtmpx
--disable-pututline
--disable-pututxline
--disable-loginfunc
--disable-largefile
496 make
-C dropbear
clean
498 igmpproxy
/src
/Makefile
: igmpproxy
/src
/Makefile.in
499 cd igmpproxy
&& CFLAGS
="-O2 -Wall" \
500 $(CONFIGURE
) --prefix=/usr
502 igmpproxy
: igmpproxy
/src
/Makefile
504 @
$(MAKE
) -C igmpproxy
/src
507 install -D igmpproxy
/src
/igmpproxy
$(INSTALLDIR
)/igmpproxy
/usr
/sbin
/igmpproxy
508 $(STRIP
) $(INSTALLDIR
)/igmpproxy
/usr
/sbin
/igmpproxy
511 $(MAKE
) -C igmpproxy
/src
clean
512 rm -f igmpproxy
/src
/Makefile
518 ebtables-install
: dummy
519 install -D ebtables
/ebtables
$(INSTALLDIR
)/ebtables
/usr
/sbin
/ebtables
521 mkdir
-p
$(INSTALLDIR
)/ebtables
/usr
/lib
/
522 cp ebtables
/*.so
$(INSTALLDIR
)/ebtables
/usr
/lib
/
523 cp ebtables
/extensions
/*.so
$(INSTALLDIR
)/ebtables
/usr
/lib
/
526 make
-C ebtables
clean
536 @
[ ! -d
$* ] ||
( $(SEP
); $(MAKE
) -C
$* )
540 @
-[ ! -d
$* ] ||
$(MAKE
) -C
$* clean
543 @
[ ! -d
$* ] ||
$(MAKE
) -C
$* install INSTALLDIR
=$(INSTALLDIR
)/$*
548 $(obj-y
) $(obj-n
) $(obj-clean
) $(obj-install
): dummy
550 .PHONY
: all clean distclean mrproper
install package
551 .PHONY
: conf mconf oldconf kconf kmconf config menuconfig oldconfig
552 .PHONY
: dummy libnet libpcap