Merge branch 'tomato-ND-usbmod-vpn' into tomato-ND-USBmod
[tomato.git] / release / src / Makefile
blob29a303a1108bbd30c91ecfbe50ef23670a939c9f
2 # Toplevel Makefile for the BCM947xx Linux Router release
4 # Copyright 2005, Broadcom Corporation
5 # All Rights Reserved.
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:
18 # make distclean
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.
24 # Example:
25 # make V1=8516 V2=".jffs.1" a b c d m
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 a b c d"
37 # But if you don't give anything for "V1", it'll get a default of "0000".
38 V1 ?= "0000"
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))
49 uppercase_N = $(shell echo $(N) | tr a-z A-Z)
50 lowercase_N = $(shell echo $(N) | tr A-Z a-z)
51 uppercase_B = $(shell echo $(B) | tr a-z A-Z)
52 lowercase_B = $(shell echo $(B) | tr A-Z a-z)
55 ifeq ($(TOMATO_BUILD),)
57 all:
58 $(MAKE) libc
59 $(MAKE) a
61 else
63 all:
64 @echo -e "\n\nBuilding USB-$(V1)$(V2) $(current_BUILD_DESC) $(current_BUILD_NAME) with $(TOMATO_PROFILE_NAME) Profile"
65 @echo -n "1.23."$(V1)$(V2)" ND USB "$(current_BUILD_DESC) > router/shared/tomato_version
66 @btools/uversion.pl --gen
67 @echo -e "\n\n"
69 @-mkdir image
70 @$(MAKE) -C router all
71 @$(MAKE) -C router install
72 @$(MAKE) -C btools
74 @rm -f image/tomato-ND-USB-$(V1)$(V2)-$(current_BUILD_DESC).trx
75 @echo -e "\n\n***********************" `date` "************************" >>fpkg.log
76 @cat router/shared/tomato_version >>fpkg.log
77 @echo "" >>fpkg.log
78 @cat router/target.info >>fpkg.log
79 ifeq ($(wildcard include/bcm20xx.h),)
80 @btools/fpkg -i linux/linux/arch/mips/brcm-boards/bcm947xx/compressed/vmlinuz -i router/mipsel-uclibc/target.image \
81 -t image/tomato.trx \
82 -l W54G,image/WRT54G_WRT54GL.bin \
83 -l W54S,image/WRT54GS.bin \
84 -l W54s,image/WRT54GSv4.bin \
85 -l W54U,image/WRTSL54GS.bin \
86 -m 0x10577050,image/WR850G.bin \
87 | tee -a fpkg.log
88 else
89 @btools/fpkg -i linux/linux/arch/mips/brcm-boards/bcm947xx/compressed/vmlinuz -i router/mipsel-uclibc/target.image \
90 -t image/tomato-ND-USB-$(V1)$(V2)-$(current_BUILD_DESC).trx | tee -a fpkg.log
91 endif
92 @cp fpkg.log image/fpkg-$(V1)$(V2).log
93 @echo -e "\n-----------------\n" `cat router/shared/tomato_version` " ready\n-----------------"
94 ifneq ($(NOVERSION),1)
95 @cp router/shared/tomato_version router/shared/tomato_version_last
96 @btools/uversion.pl --bump
97 endif
98 endif
102 clean:
103 @touch router/.config
104 @rm -f router/config_[a-z]
105 @rm -f router/busybox/config_[a-z]
106 @$(MAKE) -C router $@
107 @-rmdir router/mipsel-uclibc
109 cleanimage:
110 @rm -f fpkg.log
111 @rm -fr image/*
112 @rm -f router/.config
113 @touch router/.config
114 @-mkdir image
116 cleantools:
117 @$(MAKE) -C linux/linux/scripts/squashfs clean
118 @$(MAKE) -C btools clean
120 cleankernel:
121 @cd linux/linux && \
122 mv .config save-config && \
123 $(MAKE) distclean; \
124 cp -p save-config .config
126 distclean: clean cleanimage cleankernel cleantools cleanlibc
127 ifneq ($(INSIDE_MAK),1)
128 @$(MAKE) -C router $@ INSIDE_MAK=1
129 endif
130 mv router/busybox/.config busybox-saved-config
131 @$(MAKE) -C router/busybox distclean
132 @rm -f router/busybox/config_current || true
133 @cp -p busybox-saved-config router/busybox/.config
134 @cp -p router/busybox/.config router/busybox/config_current
135 @rm -f router/config_current || true
136 @rm -f router/.config.cmd router/.config.old router/.config
137 @rm -f router/libfoo_xref.txt
138 @rm -f tomato_profile.mak router/shared/tomato_profile.h
139 @touch tomato_profile.mak
140 @touch router/shared/tomato_profile.h
143 prepk:
144 $(MAKE) -C linux/linux oldconfig dep
146 what:
147 @echo -e "\n$(current_BUILD_DESC)-$(current_BUILD_NAME)-$(TOMATO_PROFILE_NAME) Profile\n"
150 # The methodology for making the different builds is to
151 # copy the "base" config file to the "target" config file in
152 # the appropriate directory, and then edit it by removing and
153 # inserting the desired configuration lines.
154 # You can't just delete the "whatever=y" line, you must have
155 # a "...is not set" line, or the make oldconfig will stop and ask
156 # what to do.
158 ## Make the "normal" build
160 @cp router/config_base router/config_$@
161 @cp router/busybox/config_base router/busybox/config_$@
162 @$(MAKE) setprofile N=G B=A DESC="Std"
163 @$(MAKE) all
166 ## Make the "normal but without SSH" build
168 @cp router/config_base router/config_$@
169 @sed -i "/TCONFIG_SSH/d" router/config_$@
170 @echo "# TCONFIG_SSH is not set" >>router/config_$@
171 @cp router/busybox/config_base router/busybox/config_$@
172 @$(MAKE) setprofile N=G B=B DESC="No SSH"
173 @$(MAKE) all
175 ## Make the "normal but without cifs" build
177 @cp router/config_base router/config_$@
178 @sed -i "/TCONFIG_CIFS/d" router/config_$@
179 @echo "# TCONFIG_CIFS is not set" >>router/config_$@
180 @cp router/busybox/config_base router/busybox/config_$@
181 @$(MAKE) setprofile N=G B=C DESC="No CIFS"
182 @$(MAKE) all
184 ## Make the "normal but without SAMBA" build
186 @cp router/config_base router/config_$@
187 @sed -i "/TCONFIG_SAMBASRV/d" router/config_$@
188 @echo "# TCONFIG_SAMBASRV is not set" >>router/config_$@
189 @cp router/busybox/config_base router/busybox/config_$@
190 @sed -i "/CONFIG_FEATURE_MOUNT_LOOP/d" router/busybox/config_$@
191 @echo "# CONFIG_FEATURE_MOUNT_LOOP is not set" >>router/busybox/config_$@
192 @sed -i "/CONFIG_FEATURE_DEVFS/d" router/busybox/config_$@
193 @echo "# CONFIG_FEATURE_DEVFS is not set" >>router/busybox/config_$@
194 @sed -i "/CONFIG_ARPING/d" router/busybox/config_$@
195 @echo "# CONFIG_ARPING is not set" >>router/busybox/config_$@
196 @$(MAKE) setprofile N=G B=D DESC="Lite"
197 @$(MAKE) all
199 ## Make the "normal + VPN" build
201 @cp router/config_base router/config_$@
202 @sed -i "/TCONFIG_LZO/d" router/config_$@
203 @sed -i "/TCONFIG_OPENVPN/d" router/config_$@
204 @echo "TCONFIG_LZO=y" >>router/config_$@
205 @echo "TCONFIG_OPENVPN=y" >>router/config_$@
206 @cp router/busybox/config_base router/busybox/config_$@
207 @$(MAKE) setprofile N=G B=E DESC="VPN"
208 @$(MAKE) all
210 ## Make the "normal with Extras" build
212 @cp router/config_base router/config_$@
213 @sed -i "/TCONFIG_USB_EXTRAS/d" router/config_$@
214 @echo "TCONFIG_USB_EXTRAS=y" >>router/config_$@
215 @cp router/busybox/config_base router/busybox/config_$@
216 @sed -i "/CONFIG_UNZIP/d" router/busybox/config_$@
217 @echo "CONFIG_UNZIP=y" >>router/busybox/config_$@
218 @sed -i "/CONFIG_AWK/d" router/busybox/config_$@
219 @echo "CONFIG_AWK=y" >>router/busybox/config_$@
220 @sed -i "/CONFIG_FEATURE_AWK_MATH/d" router/busybox/config_$@
221 @echo "CONFIG_FEATURE_AWK_MATH=y" >>router/busybox/config_$@
222 @sed -i "/CONFIG_FEATURE_LS_COLOR/d" router/busybox/config_$@
223 @echo "CONFIG_FEATURE_LS_COLOR=y" >>router/busybox/config_$@
224 @sed -i "/CONFIG_FEATURE_LS_COLOR_IS_DEFAULT/d" router/busybox/config_$@
225 @echo "CONFIG_FEATURE_LS_COLOR_IS_DEFAULT=y" >>router/busybox/config_$@
226 @sed -i "/CONFIG_FEATURE_SORT_BIG/d" router/busybox/config_$@
227 @echo "CONFIG_FEATURE_SORT_BIG=y" >>router/busybox/config_$@
228 @sed -i "/CONFIG_E2FSCK/d" router/busybox/config_$@
229 @echo "CONFIG_E2FSCK=y" >>router/busybox/config_$@
230 @sed -i "/CONFIG_MKE2FS/d" router/busybox/config_$@
231 @echo "CONFIG_MKE2FS=y" >>router/busybox/config_$@
232 @sed -i "/CONFIG_FDISK/d" router/busybox/config_$@
233 @echo "CONFIG_FDISK=y" >>router/busybox/config_$@
234 @sed -i "/CONFIG_FEATURE_FDISK_WRITABLE/d" router/busybox/config_$@
235 @echo "CONFIG_FEATURE_FDISK_WRITABLE=y" >>router/busybox/config_$@
236 @sed -i "/CONFIG_MKSWAP/d" router/busybox/config_$@
237 @echo "CONFIG_MKSWAP=y" >>router/busybox/config_$@
238 @$(MAKE) setprofile N=G B=M DESC="Ext"
239 @$(MAKE) all
241 setprofile:
242 @echo -e "\
243 #ifndef TOMATO_PROFILE\n\
244 #define TOMATO_$(N) 1\n\
245 #define PROFILE_G 1\n\
246 #define PROFILE_N 2\n\
247 #define TOMATO_PROFILE PROFILE_$(N)\n\
248 #define TOMATO_PROFILE_NAME \"$(N)\"\n\
249 #define TOMATO_BUILD_NAME \"$(B)\"\n\
250 #define TOMATO_BUILD_DESC \"$(DESC)\"\n\
251 #endif\n" > router/shared/tomato_profile.h
253 @echo -e "\
254 TOMATO_$(N) = 1\n\
255 PROFILE_G = 1\n\
256 PROFILE_N = 2\n\
257 TOMATO_PROFILE = \$$(PROFILE_$(N))\n\
258 TOMATO_PROFILE_NAME = \"$(N)\"\n\
259 TOMATO_BUILD = \"$(B)\"\n\
260 TOMATO_BUILD_NAME = \"$(B)\"\n\
261 TOMATO_BUILD_DESC = \"$(DESC)\"\n\
262 TOMATO_PROFILE_L = $(lowercase_N)\n\
263 TOMATO_PROFILE_U = $(uppercase_N)\n" > tomato_profile.mak
265 # Note that changes to variables in tomato_profile.mak don't
266 # get propogated to this invocation of make!
268 @cd router ; \
269 rm -f config_current ; \
270 ln -s config_$(lowercase_B) config_current ; \
271 cp config_current .config
272 @$(MAKE) -C router oldconfig
274 @cd router/busybox && \
275 rm -f config_current ; \
276 ln -s config_$(lowercase_B) config_current ; \
277 cp config_current .config
278 @$(MAKE) -C router/busybox oldconfig
280 @echo -e "\nUsing $(N) profile, $(B) build config.\n"
282 cleanlibc:
283 @$(MAKE) -C ../../tools-src/uClibc clean
285 libc: cleanlibc
286 @$(MAKE) -C ../../tools-src/uClibc
287 @$(MAKE) -C ../../tools-src/uClibc install
289 help:
290 @echo "a A build (standard)"
291 @echo "b B build (standard minus SSH)"
292 @echo "c C build (standard minus cifs)"
293 @echo "d D build (standard minus Samba server)"
294 @echo "m M build (standard plus extra utilities)"
295 @echo "..etc.. other build configs"
296 @echo "clean -C router clean"
297 @echo "cleanimage rm -rf image"
298 @echo "cleantools clean btools, mksquashfs"
299 @echo "cleankernel -C linux/linux distclean (but preserves .config)"
300 @echo "distclean distclean of Linux & busybox (but preserve .configs)"
301 @echo "prepk -C linux/linux oldconfig dep"
302 @echo "libc -C uClibc clean, all, install"
304 .PHONY: all clean distclean cleanimage cleantools cleankernel prepk what setprofile libc help
305 .PHONY: a b c d m Makefile allversions tomato_profile.mak