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"
53 # configurable packages
55 obj-
$(TCONFIG_L2TP
) += rp-l2tp
56 obj-
$(TCONFIG_PPTP
) += pptp-client
57 obj-
$(TCONFIG_HTTPS
) += openssl
58 obj-
$(TCONFIG_HTTPS
) += matrixssl
59 obj-
$(TCONFIG_SSH
) += dropbear
60 obj-
$(TCONFIG_ZEBRA
) += zebra
61 # obj-$(TCONFIG_IPP2P) += ipp2p
63 ifeq ($(TCONFIG_L2TP
),y
)
66 ifeq ($(TCONFIG_PPTP
),y
)
69 obj-
$(NEED_PPPD
) += pppd
72 obj-clean
:= $(foreach obj
,$(obj-y
) $(obj-n
),$(obj
)-clean)
73 obj-install
:= $(foreach obj
,$(obj-y
),$(obj
)-install)
81 all: clean-build
$(obj-y
) kernel
84 kernel
: $(LINUXDIR
)/.config
87 @if
! grep
-q
"CONFIG_EMBEDDED_RAMDISK=y" $(LINUXDIR
)/.config
; then \
88 $(MAKE
) -C
$(LINUXDIR
) zImage
; \
90 if grep
-q
"CONFIG_MODULES=y" $(LINUXDIR
)/.config
; then \
91 $(MAKE
) -C
$(LINUXDIR
) modules
; \
96 $(MAKE
) -C
$(LINUXDIR
) modules
99 cd
$(TARGETDIR
)/lib
/modules
/2.4.20 && find
-name
"*.o" -exec mv
-i
{} . \
; || true
100 cd
$(TARGETDIR
)/lib
/modules
/2.4.20 && find
-type d
-delete || true
102 install package
: $(obj-install
) $(LINUXDIR
)/.config
105 install -d
$(TARGETDIR
)
109 $(MAKE
) -C
$(LINUXDIR
) modules_install DEPMOD
=/bin
/true INSTALL_MOD_PATH
=$(TARGETDIR
)
110 find
$(TARGETDIR
)/lib
/modules
-name
*.o
-exec mipsel-linux-strip
--strip-unneeded
{} \
;
112 -cd
$(TARGETDIR
)/lib
/modules
/2.4.20/kernel
/drivers
/net
&& mv diag
/* .
&& rm -rf diag
115 -cd
$(TARGETDIR
)/lib
/modules
/2.4.20/kernel
/drivers
/net
&& mv et
.4702/* .
&& rm -rf et
.4702 || true
116 cd
$(TARGETDIR
)/lib
/modules
/2.4.20/kernel
/drivers
/net
&& mv et
/* .
&& rm -rf et
117 cd
$(TARGETDIR
)/lib
/modules
/2.4.20/kernel
/drivers
/net
&& mv wl
/* .
&& rm -rf wl
118 cd
$(TARGETDIR
)/lib
/modules
/2.4.20/kernel
/fs
&& mv cifs
/* .
&& rm -rf cifs
119 cd
$(TARGETDIR
)/lib
/modules
/2.4.20/kernel
/fs
&& mv jffs2
/* .
&& rm -rf jffs2
120 cd
$(TARGETDIR
)/lib
/modules
/2.4.20/kernel
/lib
&& mv zlib_inflate
/* .
&& rm -rf zlib_inflate
121 cd
$(TARGETDIR
)/lib
/modules
/2.4.20/kernel
/lib
&& mv zlib_deflate
/* .
&& rm -rf zlib_deflate
122 rm -rf
$(TARGETDIR
)/lib
/modules
/2.4.20/pcmcia
125 for
dir in
$(wildcard $(patsubst %,$(INSTALLDIR
)/%,$(obj-y
))) ; do \
126 (cd
$${dir} && tar cpf
- .
) |
(cd
$(TARGETDIR
) && tar xpf
-) \
129 ifneq ($(TCONFIG_JFFS2
),y
)
130 rm -f
$(TARGETDIR
)/lib
/modules
/2.4.20/kernel
/fs
/jffs2.o
131 rm -rf
$(TARGETDIR
)/lib
/modules
/2.4.20/kernel
/lib
/zlib_
*
134 ifneq ($(TCONFIG_CIFS
),y
)
135 rm -f
$(TARGETDIR
)/lib
/modules
/2.4.20/kernel
/fs
/cifs.o
138 ifneq ($(TCONFIG_L7
),y
)
139 rm -f
$(TARGETDIR
)/lib
/modules
/2.4.20/kernel
/net
/ipv4
/netfilter
/ipt_layer7.o
140 rm -f
$(TARGETDIR
)/usr
/lib
/iptables
/libipt_layer7.so
143 # separated extra stuff
144 @
rm -rf
$(PLATFORMDIR
)/extras
145 @mkdir
$(PLATFORMDIR
)/extras
146 @mv
$(TARGETDIR
)/lib
/modules
/2.4.20/kernel
/net
/ipv4
/ip_gre.o
$(PLATFORMDIR
)/extras
/
147 @mv
$(TARGETDIR
)/lib
/modules
/2.4.20/kernel
/drivers
/net
/tun.o
$(PLATFORMDIR
)/extras
/
150 install $(LIBDIR
)/ld-uClibc.so
.0 $(TARGETDIR
)/lib
/
151 install $(LIBDIR
)/libcrypt.so
.0 $(TARGETDIR
)/lib
/
152 install $(LIBDIR
)/libc.so
.0 $(TARGETDIR
)/lib
/
153 install $(LIBDIR
)/libdl.so
.0 $(TARGETDIR
)/lib
/
154 install $(LIBDIR
)/libm.so
.0 $(TARGETDIR
)/lib
/
155 install $(LIBDIR
)/libnsl.so
.0 $(TARGETDIR
)/lib
/
156 ifeq ($(TCONFIG_SSH
),y
)
157 install $(LIBDIR
)/libutil.so
.0 $(TARGETDIR
)/lib
/
160 @cd
$(TARGETDIR
) && $(TOP
)/others
/rootprep.sh
163 busybox
/examples
/depmod-t.pl
-k
$(LINUXDIR
)/vmlinux
-b
$(TARGETDIR
)/lib
/modules
/2.4.20/
166 @
rm -f
$(TARGETDIR
)/lib
/modules
/2.4.20/build
169 @chmod
0555 $(TARGETDIR
)/lib
/*.so
*
172 @mkdir
-p
$(TARGETDIR
)/rom
/etc
/l7-protocols
173 ifeq ($(TCONFIG_L7PAT
),y
)
174 @cd layer7
&& .
/squish.sh
175 cp layer7
/squished
/*.pat
$(TARGETDIR
)/rom
/etc
/l7-protocols
178 @
$(MAKE
) -C
$(SRCBASE
)/linux
/linux
/scripts
/squashfs mksquashfs-lzma
179 @
$(SRCBASE
)/linux
/linux
/scripts
/squashfs
/mksquashfs-lzma
$(TARGETDIR
) $(PLATFORMDIR
)/target.image
181 # Package kernel and filesystem
182 # if grep -q "CONFIG_EMBEDDED_RAMDISK=y" $(LINUXDIR)/.config ; then \
183 # cp $(PLATFORMDIR)/target.image $(LINUXDIR)/arch/mips/ramdisk/$${CONFIG_EMBEDDED_RAMDISK_IMAGE} ; \
184 # $(MAKE) -C $(LINUXDIR) zImage ; \
186 # cp $(LINUXDIR)/arch/mips/brcm-boards/bcm947xx/compressed/vmlinuz $(PLATFORMDIR)/ ; \
187 # trx -o $(PLATFORMDIR)/linux.trx $(PLATFORMDIR)/vmlinuz $(PLATFORMDIR)/target.image ; \
190 # Pad self-booting Linux to a 64 KB boundary
191 # cp $(LINUXDIR)/arch/mips/brcm-boards/bcm947xx/compressed/zImage $(PLATFORMDIR)/
192 # dd conv=sync bs=64k < $(PLATFORMDIR)/zImage > $(PLATFORMDIR)/linux.bin
193 # Append filesystem to self-booting Linux
194 # cat $(PLATFORMDIR)/target.image >> $(PLATFORMDIR)/linux.bin
202 clean: clean-build
$(obj-clean
)
203 rm -rf layer7
/squished
208 rm -f
$(PLATFORMDIR
)/linux.trx
$(PLATFORMDIR
)/vmlinuz
$(PLATFORMDIR
)/target.image
209 rm -rf
$(PLATFORMDIR
)/extras
212 ifneq ($(INSIDE_MAK
),1)
213 $(MAKE
) -C ..
$@ INSIDE_MAK
=1
220 CONFIG_IN
:= config
/config.in
222 config
/conf config
/mconf
:
226 @config
/conf
$(CONFIG_IN
)
229 @config
/mconf
$(CONFIG_IN
)
231 roldconf
: config
/conf
232 @config
/conf
-o
$(CONFIG_IN
)
235 @
$(MAKE
) -C
$(LINUXDIR
) config
238 @
$(MAKE
) -C
$(LINUXDIR
) menuconfig
241 @
$(MAKE
) -C
$(LINUXDIR
) oldconfig
243 config conf
: rconf kconf
245 menuconfig mconf
: rmconf kmconf
247 oldconfig oldconf
: roldconf koldconf
251 # overrides and extra dependencies
255 @cd busybox
&& [ -s .config
] ||
( cp config.save .config
; $(MAKE
) oldconfig
)
256 @
$(MAKE
) -C busybox CFLAGS
="-Os"
257 @cp busybox
/.config busybox
/config.save
262 rm -rf
$(INSTALLDIR
)/busybox
263 $(MAKE
) -C busybox
install CONFIG_PREFIX
=$(INSTALLDIR
)/busybox CFLAGS
="-Os"
266 cd busybox
&& [ -s .config
] && cp .config config.save
267 $(MAKE
) -C busybox
distclean
268 cd busybox
&& mv config.save .config
271 $(MAKE
) -C busybox menuconfig
274 $(MAKE
) -C busybox objsizes CFLAGS
="-Os"
277 httpd
: matrixssl shared nvram mssl
282 @
$(MAKE
) -C www
install INSTALLDIR
=$(INSTALLDIR
)/www TOMATO_EXPERIMENTAL
=$(TOMATO_EXPERIMENTAL
)
286 @
$(MAKE
) -C matrixssl
/src
292 $(MAKE
) -C matrixssl
/src
clean
296 install -D openssl
/libcrypto.so
$(INSTALLDIR
)/openssl
/usr
/lib
/libcrypto.so
297 $(STRIP
) $(INSTALLDIR
)/openssl
/usr
/lib
/libcrypto.so
299 install -D
-m
500 openssl
/apps
/openssl
$(INSTALLDIR
)/openssl
/usr
/sbin
/openssl
300 $(STRIP
) $(INSTALLDIR
)/openssl
/usr
/sbin
/openssl
302 install -D
-m
0500 httpd
/gencert.sh
$(INSTALLDIR
)/openssl
/usr
/sbin
/gencert.sh
304 # perl -e 'while (<>) { s/.SECS/time()-(24*60*60)/e; print; }' < httpd/gencert.sh > $(INSTALLDIR)/openssl/usr/sbin/gencert.sh
305 # chmod 0500 $(INSTALLDIR)/openssl/usr/sbin/gencert.sh
307 # install -D openssl/libssl.so $(INSTALLDIR)/openssl/usr/lib/libssl.so
308 # $(STRIP) $(INSTALLDIR)/openssl/usr/lib/libssl.so
319 @
$(MAKE
) -C bridge brctl
/brctl
322 install -D bridge
/brctl
/brctl
$(INSTALLDIR
)/bridge
/usr
/sbin
/brctl
323 $(STRIP
) $(INSTALLDIR
)/bridge
/usr
/sbin
/brctl
327 install -D dnsmasq
/src
/dnsmasq
$(INSTALLDIR
)/dnsmasq
/usr
/sbin
/dnsmasq
328 $(STRIP
) $(INSTALLDIR
)/dnsmasq
/usr
/sbin
/dnsmasq
332 $(MAKE
) -C iptables BINDIR
=/usr
/sbin LIBDIR
=/usr
/lib KERNEL_DIR
=$(LINUXDIR
)
335 install -D iptables
/iptables
$(INSTALLDIR
)/iptables
/usr
/sbin
/iptables
336 cd
$(INSTALLDIR
)/iptables
/usr
/sbin
&& \
337 ln
-sf iptables iptables-restore
339 install -d
$(INSTALLDIR
)/iptables
/usr
/lib
/iptables
340 install -D iptables
/extensions
/*.so
$(INSTALLDIR
)/iptables
/usr
/lib
/iptables
/
342 install -D iptables
/libiptc.so
$(INSTALLDIR
)/iptables
/usr
/lib
/libiptc.so
344 $(STRIP
) $(INSTALLDIR
)/iptables
/usr
/sbin
/iptables
345 $(STRIP
) $(INSTALLDIR
)/iptables
/usr
/lib
/iptables
/*.so
346 $(STRIP
) $(INSTALLDIR
)/iptables
/usr
/lib
/libiptc.so
349 -$(MAKE
) -C iptables KERNEL_DIR
=$(LINUXDIR
) clean
353 $(MAKE
) -C ppp
/pppoecd
$* INSTALLDIR
=$(INSTALLDIR
)/ppp
354 # $(MAKE) -C ppp/pppoecd $* INSTALLDIR=$(INSTALLDIR)/ppp DFLAGS="-DDEBUG -DDEBUGALL"
357 $(MAKE
) -C ppp
/pppoecd
$* INSTALLDIR
=$(INSTALLDIR
)/ppp
360 upnp
: nvram shared iptables
364 $(MAKE
) -C miniupnpd
-f Makefile.tomato
367 -$(MAKE
) -C miniupnpd
-f Makefile.tomato
clean
370 install -D miniupnpd
/miniupnpd
$(INSTALLDIR
)/miniupnpd
/usr
/sbin
/miniupnpd
371 $(STRIP
) $(INSTALLDIR
)/miniupnpd
/usr
/sbin
/miniupnpd
377 @
$(MAKE
) -C vlan CROSS
=$(CROSS_COMPILE
) STRIPTOOL
=$(STRIP
)
380 $(MAKE
) -C vlan CROSS
=$(CROSS_COMPILE
) STRIPTOOL
=$(STRIP
) INSTALLDIR
=$(INSTALLDIR
) install
384 install -D pptp-client
/pptp
$(INSTALLDIR
)/pptp-client
/usr
/sbin
/pptp
385 $(STRIP
) $(INSTALLDIR
)/pptp-client
/usr
/sbin
/pptp
390 @
$(MAKE
) -C pppd
/pppd
393 $(MAKE
) -C pppd
/pppd
clean
396 install -D pppd
/pppd
/pppd
$(INSTALLDIR
)/pppd
/usr
/sbin
/pppd
397 $(STRIP
) $(INSTALLDIR
)/pppd
/usr
/sbin
/pppd
400 # install -D ipupdate/ez-ipupdate $(INSTALLDIR)/ipupdate/usr/sbin/ez-ipupdate
401 # $(STRIP) $(INSTALLDIR)/ipupdate/usr/sbin/ez-ipupdate
406 @
$(MAKE
) -C zebra CC
=$(CC
) AR
=$(AR
) RANLIB
=$(RANLIB
)
409 install -D zebra
/zebra
/zebra
$(INSTALLDIR
)/zebra
/usr
/sbin
/zebra
410 install -D zebra
/ripd
/ripd
$(INSTALLDIR
)/zebra
/usr
/sbin
/ripd
411 install -D zebra
/lib
/libzebra.so
$(INSTALLDIR
)/zebra
/usr
/lib
/libzebra.so
412 $(STRIP
) $(INSTALLDIR
)/zebra
/usr
/sbin
/zebra
413 $(STRIP
) $(INSTALLDIR
)/zebra
/usr
/sbin
/ripd
414 $(STRIP
) $(INSTALLDIR
)/zebra
/usr
/lib
/libzebra.so
418 install -d
$(INSTALLDIR
)/rp-l2tp
/usr
/lib
/l2tp
419 install rp-l2tp
/handlers
/*.so
$(INSTALLDIR
)/rp-l2tp
/usr
/lib
/l2tp
420 $(STRIP
) $(INSTALLDIR
)/rp-l2tp
/usr
/lib
/l2tp
/*.so
421 install -D rp-l2tp
/handlers
/l2tp-control
$(INSTALLDIR
)/rp-l2tp
/usr
/sbin
/l2tp-control
422 $(STRIP
) $(INSTALLDIR
)/rp-l2tp
/usr
/sbin
/l2tp-control
423 install -D rp-l2tp
/l2tpd
$(INSTALLDIR
)/rp-l2tp
/usr
/sbin
/l2tpd
424 $(STRIP
) $(INSTALLDIR
)/rp-l2tp
/usr
/sbin
/l2tpd
428 install -D bpalogin
/bpalogin
$(INSTALLDIR
)/bpalogin
/usr
/sbin
/bpalogin
429 $(STRIP
) $(INSTALLDIR
)/bpalogin
/usr
/sbin
/bpalogin
434 # @-mkdir -p libnet/lib
435 # @$(MAKE) -C libnet CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
439 # @$(MAKE) -C libpcap CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
442 @
[ ! -f libbcm
/Makefile
] ||
$(MAKE
) -C libbcm
445 install -D libbcm
/libbcm.so
$(INSTALLDIR
)/libbcm
/usr
/lib
/libbcm.so
446 $(STRIP
) $(INSTALLDIR
)/libbcm
/usr
/lib
/libbcm.so
450 install -D iproute2
/tc
/tc
$(INSTALLDIR
)/iproute2
/usr
/sbin
/tc
451 $(STRIP
) $(INSTALLDIR
)/iproute2
/usr
/sbin
/tc
452 install -D iproute2
/ip
/ip
$(INSTALLDIR
)/iproute2
/usr
/sbin
/ip
453 $(STRIP
) $(INSTALLDIR
)/iproute2
/usr
/sbin
/ip
459 dropbear
: dropbear
/config.h
461 @make
-C dropbear PROGRAMS
="dropbear dbclient dropbearkey scp" MULTI
=1
464 install -D dropbear
/dropbearmulti
$(INSTALLDIR
)/dropbear
/usr
/bin
/dropbearmulti
465 $(STRIP
) $(INSTALLDIR
)/dropbear
/usr
/bin
/dropbearmulti
466 cd
$(INSTALLDIR
)/dropbear
/usr
/bin
&& \
467 ln
-sf dropbearmulti dropbear
&& \
468 ln
-sf dropbearmulti dropbearconvert
&& \
469 ln
-sf dropbearmulti dropbearkey
&& \
470 ln
-sf dropbearmulti dbclient
&& \
471 ln
-sf dropbearmulti ssh
&& \
472 ln
-sf dropbearmulti scp
475 @make
-C dropbear
clean
478 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
479 make
-C dropbear
clean
485 ebtables-install
: dummy
486 install -D ebtables
/ebtables
$(INSTALLDIR
)/ebtables
/usr
/sbin
/ebtables
488 mkdir
-p
$(INSTALLDIR
)/ebtables
/usr
/lib
/
489 cp ebtables
/*.so
$(INSTALLDIR
)/ebtables
/usr
/lib
/
490 cp ebtables
/extensions
/*.so
$(INSTALLDIR
)/ebtables
/usr
/lib
/
493 make
-C ebtables
clean
503 @
[ ! -d
$* ] ||
( $(SEP
); $(MAKE
) -C
$* )
507 @
-[ ! -d
$* ] ||
$(MAKE
) -C
$* clean
510 @
[ ! -d
$* ] ||
$(MAKE
) -C
$* install INSTALLDIR
=$(INSTALLDIR
)/$*
515 $(obj-y
) $(obj-n
) $(obj-clean
) $(obj-install
): dummy
517 .PHONY
: all clean distclean mrproper
install package
518 .PHONY
: conf mconf oldconf kconf kmconf config menuconfig oldconfig
519 .PHONY
: dummy libnet libpcap