1 # Makefile for buildroot2
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 #--------------------------------------------------------------
25 CONFIG_CONFIG_IN=Config.in
26 CONFIG_DEFCONFIG=.defconfig
28 DATE:=$(shell date +%Y%m%d)
30 noconfig_targets:=menuconfig config oldconfig randconfig \
31 defconfig allyesconfig allnoconfig release tags \
35 # Use shell variables, if defined
36 ifneq ($(BUILDROOT_LOCAL),)
37 BR2_LOCAL:=$(BUILDROOT_LOCAL)
39 BR2_LOCAL:=$(TOPDIR)/local
42 # $(shell find . -name *_defconfig |sed 's/.*\///')
43 # Pull in the user's configuration file
44 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
46 # if "make BOARD=xyz" command
50 -include $(BR2_LOCAL)/$(BOARD)/$(BOARD).config
54 # Override BR2_DL_DIR if shell variable defined
55 ifneq ($(BUILDROOT_DL_DIR),)
56 BR2_DL_DIR:=$(BUILDROOT_DL_DIR)
60 # To put more focus on warnings, be less verbose as default
61 # Use 'make V=1' to see the full commands
63 ifeq ("$(origin V)", "command line")
71 ifeq ($(KBUILD_VERBOSE),1)
82 # we want bash as shell
83 SHELL:=$(shell if [ -x "$$BASH" ]; then echo $$BASH; \
84 else if [ -x /bin/bash ]; then echo /bin/bash; \
87 # kconfig uses CONFIG_SHELL
88 CONFIG_SHELL:=$(SHELL)
90 export SHELL CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
120 HOSTAR:=$(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
121 HOSTAS:=$(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
122 HOSTCC:=$(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
123 HOSTCXX:=$(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
124 HOSTFC:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran)
125 HOSTCPP:=$(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
126 HOSTLD:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
127 HOSTLN:=$(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
128 HOSTNM:=$(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
129 HOST_GLIB_BIN:=`dirname $(shell which glib-genmarshal || echo /usr/bin/glib-genmarshal)`
130 HOST_GLIB:=$(shell dirname $(HOST_GLIB_BIN) || echo /usr)
133 ifndef CFLAGS_FOR_BUILD
134 CFLAGS_FOR_BUILD:=-g -O2
136 ifndef CXXFLAGS_FOR_BUILD
137 CXXFLAGS_FOR_BUILD:=-g -O2
139 ifndef FCFLAGS_FOR_BUILD
140 FCFLAGS_FOR_BUILD:=-g -O2
142 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
145 ifeq ($(BR2_HAVE_DOT_CONFIG),y)
148 # Usage: cflags-y+=$(call cc-option, -march=winchip-c6, -march=i586)
149 # sets -march=winchip-c6 if supported else falls back to -march=i586
150 # without checking the latter.
151 cc-option=$(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
152 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
154 #############################################################
156 # Hide troublesome environment variables from sub processes
158 #############################################################
159 unexport CROSS_COMPILE
162 #############################################################
164 # Setup the proper filename extensions for the host
166 ##############################################################
167 ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
172 ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
177 ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
181 HOST_LOADLIBES="-lcurses -lintl"
182 export HOST_LOADLIBES
184 ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
190 # The preferred type of libs we build for the target
191 ifeq ($(BR2_PREFER_STATIC_LIB),y)
193 #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
196 #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
198 PREFERRED_LIB_FLAGS:=--enable-static --enable-shared
200 ##############################################################
202 # The list of stuff to build for the target toolchain
203 # along with the packages to build for the target.
205 ##############################################################
206 ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
207 BASE_TARGETS:=uclibc-configured binutils cross_compiler uclibc-target-utils kernel-headers
214 include project/Makefile.in
216 BR2_DEPENDS_DIR=$(PROJECT_BUILD_DIR)/buildroot-config
218 include toolchain/Makefile.in
219 include package/Makefile.in
221 #############################################################
223 # You should probably leave this stuff alone unless you know
224 # what you are doing.
226 #############################################################
230 # In this section, we need .config
235 # We also need the various per-package makefiles, which also add
236 # each selected package to TARGETS if that package was selected
237 # in the .config file.
238 ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
239 # avoid pulling in external toolchain which is broken for toplvl parallel builds
241 include toolchain/dependencies/dependencies.mk
242 include toolchain/binutils/binutils.mk
243 include toolchain/ccache/ccache.mk
244 include toolchain/elf2flt/elf2flt.mk
245 include toolchain/gcc/gcc-uclibc-3.x.mk
246 include toolchain/gcc/gcc-uclibc-4.x.mk
247 include toolchain/gdb/gdb.mk
248 include toolchain/kernel-headers/kernel-headers.mk
249 include toolchain/mklibs/mklibs.mk
250 include toolchain/sstrip/sstrip.mk
251 include toolchain/uClibc/uclibc.mk
253 include toolchain/*/*.mk
256 ifeq ($(BR2_PACKAGE_LINUX),y)
257 TARGETS+=linux26-modules
260 include package/*/*.mk
262 TARGETS+=target-devfiles
264 # target stuff is last so it can override anything else
265 include target/Makefile.in
267 TARGETS+=erase-fakeroots
269 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
270 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS) $(BASE_TARGETS))
271 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
272 TARGETS_ALL:=$(patsubst %,__real_tgt_%,$(TARGETS))
273 # all targets depend on the crosscompiler and it's prerequisites
274 $(TARGETS_ALL): __real_tgt_%: $(BASE_TARGETS) %
276 $(BR2_DEPENDS_DIR): .config
279 cp -dpRf $(CONFIG)/buildroot-config $@
281 dirs: $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
282 $(BR2_DEPENDS_DIR) $(BINARIES_DIR) $(PROJECT_BUILD_DIR) \
283 $(PROJECT_BUILD_DIR)/autotools-stamps
285 $(BASE_TARGETS): dirs
287 world: dependencies dirs target-host-info $(BASE_TARGETS) $(TARGETS_ALL)
290 .PHONY: all world dirs clean dirclean distclean source \
291 $(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
292 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
293 $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
294 $(BR2_DEPENDS_DIR) $(BINARIES_DIR) $(PROJECT_BUILD_DIR) \
295 $(PROJECT_BUILD_DIR)/autotools-stamps
297 #############################################################
299 # staging and target directories do NOT list these as
300 # dependencies anywhere else
302 #############################################################
303 $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(PROJECT_BUILD_DIR) \
304 $(PROJECT_BUILD_DIR)/autotools-stamps $(BINARIES_DIR):
308 @mkdir -p $(STAGING_DIR)/bin
309 @mkdir -p $(STAGING_DIR)/lib
310 ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
311 @mkdir -p $(STAGING_DIR)/usr/lib
313 ifneq ($(BR2_TOOLCHAIN_EXTERNAL),y)
314 @ln -snf . $(STAGING_DIR)/usr
315 @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)
316 @ln -snf ../lib $(STAGING_DIR)/usr/lib
317 @ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
320 @mkdir -p $(STAGING_DIR)/usr/include
322 $(PROJECT_BUILD_DIR)/.root:
323 mkdir -p $(TARGET_DIR)
324 if ! [ -d "$(TARGET_DIR)/bin" ]; then \
325 if [ -d "$(TARGET_SKELETON)" ]; then \
326 cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
328 touch $(STAGING_DIR)/.fakeroot.00000; \
330 -find $(TARGET_DIR) -type d -name CVS -o -name .svn | xargs rm -rf
331 -find $(TARGET_DIR) -type f -name .empty | xargs rm -rf
334 $(TARGET_DIR): $(PROJECT_BUILD_DIR)/.root
337 rm -f $(PROJECT_BUILD_DIR)/.fakeroot*
340 ifeq ($(BR2_HAVE_DEVFILES),y)
341 ( scripts/copy.sh $(STAGING_DIR) $(TARGET_DIR) )
343 rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/lib/pkgconfig
344 find $(TARGET_DIR)/usr/lib -name '*.a' -delete
345 find $(TARGET_DIR)/lib -name '*.a' -delete
346 find $(TARGET_DIR)/usr/lib -name '*.la' -delete
347 find $(TARGET_DIR)/lib -name '*.la' -delete
350 source: $(TARGETS_SOURCE) $(HOST_SOURCE)
353 $(MAKE) SPIDER=--spider source
356 @$(MAKE) -Bs BR2_WGET=$(TOPDIR)/toolchain/wget-show-external-deps.sh \
357 SPIDER=--spider source
359 #############################################################
361 # Cleanup and misc junk
363 #############################################################
364 clean: $(TARGETS_CLEAN)
365 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) $(PROJECT_BUILD_DIR)/.root $(PROJECT_BUILD_DIR)/autotools-stamps
367 dirclean: $(TARGETS_DIRCLEAN)
368 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) $(PROJECT_BUILD_DIR)/.root $(PROJECT_BUILD_DIR)/autotools-stamps
371 ifeq ($(DL_DIR),$(BASE_DIR)/dl)
374 rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR) \
375 $(LINUX_KERNEL) $(BASE_DIR)/include \
377 $(MAKE) -C $(CONFIG) clean
380 rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR)
383 rm -f buildroot.tar.bz2; \
384 tar -cvf buildroot.tar buildroot; \
385 bzip2 -9 buildroot.tar; \
388 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
393 # ---------------------------------------------------------------------------
395 HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
399 @mkdir -p $(CONFIG)/buildroot-config
400 $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf
401 -@if [ ! -f .config ]; then \
402 cp $(CONFIG_DEFCONFIG) .config; \
405 @mkdir -p $(CONFIG)/buildroot-config
406 $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf mconf
407 -@if [ ! -f .config ]; then \
408 cp $(CONFIG_DEFCONFIG) .config; \
411 menuconfig: $(CONFIG)/mconf
412 @mkdir -p $(CONFIG)/buildroot-config
413 @if ! KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
414 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
415 $(CONFIG)/mconf $(CONFIG_CONFIG_IN); then \
416 test -f .config.cmd || rm -f .config; \
419 config: $(CONFIG)/conf
420 @mkdir -p $(CONFIG)/buildroot-config
421 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
422 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
423 $(CONFIG)/conf $(CONFIG_CONFIG_IN)
425 oldconfig: $(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 -o $(CONFIG_CONFIG_IN)
431 randconfig: $(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 -r $(CONFIG_CONFIG_IN)
437 allyesconfig: $(CONFIG)/conf
438 cat $(CONFIG_DEFCONFIG) > .config
439 @mkdir -p $(CONFIG)/buildroot-config
440 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
441 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
442 $(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
443 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
445 allnoconfig: $(CONFIG)/conf
446 @mkdir -p $(CONFIG)/buildroot-config
447 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
448 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
449 $(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
451 defconfig: $(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 -d $(CONFIG_CONFIG_IN)
457 # check if download URLs are outdated
458 source-check: allyesconfig
459 $(MAKE) _source-check
461 #############################################################
463 # Cleanup and misc junk
465 #############################################################
467 rm -f .config .config.old .config.cmd .tmpconfig.h .lognr.*
468 -$(MAKE) -C $(CONFIG) clean
473 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
475 %_defconfig: $(CONFIG)/conf
476 cp $(shell find ./target/ -name $@) .config
480 cp .config $(BOARD_PATH)/$(BOARD_NAME)_defconfig
482 configured: dirs host-sed kernel-headers uclibc-config busybox-config linux26-config
484 prepatch: gcc-patched binutils-patched gdb-patched uclibc-patched
487 @echo "0" > .lognr.$(PROJECT)
489 log: .lognr.$(PROJECT)
490 @expr `cat .lognr.$(PROJECT)` + 1 > .lognr.$(PROJECT)
491 @echo Creating $(PROJECT)-`cat .lognr.$(PROJECT)`.log
492 @$(MAKE) > $(PROJECT)-`cat .lognr.$(PROJECT)`.log 2>&1
495 cross: $(BASE_TARGETS)
499 @echo ' clean - delete temporary files created by build'
500 @echo ' distclean - delete all non-source files (including .config)'
503 @echo ' all - make world'
505 @echo 'Configuration:'
506 @echo ' menuconfig - interactive curses-based configurator'
507 @echo ' oldconfig - resolve any unresolved symbols in .config'
508 @echo ' saveconfig - save current configuration under local/<project>'
509 @echo ' getconfig - restore saved configuration from local/<project>'
511 @echo 'Miscellaneous:'
512 @echo ' source - download all sources needed for offline-build'
513 @echo ' source-check - check all packages for valid download URLs'
514 @echo ' external-deps - list external packages used'
516 @echo 'See docs/README and docs/buildroot.html for further details'
519 .PHONY: dummy subdirs release distclean clean config oldconfig \
520 menuconfig tags check test depend defconfig help