Tomato 1.28
[tomato-rt-n10.git] / release / src / router / Makefile
blob3178d881540568718e28dcdbce475764ae0eb24c
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=0
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
45 obj-y += mssl
46 obj-y += mdu
48 obj-y += miniupnpd
49 # obj-y += upnp
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)
64 NEED_PPPD = y
65 endif
66 ifeq ($(TCONFIG_PPTP),y)
67 NEED_PPPD = y
68 endif
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)
78 # Basic rules
81 all: clean-build $(obj-y) kernel
84 kernel: $(LINUXDIR)/.config
85 @$(SEP)
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 ; \
95 kmod: dummy
96 $(MAKE) -C $(LINUXDIR) modules
98 testfind:
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
103 @$(SEP)
105 install -d $(TARGETDIR)
108 # kernel modules
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
114 # nice and clean
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
124 # misc
125 for dir in $(wildcard $(patsubst %,$(INSTALLDIR)/%,$(obj-y))) ; do \
126 (cd $${dir} && tar cpf - .) | (cd $(TARGETDIR) && tar xpf -) \
127 done
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_*
132 endif
134 ifneq ($(TCONFIG_CIFS),y)
135 rm -f $(TARGETDIR)/lib/modules/2.4.20/kernel/fs/cifs.o
136 endif
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
141 endif
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/
149 # uClibc
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/
158 endif
160 @cd $(TARGETDIR) && $(TOP)/others/rootprep.sh
162 @echo ---
163 busybox/examples/depmod.pl -k $(LINUXDIR)/vmlinux -b $(TARGETDIR)/lib/modules/2.4.20/
164 @echo ---
166 @rm -f $(TARGETDIR)/lib/modules/2.4.20/build
168 @../btools/libfoo.pl
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
176 endif
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 ; \
185 # else \
186 # cp $(LINUXDIR)/arch/mips/brcm-boards/bcm947xx/compressed/vmlinuz $(PLATFORMDIR)/ ; \
187 # trx -o $(PLATFORMDIR)/linux.trx $(PLATFORMDIR)/vmlinuz $(PLATFORMDIR)/target.image ; \
188 # fi
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
199 # cleaners
202 clean: clean-build $(obj-clean)
203 rm -rf layer7/squished
205 clean-build: dummy
206 rm -rf $(TARGETDIR)
207 rm -rf $(INSTALLDIR)
208 rm -f $(PLATFORMDIR)/linux.trx $(PLATFORMDIR)/vmlinuz $(PLATFORMDIR)/target.image
209 rm -rf $(PLATFORMDIR)/extras
211 distclean: clean
212 ifneq ($(INSIDE_MAK),1)
213 $(MAKE) -C .. $@ INSIDE_MAK=1
214 endif
217 # configuration
220 CONFIG_IN := config/config.in
222 config/conf config/mconf:
223 @$(MAKE) -C config
225 rconf: config/conf
226 @config/conf $(CONFIG_IN)
228 rmconf: config/mconf
229 @config/mconf $(CONFIG_IN)
231 roldconf: config/conf
232 @config/conf -o $(CONFIG_IN)
234 kconf:
235 @$(MAKE) -C $(LINUXDIR) config
237 kmconf:
238 @$(MAKE) -C $(LINUXDIR) menuconfig
240 koldconf:
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
254 busybox:
255 @cd busybox && [ -s .config ] || ( cp config.save .config; $(MAKE) oldconfig )
256 @$(MAKE) -C busybox CFLAGS="-Os"
257 @cp busybox/.config busybox/config.save
259 # V=1
261 busybox-install:
262 rm -rf $(INSTALLDIR)/busybox
263 $(MAKE) -C busybox install CONFIG_PREFIX=$(INSTALLDIR)/busybox CFLAGS="-Os"
265 busybox-clean:
266 cd busybox && [ -s .config ] && cp .config config.save
267 $(MAKE) -C busybox distclean
268 cd busybox && mv config.save .config
270 busybox-config:
271 $(MAKE) -C busybox menuconfig
274 httpd: matrixssl shared nvram mssl
275 @$(SEP)
276 @$(MAKE) -C httpd
278 www-install:
279 @$(MAKE) -C www install INSTALLDIR=$(INSTALLDIR)/www TOMATO_EXPERIMENTAL=$(TOMATO_EXPERIMENTAL)
281 matrixssl:
282 @$(SEP)
283 @$(MAKE) -C matrixssl/src
285 matrixssl-install:
286 @true
288 matrixssl-clean:
289 $(MAKE) -C matrixssl/src clean
292 openssl-install:
293 install -D openssl/libcrypto.so $(INSTALLDIR)/openssl/usr/lib/libcrypto.so
294 $(STRIP) $(INSTALLDIR)/openssl/usr/lib/libcrypto.so
296 install -D -m 500 openssl/apps/openssl $(INSTALLDIR)/openssl/usr/sbin/openssl
297 $(STRIP) $(INSTALLDIR)/openssl/usr/sbin/openssl
299 install -D -m 0500 httpd/gencert.sh $(INSTALLDIR)/openssl/usr/sbin/gencert.sh
301 # perl -e 'while (<>) { s/.SECS/time()-(24*60*60)/e; print; }' < httpd/gencert.sh > $(INSTALLDIR)/openssl/usr/sbin/gencert.sh
302 # chmod 0500 $(INSTALLDIR)/openssl/usr/sbin/gencert.sh
304 # install -D openssl/libssl.so $(INSTALLDIR)/openssl/usr/lib/libssl.so
305 # $(STRIP) $(INSTALLDIR)/openssl/usr/lib/libssl.so
307 mssl: matrixssl
309 mdu: shared mssl
311 rc: nvram shared
314 bridge:
315 @$(SEP)
316 @$(MAKE) -C bridge brctl/brctl
318 bridge-install:
319 install -D bridge/brctl/brctl $(INSTALLDIR)/bridge/usr/sbin/brctl
320 $(STRIP) $(INSTALLDIR)/bridge/usr/sbin/brctl
323 dnsmasq-install:
324 install -D dnsmasq/src/dnsmasq $(INSTALLDIR)/dnsmasq/usr/sbin/dnsmasq
325 $(STRIP) $(INSTALLDIR)/dnsmasq/usr/sbin/dnsmasq
327 iptables:
328 @$(SEP)
329 $(MAKE) -C iptables BINDIR=/usr/sbin LIBDIR=/usr/lib KERNEL_DIR=$(LINUXDIR)
331 iptables-install:
332 install -D iptables/iptables $(INSTALLDIR)/iptables/usr/sbin/iptables
333 cd $(INSTALLDIR)/iptables/usr/sbin && \
334 ln -sf iptables iptables-restore
336 install -d $(INSTALLDIR)/iptables/usr/lib/iptables
337 install -D iptables/extensions/*.so $(INSTALLDIR)/iptables/usr/lib/iptables/
339 install -D iptables/libiptc.so $(INSTALLDIR)/iptables/usr/lib/libiptc.so
341 $(STRIP) $(INSTALLDIR)/iptables/usr/sbin/iptables
342 $(STRIP) $(INSTALLDIR)/iptables/usr/lib/iptables/*.so
343 $(STRIP) $(INSTALLDIR)/iptables/usr/lib/libiptc.so
345 iptables-clean:
346 -$(MAKE) -C iptables KERNEL_DIR=$(LINUXDIR) clean
348 ppp:
349 @$(SEP)
350 $(MAKE) -C ppp/pppoecd $* INSTALLDIR=$(INSTALLDIR)/ppp
351 # $(MAKE) -C ppp/pppoecd $* INSTALLDIR=$(INSTALLDIR)/ppp DFLAGS="-DDEBUG -DDEBUGALL"
353 ppp-%:
354 $(MAKE) -C ppp/pppoecd $* INSTALLDIR=$(INSTALLDIR)/ppp
357 upnp: nvram shared iptables
359 miniupnpd: iptables
360 @$(SEP)
361 $(MAKE) -C miniupnpd -f Makefile.tomato
363 miniupnpd-clean:
364 -$(MAKE) -C miniupnpd -f Makefile.tomato clean
366 miniupnpd-install:
367 install -D miniupnpd/miniupnpd $(INSTALLDIR)/miniupnpd/usr/sbin/miniupnpd
368 $(STRIP) $(INSTALLDIR)/miniupnpd/usr/sbin/miniupnpd
370 nvram: shared
372 vlan:
373 @$(SEP)
374 @$(MAKE) -C vlan CROSS=$(CROSS_COMPILE) STRIPTOOL=$(STRIP)
376 vlan-install:
377 $(MAKE) -C vlan CROSS=$(CROSS_COMPILE) STRIPTOOL=$(STRIP) INSTALLDIR=$(INSTALLDIR) install
380 pptp-client-install:
381 install -D pptp-client/pptp $(INSTALLDIR)/pptp-client/usr/sbin/pptp
382 $(STRIP) $(INSTALLDIR)/pptp-client/usr/sbin/pptp
385 pppd:
386 @$(SEP)
387 @$(MAKE) -C pppd/pppd
389 pppd-clean:
390 $(MAKE) -C pppd/pppd clean
392 pppd-install:
393 install -D pppd/pppd/pppd $(INSTALLDIR)/pppd/usr/sbin/pppd
394 $(STRIP) $(INSTALLDIR)/pppd/usr/sbin/pppd
396 # ipupdate-install:
397 # install -D ipupdate/ez-ipupdate $(INSTALLDIR)/ipupdate/usr/sbin/ez-ipupdate
398 # $(STRIP) $(INSTALLDIR)/ipupdate/usr/sbin/ez-ipupdate
401 zebra:
402 @$(SEP)
403 @$(MAKE) -C zebra CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
405 zebra-install:
406 install -D zebra/zebra/zebra $(INSTALLDIR)/zebra/usr/sbin/zebra
407 install -D zebra/ripd/ripd $(INSTALLDIR)/zebra/usr/sbin/ripd
408 install -D zebra/lib/libzebra.so $(INSTALLDIR)/zebra/usr/lib/libzebra.so
409 $(STRIP) $(INSTALLDIR)/zebra/usr/sbin/zebra
410 $(STRIP) $(INSTALLDIR)/zebra/usr/sbin/ripd
411 $(STRIP) $(INSTALLDIR)/zebra/usr/lib/libzebra.so
414 rp-l2tp-install:
415 install -d $(INSTALLDIR)/rp-l2tp/usr/lib/l2tp
416 install rp-l2tp/handlers/*.so $(INSTALLDIR)/rp-l2tp/usr/lib/l2tp
417 $(STRIP) $(INSTALLDIR)/rp-l2tp/usr/lib/l2tp/*.so
418 install -D rp-l2tp/handlers/l2tp-control $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tp-control
419 $(STRIP) $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tp-control
420 install -D rp-l2tp/l2tpd $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tpd
421 $(STRIP) $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tpd
424 bpalogin-install:
425 install -D bpalogin/bpalogin $(INSTALLDIR)/bpalogin/usr/sbin/bpalogin
426 $(STRIP) $(INSTALLDIR)/bpalogin/usr/sbin/bpalogin
429 # libnet:
430 # @$(SEP)
431 # @-mkdir -p libnet/lib
432 # @$(MAKE) -C libnet CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
434 # libpcap:
435 # @$(SEP)
436 # @$(MAKE) -C libpcap CC=$(CC) AR=$(AR) RANLIB=$(RANLIB)
438 libbcm:
439 @[ ! -f libbcm/Makefile ] || $(MAKE) -C libbcm
441 libbcm-install:
442 install -D libbcm/libbcm.so $(INSTALLDIR)/libbcm/usr/lib/libbcm.so
443 $(STRIP) $(INSTALLDIR)/libbcm/usr/lib/libbcm.so
446 iproute2-install:
447 install -D iproute2/tc/tc $(INSTALLDIR)/iproute2/usr/sbin/tc
448 $(STRIP) $(INSTALLDIR)/iproute2/usr/sbin/tc
449 install -D iproute2/ip/ip $(INSTALLDIR)/iproute2/usr/sbin/ip
450 $(STRIP) $(INSTALLDIR)/iproute2/usr/sbin/ip
453 ntpc: nvram shared
456 dropbear: dropbear/config.h
457 @$(SEP)
458 @make -C dropbear PROGRAMS="dropbear dbclient dropbearkey scp" MULTI=1
460 dropbear-install:
461 install -D dropbear/dropbearmulti $(INSTALLDIR)/dropbear/usr/bin/dropbearmulti
462 $(STRIP) $(INSTALLDIR)/dropbear/usr/bin/dropbearmulti
463 cd $(INSTALLDIR)/dropbear/usr/bin && \
464 ln -sf dropbearmulti dropbear && \
465 ln -sf dropbearmulti dropbearconvert && \
466 ln -sf dropbearmulti dropbearkey && \
467 ln -sf dropbearmulti dbclient && \
468 ln -sf dropbearmulti ssh && \
469 ln -sf dropbearmulti scp
471 dropbear-clean:
472 @make -C dropbear clean
474 dropbear/config.h:
475 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
476 make -C dropbear clean
479 ebtables: dummy
480 @make -C ebtables
482 ebtables-install: dummy
483 install -D ebtables/ebtables $(INSTALLDIR)/ebtables/usr/sbin/ebtables
485 mkdir -p $(INSTALLDIR)/ebtables/usr/lib/
486 cp ebtables/*.so $(INSTALLDIR)/ebtables/usr/lib/
487 cp ebtables/extensions/*.so $(INSTALLDIR)/ebtables/usr/lib/
489 ebtables-clean:
490 make -C ebtables clean
496 # Generic rules
500 @[ ! -d $* ] || ( $(SEP); $(MAKE) -C $* )
503 %-clean:
504 @-[ ! -d $* ] || $(MAKE) -C $* clean
506 %-install:
507 @[ ! -d $* ] || $(MAKE) -C $* install INSTALLDIR=$(INSTALLDIR)/$*
509 %-build:
510 $(MAKE) $*-clean $*
512 $(obj-y) $(obj-n) $(obj-clean) $(obj-install): dummy
514 .PHONY: all clean distclean mrproper install package
515 .PHONY: conf mconf oldconf kconf kmconf config menuconfig oldconfig
516 .PHONY: dummy libnet libpcap