1 # Makefile for buildroot2
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #--------------------------------------------------------------
22 # Just run 'make menuconfig', configure stuff, then run 'make'.
23 # You shouldn't need to mess with anything beyond this point...
24 #--------------------------------------------------------------
26 CONFIG_CONFIG_IN=Config.in
27 CONFIG_DEFCONFIG=.defconfig
29 DATE:=$(shell date +%Y%m%d)
31 noconfig_targets:=menuconfig config oldconfig randconfig \
32 defconfig allyesconfig allnoconfig release tags \
36 # Use shell variables, if defined
37 ifneq ($(BUILDROOT_LOCAL),)
38 BR2_LOCAL:=$(BUILDROOT_LOCAL)
40 BR2_LOCAL:=$(TOPDIR)/local
43 # Variables for use in Make constructs
46 space:=$(empty) $(empty)
48 # $(shell find . -name *_defconfig |sed 's/.*\///')
49 # Pull in the user's configuration file
50 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
52 # if "make BOARD=xyz" command
56 -include $(BR2_LOCAL)/$(BOARD)/$(BOARD).config
60 # Override BR2_DL_DIR if shell variable defined
61 ifneq ($(BUILDROOT_DL_DIR),)
62 BR2_DL_DIR:=$(BUILDROOT_DL_DIR)
66 # To put more focus on warnings, be less verbose as default
67 # Use 'make V=1' to see the full commands
69 ifeq ("$(origin V)", "command line")
77 ifeq ($(KBUILD_VERBOSE),1)
88 # we want bash as shell
89 SHELL:=$(shell if [ -x "$$BASH" ]; then echo $$BASH; \
90 else if [ -x /bin/bash ]; then echo /bin/bash; \
93 # kconfig uses CONFIG_SHELL
94 CONFIG_SHELL:=$(SHELL)
96 export SHELL CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
126 HOSTAR:=$(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
127 HOSTAS:=$(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
128 HOSTCC:=$(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
129 HOSTCXX:=$(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
130 HOSTFC:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran)
131 HOSTCPP:=$(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
132 HOSTLD:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
133 HOSTLN:=$(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
134 HOSTNM:=$(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
135 HOST_GLIB_BIN:=`dirname $(shell which glib-genmarshal || echo /usr/bin/glib-genmarshal)`
136 HOST_GLIB:=$(shell dirname $(HOST_GLIB_BIN) || echo /usr)
139 ifndef CFLAGS_FOR_BUILD
140 CFLAGS_FOR_BUILD:=-g -O2
142 ifndef CXXFLAGS_FOR_BUILD
143 CXXFLAGS_FOR_BUILD:=-g -O2
145 ifndef FCFLAGS_FOR_BUILD
146 FCFLAGS_FOR_BUILD:=-g -O2
148 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
151 ifeq ($(BR2_HAVE_DOT_CONFIG),y)
154 # Usage: cflags-y+=$(call cc-option, -march=winchip-c6, -march=i586)
155 # sets -march=winchip-c6 if supported else falls back to -march=i586
156 # without checking the latter.
157 cc-option=$(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
158 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
160 #############################################################
162 # Hide troublesome environment variables from sub processes
164 #############################################################
165 unexport CROSS_COMPILE
168 #############################################################
170 # Setup the proper filename extensions for the host
172 ##############################################################
173 ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
178 ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
183 ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
187 HOST_LOADLIBES="-lcurses -lintl"
188 export HOST_LOADLIBES
190 ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
196 # The preferred type of libs we build for the target
197 ifeq ($(BR2_PREFER_STATIC_LIB),y)
199 #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
202 #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
204 PREFERRED_LIB_FLAGS:=--enable-static --enable-shared
206 ##############################################################
208 # The list of stuff to build for the target toolchain
209 # along with the packages to build for the target.
211 ##############################################################
212 ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
213 BASE_TARGETS:=uclibc-configured binutils cross_compiler uclibc-target-utils kernel-headers
220 include project/Makefile.in
222 BR2_DEPENDS_DIR=$(PROJECT_BUILD_DIR)/buildroot-config
224 include toolchain/Makefile.in
225 include package/Makefile.in
227 #############################################################
229 # You should probably leave this stuff alone unless you know
230 # what you are doing.
232 #############################################################
236 # In this section, we need .config
241 # We also need the various per-package makefiles, which also add
242 # each selected package to TARGETS if that package was selected
243 # in the .config file.
244 ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
245 # avoid pulling in external toolchain which is broken for toplvl parallel builds
247 include toolchain/dependencies/dependencies.mk
248 include toolchain/binutils/binutils.mk
249 include toolchain/ccache/ccache.mk
250 include toolchain/elf2flt/elf2flt.mk
251 include toolchain/gcc/gcc-uclibc-3.x.mk
252 include toolchain/gcc/gcc-uclibc-4.x.mk
253 include toolchain/gdb/gdb.mk
254 include toolchain/kernel-headers/kernel-headers.mk
255 include toolchain/mklibs/mklibs.mk
256 include toolchain/sstrip/sstrip.mk
257 include toolchain/uClibc/uclibc.mk
259 include toolchain/*/*.mk
262 ifeq ($(BR2_PACKAGE_LINUX),y)
263 TARGETS+=linux26-modules
266 include package/*/*.mk
268 TARGETS+=target-devfiles
270 # target stuff is last so it can override anything else
271 include target/Makefile.in
273 TARGETS+=erase-fakeroots
275 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
276 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS) $(BASE_TARGETS))
277 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
278 TARGETS_ALL:=$(patsubst %,__real_tgt_%,$(TARGETS))
279 # all targets depend on the crosscompiler and it's prerequisites
280 $(TARGETS_ALL): __real_tgt_%: $(BASE_TARGETS) %
282 $(BR2_DEPENDS_DIR): .config
285 cp -dpRf $(CONFIG)/buildroot-config $@
287 dirs: $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
288 $(BR2_DEPENDS_DIR) $(BINARIES_DIR) $(PROJECT_BUILD_DIR) \
289 $(PROJECT_BUILD_DIR)/autotools-stamps
291 $(BASE_TARGETS): dirs
293 world: dependencies dirs target-host-info $(BASE_TARGETS) $(TARGETS_ALL)
296 .PHONY: all world dirs clean dirclean distclean source \
297 $(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
298 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
299 $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
300 $(BR2_DEPENDS_DIR) $(BINARIES_DIR) $(PROJECT_BUILD_DIR) \
301 $(PROJECT_BUILD_DIR)/autotools-stamps
303 #############################################################
305 # staging and target directories do NOT list these as
306 # dependencies anywhere else
308 #############################################################
309 $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(PROJECT_BUILD_DIR) \
310 $(PROJECT_BUILD_DIR)/autotools-stamps $(BINARIES_DIR):
314 @mkdir -p $(STAGING_DIR)/bin
315 @mkdir -p $(STAGING_DIR)/lib
316 ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
317 @mkdir -p $(STAGING_DIR)/usr/lib
319 ifneq ($(BR2_TOOLCHAIN_EXTERNAL),y)
320 @ln -snf . $(STAGING_DIR)/usr
321 @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)
322 @ln -snf ../lib $(STAGING_DIR)/usr/lib
323 @ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
326 @mkdir -p $(STAGING_DIR)/usr/include
328 $(PROJECT_BUILD_DIR)/.root:
329 mkdir -p $(TARGET_DIR)
330 if ! [ -d "$(TARGET_DIR)/bin" ]; then \
331 if [ -d "$(TARGET_SKELETON)" ]; then \
332 cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
334 touch $(STAGING_DIR)/.fakeroot.00000; \
336 -find $(TARGET_DIR) -type d -name CVS -o -name .svn | xargs rm -rf
337 -find $(TARGET_DIR) -type f -name .empty | xargs rm -rf
340 $(TARGET_DIR): $(PROJECT_BUILD_DIR)/.root
343 rm -f $(PROJECT_BUILD_DIR)/.fakeroot*
346 ifeq ($(BR2_HAVE_DEVFILES),y)
347 ( scripts/copy.sh $(STAGING_DIR) $(TARGET_DIR) )
349 rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/lib/pkgconfig
350 find $(TARGET_DIR)/usr/lib -name '*.a' -delete
351 find $(TARGET_DIR)/lib -name '*.a' -delete
352 find $(TARGET_DIR)/usr/lib -name '*.la' -delete
353 find $(TARGET_DIR)/lib -name '*.la' -delete
356 source: $(TARGETS_SOURCE) $(HOST_SOURCE)
359 $(MAKE) SPIDER=--spider source
362 @$(MAKE) -Bs BR2_WGET=$(TOPDIR)/toolchain/wget-show-external-deps.sh \
363 SPIDER=--spider source
365 #############################################################
367 # Cleanup and misc junk
369 #############################################################
370 clean: $(TARGETS_CLEAN)
371 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) $(PROJECT_BUILD_DIR)/.root $(PROJECT_BUILD_DIR)/autotools-stamps
373 dirclean: $(TARGETS_DIRCLEAN)
374 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) $(PROJECT_BUILD_DIR)/.root $(PROJECT_BUILD_DIR)/autotools-stamps
377 ifeq ($(DL_DIR),$(BASE_DIR)/dl)
380 rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR) \
381 $(LINUX_KERNEL) $(BASE_DIR)/include \
383 $(MAKE) -C $(CONFIG) clean
386 rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR)
389 rm -f buildroot.tar.bz2; \
390 tar -cvf buildroot.tar buildroot; \
391 bzip2 -9 buildroot.tar; \
394 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
399 # ---------------------------------------------------------------------------
401 HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
405 @mkdir -p $(CONFIG)/buildroot-config
406 $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf
407 -@if [ ! -f .config ]; then \
408 cp $(CONFIG_DEFCONFIG) .config; \
411 @mkdir -p $(CONFIG)/buildroot-config
412 $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf mconf
413 -@if [ ! -f .config ]; then \
414 cp $(CONFIG_DEFCONFIG) .config; \
417 menuconfig: $(CONFIG)/mconf
418 @mkdir -p $(CONFIG)/buildroot-config
419 @if ! KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
420 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
421 $(CONFIG)/mconf $(CONFIG_CONFIG_IN); then \
422 test -f .config.cmd || rm -f .config; \
425 config: $(CONFIG)/conf
426 @mkdir -p $(CONFIG)/buildroot-config
427 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
428 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
429 $(CONFIG)/conf $(CONFIG_CONFIG_IN)
431 oldconfig: $(CONFIG)/conf
432 @mkdir -p $(CONFIG)/buildroot-config
433 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
434 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
435 $(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
437 randconfig: $(CONFIG)/conf
438 @mkdir -p $(CONFIG)/buildroot-config
439 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
440 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
441 $(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
443 allyesconfig: $(CONFIG)/conf
444 cat $(CONFIG_DEFCONFIG) > .config
445 @mkdir -p $(CONFIG)/buildroot-config
446 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
447 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
448 $(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
449 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
451 allnoconfig: $(CONFIG)/conf
452 @mkdir -p $(CONFIG)/buildroot-config
453 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
454 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
455 $(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
457 defconfig: $(CONFIG)/conf
458 @mkdir -p $(CONFIG)/buildroot-config
459 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
460 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
461 $(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
463 # check if download URLs are outdated
464 source-check: allyesconfig
465 $(MAKE) _source-check
467 #############################################################
469 # Cleanup and misc junk
471 #############################################################
473 rm -f .config .config.old .config.cmd .tmpconfig.h .lognr.*
474 -$(MAKE) -C $(CONFIG) clean
479 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
481 %_defconfig: $(CONFIG)/conf
482 cp $(shell find ./target/ -name $@) .config
486 cp .config $(BOARD_PATH)/$(BOARD_NAME)_defconfig
488 configured: dirs host-sed kernel-headers uclibc-config busybox-config linux26-config
490 prepatch: gcc-patched binutils-patched gdb-patched uclibc-patched
493 @echo "0" > .lognr.$(PROJECT)
495 log: .lognr.$(PROJECT)
496 @expr `cat .lognr.$(PROJECT)` + 1 > .lognr.$(PROJECT)
497 @echo Creating $(PROJECT)-`cat .lognr.$(PROJECT)`.log
498 @$(MAKE) > $(PROJECT)-`cat .lognr.$(PROJECT)`.log 2>&1
501 cross: $(BASE_TARGETS)
505 @echo ' clean - delete temporary files created by build'
506 @echo ' distclean - delete all non-source files (including .config)'
509 @echo ' all - make world'
511 @echo 'Configuration:'
512 @echo ' menuconfig - interactive curses-based configurator'
513 @echo ' oldconfig - resolve any unresolved symbols in .config'
514 @echo ' configured - make {uclibc/busybox/linux26}-config'
515 @echo ' saveconfig - save current configuration under local/<project>'
516 @echo ' getconfig - restore saved configuration from local/<project>'
518 @echo 'Miscellaneous:'
519 @echo ' source - download all sources needed for offline-build'
520 @echo ' source-check - check all packages for valid download URLs'
521 @echo ' external-deps - list external packages used'
523 @echo 'See docs/README and docs/buildroot.html for further details'
527 OUT=buildroot-$$(grep -A2 BR2_VERSION $(CONFIG_CONFIG_IN)|grep default|cut -f2 -d\"); \
528 rm -rf ../$$OUT*; cp -al . ../$$OUT; cd ..; \
529 tar cfz $$OUT.tar.gz --exclude .svn --exclude .git --exclude \*~ $$OUT; \
532 .PHONY: dummy subdirs release distclean clean config oldconfig \
533 menuconfig tags check test depend defconfig help