1#
2# Broadcom Linux Router Makefile
3# 
4# Copyright 2004, Broadcom Corporation
5# All Rights Reserved.
6# 
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.
11#
12# $Id: Makefile,v 1.33 2009/02/18 08:52:03 james26_jang Exp $
13#
14
15include .config
16include .config.asus
17
18export CONFIG_MULTICONFIG := y
19
20#
21# Paths
22#
23
24# Source bases
25export PLATFORM LINUXDIR LIBDIR USRLIBDIR
26export TOP := $(shell pwd)
27export SRCBASE := $(shell (cd $(TOP)/.. && pwd -P))
28
29#
30# Cross-compile environment variables
31#
32
33# Build platform
34export BUILD := i386-pc-linux-gnu
35export HOSTCC := gcc
36
37# uClibc wrapper
38ifeq ($(CONFIG_UCLIBC),y)
39export PLATFORM := $(PLATFORM)-uclibc
40endif
41
42ifeq ($(PLATFORM),mipsel)
43export CROSS_COMPILE := mipsel-linux-
44export CONFIGURE := ./configure mipsel-linux --build=$(BUILD)
45export TOOLCHAIN := $(shell cd $(dir $(shell which $(CROSS_COMPILE)gcc))/../mipsel-linux && pwd -P)
46endif
47
48ifeq ($(PLATFORM),mipsel-uclibc)
49export CROSS_COMPILE := mipsel-uclibc-
50export CONFIGURE := ./configure mipsel-linux --build=$(BUILD)
51export TOOLCHAIN := $(shell cd $(dir $(shell which $(CROSS_COMPILE)gcc))/.. && pwd -P)
52endif
53
54ifeq ($(CONFIG_BCMWPA2),y)
55export CFLAGS += -DBCMWPA2 
56endif
57
58export CC := $(CROSS_COMPILE)gcc
59export AR := $(CROSS_COMPILE)ar
60export AS := $(CROSS_COMPILE)as
61export LD := $(CROSS_COMPILE)ld
62export NM := $(CROSS_COMPILE)nm
63export RANLIB := $(CROSS_COMPILE)ranlib
64export STRIP := $(CROSS_COMPILE)strip
65export SIZE := $(CROSS_COMPILE)size
66
67#
68# Install and target directories
69#
70
71export PLATFORMDIR := $(TOP)/$(PLATFORM)
72export INSTALLDIR := $(PLATFORMDIR)/install
73export TARGETDIR := $(PLATFORMDIR)/target
74
75# always build
76obj-y += libbcmcrypto 
77#obj-y += dnsmasq
78
79#
80# Configuration
81#
82
83obj-$(CONFIG_HTTPD) += httpd
84obj-$(CONFIG_RC) += rc
85obj-$(CONFIG_LIBBCM) += libbcm
86obj-$(CONFIG_SHARED) += shared
87#obj-$(CONFIG_WWW) += www
88ifeq ($(CONFIG_SENTRY5),y)
89include Makefiles5.cnf
90endif
91obj-$(CONFIG_GLIBC) += lib
92obj-$(CONFIG_UCLIBC) += lib
93obj-$(CONFIG_WLCONF) += wlconf
94obj-$(CONFIG_BRIDGE) += bridge
95obj-$(CONFIG_BUSYBOX) += busybox
96obj-$(CONFIG_DNSMASQ) += dproxy
97obj-$(CONFIG_IPTABLES) += iptables
98obj-$(CONFIG_LIBIPT) += iptables
99obj-$(CONFIG_NAS) += nas
100obj-$(CONFIG_NETCONF) += netconf
101obj-$(CONFIG_NTP) += ntpclient
102obj-$(CONFIG_NVRAM) += nvram
103#obj-$(CONFIG_PPP) += ppp
104obj-$(CONFIG_UDHCPD) += udhcpd
105obj-$(CONFIG_UPNP) += upnp
106obj-$(CONFIG_UTILS) += utils
107obj-$(CONFIG_ETC) += etc
108obj-$(CONFIG_VLAN) += vlan
109#obj-$(CONFIG_WSCCMD) += wsc/Wsccmd/src/linux
110obj-$(CONFIG_LLD2D) += lltd/wrt54g-linux
111
112
113# Added by Joey for ASUS application
114obj-$(CONFIG_PPPD) += pppd
115#obj-$(CONFIG_PPTP) += pptp-client
116#obj-$(CONFIG_PPPOE) += rp-pppoe
117obj-$(CONFIG_PPPOERELAY) += pppoe-relay
118obj-$(CONFIG_INFOSVR) += infosvr
119obj-$(CONFIG_EZIPUPDATE) += ez-ipupdate
120obj-$(CONFIG_JPEG6B) += jpeg-6b
121obj-$(CONFIG_RCAMD) += rcamdmips
122obj-$(CONFIG_SENDMAIL) += sendmail
123obj-$(CONFIG_LPRNG) += LPRng
124obj-$(CONFIG_OTHERS) += others
125obj-$(CONFIG_OV51X) += ov51x
126obj-$(CONFIG_TEST) += test
127obj-$(CONFIG_BPALOGIN) += bpalogin
128obj-$(CONFIG_IPROUTE2) += iproute2
129
130obj-$(CONFIG_ATTR) += attr
131obj-$(CONFIG_ACL) += acl
132obj-$(CONFIG_SAMBA) += samba
133obj-$(CONFIG_LIBCRYPTO) += libcrypto
134obj-$(CONFIG_DOSFSTOOLS) += dosfstools
135obj-$(CONFIG_VSFTPD) += vsftpd
136obj-$(CONFIG_L2TP) += rp-l2tp
137obj-$(CONFIG_IGMPPROXY) += igmpproxy
138
139obj-$(CONFIG_UTELNETD) += utelnetd
140obj-$(CONFIG_LIBDISK) += libdisk	# 2007.10 James
141obj-$(CONFIG_WANDUCK) += wanduck	# 2007.10 James
142obj-$(CONFIG_NETWORKMAP) += networkmap #2008.06.25 Yau add
143obj-$(CONFIG_FDISK) += fdisk	# 2008.04 James
144obj-$(CONFIG_MKDOSFS) += mkdosfs	# 2008.04 James
145obj-$(CONFIG_E2FSPROGS) += e2fsprogs-1.40.8	# 2008.04 James
146
147obj-$(CONFIG_LIBUSB) += libusb
148obj-$(CONFIG_U2EC) += u2ec
149
150# HSDPA
151#obj-y += AT
152#obj-y += usb_modeswitch-1.0.2
153
154obj-clean := $(foreach obj,$(obj-y) $(obj-n),$(obj)-clean)
155obj-install := $(foreach obj,$(obj-y),$(obj)-install)
156
157export LANGUAGE := "EN"
158export USB_WAN := "NONE"
159
160#
161# Basic rules
162#
163
164all: $(obj-y) $(LINUXDIR)/.config
165	# Also build kernel
166	#( . $(LINUXDIR)/.config ; \
167	#if [ "$${CONFIG_EMBEDDED_RAMDISK}" = "" ] ; then \
168	#    $(MAKE) -C $(LINUXDIR) zImage ; \
169	#fi ; \
170	#if [ "$${CONFIG_MODULES}" = "y" ] ; then \
171	#    $(MAKE) -C $(LINUXDIR) modules ; \
172	#fi )
173	. $(LINUXDIR)/.config
174	$(MAKE) -C $(LINUXDIR) zImage
175	$(MAKE) -C $(LINUXDIR) modules
176
177clean: $(obj-clean) config-clean
178	rm -rf $(TARGETDIR)
179	rm -f $(PLATFORMDIR)/linux.trx $(PLATFORMDIR)/vmlinuz $(PLATFORMDIR)/target.cramfs
180	rm -f full usb20 520gu 500gpv2
181	$(MAKE) -C $(LINUXDIR) clean
182	cd $(LINUXDIR) && rm -f `find -name .depend` && cd $(TOP)
183	cd $(PLATFORMDIR) && rm -rf temp && mkdir temp && cd install && cp -rf CVS lltd nas wsc utils ../temp && rm -rf * && cp -rf ../temp/* . && rm -rf ../temp && cd ../..
184
185distclean mrproper: clean
186	rm -f .config $(LINUXDIR)/.config
187
188install package: $(filter-out lib-install,$(obj-install)) $(LINUXDIR)/.config
189	# Install binaries into target directory
190	install -d $(TARGETDIR)
191	for dir in $(wildcard $(patsubst %,$(INSTALLDIR)/%,$(obj-y))) ; do \
192            (cd $${dir} && tar cpf - .) | (cd $(TARGETDIR) && tar xpf -) \
193        done
194	# optimize the crypto library by removing unneeded symbols
195	[ ! -d libbcmcrypto ] || $(MAKE) -C libbcmcrypto optimize
196	# Install (and possibly optimize) C library
197	$(MAKE) lib-install
198	# Install modules into filesystem
199	if grep -q "CONFIG_MODULES=y" $(LINUXDIR)/.config ; then \
200            $(MAKE) -C $(LINUXDIR) modules_install DEPMOD=/bin/true INSTALL_MOD_PATH=$(TARGETDIR) ; \
201        fi
202	find $(TARGETDIR) -name "wl_*.o"  | xargs rm -rf
203	# Prepare filesystem
204	cd $(TARGETDIR) && $(TOP)/misc/rootprep.sh
205	# Make sure mkcramfs-2.0 is used
206	$(MAKE) -C $(LINUXDIR)/scripts/cramfs mkcramfs
207	# '-u 0 -g 0' will set the uid and gid of all the files to 0 (root)
208	# These options are currently only available on our version of mkcramfs
209	#$(LINUXDIR)/scripts/cramfs/mkcramfs -u 0 -g 0 $(TARGETDIR) $(PLATFORMDIR)/target.cramfs
210	# Package kernel and filesystem
211	#if grep -q "CONFIG_EMBEDDED_RAMDISK=y" $(LINUXDIR)/.config ; then \
212        #    cp $(PLATFORMDIR)/target.cramfs $(LINUXDIR)/arch/mips/ramdisk/$${CONFIG_EMBEDDED_RAMDISK_IMAGE} ; \
213        #    $(MAKE) -C $(LINUXDIR) zImage ; \
214        #else \
215        #    cp $(LINUXDIR)/arch/mips/brcm-boards/bcm947xx/compressed/vmlinuz $(PLATFORMDIR)/ ; \
216        #    ../../tools/trx -o $(PLATFORMDIR)/linux.trx $(PLATFORMDIR)/vmlinuz $(PLATFORMDIR)/target.cramfs ; \
217        #fi
218        # Pad self-booting Linux to a 64 KB boundary
219	#cp $(LINUXDIR)/arch/mips/brcm-boards/bcm947xx/compressed/zImage $(PLATFORMDIR)/
220	#dd conv=sync bs=64k < $(PLATFORMDIR)/zImage > $(PLATFORMDIR)/linux.bin
221	# Append filesystem to self-booting Linux
222	#cat $(PLATFORMDIR)/target.cramfs >> $(PLATFORMDIR)/linux.bin
223	cp -f $(LINUXDIR)/arch/mips/brcm-boards/bcm947xx/compressed/vmlinuz $(PLATFORMDIR)/
224
225
226#
227# Configuration rules
228#
229
230conf mconf:
231	$(MAKE) -C config
232	@./config/$@ ./config/Config
233	# Also configure kernel
234	$(MAKE) k$@
235
236oldconf: .config
237	$(MAKE) -C config
238	@./config/conf -o ./config/Config
239	# Also configure kernel
240	$(MAKE) k$@
241
242kconf:
243	$(MAKE) -C $(LINUXDIR) config
244
245kmconf:
246	$(MAKE) -C $(LINUXDIR) menuconfig
247
248koldconf: $(LINUXDIR)/.config
249	$(MAKE) -C $(LINUXDIR) oldconfig
250
251# Convenience
252config: conf
253
254menuconfig: mconf
255
256oldconfig: oldconf
257
258# Default configurations
259.config:
260	cp -f config/defconfig $@
261	$(MAKE) oldconfig
262
263$(LINUXDIR)/.config:
264	cp -f $(LINUXDIR)/arch/mips/defconfig-bcm947xx $@
265
266#
267# Overrides
268#
269
270# 2007.10 James. add libdisk.
271shared:
272	$(MAKE) -C $@ install INSTALLDIR=$(INSTALLDIR)/$@
273
274libdisk: nvram shared
275	$(MAKE) -C $@ install INSTALLDIR=$(INSTALLDIR)/$@
276
277OBJS_httpd = netconf nvram shared $(EXTRA_LIBS)
278ifeq ($(CONFIG_LIBDISK),y)
279OBJS_httpd += libdisk
280endif
281httpd: $(OBJS_httpd)
282	$(MAKE) -C $@ install INSTALLDIR=$(INSTALLDIR)/$@
283
284rc: netconf nvram shared libbcmcrypto $(EXTRA_LIBS)
285
286wanduck: nvram shared
287
288www www-%:
289	$(MAKE) -C www/$(CONFIG_VENDOR) $* INSTALLDIR=$(INSTALLDIR)/www
290
291wwwmt wwwmt-%:
292	$(MAKE) -C www/mea $* INSTALLDIR=$(INSTALLDIR)/www
293
294ifeq ($(CONFIG_SENTRY5),y)
295include $(TOP)/Makefiles5.mk
296endif
297
298bridge:
299	$(MAKE) -C bridge brctl/brctl
300
301bridge-install: bridge
302	install -D bridge/brctl/brctl $(INSTALLDIR)/bridge/usr/sbin/brctl
303	$(STRIP) $(INSTALLDIR)/bridge/usr/sbin/brctl
304
305busybox:
306	cd busybox && rm -f Config.h && ln -sf configs/$(CONFIG_BUSYBOX_CONFIG).h Config.h
307	$(MAKE) -C busybox STRIPTOOL=$(STRIP)
308
309busybox-clean:
310	cd busybox && rm -f Config.h && ln -sf configs/$(CONFIG_BUSYBOX_CONFIG).h Config.h && cd ..
311	$(MAKE) -C busybox clean
312
313busybox-install: busybox
314	$(MAKE) -C busybox STRIPTOOL=$(STRIP) PREFIX=$(INSTALLDIR)/busybox install
315
316dproxy:
317	$(MAKE) -C dproxy
318
319dproxy-install: dproxy
320	install -D dproxy/dproxy $(INSTALLDIR)/dproxy/usr/sbin/dproxy
321	$(STRIP) $(INSTALLDIR)/dproxy/usr/sbin/dproxy
322
323ez-ipupdate-install: ez-ipupdate
324	install -D ez-ipupdate/ez-ipupdate $(INSTALLDIR)/ez-ipupdate/usr/sbin/ez-ipupdate
325	$(STRIP) $(INSTALLDIR)/ez-ipupdate/usr/sbin/ez-ipupdate
326
327iptables:
328	$(MAKE) -C iptables BINDIR=/usr/sbin LIBDIR=/usr/lib KERNEL_DIR=$(LINUXDIR)
329
330iptables-install: iptables
331ifeq ($(CONFIG_IPTABLES),y)
332	install -d $(INSTALLDIR)/iptables/usr/lib/iptables
333	install iptables/extensions/*.so $(INSTALLDIR)/iptables/usr/lib/iptables
334	$(STRIP) $(INSTALLDIR)/iptables/usr/lib/iptables/*.so
335	install -D iptables/iptables $(INSTALLDIR)/iptables/usr/sbin/iptables
336	$(STRIP) $(INSTALLDIR)/iptables/usr/sbin/iptables
337endif
338ifeq ($(CONFIG_LIBIPT),y)
339	install -d $(INSTALLDIR)/iptables/usr/lib/iptables
340	install iptables/extensions/*.so $(INSTALLDIR)/iptables/usr/lib/iptables
341	$(STRIP) $(INSTALLDIR)/iptables/usr/lib/iptables/*.so
342	install -D iptables/iptables-restore $(INSTALLDIR)/iptables/usr/sbin/iptables-restore
343	$(STRIP) $(INSTALLDIR)/iptables/usr/sbin/iptables-restore
344endif
345
346iptables-clean:
347	-$(MAKE) -C iptables KERNEL_DIR=$(LINUXDIR) clean
348
349iproute2-clean:
350	cd iproute2/include-glibc/bits && ln -sf ../socketbits.h socket.h && cd ../../../
351	cd iproute2/reference && ln -sf asm-mips asm
352	$(MAKE) -C iproute2 clean
353
354netconf: iptables
355
356ppp ppp-%:
357	$(MAKE) -C ppp/pppoecd $* INSTALLDIR=$(INSTALLDIR)/ppp
358
359udhcpd-install: udhcpd
360	install -D udhcpd/udhcpd $(INSTALLDIR)/udhcpd/usr/sbin/udhcpd
361	$(STRIP) $(INSTALLDIR)/udhcpd/usr/sbin/udhcpd
362	cd $(INSTALLDIR)/udhcpd/usr/sbin && ln -sf udhcpd udhcpc
363
364upnp: netconf nvram shared
365
366wlconf: nvram shared
367
368vlan:
369	$(MAKE) -C vlan CROSS=$(CROSS_COMPILE) STRIPTOOL=$(STRIP)
370
371vlan-install:
372	$(MAKE) -C vlan CROSS=$(CROSS_COMPILE) STRIPTOOL=$(STRIP) INSTALLDIR=$(INSTALLDIR) install
373
374vlan-clean:
375	$(MAKE) -C vlan clean
376
377pptp-client-install: pptp-client
378	install -D pptp-client/pptp $(INSTALLDIR)/pptp-client/usr/sbin/pptp
379	$(STRIP) $(INSTALLDIR)/pptp-client/usr/sbin/pptp
380
381pppd:
382	$(MAKE) -C pppd/pppd
383	$(MAKE) -C pppd/pppd/plugins
384
385pppd-install: pppd
386	$(STRIP) pppd/pppd/pppd
387	install -D pppd/pppd/pppd $(INSTALLDIR)/pppd/usr/sbin/pppd
388#	install -D pppd/chat/chat $(INSTALLDIR)/pppd/usr/sbin/chat
389#	$(STRIP) $(INSTALLDIR)/pppd/usr/sbin/chat
390	$(STRIP) pppd/pppd/plugins/rp-pppoe/rp-pppoe.so
391	install -D pppd/pppd/plugins/rp-pppoe/rp-pppoe.so $(INSTALLDIR)/pppd/usr/lib/pppd/rp-pppoe.so
392	$(STRIP) pppd/pppd/plugins/pppol2tp.so
393	install -D pppd/pppd/plugins/pppol2tp.so $(INSTALLDIR)/pppd/usr/lib/pppd/pppol2tp.so
394	$(STRIP) pppd/pppd/plugins/pptp/pptp.so
395	install -D pppd/pppd/plugins/pptp/pptp.so $(INSTALLDIR)/pppd/usr/lib/pppd/pptp.so
396
397pppd-clean:
398	cd pppd && ln -sf linux/Makefile.top Makefile && \
399	cd chat && ln -sf Makefile.linux Makefile && cd .. && \
400	cd pppd && ln -sf Makefile.linux Makefile && cd plugins && ln -sf Makefile.linux Makefile && cd radius && ln -sf Makefile.linux Makefile && cd ../rp-pppoe && ln -sf Makefile.linux Makefile && cd ../../.. && \
401	cd pppdump && ln -sf Makefile.linux Makefile && cd .. && \
402	cd pppstats && ln -sf Makefile.linux Makefile && cd .. && \
403	cd ..
404	$(MAKE) -C pppd/pppd clean
405	$(MAKE) -C pppd/pppd/plugins clean
406
407samba: attr acl
408
409acl: attr
410
411rp-l2tp-install: rp-l2tp
412	install -D rp-l2tp/l2tpd $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tpd
413	install -D rp-l2tp/handlers/l2tp-control $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tp-control
414	install -d $(INSTALLDIR)/rp-l2tp/usr/lib/l2tp/plugins
415	install -D rp-l2tp/handlers/*.so $(INSTALLDIR)/rp-l2tp/usr/lib/l2tp/plugins
416
417igmpproxy:
418	$(MAKE) -C igmpproxy/src
419
420igmpproxy-install: igmpproxy
421	install -D igmpproxy/src/igmpproxy $(INSTALLDIR)/igmpproxy/usr/sbin/igmpproxy
422	
423igmpproxy-clean:
424	$(MAKE) -C igmpproxy/src clean
425                                                                                                                  
426utelnetd-install: utelnetd
427	install -D utelnetd/utelnetd $(INSTALLDIR)/utelnetd/usr/sbin/utelnetd
428
429checkout-%: 
430	# Get up-to-date source from CVS
431	cvs -d:pserver:$*@192.168.39.9:/WL500g login
432	cd $(LINUXDIR) && cvs co 
433	cd $(TOP) 
434	for dir in $(obj-y) ; do \
435	    cvs co $${dir} \
436	done
437
438image-%:
439ifeq ($(CONFIG_MULTICONFIG),y)
440	( if [ "$*" = "WL500gpv2" ]; then \
441		( if [ -f ./500gpv2 ]; then \
442			echo "the same configuration"; \
443		else \
444			make clean; \
445			cp -f ./config.asus/linux.config.500gp ../linux/linux/.config; \
446			make menuconfig; \
447			cd ../linux/linux && make dep && make modules && cd ../../router; \
448			cp -f ./config.asus/busybox.router.h.500gp ./busybox/configs/router.h; \
449			cp -f ./config.asus/router.config.500gp ./.config.asus; \
450			make netconf; \
451			make all; \
452			rm -f usb20; \
453			rm -f 500gpv2; \
454			touch 500gpv2; \
455		fi ) \
456	elif [ "$*" = "WL520gu" ]; then \
457		( if [ -f ./520gu ]; then \
458			echo "the same configuration"; \
459		else \
460			make clean; \
461			cp -f ./config.asus/linux.config.520gu ../linux/linux/.config; \
462			make menuconfig; \
463			cd ../linux/linux && make dep && make modules && cd ../../router; \
464			cp -f ./config.asus/busybox.router.h.520gu ./busybox/configs/router.h; \
465			cp -f ./config.asus/router.config.520gu ./.config.asus; \
466			make netconf; \
467			make all; \
468			rm -f usb20; \
469			rm -f 520gu; \
470			touch 520gu; \
471		fi ) \
472	else \
473		( if [ -f ./full ]; then \
474			echo "the same configuration"; \
475		else \
476			cp -f ./config.asus/linux.config.full ../linux/linux/.config; \
477			cp -f ./config.asus/router.config.full ./.config.asus; \
478			cp -f ./config.asus/busybox.router.h.full ./busybox/configs/router.h; \
479			cd ../linux/linux && make dep && cd ../../router; \
480			make menuconfig; \
481			cp -f ./config.asus/router.config.full ./.config.asus; \
482			make clean; \
483			make netconf; \
484			make all; \
485			rm -f lite; \
486			rm -f usb20; \
487			touch full; \
488		fi ) \
489	fi )
490endif
491#	( if [ "$*" = "WL520g" ]; then \
492#		rm -rf pppd; \
493#                rm -rf pptp-client; \
494#                cp -rf pppd.orig pppd; \
495#                cp -rf pptp-client.orig pptp-client; \
496#	else \
497#                rm -rf pppd; \
498#                rm -rf pptp-client; \
499#                cp -rf pppd.mppe pppd; \
500#                cp -rf pptp-client.mppe pptp-client; \
501#	fi )
502
503	# clean folders for multiple compile
504	make rc-clean
505	make infosvr-clean
506	make LPRng-clean
507	make vlan-clean
508	make shared-clean
509	make httpd-clean
510ifeq ($(CONFIG_LIBDISK),y)
511	make libdisk-clean	# 2007.10 James
512endif
513ifeq ($(CONFIG_WANDUCK),y)
514	make wanduck-clean
515endif
516	
517	cd $(TOP)/mipsel/install/nas/usr/sbin && ln -sf nas nas4not && cd $(TOP)
518	
519	$(MAKE) -C $(LINUXDIR) zImage
520	$(MAKE) -C $(LINUXDIR) modules
521
522	cd library/lib && \
523	ln -sf libbackup.so.0 libbackup.so && \
524	ln -sf libbackup.so.0.0 libbackup.so.0 && \
525	ln -sf libfilesharing.so.0 libfilesharing.so && \
526	ln -sf libfilesharing.so.0.0 libfilesharing.so.0 && \
527	ln -sf libflash.so.0 libflash.so && \
528	ln -sf libflash.so.0.0 libflash.so.0 && \
529	ln -sf libhd.so.0 libhd.so && \
530	ln -sf libhd.so.0.0 libhd.so.0 && \
531	ln -sf libiconv.so.0 libiconv.so && \
532	ln -sf libiconv.so.0.0 libiconv.so.0 && \
533	ln -sf libnetcgi.so.0 libnetcgi.so && \
534	ln -sf libnetcgi.so.0.0 libnetcgi.so.0 && \
535	ln -sf libnetwork.so.1 libnetwork.so && \
536	ln -sf libnetwork.so.1.0 libnetwork.so.1 && \
537	ln -sf libntpass.so.0 libntpass.so && \
538	ln -sf libntpass.so.0.0 libntpass.so.0 && \
539	ln -sf libprofile.so.0 libprofile.so && \
540	ln -sf libprofile.so.0.0 libprofile.so.0 && \
541	ln -sf libsamba.so.1 libsamba.so && \
542	ln -sf libsamba.so.1.0 libsamba.so.1 && \
543	ln -sf libschl.so.0 libschl.so && \
544	ln -sf libschl.so.0.0 libschl.so.0 && \
545	ln -sf libsystem.so.0 libsystem.so && \
546	ln -sf libsystem.so.0.0 libsystem.so.0 && \
547	cd ../..
548	
549	( if [ "$*" = "WL500gpv2" ]; then \
550		make shared GLOBAL_OPTIONS="-DDLM" CONFIG_DLM=y; \
551		make rc GLOBAL_OPTIONS="-DWL500GPV2 -DWPA2_WMM -DWOB -DRPPPPOE -DBTN_SETUP -DURE -DUSB_SUPPORT -DWSC -DWCN -DQOS -DWEB_REDIRECT -DDLM -DU2EC" CONFIG_BTNSETUP=y CONFIG_DLM=y; \
552		make infosvr GLOBAL_OPTIONS="-DPRNINFO -DNO_PARALLEL"; \
553		make LPRng GLOBAL_OPTIONS="-DUSBONLY"; \
554		make httpd GLOBAL_OPTIONS="-DWL500GPV2 -DDLM -DWSC -DU2EC" CONFIG_NOUSB=n MODEL_NAME=WL-500gP\ V2 CONFIG_DLM=y; \
555		make wanduck GLOBAL_OPTIONS="-DWL500GPV2"; \
556	elif [ "$*" = "WL520gu" ]; then \
557		make shared GLOBAL_OPTIONS="" CONFIG_DLM=n; \
558		make rc GLOBAL_OPTIONS="-DWL520GU -DWPA2_WMM -DWOB -DRPPPPOE -DBTN_SETUP -DURE -DUSB_SUPPORT -DWSC -DWCN -DQOS -DWEB_REDIRECT -DU2EC" CONFIG_BTNSETUP=y; \
559		make infosvr GLOBAL_OPTIONS="-DPRNINFO -DNO_PARALLEL"; \
560		make LPRng GLOBAL_OPTIONS="-DUSBONLY"; \
561		make httpd GLOBAL_OPTIONS="-DWL520GU -DWSC -DU2EC" CONFIG_NOUSB=n MODEL_NAME=WL-520GU CONFIG_DLM=n; \
562		make wanduck GLOBAL_OPTIONS="-DWL520GU"; \
563	else \
564		echo "no such model name"; \
565	fi )
566
567	#make www-install-$*
568 
569	rm $(PLATFORMDIR)/target/usr/sbin/waveserver -f
570
571	# install Vista support utility before lib-opt 
572	( if [ "$*" = "WL520gu" ] || [ "$*" = "WL500gpv2" ]; then \
573		mkdir $(PLATFORMDIR)/target/; \
574		mkdir $(PLATFORMDIR)/target/bin; \
575		mkdir $(PLATFORMDIR)/target/usr/; \
576		mkdir $(PLATFORMDIR)/target/usr/sbin; \
577		cp -rf $(PLATFORMDIR)/install/wsc/Wsccmd/src/linux/bin/* $(PLATFORMDIR)/target/bin -f; \
578		cp -rf $(PLATFORMDIR)/install/lltd/wrt54g-linux/usr/sbin/* $(PLATFORMDIR)/target/usr/sbin -f; \
579	fi )
580	
581	( if [ "$*" = "WL500gpv2" ]; then \
582		$(MAKE) -C rc install CONFIG_DLM=y INSTALLDIR=$(INSTALLDIR)/rc; \
583	elif [ "$*" = "WL520gu" ]; then \
584		$(MAKE) -C rc install INSTALLDIR=$(INSTALLDIR)/rc; \
585	else \
586		echo "no such model name"; \
587	fi )
588
589#	mkdir -p $(PLATFORMDIR)/target/usr/sbin
590#	cp -f $(TOP)/pppd.mppe/chat/chat $(PLATFORMDIR)/target/usr/sbin/
591
592	make install 
593	
594ifeq ($(CONFIG_BPLAY),y)
595	cp -f others/waveserver $(PLATFORMDIR)/target/usr/sbin/
596endif
597
598# Compile TW version for WL500GPv2 including CN, TW, and KR USB modules
599	( if [ "$(LANGUAGE)" = "TW" ]; then \
600		( if [ "$*" = "WL500gpv2" ]; then \
601			rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp932.o; \
602		else \
603			rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp949.o; \
604			rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp932.o; \
605		fi ) \
606	elif [ "$(LANGUAGE)" = "CN" ] || [ "$(LANGUAGE)" = "ML" ]; then \
607		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp932.o; \
608		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp949.o; \
609	elif [ "$(LANGUAGE)" = "KR" ]; then \
610		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp932.o; \
611		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp936.o; \
612		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp950.o; \
613	elif [ "$(LANGUAGE)" = "JP" ]; then \
614		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp950.o; \
615		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp936.o; \
616		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp949.o; \
617	else \
618		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp932.o; \
619		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp936.o; \
620		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp949.o; \
621		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp950.o; \
622	fi )
623
624#	install: ./libgcc_s.so.1
625
626	( if [ "$*" = "WL500gpv2" ]; then \
627		rm -rf $(PLATFORMDIR)/target/apps; \
628		mkdir $(PLATFORMDIR)/target/apps; \
629		mkdir $(PLATFORMDIR)/target/apps/bin; \
630		cd 500gp && tar xzf exinstall.tgz && cd ..; \
631		cp -f 500gp/exinstall/bin/dms $(PLATFORMDIR)/target/apps/bin; \
632		cp -rf 500gp 500gp.tmp; \
633		rm -rf 500gp.tmp/exinstall/bin/dms; \
634		cd 500gp.tmp/exinstall && find > $(PLATFORMDIR)/target/apps/list && cd ../..; \
635		$(TOP)/shared/crc_gen $(PLATFORMDIR)/target/apps/list $(PLATFORMDIR)/target/apps/crc $(TOP)/500gp.tmp/exinstall/; \
636		rm -rf 500gp.tmp; \
637		make lib-install; \
638		cd $(TARGETDIR) && rm -rf shares && ln -s tmp shares; \
639		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/parport/* -f; \
640	fi )
641#	( if [ "$*" = "WL520gu" ]; then \
642#		rm -rf $(PLATFORMDIR)/target/apps; \
643#		cd $(TARGETDIR) && rm -rf shares && ln -s tmp shares; \
644#		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/parport/* -f; \
645#		rm $(PLATFORMDIR)/target/usr/sbin/waveserver -f; \
646#		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/drivers/media -rf; \
647#		rm $(PLATFORMDIR)/target/usr/sbin/et -rf; \
648#		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/drivers/usb/serial -rf; \
649#		rm $(PLATFORMDIR)/target/usr/sbin/pppoecd -f; \
650#		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/drivers/usb/hcd/* -f; \
651#		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs -rf; \
652#		rm $(PLATFORMDIR)/target/usr/sbin/test -f; \
653#		rm $(PLATFORMDIR)/target/usr/sbin/pppoe -f; \
654#		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/pcmcia -rf; \
655#	fi )
656	( if [ "$*" = "WL520gu" ]; then \
657		cd $(TARGETDIR) && rm -rf shares && ln -s tmp shares; \
658		rm $(PLATFORMDIR)/target/usr/sbin/et -rf; \
659		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs -rf; \
660		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/pcmcia -rf; \
661	fi )
662	
663	( if [ $(CONFIG_OTHERS) = "n" ]; then \
664		cd $(PLATFORMDIR)/target/etc/ && ln -sf /tmp/resolv.conf resolv.conf; cd -; \
665		cd $(PLATFORMDIR)/target/etc/ && ln -sf /tmp/hosts hosts; cd -; \
666		cd $(PLATFORMDIR)/target/etc/ && ln -sf /tmp/TZ TZ; cd -; \
667		cp -f $(TOP)/others/services $(PLATFORMDIR)/target/etc/services; \
668		cp -f $(TOP)/others/protocols $(PLATFORMDIR)/target/etc/protocols; \
669		echo "order hosts,bind" > $(PLATFORMDIR)/target/etc/host.conf; \
670		echo "hosts: files dns" > $(PLATFORMDIR)/target/etc/nsswitch.conf; \
671	fi )
672
673	cd $(PLATFORMDIR) && make $* && cd ..
674
675images-%:
676#	make image-$* LANGUAGE="EN"
677#	make image-$* LANGUAGE="KR"
678	make image-$* LANGUAGE="TW"
679#	make image-$* LANGUAGE="CN"
680
681images:
682	make images-WL500gx
683	make images-WL500g
684
685
686#
687# Generic rules
688#
689
690%:
691	[ ! -d $* ] || $(MAKE) -C $*
692
693%-clean:
694	[ ! -d $* ] || $(MAKE) -C $* clean
695
696%-install:
697	[ ! -d $* ] || $(MAKE) -C $* install INSTALLDIR=$(INSTALLDIR)/$*
698
699$(obj-y) $(obj-n) $(obj-clean) $(obj-install): dummy
700
701.PHONY: all clean distclean mrproper install package
702.PHONY: conf mconf oldconf kconf kmconf config menuconfig oldconfig
703.PHONY: dummy
704