1 # Makefile for to build the base openwrt
3 # Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ######################################################################
21 # WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
23 # Currently the dependencies are not all handled. But that's true of
24 # our buildroot in general, since it wasn't really set up for end users.
26 OPENWRT_TARGETS
:= $(STAGING_DIR
)/bin
/sstrip gcc3_3 openwrt-linux openwrt-kmodules.
tar.bz2 \
27 openwrt-shared openwrt-mtd openwrt-nvram openwrt-wlconf \
28 bridge dnsmasq1 iptables wtools busybox \
31 .PHONY
: $(OPENWRT_TARGETS
) openwrt-code.bin
33 openwrt-base
: $(OPENWRT_TARGETS
)
35 ######################################################################
37 WRT54G_SOURCE
=wrt54gs
.2.07.1.tgz
38 WRT54G_SITE
=http
://www.linksys.com
/support
/opensourcecode
/wrt54gs
/2.07.1
39 WRT54G_DIR
=$(BUILD_DIR
)/WRT54GS
41 LINUX_DIR
=$(WRT54G_DIR
)/release
/src
/linux
/linux
43 LINUX_BINLOC
=arch
/mips
/brcm-boards
/bcm947xx
/compressed
/vmlinuz
45 TARGET_MODULES_DIR
:=$(TARGET_DIR
)/lib
/modules
/2.4.20
47 $(LINUX_DIR
)/.unpacked
: $(WRT54G_DIR
)/.prepared
48 -(cd
$(BUILD_DIR
); ln
-sf
$(LINUX_DIR
) linux
)
49 touch
$(LINUX_DIR
)/.unpacked
51 $(LINUX_DIR
)/.patched
: $(WRT54G_DIR
)/.prepared
52 $(SOURCE_DIR
)/patch-kernel.sh
$(LINUX_DIR
) $(SOURCE_DIR
)/openwrt
/kernel
/patches
53 # use replacement diag module code
54 cp
-f
$(SOURCE_DIR
)/openwrt
/kernel
/diag.c
$(LINUX_DIR
)/drivers
/net
/diag
/diag_led.c
55 cp
-f
$(SOURCE_DIR
)/openwrt
/kernel
/linux.config
$(LINUX_DIR
)/.config
56 -(cd
$(BUILD_DIR
); ln
-sf
$(LINUX_DIR
) linux
)
57 -(cd
$(LINUX_DIR
)/arch
/mips
/brcm-boards
/bcm947xx
/; \
59 tar jxvf
$(SOURCE_DIR
)/openwrt
/kernel
/compressed-20040531.
tar.bz2
; \
61 touch
$(LINUX_DIR
)/.patched
63 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.nf-patched
$(LINUX_DIR
)/.patched
$(LINUX_DIR
)/.bbc-patched
64 $(SED
) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR
)/Makefile
65 $(SED
) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR
)/arch
/mips
/Makefile
66 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
67 make
-C
$(LINUX_DIR
) oldconfig
include/linux
/version.h
68 touch
$(LINUX_DIR
)/.configured
70 $(LINUX_DIR
)/.depend_done
: $(LINUX_DIR
)/.configured
$(GCC_BUILD_DIR2
)/.installed
71 $(MAKE
) -C
$(LINUX_DIR
) dep
72 touch
$(LINUX_DIR
)/.depend_done
74 $(LINUX_DIR
)/$(LINUX_BINLOC
): $(LINUX_DIR
)/.depend_done
75 $(MAKE
) -C
$(LINUX_DIR
) $(LINUX_FORMAT
)
77 openwrt-kmodules.
tar.bz2
: $(LINUX_DIR
)/$(LINUX_BINLOC
)
78 $(MAKE
) -C
$(LINUX_DIR
) modules
79 $(MAKE
) -C
$(LINUX_DIR
) DEPMOD
=true \
80 INSTALL_MOD_PATH
=$(LINUX_DIR
)/modules modules_install
81 tar -C
$(LINUX_DIR
)/modules
/lib
-cjf openwrt-kmodules.
tar.bz2 modules
83 openwrt-linux
: $(LINUX_DIR
)/$(LINUX_BINLOC
)
85 $(DL_DIR
)/$(WRT54G_SOURCE
):
86 $(WGET
) -P
$(DL_DIR
) $(WRT54G_SITE
)/$(WRT54G_SOURCE
)
88 $(WRT54G_DIR
)/.source
: $(DL_DIR
)/$(WRT54G_SOURCE
)
89 zcat
$(DL_DIR
)/$(WRT54G_SOURCE
) |
tar -C
$(BUILD_DIR
) -xvf
- WRT54GS
/README.TXT WRT54GS
/release
90 touch
$(WRT54G_DIR
)/.source
92 $(WRT54G_DIR
)/.prepared
: $(WRT54G_DIR
)/.source
93 $(SOURCE_DIR
)/patch-kernel.sh
$(WRT54G_DIR
) $(SOURCE_DIR
)/openwrt
/patches
94 touch
$(WRT54G_DIR
)/.prepared
96 ######################################################################
98 OPENWRT_ROOT_SKEL
:=root.
tar.gz
99 OPENWRT_SITE
=http
://openwrt.ksilebo.net
/cgi-bin
/viewcvs.cgi
/root
101 $(DL_DIR
)/$(OPENWRT_ROOT_SKEL
):
102 $(WGET
) -P
$(DL_DIR
) $(OPENWRT_SITE
)/$(OPENWRT_ROOT_SKEL
)
104 ######################################################################
106 OPENWRT_SRCBASE
:=$(WRT54G_DIR
)/release
/src
107 OPENWRT_SHARED_BUILD_DIR
:=$(OPENWRT_SRCBASE
)/router
/shared
108 OPENWRT_SHARED_TARGET_BINARY
:=usr
/lib
/libshared.so
110 $(TARGET_DIR
)/$(OPENWRT_SHARED_TARGET_BINARY
): $(WRT54G_DIR
)/.source
111 $(MAKE
) -C
$(OPENWRT_SHARED_BUILD_DIR
) -f Makefile-openwrt \
112 SRCBASE
=$(OPENWRT_SRCBASE
) INSTALLDIR
=$(TARGET_DIR
) \
113 CC
=$(TARGET_CC
) LD
=$(TARGET_CROSS
)ld STRIP
="$(STRIP)" \
114 CFLAGS
="$(TARGET_CFLAGS) -I. -I$(OPENWRT_SRCBASE)/include -Wall -I$(OPENWRT_SRCBASE)/" \
117 openwrt-shared
: $(TARGET_DIR
)/$(OPENWRT_SHARED_TARGET_BINARY
)
119 openwrt-shared-clean
:
120 -$(MAKE
) -C
$(OPENWRT_SHARED_BUILD_DIR
) clean
122 ######################################################################
124 OPENWRT_NVRAM_BUILD_DIR
:=$(OPENWRT_SRCBASE
)/router
/nvram
125 OPENWRT_NVRAM_TARGET_BINARY
:=usr
/sbin
/nvram
127 $(TARGET_DIR
)/$(OPENWRT_NVRAM_TARGET_BINARY
): $(WRT54G_DIR
)/.source
128 $(MAKE
) -C
$(OPENWRT_NVRAM_BUILD_DIR
) \
129 SRCBASE
=$(OPENWRT_SRCBASE
) INSTALLDIR
=$(TARGET_DIR
) \
130 CC
=$(TARGET_CC
) LD
=$(TARGET_CROSS
)ld STRIP
="$(STRIP)" \
131 CFLAGS
="$(TARGET_CFLAGS) -I. -I$(OPENWRT_SRCBASE)/include -Wall -DOPENWRT_NVRAM" \
135 openwrt-nvram
: $(TARGET_DIR
)/$(OPENWRT_NVRAM_TARGET_BINARY
)
138 -$(MAKE
) -C
$(OPENWRT_NVRAM_BUILD_DIR
) clean
140 ######################################################################
142 OPENWRT_MTD_BUILD_DIR
:=$(OPENWRT_SRCBASE
)/router
/rc
143 OPENWRT_MTD_TARGET_BINARY
:=sbin
/mtd
145 $(TARGET_DIR
)/$(OPENWRT_MTD_TARGET_BINARY
): $(WRT54G_DIR
)/.source
$(TARGET_DIR
)/$(OPENWRT_NVRAM_TARGET_BINARY
) # need libnvram
146 $(MAKE
) -C
$(OPENWRT_MTD_BUILD_DIR
) -f Makefile-openwrt \
147 TOP
=$(OPENWRT_SRCBASE
)/router \
148 SRCBASE
=$(OPENWRT_SRCBASE
) INSTALLDIR
=$(TARGET_DIR
) \
149 CC
=$(TARGET_CC
) LD
=$(TARGET_CROSS
)ld STRIP
="$(STRIP)" \
150 CFLAGS
="$(TARGET_CFLAGS) -I. -I$(OPENWRT_SRCBASE)/router/shared -I$(OPENWRT_SRCBASE)/include -Wall -I$(OPENWRT_SRCBASE)/" \
153 openwrt-mtd
: $(TARGET_DIR
)/$(OPENWRT_MTD_TARGET_BINARY
)
156 -$(MAKE
) -C
$(OPENWRT_MTD_BUILD_DIR
) clean
158 ######################################################################
160 OPENWRT_WLCONF_BUILD_DIR
:=$(OPENWRT_SRCBASE
)/router
/wlconf
161 OPENWRT_WLCONF_TARGET_BINARY
:=usr
/sbin
/wlconf
163 $(TARGET_DIR
)/$(OPENWRT_WLCONF_TARGET_BINARY
): $(WRT54G_DIR
)/.source
164 $(MAKE
) -C
$(OPENWRT_WLCONF_BUILD_DIR
) \
165 TOP
=$(OPENWRT_SRCBASE
)/router \
166 SRCBASE
=$(OPENWRT_SRCBASE
) INSTALLDIR
=$(TARGET_DIR
) \
167 CC
=$(TARGET_CC
) LD
=$(TARGET_CROSS
)ld STRIP
="$(STRIP)" \
168 CFLAGS
="$(TARGET_CFLAGS) -I. -I$(OPENWRT_SRCBASE)/router/shared -I$(OPENWRT_SRCBASE)/include -Wall" \
172 openwrt-wlconf
: $(TARGET_DIR
)/$(OPENWRT_WLCONF_TARGET_BINARY
)
174 openwrt-wlconf-clean
:
175 -$(MAKE
) -C
$(OPENWRT_WLCONF_BUILD_DIR
) clean
177 ######################################################################
181 mkdir
-p
$(TARGET_DIR
)/tmp
182 chmod a
+rwxt
$(TARGET_DIR
)/tmp
183 ln
-sf
/tmp
$(TARGET_DIR
)/var
184 rm -f
$(TARGET_DIR
)/usr
/tmp
185 ln
-sf ..
/tmp
$(TARGET_DIR
)/usr
/tmp
187 mkdir
-p
$(TARGET_DIR
)/dev
189 mkdir
-p
$(TARGET_DIR
)/etc
190 ln
-sf
/tmp
/resolv.conf
$(TARGET_DIR
)/etc
/resolv.conf
192 mkdir
-p
$(TARGET_DIR
)/mnt
193 mkdir
-p
$(TARGET_DIR
)/proc
194 mkdir
-p
$(TARGET_DIR
)/jffs
195 mkdir
-p
$(TARGET_DIR
)/rom
197 mkdir
-p
$(TARGET_MODULES_DIR
)
198 cp
$(LINUX_DIR
)/drivers
/net
/wl
/wl.o
$(TARGET_MODULES_DIR
)
199 #cp $(LINUX_DIR)/drivers/net/et.4702/et.4702.o $(TARGET_MODULES_DIR)
200 cp
$(LINUX_DIR
)/drivers
/net
/et
/et.o
$(TARGET_MODULES_DIR
)
201 cp
$(LINUX_DIR
)/drivers
/net
/diag
/diag.o
$(TARGET_MODULES_DIR
)
203 ######################################################################
205 openwrt-prune
: openwrt-base
206 # remove unneeded uClibc libs
207 rm -rf
$(TARGET_DIR
)/lib
/libthread_db
*
208 rm -rf
$(TARGET_DIR
)/lib
/libpthread
*
209 # remove unneeded uClibc utils
210 rm -f
$(TARGET_DIR
)/sbin
/ldconfig
211 rm -f
$(TARGET_DIR
)/usr
/bin
/ldd
212 # remove other unneeded files
213 rm -f
$(TARGET_DIR
)/usr
/sbin
/iptables-save
214 rm -f
$(TARGET_DIR
)/usr
/sbin
/iptables-restore
215 rm -f
$(TARGET_DIR
)/usr
/sbin
/ip6tables
216 rm -f
$(TARGET_DIR
)/usr
/lib
/iptables
/libip6
*
217 -@find
$(TARGET_DIR
) -type f
-perm
+111 | xargs
$(STAGING_DIR
)/bin
/sstrip
2>/dev
/null || true
;
219 ######################################################################
221 $(STAGING_DIR
)/bin
/sstrip
:
222 $(CC
) -o
$(STAGING_DIR
)/bin
/sstrip
$(SOURCE_DIR
)/openwrt
/tools
/sstrip.c
225 $(CC
) -o
$(WRT54G_DIR
)/release
/tools
/trx
$(SOURCE_DIR
)/openwrt
/tools
/trx.c
226 $(CC
) -o
$(WRT54G_DIR
)/release
/tools
/addpattern
$(SOURCE_DIR
)/openwrt
/tools
/addpattern.c
228 openwrt-linux.trx
: openwrt-prune squashfsroot wrt-tools
229 $(WRT54G_DIR
)/release
/tools
/trx
-o openwrt-linux.trx \
230 $(LINUX_DIR
)/$(LINUX_BINLOC
) $(IMAGE
)
232 openwrt-gs-code.bin
: openwrt-linux.trx
233 $(WRT54G_DIR
)/release
/tools
/addpattern
-i openwrt-linux.trx \
234 -o openwrt-gs-code.bin
-g
236 openwrt-g-code.bin
: openwrt-gs-code.bin
237 sed
-e
"1s,^W54S,W54G," < openwrt-gs-code.bin
> openwrt-g-code.bin
239 openwrt-code.bin
: openwrt-gs-code.bin openwrt-g-code.bin
241 ######################################################################