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 export SRCBASE
:= $(shell pwd
)
32 RELEASEDIR
:= $(shell (cd
$(SRCBASE
)/..
&& pwd
-P
))
33 PATH
:= $(RELEASEDIR
)/tools
:$(PATH
)
37 # Normally you'd do something like "make V1=8516 V2=sub-ver a b c d"
38 # But if you don't give anything for "V1", it'll get a default from tomato_version.
41 -include tomato_profile.mak
44 # This could be simpler by just using $(TOMATO_PROFILE_NAME) like it used to be,
45 # but that's fragile. If you make one certain innocuous change elsewhere in the
46 # makefile(s), the build will silently be wrong. This way it works properly every time.
47 current_BUILD_NAME
= $(strip $(shell grep
"^TOMATO_BUILD_NAME" tomato_profile.mak | cut
-d
"=" -f2
))
48 current_BUILD_DESC
= $(strip $(shell grep
"^TOMATO_BUILD_DESC" tomato_profile.mak | cut
-d
"=" -f2
))
49 current_BUILD_USB
= $(strip $(shell grep
"^TOMATO_BUILD_USB" tomato_profile.mak | cut
-d
"=" -f2
))
51 uppercase_N
= $(shell echo
$(N
) | tr a-z A-Z
)
52 lowercase_N
= $(shell echo
$(N
) | tr A-Z a-z
)
53 uppercase_B
= $(shell echo
$(B
) | tr a-z A-Z
)
54 lowercase_B
= $(shell echo
$(B
) | tr A-Z a-z
)
57 ifeq ($(TOMATO_BUILD
),)
68 @echo
"Building $(current_BUILD_USB) $(V1)$(V2) $(current_BUILD_DESC) $(current_BUILD_NAME) with $(TOMATO_PROFILE_NAME) Profile"
69 @btools
/uversion.pl
--gen
$(V1
) $(V2
) "ND" $(current_BUILD_USB
) $(current_BUILD_DESC
)
74 @
$(MAKE
) -C router
all
75 @
$(MAKE
) -C router
install
78 @
rm -f image
/tomato-ND
$(current_BUILD_USB
)-$(V1
)$(V2
)-$(current_BUILD_DESC
).trx
80 @echo
"***********************" `date` "************************" >>fpkg.log
81 @cat router
/shared
/tomato_version
>>fpkg.log
83 @cat router
/target.
info >>fpkg.log
84 ifeq ($(wildcard include/bcm20xx.h
),)
85 @btools
/fpkg
-i lzma-loader
/loader.gz
-i
$(LINUXDIR
)/arch
/mips
/brcm-boards
/bcm947xx
/compressed
/vmlinuz
-i router
/mipsel-uclibc
/target.image \
87 -l W54G
,image
/WRT54G_WRT54GL.bin \
88 -l W54S
,image
/WRT54GS.bin \
89 -l W54s
,image
/WRT54GSv4.bin \
90 -l W54U
,image
/WRTSL54GS.bin \
91 -m
0x10577050,image
/WR850G.bin \
94 @btools
/fpkg
-i lzma-loader
/loader.gz
-i
$(LINUXDIR
)/arch
/mips
/brcm-boards
/bcm947xx
/compressed
/vmlinuz
-i router
/mipsel-uclibc
/target.image \
95 -t image
/tomato-ND
$(current_BUILD_USB
)-$(V1
)$(V2
)-$(current_BUILD_DESC
).trx | tee
-a fpkg.log
98 @cp fpkg.log image
/fpkg-
$(V1
)$(V2
).log
100 @echo
"-----------------"
101 @echo
`cat router/shared/tomato_version` " ready"
102 @echo
"-----------------"
103 ifneq ($(NOVERSION
),1)
104 @cp router
/shared
/tomato_version router
/shared
/tomato_version_last
105 @btools
/uversion.pl
--bump
112 @touch router
/.config
113 @
rm -f router
/config_
[a-z
]
114 @
rm -f router
/busybox
/config_
[a-z
]
115 @
$(MAKE
) -C router
$@
116 @
-rmdir router
/mipsel-uclibc
121 @
rm -f router
/.config
122 @touch router
/.config
126 @
$(MAKE
) -C
$(LINUXDIR
)/scripts
/squashfs
clean
127 @
$(MAKE
) -C btools
clean
131 mv .config save-config
&& \
133 cp
-p save-config .config
135 distclean: clean cleanimage cleankernel cleantools cleanlibc
136 ifneq ($(INSIDE_MAK
),1)
137 @
$(MAKE
) -C router
$@ INSIDE_MAK
=1
139 mv router
/busybox
/.config busybox-saved-config
140 @
$(MAKE
) -C router
/busybox
distclean
141 @
rm -f router
/busybox
/config_current || true
142 @cp
-p busybox-saved-config router
/busybox
/.config
143 @cp
-p router
/busybox
/.config router
/busybox
/config_current
144 @
rm -f router
/config_current || true
145 @
rm -f router
/.config.cmd router
/.config.old router
/.config
146 @
rm -f router
/libfoo_xref.txt
147 @
rm -f tomato_profile.mak router
/shared
/tomato_profile.h
148 @touch tomato_profile.mak
149 @touch router
/shared
/tomato_profile.h
153 $(MAKE
) -C
$(LINUXDIR
) oldconfig dep
157 @echo
"$(current_BUILD_DESC)-$(current_BUILD_NAME)-$(TOMATO_PROFILE_NAME) Profile"
161 # The methodology for making the different builds is to
162 # copy the "base" config file to the "target" config file in
163 # the appropriate directory, and then edit it by removing and
164 # inserting the desired configuration lines.
165 # You can't just delete the "whatever=y" line, you must have
166 # a "...is not set" line, or the make oldconfig will stop and ask
169 # $(1) - router/busybox/config_$@
171 define BusyboxExtraOptions
172 @sed
-i
"/CONFIG_UNZIP/d" $(1)
173 @echo
"CONFIG_UNZIP=y" >>$(1)
174 @sed
-i
"/CONFIG_FEATURE_LS_COLOR/d" $(1)
175 @echo
"CONFIG_FEATURE_LS_COLOR=y" >>$(1)
176 @sed
-i
"/CONFIG_FEATURE_LS_COLOR_IS_DEFAULT/d" $(1)
177 @echo
"CONFIG_FEATURE_LS_COLOR_IS_DEFAULT=y" >>$(1)
178 @sed
-i
"/CONFIG_FEATURE_SORT_BIG/d" $(1)
179 @echo
"CONFIG_FEATURE_SORT_BIG=y" >>$(1)
182 define BusyboxExtraUSBOptions
183 @sed
-i
"/CONFIG_E2FSCK/d" $(1)
184 @echo
"CONFIG_E2FSCK=y" >>$(1)
185 @sed
-i
"/CONFIG_MKE2FS/d" $(1)
186 @echo
"CONFIG_MKE2FS=y" >>$(1)
187 @sed
-i
"/CONFIG_FDISK/d" $(1)
188 @echo
"CONFIG_FDISK=y" >>$(1)
189 @sed
-i
"/CONFIG_FEATURE_FDISK_WRITABLE/d" $(1)
190 @echo
"CONFIG_FEATURE_FDISK_WRITABLE=y" >>$(1)
191 @sed
-i
"/CONFIG_MKFS_VFAT/d" $(1)
192 @echo
"CONFIG_MKFS_VFAT=y" >>$(1)
193 @sed
-i
"/CONFIG_MKSWAP/d" $(1)
194 @echo
"CONFIG_MKSWAP=y" >>$(1)
197 ifeq ($(CONFIG_LINUX26
),y
)
198 define BusyboxKernelConfig
199 @sed
-i
"/CONFIG_FEATURE_2_4_MODULES/d" $(1)
200 @echo
"# CONFIG_FEATURE_2_4_MODULES is not set" >>$(1)
201 @sed
-i
"/CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT/d" $(1)
202 @echo
"CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT=y" >>$(1)
203 @sed
-i
"/CONFIG_FEATURE_DEVFS/d" $(1)
204 @echo
"# CONFIG_FEATURE_DEVFS is not set" >>$(1)
205 @sed
-i
"/CONFIG_MKNOD/d" $(1)
206 @echo
"CONFIG_MKNOD=y" >>$(1)
207 @sed
-i
"/CONFIG_FEATURE_WGET_STATUSBAR/d" $(1)
208 @echo
"CONFIG_FEATURE_WGET_STATUSBAR=y" >>$(1)
209 @sed
-i
"/CONFIG_FEATURE_VERBOSE_USAGE/d" $(1)
210 @echo
"CONFIG_FEATURE_VERBOSE_USAGE=y" >>$(1)
211 $(call BusyboxExtraOptions
, $(1))
214 define BusyboxKernelConfig
218 ## Make the "normal" build
220 @cp router
/config_base router
/config_
$@
221 @cp router
/busybox
/config_base router
/busybox
/config_
$@
223 $(call BusyboxKernelConfig
, router
/busybox
/config_
$@
)
225 @
$(MAKE
) setprofile N
=$(TPROFILE
) B
=A DESC
="Std" USB
="USB"
228 ## Make the "normal but without SSH" build
230 @cp router
/config_base router
/config_
$@
231 @cp router
/busybox
/config_base router
/busybox
/config_
$@
233 @sed
-i
"/TCONFIG_SSH/d" router
/config_
$@
234 @echo
"# TCONFIG_SSH is not set" >>router
/config_
$@
236 $(call BusyboxKernelConfig
, router
/busybox
/config_
$@
)
238 @
$(MAKE
) setprofile N
=$(TPROFILE
) B
=B DESC
="No SSH" USB
="USB"
241 ## Make the "normal but without cifs" build
243 @cp router
/config_base router
/config_
$@
244 @cp router
/busybox
/config_base router
/busybox
/config_
$@
246 @sed
-i
"/TCONFIG_CIFS/d" router
/config_
$@
247 @echo
"# TCONFIG_CIFS is not set" >>router
/config_
$@
249 $(call BusyboxKernelConfig
, router
/busybox
/config_
$@
)
251 @sed
-i
"/CONFIG_FEATURE_MOUNT_CIFS/d" router
/busybox
/config_
$@
252 @echo
"# CONFIG_FEATURE_MOUNT_CIFS is not set" >>router
/busybox
/config_
$@
254 @
$(MAKE
) setprofile N
=$(TPROFILE
) B
=C DESC
="No CIFS" USB
="USB"
257 ## Make the "normal but without SAMBA" build
259 @cp router
/config_base router
/config_
$@
260 @cp router
/busybox
/config_base router
/busybox
/config_
$@
262 @sed
-i
"/TCONFIG_SAMBASRV/d" router
/config_
$@
263 @echo
"# TCONFIG_SAMBASRV is not set" >>router
/config_
$@
265 $(call BusyboxKernelConfig
, router
/busybox
/config_
$@
)
267 @sed
-i
"/CONFIG_FEATURE_MOUNT_LOOP/d" router
/busybox
/config_
$@
268 @echo
"# CONFIG_FEATURE_MOUNT_LOOP is not set" >>router
/busybox
/config_
$@
269 @sed
-i
"/CONFIG_AWK/d" router
/busybox
/config_
$@
270 @echo
"# CONFIG_AWK is not set" >>router
/busybox
/config_
$@
271 @sed
-i
"/CONFIG_FEATURE_DEVFS/d" router
/busybox
/config_
$@
272 @echo
"# CONFIG_FEATURE_DEVFS is not set" >>router
/busybox
/config_
$@
273 @sed
-i
"/CONFIG_BLKID/d" router
/busybox
/config_
$@
274 @echo
"# CONFIG_BLKID is not set" >>router
/busybox
/config_
$@
275 @sed
-i
"/CONFIG_ARPING/d" router
/busybox
/config_
$@
276 @echo
"# CONFIG_ARPING is not set" >>router
/busybox
/config_
$@
278 @
$(MAKE
) setprofile N
=$(TPROFILE
) B
=D DESC
="Lite" USB
="USB"
281 ## Make the "normal with Extras + VPN" build
283 @cp router
/config_base router
/config_
$@
284 @cp router
/busybox
/config_base router
/busybox
/config_
$@
286 @sed
-i
"/TCONFIG_LZO/d" router
/config_
$@
287 @sed
-i
"/TCONFIG_OPENVPN/d" router
/config_
$@
288 @echo
"TCONFIG_LZO=y" >>router
/config_
$@
289 @echo
"TCONFIG_OPENVPN=y" >>router
/config_
$@
290 @sed
-i
"/TCONFIG_USB_EXTRAS/d" router
/config_
$@
291 @echo
"TCONFIG_USB_EXTRAS=y" >>router
/config_
$@
292 @sed
-i
"/TCONFIG_NTFS/d" router
/config_
$@
293 @echo
"TCONFIG_NTFS=y" >>router
/config_
$@
295 $(call BusyboxExtraOptions
, router
/busybox
/config_
$@
)
296 $(call BusyboxExtraUSBOptions
, router
/busybox
/config_
$@
)
297 $(call BusyboxKernelConfig
, router
/busybox
/config_
$@
)
299 @
$(MAKE
) setprofile N
=$(TPROFILE
) B
=E DESC
="VPN" USB
="USB"
302 ## Make the "normal with Extras" build
304 @cp router
/config_base router
/config_
$@
305 @cp router
/busybox
/config_base router
/busybox
/config_
$@
307 @sed
-i
"/TCONFIG_USB_EXTRAS/d" router
/config_
$@
308 @echo
"TCONFIG_USB_EXTRAS=y" >>router
/config_
$@
309 @sed
-i
"/TCONFIG_NTFS/d" router
/config_
$@
310 @echo
"TCONFIG_NTFS=y" >>router
/config_
$@
312 $(call BusyboxExtraOptions
, router
/busybox
/config_
$@
)
313 $(call BusyboxExtraUSBOptions
, router
/busybox
/config_
$@
)
314 $(call BusyboxKernelConfig
, router
/busybox
/config_
$@
)
316 @
$(MAKE
) setprofile N
=$(TPROFILE
) B
=M DESC
="Ext" USB
="USB"
319 ## Make the "No USB" build
321 @cp router
/config_base router
/config_
$@
322 @cp router
/busybox
/config_base router
/busybox
/config_
$@
324 @sed
-i
"/TCONFIG_SAMBASRV/d" router
/config_
$@
325 @echo
"# TCONFIG_SAMBASRV is not set" >>router
/config_
$@
326 @sed
-i
"/TCONFIG_FTP/d" router
/config_
$@
327 @echo
"# TCONFIG_FTP is not set" >>router
/config_
$@
328 @sed
-i
"/TCONFIG_USB/d" router
/config_
$@
329 @echo
"# TCONFIG_USB is not set" >>router
/config_
$@
331 $(call BusyboxExtraOptions
, router
/busybox
/config_
$@
)
332 $(call BusyboxKernelConfig
, router
/busybox
/config_
$@
)
334 @sed
-i
"/CONFIG_FEATURE_MOUNT_LOOP/d" router
/busybox
/config_
$@
335 @echo
"# CONFIG_FEATURE_MOUNT_LOOP is not set" >>router
/busybox
/config_
$@
336 @sed
-i
"/CONFIG_FEATURE_DEVFS/d" router
/busybox
/config_
$@
337 @echo
"# CONFIG_FEATURE_DEVFS is not set" >>router
/busybox
/config_
$@
338 @sed
-i
"/CONFIG_FEATURE_MOUNT_LABEL/d" router
/busybox
/config_
$@
339 @echo
"# CONFIG_FEATURE_MOUNT_LABEL is not set" >>router
/busybox
/config_
$@
340 @sed
-i
"/CONFIG_FEATURE_MOUNT_FSTAB/d" router
/busybox
/config_
$@
341 @echo
"# CONFIG_FEATURE_MOUNT_FSTAB is not set" >>router
/busybox
/config_
$@
342 @sed
-i
"/CONFIG_VOLUMEID/d" router
/busybox
/config_
$@
343 @echo
"# CONFIG_VOLUMEID is not set" >>router
/busybox
/config_
$@
344 @sed
-i
"/CONFIG_BLKID/d" router
/busybox
/config_
$@
345 @echo
"# CONFIG_BLKID is not set" >>router
/busybox
/config_
$@
346 @sed
-i
"/CONFIG_SWAPONOFF/d" router
/busybox
/config_
$@
347 @echo
"# CONFIG_SWAPONOFF is not set" >>router
/busybox
/config_
$@
349 @
$(MAKE
) setprofile N
=$(TPROFILE
) B
=S DESC
="" USB
=""
353 echo
'#ifndef TOMATO_PROFILE' > router
/shared
/tomato_profile.h
354 echo
'#define TOMATO_$(N) 1' >> router
/shared
/tomato_profile.h
355 echo
'#define PROFILE_G 1' >> router
/shared
/tomato_profile.h
356 echo
'#define PROFILE_N 2' >> router
/shared
/tomato_profile.h
357 echo
'#define TOMATO_PROFILE PROFILE_$(N)' >> router
/shared
/tomato_profile.h
358 echo
'#define TOMATO_PROFILE_NAME "$(N)"' >> router
/shared
/tomato_profile.h
359 echo
'#define TOMATO_BUILD_NAME "$(B)"' >> router
/shared
/tomato_profile.h
360 echo
'#define TOMATO_BUILD_DESC "$(DESC)"' >> router
/shared
/tomato_profile.h
361 echo
'#endif' >> router
/shared
/tomato_profile.h
363 echo
'TOMATO_$(N) = 1' > tomato_profile.mak
364 echo
'PROFILE_G = 1' >> tomato_profile.mak
365 echo
'PROFILE_N = 2' >> tomato_profile.mak
366 echo
'TOMATO_PROFILE = $$(PROFILE_$(N))' >> tomato_profile.mak
367 echo
'TOMATO_PROFILE_NAME = "$(N)"' >> tomato_profile.mak
368 echo
'TOMATO_BUILD = "$(B)"' >> tomato_profile.mak
369 echo
'TOMATO_BUILD_NAME = "$(B)"' >> tomato_profile.mak
370 echo
'TOMATO_BUILD_DESC = "$(DESC)"' >> tomato_profile.mak
371 echo
'TOMATO_PROFILE_L = $(lowercase_N)' >> tomato_profile.mak
372 echo
'TOMATO_PROFILE_U = $(uppercase_N)' >> tomato_profile.mak
373 echo
'TOMATO_BUILD_USB = "$(USB)"' >> tomato_profile.mak
376 # Note that changes to variables in tomato_profile.mak don't
377 # get propogated to this invocation of make!
379 rm -f config_current
; \
380 ln
-s config_
$(lowercase_B
) config_current
; \
381 cp config_current .config
382 @
$(MAKE
) -C router oldconfig
385 @echo
"Using $(N) profile, $(B) build config."
388 @cd router
/busybox
&& \
389 rm -f config_current
; \
390 ln
-s config_
$(lowercase_B
) config_current
; \
391 cp config_current .config
392 @
$(MAKE
) -C router
/busybox oldconfig
395 # @$(MAKE) -C ../../tools-src/uClibc clean
398 # @$(MAKE) -C ../../tools-src/uClibc
399 # @$(MAKE) -C ../../tools-src/uClibc install
402 @echo
"a A build (standard)"
403 @echo
"b B build (standard minus SSH)"
404 @echo
"c C build (standard minus cifs)"
405 @echo
"d D build (standard minus Samba server)"
406 @echo
"m M build (standard plus extra utilities)"
407 @echo
"..etc.. other build configs"
408 @echo
"clean -C router clean"
409 @echo
"cleanimage rm -rf image"
410 @echo
"cleantools clean btools, mksquashfs"
411 @echo
"cleankernel -C Linux distclean (but preserves .config)"
412 @echo
"distclean distclean of Linux & busybox (but preserve .configs)"
413 @echo
"prepk -C Linux oldconfig dep"
414 @echo
"libc -C uClibc clean, all, install"
416 .PHONY
: all clean distclean cleanimage cleantools cleankernel prepk what setprofile libc help
417 .PHONY
: a b c d m Makefile allversions tomato_profile.mak