Merge branch 'tomato-ND-WL-4.158.4.0' into tomato-ND-USBmod-1.25
[tomato.git] / release / src / router / Makefile
blob2f072b2858832cdb812db24803b2a48ded31dc27
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 += iptables
30 obj-y += rc
31 obj-y += iproute2
32 obj-y += rom
33 obj-y += others
34 obj-y += busybox
35 obj-y += httpd
36 obj-y += www
37 obj-y += bridge
38 obj-y += dnsmasq
39 obj-y += etc
40 obj-y += vlan
41 obj-y += ppp
42 obj-y += ttcp
43 obj-y += ntpc
44 obj-y += rstats
46 # !!TB - updated Broadcom Wireless driver 4.150.10.X
47 obj-y += et
48 obj-y += libbcmcrypto
49 obj-y += wlconf
51 obj-y += mssl
52 obj-y += mdu
54 obj-y += miniupnpd
55 # obj-y += upnp
59 # configurable packages
61 obj-$(TCONFIG_L2TP) += rp-l2tp
62 obj-$(TCONFIG_PPTP) += pptp-client
63 obj-$(TCONFIG_HTTPS) += openssl
64 obj-$(TCONFIG_HTTPS) += matrixssl
65 obj-$(TCONFIG_SSH) += dropbear
66 obj-$(TCONFIG_ZEBRA) += zebra
67 # obj-$(TCONFIG_IPP2P) += ipp2p
69 ifeq ($(TCONFIG_L2TP),y)
70 NEED_PPPD = y
71 endif
72 ifeq ($(TCONFIG_PPTP),y)
73 NEED_PPPD = y
74 endif
75 obj-$(NEED_PPPD) += pppd
78 obj-clean := $(foreach obj,$(obj-y) $(obj-n),$(obj)-clean)
79 obj-install := $(foreach obj,$(obj-y),$(obj)-install)
84 # Basic rules
87 all: clean-build $(obj-y) kernel
90 kernel: $(LINUXDIR)/.config
91 @$(SEP)
93 @if ! grep -q "CONFIG_EMBEDDED_RAMDISK=y" $(LINUXDIR)/.config ; then \
94 $(MAKE) -C $(LINUXDIR) zImage ; \
96 if grep -q "CONFIG_MODULES=y" $(LINUXDIR)/.config ; then \
97 $(MAKE) -C $(LINUXDIR) modules ; \
101 kmod: dummy
102 $(MAKE) -C $(LINUXDIR) modules
104 testfind:
105 cd $(TARGETDIR)/lib/modules/2.4.20 && find -name "*.o" -exec mv -i {} . \; || true
106 cd $(TARGETDIR)/lib/modules/2.4.20 && find -type d -delete || true
108 install package: $(obj-install) $(LINUXDIR)/.config
109 @$(SEP)
111 install -d $(TARGETDIR)
114 # kernel modules
115 $(MAKE) -C $(LINUXDIR) modules_install DEPMOD=/bin/true INSTALL_MOD_PATH=$(TARGETDIR)
116 find $(TARGETDIR)/lib/modules -name *.o -exec mipsel-linux-strip --strip-unneeded {} \;
118 -cd $(TARGETDIR)/lib/modules/2.4.20/kernel/drivers/net && mv diag/* . && rm -rf diag
120 # nice and clean
121 -cd $(TARGETDIR)/lib/modules/2.4.20/kernel/drivers/net && mv et.4702/* . && rm -rf et.4702 || true
122 cd $(TARGETDIR)/lib/modules/2.4.20/kernel/drivers/net && mv et/* . && rm -rf et
123 cd $(TARGETDIR)/lib/modules/2.4.20/kernel/drivers/net && mv wl/* . && rm -rf wl
124 cd $(TARGETDIR)/lib/modules/2.4.20/kernel/fs && mv cifs/* . && rm -rf cifs
125 cd $(TARGETDIR)/lib/modules/2.4.20/kernel/fs && mv jffs2/* . && rm -rf jffs2 || true
126 cd $(TARGETDIR)/lib/modules/2.4.20/kernel/fs && mv jffs/* . && rm -rf jffs || true
127 cd $(TARGETDIR)/lib/modules/2.4.20/kernel/lib && mv zlib_inflate/* . && rm -rf zlib_inflate
128 cd $(TARGETDIR)/lib/modules/2.4.20/kernel/lib && mv zlib_deflate/* . && rm -rf zlib_deflate
129 rm -rf $(TARGETDIR)/lib/modules/2.4.20/pcmcia
131 # misc
132 for dir in $(wildcard $(patsubst %,$(INSTALLDIR)/%,$(obj-y))) ; do \
133 (cd $${dir} && tar cpf - .) | (cd $(TARGETDIR) && tar xpf -) \
134 done
136 ifneq ($(TCONFIG_JFFS2),y)
137 rm -f $(TARGETDIR)/lib/modules/2.4.20/kernel/fs/jffs2.o || true
138 rm -f $(TARGETDIR)/lib/modules/2.4.20/kernel/fs/jffs.o || true
139 rm -rf $(TARGETDIR)/lib/modules/2.4.20/kernel/lib/zlib_*
140 endif
142 ifneq ($(TCONFIG_CIFS),y)
143 rm -f $(TARGETDIR)/lib/modules/2.4.20/kernel/fs/cifs.o
144 endif
146 ifneq ($(TCONFIG_L7),y)
147 rm -f $(TARGETDIR)/lib/modules/2.4.20/kernel/net/ipv4/netfilter/ipt_layer7.o
148 rm -f $(TARGETDIR)/usr/lib/iptables/libipt_layer7.so
149 endif
151 # separated extra stuff
152 @rm -rf $(PLATFORMDIR)/extras
153 @mkdir $(PLATFORMDIR)/extras
154 @mv $(TARGETDIR)/lib/modules/2.4.20/kernel/net/ipv4/ip_gre.o $(PLATFORMDIR)/extras/
155 @mv $(TARGETDIR)/lib/modules/2.4.20/kernel/drivers/net/tun.o $(PLATFORMDIR)/extras/
157 # uClibc
158 install $(LIBDIR)/ld-uClibc.so.0 $(TARGETDIR)/lib/
159 install $(LIBDIR)/libcrypt.so.0 $(TARGETDIR)/lib/
160 install $(LIBDIR)/libc.so.0 $(TARGETDIR)/lib/
161 install $(LIBDIR)/libdl.so.0 $(TARGETDIR)/lib/
162 install $(LIBDIR)/libm.so.0 $(TARGETDIR)/lib/
163 install $(LIBDIR)/libnsl.so.0 $(TARGETDIR)/lib/
164 ifeq ($(TCONFIG_SSH),y)
165 install $(LIBDIR)/libutil.so.0 $(TARGETDIR)/lib/
166 endif
168 @cd $(TARGETDIR) && $(TOP)/others/rootprep.sh
170 @echo ---
171 busybox/examples/depmod-t.pl -k $(LINUXDIR)/vmlinux -b $(TARGETDIR)/lib/modules/2.4.20/
172 @echo ---
174 @rm -f $(TARGETDIR)/lib/modules/2.4.20/build
176 @../btools/libfoo.pl
177 @chmod 0555 $(TARGETDIR)/lib/*.so*
180 @mkdir -p $(TARGETDIR)/rom/etc/l7-protocols
181 ifeq ($(TCONFIG_L7PAT),y)
182 @cd layer7 && ./squish.sh
183 cp layer7/squished/*.pat $(TARGETDIR)/rom/etc/l7-protocols
184 endif
186 @$(MAKE) -C $(SRCBASE)/linux/linux/scripts/squashfs mksquashfs-lzma
187 @$(SRCBASE)/linux/linux/scripts/squashfs/mksquashfs-lzma $(TARGETDIR) $(PLATFORMDIR)/target.image
189 # Package kernel and filesystem
190 # if grep -q "CONFIG_EMBEDDED_RAMDISK=y" $(LINUXDIR)/.config ; then \
191 # cp $(PLATFORMDIR)/target.image $(LINUXDIR)/arch/mips/ramdisk/$${CONFIG_EMBEDDED_RAMDISK_IMAGE} ; \
192 # $(MAKE) -C $(LINUXDIR) zImage ; \
193 # else \
194 # cp $(LINUXDIR)/arch/mips/brcm-boards/bcm947xx/compressed/vmlinuz $(PLATFORMDIR)/ ; \
195 # trx -o $(PLATFORMDIR)/linux.trx $(PLATFORMDIR)/vmlinuz $(PLATFORMDIR)/target.image ; \
196 # fi
198 # Pad self-booting Linux to a 64 KB boundary
199 # cp $(LINUXDIR)/arch/mips/brcm-boards/bcm947xx/compressed/zImage $(PLATFORMDIR)/
200 # dd conv=sync bs=64k < $(PLATFORMDIR)/zImage > $(PLATFORMDIR)/linux.bin
201 # Append filesystem to self-booting Linux
202 # cat $(PLATFORMDIR)/target.image >> $(PLATFORMDIR)/linux.bin
207 # cleaners
210 clean: clean-build $(obj-clean)
211 rm -rf layer7/squished
213 clean-build: dummy
214 rm -rf $(TARGETDIR)
215 rm -rf $(INSTALLDIR)
216 rm -f $(PLATFORMDIR)/linux.trx $(PLATFORMDIR)/vmlinuz $(PLATFORMDIR)/target.image
217 rm -rf $(PLATFORMDIR)/extras
219 distclean: clean
220 ifneq ($(INSIDE_MAK),1)
221 $(MAKE) -C .. $@ INSIDE_MAK=1
222 endif
225 # configuration
228 CONFIG_IN := config/config.in
230 config/conf config/mconf:
231 @$(MAKE) -C config
233 rconf: config/conf
234 @config/conf $(CONFIG_IN)
236 rmconf: config/mconf
237 @config/mconf $(CONFIG_IN)
239 roldconf: config/conf
240 @config/conf -o $(CONFIG_IN)
242 kconf:
243 @$(MAKE) -C $(LINUXDIR) config
245 kmconf:
246 @$(MAKE) -C $(LINUXDIR) menuconfig
248 koldconf:
249 @$(MAKE) -C $(LINUXDIR) oldconfig
251 config conf: rconf kconf
253 menuconfig mconf: rmconf kmconf
255 oldconfig oldconf: roldconf koldconf
259 # overrides and extra dependencies
262 busybox:
263 @cd busybox && [ -s .config ] || ( cp config.save .config; $(MAKE) oldconfig )
264 @$(MAKE) -C busybox CFLAGS="-Os"
265 @cp busybox/.config busybox/config.save
267 # V=1
269 busybox-install:
270 rm -rf $(INSTALLDIR)/busybox
271 $(MAKE) -C busybox install CONFIG_PREFIX=$(INSTALLDIR)/busybox CFLAGS="-Os"
273 busybox-clean:
274 cd busybox && [ -s .config ] && cp .config config.save
275 $(MAKE) -C busybox distclean
276 cd busybox && mv config.save .config
278 busybox-config:
279 $(MAKE) -C busybox menuconfig
281 busybox-test: dummy
282 $(MAKE) -C busybox objsizes CFLAGS="-Os"
285 httpd: matrixssl shared nvram mssl
286 @$(SEP)
287 @$(MAKE) -C httpd
289 www-install:
290 @$(MAKE) -C www install INSTALLDIR=$(INSTALLDIR)/www TOMATO_EXPERIMENTAL=$(TOMATO_EXPERIMENTAL)
292 matrixssl:
293 @$(SEP)
294 @$(MAKE) -C matrixssl/src
296 matrixssl-install:
297 @true
299 matrixssl-clean:
300 $(MAKE) -C matrixssl/src clean
303 openssl-install:
304 install -D openssl/libcrypto.so $(INSTALLDIR)/openssl/usr/lib/libcrypto.so
305 $(STRIP) $(INSTALLDIR)/openssl/usr/lib/libcrypto.so
307 install -D -m 500 openssl/apps/openssl $(INSTALLDIR)/openssl/usr/sbin/openssl
308 $(STRIP) $(INSTALLDIR)/openssl/usr/sbin/openssl
310 install -D -m 0500 httpd/gencert.sh $(INSTALLDIR)/openssl/usr/sbin/gencert.sh
312 # perl -e 'while (<>) { s/.SECS/time()-(24*60*60)/e; print; }' < httpd/gencert.sh > $(INSTALLDIR)/openssl/usr/sbin/gencert.sh
313 # chmod 0500 $(INSTALLDIR)/openssl/usr/sbin/gencert.sh
315 # install -D openssl/libssl.so $(INSTALLDIR)/openssl/usr/lib/libssl.so
316 # $(STRIP) $(INSTALLDIR)/openssl/usr/lib/libssl.so
318 mssl: matrixssl
320 mdu: shared mssl
322 rc: nvram shared
325 bridge:
326 @$(SEP)
327 @$(MAKE) -C bridge brctl/brctl
329 bridge-install:
330 install -D bridge/brctl/brctl $(INSTALLDIR)/bridge/usr/sbin/brctl
331 $(STRIP) $(INSTALLDIR)/bridge/usr/sbin/brctl
334 dnsmasq-install:
335 install -D dnsmasq/src/dnsmasq $(INSTALLDIR)/dnsmasq/usr/sbin/dnsmasq
336 $(STRIP) $(INSTALLDIR)/dnsmasq/usr/sbin/dnsmasq
338 iptables:
339 @$(SEP)
340 $(MAKE) -C iptables BINDIR=/usr/sbin LIBDIR=/usr/lib KERNEL_DIR=$(LINUXDIR)
342 iptables-install:
343 install -D iptables/iptables $(INSTALLDIR)/iptables/usr/sbin/iptables
344 cd $(INSTALLDIR)/iptables/usr/sbin && \
345 ln -sf iptables iptables-restore
347 install -d $(INSTALLDIR)/iptables/usr/lib/iptables
348 install -D iptables/extensions/*.so $(INSTALLDIR)/iptables/usr/lib/iptables/
350 install -D iptables/libiptc.so $(INSTALLDIR)/iptables/usr/lib/libiptc.so
352 $(STRIP) $(INSTALLDIR)/iptables/usr/sbin/iptables
353 $(STRIP) $(INSTALLDIR)/iptables/usr/lib/iptables/*.so
354 $(STRIP) $(INSTALLDIR)/iptables/usr/lib/libiptc.so
356 iptables-clean:
357 -$(MAKE) -C iptables KERNEL_DIR=$(LINUXDIR) clean
359 ppp:
360 @$(SEP)
361 $(MAKE) -C ppp/pppoecd $* INSTALLDIR=$(INSTALLDIR)/ppp
362 # $(MAKE) -C ppp/pppoecd $* INSTALLDIR=$(INSTALLDIR)/ppp DFLAGS="-DDEBUG -DDEBUGALL"
364 ppp-%:
365 $(MAKE) -C ppp/pppoecd $* INSTALLDIR=$(INSTALLDIR)/ppp
368 upnp: nvram shared iptables
370 miniupnpd: iptables
371 @$(SEP)
372 $(MAKE) -C miniupnpd -f Makefile.tomato
374 miniupnpd-clean:
375 -$(MAKE) -C miniupnpd -f Makefile.tomato clean
377 miniupnpd-install:
378 install -D miniupnpd/miniupnpd $(INSTALLDIR)/miniupnpd/usr/sbin/miniupnpd
379 $(STRIP) $(INSTALLDIR)/miniupnpd/usr/sbin/miniupnpd
381 nvram: shared
383 vlan:
384 @$(SEP)
385 @$(MAKE) -C vlan CROSS=$(CROSS_COMPILE) STRIPTOOL=$(STRIP)
387 vlan-install:
388 $(MAKE) -C vlan CROSS=$(CROSS_COMPILE) STRIPTOOL=$(STRIP) INSTALLDIR=$(INSTALLDIR) install
391 pptp-client-install:
392 install -D pptp-client/pptp $(INSTALLDIR)/pptp-client/usr/sbin/pptp
393 $(STRIP) $(INSTALLDIR)/pptp-client/usr/sbin/pptp
396 pppd:
397 @$(SEP)
398 @$(MAKE) -C pppd/pppd
400 pppd-clean:
401 $(MAKE) -C pppd/pppd clean
403 pppd-install:
404 install -D pppd/pppd/pppd $(INSTALLDIR)/pppd/usr/sbin/pppd
405 $(STRIP) $(INSTALLDIR)/pppd/usr/sbin/pppd
407 # ipupdate-install:
408 # install -D ipupdate/ez-ipupdate $(INSTALLDIR)/ipupdate/usr/sbin/ez-ipupdate
409 # $(STRIP) $(INSTALLDIR)/ipupdate/usr/sbin/ez-ipupdate
412 zebra:
413 @$(SEP)
414 @$(MAKE) -C zebra CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
416 zebra-install:
417 install -D zebra/zebra/zebra $(INSTALLDIR)/zebra/usr/sbin/zebra
418 install -D zebra/ripd/ripd $(INSTALLDIR)/zebra/usr/sbin/ripd
419 install -D zebra/lib/libzebra.so $(INSTALLDIR)/zebra/usr/lib/libzebra.so
420 $(STRIP) $(INSTALLDIR)/zebra/usr/sbin/zebra
421 $(STRIP) $(INSTALLDIR)/zebra/usr/sbin/ripd
422 $(STRIP) $(INSTALLDIR)/zebra/usr/lib/libzebra.so
425 rp-l2tp-install:
426 install -d $(INSTALLDIR)/rp-l2tp/usr/lib/l2tp
427 install rp-l2tp/handlers/*.so $(INSTALLDIR)/rp-l2tp/usr/lib/l2tp
428 $(STRIP) $(INSTALLDIR)/rp-l2tp/usr/lib/l2tp/*.so
429 install -D rp-l2tp/handlers/l2tp-control $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tp-control
430 $(STRIP) $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tp-control
431 install -D rp-l2tp/l2tpd $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tpd
432 $(STRIP) $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tpd
435 bpalogin-install:
436 install -D bpalogin/bpalogin $(INSTALLDIR)/bpalogin/usr/sbin/bpalogin
437 $(STRIP) $(INSTALLDIR)/bpalogin/usr/sbin/bpalogin
440 # libnet:
441 # @$(SEP)
442 # @-mkdir -p libnet/lib
443 # @$(MAKE) -C libnet CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
445 # libpcap:
446 # @$(SEP)
447 # @$(MAKE) -C libpcap CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
449 libbcm:
450 @[ ! -f libbcm/Makefile ] || $(MAKE) -C libbcm
452 libbcm-install:
453 install -D libbcm/libbcm.so $(INSTALLDIR)/libbcm/usr/lib/libbcm.so
454 $(STRIP) $(INSTALLDIR)/libbcm/usr/lib/libbcm.so
457 iproute2-install:
458 install -D iproute2/tc/tc $(INSTALLDIR)/iproute2/usr/sbin/tc
459 $(STRIP) $(INSTALLDIR)/iproute2/usr/sbin/tc
460 install -D iproute2/ip/ip $(INSTALLDIR)/iproute2/usr/sbin/ip
461 $(STRIP) $(INSTALLDIR)/iproute2/usr/sbin/ip
464 ntpc: nvram shared
467 dropbear: dropbear/config.h
468 @$(SEP)
469 @make -C dropbear PROGRAMS="dropbear dbclient dropbearkey scp" MULTI=1
471 dropbear-install:
472 install -D dropbear/dropbearmulti $(INSTALLDIR)/dropbear/usr/bin/dropbearmulti
473 $(STRIP) $(INSTALLDIR)/dropbear/usr/bin/dropbearmulti
474 cd $(INSTALLDIR)/dropbear/usr/bin && \
475 ln -sf dropbearmulti dropbear && \
476 ln -sf dropbearmulti dropbearconvert && \
477 ln -sf dropbearmulti dropbearkey && \
478 ln -sf dropbearmulti dbclient && \
479 ln -sf dropbearmulti ssh && \
480 ln -sf dropbearmulti scp
482 dropbear-clean:
483 @make -C dropbear clean
485 dropbear/config.h:
486 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
487 make -C dropbear clean
490 ebtables: dummy
491 @make -C ebtables
493 ebtables-install: dummy
494 install -D ebtables/ebtables $(INSTALLDIR)/ebtables/usr/sbin/ebtables
496 mkdir -p $(INSTALLDIR)/ebtables/usr/lib/
497 cp ebtables/*.so $(INSTALLDIR)/ebtables/usr/lib/
498 cp ebtables/extensions/*.so $(INSTALLDIR)/ebtables/usr/lib/
500 ebtables-clean:
501 make -C ebtables clean
507 # Generic rules
511 @[ ! -d $* ] || ( $(SEP); $(MAKE) -C $* )
514 %-clean:
515 @-[ ! -d $* ] || $(MAKE) -C $* clean
517 %-install:
518 @[ ! -d $* ] || $(MAKE) -C $* install INSTALLDIR=$(INSTALLDIR)/$*
520 %-build:
521 $(MAKE) $*-clean $*
523 $(obj-y) $(obj-n) $(obj-clean) $(obj-install): dummy
525 .PHONY: all clean distclean mrproper install package
526 .PHONY: conf mconf oldconf kconf kmconf config menuconfig oldconfig
527 .PHONY: dummy libnet libpcap