1 # Makefile for buildroot2
3 # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4 # Copyright (C) 2006-2009 by the Buildroot developers <buildroot@uclibc.org>
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
)
136 ifndef CFLAGS_FOR_BUILD
137 CFLAGS_FOR_BUILD
:=-g
-O2
139 ifndef CXXFLAGS_FOR_BUILD
140 CXXFLAGS_FOR_BUILD
:=-g
-O2
142 ifndef FCFLAGS_FOR_BUILD
143 FCFLAGS_FOR_BUILD
:=-g
-O2
145 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
148 ifeq ($(BR2_HAVE_DOT_CONFIG
),y
)
151 # Usage: cflags-y+=$(call cc-option, -march=winchip-c6, -march=i586)
152 # sets -march=winchip-c6 if supported else falls back to -march=i586
153 # without checking the latter.
154 cc-option
=$(shell if
$(TARGET_CC
) $(TARGET_CFLAGS
) $(1) -S
-o
/dev
/null
-xc
/dev
/null \
155 > /dev
/null
2>&1; then echo
"$(1)"; else echo
"$(2)"; fi
;)
157 #############################################################
159 # Hide troublesome environment variables from sub processes
161 #############################################################
162 unexport CROSS_COMPILE
165 #############################################################
167 # Setup the proper filename extensions for the host
169 ##############################################################
170 ifneq ($(findstring linux
,$(BR2_GNU_BUILD_SUFFIX
)),)
175 ifneq ($(findstring apple
,$(BR2_GNU_BUILD_SUFFIX
)),)
180 ifneq ($(findstring cygwin
,$(BR2_GNU_BUILD_SUFFIX
)),)
184 HOST_LOADLIBES
="-lcurses -lintl"
185 export HOST_LOADLIBES
187 ifneq ($(findstring mingw
,$(BR2_GNU_BUILD_SUFFIX
)),)
193 # The preferred type of libs we build for the target
194 ifeq ($(BR2_PREFER_STATIC_LIB
),y
)
196 #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
199 #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
201 PREFERRED_LIB_FLAGS
:=--enable-static
--enable-shared
203 ##############################################################
205 # The list of stuff to build for the target toolchain
206 # along with the packages to build for the target.
208 ##############################################################
209 ifeq ($(BR2_TOOLCHAIN_SOURCE
),y
)
210 BASE_TARGETS
:=uclibc-configured binutils cross_compiler uclibc-target-utils kernel-headers
217 include project
/Makefile.in
219 BR2_DEPENDS_DIR
=$(PROJECT_BUILD_DIR
)/buildroot-config
221 include toolchain
/Makefile.in
222 include package
/Makefile.in
224 #############################################################
226 # You should probably leave this stuff alone unless you know
227 # what you are doing.
229 #############################################################
233 # In this section, we need .config
238 # We also need the various per-package makefiles, which also add
239 # each selected package to TARGETS if that package was selected
240 # in the .config file.
241 ifeq ($(BR2_TOOLCHAIN_SOURCE
),y
)
242 # avoid pulling in external toolchain which is broken for toplvl parallel builds
244 include toolchain
/dependencies
/dependencies.mk
245 include toolchain
/binutils
/binutils.mk
246 include toolchain
/ccache
/ccache.mk
247 include toolchain
/elf2flt
/elf2flt.mk
248 include toolchain
/gcc
/gcc-uclibc-3.x.mk
249 include toolchain
/gcc
/gcc-uclibc-4.x.mk
250 include toolchain
/gdb
/gdb.mk
251 include toolchain
/kernel-headers
/kernel-headers.mk
252 include toolchain
/mklibs
/mklibs.mk
253 include toolchain
/sstrip
/sstrip.mk
254 include toolchain
/uClibc
/uclibc.mk
256 include toolchain
/*/*.mk
259 ifeq ($(BR2_PACKAGE_LINUX
),y
)
260 TARGETS
+=linux26-modules
263 include package
/*/*.mk
265 TARGETS
+=target-finalize
267 ifeq ($(BR2_ENABLE_LOCALE_PURGE
),y
)
268 TARGETS
+=target-purgelocales
271 # target stuff is last so it can override anything else
272 include target
/Makefile.in
274 TARGETS
+=erase-fakeroots
276 TARGETS_CLEAN
:=$(patsubst %,%-clean,$(TARGETS
))
277 TARGETS_SOURCE
:=$(patsubst %,%-source
,$(TARGETS
) $(BASE_TARGETS
))
278 TARGETS_DIRCLEAN
:=$(patsubst %,%-dirclean
,$(TARGETS
))
279 TARGETS_ALL
:=$(patsubst %,__real_tgt_
%,$(TARGETS
))
280 # all targets depend on the crosscompiler and it's prerequisites
281 $(TARGETS_ALL
): __real_tgt_
%: $(BASE_TARGETS
) %
283 $(BR2_DEPENDS_DIR
): .config
286 cp
-dpRf
$(CONFIG
)/buildroot-config
$@
288 dirs
: $(DL_DIR
) $(TOOL_BUILD_DIR
) $(BUILD_DIR
) $(STAGING_DIR
) $(TARGET_DIR
) \
289 $(HOST_DIR
) $(BR2_DEPENDS_DIR
) $(BINARIES_DIR
) $(PROJECT_BUILD_DIR
) \
290 $(PROJECT_BUILD_DIR
)/autotools-stamps
$(STAMP_DIR
)
292 $(BASE_TARGETS
): dirs
294 world
: dependencies dirs target-host-info
$(BASE_TARGETS
) $(TARGETS_ALL
)
297 .PHONY
: all world dirs
clean dirclean
distclean source \
298 $(BASE_TARGETS
) $(TARGETS
) $(TARGETS_ALL
) \
299 $(TARGETS_CLEAN
) $(TARGETS_DIRCLEAN
) $(TARGETS_SOURCE
) \
300 $(DL_DIR
) $(TOOL_BUILD_DIR
) $(BUILD_DIR
) $(STAGING_DIR
) $(TARGET_DIR
) \
301 $(HOST_DIR
) $(BR2_DEPENDS_DIR
) $(BINARIES_DIR
) $(PROJECT_BUILD_DIR
) \
302 $(PROJECT_BUILD_DIR
)/autotools-stamps
$(STAMP_DIR
)
304 #############################################################
306 # staging and target directories do NOT list these as
307 # dependencies anywhere else
309 #############################################################
310 $(DL_DIR
) $(TOOL_BUILD_DIR
) $(BUILD_DIR
) $(HOST_DIR
) $(PROJECT_BUILD_DIR
) \
311 $(PROJECT_BUILD_DIR
)/autotools-stamps
$(BINARIES_DIR
) $(STAMP_DIR
):
315 @mkdir
-p
$(STAGING_DIR
)/bin
316 @mkdir
-p
$(STAGING_DIR
)/lib
317 ifeq ($(BR2_TOOLCHAIN_SYSROOT
),y
)
318 @mkdir
-p
$(STAGING_DIR
)/usr
/lib
320 ifneq ($(BR2_TOOLCHAIN_EXTERNAL
),y
)
321 @ln
-snf .
$(STAGING_DIR
)/usr
322 @mkdir
-p
$(STAGING_DIR
)/usr
/$(REAL_GNU_TARGET_NAME
)
323 @ln
-snf ..
/lib
$(STAGING_DIR
)/usr
/lib
324 @ln
-snf ..
/lib
$(STAGING_DIR
)/usr
/$(REAL_GNU_TARGET_NAME
)/lib
327 @mkdir
-p
$(STAGING_DIR
)/usr
/include
329 $(PROJECT_BUILD_DIR
)/.root
:
330 mkdir
-p
$(TARGET_DIR
)
331 if
! [ -d
"$(TARGET_DIR)/bin" ]; then \
332 if
[ -d
"$(TARGET_SKELETON)" ]; then \
333 cp
-fa
$(TARGET_SKELETON
)/* $(TARGET_DIR
)/; \
335 touch
$(STAGING_DIR
)/.fakeroot
.00000; \
337 -find
$(TARGET_DIR
) -type d
-name CVS
-o
-name .svn
-print0 | xargs
-0 rm -rf
338 -find
$(TARGET_DIR
) -type f
-name .empty
-print0 | xargs
-0 rm -rf
341 $(TARGET_DIR
): $(PROJECT_BUILD_DIR
)/.root
344 rm -f
$(PROJECT_BUILD_DIR
)/.fakeroot
*
347 ifeq ($(BR2_HAVE_DEVFILES
),y
)
348 ( scripts
/copy.sh
$(STAGING_DIR
) $(TARGET_DIR
) )
350 rm -rf
$(TARGET_DIR
)/usr
/include $(TARGET_DIR
)/usr
/lib
/pkgconfig
351 find
$(TARGET_DIR
)/lib \
( -name
'*.a' -o
-name
'*.la' \
) -print0 | xargs
-0 rm -f
352 find
$(TARGET_DIR
)/usr
/lib \
( -name
'*.a' -o
-name
'*.la' \
) -print0 | xargs
-0 rm -f
354 ifneq ($(BR2_HAVE_MANPAGES
),y
)
355 rm -rf
$(TARGET_DIR
)/usr
/man
$(TARGET_DIR
)/usr
/share
/man
357 ifneq ($(BR2_HAVE_INFOPAGES
),y
)
358 rm -rf
$(TARGET_DIR
)/usr
/info $(TARGET_DIR
)/usr
/share
/info
360 find
$(TARGET_DIR
) -type f
-perm
+111 | xargs
$(STRIPCMD
) 2>/dev
/null || true
361 $(TARGET_LDCONFIG
) -r
$(TARGET_DIR
) 2>/dev
/null
363 ifeq ($(BR2_ENABLE_LOCALE_PURGE
),y
)
364 LOCALE_WHITELIST
=$(PROJECT_BUILD_DIR
)/locales.nopurge
365 LOCALE_NOPURGE
=$(strip $(subst ",,$(BR2_ENABLE_LOCALE_WHITELIST)))
369 rm -f
$(LOCALE_WHITELIST
)
370 for i in
$(LOCALE_NOPURGE
); do echo
$$i >> $(LOCALE_WHITELIST
); done
372 for
dir in
$(wildcard $(addprefix $(TARGET_DIR
),/usr
/share
/locale
/usr
/share
/X11
/locale
/usr
/man
/usr
/share
/man
)); \
374 for lang in
$$(cd
$$dir; ls .|grep
-v man
); \
376 grep
-qx
$$lang $(LOCALE_WHITELIST
) ||
rm -rf
$$dir/$$lang; \
381 source
: $(TARGETS_SOURCE
) $(HOST_SOURCE
)
384 $(MAKE
) SPIDER
=--spider source
387 @
$(MAKE
) -Bs BR2_WGET
=$(TOPDIR
)/toolchain
/wget-show-external-deps.sh \
388 SPIDER
=--spider source
390 #############################################################
392 # Cleanup and misc junk
394 #############################################################
395 clean: $(TARGETS_CLEAN
)
396 rm -rf
$(STAGING_DIR
) $(TARGET_DIR
) $(IMAGE
) $(PROJECT_BUILD_DIR
)/.root
$(PROJECT_BUILD_DIR
)/autotools-stamps
$(STAMP_DIR
)
398 dirclean
: $(TARGETS_DIRCLEAN
)
399 rm -rf
$(STAGING_DIR
) $(TARGET_DIR
) $(IMAGE
) $(PROJECT_BUILD_DIR
)/.root
$(PROJECT_BUILD_DIR
)/autotools-stamps
$(STAMP_DIR
)
402 ifeq ($(DL_DIR
),$(BASE_DIR
)/dl
)
405 rm -rf
$(TOOL_BUILD_DIR
) $(BUILD_DIR
) $(PROJECT_BUILD_DIR
) $(BINARIES_DIR
) \
407 $(MAKE
) -C
$(CONFIG
) clean
410 rm -rf
$(BUILD_DIR
) $(PROJECT_BUILD_DIR
) $(BINARIES_DIR
)
413 rm -f buildroot.
tar.bz2
; \
414 tar -cvf buildroot.
tar buildroot
; \
415 bzip2
-9 buildroot.
tar; \
418 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
423 # ---------------------------------------------------------------------------
425 HOSTCFLAGS
=$(CFLAGS_FOR_BUILD
)
429 @mkdir
-p
$(CONFIG
)/buildroot-config
430 $(MAKE
) CC
="$(HOSTCC)" -C
$(CONFIG
) conf
431 -@if
[ ! -f .config
]; then \
432 cp
$(CONFIG_DEFCONFIG
) .config
; \
435 @mkdir
-p
$(CONFIG
)/buildroot-config
436 $(MAKE
) CC
="$(HOSTCC)" -C
$(CONFIG
) conf mconf
437 -@if
[ ! -f .config
]; then \
438 cp
$(CONFIG_DEFCONFIG
) .config
; \
441 menuconfig
: $(CONFIG
)/mconf
442 @mkdir
-p
$(CONFIG
)/buildroot-config
443 @if
! KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
444 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
445 $(CONFIG
)/mconf
$(CONFIG_CONFIG_IN
); then \
446 test -f .config.cmd ||
rm -f .config
; \
449 config
: $(CONFIG
)/conf
450 @mkdir
-p
$(CONFIG
)/buildroot-config
451 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
452 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
453 $(CONFIG
)/conf
$(CONFIG_CONFIG_IN
)
455 oldconfig
: $(CONFIG
)/conf
456 @mkdir
-p
$(CONFIG
)/buildroot-config
457 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
458 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
459 $(CONFIG
)/conf
-o
$(CONFIG_CONFIG_IN
)
461 randconfig
: $(CONFIG
)/conf
462 @mkdir
-p
$(CONFIG
)/buildroot-config
463 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
464 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
465 $(CONFIG
)/conf
-r
$(CONFIG_CONFIG_IN
)
467 allyesconfig
: $(CONFIG
)/conf
468 cat
$(CONFIG_DEFCONFIG
) > .config
469 @mkdir
-p
$(CONFIG
)/buildroot-config
470 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
471 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
472 $(CONFIG
)/conf
-y
$(CONFIG_CONFIG_IN
)
473 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
475 allnoconfig
: $(CONFIG
)/conf
476 @mkdir
-p
$(CONFIG
)/buildroot-config
477 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
478 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
479 $(CONFIG
)/conf
-n
$(CONFIG_CONFIG_IN
)
481 defconfig
: $(CONFIG
)/conf
482 @mkdir
-p
$(CONFIG
)/buildroot-config
483 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
484 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
485 $(CONFIG
)/conf
-d
$(CONFIG_CONFIG_IN
)
487 # check if download URLs are outdated
488 source-check
: allyesconfig
489 $(MAKE
) _source-check
491 #############################################################
493 # Cleanup and misc junk
495 #############################################################
497 rm -f .config .config.old .config.cmd .tmpconfig.h .lognr.
*
498 -$(MAKE
) -C
$(CONFIG
) clean
504 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
507 rm -f
$(PROJECT_BUILD_DIR
)/tgt-config.cache
509 %_defconfig
: $(CONFIG
)/conf
510 cp
$(shell find .
/target
/ -name
$@
) .config
514 cp .config
$(BOARD_PATH
)/$(PROJECT
)_defconfig
516 configured
: dirs host-sed kernel-headers uclibc-config busybox-config linux26-config
518 prepatch
: gcc-patched binutils-patched gdb-patched uclibc-patched
521 @echo
"0" > .lognr.
$(PROJECT
)
523 log
: .lognr.
$(PROJECT
)
524 @expr
`cat .lognr.$(PROJECT)` + 1 > .lognr.
$(PROJECT
)
525 @echo Creating
$(PROJECT
)-`cat .lognr.$(PROJECT)`.log
526 @
$(MAKE
) > $(PROJECT
)-`cat .lognr.$(PROJECT)`.log
2>&1
529 cross
: $(BASE_TARGETS
)
533 @echo
' clean - delete temporary files created by build'
534 @echo
' distclean - delete all non-source files (including .config)'
537 @echo
' all - make world'
539 @echo
'Configuration:'
540 @echo
' menuconfig - interactive curses-based configurator'
541 @echo
' oldconfig - resolve any unresolved symbols in .config'
542 @echo
' configured - make {uclibc/busybox/linux26}-config'
543 @echo
' saveconfig - save current configuration under local/<project>'
544 @echo
' getconfig - restore saved configuration from local/<project>'
546 @echo
'Miscellaneous:'
547 @echo
' source - download all sources needed for offline-build'
548 @echo
' source-check - check all packages for valid download URLs'
549 @echo
' external-deps - list external packages used'
550 @echo
' flush - flush configuration cache'
552 @echo
'See docs/README and docs/buildroot.html for further details'
556 OUT
=buildroot-
$$(grep
-A2 BR2_VERSION
$(CONFIG_CONFIG_IN
)|grep default|cut
-f2
-d
\"); \
557 rm -rf ..
/$$OUT*; cp
-al . ..
/$$OUT; cd ..
; \
558 tar cfz
$$OUT.
tar.gz
--exclude .svn
--exclude .git
--exclude \
*~
$$OUT; \
561 .PHONY
: dummy subdirs release
distclean clean config oldconfig \
562 menuconfig
tags check test depend defconfig help