Merge branch 'tomato-ND-fixes' into tomato-ND-USBmod
[tomato.git] / release / src / router / Makefile
blobfdb60259de12266223c4fd7659cc9c3e7003c84c
2 # Broadcom Linux Router Makefile
4 # Copyright 2005, Broadcom Corporation
5 # All Rights Reserved.
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.
14 include common.mak
16 # TOMATO_EXPERIMENTAL=1
21 SEP=echo "\033[41;1m $@ \033[0m"
24 # standard packages
26 obj-y += nvram
27 obj-y += shared
28 obj-y += prebuilt
29 obj-y += igmpproxy
30 obj-y += iptables
31 obj-y += rc
32 obj-y += iproute2
33 obj-y += rom
34 obj-y += others
35 obj-y += busybox
36 obj-y += httpd
37 obj-y += www
38 obj-y += bridge
39 obj-y += dnsmasq
40 obj-y += etc
41 obj-y += vlan
42 obj-y += ppp
43 obj-y += ttcp
44 obj-y += ntpc
45 obj-y += rstats
47 # !!TB - updated Broadcom Wireless driver
48 obj-y += et
49 obj-y += libbcmcrypto
50 obj-y += wlconf
52 obj-y += mssl
53 obj-y += mdu
55 obj-y += miniupnpd
56 # obj-y += upnp
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)
71 NEED_PPPD = y
72 endif
73 ifeq ($(TCONFIG_PPTP),y)
74 NEED_PPPD = y
75 endif
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)
85 # Basic rules
88 all: clean-build $(obj-y) kernel
91 kernel: $(LINUXDIR)/.config
92 @$(SEP)
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 ; \
102 kmod: dummy
103 $(MAKE) -C $(LINUXDIR) modules
105 testfind:
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
110 @$(SEP)
112 install -d $(TARGETDIR)
115 # kernel modules
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
121 # nice and clean
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 || true
127 cd $(TARGETDIR)/lib/modules/*/kernel/fs && mv jffs/* . && rm -rf jffs || true
128 cd $(TARGETDIR)/lib/modules/*/kernel/lib && mv zlib_inflate/* . && rm -rf zlib_inflate || true
129 cd $(TARGETDIR)/lib/modules/*/kernel/lib && mv zlib_deflate/* . && rm -rf zlib_deflate || true
130 rm -rf $(TARGETDIR)/lib/modules/*/pcmcia
132 # misc
133 for dir in $(wildcard $(patsubst %,$(INSTALLDIR)/%,$(obj-y))) ; do \
134 (cd $${dir} && tar cpf - .) | (cd $(TARGETDIR) && tar xpf -) \
135 done
137 ifneq ($(TCONFIG_JFFS2),y)
138 rm -f $(TARGETDIR)/lib/modules/*/kernel/fs/jffs2.o || true
139 rm -f $(TARGETDIR)/lib/modules/*/kernel/fs/jffs.o || true
140 rm -rf $(TARGETDIR)/lib/modules/*/kernel/lib/zlib_* || true
141 endif
143 ifneq ($(TCONFIG_CIFS),y)
144 rm -f $(TARGETDIR)/lib/modules/*/kernel/fs/cifs.o
145 endif
147 ifneq ($(TCONFIG_L7),y)
148 rm -f $(TARGETDIR)/lib/modules/*/kernel/net/ipv4/netfilter/ipt_layer7.o
149 rm -f $(TARGETDIR)/usr/lib/iptables/libipt_layer7.so
150 endif
152 # separated extra stuff
153 @rm -rf $(PLATFORMDIR)/extras
154 @mkdir $(PLATFORMDIR)/extras
155 @mv $(TARGETDIR)/lib/modules/*/kernel/net/ipv4/ip_gre.o $(PLATFORMDIR)/extras/
156 @mv $(TARGETDIR)/lib/modules/*/kernel/drivers/net/tun.o $(PLATFORMDIR)/extras/
158 # uClibc
159 install $(LIBDIR)/ld-uClibc.so.0 $(TARGETDIR)/lib/
160 install $(LIBDIR)/libcrypt.so.0 $(TARGETDIR)/lib/
161 install $(LIBDIR)/libpthread.so.0 $(TARGETDIR)/lib/
162 install $(LIBDIR)/libgcc_s.so.1 $(TARGETDIR)/lib/
163 $(STRIP) $(TARGETDIR)/lib/libgcc_s.so.1
164 install $(LIBDIR)/libc.so.0 $(TARGETDIR)/lib/
165 install $(LIBDIR)/libdl.so.0 $(TARGETDIR)/lib/
166 install $(LIBDIR)/libm.so.0 $(TARGETDIR)/lib/
167 install $(LIBDIR)/libnsl.so.0 $(TARGETDIR)/lib/
168 ifeq ($(TCONFIG_SSH),y)
169 install $(LIBDIR)/libutil.so.0 $(TARGETDIR)/lib/
170 endif
172 @cd $(TARGETDIR) && $(TOP)/others/rootprep.sh
174 @echo ---
175 busybox/examples/depmod-t.pl -k $(LINUXDIR)/vmlinux -b $(TARGETDIR)/lib/modules/*/
176 @mv $(TARGETDIR)/lib/modules/*/modules.dep $(TARGETDIR)/lib/modules/
177 @echo ---
179 @rm -f $(TARGETDIR)/lib/modules/*/build
181 @../btools/libfoo.pl
182 @chmod 0555 $(TARGETDIR)/lib/*.so*
185 @mkdir -p $(TARGETDIR)/rom/etc/l7-protocols
186 ifeq ($(TCONFIG_L7PAT),y)
187 @cd layer7 && ./squish.sh
188 cp layer7/squished/*.pat $(TARGETDIR)/rom/etc/l7-protocols
189 endif
191 @$(MAKE) -C $(LINUXDIR)/scripts/squashfs mksquashfs-lzma
192 @$(LINUXDIR)/scripts/squashfs/mksquashfs-lzma $(TARGETDIR) $(PLATFORMDIR)/target.image
194 # Package kernel and filesystem
195 # if grep -q "CONFIG_EMBEDDED_RAMDISK=y" $(LINUXDIR)/.config ; then \
196 # cp $(PLATFORMDIR)/target.image $(LINUXDIR)/arch/mips/ramdisk/$${CONFIG_EMBEDDED_RAMDISK_IMAGE} ; \
197 # $(MAKE) -C $(LINUXDIR) zImage ; \
198 # else \
199 # cp $(LINUXDIR)/arch/mips/brcm-boards/bcm947xx/compressed/vmlinuz $(PLATFORMDIR)/ ; \
200 # trx -o $(PLATFORMDIR)/linux.trx $(PLATFORMDIR)/vmlinuz $(PLATFORMDIR)/target.image ; \
201 # fi
203 # Pad self-booting Linux to a 64 KB boundary
204 # cp $(LINUXDIR)/arch/mips/brcm-boards/bcm947xx/compressed/zImage $(PLATFORMDIR)/
205 # dd conv=sync bs=64k < $(PLATFORMDIR)/zImage > $(PLATFORMDIR)/linux.bin
206 # Append filesystem to self-booting Linux
207 # cat $(PLATFORMDIR)/target.image >> $(PLATFORMDIR)/linux.bin
212 # cleaners
215 clean: clean-build $(obj-clean)
216 rm -rf layer7/squished
218 clean-build: dummy
219 rm -rf $(TARGETDIR)
220 rm -rf $(INSTALLDIR)
221 rm -f $(PLATFORMDIR)/linux.trx $(PLATFORMDIR)/vmlinuz $(PLATFORMDIR)/target.image
222 rm -rf $(PLATFORMDIR)/extras
224 distclean: clean
225 ifneq ($(INSIDE_MAK),1)
226 $(MAKE) -C .. $@ INSIDE_MAK=1
227 endif
230 # configuration
233 CONFIG_IN := config/config.in
235 config/conf config/mconf:
236 @$(MAKE) -C config
238 rconf: config/conf
239 @config/conf $(CONFIG_IN)
241 rmconf: config/mconf
242 @config/mconf $(CONFIG_IN)
244 roldconf: config/conf
245 @config/conf -o $(CONFIG_IN)
247 kconf:
248 @$(MAKE) -C $(LINUXDIR) config
250 kmconf:
251 @$(MAKE) -C $(LINUXDIR) menuconfig
253 koldconf:
254 @$(MAKE) -C $(LINUXDIR) oldconfig
256 config conf: rconf kconf
258 menuconfig mconf: rmconf kmconf
260 oldconfig oldconf: roldconf koldconf
264 # overrides and extra dependencies
267 busybox:
268 @cd busybox && [ -s .config ] || ( cp config.save .config; $(MAKE) oldconfig )
269 @$(MAKE) -C busybox CFLAGS="-Os"
270 @cp busybox/.config busybox/config.save
272 # V=1
274 busybox-install:
275 rm -rf $(INSTALLDIR)/busybox
276 $(MAKE) -C busybox install CONFIG_PREFIX=$(INSTALLDIR)/busybox CFLAGS="-Os"
278 busybox-clean:
279 cd busybox && [ -s .config ] && cp .config config.save
280 $(MAKE) -C busybox distclean
281 cd busybox && mv config.save .config
283 busybox-config:
284 $(MAKE) -C busybox menuconfig
286 busybox-test: dummy
287 $(MAKE) -C busybox objsizes CFLAGS="-Os"
290 httpd: matrixssl shared nvram mssl
291 @$(SEP)
292 @$(MAKE) -C httpd
294 www-install:
295 @$(MAKE) -C www install INSTALLDIR=$(INSTALLDIR)/www TOMATO_EXPERIMENTAL=$(TOMATO_EXPERIMENTAL)
297 matrixssl:
298 @$(SEP)
299 @$(MAKE) -C matrixssl/src
301 matrixssl-install:
302 @true
304 matrixssl-clean:
305 $(MAKE) -C matrixssl/src clean
308 openssl-install:
309 install -D openssl/libcrypto.so $(INSTALLDIR)/openssl/usr/lib/libcrypto.so
310 $(STRIP) $(INSTALLDIR)/openssl/usr/lib/libcrypto.so
312 install -D -m 500 openssl/apps/openssl $(INSTALLDIR)/openssl/usr/sbin/openssl
313 $(STRIP) $(INSTALLDIR)/openssl/usr/sbin/openssl
315 install -D -m 0500 httpd/gencert.sh $(INSTALLDIR)/openssl/usr/sbin/gencert.sh
317 # perl -e 'while (<>) { s/.SECS/time()-(24*60*60)/e; print; }' < httpd/gencert.sh > $(INSTALLDIR)/openssl/usr/sbin/gencert.sh
318 # chmod 0500 $(INSTALLDIR)/openssl/usr/sbin/gencert.sh
320 # install -D openssl/libssl.so $(INSTALLDIR)/openssl/usr/lib/libssl.so
321 # $(STRIP) $(INSTALLDIR)/openssl/usr/lib/libssl.so
323 mssl: matrixssl
325 mdu: shared mssl
327 rc: nvram shared
330 bridge:
331 @$(SEP)
332 @$(MAKE) -C bridge brctl/brctl
334 bridge-install:
335 install -D bridge/brctl/brctl $(INSTALLDIR)/bridge/usr/sbin/brctl
336 $(STRIP) $(INSTALLDIR)/bridge/usr/sbin/brctl
338 dnsmasq:
339 @$(SEP)
340 @$(MAKE) -C dnsmasq COPTS=-DNO_IPV6
342 dnsmasq-install:
343 install -D dnsmasq/src/dnsmasq $(INSTALLDIR)/dnsmasq/usr/sbin/dnsmasq
344 $(STRIP) $(INSTALLDIR)/dnsmasq/usr/sbin/dnsmasq
346 iptables:
347 @$(SEP)
348 $(MAKE) -C iptables BINDIR=/usr/sbin LIBDIR=/usr/lib KERNEL_DIR=$(LINUXDIR)
350 iptables-install:
351 install -D iptables/iptables $(INSTALLDIR)/iptables/usr/sbin/iptables
352 cd $(INSTALLDIR)/iptables/usr/sbin && \
353 ln -sf iptables iptables-restore
355 install -d $(INSTALLDIR)/iptables/usr/lib/iptables
356 install -D iptables/extensions/*.so $(INSTALLDIR)/iptables/usr/lib/iptables/
358 install -D iptables/libiptc.so $(INSTALLDIR)/iptables/usr/lib/libiptc.so
360 $(STRIP) $(INSTALLDIR)/iptables/usr/sbin/iptables
361 $(STRIP) $(INSTALLDIR)/iptables/usr/lib/iptables/*.so
362 $(STRIP) $(INSTALLDIR)/iptables/usr/lib/libiptc.so
364 iptables-clean:
365 -$(MAKE) -C iptables KERNEL_DIR=$(LINUXDIR) clean
367 ppp:
368 @$(SEP)
369 $(MAKE) -C ppp/pppoecd $* INSTALLDIR=$(INSTALLDIR)/ppp
370 # $(MAKE) -C ppp/pppoecd $* INSTALLDIR=$(INSTALLDIR)/ppp DFLAGS="-DDEBUG -DDEBUGALL"
372 ppp-%:
373 $(MAKE) -C ppp/pppoecd $* INSTALLDIR=$(INSTALLDIR)/ppp
376 upnp: nvram shared iptables
378 miniupnpd: iptables
379 @$(SEP)
380 $(MAKE) -C miniupnpd -f Makefile.tomato
382 miniupnpd-clean:
383 -$(MAKE) -C miniupnpd -f Makefile.tomato clean
385 miniupnpd-install:
386 install -D miniupnpd/miniupnpd $(INSTALLDIR)/miniupnpd/usr/sbin/miniupnpd
387 $(STRIP) $(INSTALLDIR)/miniupnpd/usr/sbin/miniupnpd
389 nvram: shared
391 prebuilt: shared
393 vlan:
394 @$(SEP)
395 @$(MAKE) -C vlan CROSS=$(CROSS_COMPILE) STRIPTOOL=$(STRIP)
397 vlan-install:
398 $(MAKE) -C vlan CROSS=$(CROSS_COMPILE) STRIPTOOL=$(STRIP) INSTALLDIR=$(INSTALLDIR) install
401 pptp-client-install:
402 install -D pptp-client/pptp $(INSTALLDIR)/pptp-client/usr/sbin/pptp
403 $(STRIP) $(INSTALLDIR)/pptp-client/usr/sbin/pptp
406 pppd:
407 @$(SEP)
408 @$(MAKE) -C pppd/pppd
410 pppd-clean:
411 $(MAKE) -C pppd/pppd clean
413 pppd-install:
414 install -D pppd/pppd/pppd $(INSTALLDIR)/pppd/usr/sbin/pppd
415 $(STRIP) $(INSTALLDIR)/pppd/usr/sbin/pppd
417 # ipupdate-install:
418 # install -D ipupdate/ez-ipupdate $(INSTALLDIR)/ipupdate/usr/sbin/ez-ipupdate
419 # $(STRIP) $(INSTALLDIR)/ipupdate/usr/sbin/ez-ipupdate
422 zebra:
423 @$(SEP)
424 cd zebra && rm -f config.cache && CC=$(CC) AR=$(AR) RANLIB=$(RANLIB) CFLAGS="-g -Os -Wall" $(CONFIGURE) \
425 --host=mipsel-linux --prefix=/usr/local/zebra \
426 --enable-netlink --disable-ipv6 --disable-ripngd --disable-ospfd --disable-doc \
427 --disable-ospf6d --disable-bgpd --disable-bgpd-announce
428 @$(MAKE) -C zebra CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
430 zebra-install:
431 install -D zebra/zebra/zebra $(INSTALLDIR)/zebra/usr/sbin/zebra
432 install -D zebra/ripd/ripd $(INSTALLDIR)/zebra/usr/sbin/ripd
433 install -D zebra/lib/libzebra.so $(INSTALLDIR)/zebra/usr/lib/libzebra.so
434 $(STRIP) $(INSTALLDIR)/zebra/usr/sbin/zebra
435 $(STRIP) $(INSTALLDIR)/zebra/usr/sbin/ripd
436 $(STRIP) $(INSTALLDIR)/zebra/usr/lib/libzebra.so
439 rp-l2tp-install:
440 install -d $(INSTALLDIR)/rp-l2tp/usr/lib/l2tp
441 install rp-l2tp/handlers/*.so $(INSTALLDIR)/rp-l2tp/usr/lib/l2tp
442 $(STRIP) $(INSTALLDIR)/rp-l2tp/usr/lib/l2tp/*.so
443 install -D rp-l2tp/handlers/l2tp-control $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tp-control
444 $(STRIP) $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tp-control
445 install -D rp-l2tp/l2tpd $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tpd
446 $(STRIP) $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tpd
449 bpalogin-install:
450 install -D bpalogin/bpalogin $(INSTALLDIR)/bpalogin/usr/sbin/bpalogin
451 $(STRIP) $(INSTALLDIR)/bpalogin/usr/sbin/bpalogin
454 # libnet:
455 # @$(SEP)
456 # @-mkdir -p libnet/lib
457 # @$(MAKE) -C libnet CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
459 # libpcap:
460 # @$(SEP)
461 # @$(MAKE) -C libpcap CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
463 libbcm:
464 @[ ! -f libbcm/Makefile ] || $(MAKE) -C libbcm
466 libbcm-install:
467 install -D libbcm/libbcm.so $(INSTALLDIR)/libbcm/usr/lib/libbcm.so
468 $(STRIP) $(INSTALLDIR)/libbcm/usr/lib/libbcm.so
471 iproute2-install:
472 install -D iproute2/tc/tc $(INSTALLDIR)/iproute2/usr/sbin/tc
473 $(STRIP) $(INSTALLDIR)/iproute2/usr/sbin/tc
474 install -D iproute2/ip/ip $(INSTALLDIR)/iproute2/usr/sbin/ip
475 $(STRIP) $(INSTALLDIR)/iproute2/usr/sbin/ip
478 ntpc: nvram shared
481 dropbear: dropbear/config.h
482 @$(SEP)
483 @make -C dropbear PROGRAMS="dropbear dbclient dropbearkey scp" MULTI=1
485 dropbear-install:
486 install -D dropbear/dropbearmulti $(INSTALLDIR)/dropbear/usr/bin/dropbearmulti
487 $(STRIP) $(INSTALLDIR)/dropbear/usr/bin/dropbearmulti
488 cd $(INSTALLDIR)/dropbear/usr/bin && \
489 ln -sf dropbearmulti dropbear && \
490 ln -sf dropbearmulti dropbearconvert && \
491 ln -sf dropbearmulti dropbearkey && \
492 ln -sf dropbearmulti dbclient && \
493 ln -sf dropbearmulti ssh && \
494 ln -sf dropbearmulti scp
496 dropbear-clean:
497 @make -C dropbear clean
499 dropbear/config.h:
500 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
501 make -C dropbear clean
503 igmpproxy/src/Makefile: igmpproxy/src/Makefile.in
504 cd igmpproxy && CFLAGS="-O2 -Wall" \
505 $(CONFIGURE) --prefix=/usr
507 igmpproxy: igmpproxy/src/Makefile
508 @$(SEP)
509 @$(MAKE) -C igmpproxy/src
511 igmpproxy-install:
512 install -D igmpproxy/src/igmpproxy $(INSTALLDIR)/igmpproxy/usr/sbin/igmpproxy
513 $(STRIP) $(INSTALLDIR)/igmpproxy/usr/sbin/igmpproxy
515 igmpproxy-clean:
516 $(MAKE) -C igmpproxy/src clean
517 rm -f igmpproxy/src/Makefile
520 ebtables: dummy
521 @make -C ebtables
523 ebtables-install: dummy
524 install -D ebtables/ebtables $(INSTALLDIR)/ebtables/usr/sbin/ebtables
526 mkdir -p $(INSTALLDIR)/ebtables/usr/lib/
527 cp ebtables/*.so $(INSTALLDIR)/ebtables/usr/lib/
528 cp ebtables/extensions/*.so $(INSTALLDIR)/ebtables/usr/lib/
530 ebtables-clean:
531 make -C ebtables clean
537 # Generic rules
541 @[ ! -d $* ] || ( $(SEP); $(MAKE) -C $* )
544 %-clean:
545 @-[ ! -d $* ] || $(MAKE) -C $* clean
547 %-install:
548 @[ ! -d $* ] || $(MAKE) -C $* install INSTALLDIR=$(INSTALLDIR)/$*
550 %-build:
551 $(MAKE) $*-clean $*
553 $(obj-y) $(obj-n) $(obj-clean) $(obj-install): dummy
555 .PHONY: all clean distclean mrproper install package
556 .PHONY: conf mconf oldconf kconf kmconf config menuconfig oldconfig
557 .PHONY: dummy libnet libpcap