2 # Toplevel Makefile for the BCM947xx Linux Router release
4 # Copyright 2005, Broadcom Corporation
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.
12 # $Id: Makefile,v 1.53 2005/04/25 03:54:37 tallest Exp $
15 # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
17 # To rebuild everything and all configurations:
19 # make libc (usually doesn't need to be done ???)
20 # make V1=whatever V2=sub-whatever a b c d m
21 # The 1st "whatever" would be the build number, the sub-whatever would
22 # be the update to the version.
25 # make V1=8516 V2="jffs.1" a b c d m s
27 # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31 SRCBASE
:= $(shell pwd
)
32 RELEASEDIR
:= $(shell (cd
$(SRCBASE
)/..
&& pwd
-P
))
33 PATH
:= $(RELEASEDIR
)/tools
:$(PATH
)
36 # Normally you'd do something like "make V1=8516 V2=sub-ver a b c d"
37 # But if you don't give anything for "V1", it'll get a default from tomato_version.
40 -include tomato_profile.mak
43 # This could be simpler by just using $(TOMATO_PROFILE_NAME) like it used to be,
44 # but that's fragile. If you make one certain innocuous change elsewhere in the
45 # makefile(s), the build will silently be wrong. This way it works properly every time.
46 current_BUILD_NAME
= $(strip $(shell grep
"^TOMATO_BUILD_NAME" tomato_profile.mak | cut
-d
"=" -f2
))
47 current_BUILD_DESC
= $(strip $(shell grep
"^TOMATO_BUILD_DESC" tomato_profile.mak | cut
-d
"=" -f2
))
48 current_BUILD_USB
= $(strip $(shell grep
"^TOMATO_BUILD_USB" tomato_profile.mak | cut
-d
"=" -f2
))
50 uppercase_N
= $(shell echo
$(N
) | tr a-z A-Z
)
51 lowercase_N
= $(shell echo
$(N
) | tr A-Z a-z
)
52 uppercase_B
= $(shell echo
$(B
) | tr a-z A-Z
)
53 lowercase_B
= $(shell echo
$(B
) | tr A-Z a-z
)
56 ifeq ($(TOMATO_BUILD
),)
67 @echo
"Building $(current_BUILD_USB) $(V1)$(V2) $(current_BUILD_DESC) $(current_BUILD_NAME) with $(TOMATO_PROFILE_NAME) Profile"
68 @btools
/uversion.pl
--gen
$(V1
) $(V2
) "ND" $(current_BUILD_USB
) $(current_BUILD_DESC
)
73 @
$(MAKE
) -C router
all
74 @
$(MAKE
) -C router
install
77 @
rm -f image
/tomato-ND
$(current_BUILD_USB
)-$(V1
)$(V2
)-$(current_BUILD_DESC
).trx
79 @echo
"***********************" `date` "************************" >>fpkg.log
80 @cat router
/shared
/tomato_version
>>fpkg.log
82 @cat router
/target.
info >>fpkg.log
83 ifeq ($(wildcard include/bcm20xx.h
),)
84 @btools
/fpkg
-i lzma-loader
/loader.gz
-i linux
/linux
/arch
/mips
/brcm-boards
/bcm947xx
/compressed
/vmlinuz
-i router
/mipsel-uclibc
/target.image \
86 -l W54G
,image
/WRT54G_WRT54GL.bin \
87 -l W54S
,image
/WRT54GS.bin \
88 -l W54s
,image
/WRT54GSv4.bin \
89 -l W54U
,image
/WRTSL54GS.bin \
90 -m
0x10577050,image
/WR850G.bin \
93 @btools
/fpkg
-i lzma-loader
/loader.gz
-i linux
/linux
/arch
/mips
/brcm-boards
/bcm947xx
/compressed
/vmlinuz
-i router
/mipsel-uclibc
/target.image \
94 -t image
/tomato-ND
$(current_BUILD_USB
)-$(V1
)$(V2
)-$(current_BUILD_DESC
).trx | tee
-a fpkg.log
97 @cp fpkg.log image
/fpkg-
$(V1
)$(V2
).log
99 @echo
"-----------------"
100 @echo
`cat router/shared/tomato_version` " ready"
101 @echo
"-----------------"
102 ifneq ($(NOVERSION
),1)
103 @cp router
/shared
/tomato_version router
/shared
/tomato_version_last
104 @btools
/uversion.pl
--bump
111 @touch router
/.config
112 @
rm -f router
/config_
[a-z
]
113 @
rm -f router
/busybox
/config_
[a-z
]
114 @
$(MAKE
) -C router
$@
115 @
-rmdir router
/mipsel-uclibc
120 @
rm -f router
/.config
121 @touch router
/.config
125 @
$(MAKE
) -C linux
/linux
/scripts
/squashfs
clean
126 @
$(MAKE
) -C btools
clean
130 mv .config save-config
&& \
132 cp
-p save-config .config
134 distclean: clean cleanimage cleankernel cleantools cleanlibc
135 ifneq ($(INSIDE_MAK
),1)
136 @
$(MAKE
) -C router
$@ INSIDE_MAK
=1
138 mv router
/busybox
/.config busybox-saved-config
139 @
$(MAKE
) -C router
/busybox
distclean
140 @
rm -f router
/busybox
/config_current || true
141 @cp
-p busybox-saved-config router
/busybox
/.config
142 @cp
-p router
/busybox
/.config router
/busybox
/config_current
143 @
rm -f router
/config_current || true
144 @
rm -f router
/.config.cmd router
/.config.old router
/.config
145 @
rm -f router
/libfoo_xref.txt
146 @
rm -f tomato_profile.mak router
/shared
/tomato_profile.h
147 @touch tomato_profile.mak
148 @touch router
/shared
/tomato_profile.h
152 $(MAKE
) -C linux
/linux oldconfig dep
156 @echo
"$(current_BUILD_DESC)-$(current_BUILD_NAME)-$(TOMATO_PROFILE_NAME) Profile"
160 # The methodology for making the different builds is to
161 # copy the "base" config file to the "target" config file in
162 # the appropriate directory, and then edit it by removing and
163 # inserting the desired configuration lines.
164 # You can't just delete the "whatever=y" line, you must have
165 # a "...is not set" line, or the make oldconfig will stop and ask
168 ## Make the "normal" build
170 @cp router
/config_base router
/config_
$@
171 @cp router
/busybox
/config_base router
/busybox
/config_
$@
172 @
$(MAKE
) setprofile N
=G B
=A DESC
="Std" USB
="USB"
176 ## Make the "normal but without SSH" build
178 @cp router
/config_base router
/config_
$@
179 @sed
-i
"/TCONFIG_SSH/d" router
/config_
$@
180 @echo
"# TCONFIG_SSH is not set" >>router
/config_
$@
181 @cp router
/busybox
/config_base router
/busybox
/config_
$@
182 @
$(MAKE
) setprofile N
=G B
=B DESC
="No SSH" USB
="USB"
185 ## Make the "normal but without cifs" build
187 @cp router
/config_base router
/config_
$@
188 @sed
-i
"/TCONFIG_CIFS/d" router
/config_
$@
189 @echo
"# TCONFIG_CIFS is not set" >>router
/config_
$@
190 @cp router
/busybox
/config_base router
/busybox
/config_
$@
191 @
$(MAKE
) setprofile N
=G B
=C DESC
="No CIFS" USB
="USB"
194 ## Make the "normal but without SAMBA" build
196 @cp router
/config_base router
/config_
$@
197 @sed
-i
"/TCONFIG_SAMBASRV/d" router
/config_
$@
198 @echo
"# TCONFIG_SAMBASRV is not set" >>router
/config_
$@
199 @cp router
/busybox
/config_base router
/busybox
/config_
$@
200 @sed
-i
"/CONFIG_FEATURE_MOUNT_LOOP/d" router
/busybox
/config_
$@
201 @echo
"# CONFIG_FEATURE_MOUNT_LOOP is not set" >>router
/busybox
/config_
$@
202 @sed
-i
"/CONFIG_AWK/d" router
/busybox
/config_
$@
203 @echo
"# CONFIG_AWK is not set" >>router
/busybox
/config_
$@
204 @sed
-i
"/CONFIG_FEATURE_DEVFS/d" router
/busybox
/config_
$@
205 @echo
"# CONFIG_FEATURE_DEVFS is not set" >>router
/busybox
/config_
$@
206 @sed
-i
"/CONFIG_ARPING/d" router
/busybox
/config_
$@
207 @echo
"# CONFIG_ARPING is not set" >>router
/busybox
/config_
$@
208 @
$(MAKE
) setprofile N
=G B
=D DESC
="Lite" USB
="USB"
211 ## Make the "normal + VPN" build
213 @cp router
/config_base router
/config_
$@
214 @sed
-i
"/TCONFIG_LZO/d" router
/config_
$@
215 @sed
-i
"/TCONFIG_OPENVPN/d" router
/config_
$@
216 @echo
"TCONFIG_LZO=y" >>router
/config_
$@
217 @echo
"TCONFIG_OPENVPN=y" >>router
/config_
$@
218 @cp router
/busybox
/config_base router
/busybox
/config_
$@
219 @
$(MAKE
) setprofile N
=G B
=E DESC
="VPN" USB
="USB"
222 ## Make the "normal with Extras" build
224 @cp router
/config_base router
/config_
$@
225 @sed
-i
"/TCONFIG_USB_EXTRAS/d" router
/config_
$@
226 @echo
"TCONFIG_USB_EXTRAS=y" >>router
/config_
$@
227 @sed
-i
"/TCONFIG_NTFS/d" router
/config_
$@
228 @echo
"TCONFIG_NTFS=y" >>router
/config_
$@
229 @cp router
/busybox
/config_base router
/busybox
/config_
$@
230 @sed
-i
"/CONFIG_UNZIP/d" router
/busybox
/config_
$@
231 @echo
"CONFIG_UNZIP=y" >>router
/busybox
/config_
$@
232 @sed
-i
"/CONFIG_FEATURE_LS_COLOR/d" router
/busybox
/config_
$@
233 @echo
"CONFIG_FEATURE_LS_COLOR=y" >>router
/busybox
/config_
$@
234 @sed
-i
"/CONFIG_FEATURE_LS_COLOR_IS_DEFAULT/d" router
/busybox
/config_
$@
235 @echo
"CONFIG_FEATURE_LS_COLOR_IS_DEFAULT=y" >>router
/busybox
/config_
$@
236 @sed
-i
"/CONFIG_FEATURE_SORT_BIG/d" router
/busybox
/config_
$@
237 @echo
"CONFIG_FEATURE_SORT_BIG=y" >>router
/busybox
/config_
$@
238 @sed
-i
"/CONFIG_E2FSCK/d" router
/busybox
/config_
$@
239 @echo
"CONFIG_E2FSCK=y" >>router
/busybox
/config_
$@
240 @sed
-i
"/CONFIG_MKE2FS/d" router
/busybox
/config_
$@
241 @echo
"CONFIG_MKE2FS=y" >>router
/busybox
/config_
$@
242 @sed
-i
"/CONFIG_FDISK/d" router
/busybox
/config_
$@
243 @echo
"CONFIG_FDISK=y" >>router
/busybox
/config_
$@
244 @sed
-i
"/CONFIG_FEATURE_FDISK_WRITABLE/d" router
/busybox
/config_
$@
245 @echo
"CONFIG_FEATURE_FDISK_WRITABLE=y" >>router
/busybox
/config_
$@
246 @sed
-i
"/CONFIG_MKFS_VFAT/d" router
/busybox
/config_
$@
247 @echo
"CONFIG_MKFS_VFAT=y" >>router
/busybox
/config_
$@
248 @sed
-i
"/CONFIG_MKSWAP/d" router
/busybox
/config_
$@
249 @echo
"CONFIG_MKSWAP=y" >>router
/busybox
/config_
$@
250 @
$(MAKE
) setprofile N
=G B
=M DESC
="Ext" USB
="USB"
253 ## Make the "No USB" build
255 @cp router
/config_base router
/config_
$@
256 @sed
-i
"/TCONFIG_SAMBASRV/d" router
/config_
$@
257 @echo
"# TCONFIG_SAMBASRV is not set" >>router
/config_
$@
258 @sed
-i
"/TCONFIG_FTP/d" router
/config_
$@
259 @echo
"# TCONFIG_FTP is not set" >>router
/config_
$@
260 @sed
-i
"/TCONFIG_USB/d" router
/config_
$@
261 @echo
"# TCONFIG_USB is not set" >>router
/config_
$@
262 @cp router
/busybox
/config_base router
/busybox
/config_
$@
263 @sed
-i
"/CONFIG_FEATURE_MOUNT_LOOP/d" router
/busybox
/config_
$@
264 @echo
"# CONFIG_FEATURE_MOUNT_LOOP is not set" >>router
/busybox
/config_
$@
265 @sed
-i
"/CONFIG_FEATURE_DEVFS/d" router
/busybox
/config_
$@
266 @echo
"# CONFIG_FEATURE_DEVFS is not set" >>router
/busybox
/config_
$@
267 @sed
-i
"/CONFIG_UNZIP/d" router
/busybox
/config_
$@
268 @echo
"CONFIG_UNZIP=y" >>router
/busybox
/config_
$@
269 @sed
-i
"/CONFIG_FEATURE_LS_COLOR/d" router
/busybox
/config_
$@
270 @echo
"CONFIG_FEATURE_LS_COLOR=y" >>router
/busybox
/config_
$@
271 @sed
-i
"/CONFIG_FEATURE_LS_COLOR_IS_DEFAULT/d" router
/busybox
/config_
$@
272 @echo
"CONFIG_FEATURE_LS_COLOR_IS_DEFAULT=y" >>router
/busybox
/config_
$@
273 @sed
-i
"/CONFIG_FEATURE_SORT_BIG/d" router
/busybox
/config_
$@
274 @echo
"CONFIG_FEATURE_SORT_BIG=y" >>router
/busybox
/config_
$@
275 @sed
-i
"/CONFIG_FEATURE_MOUNT_LABEL/d" router
/busybox
/config_
$@
276 @echo
"# CONFIG_FEATURE_MOUNT_LABEL is not set" >>router
/busybox
/config_
$@
277 @sed
-i
"/CONFIG_FEATURE_MOUNT_FSTAB/d" router
/busybox
/config_
$@
278 @echo
"# CONFIG_FEATURE_MOUNT_FSTAB is not set" >>router
/busybox
/config_
$@
279 @sed
-i
"/CONFIG_VOLUMEID/d" router
/busybox
/config_
$@
280 @echo
"# CONFIG_VOLUMEID is not set" >>router
/busybox
/config_
$@
281 @sed
-i
"/CONFIG_BLKID/d" router
/busybox
/config_
$@
282 @echo
"# CONFIG_BLKID is not set" >>router
/busybox
/config_
$@
283 @sed
-i
"/CONFIG_SWAPONOFF/d" router
/busybox
/config_
$@
284 @echo
"# CONFIG_SWAPONOFF is not set" >>router
/busybox
/config_
$@
285 @
$(MAKE
) setprofile N
=G B
=S DESC
="" USB
=""
289 echo
'#ifndef TOMATO_PROFILE' > router
/shared
/tomato_profile.h
290 echo
'#define TOMATO_$(N) 1' >> router
/shared
/tomato_profile.h
291 echo
'#define PROFILE_G 1' >> router
/shared
/tomato_profile.h
292 echo
'#define PROFILE_N 2' >> router
/shared
/tomato_profile.h
293 echo
'#define TOMATO_PROFILE PROFILE_$(N)' >> router
/shared
/tomato_profile.h
294 echo
'#define TOMATO_PROFILE_NAME "$(N)"' >> router
/shared
/tomato_profile.h
295 echo
'#define TOMATO_BUILD_NAME "$(B)"' >> router
/shared
/tomato_profile.h
296 echo
'#define TOMATO_BUILD_DESC "$(DESC)"' >> router
/shared
/tomato_profile.h
297 echo
'#endif' >> router
/shared
/tomato_profile.h
299 echo
'TOMATO_$(N) = 1' > tomato_profile.mak
300 echo
'PROFILE_G = 1' >> tomato_profile.mak
301 echo
'PROFILE_N = 2' >> tomato_profile.mak
302 echo
'TOMATO_PROFILE = $$(PROFILE_$(N))' >> tomato_profile.mak
303 echo
'TOMATO_PROFILE_NAME = "$(N)"' >> tomato_profile.mak
304 echo
'TOMATO_BUILD = "$(B)"' >> tomato_profile.mak
305 echo
'TOMATO_BUILD_NAME = "$(B)"' >> tomato_profile.mak
306 echo
'TOMATO_BUILD_DESC = "$(DESC)"' >> tomato_profile.mak
307 echo
'TOMATO_PROFILE_L = $(lowercase_N)' >> tomato_profile.mak
308 echo
'TOMATO_PROFILE_U = $(uppercase_N)' >> tomato_profile.mak
309 echo
'TOMATO_BUILD_USB = "$(USB)"' >> tomato_profile.mak
312 # Note that changes to variables in tomato_profile.mak don't
313 # get propogated to this invocation of make!
315 rm -f config_current
; \
316 ln
-s config_
$(lowercase_B
) config_current
; \
317 cp config_current .config
318 @
$(MAKE
) -C router oldconfig
321 @echo
"Using $(N) profile, $(B) build config."
324 @cd router
/busybox
&& \
325 rm -f config_current
; \
326 ln
-s config_
$(lowercase_B
) config_current
; \
327 cp config_current .config
328 @
$(MAKE
) -C router
/busybox oldconfig
331 # @$(MAKE) -C ../../tools-src/uClibc clean
334 # @$(MAKE) -C ../../tools-src/uClibc
335 # @$(MAKE) -C ../../tools-src/uClibc install
338 @echo
"a A build (standard)"
339 @echo
"b B build (standard minus SSH)"
340 @echo
"c C build (standard minus cifs)"
341 @echo
"d D build (standard minus Samba server)"
342 @echo
"m M build (standard plus extra utilities)"
343 @echo
"..etc.. other build configs"
344 @echo
"clean -C router clean"
345 @echo
"cleanimage rm -rf image"
346 @echo
"cleantools clean btools, mksquashfs"
347 @echo
"cleankernel -C linux/linux distclean (but preserves .config)"
348 @echo
"distclean distclean of Linux & busybox (but preserve .configs)"
349 @echo
"prepk -C linux/linux oldconfig dep"
350 @echo
"libc -C uClibc clean, all, install"
352 .PHONY
: all clean distclean cleanimage cleantools cleankernel prepk what setprofile libc help
353 .PHONY
: a b c d m Makefile allversions tomato_profile.mak