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
:= 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 ifneq ($(filter $(TARGETS
),openwrt-base
),)
39 # WRT54G_SOURCE=wrt54gv2.2.02.2.tgz
40 # WRT54G_SITE=http://www.linksys.com/support/opensourcecode/wrt54gv2/2.02.2
42 # WRT54G_SOURCE=wrt54g.2.02.7.tgz
43 # WRT54G_SITE=http://www.linksys.com/support/opensourcecode/wrt54gv2/2.02.7
44 # WRT54G_DIR=$(BUILD_DIR)/WRT54G
46 WRT54G_SOURCE
=wrt54gs
.2.07.1.tgz
47 WRT54G_SITE
=http
://www.linksys.com
/support
/opensourcecode
/wrt54gs
/2.07.1
49 WRT54G_DIR
=$(BUILD_DIR
)/WRT54GS
51 # OPENWRT_ROOT=openwrt-root.tar.bz2
52 # OPENWRT_SITE=http://127.0.0.1
53 # OPENWRT_DIR=$(BUILD_DIR)/openwrt
55 LINUX_DIR
=$(WRT54G_DIR
)/release
/src
/linux
/linux
57 LINUX_BINLOC
=arch
/mips
/brcm-boards
/bcm947xx
/compressed
/vmlinuz
59 TARGET_MODULES_DIR
:=$(TARGET_DIR
)/lib
/modules
/2.4.20
61 $(LINUX_DIR
)/.unpacked
: $(WRT54G_DIR
)/.prepared
62 -(cd
$(BUILD_DIR
); ln
-sf
$(LINUX_DIR
) linux
)
63 touch
$(LINUX_DIR
)/.unpacked
65 $(LINUX_DIR
)/.patched
: $(WRT54G_DIR
)/.prepared
66 $(SOURCE_DIR
)/patch-kernel.sh
$(LINUX_DIR
)/..
/..
$(SOURCE_DIR
) openwrt-linux-netfilter.patch
67 $(SOURCE_DIR
)/patch-kernel.sh
$(LINUX_DIR
)/..
/..
$(SOURCE_DIR
) openwrt-wrt54g-linux.patch
68 $(SOURCE_DIR
)/patch-kernel.sh
$(LINUX_DIR
)/..
/..
$(SOURCE_DIR
) openwrt-wrt54g-nfsswap.patch
69 # use replacement diag module code
70 cp
-f
$(SOURCE_DIR
)/openwrt-diag.c
$(LINUX_DIR
)/drivers
/net
/diag
/diag_led.c
71 cp
-f
$(SOURCE_DIR
)/openwrt-wrt54g-linux.config
$(LINUX_DIR
)/.config
72 -(cd
$(BUILD_DIR
); ln
-sf
$(LINUX_DIR
) linux
)
73 -(cd
$(LINUX_DIR
)/arch
/mips
/brcm-boards
/bcm947xx
/; \
75 tar jxvf
$(SOURCE_DIR
)/compressed-20040531.
tar.bz2
; \
77 touch
$(LINUX_DIR
)/.patched
79 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.patched
$(LINUX_DIR
)/.bbc-patched
$(LINUX_DIR
)/.nf-patched
80 $(SED
) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR
)/Makefile
81 $(SED
) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR
)/arch
/mips
/Makefile
82 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
83 make
-C
$(LINUX_DIR
) oldconfig
include/linux
/version.h
84 touch
$(LINUX_DIR
)/.configured
86 $(LINUX_DIR
)/.depend_done
: $(LINUX_DIR
)/.configured
$(GCC_BUILD_DIR2
)/.installed
87 $(MAKE
) -C
$(LINUX_DIR
) dep
88 touch
$(LINUX_DIR
)/.depend_done
90 $(LINUX_DIR
)/$(LINUX_BINLOC
): $(LINUX_DIR
)/.depend_done
91 $(MAKE
) -C
$(LINUX_DIR
) $(LINUX_FORMAT
)
93 openwrt-kmodules.
tar.bz2
: $(LINUX_DIR
)/$(LINUX_BINLOC
)
94 $(MAKE
) -C
$(LINUX_DIR
) modules
95 $(MAKE
) -C
$(LINUX_DIR
) DEPMOD
=/bin
/true \
96 INSTALL_MOD_PATH
=$(LINUX_DIR
)/modules modules_install
97 tar -C
$(LINUX_DIR
)/modules
/lib
-cjf openwrt-kmodules.
tar.bz2 modules
99 openwrt-linux
: $(LINUX_DIR
)/$(LINUX_BINLOC
)
101 $(DL_DIR
)/$(WRT54G_SOURCE
):
102 $(WGET
) -P
$(DL_DIR
) $(WRT54G_SITE
)/$(WRT54G_SOURCE
)
104 $(WRT54G_DIR
)/.source
: $(DL_DIR
)/$(WRT54G_SOURCE
)
105 zcat
$(DL_DIR
)/$(WRT54G_SOURCE
) |
tar -C
$(BUILD_DIR
) -xvf
- WRT54GS
/README.TXT WRT54GS
/release
106 touch
$(WRT54G_DIR
)/.source
108 $(WRT54G_DIR
)/.prepared
: $(WRT54G_DIR
)/.source
109 $(SOURCE_DIR
)/patch-kernel.sh
$(WRT54G_DIR
) $(SOURCE_DIR
) openwrt-wrt54g-router.patch
110 $(SOURCE_DIR
)/patch-kernel.sh
$(WRT54G_DIR
) $(SOURCE_DIR
) openwrt-wrt54g-shared.patch
111 touch
$(WRT54G_DIR
)/.prepared
113 ######################################################################
115 OPENWRT_ROOT_SKEL
:=root.
tar.gz
116 OPENWRT_SITE
=http
://openwrt.ksilebo.net
/cgi-bin
/viewcvs.cgi
/root
118 $(DL_DIR
)/$(OPENWRT_ROOT_SKEL
):
119 $(WGET
) -P
$(DL_DIR
) $(OPENWRT_SITE
)/$(OPENWRT_ROOT_SKEL
)
121 ######################################################################
123 OPENWRT_SRCBASE
:=$(WRT54G_DIR
)/release
/src
124 OPENWRT_SHARED_BUILD_DIR
:=$(OPENWRT_SRCBASE
)/router
/shared
125 OPENWRT_SHARED_TARGET_BINARY
:=usr
/lib
/libshared.so
127 $(TARGET_DIR
)/$(OPENWRT_SHARED_TARGET_BINARY
): $(WRT54G_DIR
)/.source
128 $(MAKE
) -C
$(OPENWRT_SHARED_BUILD_DIR
) -f Makefile-openwrt \
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 -I$(OPENWRT_SRCBASE)/" \
134 openwrt-shared
: $(TARGET_DIR
)/$(OPENWRT_SHARED_TARGET_BINARY
)
136 openwrt-shared-clean
:
137 -$(MAKE
) -C
$(OPENWRT_SHARED_BUILD_DIR
) clean
139 ######################################################################
141 OPENWRT_NVRAM_BUILD_DIR
:=$(OPENWRT_SRCBASE
)/router
/nvram
142 OPENWRT_NVRAM_TARGET_BINARY
:=usr
/sbin
/nvram
144 $(TARGET_DIR
)/$(OPENWRT_NVRAM_TARGET_BINARY
): $(WRT54G_DIR
)/.source
145 $(MAKE
) -C
$(OPENWRT_NVRAM_BUILD_DIR
) \
146 SRCBASE
=$(OPENWRT_SRCBASE
) INSTALLDIR
=$(TARGET_DIR
) \
147 CC
=$(TARGET_CC
) LD
=$(TARGET_CROSS
)ld STRIP
="$(STRIP)" \
148 CFLAGS
="$(TARGET_CFLAGS) -I. -I$(OPENWRT_SRCBASE)/include -Wall -DOPENWRT_NVRAM" \
152 openwrt-nvram
: $(TARGET_DIR
)/$(OPENWRT_NVRAM_TARGET_BINARY
)
155 -$(MAKE
) -C
$(OPENWRT_NVRAM_BUILD_DIR
) clean
157 ######################################################################
159 OPENWRT_MTD_BUILD_DIR
:=$(OPENWRT_SRCBASE
)/router
/rc
160 OPENWRT_MTD_TARGET_BINARY
:=sbin
/mtd
162 $(TARGET_DIR
)/$(OPENWRT_MTD_TARGET_BINARY
): $(WRT54G_DIR
)/.source
$(TARGET_DIR
)/$(OPENWRT_NVRAM_TARGET_BINARY
) # need libnvram
163 $(MAKE
) -C
$(OPENWRT_MTD_BUILD_DIR
) -f Makefile-openwrt \
164 TOP
=$(OPENWRT_SRCBASE
)/router \
165 SRCBASE
=$(OPENWRT_SRCBASE
) INSTALLDIR
=$(TARGET_DIR
) \
166 CC
=$(TARGET_CC
) LD
=$(TARGET_CROSS
)ld STRIP
="$(STRIP)" \
167 CFLAGS
="$(TARGET_CFLAGS) -I. -I$(OPENWRT_SRCBASE)/router/shared -I$(OPENWRT_SRCBASE)/include -Wall -I$(OPENWRT_SRCBASE)/" \
170 openwrt-mtd
: $(TARGET_DIR
)/$(OPENWRT_MTD_TARGET_BINARY
)
173 -$(MAKE
) -C
$(OPENWRT_MTD_BUILD_DIR
) clean
175 ######################################################################
177 OPENWRT_WLCONF_BUILD_DIR
:=$(OPENWRT_SRCBASE
)/router
/wlconf
178 OPENWRT_WLCONF_TARGET_BINARY
:=usr
/sbin
/wlconf
180 $(TARGET_DIR
)/$(OPENWRT_WLCONF_TARGET_BINARY
): $(WRT54G_DIR
)/.source
181 $(MAKE
) -C
$(OPENWRT_WLCONF_BUILD_DIR
) \
182 TOP
=$(OPENWRT_SRCBASE
)/router \
183 SRCBASE
=$(OPENWRT_SRCBASE
) INSTALLDIR
=$(TARGET_DIR
) \
184 CC
=$(TARGET_CC
) LD
=$(TARGET_CROSS
)ld STRIP
="$(STRIP)" \
185 CFLAGS
="$(TARGET_CFLAGS) -I. -I$(OPENWRT_SRCBASE)/router/shared -I$(OPENWRT_SRCBASE)/include -Wall" \
189 openwrt-wlconf
: $(TARGET_DIR
)/$(OPENWRT_WLCONF_TARGET_BINARY
)
191 openwrt-wlconf-clean
:
192 -$(MAKE
) -C
$(OPENWRT_WLCONF_BUILD_DIR
) clean
194 ######################################################################
198 mkdir
-p
$(TARGET_DIR
)/tmp
199 chmod a
+rwxt
$(TARGET_DIR
)/tmp
200 ln
-sf
/tmp
$(TARGET_DIR
)/var
201 rm -f
$(TARGET_DIR
)/usr
/tmp
202 ln
-sf ..
/tmp
$(TARGET_DIR
)/usr
/tmp
204 mkdir
-p
$(TARGET_DIR
)/dev
206 mkdir
-p
$(TARGET_DIR
)/etc
207 ln
-sf
/tmp
/resolv.conf
$(TARGET_DIR
)/etc
/resolv.conf
209 mkdir
-p
$(TARGET_DIR
)/mnt
210 mkdir
-p
$(TARGET_DIR
)/proc
211 mkdir
-p
$(TARGET_DIR
)/jffs
212 mkdir
-p
$(TARGET_DIR
)/rom
214 mkdir
-p
$(TARGET_MODULES_DIR
)
215 cp
$(LINUX_DIR
)/drivers
/net
/wl
/wl.o
$(TARGET_MODULES_DIR
)
216 #cp $(LINUX_DIR)/drivers/net/et.4702/et.4702.o $(TARGET_MODULES_DIR)
217 cp
$(LINUX_DIR
)/drivers
/net
/et
/et.o
$(TARGET_MODULES_DIR
)
218 cp
$(LINUX_DIR
)/drivers
/net
/diag
/diag.o
$(TARGET_MODULES_DIR
)
220 ######################################################################
223 -@find
$(TARGET_DIR
) -type f
-perm
+111 | xargs
$(STRIP
) 2>/dev
/null || true
;
224 # remove unneeded uClibc libs
225 rm -rf
$(TARGET_DIR
)/lib
/libthread_db
*
226 rm -rf
$(TARGET_DIR
)/lib
/libpthread
*
227 # remove unneeded uClibc utils
228 rm -f
$(TARGET_DIR
)/sbin
/ldconfig
229 rm -f
$(TARGET_DIR
)/usr
/bin
/ldd
230 # remove other unneeded files
231 rm -f
$(TARGET_DIR
)/usr
/sbin
/iptables-save
232 rm -f
$(TARGET_DIR
)/usr
/sbin
/iptables-restore
233 rm -f
$(TARGET_DIR
)/usr
/sbin
/ip6tables
235 ######################################################################
237 openwrt-linux.trx
: openwrt-prune squashfsroot
238 $(WRT54G_DIR
)/release
/tools
/trx
-o openwrt-linux.trx \
239 $(LINUX_DIR
)/$(LINUX_BINLOC
) $(IMAGE
)
241 openwrt-gs-code.bin
: openwrt-linux.trx
242 $(WRT54G_DIR
)/release
/tools
/addpattern
-i openwrt-linux.trx \
243 -o openwrt-gs-code.bin
-g
245 openwrt-g-code.bin
: openwrt-gs-code.bin
246 sed
-e
"1s,^W54S,W54G," < openwrt-gs-code.bin
> openwrt-g-code.bin
248 openwrt-code.bin
: openwrt-gs-code.bin openwrt-g-code.bin
250 ######################################################################
253 tar cjf buildroot-openwrt.
tar.bz2 \
260 sources
/uClibc.config \
261 sources
/uClibc.config-openwrt \
262 sources
/busybox-openwrt-
*.patch \
263 sources
/busybox.config \
264 sources
/busybox.config-openwrt \
265 sources
/dnsmasq1-openwrt.patch \
266 sources
/iptables-openwrt-extensions.patch \
267 sources
/openwrt-wrt54g-linux.config \
268 sources
/openwrt-wrt54g-
*.patch \
269 sources
/openwrt-diag.c