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 \
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
110 HOSTAR
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTAR)" || type
-p
$(HOSTAR
) || echo
ar)
111 HOSTAS
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTAS)" || type
-p
$(HOSTAS
) || echo
as)
112 HOSTCC
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTCC)" || type
-p
$(HOSTCC
) || echo gcc
)
113 HOSTCXX
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTCXX)" || type
-p
$(HOSTCXX
) || echo g
++)
114 HOSTFC
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTLD)" || type
-p
$(HOSTLD
) || echo || which g77 || type
-p g77 || echo gfortran
)
115 HOSTCPP
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTCPP)" || type
-p
$(HOSTCPP
) || echo
cpp)
116 HOSTLD
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTLD)" || type
-p
$(HOSTLD
) || echo
ld)
117 HOSTLN
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTLN)" || type
-p
$(HOSTLN
) || echo ln
)
118 HOSTNM
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTNM)" || type
-p
$(HOSTNM
) || echo nm
)
119 ifndef CFLAGS_FOR_BUILD
120 CFLAGS_FOR_BUILD
:=-g
-O2
122 ifndef CXXFLAGS_FOR_BUILD
123 CXXFLAGS_FOR_BUILD
:=-g
-O2
125 ifndef FCFLAGS_FOR_BUILD
126 FCFLAGS_FOR_BUILD
:=-g
-O2
128 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
131 ifeq ($(BR2_HAVE_DOT_CONFIG
),y
)
134 # Usage: cflags-y+=$(call cc-option, -march=winchip-c6, -march=i586)
135 # sets -march=winchip-c6 if supported else falls back to -march=i586
136 # without checking the latter.
137 cc-option
=$(shell if
$(TARGET_CC
) $(TARGET_CFLAGS
) $(1) -S
-o
/dev
/null
-xc
/dev
/null \
138 > /dev
/null
2>&1; then echo
"$(1)"; else echo
"$(2)"; fi
;)
140 #############################################################
142 # Hide troublesome environment variables from sub processes
144 #############################################################
145 unexport CROSS_COMPILE
148 #############################################################
150 # Setup the proper filename extensions for the host
152 ##############################################################
153 ifneq ($(findstring linux
,$(BR2_GNU_BUILD_SUFFIX
)),)
158 ifneq ($(findstring apple
,$(BR2_GNU_BUILD_SUFFIX
)),)
163 ifneq ($(findstring cygwin
,$(BR2_GNU_BUILD_SUFFIX
)),)
167 HOST_LOADLIBES
="-lcurses -lintl"
168 export HOST_LOADLIBES
170 ifneq ($(findstring mingw
,$(BR2_GNU_BUILD_SUFFIX
)),)
176 # The preferred type of libs we build for the target
177 ifeq ($(BR2_PREFER_STATIC_LIB
),y
)
179 #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
182 #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
184 PREFERRED_LIB_FLAGS
:=--enable-static
--enable-shared
186 ##############################################################
188 # The list of stuff to build for the target toolchain
189 # along with the packages to build for the target.
191 ##############################################################
192 ifeq ($(BR2_TOOLCHAIN_SOURCE
),y
)
193 BASE_TARGETS
:=uclibc-configured binutils cross_compiler uclibc-target-utils
200 include project
/Makefile.in
202 BR2_DEPENDS_DIR
=$(PROJECT_BUILD_DIR
)/buildroot-config
204 include toolchain
/Makefile.in
205 include package
/Makefile.in
207 #############################################################
209 # You should probably leave this stuff alone unless you know
210 # what you are doing.
212 #############################################################
216 # In this section, we need .config
221 # We also need the various per-package makefiles, which also add
222 # each selected package to TARGETS if that package was selected
223 # in the .config file.
224 ifeq ($(BR2_TOOLCHAIN_SOURCE
),y
)
225 # avoid pulling in external toolchain which is broken for toplvl parallel builds
227 include toolchain
/dependencies
/dependencies.mk
228 include toolchain
/binutils
/binutils.mk
229 include toolchain
/ccache
/ccache.mk
230 include toolchain
/elf2flt
/elf2flt.mk
231 include toolchain
/gcc
/gcc-uclibc-3.x.mk
232 include toolchain
/gcc
/gcc-uclibc-4.x.mk
233 include toolchain
/gdb
/gdb.mk
234 include toolchain
/kernel-headers
/kernel-headers.mk
235 include toolchain
/mklibs
/mklibs.mk
236 include toolchain
/sstrip
/sstrip.mk
237 include toolchain
/uClibc
/uclibc.mk
239 include toolchain
/*/*.mk
242 ifeq ($(BR2_PACKAGE_LINUX
),y
)
243 TARGETS
+=linux26-modules
246 include package
/*/*.mk
248 # target stuff is last so it can override anything else
249 include target
/Makefile.in
251 TARGETS
+=erase-fakeroots
253 TARGETS_CLEAN
:=$(patsubst %,%-clean,$(TARGETS
))
254 TARGETS_SOURCE
:=$(patsubst %,%-source
,$(TARGETS
) $(BASE_TARGETS
))
255 TARGETS_DIRCLEAN
:=$(patsubst %,%-dirclean
,$(TARGETS
))
256 TARGETS_ALL
:=$(patsubst %,__real_tgt_
%,$(TARGETS
))
257 # all targets depend on the crosscompiler and it's prerequisites
258 $(TARGETS_ALL
): __real_tgt_
%: $(BASE_TARGETS
) %
260 ifeq ($(BR2__UCLIBC_HAVE_DOT_CONFIG
),)
261 ifneq ($(findstring uclibc-menuconfig
,$(MAKECMDGOALS
)),uclibc-menuconfig
)
262 BR2_UCLIBC_CONFIG_FOR_BUILDROOT
=$(BASE_DIR
)/.buildroot.uclibc_config
264 $(BR2_UCLIBC_CONFIG_FOR_BUILDROOT
): $(dependencies
) $(UCLIBC_DIR
)/.config
265 # Create BR2__UCLIBC_SYM=val
266 cat
$(UCLIBC_DIR
)/.config
> $(BR2_UCLIBC_CONFIG_FOR_BUILDROOT
)
267 $(SED
) '/#/d' -e
'/^$$/d' -e
's,\([^=]*\)=\(.*\),BR2__UCLIBC_\1=\2,g' \
268 $(BR2_UCLIBC_CONFIG_FOR_BUILDROOT
)
271 include $(BR2_UCLIBC_CONFIG_FOR_BUILDROOT
)
275 $(BR2_DEPENDS_DIR
): .config
276 rm -rf
$(BR2_DEPENDS_DIR
)
277 mkdir
-p
$(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
: 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
)
297 #############################################################
299 # staging and target directories do NOT list these as
300 # dependencies anywhere else
302 #############################################################
303 $(DL_DIR
) $(TOOL_BUILD_DIR
) $(BUILD_DIR
) \
304 $(PROJECT_BUILD_DIR
) $(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 @if
test ! -L
$(STAGING_DIR
)/usr
&& test -d
$(STAGING_DIR
)/usr
; then \
314 echo
"You seem to be coming from a toolchain with sysroot support."; \
315 echo
"Reconfiguring without wiping your rootfs will not work, sorry.";\
316 echo
"Please 'rm -rf $(STAGING_DIR)'"; \
317 echo
"Then run 'make' again."; \
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
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 | xargs
rm -rf
337 -find
$(TARGET_DIR
) -type d
-name .svn | xargs
rm -rf
338 -find
$(TARGET_DIR
) -type d
-name .gitignore | xargs
rm -rf
341 $(TARGET_DIR
): $(PROJECT_BUILD_DIR
)/.root
344 rm -f
$(PROJECT_BUILD_DIR
)/.fakeroot
*
346 source
: $(TARGETS_SOURCE
) $(HOST_SOURCE
)
349 $(MAKE
) SPIDER
=--spider source
351 #############################################################
353 # Cleanup and misc junk
355 #############################################################
356 clean: $(TARGETS_CLEAN
)
357 rm -rf
$(STAGING_DIR
) $(TARGET_DIR
) $(IMAGE
)
359 dirclean
: $(TARGETS_DIRCLEAN
)
360 rm -rf
$(STAGING_DIR
) $(TARGET_DIR
) $(IMAGE
)
363 ifeq ($(DL_DIR
),$(BASE_DIR
)/dl
)
366 rm -rf
$(BUILD_DIR
) $(PROJECT_BUILD_DIR
) $(BINARIES_DIR
) \
367 $(LINUX_KERNEL
) $(IMAGE
) $(BASE_DIR
)/include \
369 $(MAKE
) -C
$(CONFIG
) clean distclean
372 rm -rf
$(BUILD_DIR
) $(PROJECT_BUILD_DIR
) $(BINARIES_DIR
)
375 rm -f buildroot.
tar.bz2
; \
376 tar -cvf buildroot.
tar buildroot
; \
377 bzip2
-9 buildroot.
tar; \
380 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
385 # ---------------------------------------------------------------------------
387 HOSTCFLAGS
=$(CFLAGS_FOR_BUILD
)
391 @mkdir
-p
$(CONFIG
)/buildroot-config
392 $(MAKE
) CC
="$(HOSTCC)" -C
$(CONFIG
) conf
393 -@if
[ ! -f .config
]; then \
394 cp
$(CONFIG_DEFCONFIG
) .config
; \
397 @mkdir
-p
$(CONFIG
)/buildroot-config
398 $(MAKE
) CC
="$(HOSTCC)" -C
$(CONFIG
) conf mconf
399 -@if
[ ! -f .config
]; then \
400 cp
$(CONFIG_DEFCONFIG
) .config
; \
403 menuconfig
: $(CONFIG
)/mconf
404 @mkdir
-p
$(CONFIG
)/buildroot-config
405 @if
! KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
406 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
407 $(CONFIG
)/mconf
$(CONFIG_CONFIG_IN
); then \
408 test -f .config.cmd ||
rm -f .config
; \
411 config
: $(CONFIG
)/conf
412 @mkdir
-p
$(CONFIG
)/buildroot-config
413 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
414 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
415 $(CONFIG
)/conf
$(CONFIG_CONFIG_IN
)
417 oldconfig
: $(CONFIG
)/conf
418 @mkdir
-p
$(CONFIG
)/buildroot-config
419 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
420 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
421 $(CONFIG
)/conf
-o
$(CONFIG_CONFIG_IN
)
423 randconfig
: $(CONFIG
)/conf
424 @mkdir
-p
$(CONFIG
)/buildroot-config
425 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
426 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
427 $(CONFIG
)/conf
-r
$(CONFIG_CONFIG_IN
)
429 allyesconfig
: $(CONFIG
)/conf
430 cat
$(CONFIG_DEFCONFIG
) > .config
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
-y
$(CONFIG_CONFIG_IN
)
435 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
437 allnoconfig
: $(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
-n
$(CONFIG_CONFIG_IN
)
443 defconfig
: $(CONFIG
)/conf
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
-d
$(CONFIG_CONFIG_IN
)
449 # check if download URLs are outdated
450 source-check
: allyesconfig
451 $(MAKE
) _source-check
453 #############################################################
455 # Cleanup and misc junk
457 #############################################################
459 rm -f .config .config.old .config.cmd .tmpconfig.h
460 -$(MAKE
) -C
$(CONFIG
) clean
465 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
467 %_defconfig
: $(CONFIG
)/conf
468 cp
$(shell find .
/target
/ -name
$@
) .config
471 configured
: dirs host-sed kernel-headers uclibc-config busybox-config linux26-config
473 cross
: $(BASE_TARGETS
)
477 @echo
' clean - delete temporary files created by build'
478 @echo
' distclean - delete all non-source files (including .config)'
481 @echo
' all - make world'
483 @echo
'Configuration:'
484 @echo
' menuconfig - interactive curses-based configurator'
485 @echo
' oldconfig - resolve any unresolved symbols in .config'
487 @echo
'Miscellaneous:'
488 @echo
' source - download all sources needed for offline-build'
489 @echo
' source-check - check all packages for valid download URLs'
491 @echo
'See docs/README and docs/buildroot.html for further details'
494 .PHONY
: dummy subdirs release
distclean clean config oldconfig \
495 menuconfig
tags check test depend defconfig help