add temporary workaround for PR34668
[buildroot.git] / Makefile
blob10888b8668789b4e5fdb303661926994a4eecc9e
1 # Makefile for buildroot2
3 # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
5 # This program is free software; you can redistribute it and/or modify
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.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
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
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
28 DATE:=$(shell date -u +%Y%m%d)
30 noconfig_targets:=menuconfig config oldconfig randconfig \
31 defconfig allyesconfig allnoconfig release tags \
32 source-check help
34 # $(shell find . -name *_defconfig |sed 's/.*\///')
36 # Pull in the user's configuration file
37 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
38 ifeq ($(BOARD),)
39 -include $(TOPDIR).config
40 else
41 -include $(TOPDIR)/local/$(BOARD)/$(BOARD).config
42 endif
43 endif
44 ifneq ($(BUILDROOT_DL_DIR),)
45 BR2_DL_DIR:=$(BUILDROOT_DL_DIR)
46 endif
47 ifneq ($(BUILDROOT_LOCAL),)
48 LOCAL:=$(BUILDROOT_LOCAL)
49 else
50 LOCAL:=local
51 endif
53 # To put more focus on warnings, be less verbose as default
54 # Use 'make V=1' to see the full commands
55 ifdef V
56 ifeq ("$(origin V)", "command line")
57 KBUILD_VERBOSE=$(V)
58 endif
59 endif
60 ifndef KBUILD_VERBOSE
61 KBUILD_VERBOSE=0
62 endif
64 ifeq ($(KBUILD_VERBOSE),1)
65 quiet=
67 ifndef VERBOSE
68 VERBOSE=1
69 endif
70 else
71 quiet=quiet_
72 Q=@
73 endif
75 CONFIG_SHELL:=$(shell if [ -x "$$BASH" ]; then echo $$BASH; \
76 else if [ -x /bin/bash ]; then echo /bin/bash; \
77 else echo sh; fi; fi)
79 export CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
81 ifndef HOSTAR
82 HOSTAR:=ar
83 endif
84 ifndef HOSTAS
85 HOSTAS:=as
86 endif
87 ifndef HOSTCC
88 HOSTCC:=gcc
89 else
90 endif
91 ifndef HOSTCXX
92 HOSTCXX:=g++
93 endif
94 ifndef HOSTFC
95 HOSTFC:=gfortran
96 endif
97 ifndef HOSTCPP
98 HOSTCPP:=cpp
99 endif
100 ifndef HOSTLD
101 HOSTLD:=ld
102 endif
103 ifndef HOSTLN
104 HOSTLN:=ln
105 endif
106 ifndef HOSTNM
107 HOSTNM:=nm
108 endif
109 HOSTAR:=$(shell $(CONFIG_SHELL) -c "which $(HOSTAR)" || type -p $(HOSTAR) || echo ar)
110 HOSTAS:=$(shell $(CONFIG_SHELL) -c "which $(HOSTAS)" || type -p $(HOSTAS) || echo as)
111 HOSTCC:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCC)" || type -p $(HOSTCC) || echo gcc)
112 HOSTCXX:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCXX)" || type -p $(HOSTCXX) || echo g++)
113 HOSTFC:=$(shell $(CONFIG_SHELL) -c "which $(HOSTLD)" || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran)
114 HOSTCPP:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCPP)" || type -p $(HOSTCPP) || echo cpp)
115 HOSTLD:=$(shell $(CONFIG_SHELL) -c "which $(HOSTLD)" || type -p $(HOSTLD) || echo ld)
116 HOSTLN:=$(shell $(CONFIG_SHELL) -c "which $(HOSTLN)" || type -p $(HOSTLN) || echo ln)
117 HOSTNM:=$(shell $(CONFIG_SHELL) -c "which $(HOSTNM)" || type -p $(HOSTNM) || echo nm)
118 ifndef CFLAGS_FOR_BUILD
119 CFLAGS_FOR_BUILD:=-g -O2
120 endif
121 ifndef CXXFLAGS_FOR_BUILD
122 CXXFLAGS_FOR_BUILD:=-g -O2
123 endif
124 ifndef FCFLAGS_FOR_BUILD
125 FCFLAGS_FOR_BUILD:=-g -O2
126 endif
127 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
130 ifeq ($(BR2_HAVE_DOT_CONFIG),y)
132 # cc-option
133 # Usage: cflags-y+=$(call cc-option, -march=winchip-c6, -march=i586)
134 # sets -march=winchip-c6 if supported else falls back to -march=i586
135 # without checking the latter.
136 cc-option=$(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
137 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
139 #############################################################
141 # Hide troublesome environment variables from sub processes
143 #############################################################
144 unexport CROSS_COMPILE
145 unexport ARCH
147 #############################################################
149 # Setup the proper filename extensions for the host
151 ##############################################################
152 ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
153 HOST_EXEEXT:=
154 HOST_LIBEXT:=.a
155 HOST_SHREXT:=.so
156 endif
157 ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
158 HOST_EXEEXT:=
159 HOST_LIBEXT:=.a
160 HOST_SHREXT:=.dylib
161 endif
162 ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
163 HOST_EXEEXT:=.exe
164 HOST_LIBEXT:=.lib
165 HOST_SHREXT:=.dll
166 HOST_LOADLIBES="-lcurses -lintl"
167 export HOST_LOADLIBES
168 endif
169 ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
170 HOST_EXEEXT:=.exe
171 HOST_LIBEXT:=.lib
172 HOST_SHREXT:=.dll
173 endif
175 # The preferred type of libs we build for the target
176 ifeq ($(BR2_PREFER_STATIC_LIB),y)
177 LIBTGTEXT=.a
178 #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
179 else
180 LIBTGTEXT=.so
181 #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
182 endif
183 PREFERRED_LIB_FLAGS:=--enable-static --enable-shared
185 ##############################################################
187 # The list of stuff to build for the target toolchain
188 # along with the packages to build for the target.
190 ##############################################################
191 ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
192 BASE_TARGETS:=uclibc-configured binutils cross_compiler uclibc-target-utils
193 else
194 BASE_TARGETS:=uclibc
195 endif
196 TARGETS:=
198 # setup our paths
199 include project/Makefile.in
201 BR2_DEPENDS_DIR=$(PROJECT_BUILD_DIR)/buildroot-config
203 include toolchain/Makefile.in
204 include package/Makefile.in
206 #############################################################
208 # You should probably leave this stuff alone unless you know
209 # what you are doing.
211 #############################################################
213 all: world
215 # In this section, we need .config
216 include .config.cmd
218 include project/*.mk
220 # We also need the various per-package makefiles, which also add
221 # each selected package to TARGETS if that package was selected
222 # in the .config file.
223 ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
224 # avoid pulling in external toolchain which is broken for toplvl parallel builds
225 # Explicit ordering:
226 include toolchain/dependencies/dependencies.mk
227 include toolchain/binutils/binutils.mk
228 include toolchain/ccache/ccache.mk
229 include toolchain/elf2flt/elf2flt.mk
230 include toolchain/gcc/gcc-uclibc-3.x.mk
231 include toolchain/gcc/gcc-uclibc-4.x.mk
232 include toolchain/gdb/gdb.mk
233 include toolchain/kernel-headers/kernel-headers.mk
234 include toolchain/mklibs/mklibs.mk
235 include toolchain/sstrip/sstrip.mk
236 include toolchain/uClibc/uclibc.mk
237 else
238 include toolchain/*/*.mk
239 endif
241 ifeq ($(BR2_PACKAGE_LINUX),y)
242 TARGETS+=linux26-modules
243 endif
245 include package/*/*.mk
247 # target stuff is last so it can override anything else
248 include target/Makefile.in
250 TARGETS+=erase-fakeroots
252 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
253 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS) $(BASE_TARGETS))
254 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
255 TARGETS_ALL:=$(patsubst %,__real_tgt_%,$(TARGETS))
256 # all targets depend on the crosscompiler and it's prerequisites
257 $(TARGETS_ALL): __real_tgt_%: $(BASE_TARGETS) %
259 $(BR2_DEPENDS_DIR): .config
260 rm -rf $@
261 mkdir -p $(@D)
262 cp -dpRf $(CONFIG)/buildroot-config $@
264 dirs: $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
265 $(BR2_DEPENDS_DIR) \
266 $(BINARIES_DIR) $(PROJECT_BUILD_DIR)
268 $(BASE_TARGETS): dirs
270 world: dependencies dirs target-host-info $(BASE_TARGETS) $(TARGETS_ALL)
273 .PHONY: all world dirs clean dirclean distclean source \
274 $(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
275 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
276 $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
277 $(BR2_DEPENDS_DIR) \
278 $(BINARIES_DIR) $(PROJECT_BUILD_DIR)
280 #############################################################
282 # staging and target directories do NOT list these as
283 # dependencies anywhere else
285 #############################################################
286 $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) \
287 $(PROJECT_BUILD_DIR) $(BINARIES_DIR):
288 @mkdir -p $@
290 $(STAGING_DIR):
291 @mkdir -p $(STAGING_DIR)/bin
292 @mkdir -p $(STAGING_DIR)/lib
293 ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
294 @mkdir -p $(STAGING_DIR)/usr/lib
295 else
296 @if test ! -L $(STAGING_DIR)/usr && test -d $(STAGING_DIR)/usr; then \
297 echo "You seem to be coming from a toolchain with sysroot support."; \
298 echo "Reconfiguring without wiping your rootfs will not work, sorry.";\
299 echo "Please 'rm -rf $(STAGING_DIR)'"; \
300 echo "Then run 'make' again."; \
301 echo ""; \
302 exit 1; \
304 ln -snf . $(STAGING_DIR)/usr
305 @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)
306 ln -snf ../lib $(STAGING_DIR)/usr/lib
307 ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
308 endif
309 @mkdir -p $(STAGING_DIR)/usr/include
311 $(PROJECT_BUILD_DIR)/.root:
312 mkdir -p $(TARGET_DIR)
313 if ! [ -d "$(TARGET_DIR)/bin" ]; then \
314 if [ -d "$(TARGET_SKELETON)" ]; then \
315 cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
316 fi; \
317 touch $(STAGING_DIR)/.fakeroot.00000; \
319 -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf
320 -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf
321 -find $(TARGET_DIR) -type d -name .gitignore | xargs rm -rf
322 touch $@
324 $(TARGET_DIR): $(PROJECT_BUILD_DIR)/.root
326 erase-fakeroots:
327 rm -f $(PROJECT_BUILD_DIR)/.fakeroot*
329 source: $(TARGETS_SOURCE) $(HOST_SOURCE)
331 _source-check:
332 $(MAKE) SPIDER=--spider source
334 #############################################################
336 # Cleanup and misc junk
338 #############################################################
339 clean: $(TARGETS_CLEAN)
340 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
342 dirclean: $(TARGETS_DIRCLEAN)
343 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
345 distclean:
346 ifeq ($(DL_DIR),$(BASE_DIR)/dl)
347 rm -rf $(DL_DIR)
348 endif
349 rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR) \
350 $(LINUX_KERNEL) $(IMAGE) $(BASE_DIR)/include \
351 .config* .auto.deps
352 $(MAKE) -C $(CONFIG) clean distclean
354 sourceball:
355 rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR)
356 set -e; \
357 cd ..; \
358 rm -f buildroot.tar.bz2; \
359 tar -cvf buildroot.tar buildroot; \
360 bzip2 -9 buildroot.tar; \
363 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
365 all: menuconfig
367 # configuration
368 # ---------------------------------------------------------------------------
370 HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
371 export HOSTCFLAGS
373 $(CONFIG)/conf:
374 @mkdir -p $(CONFIG)/buildroot-config
375 $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf
376 -@if [ ! -f .config ]; then \
377 cp $(CONFIG_DEFCONFIG) .config; \
379 $(CONFIG)/mconf:
380 @mkdir -p $(CONFIG)/buildroot-config
381 $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf mconf
382 -@if [ ! -f .config ]; then \
383 cp $(CONFIG_DEFCONFIG) .config; \
386 menuconfig: $(CONFIG)/mconf
387 @mkdir -p $(CONFIG)/buildroot-config
388 @if ! KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
389 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
390 $(CONFIG)/mconf $(CONFIG_CONFIG_IN); then \
391 test -f .config.cmd || rm -f .config; \
394 config: $(CONFIG)/conf
395 @mkdir -p $(CONFIG)/buildroot-config
396 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
397 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
398 $(CONFIG)/conf $(CONFIG_CONFIG_IN)
400 oldconfig: $(CONFIG)/conf
401 @mkdir -p $(CONFIG)/buildroot-config
402 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
403 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
404 $(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
406 randconfig: $(CONFIG)/conf
407 @mkdir -p $(CONFIG)/buildroot-config
408 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
409 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
410 $(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
412 allyesconfig: $(CONFIG)/conf
413 cat $(CONFIG_DEFCONFIG) > .config
414 @mkdir -p $(CONFIG)/buildroot-config
415 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
416 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
417 $(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
418 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
420 allnoconfig: $(CONFIG)/conf
421 @mkdir -p $(CONFIG)/buildroot-config
422 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
423 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
424 $(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
426 defconfig: $(CONFIG)/conf
427 @mkdir -p $(CONFIG)/buildroot-config
428 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
429 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
430 $(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
432 # check if download URLs are outdated
433 source-check: allyesconfig
434 $(MAKE) _source-check
436 #############################################################
438 # Cleanup and misc junk
440 #############################################################
441 clean:
442 rm -f .config .config.old .config.cmd .tmpconfig.h
443 -$(MAKE) -C $(CONFIG) clean
445 distclean: clean
446 rm -rf sources/*
448 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
450 %_defconfig: $(CONFIG)/conf
451 cp $(shell find ./target/ -name $@) .config
452 -@$(MAKE) oldconfig
454 configured: dirs host-sed kernel-headers uclibc-config busybox-config linux26-config
456 cross: $(BASE_TARGETS)
458 help:
459 @echo 'Cleaning:'
460 @echo ' clean - delete temporary files created by build'
461 @echo ' distclean - delete all non-source files (including .config)'
462 @echo
463 @echo 'Build:'
464 @echo ' all - make world'
465 @echo
466 @echo 'Configuration:'
467 @echo ' menuconfig - interactive curses-based configurator'
468 @echo ' oldconfig - resolve any unresolved symbols in .config'
469 @echo
470 @echo 'Miscellaneous:'
471 @echo ' source - download all sources needed for offline-build'
472 @echo ' source-check - check all packages for valid download URLs'
473 @echo
474 @echo 'See docs/README and docs/buildroot.html for further details'
475 @echo
477 .PHONY: dummy subdirs release distclean clean config oldconfig \
478 menuconfig tags check test depend defconfig help