]>
Commit | Line | Data |
---|---|---|
2d523c23 | 1 | # Makefile for buildroot2 |
ffde94bd | 2 | # |
15b26aee | 3 | # Copyright (C) 1999-2005 by Erik Andersen <[email protected]> |
ffde94bd | 4 | # |
08782ae7 | 5 | # This program is free software; you can redistribute it and/or modify |
2d523c23 EA |
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. | |
ffde94bd | 9 | # |
2d523c23 EA |
10 | # This program is distributed in the hope that it will be useful, |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
08782ae7 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2d523c23 | 13 | # General Public License for more details. |
ffde94bd | 14 | # |
2d523c23 EA |
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 | |
3ad3d8a1 | 18 | # |
02bf5816 | 19 | |
2d523c23 EA |
20 | #-------------------------------------------------------------- |
21 | # Just run 'make menuconfig', configure stuff, then run 'make'. | |
22 | # You shouldn't need to mess with anything beyond this point... | |
23 | #-------------------------------------------------------------- | |
24 | TOPDIR=./ | |
25 | CONFIG_CONFIG_IN = Config.in | |
26 | CONFIG_DEFCONFIG = .defconfig | |
27 | CONFIG = package/config | |
7def5559 | 28 | DATE:=$(shell date -u +%Y%m%d) |
a0aef7c4 | 29 | |
2d523c23 | 30 | noconfig_targets := menuconfig config oldconfig randconfig \ |
0c1e709e | 31 | defconfig allyesconfig allnoconfig release tags \ |
e491fba2 | 32 | source-check help |
9e250356 BRF |
33 | |
34 | # $(shell find . -name *_defconfig |sed 's/.*\///') | |
cad58108 | 35 | |
2d523c23 EA |
36 | # Pull in the user's configuration file |
37 | ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) | |
38 | -include $(TOPDIR).config | |
39 | endif | |
9741a49e | 40 | |
afc61c6e BRF |
41 | # To put more focus on warnings, be less verbose as default |
42 | # Use 'make V=1' to see the full commands | |
43 | ifdef V | |
44 | ifeq ("$(origin V)", "command line") | |
45 | KBUILD_VERBOSE = $(V) | |
46 | endif | |
47 | endif | |
48 | ifndef KBUILD_VERBOSE | |
49 | KBUILD_VERBOSE = 0 | |
50 | endif | |
51 | ||
52 | ifeq ($(KBUILD_VERBOSE),1) | |
4df454e9 | 53 | quiet= |
afc61c6e BRF |
54 | Q = |
55 | else | |
56 | quiet=quiet_ | |
57 | Q = @ | |
58 | endif | |
59 | ||
60 | CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ | |
61 | else if [ -x /bin/bash ]; then echo /bin/bash; \ | |
62 | else echo sh; fi ; fi) | |
63 | ||
64 | export CONFIG_SHELL quiet Q KBUILD_VERBOSE | |
65 | ||
66 | ifndef HOSTAR | |
67 | HOSTAR:=ar | |
68 | endif | |
69 | ifndef HOSTAS | |
70 | HOSTAS:=as | |
71 | endif | |
72 | ifndef HOSTCC | |
73 | HOSTCC:=gcc | |
74 | else | |
75 | endif | |
76 | ifndef HOSTCXX | |
77 | HOSTCXX:=g++ | |
78 | endif | |
79 | ifndef HOSTLD | |
80 | HOSTLD:=ld | |
81 | endif | |
0f9c5b11 US |
82 | ifndef HOSTLN |
83 | HOSTLN:=ln | |
84 | endif | |
83832cda US |
85 | HOSTAR :=$(shell $(CONFIG_SHELL) -c "which $(HOSTAR)" || type -p $(HOSTAR) || echo ar) |
86 | HOSTAS :=$(shell $(CONFIG_SHELL) -c "which $(HOSTAS)" || type -p $(HOSTAS) || echo as) | |
87 | HOSTCC :=$(shell $(CONFIG_SHELL) -c "which $(HOSTCC)" || type -p $(HOSTCC) || echo gcc) | |
88 | HOSTCXX:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCXX)" || type -p $(HOSTCXX) || echo g++) | |
89 | HOSTLD :=$(shell $(CONFIG_SHELL) -c "which $(HOSTLD)" || type -p $(HOSTLD) || echo ld) | |
0f9c5b11 | 90 | HOSTLN :=$(shell $(CONFIG_SHELL) -c "which $(HOSTLN)" || type -p $(HOSTLN) || echo ln) |
afc61c6e | 91 | ifndef CFLAGS_FOR_BUILD |
f987b7a5 | 92 | CFLAGS_FOR_BUILD:=-g -O2 |
afc61c6e BRF |
93 | endif |
94 | export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD | |
95 | ||
96 | ||
2d523c23 | 97 | ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y) |
54e098e4 | 98 | |
99cf7293 BRF |
99 | # cc-option |
100 | # Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586) | |
101 | # sets -march=winchip-c6 if supported else falls back to -march=i586 | |
102 | # without checking the latter. | |
103 | cc-option = $(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ | |
104 | > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) | |
105 | ||
2c649045 PK |
106 | ############################################################# |
107 | # | |
108 | # Hide troublesome environment variables from sub processes | |
109 | # | |
110 | ############################################################# | |
111 | unexport CROSS_COMPILE | |
112 | unexport ARCH | |
27bc59d4 | 113 | |
08782ae7 EA |
114 | ############################################################# |
115 | # | |
c6e43c9d | 116 | # Setup the proper filename extensions for the host |
08782ae7 | 117 | # |
7dcbbfbb BRF |
118 | ############################################################## |
119 | ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),) | |
c6e43c9d BRF |
120 | HOST_EXEEXT:= |
121 | HOST_LIBEXT:=.a | |
122 | HOST_SHREXT:=.so | |
3096f34d | 123 | endif |
7dcbbfbb | 124 | ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),) |
c6e43c9d BRF |
125 | HOST_EXEEXT:= |
126 | HOST_LIBEXT:=.a | |
127 | HOST_SHREXT:=.dylib | |
3096f34d | 128 | endif |
7dcbbfbb | 129 | ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),) |
c6e43c9d BRF |
130 | HOST_EXEEXT:=.exe |
131 | HOST_LIBEXT:=.lib | |
132 | HOST_SHREXT:=.dll | |
3096f34d | 133 | endif |
7dcbbfbb | 134 | ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),) |
c6e43c9d BRF |
135 | HOST_EXEEXT:=.exe |
136 | HOST_LIBEXT:=.lib | |
137 | HOST_SHREXT:=.dll | |
3096f34d | 138 | endif |
cb7d5b81 | 139 | |
c6e43c9d | 140 | # The preferred type of libs we build for the target |
3096f34d | 141 | ifeq ($(BR2_PREFER_STATIC_LIB),y) |
c6e43c9d | 142 | LIBTGTEXT=.a |
8027784c | 143 | #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static |
3096f34d | 144 | else |
c6e43c9d | 145 | LIBTGTEXT=.so |
8027784c | 146 | #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared |
3096f34d | 147 | endif |
8027784c | 148 | PREFERRED_LIB_FLAGS:=--enable-static --enable-shared |
ffde94bd | 149 | |
7dcbbfbb | 150 | |
7dcbbfbb BRF |
151 | ############################################################# |
152 | # | |
153 | # The list of stuff to build for the target toolchain | |
154 | # along with the packages to build for the target. | |
155 | # | |
156 | ############################################################## | |
157 | ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y) | |
158 | TARGETS:=uclibc-configured binutils gcc uclibc-target-utils | |
159 | else | |
160 | TARGETS:=uclibc | |
161 | endif | |
412ca2a4 | 162 | |
e0dd5309 BRF |
163 | PROJECT:=$(strip $(subst ",,$(BR2_PROJECT))) |
164 | #")) | |
165 | TARGET_HOSTNAME:=$(strip $(subst ",,$(BR2_HOSTNAME))) | |
166 | #")) | |
167 | BANNER:=$(strip $(subst ",,$(BR2_BANNER))) | |
168 | #")) | |
412ca2a4 US |
169 | |
170 | ||
7dcbbfbb BRF |
171 | include toolchain/Makefile.in |
172 | include package/Makefile.in | |
173 | ||
174 | ############################################################# | |
175 | # | |
176 | # You should probably leave this stuff alone unless you know | |
177 | # what you are doing. | |
178 | # | |
179 | ############################################################# | |
180 | ||
08782ae7 | 181 | all: world |
ffde94bd | 182 | |
2d523c23 EA |
183 | # In this section, we need .config |
184 | include .config.cmd | |
185 | ||
d06645d8 EA |
186 | # We also need the various per-package makefiles, which also add |
187 | # each selected package to TARGETS if that package was selected | |
188 | # in the .config file. | |
189 | include toolchain/*/*.mk | |
62b5ae4b SH |
190 | ifeq ($(BR2_PACKAGE_LINUX),y) |
191 | TARGETS+=linux26-modules | |
192 | endif | |
d06645d8 | 193 | include package/*/*.mk |
d06645d8 | 194 | |
79f5f1e8 EA |
195 | # target stuff is last so it can override anything else |
196 | include target/Makefile.in | |
197 | ||
08782ae7 | 198 | TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS)) |
a5c23541 | 199 | TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS)) |
08782ae7 | 200 | TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS)) |
ffde94bd | 201 | |
412ca2a4 US |
202 | world: $(DL_DIR) $(BUILD_DIR) $(PROJECT_BUILD_DIR) \ |
203 | $(BINARIES_DIR) $(STAGING_DIR) $(TARGET_DIR) bsp $(TARGETS) | |
204 | dirs: $(DL_DIR) $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(STAGING_DIR) | |
ffde94bd | 205 | |
412ca2a4 | 206 | .PHONY: all world dirs clean dirclean distclean source bsp $(TARGETS) \ |
747b16dd | 207 | $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \ |
412ca2a4 US |
208 | $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR) \ |
209 | $(PROJECT_BUILD_DIR) $(BINARIES_DIR) | |
ffde94bd | 210 | |
08782ae7 EA |
211 | ############################################################# |
212 | # | |
ef407d3d | 213 | # staging and target directories do NOT list these as |
d99c31c6 | 214 | # dependencies anywhere else |
08782ae7 EA |
215 | # |
216 | ############################################################# | |
412ca2a4 US |
217 | $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) \ |
218 | $(PROJECT_BUILD_DIR) $(BINARIES_DIR) : | |
8d583fc0 | 219 | @mkdir -p $@ |
3ad3d8a1 | 220 | |
08782ae7 | 221 | $(STAGING_DIR): |
9c865d75 | 222 | @mkdir -p $(STAGING_DIR)/bin |
bf38723f | 223 | @mkdir -p $(STAGING_DIR)/lib |
7e0c890c | 224 | ifeq ($(BR2_TOOLCHAIN_SYSROOT),y) |
8027784c BRF |
225 | @mkdir -p $(STAGING_DIR)/usr/lib |
226 | else | |
227 | @ln -snf . $(STAGING_DIR)/usr | |
228 | @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME) | |
3da708e4 | 229 | @ln -snf ../lib $(STAGING_DIR)/usr/lib |
8027784c BRF |
230 | @ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib |
231 | endif | |
232 | @mkdir -p $(STAGING_DIR)/usr/include | |
ffde94bd | 233 | |
08782ae7 | 234 | $(TARGET_DIR): |
a4c685f1 | 235 | mkdir -p $(TARGET_DIR) |
ba70f94e EA |
236 | if [ -d "$(TARGET_SKELETON)" ] ; then \ |
237 | cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \ | |
bb15c221 | 238 | fi; |
5418a923 | 239 | touch $(STAGING_DIR)/.fakeroot.00000 |
bb15c221 EA |
240 | -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf |
241 | -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf | |
08782ae7 | 242 | |
412ca2a4 US |
243 | bsp: $(TARGET_DIR)/etc/issue $(TARGET_DIR)/etc/hostname |
244 | ||
245 | $(TARGET_DIR)/etc/issue: $(TARGET_DIR) .config | |
246 | echo "" > $(TARGET_DIR)/etc/issue | |
247 | echo "" >> $(TARGET_DIR)/etc/issue | |
248 | echo "$(BANNER)" >> $(TARGET_DIR)/etc/issue | |
249 | ||
250 | $(TARGET_DIR)/etc/hostname: $(TARGET_DIR) .config | |
e327a1f0 | 251 | echo "$(TARGET_HOSTNAME)" > $(TARGET_DIR)/etc/hostname |
412ca2a4 | 252 | |
73be7f9e | 253 | source: $(TARGETS_SOURCE) $(HOST_SOURCE) |
08782ae7 | 254 | |
825ff341 BRF |
255 | .config.check: dependencies |
256 | $(SED) '/BR2_WGET/s/\"$$/ --spider\"/g' .config | |
257 | touch $@ | |
258 | ||
259 | _source-check: .config.check | |
260 | $(MAKE) source | |
261 | ||
08782ae7 EA |
262 | ############################################################# |
263 | # | |
264 | # Cleanup and misc junk | |
265 | # | |
266 | ############################################################# | |
267 | clean: $(TARGETS_CLEAN) | |
3ad3d8a1 | 268 | rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) |
08782ae7 EA |
269 | |
270 | dirclean: $(TARGETS_DIRCLEAN) | |
3ad3d8a1 | 271 | rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) |
08782ae7 EA |
272 | |
273 | distclean: | |
5bc1f0c3 MF |
274 | ifeq ($(DL_DIR),$(BASE_DIR)/dl) |
275 | rm -rf $(DL_DIR) | |
276 | endif | |
412ca2a4 US |
277 | rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR) \ |
278 | $(LINUX_KERNEL) $(IMAGE) $(BASE_DIR)/include \ | |
81df2264 | 279 | .config.cmd |
b5136193 | 280 | $(MAKE) -C $(CONFIG) clean |
08782ae7 | 281 | |
3ad3d8a1 | 282 | sourceball: |
412ca2a4 | 283 | rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR) |
08782ae7 EA |
284 | set -e; \ |
285 | cd ..; \ | |
286 | rm -f buildroot.tar.bz2; \ | |
287 | tar -cvf buildroot.tar buildroot; \ | |
288 | bzip2 -9 buildroot.tar; \ | |
2d523c23 EA |
289 | |
290 | ||
291 | else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y) | |
292 | ||
293 | all: menuconfig | |
294 | ||
295 | # configuration | |
296 | # --------------------------------------------------------------------------- | |
297 | ||
c0d7d4e0 BRF |
298 | HOSTCFLAGS=$(CFLAGS_FOR_BUILD) |
299 | export HOSTCFLAGS | |
300 | ||
2d523c23 | 301 | $(CONFIG)/conf: |
c0d7d4e0 | 302 | $(MAKE) CC="$(HOSTCC)" MAKECMDGOALS="$(MAKECMDGOALS)" \ |
afc61c6e | 303 | -C $(CONFIG) conf |
2d523c23 EA |
304 | -@if [ ! -f .config ] ; then \ |
305 | cp $(CONFIG_DEFCONFIG) .config; \ | |
306 | fi | |
307 | $(CONFIG)/mconf: | |
c0d7d4e0 | 308 | $(MAKE) CC="$(HOSTCC)" MAKECMDGOALS="$(MAKECMDGOALS)" \ |
afc61c6e | 309 | -C $(CONFIG) conf mconf |
2d523c23 EA |
310 | -@if [ ! -f .config ] ; then \ |
311 | cp $(CONFIG_DEFCONFIG) .config; \ | |
312 | fi | |
313 | ||
314 | menuconfig: $(CONFIG)/mconf | |
62b5ae4b SH |
315 | @-mkdir -p $(CONFIG)/buildroot-config |
316 | @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \ | |
317 | KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \ | |
f987b7a5 | 318 | $(CONFIG)/mconf $(CONFIG_CONFIG_IN) |
2d523c23 EA |
319 | |
320 | config: $(CONFIG)/conf | |
62b5ae4b SH |
321 | @-mkdir -p $(CONFIG)/buildroot-config |
322 | @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \ | |
323 | KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \ | |
f987b7a5 | 324 | $(CONFIG)/conf $(CONFIG_CONFIG_IN) |
2d523c23 EA |
325 | |
326 | oldconfig: $(CONFIG)/conf | |
62b5ae4b SH |
327 | @-mkdir -p $(CONFIG)/buildroot-config |
328 | @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \ | |
329 | KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \ | |
f987b7a5 | 330 | $(CONFIG)/conf -o $(CONFIG_CONFIG_IN) |
2d523c23 EA |
331 | |
332 | randconfig: $(CONFIG)/conf | |
62b5ae4b SH |
333 | @-mkdir -p $(CONFIG)/buildroot-config |
334 | @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \ | |
335 | KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \ | |
f987b7a5 | 336 | $(CONFIG)/conf -r $(CONFIG_CONFIG_IN) |
2d523c23 EA |
337 | |
338 | allyesconfig: $(CONFIG)/conf | |
f987b7a5 | 339 | cat $(CONFIG_DEFCONFIG) > .config |
62b5ae4b SH |
340 | @-mkdir -p $(CONFIG)/buildroot-config |
341 | @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \ | |
342 | KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \ | |
f987b7a5 | 343 | $(CONFIG)/conf -y $(CONFIG_CONFIG_IN) |
2d523c23 | 344 | #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config |
2d523c23 EA |
345 | |
346 | allnoconfig: $(CONFIG)/conf | |
62b5ae4b SH |
347 | @-mkdir -p $(CONFIG)/buildroot-config |
348 | @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \ | |
349 | KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \ | |
f987b7a5 | 350 | $(CONFIG)/conf -n $(CONFIG_CONFIG_IN) |
2d523c23 EA |
351 | |
352 | defconfig: $(CONFIG)/conf | |
62b5ae4b SH |
353 | @-mkdir -p $(CONFIG)/buildroot-config |
354 | @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \ | |
355 | KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \ | |
f987b7a5 | 356 | $(CONFIG)/conf -d $(CONFIG_CONFIG_IN) |
2d523c23 | 357 | |
825ff341 BRF |
358 | # check if download URLs are outdated |
359 | source-check: allyesconfig | |
360 | $(MAKE) _source-check | |
361 | ||
2d523c23 EA |
362 | ############################################################# |
363 | # | |
364 | # Cleanup and misc junk | |
365 | # | |
366 | ############################################################# | |
367 | clean: | |
368 | rm -f .config .config.old .config.cmd .tmpconfig.h | |
369 | - $(MAKE) -C $(CONFIG) clean | |
370 | ||
371 | distclean: clean | |
372 | rm -rf sources/* | |
373 | ||
374 | endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y) | |
375 | ||
ba2e7e02 BRF |
376 | %_defconfig: $(CONFIG)/conf |
377 | cp $(shell find ./target/ -name $@) .config | |
378 | @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN) | |
379 | ||
e491fba2 BRF |
380 | help: |
381 | @echo 'Cleaning:' | |
382 | @echo ' clean - delete temporary files created by build' | |
383 | @echo ' distclean - delete all non-source files (including .config)' | |
384 | @echo | |
385 | @echo 'Build:' | |
386 | @echo ' all - make world' | |
387 | @echo | |
388 | @echo 'Configuration:' | |
389 | @echo ' menuconfig - interactive curses-based configurator' | |
390 | @echo ' oldconfig - resolve any unresolved symbols in .config' | |
391 | @echo | |
392 | @echo 'Miscellaneous:' | |
393 | @echo ' source - download all sources needed for offline-build' | |
394 | @echo ' source-check - check all packages for valid download URLS' | |
395 | @echo | |
ba2e7e02 | 396 | |
2d523c23 | 397 | .PHONY: dummy subdirs release distclean clean config oldconfig \ |
e491fba2 | 398 | menuconfig tags check test depend defconfig help |
2d523c23 EA |
399 | |
400 |