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