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
147#obj-$(CONFIG_LIBUSB) += libusb
148#obj-$(CONFIG_U2EC) += u2ec
149
150# HSDPA
151#obj-y += AT
152obj-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
323iptables:
324	$(MAKE) -C iptables BINDIR=/usr/sbin LIBDIR=/usr/lib KERNEL_DIR=$(LINUXDIR)
325
326iptables-install: iptables
327ifeq ($(CONFIG_IPTABLES),y)
328	install -d $(INSTALLDIR)/iptables/usr/lib/iptables
329	install iptables/extensions/*.so $(INSTALLDIR)/iptables/usr/lib/iptables
330	$(STRIP) $(INSTALLDIR)/iptables/usr/lib/iptables/*.so
331	install -D iptables/iptables $(INSTALLDIR)/iptables/usr/sbin/iptables
332	$(STRIP) $(INSTALLDIR)/iptables/usr/sbin/iptables
333endif
334ifeq ($(CONFIG_LIBIPT),y)
335	install -d $(INSTALLDIR)/iptables/usr/lib/iptables
336	install iptables/extensions/*.so $(INSTALLDIR)/iptables/usr/lib/iptables
337	$(STRIP) $(INSTALLDIR)/iptables/usr/lib/iptables/*.so
338	install -D iptables/iptables-restore $(INSTALLDIR)/iptables/usr/sbin/iptables-restore
339	$(STRIP) $(INSTALLDIR)/iptables/usr/sbin/iptables-restore
340endif
341
342iptables-clean:
343	-$(MAKE) -C iptables KERNEL_DIR=$(LINUXDIR) clean
344
345iproute2-clean:
346	cd iproute2/include-glibc/bits && ln -sf ../socketbits.h socket.h && cd ../../../
347	cd iproute2/reference && ln -sf asm-mips asm
348	$(MAKE) -C iproute2 clean
349
350netconf: iptables
351
352ppp ppp-%:
353	$(MAKE) -C ppp/pppoecd $* INSTALLDIR=$(INSTALLDIR)/ppp
354
355udhcpd-install: udhcpd
356	install -D udhcpd/udhcpd $(INSTALLDIR)/udhcpd/usr/sbin/udhcpd
357	$(STRIP) $(INSTALLDIR)/udhcpd/usr/sbin/udhcpd
358	cd $(INSTALLDIR)/udhcpd/usr/sbin && ln -sf udhcpd udhcpc
359
360upnp: netconf nvram shared
361
362wlconf: nvram shared
363
364vlan:
365	$(MAKE) -C vlan CROSS=$(CROSS_COMPILE) STRIPTOOL=$(STRIP)
366
367vlan-install:
368	$(MAKE) -C vlan CROSS=$(CROSS_COMPILE) STRIPTOOL=$(STRIP) INSTALLDIR=$(INSTALLDIR) install
369
370vlan-clean:
371	$(MAKE) -C vlan clean
372
373pptp-client-install: pptp-client
374	install -D pptp-client/pptp $(INSTALLDIR)/pptp-client/usr/sbin/pptp
375	$(STRIP) $(INSTALLDIR)/pptp-client/usr/sbin/pptp
376
377pppd:
378	$(MAKE) -C pppd/pppd
379	$(MAKE) -C pppd/pppd/plugins
380
381pppd-install: pppd
382	$(STRIP) pppd/pppd/pppd
383	install -D pppd/pppd/pppd $(INSTALLDIR)/pppd/usr/sbin/pppd
384#	install -D pppd/chat/chat $(INSTALLDIR)/pppd/usr/sbin/chat
385#	$(STRIP) $(INSTALLDIR)/pppd/usr/sbin/chat
386	$(STRIP) pppd/pppd/plugins/rp-pppoe/rp-pppoe.so
387	install -D pppd/pppd/plugins/rp-pppoe/rp-pppoe.so $(INSTALLDIR)/pppd/usr/lib/pppd/rp-pppoe.so
388	$(STRIP) pppd/pppd/plugins/pppol2tp.so
389	install -D pppd/pppd/plugins/pppol2tp.so $(INSTALLDIR)/pppd/usr/lib/pppd/pppol2tp.so
390	$(STRIP) pppd/pppd/plugins/pptp/pptp.so
391	install -D pppd/pppd/plugins/pptp/pptp.so $(INSTALLDIR)/pppd/usr/lib/pppd/pptp.so
392
393pppd-clean:
394	cd pppd && ln -sf linux/Makefile.top Makefile && \
395	cd chat && ln -sf Makefile.linux Makefile && cd .. && \
396	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 ../../.. && \
397	cd pppdump && ln -sf Makefile.linux Makefile && cd .. && \
398	cd pppstats && ln -sf Makefile.linux Makefile && cd .. && \
399	cd ..
400	$(MAKE) -C pppd/pppd clean
401	$(MAKE) -C pppd/pppd/plugins clean
402
403samba: attr acl
404
405acl: attr
406
407rp-l2tp-install: rp-l2tp
408	install -D rp-l2tp/l2tpd $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tpd
409	install -D rp-l2tp/handlers/l2tp-control $(INSTALLDIR)/rp-l2tp/usr/sbin/l2tp-control
410	install -d $(INSTALLDIR)/rp-l2tp/usr/lib/l2tp/plugins
411	install -D rp-l2tp/handlers/*.so $(INSTALLDIR)/rp-l2tp/usr/lib/l2tp/plugins
412
413igmpproxy:
414	$(MAKE) -C igmpproxy/src
415
416igmpproxy-install: igmpproxy
417	install -D igmpproxy/src/igmpproxy $(INSTALLDIR)/igmpproxy/usr/sbin/igmpproxy
418	
419igmpproxy-clean:
420	$(MAKE) -C igmpproxy/src clean
421                                                                                                                  
422utelnetd-install: utelnetd
423	install -D utelnetd/utelnetd $(INSTALLDIR)/utelnetd/usr/sbin/utelnetd
424
425checkout-%: 
426	# Get up-to-date source from CVS
427	cvs -d:pserver:$*@192.168.39.9:/WL500g login
428	cd $(LINUXDIR) && cvs co 
429	cd $(TOP) 
430	for dir in $(obj-y) ; do \
431	    cvs co $${dir} \
432	done
433
434image-%:
435ifeq ($(CONFIG_MULTICONFIG),y)
436	( if [ "$*" = "WL500gpv2" ]; then \
437		( if [ -f ./500gpv2 ]; then \
438			echo "the same configuration"; \
439		else \
440			make clean; \
441			cp -f ./config.asus/linux.config.500gp_HSDPA ../linux/linux/.config; \
442			make menuconfig; \
443			cd ../linux/linux && make dep && make modules && cd ../../router; \
444			cp -f ./config.asus/busybox.router.h.500gp ./busybox/configs/router.h; \
445			cp -f ./config.asus/router.config.500gp ./.config.asus; \
446			make netconf; \
447			make all; \
448			rm -f usb20; \
449			rm -f 500gpv2; \
450			touch 500gpv2; \
451		fi ) \
452	elif [ "$*" = "WL520gu" ]; then \
453		( if [ -f ./520gu ]; then \
454			echo "the same configuration"; \
455		else \
456			make clean; \
457			cp -f ./config.asus/linux.config.520gu_HSDPA ../linux/linux/.config; \
458			make menuconfig; \
459			cd ../linux/linux && make dep && make modules && cd ../../router; \
460			cp -f ./config.asus/busybox.router.h.520gu ./busybox/configs/router.h; \
461			cp -f ./config.asus/router.config.520gu ./.config.asus; \
462			make netconf; \
463			make all; \
464			rm -f usb20; \
465			rm -f 520gu; \
466			touch 520gu; \
467		fi ) \
468	else \
469		( if [ -f ./full ]; then \
470			echo "the same configuration"; \
471		else \
472			cp -f ./config.asus/linux.config.full ../linux/linux/.config; \
473			cp -f ./config.asus/router.config.full ./.config.asus; \
474			cp -f ./config.asus/busybox.router.h.full ./busybox/configs/router.h; \
475			cd ../linux/linux && make dep && cd ../../router; \
476			make menuconfig; \
477			cp -f ./config.asus/router.config.full ./.config.asus; \
478			make clean; \
479			make netconf; \
480			make all; \
481			rm -f lite; \
482			rm -f usb20; \
483			touch full; \
484		fi ) \
485	fi )
486endif
487#	( if [ "$*" = "WL520g" ]; then \
488#		rm -rf pppd; \
489#                rm -rf pptp-client; \
490#                cp -rf pppd.orig pppd; \
491#                cp -rf pptp-client.orig pptp-client; \
492#	else \
493#                rm -rf pppd; \
494#                rm -rf pptp-client; \
495#                cp -rf pppd.mppe pppd; \
496#                cp -rf pptp-client.mppe pptp-client; \
497#	fi )
498
499	# clean folders for multiple compile
500	make rc-clean
501	make infosvr-clean
502	make LPRng-clean
503	make vlan-clean
504	make shared-clean
505	make httpd-clean
506ifeq ($(CONFIG_LIBDISK),y)
507	make libdisk-clean	# 2007.10 James
508endif
509ifeq ($(CONFIG_WANDUCK),y)
510	make wanduck-clean
511endif
512	
513	cd $(TOP)/mipsel/install/nas/usr/sbin && ln -sf nas nas4not && cd $(TOP)
514	
515	$(MAKE) -C $(LINUXDIR) zImage
516	$(MAKE) -C $(LINUXDIR) modules
517
518	cd library/lib && \
519	ln -sf libbackup.so.0 libbackup.so && \
520	ln -sf libbackup.so.0.0 libbackup.so.0 && \
521	ln -sf libfilesharing.so.0 libfilesharing.so && \
522	ln -sf libfilesharing.so.0.0 libfilesharing.so.0 && \
523	ln -sf libflash.so.0 libflash.so && \
524	ln -sf libflash.so.0.0 libflash.so.0 && \
525	ln -sf libhd.so.0 libhd.so && \
526	ln -sf libhd.so.0.0 libhd.so.0 && \
527	ln -sf libiconv.so.0 libiconv.so && \
528	ln -sf libiconv.so.0.0 libiconv.so.0 && \
529	ln -sf libnetcgi.so.0 libnetcgi.so && \
530	ln -sf libnetcgi.so.0.0 libnetcgi.so.0 && \
531	ln -sf libnetwork.so.1 libnetwork.so && \
532	ln -sf libnetwork.so.1.0 libnetwork.so.1 && \
533	ln -sf libntpass.so.0 libntpass.so && \
534	ln -sf libntpass.so.0.0 libntpass.so.0 && \
535	ln -sf libprofile.so.0 libprofile.so && \
536	ln -sf libprofile.so.0.0 libprofile.so.0 && \
537	ln -sf libsamba.so.1 libsamba.so && \
538	ln -sf libsamba.so.1.0 libsamba.so.1 && \
539	ln -sf libschl.so.0 libschl.so && \
540	ln -sf libschl.so.0.0 libschl.so.0 && \
541	ln -sf libsystem.so.0 libsystem.so && \
542	ln -sf libsystem.so.0.0 libsystem.so.0 && \
543	cd ../..
544	
545	( if [ "$*" = "WL500gpv2" ]; then \
546		make shared GLOBAL_OPTIONS="-DDLM -DCDMA" CONFIG_DLM=y; \
547		make rc GLOBAL_OPTIONS="-DWL500GPV2 -DWPA2_WMM -DWOB -DRPPPPOE -DBTN_SETUP -DURE -DUSB_SUPPORT -DWSC -DWCN -DQOS -DWEB_REDIRECT -DDLM -DU2EC -DCDMA" CONFIG_BTNSETUP=y CONFIG_DLM=y CONFIG_CDMA=y; \
548		make infosvr GLOBAL_OPTIONS="-DPRNINFO -DNO_PARALLEL"; \
549		make LPRng GLOBAL_OPTIONS="-DUSBONLY"; \
550		make httpd GLOBAL_OPTIONS="-DWL500GPV2 -DDLM -DWSC -DU2EC -DCDMA" CONFIG_NOUSB=n MODEL_NAME=WL-500gP\ V2 CONFIG_DLM=y; \
551		make wanduck GLOBAL_OPTIONS="-DWL500GPV2 -DCDMA"; \
552	elif [ "$*" = "WL520gu" ]; then \
553		make shared GLOBAL_OPTIONS="-DCDMA" CONFIG_DLM=n; \
554		make rc GLOBAL_OPTIONS="-DWL520GU -DWPA2_WMM -DWOB -DRPPPPOE -DBTN_SETUP -DURE -DUSB_SUPPORT -DWSC -DWCN -DQOS -DWEB_REDIRECT -DCDMA" CONFIG_BTNSETUP=y CONFIG_CDMA=y; \
555		make infosvr GLOBAL_OPTIONS="-DPRNINFO -DNO_PARALLEL"; \
556		make LPRng GLOBAL_OPTIONS="-DUSBONLY"; \
557		make httpd GLOBAL_OPTIONS="-DWL520GU -DWSC -DCDMA" CONFIG_NOUSB=n MODEL_NAME=WL-520GU CONFIG_DLM=n; \
558		make wanduck GLOBAL_OPTIONS="-DWL520GU -DCDMA"; \
559	else \
560		echo "no such model name"; \
561	fi )
562
563	#make www-install-$*
564 
565	rm $(PLATFORMDIR)/target/usr/sbin/waveserver -f
566
567	# install Vista support utility before lib-opt 
568	( if [ "$*" = "WL520gu" ] || [ "$*" = "WL500gpv2" ]; then \
569		mkdir $(PLATFORMDIR)/target/; \
570		mkdir $(PLATFORMDIR)/target/bin; \
571		mkdir $(PLATFORMDIR)/target/usr/; \
572		mkdir $(PLATFORMDIR)/target/usr/sbin; \
573		cp -rf $(PLATFORMDIR)/install/wsc/Wsccmd/src/linux/bin/* $(PLATFORMDIR)/target/bin -f; \
574		cp -rf $(PLATFORMDIR)/install/lltd/wrt54g-linux/usr/sbin/* $(PLATFORMDIR)/target/usr/sbin -f; \
575	fi )
576	
577	( if [ "$*" = "WL500gpv2" ]; then \
578		$(MAKE) -C rc install CONFIG_DLM=y CONFIG_CDMA=y INSTALLDIR=$(INSTALLDIR)/rc; \
579	elif [ "$*" = "WL520gu" ]; then \
580		$(MAKE) -C rc install CONFIG_CDMA=y INSTALLDIR=$(INSTALLDIR)/rc; \
581	else \
582		echo "no such model name"; \
583	fi )
584
585	mkdir -p $(PLATFORMDIR)/target/usr/sbin
586	cp -f $(TOP)/pppd.mppe/chat/chat $(PLATFORMDIR)/target/usr/sbin/
587
588	make install 
589	
590ifeq ($(CONFIG_BPLAY),y)
591	cp -f others/waveserver $(PLATFORMDIR)/target/usr/sbin/
592endif
593
594# Compile TW version for WL500GPv2 including CN, TW, and KR USB modules
595	( if [ "$(LANGUAGE)" = "TW" ]; then \
596		( if [ "$*" = "WL500gpv2" ]; then \
597			rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp932.o; \
598		else \
599			rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp949.o; \
600			rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp932.o; \
601		fi ) \
602	elif [ "$(LANGUAGE)" = "CN" ] || [ "$(LANGUAGE)" = "ML" ]; then \
603		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp932.o; \
604		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp949.o; \
605	elif [ "$(LANGUAGE)" = "KR" ]; then \
606		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp932.o; \
607		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp936.o; \
608		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp950.o; \
609	elif [ "$(LANGUAGE)" = "JP" ]; then \
610		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp950.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_cp949.o; \
613	else \
614		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp932.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		rm -f $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs/nls/nls_cp950.o; \
618	fi )
619
620#	install: ./libgcc_s.so.1
621
622	( if [ "$*" = "WL500gpv2" ]; then \
623		rm -rf $(PLATFORMDIR)/target/apps; \
624		mkdir $(PLATFORMDIR)/target/apps; \
625		mkdir $(PLATFORMDIR)/target/apps/bin; \
626		cd 500gp && tar xzf exinstall.tgz && cd ..; \
627		cp -f 500gp/exinstall/bin/dms $(PLATFORMDIR)/target/apps/bin; \
628		cp -rf 500gp 500gp.tmp; \
629		rm -rf 500gp.tmp/exinstall/bin/dms; \
630		cd 500gp.tmp/exinstall && find > $(PLATFORMDIR)/target/apps/list && cd ../..; \
631		$(TOP)/shared/crc_gen $(PLATFORMDIR)/target/apps/list $(PLATFORMDIR)/target/apps/crc $(TOP)/500gp.tmp/exinstall/; \
632		rm -rf 500gp.tmp; \
633		make lib-install; \
634		cd $(TARGETDIR) && rm -rf shares && ln -s tmp shares; \
635		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/parport/* -f; \
636	fi )
637	#( if [ "$*" = "WL520gu" ]; then \
638		rm -rf $(PLATFORMDIR)/target/apps; \
639		cd $(TARGETDIR) && rm -rf shares && ln -s tmp shares; \
640		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/parport/* -f; \
641		rm $(PLATFORMDIR)/target/usr/sbin/waveserver -f; \
642		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/drivers/media -rf; \
643		rm $(PLATFORMDIR)/target/usr/sbin/et -rf; \
644		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/drivers/usb/serial -rf; \
645		rm $(PLATFORMDIR)/target/usr/sbin/pppoecd -f; \
646		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/drivers/usb/hcd/* -f; \
647		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs -rf; \
648		rm $(PLATFORMDIR)/target/usr/sbin/test -f; \
649		rm $(PLATFORMDIR)/target/usr/sbin/pppoe -f; \
650		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/pcmcia -rf; \
651	fi )
652	( if [ "$*" = "WL520gu" ]; then \
653		cd $(TARGETDIR) && rm -rf shares && ln -s tmp shares; \
654		rm $(PLATFORMDIR)/target/usr/sbin/et -rf; \
655		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/kernel/fs -rf; \
656		rm $(PLATFORMDIR)/target/lib/modules/2.4.20/pcmcia -rf; \
657	fi )
658	
659	( if [ $(CONFIG_OTHERS) = "n" ]; then \
660		cd $(PLATFORMDIR)/target/etc/ && ln -sf /tmp/resolv.conf resolv.conf; cd -; \
661		cd $(PLATFORMDIR)/target/etc/ && ln -sf /tmp/hosts hosts; cd -; \
662		cp -f $(TOP)/others/services $(PLATFORMDIR)/target/etc/services; \
663		echo "order hosts,bind" > $(PLATFORMDIR)/target/etc/host.conf; \
664		echo "hosts: files dns" > $(PLATFORMDIR)/target/etc/nsswitch.conf; \
665	fi )
666
667	cd $(PLATFORMDIR) && make $* && cd ..
668
669images-%:
670#	make image-$* LANGUAGE="EN"
671#	make image-$* LANGUAGE="KR"
672	make image-$* LANGUAGE="TW"
673#	make image-$* LANGUAGE="CN"
674
675images:
676	make images-WL500gx
677	make images-WL500g
678
679
680#
681# Generic rules
682#
683
684%:
685	[ ! -d $* ] || $(MAKE) -C $*
686
687%-clean:
688	[ ! -d $* ] || $(MAKE) -C $* clean
689
690%-install:
691	[ ! -d $* ] || $(MAKE) -C $* install INSTALLDIR=$(INSTALLDIR)/$*
692
693$(obj-y) $(obj-n) $(obj-clean) $(obj-install): dummy
694
695.PHONY: all clean distclean mrproper install package
696.PHONY: conf mconf oldconf kconf kmconf config menuconfig oldconfig
697.PHONY: dummy
698