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 #--------------------------------------------------------------
25 CONFIG_CONFIG_IN
=Config.in
26 CONFIG_DEFCONFIG
=.defconfig
28 DATE
:=$(shell date
-u
+%Y
%m
%d
)
30 noconfig_targets
:=menuconfig config oldconfig randconfig \
31 defconfig allyesconfig allnoconfig release
tags \
32 silentoldconfig source-check help
34 # $(shell find . -name *_defconfig |sed 's/.*\///')
36 # Pull in the user's configuration file
37 ifeq ($(filter $(noconfig_targets
),$(MAKECMDGOALS
)),)
39 -include $(TOPDIR
).config
41 -include $(TOPDIR
)/local
/$(BOARD
)/$(BOARD
).config
45 ifneq ($(BUILDROOT_DL_DIR
),)
46 BR2_DL_DIR
:=$(BUILDROOT_DL_DIR
)
48 ifneq ($(BUILDROOT_LOCAL
),)
49 LOCAL
:=$(BUILDROOT_LOCAL
)
54 # To put more focus on warnings, be less verbose as default
55 # Use 'make V=1' to see the full commands
57 ifeq ("$(origin V)", "command line")
65 ifeq ($(KBUILD_VERBOSE
),1)
76 CONFIG_SHELL
:=$(shell if
[ -x
"$$BASH" ]; then echo
$$BASH; \
77 else if
[ -x
/bin
/bash
]; then echo
/bin
/bash
; \
80 export CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
113 HOSTAR
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTAR)" || type
-p
$(HOSTAR
) || echo
ar)
114 HOSTAS
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTAS)" || type
-p
$(HOSTAS
) || echo
as)
115 HOSTCC
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTCC)" || type
-p
$(HOSTCC
) || echo gcc
)
116 HOSTCXX
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTCXX)" || type
-p
$(HOSTCXX
) || echo g
++)
117 HOSTGCJ
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTGCJ)" || type
-p
$(HOSTGCJ
) || echo gcj
)
118 HOSTFC
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTFC)" || type
-p
$(HOSTFC
) || echo || which g77 || type
-p g77 || echo gfortran
)
119 HOSTCPP
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTCPP)" || type
-p
$(HOSTCPP
) || echo
cpp)
120 HOSTLD
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTLD)" || type
-p
$(HOSTLD
) || echo
ld)
121 HOSTLN
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTLN)" || type
-p
$(HOSTLN
) || echo ln
)
122 HOSTNM
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTNM)" || type
-p
$(HOSTNM
) || echo nm
)
123 ifndef CFLAGS_FOR_BUILD
124 CFLAGS_FOR_BUILD
:=-g
-O2
126 ifndef CXXFLAGS_FOR_BUILD
127 CXXFLAGS_FOR_BUILD
:=-g
-O2
129 ifndef FCFLAGS_FOR_BUILD
130 FCFLAGS_FOR_BUILD
:=-g
-O2
132 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTGCJ HOSTFC HOSTLD
135 ifeq ($(BR2_HAVE_DOT_CONFIG
),y
)
138 # Usage: cflags-y+=$(call cc-option, -march=winchip-c6, -march=i586)
139 # sets -march=winchip-c6 if supported else falls back to -march=i586
140 # without checking the latter.
141 cc-option
=$(shell if
$(TARGET_CC
) $(TARGET_CFLAGS
) $(1) -S
-o
/dev
/null
-xc
/dev
/null \
142 > /dev
/null
2>&1; then echo
"$(1)"; else echo
"$(2)"; fi
;)
144 #############################################################
146 # Hide troublesome environment variables from sub processes
148 #############################################################
149 unexport CROSS_COMPILE
152 #############################################################
154 # Setup the proper filename extensions for the host
156 ##############################################################
157 ifneq ($(findstring linux
,$(BR2_GNU_BUILD_SUFFIX
)),)
162 ifneq ($(findstring apple
,$(BR2_GNU_BUILD_SUFFIX
)),)
167 ifneq ($(findstring cygwin
,$(BR2_GNU_BUILD_SUFFIX
)),)
171 HOST_LOADLIBES
="-lcurses -lintl"
172 export HOST_LOADLIBES
174 ifneq ($(findstring mingw
,$(BR2_GNU_BUILD_SUFFIX
)),)
180 # The preferred type of libs we build for the target
181 ifeq ($(BR2_PREFER_STATIC_LIB
),y
)
183 #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
186 #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
188 PREFERRED_LIB_FLAGS
:=--enable-static
--enable-shared
190 BR2_LIBC_NAME
:=$(strip ",,$(BR2_LIBC_NAME))
193 ##############################################################
195 # The list of stuff to build for the target toolchain
196 # along with the packages to build for the target.
198 ##############################################################
199 ifeq ($(BR2_TOOLCHAIN_SOURCE
),y
)
200 BASE_TARGETS
:=libc-configured binutils cross_compiler libc_target
207 include project
/Makefile.in
209 BR2_DEPENDS_DIR
=$(PROJECT_BUILD_DIR
)/buildroot-config
211 include toolchain
/Makefile.in
212 include package
/Makefile.in
214 #############################################################
216 # You should probably leave this stuff alone unless you know
217 # what you are doing.
219 #############################################################
223 # In this section, we need .config
228 # We also need the various per-package makefiles, which also add
229 # each selected package to TARGETS if that package was selected
230 # in the .config file.
231 ifeq ($(BR2_TOOLCHAIN_SOURCE
),y
)
232 # avoid pulling in external toolchain which is broken for toplvl parallel builds
234 include toolchain
/dependencies
/dependencies.mk
235 include toolchain
/binutils
/binutils.mk
236 include toolchain
/ccache
/ccache.mk
237 include toolchain
/elf2flt
/elf2flt.mk
238 ifeq ($(BR2_LIBC_FLAVOUR_uclibc
),y
)
239 include toolchain
/gcc
/gcc-uclibc-3.x.mk
240 include toolchain
/gcc
/gcc-uclibc-4.x.mk
242 include toolchain
/gcc
/gcc-
$(BR2_LIBC_NAME
).mk
244 include toolchain
/gdb
/gdb.mk
245 include toolchain
/kernel-headers
/kernel-headers.mk
246 include toolchain
/mklibs
/mklibs.mk
247 include toolchain
/sstrip
/sstrip.mk
248 ifeq ($(BR2_LIBC_FLAVOUR_uclibc
),y
)
249 include toolchain
/uClibc
/uclibc.mk
251 include toolchain
/$(BR2_LIBC_NAME
)/$(BR2_LIBC_NAME
).mk
254 include toolchain
/*/*.mk
257 ifeq ($(BR2_PACKAGE_LINUX
),y
)
258 TARGETS
+=linux26-modules
261 include package
/*/*.mk
263 # target stuff is last so it can override anything else
264 include target
/Makefile.in
266 TARGETS
+=erase-fakeroots
268 TARGETS_CLEAN
:=$(patsubst %,%-clean,$(TARGETS
))
269 TARGETS_SOURCE
:=$(patsubst %,%-source
,$(TARGETS
) $(BASE_TARGETS
))
270 TARGETS_DIRCLEAN
:=$(patsubst %,%-dirclean
,$(TARGETS
))
271 TARGETS_ALL
:=$(patsubst %,__real_tgt_
%,$(TARGETS
))
272 # all targets depend on the crosscompiler and it's prerequisites
273 $(TARGETS_ALL
): __real_tgt_
%: $(BASE_TARGETS
) % libtool_cluebait
275 $(BR2_DEPENDS_DIR
): .config
276 rm -rf
$(BR2_DEPENDS_DIR
)
278 cp
-dpRf
$(CONFIG
)/buildroot-config
$(BR2_DEPENDS_DIR
)
281 dirs
: $(DL_DIR
) $(TOOL_BUILD_DIR
) $(BUILD_DIR
) $(STAGING_DIR
) $(TARGET_DIR
) \
283 $(BINARIES_DIR
) $(PROJECT_BUILD_DIR
)
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
) \
295 $(BINARIES_DIR
) $(PROJECT_BUILD_DIR
) libtool_cluebait
297 # libtool currently does not play nice with cross-compiling
299 $(Q
)find
$(STAGING_DIR
)/lib
* -name
"*.la" -exec
rm -f
{} \
;
300 $(Q
)find
$(STAGING_DIR
)/usr
/lib
* -name
"*.la" -exec
rm -f
{} \
;
302 #############################################################
304 # staging and target directories do NOT list these as
305 # dependencies anywhere else
307 #############################################################
308 $(DL_DIR
) $(TOOL_BUILD_DIR
) $(BUILD_DIR
) \
309 $(PROJECT_BUILD_DIR
) $(BINARIES_DIR
):
313 @mkdir
-p
$(STAGING_DIR
)/bin
314 @mkdir
-p
$(STAGING_DIR
)/lib
315 ifeq ($(BR2_TOOLCHAIN_SYSROOT
),y
)
316 @mkdir
-p
$(STAGING_DIR
)/usr
/lib
318 @if
test ! -L
$(STAGING_DIR
)/usr
&& test -d
$(STAGING_DIR
)/usr
; then \
319 echo
"You seem to be coming from a toolchain with sysroot support."; \
320 echo
"Reconfiguring without wiping your rootfs will not work, sorry.";\
321 echo
"Please 'rm -rf $(STAGING_DIR)'"; \
322 echo
"Then run 'make' again."; \
326 ln
-snf .
$(STAGING_DIR
)/usr
327 @mkdir
-p
$(STAGING_DIR
)/usr
/$(REAL_GNU_TARGET_NAME
)
328 ln
-snf ..
/lib
$(STAGING_DIR
)/usr
/lib
329 ln
-snf ..
/lib
$(STAGING_DIR
)/usr
/$(REAL_GNU_TARGET_NAME
)/lib
331 @mkdir
-p
$(STAGING_DIR
)/usr
/include
333 $(PROJECT_BUILD_DIR
)/.root
:
334 mkdir
-p
$(TARGET_DIR
)
335 if
! [ -d
"$(TARGET_DIR)/bin" ]; then \
336 if
[ -d
"$(TARGET_SKELETON)" ]; then \
337 cp
-fa
$(TARGET_SKELETON
)/* $(TARGET_DIR
)/; \
339 touch
$(STAGING_DIR
)/.fakeroot
.00000; \
341 -find
$(TARGET_DIR
) -type d
-name CVS | xargs
rm -rf
342 -find
$(TARGET_DIR
) -type d
-name .svn | xargs
rm -rf
343 -find
$(TARGET_DIR
) -type f
-name .gitignore | xargs
rm -rf
346 $(TARGET_DIR
): $(PROJECT_BUILD_DIR
)/.root
349 rm -f
$(PROJECT_BUILD_DIR
)/.fakeroot
*
351 source
: $(TARGETS_SOURCE
) $(HOST_SOURCE
)
354 $(MAKE
) SPIDER
=--spider source
356 #############################################################
358 # Cleanup and misc junk
360 #############################################################
361 clean: $(TARGETS_CLEAN
)
362 rm -rf
$(STAGING_DIR
) $(TARGET_DIR
) $(IMAGE
) \
363 $(BR2_UCLIBC_CONFIG_FOR_BUILDROOT
) $(dependencies
) \
364 $(PROJECT_BUILD_DIR
)/.root
$(PROJECT_BUILD_DIR
)/autotools-stamps
366 dirclean
: $(TARGETS_DIRCLEAN
) clean
369 ifeq ($(DL_DIR
),$(BASE_DIR
)/dl
)
372 rm -rf
$(BUILD_DIR
) $(PROJECT_BUILD_DIR
) $(BINARIES_DIR
) \
373 $(LINUX_KERNEL
) $(IMAGE
) $(BASE_DIR
)/include \
374 .config
* .auto.deps
$(dependencies
) \
375 $(BR2_UCLIBC_CONFIG_FOR_BUILDROOT
)
376 $(MAKE
) -C
$(CONFIG
) clean distclean
379 rm -rf
$(BUILD_DIR
) $(PROJECT_BUILD_DIR
) $(BINARIES_DIR
)
382 rm -f buildroot.
tar.bz2
; \
383 tar -cvf buildroot.
tar buildroot
; \
384 bzip2
-9 buildroot.
tar; \
387 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
392 # ---------------------------------------------------------------------------
394 HOSTCFLAGS
=$(CFLAGS_FOR_BUILD
)
398 @mkdir
-p
$(CONFIG
)/buildroot-config
399 $(MAKE
) CC
="$(HOSTCC)" -C
$(CONFIG
) conf
400 -@if
[ ! -f .config
]; then \
401 cp
$(CONFIG_DEFCONFIG
) .config
; \
404 @mkdir
-p
$(CONFIG
)/buildroot-config
405 $(MAKE
) CC
="$(HOSTCC)" -C
$(CONFIG
) conf mconf
406 -@if
[ ! -f .config
]; then \
407 cp
$(CONFIG_DEFCONFIG
) .config
; \
410 menuconfig
: $(CONFIG
)/mconf
411 @mkdir
-p
$(CONFIG
)/buildroot-config
412 @if
! KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
413 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
414 $(CONFIG
)/mconf
$(CONFIG_CONFIG_IN
); then \
415 test -f .config.cmd ||
rm -f .config
; \
418 config
: $(CONFIG
)/conf
419 @mkdir
-p
$(CONFIG
)/buildroot-config
420 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
421 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
422 $(CONFIG
)/conf
$(CONFIG_CONFIG_IN
)
424 oldconfig
: $(CONFIG
)/conf
425 @mkdir
-p
$(CONFIG
)/buildroot-config
426 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
427 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
428 $(CONFIG
)/conf
-o
$(CONFIG_CONFIG_IN
)
430 silentoldconfig
: $(CONFIG
)/conf
431 @mkdir
-p
$(CONFIG
)/buildroot-config
432 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
433 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
434 $(CONFIG
)/conf
-s
$(CONFIG_CONFIG_IN
)
436 randconfig
: $(CONFIG
)/conf
437 @mkdir
-p
$(CONFIG
)/buildroot-config
438 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
439 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
440 $(CONFIG
)/conf
-r
$(CONFIG_CONFIG_IN
)
442 allyesconfig
: $(CONFIG
)/conf
443 cat
$(CONFIG_DEFCONFIG
) > .config
444 @mkdir
-p
$(CONFIG
)/buildroot-config
445 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
446 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
447 $(CONFIG
)/conf
-y
$(CONFIG_CONFIG_IN
)
448 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
450 allnoconfig
: $(CONFIG
)/conf
451 @mkdir
-p
$(CONFIG
)/buildroot-config
452 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
453 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
454 $(CONFIG
)/conf
-n
$(CONFIG_CONFIG_IN
)
456 defconfig
: $(CONFIG
)/conf
457 @mkdir
-p
$(CONFIG
)/buildroot-config
458 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
459 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
460 $(CONFIG
)/conf
-d
$(CONFIG_CONFIG_IN
)
462 # check if download URLs are outdated
463 source-check
: allyesconfig
464 $(MAKE
) _source-check
466 #############################################################
468 # Cleanup and misc junk
470 #############################################################
472 rm -f .config .config.old .config.cmd .tmpconfig.h
473 -$(MAKE
) -C
$(CONFIG
) clean
478 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
480 %_defconfig
: $(CONFIG
)/conf
481 cp
$(shell find .
/target
/ -name
$@
) .config
484 configured
: dirs host-sed kernel-headers libc-config busybox-config linux26-config
486 cross
: $(BASE_TARGETS
)
490 @echo
' clean - delete temporary files created by build'
491 @echo
' distclean - delete all non-source files (including .config)'
494 @echo
' all - make world'
496 @echo
'Configuration:'
497 @echo
' menuconfig - interactive curses-based configurator'
498 @echo
' oldconfig - resolve any unresolved symbols in .config'
499 @echo
' silentoldconfig - silently resolve any unresolved symbols in .config'
501 @echo
'Miscellaneous:'
502 @echo
' source - download all sources needed for offline-build'
503 @echo
' source-check - check all packages for valid download URLs'
505 @echo
'See docs/README and docs/buildroot.html for further details'
508 .PHONY
: dummy subdirs release
distclean clean config oldconfig \
509 menuconfig
tags check test depend defconfig help