source: src/router/Makefile.adm5120 @ 29121

Last change on this file since 29121 was 29121, checked in by BrainSlayer, 15 months ago

must clean iproute2 on each build

  • Property svn:executable set to *
File size: 13.8 KB
Line 
1#
2# Broadcom Linux Router Makefile
3#
4# Copyright 2001-2003, 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.2 2005/09/26 11:06:58 seg Exp $
13#
14
15include .config
16ifneq ($(wildcard ../cy_conf.mak),)
17  include ../cy_conf.mak
18endif
19
20#
21# Paths
22#
23OPENSER_MODULES := sl tm rr maxfwd usrloc registrar dbtext textops exec auth auth_db nathelper
24OPENSER_MODULE_FILES := $(foreach module,$(OPENSER_MODULES),openser/modules/$(module)/$(module).so)
25OPENSSL_NO_CIPHERS:= no-idea no-md2 no-mdc2 no-rc5 no-sha0 no-rmd160 no-aes192
26OPENSSL_OPTIONS:= shared no-ec no-err no-fips no-hw no-krb5 no-threads zlib-dynamic
27
28# Source bases
29
30export PLATFORM LINUXDIR LIBDIR USRLIBDIR
31export TOP := $(shell pwd)
32export SRCBASE := $(shell (cd $(TOP)/.. && pwd -P))
33
34
35# Set the HAL directory if you have the HAL sources
36
37# Set the Atheros Rate Control directory if you have the proprietary rate control
38export ATH_RATE=ath_rate/sample
39
40#
41# Cross-compile environment variables
42#
43
44# Build platform
45export BUILD := i386-pc-linux-gnu
46export HOSTCC := gcc
47
48# uClibc wrapper
49export ARCH:=$(PLATFORM)
50ifeq ($(CONFIG_UCLIBC),y)
51export PLATFORM := $(PLATFORM)-uclibc
52endif
53
54#export LINUXDIR := $(SRCBASE)/linux/linux.v24
55ifeq ($(ARCH),mips)
56export LINUXDIR := $(SRCBASE)/linux/brcm63xx/linux-2.6.17
57endif
58#ifeq ($(ARCH),armeb)
59#export LINUXDIR := $(SRCBASE)/linux/xscale/linux-2.6.23
60#endif
61#ifeq ($(ARCH),mipsel)
62#export LINUXDIR := $(SRCBASE)/kernel/rb500/linux-2.6.17-rc5
63#endif
64ifeq ($(ARCH),i386)
65export LINUXDIR := $(SRCBASE)/kernel/wrap/linux-2.6.16.7
66endif
67
68export KERNELRELEASE = $(shell cat $(LINUXDIR)/include/config/kernel.release 2> /dev/null)
69
70#export KERNELRELEASE = $(shell cat $(LINUXDIR)/.kernelrelease 2> /dev/null)
71
72#ifeq ($(PLATFORM),mipsel)
73#export CROSS_COMPILE := mipsel-linux-
74#export CONFIGURE := ./configure mipsel-linux --build=$(BUILD)
75#export TOOLCHAIN := $(shell cd $(dir $(shell which $(CROSS_COMPILE)gcc))/../mipsel-linux && pwd -P)
76#endif
77
78#ifeq ($(PLATFORM),mipsel-uclibc)
79export CROSS_COMPILE := $(ARCH)-linux-uclibc-
80export CONFIGURE := ./configure $(ARCH)-linux --build=$(BUILD)
81export TOOLCHAIN := $(shell cd $(dir $(shell which $(CROSS_COMPILE)gcc))/.. && pwd -P)
82#endif
83
84#ifeq ($(CONFIG_BCMWPA2),y)
85#export CFLAGS += -DBCMWPA2
86#endif
87
88export BASEOPT:=-Os
89#export ARCH:= mipsel
90
91ifeq ($(ARCH),mipsel)
92export COPTS:=$(BASEOPT) -pipe -mips32 -mtune=mips32 -funit-at-a-time
93endif
94ifeq ($(ARCH),arm)
95export COPTS:=$(BASEOPT) -march=armv4 -pipe -funit-at-a-time -msoft-float
96endif
97ifeq ($(ARCH),mips)
98export COPTS:=$(BASEOPT) -pipe -mips32 -mtune=mips32 -funit-at-a-time
99endif
100ifeq ($(ARCH),i386)
101export COPTS:=$(BASEOPT) -pipe -march=i486 -funit-at-a-time
102endif
103
104export CC := ccache $(CROSS_COMPILE)gcc
105export CXX := ccache $(CROSS_COMPILE)g++
106export AR := $(CROSS_COMPILE)ar
107export AS := $(CROSS_COMPILE)as
108export LD := $(CROSS_COMPILE)ld
109export NM := $(CROSS_COMPILE)nm
110export RANLIB := $(CROSS_COMPILE)ranlib
111export STRIP := $(CROSS_COMPILE)strip
112export SIZE := $(CROSS_COMPILE)size
113
114export CFLAGS := $(COPTS)
115
116#
117# Install and target directories
118#
119
120export PLATFORMDIR := $(TOP)/$(PLATFORM)
121export INSTALLDIR := $(PLATFORMDIR)/install
122export TARGETDIR := $(PLATFORMDIR)/target
123
124ifeq ($(PLATFORM),mipsel)
125obj-y += libcrypto
126endif
127#
128# Configuration
129#
130CONFIG_IPTABLES=y
131
132include rules/configs.mk
133
134obj-clean := $(foreach obj,$(obj-y) $(obj-n),$(obj)-clean)
135obj-install := $(foreach obj,$(obj-y),$(obj)-install)
136obj-distclean := $(foreach obj,$(obj-y) $(obj-n),$(obj)-distclean)
137
138all: build_date clean_target $(obj-y) $(LINUXDIR)/.config kernel
139
140build_date:
141        echo "#define BUILD_DATE \"$(shell date +%D)\"" > ../../opt/build.h
142
143include kernel-features.mk
144
145kernel:
146        # Also build kernel
147ifeq ($(CONFIG_WP54G),y)
148        cp $(LINUXDIR)/.config_full $(LINUXDIR)/.config
149else
150ifeq ($(CONFIG_NP28G),y)
151        cp $(LINUXDIR)/.config_np28g $(LINUXDIR)/.config
152else
153        cp $(LINUXDIR)/.config_lite $(LINUXDIR)/.config
154endif
155endif
156        $(kernelfeatures)
157        $(MAKE) -C $(LINUXDIR) oldconfig       
158
159        if ! grep -q "CONFIG_EMBEDDED_RAMDISK=y" $(LINUXDIR)/.config ; then \
160            $(MAKE) -j 4 -C $(LINUXDIR) vmlinux CROSS_COMPILE="ccache $(ARCH)-linux-uclibc-" ; \
161        fi
162        if grep -q "CONFIG_MODULES=y" $(LINUXDIR)/.config ; then \
163            $(MAKE) -j 4 -C $(LINUXDIR) modules CROSS_COMPILE="ccache $(ARCH)-linux-uclibc-" ; \
164        fi
165
166       
167realclean: $(obj-clean)
168        rm -f .config.old .config.cmd
169        #umount $(TARGETDIR)
170        rm -rf $(INSTALLDIR)
171        rm -rf $(TARGETDIR)
172        rm -f $(TARGETDIR)/*
173        -rm -f $(ARCH)-uclibc/*
174
175       
176clean: rc-clean httpd-clean services-clean shared-clean libutils-clean madwifi-clean madwifi_mimo-clean busybox-clean dnsmasq-clean iptables-clean pppd-clean  iproute2-clean
177        rm -f .config.old .config.cmd
178        #umount $(TARGETDIR)
179        rm -rf $(INSTALLDIR)
180        rm -rf $(TARGETDIR)
181        rm -f $(TARGETDIR)/*
182        -rm -f $(ARCH)-uclibc/*
183
184clean_target:
185        rm -rf $(TARGETDIR)
186        rm -rf $(INSTALLDIR)
187
188distclean mrproper: $(obj-distclean) clean_target
189        rm -rf $(INSTALLDIR)
190        $(MAKE) -C $(LINUXDIR) distclean
191        $(MAKE) -C $(LINUXDIR)/arch/mips/bcm947xx/compressed clean
192        #rm -f $(PLATFORMDIR)/zImage $(PLATFORMDIR)/linux.bin
193        $(MAKE) -C config clean
194        rm -f .config $(LINUXDIR)/.config
195        rm -f .config.old .config.cmd
196
197optimize-lib:
198#       ../../tools/optimize_lib.sh shared/ libshared.so libshared.a libshared_min.so $(TARGETDIR) $(TARGETDIR)/usr/lib/libshared.so
199        ../../tools/optimize_lib.sh libutils/ libutils.so libutils.a libutils_min.so $(TARGETDIR) $(TARGETDIR)/lib/libutils.so
200#       ../../tools/optimize_lib.sh lib.$(ARCH)/ libpthread.so libpthread.a libphread_min.so $(TARGETDIR) $(TARGETDIR)/lib/libpthread.so.0
201        @true
202
203
204install package: clean_target $(filter-out lib.$(ARCH)-install,$(obj-install)) $(LINUXDIR)/.config
205        # Install binaries into target directory
206        install -d $(TARGETDIR)
207        for dir in $(wildcard $(patsubst %,$(INSTALLDIR)/%,$(obj-y))) ; do \
208            (cd $${dir} && tar cpf - .) | (cd $(TARGETDIR) && tar xpf -) \
209        done
210        mkdir -p $(ARCH)-uclibc/target/etc/config
211        mkdir -p $(ARCH)-uclibc/target/etc/kaid
212        mkdir -p $(ARCH)-uclibc/target/etc/langpack
213        cp ./opt/bin/ipkg $(ARCH)-uclibc/target/bin
214        cd  $(ARCH)-uclibc/target/lib
215        cp ./opt/etc/preinit $(ARCH)-uclibc/target/etc
216        cp ./opt/etc/postinit $(ARCH)-uclibc/target/etc
217        cp ./opt/etc/ipkg.conf $(ARCH)-uclibc/target/etc
218        cp ./opt/etc/config/* $(ARCH)-uclibc/target/etc/config
219        cp ./opt/usr/lib/smb.conf $(ARCH)-uclibc/target/usr/lib
220        ln -sf ../tmp/smbshare $(ARCH)-uclibc/target/www/smb
221        # optimize the crypto library by removing unneeded symbols
222        # Install (and possibly optimize) C library
223        $(MAKE) -f Makefile.adm5120 lib.$(ARCH)-install
224        # optimize the others library by removing unneeded symbols
225        $(MAKE) -f Makefile.adm5120 optimize-lib
226        # Install modules into filesystem
227        if grep -q "CONFIG_MODULES=y" $(LINUXDIR)/.config ; then \
228            $(MAKE) -C $(LINUXDIR) modules_install DEPMOD=/bin/true INSTALL_MOD_PATH=$(TARGETDIR) ; \
229        fi
230ifeq ($(CONFIG_MADWIFI),y)
231        rm -rf $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/kernel/drivers/net/wl
232endif
233ifeq ($(CONFIG_WAVESAT),y)
234        make -f Makefile.adm5120 wavesat-install
235endif
236        cp lib.$(ARCH)/libgcc_s.so.1 $(TARGETDIR)/lib
237        find $(TARGETDIR) -name "wl_*.o"  | xargs rm -rf
238ifneq ($(CONFIG_SAMBA),y)
239        rm -rf $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/kernel/fs/cifs
240endif
241        rm -f $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/build
242        rm -f $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/source
243        # Prepare filesystem
244        cd $(TARGETDIR) && $(TOP)/misc/rootprep.sh
245        # Make sure mksquashfs-2.0 is used
246        cd $(TARGETDIR)  &&  find . -iname "CVS" | xargs rm -rf
247        cd $(TARGETDIR)  &&  find . -iname ".svn" | xargs rm -rf
248        -find $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/kernel -name *.ko -exec mv {} $(TARGETDIR)/lib/modules/$(KERNELRELEASE) \;
249        -find $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/net -name *.ko -exec mv {} $(TARGETDIR)/lib/modules/$(KERNELRELEASE) \;
250        rm -rf $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/kernel
251        rm -rf $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/net
252        #e2fsck -y -f $(ARCH)-uclibc/root.fs
253        ./busybox/examples/depmod.pl -F $(LINUXDIR)/System.map -b $(ARCH)-uclibc/target/lib/modules
254#       tar --directory=$(TARGETDIR) --remove-files -cvvjf $(TARGETDIR)/etc/local.tar.bz2 usr/local
255        rm -rf $(TARGETDIR)/usr/local
256        rm -f $(TARGETDIR)/bin/ipkg
257        rm -f $(TARGETDIR)/usr/lib/smb.conf
258#       mkdir $(TARGETDIR)/usr/local
259ifeq ($(CONFIG_KAID),y)
260        cp kaid/kaid $(TARGETDIR)/usr/sbin
261endif
262        mv $(TARGETDIR)/usr/lib/services.so $(TARGETDIR)/lib
263ifneq ($(CONFIG_WP54G),y)
264ifneq ($(CONFIG_NP28G),y)
265        cd $(TARGETDIR) && find . -name *.ko -exec mipsel-linux-strip --strip-unneeded --remove-section=.comment {} +
266        -mv $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/kernel/drivers/net/*.ko $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/
267        -mv $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/net/*.ko $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/
268        -mv $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/kernel/net/bridge/netfilter/*.ko $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/
269        -mv $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/kernel/net/ipv4/netfilter/*.ko $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/
270        -mv $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/kernel/net/netfilter/*.ko $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/
271        rm -rf $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/kernel
272        rm -rf $(TARGETDIR)/lib/modules/$(KERNELRELEASE)/net
273        -mv $(TARGETDIR)/usr/lib/*.so $(TARGETDIR)/lib
274        rm -rf $(TARGETDIR)/usr/lib
275endif
276endif
277#       mipsel-linux-strip $(TARGETDIR)/lib/modules/$(LINUXVER)/*.ko           
278        -./strip_libs.sh $(ARCH)
279        $(TOP)/../../tools/removewhitespace.sh $(TOP)/../../tools $(TARGETDIR)/etc/config
280#       $(LINUXDIR)/scripts/squashfs/mksquashfs-lzma $(ARCH)-uclibc/target $(ARCH)-uclibc/root.fs -noappend -root-owned -le -b 1048576 -nopad
281ifneq ($(CONFIG_WP54G),y)
282ifneq ($(CONFIG_NP28G),y)
283        $(LINUXDIR)/scripts/squashfs/mksquashfs-lzma $(ARCH)-uclibc/target $(ARCH)-uclibc/root.fs -noappend -root-owned -le -b 524288 -nopad
284else
285        $(LINUXDIR)/scripts/squashfs/mksquashfs-lzma $(ARCH)-uclibc/target $(ARCH)-uclibc/root.fs -noappend -root-owned -le
286endif
287else
288        $(LINUXDIR)/scripts/squashfs/mksquashfs-lzma $(ARCH)-uclibc/target $(ARCH)-uclibc/root.fs -noappend -root-owned -le
289endif
290#       mkfs.jffs2 --pad --big-endian --squash -e 0x20000 -o $(ARCH)-uclibc/dd-wrt.jffs2 -d $(ARCH)-uclibc/target
291        echo -ne '\xde\xad\xc0\xde' >> $(ARCH)-uclibc/dd-wrt.jffs2
292        mipsel-linux-uclibc-objcopy -O binary $(LINUXDIR)/vmlinux mipsel-uclibc/vmlinus
293        lzma e -lc1 -lp2 -pb2 -d25 mipsel-uclibc/vmlinus mipsel-uclibc/vmlinus.lzma
294        make -C lzma-loader/adm5120 all
295        gzip -9 lzma-loader/adm5120/loader.bin
296        mv lzma-loader/adm5120/loader.bin.gz mipsel-uclibc/vmlinus.gz_na
297        trx -o mipsel-uclibc/vmlinux.trx mipsel-uclibc/vmlinus.lzma
298        cat mipsel-uclibc/vmlinux.trx  >> mipsel-uclibc/vmlinus.gz_na
299#       ./tools/makeos mipsel-uclibc/vmlinus.gz_na mipsel-uclibc/vmlinus.na_csys
300        dd if=mipsel-uclibc/vmlinus.gz_na of=mipsel-uclibc/vmlinus.gz bs=4096 conv=sync
301        dd if=mipsel-uclibc/vmlinus.gz_na of=mipsel-uclibc/vmlinus.csys bs=4096 conv=sync
302        dd if=mipsel-uclibc/vmlinus.gz_na of=mipsel-uclibc/vmlinus.cpx bs=65536 conv=sync
303
304        cat mipsel-uclibc/root.fs  >> mipsel-uclibc/vmlinus.gz
305        cat mipsel-uclibc/root.fs  >> mipsel-uclibc/vmlinus.gz_na       
306        ./tools/subfile mipsel-uclibc/vmlinus.csys mipsel-uclibc/vmlinus.csyssub 12
307        cat mipsel-uclibc/root.fs  >> mipsel-uclibc/vmlinus.csyssub
308#       dd if=mipsel-uclibc/vmlinus.csyssub of=mipsel-uclibc/vmlinus.gz_na bs=65536 conv=sync
309#       ./tools/osbridge-fix mipsel-uclibc/vmlinus.csys
310        -./tools/mkcsysimg -B 5GXi -d \
311                -r mipsel-uclibc/vmlinus.csyssub::0x10000 \
312                mipsel-uclibc/vmlinus.csys
313
314#               -x mipsel-uclibc/root.fs:0x1000 \
315
316        tools/compex/mkmylofw -B WP54G \
317                -p0x20000:0x3d0000:ap:0x80001000 \
318                -b0x20000:0x3d0000::mipsel-uclibc/vmlinus.gz \
319                $(ARCH)-uclibc/compex-firmware-wp54g.bin
320
321
322        tools/compex/mkmylofw -B WP54AG \
323                -p0x20000:0x3d0000:ap:0x80001000 \
324                -b0x20000:0x3d0000::mipsel-uclibc/vmlinus.gz \
325                $(ARCH)-uclibc/compex-firmware-wp54ag.bin
326
327        tools/compex/mkmylofw -B NP28G \
328                -p0x20000:0x3d0000:ap:0x80001000 \
329                -b0x20000:0x3d0000::mipsel-uclibc/vmlinus.gz \
330                $(ARCH)-uclibc/compex-firmware-np28g.bin
331
332        tools/compex/mkmylofw -B NP27G \
333                -p0x20000:0x3d0000:ap:0x80001000 \
334                -b0x20000:0x3d0000::mipsel-uclibc/vmlinus.gz \
335                $(ARCH)-uclibc/compex-firmware-np27g.bin
336
337#       tools/compex/mkmylofw -B WP54Gv1C \
338#               -p0x20000:$(/usr/bin/filesize mipsel-uclibc/vmlinus.gz):ahp:0x80001000 \
339#               -b0x20000:$(/usr/bin/filesize mipsel-uclibc/vmlinus.gz):h:mipsel-uclibc/vmlinus.gz \
340#               $(ARCH)-uclibc/compex-firmware-wp54gv1c.bin
341
342#       $(shell tools/compex/mkmylofw -B WP54AG \
343#               -p0x20000:$(/usr/bin/filesize mipsel-uclibc/vmlinus.cpx):ahp:0x80001000 \
344#               -p$(($(/usr/bin/filesize mipsel-uclibc/vmlinus.cpx)+65536+65536)):0 \
345#               -b0x20000:$(/usr/bin/filesize mipsel-uclibc/vmlinus.cpx):h:mipsel-uclibc/vmlinus.cpx \
346#               -b$(($(/usr/bin/filesize mipsel-uclibc/vmlinus.cpx)+65536+65536)):0::mipsel-uclibc/root.fs \
347#               mipsel-uclibc/compex-firmware-wp54ag.bin)
348        cp $(ARCH)-uclibc/compex-firmware-wp54ag.bin /GruppenLW/releases
349
350        tools/compex/mkmylofw -B WPP54G \
351                -p0x20000:0x3d0000:ap:0x80001000 \
352                -b0x20000:0x3d0000::mipsel-uclibc/vmlinus.gz \
353                $(ARCH)-uclibc/compex-firmware-wpp54g.bin
354
355        tools/compex/mkmylofw -B WPP54AG \
356                -p0x20000:0x3d0000:ap:0x80001000 \
357                -b0x20000:0x3d0000::mipsel-uclibc/vmlinus.gz \
358                $(ARCH)-uclibc/compex-firmware-wpp54ag.bin
359
360
361        ./tools/trx_n -m 30000000 -a 1 -o mipsel-uclibc/adm5120-webflash.bin mipsel-uclibc/vmlinus.gz
362        ./tools/osbridge-crc -i mipsel-uclibc/vmlinus.csys -o mipsel-uclibc/vmlinus.oscrc
363        ./tools/pc1crypt -i mipsel-uclibc/vmlinus.oscrc -o mipsel-uclibc/vmlinus.osbridge
364        ./tools/trx_n -m 30000000 -a 1 -o mipsel-uclibc/adm5120-webflash-osbridge.bin mipsel-uclibc/vmlinus.csys
365       
366
367
368include rules/all.mk
369
370.PHONY: all clean distclean mrproper install package
371.PHONY: conf mconf oldconf kconf kmconf config menuconfig oldconfig
372.PHONY: dummy fixkc libnet libpcap
373
374
375
Note: See TracBrowser for help on using the repository browser.