clean up yesterday's reorganization
[openwrt.git] / obsolete-buildroot / make / openwrt.mk
1 # Makefile for to build the base openwrt
2 #
3 # Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
4 #
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.
9 #
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.
14 #
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
18 #
19 ######################################################################
20 #
21 # WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
22 #
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.
25
26 OPENWRT_TARGETS:= openwrt-linux openwrt-kmodules.tar.bz2 \
27 openwrt-shared openwrt-mtd openwrt-nvram openwrt-wlconf \
28 bridge dnsmasq1 iptables wtools busybox \
29 openwrt-rootprep
30
31 .PHONY: $(OPENWRT_TARGETS) openwrt-code.bin
32
33 openwrt-base: $(OPENWRT_TARGETS)
34
35 ######################################################################
36
37 ifneq ($(filter $(TARGETS),openwrt-base),)
38
39 WRT54G_SOURCE=wrt54gs.2.07.1.tgz
40 WRT54G_SITE=http://www.linksys.com/support/opensourcecode/wrt54gs/2.07.1
41 WRT54G_DIR=$(BUILD_DIR)/WRT54GS
42
43 LINUX_DIR=$(WRT54G_DIR)/release/src/linux/linux
44 LINUX_FORMAT=zImage
45 LINUX_BINLOC=arch/mips/brcm-boards/bcm947xx/compressed/vmlinuz
46
47 TARGET_MODULES_DIR:=$(TARGET_DIR)/lib/modules/2.4.20
48
49 $(LINUX_DIR)/.unpacked: $(WRT54G_DIR)/.prepared
50 -(cd $(BUILD_DIR); ln -sf $(LINUX_DIR) linux)
51 touch $(LINUX_DIR)/.unpacked
52
53 $(LINUX_DIR)/.patched: $(WRT54G_DIR)/.prepared
54 $(SOURCE_DIR)/patch-kernel.sh $(LINUX_DIR)/../.. $(SOURCE_DIR)/openwrt/kernel/patches
55 # use replacement diag module code
56 cp -f $(SOURCE_DIR)/openwrt/kernel/diag.c $(LINUX_DIR)/drivers/net/diag/diag_led.c
57 cp -f $(SOURCE_DIR)/openwrt/kernel/linux.config $(LINUX_DIR)/.config
58 -(cd $(BUILD_DIR); ln -sf $(LINUX_DIR) linux)
59 -(cd $(LINUX_DIR)/arch/mips/brcm-boards/bcm947xx/; \
60 rm -rf compressed; \
61 tar jxvf $(SOURCE_DIR)/openwrt/kernel/compressed-20040531.tar.bz2; \
62 )
63 touch $(LINUX_DIR)/.patched
64
65 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched $(LINUX_DIR)/.bbc-patched $(LINUX_DIR)/.nf-patched
66 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR)/Makefile
67 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR)/arch/mips/Makefile
68 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
69 make -C $(LINUX_DIR) oldconfig include/linux/version.h
70 touch $(LINUX_DIR)/.configured
71
72 $(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured $(GCC_BUILD_DIR2)/.installed
73 $(MAKE) -C $(LINUX_DIR) dep
74 touch $(LINUX_DIR)/.depend_done
75
76 $(LINUX_DIR)/$(LINUX_BINLOC): $(LINUX_DIR)/.depend_done
77 $(MAKE) -C $(LINUX_DIR) $(LINUX_FORMAT)
78
79 openwrt-kmodules.tar.bz2: $(LINUX_DIR)/$(LINUX_BINLOC)
80 $(MAKE) -C $(LINUX_DIR) modules
81 $(MAKE) -C $(LINUX_DIR) DEPMOD=/bin/true \
82 INSTALL_MOD_PATH=$(LINUX_DIR)/modules modules_install
83 tar -C $(LINUX_DIR)/modules/lib -cjf openwrt-kmodules.tar.bz2 modules
84
85 openwrt-linux: $(LINUX_DIR)/$(LINUX_BINLOC)
86
87 $(DL_DIR)/$(WRT54G_SOURCE):
88 $(WGET) -P $(DL_DIR) $(WRT54G_SITE)/$(WRT54G_SOURCE)
89
90 $(WRT54G_DIR)/.source: $(DL_DIR)/$(WRT54G_SOURCE)
91 zcat $(DL_DIR)/$(WRT54G_SOURCE) | tar -C $(BUILD_DIR) -xvf - WRT54GS/README.TXT WRT54GS/release
92 touch $(WRT54G_DIR)/.source
93
94 $(WRT54G_DIR)/.prepared: $(WRT54G_DIR)/.source
95 $(SOURCE_DIR)/patch-kernel.sh $(WRT54G_DIR) $(SOURCE_DIR)/openwrt/patches
96 touch $(WRT54G_DIR)/.prepared
97
98 ######################################################################
99
100 OPENWRT_ROOT_SKEL:=root.tar.gz
101 OPENWRT_SITE=http://openwrt.ksilebo.net/cgi-bin/viewcvs.cgi/root
102
103 $(DL_DIR)/$(OPENWRT_ROOT_SKEL):
104 $(WGET) -P $(DL_DIR) $(OPENWRT_SITE)/$(OPENWRT_ROOT_SKEL)
105
106 ######################################################################
107
108 OPENWRT_SRCBASE:=$(WRT54G_DIR)/release/src
109 OPENWRT_SHARED_BUILD_DIR:=$(OPENWRT_SRCBASE)/router/shared
110 OPENWRT_SHARED_TARGET_BINARY:=usr/lib/libshared.so
111
112 $(TARGET_DIR)/$(OPENWRT_SHARED_TARGET_BINARY): $(WRT54G_DIR)/.source
113 $(MAKE) -C $(OPENWRT_SHARED_BUILD_DIR) -f Makefile-openwrt \
114 SRCBASE=$(OPENWRT_SRCBASE) INSTALLDIR=$(TARGET_DIR) \
115 CC=$(TARGET_CC) LD=$(TARGET_CROSS)ld STRIP="$(STRIP)" \
116 CFLAGS="$(TARGET_CFLAGS) -I. -I$(OPENWRT_SRCBASE)/include -Wall -I$(OPENWRT_SRCBASE)/" \
117 install
118
119 openwrt-shared: $(TARGET_DIR)/$(OPENWRT_SHARED_TARGET_BINARY)
120
121 openwrt-shared-clean:
122 -$(MAKE) -C $(OPENWRT_SHARED_BUILD_DIR) clean
123
124 ######################################################################
125
126 OPENWRT_NVRAM_BUILD_DIR:=$(OPENWRT_SRCBASE)/router/nvram
127 OPENWRT_NVRAM_TARGET_BINARY:=usr/sbin/nvram
128
129 $(TARGET_DIR)/$(OPENWRT_NVRAM_TARGET_BINARY): $(WRT54G_DIR)/.source
130 $(MAKE) -C $(OPENWRT_NVRAM_BUILD_DIR) \
131 SRCBASE=$(OPENWRT_SRCBASE) INSTALLDIR=$(TARGET_DIR) \
132 CC=$(TARGET_CC) LD=$(TARGET_CROSS)ld STRIP="$(STRIP)" \
133 CFLAGS="$(TARGET_CFLAGS) -I. -I$(OPENWRT_SRCBASE)/include -Wall -DOPENWRT_NVRAM" \
134 install
135
136
137 openwrt-nvram: $(TARGET_DIR)/$(OPENWRT_NVRAM_TARGET_BINARY)
138
139 openwrt-nvram-clean:
140 -$(MAKE) -C $(OPENWRT_NVRAM_BUILD_DIR) clean
141
142 ######################################################################
143
144 OPENWRT_MTD_BUILD_DIR:=$(OPENWRT_SRCBASE)/router/rc
145 OPENWRT_MTD_TARGET_BINARY:=sbin/mtd
146
147 $(TARGET_DIR)/$(OPENWRT_MTD_TARGET_BINARY): $(WRT54G_DIR)/.source $(TARGET_DIR)/$(OPENWRT_NVRAM_TARGET_BINARY) # need libnvram
148 $(MAKE) -C $(OPENWRT_MTD_BUILD_DIR) -f Makefile-openwrt \
149 TOP=$(OPENWRT_SRCBASE)/router \
150 SRCBASE=$(OPENWRT_SRCBASE) INSTALLDIR=$(TARGET_DIR) \
151 CC=$(TARGET_CC) LD=$(TARGET_CROSS)ld STRIP="$(STRIP)" \
152 CFLAGS="$(TARGET_CFLAGS) -I. -I$(OPENWRT_SRCBASE)/router/shared -I$(OPENWRT_SRCBASE)/include -Wall -I$(OPENWRT_SRCBASE)/" \
153 install
154
155 openwrt-mtd: $(TARGET_DIR)/$(OPENWRT_MTD_TARGET_BINARY)
156
157 openwrt-mtd-clean:
158 -$(MAKE) -C $(OPENWRT_MTD_BUILD_DIR) clean
159
160 ######################################################################
161
162 OPENWRT_WLCONF_BUILD_DIR:=$(OPENWRT_SRCBASE)/router/wlconf
163 OPENWRT_WLCONF_TARGET_BINARY:=usr/sbin/wlconf
164
165 $(TARGET_DIR)/$(OPENWRT_WLCONF_TARGET_BINARY): $(WRT54G_DIR)/.source
166 $(MAKE) -C $(OPENWRT_WLCONF_BUILD_DIR) \
167 TOP=$(OPENWRT_SRCBASE)/router \
168 SRCBASE=$(OPENWRT_SRCBASE) INSTALLDIR=$(TARGET_DIR) \
169 CC=$(TARGET_CC) LD=$(TARGET_CROSS)ld STRIP="$(STRIP)" \
170 CFLAGS="$(TARGET_CFLAGS) -I. -I$(OPENWRT_SRCBASE)/router/shared -I$(OPENWRT_SRCBASE)/include -Wall" \
171 install
172
173
174 openwrt-wlconf: $(TARGET_DIR)/$(OPENWRT_WLCONF_TARGET_BINARY)
175
176 openwrt-wlconf-clean:
177 -$(MAKE) -C $(OPENWRT_WLCONF_BUILD_DIR) clean
178
179 ######################################################################
180
181 openwrt-rootprep:
182 # tmp
183 mkdir -p $(TARGET_DIR)/tmp
184 chmod a+rwxt $(TARGET_DIR)/tmp
185 ln -sf /tmp $(TARGET_DIR)/var
186 rm -f $(TARGET_DIR)/usr/tmp
187 ln -sf ../tmp $(TARGET_DIR)/usr/tmp
188 # dev
189 mkdir -p $(TARGET_DIR)/dev
190 # etc
191 mkdir -p $(TARGET_DIR)/etc
192 ln -sf /tmp/resolv.conf $(TARGET_DIR)/etc/resolv.conf
193 # miscellaneous
194 mkdir -p $(TARGET_DIR)/mnt
195 mkdir -p $(TARGET_DIR)/proc
196 mkdir -p $(TARGET_DIR)/jffs
197 mkdir -p $(TARGET_DIR)/rom
198 # modules
199 mkdir -p $(TARGET_MODULES_DIR)
200 cp $(LINUX_DIR)/drivers/net/wl/wl.o $(TARGET_MODULES_DIR)
201 #cp $(LINUX_DIR)/drivers/net/et.4702/et.4702.o $(TARGET_MODULES_DIR)
202 cp $(LINUX_DIR)/drivers/net/et/et.o $(TARGET_MODULES_DIR)
203 cp $(LINUX_DIR)/drivers/net/diag/diag.o $(TARGET_MODULES_DIR)
204
205 ######################################################################
206
207 openwrt-prune:
208 -@find $(TARGET_DIR) -type f -perm +111 | xargs $(STRIP) 2>/dev/null || true;
209 # remove unneeded uClibc libs
210 rm -rf $(TARGET_DIR)/lib/libthread_db*
211 rm -rf $(TARGET_DIR)/lib/libpthread*
212 # remove unneeded uClibc utils
213 rm -f $(TARGET_DIR)/sbin/ldconfig
214 rm -f $(TARGET_DIR)/usr/bin/ldd
215 # remove other unneeded files
216 rm -f $(TARGET_DIR)/usr/sbin/iptables-save
217 rm -f $(TARGET_DIR)/usr/sbin/iptables-restore
218 rm -f $(TARGET_DIR)/usr/sbin/ip6tables
219
220 ######################################################################
221
222 wrt-tools:
223 $(CC) -o $(WRT54G_DIR)/release/tools/trx $(SOURCE_DIR)/openwrt/tools/trx.c
224 $(CC) -o $(WRT54G_DIR)/release/tools/addpattern $(SOURCE_DIR)/openwrt/tools/addpattern.c
225
226 openwrt-linux.trx: openwrt-prune squashfsroot wrt-tools
227 $(WRT54G_DIR)/release/tools/trx -o openwrt-linux.trx \
228 $(LINUX_DIR)/$(LINUX_BINLOC) $(IMAGE)
229
230 openwrt-gs-code.bin: openwrt-linux.trx
231 $(WRT54G_DIR)/release/tools/addpattern -i openwrt-linux.trx \
232 -o openwrt-gs-code.bin -g
233
234 openwrt-g-code.bin: openwrt-gs-code.bin
235 sed -e "1s,^W54S,W54G," < openwrt-gs-code.bin > openwrt-g-code.bin
236
237 openwrt-code.bin: openwrt-gs-code.bin openwrt-g-code.bin
238
239 ######################################################################
240 endif
This page took 0.067136 seconds and 5 git commands to generate.