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 # $(shell find . -name *_defconfig |sed 's/.*\///')
44 # Pull in the user's configuration file
45 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
47 # if "make BOARD=xyz" command
51 -include $(BR2_LOCAL)/$(BOARD)/$(BOARD).config
55 # Override BR2_DL_DIR if shell variable defined
56 ifneq ($(BUILDROOT_DL_DIR),)
57 BR2_DL_DIR:=$(BUILDROOT_DL_DIR)
61 # To put more focus on warnings, be less verbose as default
62 # Use 'make V=1' to see the full commands
64 ifeq ("$(origin V)", "command line")
72 ifeq ($(KBUILD_VERBOSE),1)
83 # we want bash as shell
84 SHELL:=$(shell if [ -x "$$BASH" ]; then echo $$BASH; \
85 else if [ -x /bin/bash ]; then echo /bin/bash; \
88 # kconfig uses CONFIG_SHELL
89 CONFIG_SHELL:=$(SHELL)
91 export SHELL CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
121 HOSTAR:=$(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
122 HOSTAS:=$(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
123 HOSTCC:=$(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
124 HOSTCXX:=$(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
125 HOSTFC:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran)
126 HOSTCPP:=$(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
127 HOSTLD:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
128 HOSTLN:=$(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
129 HOSTNM:=$(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
130 HOST_GLIB_BIN:=`dirname $(shell which glib-genmarshal || echo /usr/bin/glib-genmarshal)`
131 HOST_GLIB:=$(shell dirname $(HOST_GLIB_BIN) || echo /usr)
134 ifndef CFLAGS_FOR_BUILD
135 CFLAGS_FOR_BUILD:=-g -O2
137 ifndef CXXFLAGS_FOR_BUILD
138 CXXFLAGS_FOR_BUILD:=-g -O2
140 ifndef FCFLAGS_FOR_BUILD
141 FCFLAGS_FOR_BUILD:=-g -O2
143 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
146 ifeq ($(BR2_HAVE_DOT_CONFIG),y)
149 # Usage: cflags-y+=$(call cc-option, -march=winchip-c6, -march=i586)
150 # sets -march=winchip-c6 if supported else falls back to -march=i586
151 # without checking the latter.
152 cc-option=$(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
153 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
155 #############################################################
157 # Hide troublesome environment variables from sub processes
159 #############################################################
160 unexport CROSS_COMPILE
163 #############################################################
165 # Setup the proper filename extensions for the host
167 ##############################################################
168 ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
173 ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
178 ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
182 HOST_LOADLIBES="-lcurses -lintl"
183 export HOST_LOADLIBES
185 ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
191 # The preferred type of libs we build for the target
192 ifeq ($(BR2_PREFER_STATIC_LIB),y)
194 #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
197 #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
199 PREFERRED_LIB_FLAGS:=--enable-static --enable-shared
201 ##############################################################
203 # The list of stuff to build for the target toolchain
204 # along with the packages to build for the target.
206 ##############################################################
207 ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
208 BASE_TARGETS:=uclibc-configured binutils cross_compiler uclibc-target-utils kernel-headers
215 include project/Makefile.in
217 BR2_DEPENDS_DIR=$(PROJECT_BUILD_DIR)/buildroot-config
219 include toolchain/Makefile.in
220 include package/Makefile.in
222 #############################################################
224 # You should probably leave this stuff alone unless you know
225 # what you are doing.
227 #############################################################
231 # In this section, we need .config
236 # We also need the various per-package makefiles, which also add
237 # each selected package to TARGETS if that package was selected
238 # in the .config file.
239 ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
240 # avoid pulling in external toolchain which is broken for toplvl parallel builds
242 include toolchain/dependencies/dependencies.mk
243 include toolchain/binutils/binutils.mk
244 include toolchain/ccache/ccache.mk
245 include toolchain/elf2flt/elf2flt.mk
246 include toolchain/gcc/gcc-uclibc-3.x.mk
247 include toolchain/gcc/gcc-uclibc-4.x.mk
248 include toolchain/gdb/gdb.mk
249 include toolchain/kernel-headers/kernel-headers.mk
250 include toolchain/mklibs/mklibs.mk
251 include toolchain/sstrip/sstrip.mk
252 include toolchain/uClibc/uclibc.mk
254 include toolchain/*/*.mk
257 ifeq ($(BR2_PACKAGE_LINUX),y)
258 TARGETS+=linux26-modules
261 include package/*/*.mk
263 TARGETS+=target-devfiles
265 # target stuff is last so it can override anything else
266 include target/Makefile.in
268 TARGETS+=erase-fakeroots
270 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
271 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS) $(BASE_TARGETS))
272 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
273 TARGETS_ALL:=$(patsubst %,__real_tgt_%,$(TARGETS))
274 # all targets depend on the crosscompiler and it's prerequisites
275 $(TARGETS_ALL): __real_tgt_%: $(BASE_TARGETS) %
277 $(BR2_DEPENDS_DIR): .config
280 cp -dpRf $(CONFIG)/buildroot-config $@
282 dirs: $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
283 $(BR2_DEPENDS_DIR) $(BINARIES_DIR) $(PROJECT_BUILD_DIR) \
284 $(PROJECT_BUILD_DIR)/autotools-stamps
286 $(BASE_TARGETS): dirs
288 world: dependencies dirs target-host-info $(BASE_TARGETS) $(TARGETS_ALL)
291 .PHONY: all world dirs clean dirclean distclean source \
292 $(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
293 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
294 $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
295 $(BR2_DEPENDS_DIR) $(BINARIES_DIR) $(PROJECT_BUILD_DIR) \
296 $(PROJECT_BUILD_DIR)/autotools-stamps
298 #############################################################
300 # staging and target directories do NOT list these as
301 # dependencies anywhere else
303 #############################################################
304 $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(PROJECT_BUILD_DIR) \
305 $(PROJECT_BUILD_DIR)/autotools-stamps $(BINARIES_DIR):
309 @mkdir -p $(STAGING_DIR)/bin
310 @mkdir -p $(STAGING_DIR)/lib
311 ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
312 @mkdir -p $(STAGING_DIR)/usr/lib
314 ifneq ($(BR2_TOOLCHAIN_EXTERNAL),y)
315 @ln -snf . $(STAGING_DIR)/usr
316 @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)
317 @ln -snf ../lib $(STAGING_DIR)/usr/lib
318 @ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
321 @mkdir -p $(STAGING_DIR)/usr/include
323 $(PROJECT_BUILD_DIR)/.root:
324 mkdir -p $(TARGET_DIR)
325 if ! [ -d "$(TARGET_DIR)/bin" ]; then \
326 if [ -d "$(TARGET_SKELETON)" ]; then \
327 cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
329 touch $(STAGING_DIR)/.fakeroot.00000; \
331 -find $(TARGET_DIR) -type d -name CVS -o -name .svn | xargs rm -rf
332 -find $(TARGET_DIR) -type f -name .empty | xargs rm -rf
335 $(TARGET_DIR): $(PROJECT_BUILD_DIR)/.root
338 rm -f $(PROJECT_BUILD_DIR)/.fakeroot*
341 ifeq ($(BR2_HAVE_DEVFILES),y)
342 ( scripts/copy.sh $(STAGING_DIR) $(TARGET_DIR) )
344 rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/lib/pkgconfig
345 find $(TARGET_DIR)/usr/lib -name '*.a' -delete
346 find $(TARGET_DIR)/lib -name '*.a' -delete
347 find $(TARGET_DIR)/usr/lib -name '*.la' -delete
348 find $(TARGET_DIR)/lib -name '*.la' -delete
351 source: $(TARGETS_SOURCE) $(HOST_SOURCE)
354 $(MAKE) SPIDER=--spider source
357 @$(MAKE) -Bs BR2_WGET=$(TOPDIR)/toolchain/wget-show-external-deps.sh \
358 SPIDER=--spider source
360 #############################################################
362 # Cleanup and misc junk
364 #############################################################
365 clean: $(TARGETS_CLEAN)
366 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) $(PROJECT_BUILD_DIR)/.root $(PROJECT_BUILD_DIR)/autotools-stamps
368 dirclean: $(TARGETS_DIRCLEAN)
369 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) $(PROJECT_BUILD_DIR)/.root $(PROJECT_BUILD_DIR)/autotools-stamps
372 ifeq ($(DL_DIR),$(BASE_DIR)/dl)
375 rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR) \
376 $(LINUX_KERNEL) $(BASE_DIR)/include \
378 $(MAKE) -C $(CONFIG) clean
381 rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR)
384 rm -f buildroot.tar.bz2; \
385 tar -cvf buildroot.tar buildroot; \
386 bzip2 -9 buildroot.tar; \
389 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
394 # ---------------------------------------------------------------------------
396 HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
400 @mkdir -p $(CONFIG)/buildroot-config
401 $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf
402 -@if [ ! -f .config ]; then \
403 cp $(CONFIG_DEFCONFIG) .config; \
406 @mkdir -p $(CONFIG)/buildroot-config
407 $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf mconf
408 -@if [ ! -f .config ]; then \
409 cp $(CONFIG_DEFCONFIG) .config; \
412 menuconfig: $(CONFIG)/mconf
413 @mkdir -p $(CONFIG)/buildroot-config
414 @if ! KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
415 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
416 $(CONFIG)/mconf $(CONFIG_CONFIG_IN); then \
417 test -f .config.cmd || rm -f .config; \
420 config: $(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 $(CONFIG_CONFIG_IN)
426 oldconfig: $(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 -o $(CONFIG_CONFIG_IN)
432 randconfig: $(CONFIG)/conf
433 @mkdir -p $(CONFIG)/buildroot-config
434 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
435 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
436 $(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
438 allyesconfig: $(CONFIG)/conf
439 cat $(CONFIG_DEFCONFIG) > .config
440 @mkdir -p $(CONFIG)/buildroot-config
441 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
442 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
443 $(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
444 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
446 allnoconfig: $(CONFIG)/conf
447 @mkdir -p $(CONFIG)/buildroot-config
448 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
449 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
450 $(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
452 defconfig: $(CONFIG)/conf
453 @mkdir -p $(CONFIG)/buildroot-config
454 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
455 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
456 $(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
458 # check if download URLs are outdated
459 source-check: allyesconfig
460 $(MAKE) _source-check
462 #############################################################
464 # Cleanup and misc junk
466 #############################################################
468 rm -f .config .config.old .config.cmd .tmpconfig.h .lognr.*
469 -$(MAKE) -C $(CONFIG) clean
474 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
476 %_defconfig: $(CONFIG)/conf
477 cp $(shell find ./target/ -name $@) .config
481 cp .config $(BOARD_PATH)/$(BOARD_NAME)_defconfig
483 configured: dirs host-sed kernel-headers uclibc-config busybox-config linux26-config
485 prepatch: gcc-patched binutils-patched gdb-patched uclibc-patched
488 @echo "0" > .lognr.$(PROJECT)
490 log: .lognr.$(PROJECT)
491 @expr `cat .lognr.$(PROJECT)` + 1 > .lognr.$(PROJECT)
492 @echo Creating $(PROJECT)-`cat .lognr.$(PROJECT)`.log
493 @$(MAKE) > $(PROJECT)-`cat .lognr.$(PROJECT)`.log 2>&1
496 cross: $(BASE_TARGETS)
500 @echo ' clean - delete temporary files created by build'
501 @echo ' distclean - delete all non-source files (including .config)'
504 @echo ' all - make world'
506 @echo 'Configuration:'
507 @echo ' menuconfig - interactive curses-based configurator'
508 @echo ' oldconfig - resolve any unresolved symbols in .config'
509 @echo ' saveconfig - save current configuration under local/<project>'
510 @echo ' getconfig - restore saved configuration from local/<project>'
512 @echo 'Miscellaneous:'
513 @echo ' source - download all sources needed for offline-build'
514 @echo ' source-check - check all packages for valid download URLs'
515 @echo ' external-deps - list external packages used'
517 @echo 'See docs/README and docs/buildroot.html for further details'
521 OUT=buildroot-$$(grep -A2 BR2_VERSION $(CONFIG_CONFIG_IN)|grep default|cut -f2 -d\"); \
522 rm -rf ../$$OUT*; cp -al . ../$$OUT; cd ..; \
523 tar cfz $$OUT.tar.gz --exclude .svn --exclude .git --exclude \*~ $$OUT; \
526 .PHONY: dummy subdirs release distclean clean config oldconfig \
527 menuconfig tags check test depend defconfig help