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
44 ifneq ($(BUILDROOT_DL_DIR
),)
45 BR2_DL_DIR
:=$(BUILDROOT_DL_DIR
)
47 ifneq ($(BUILDROOT_LOCAL
),)
48 LOCAL
:=$(BUILDROOT_LOCAL
)
53 # To put more focus on warnings, be less verbose as default
54 # Use 'make V=1' to see the full commands
56 ifeq ("$(origin V)", "command line")
64 ifeq ($(KBUILD_VERBOSE
),1)
75 CONFIG_SHELL
:=$(shell if
[ -x
"$$BASH" ]; then echo
$$BASH; \
76 else if
[ -x
/bin
/bash
]; then echo
/bin
/bash
; \
79 export CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
109 HOSTAR
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTAR)" || type
-p
$(HOSTAR
) || echo
ar)
110 HOSTAS
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTAS)" || type
-p
$(HOSTAS
) || echo
as)
111 HOSTCC
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTCC)" || type
-p
$(HOSTCC
) || echo gcc
)
112 HOSTCXX
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTCXX)" || type
-p
$(HOSTCXX
) || echo g
++)
113 HOSTFC
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTLD)" || type
-p
$(HOSTLD
) || echo || which g77 || type
-p g77 || echo gfortran
)
114 HOSTCPP
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTCPP)" || type
-p
$(HOSTCPP
) || echo
cpp)
115 HOSTLD
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTLD)" || type
-p
$(HOSTLD
) || echo
ld)
116 HOSTLN
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTLN)" || type
-p
$(HOSTLN
) || echo ln
)
117 HOSTNM
:=$(shell $(CONFIG_SHELL
) -c
"which $(HOSTNM)" || type
-p
$(HOSTNM
) || echo nm
)
118 ifndef CFLAGS_FOR_BUILD
119 CFLAGS_FOR_BUILD
:=-g
-O2
121 ifndef CXXFLAGS_FOR_BUILD
122 CXXFLAGS_FOR_BUILD
:=-g
-O2
124 ifndef FCFLAGS_FOR_BUILD
125 FCFLAGS_FOR_BUILD
:=-g
-O2
127 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
130 ifeq ($(BR2_HAVE_DOT_CONFIG
),y
)
133 # Usage: cflags-y+=$(call cc-option, -march=winchip-c6, -march=i586)
134 # sets -march=winchip-c6 if supported else falls back to -march=i586
135 # without checking the latter.
136 cc-option
=$(shell if
$(TARGET_CC
) $(TARGET_CFLAGS
) $(1) -S
-o
/dev
/null
-xc
/dev
/null \
137 > /dev
/null
2>&1; then echo
"$(1)"; else echo
"$(2)"; fi
;)
139 #############################################################
141 # Hide troublesome environment variables from sub processes
143 #############################################################
144 unexport CROSS_COMPILE
147 #############################################################
149 # Setup the proper filename extensions for the host
151 ##############################################################
152 ifneq ($(findstring linux
,$(BR2_GNU_BUILD_SUFFIX
)),)
157 ifneq ($(findstring apple
,$(BR2_GNU_BUILD_SUFFIX
)),)
162 ifneq ($(findstring cygwin
,$(BR2_GNU_BUILD_SUFFIX
)),)
167 ifneq ($(findstring mingw
,$(BR2_GNU_BUILD_SUFFIX
)),)
173 # The preferred type of libs we build for the target
174 ifeq ($(BR2_PREFER_STATIC_LIB
),y
)
176 #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
179 #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
181 PREFERRED_LIB_FLAGS
:=--enable-static
--enable-shared
183 ##############################################################
185 # The list of stuff to build for the target toolchain
186 # along with the packages to build for the target.
188 ##############################################################
189 ifeq ($(BR2_TOOLCHAIN_SOURCE
),y
)
190 BASE_TARGETS
:=uclibc-configured binutils cross_compiler uclibc-target-utils
197 include project
/Makefile.in
199 BR2_DEPENDS_DIR
=$(PROJECT_BUILD_DIR
)/buildroot-config
201 include toolchain
/Makefile.in
202 include package
/Makefile.in
204 #############################################################
206 # You should probably leave this stuff alone unless you know
207 # what you are doing.
209 #############################################################
213 # In this section, we need .config
218 # We also need the various per-package makefiles, which also add
219 # each selected package to TARGETS if that package was selected
220 # in the .config file.
221 ifeq ($(BR2_TOOLCHAIN_SOURCE
),y
)
222 # avoid pulling in external toolchain which is broken for toplvl parallel builds
224 include toolchain
/dependencies
/dependencies.mk
225 include toolchain
/binutils
/binutils.mk
226 include toolchain
/ccache
/ccache.mk
227 include toolchain
/elf2flt
/elf2flt.mk
228 include toolchain
/gcc
/gcc-uclibc-3.x.mk
229 include toolchain
/gcc
/gcc-uclibc-4.x.mk
230 include toolchain
/gdb
/gdb.mk
231 include toolchain
/kernel-headers
/kernel-headers.mk
232 include toolchain
/mklibs
/mklibs.mk
233 include toolchain
/sstrip
/sstrip.mk
234 include toolchain
/uClibc
/uclibc.mk
236 include toolchain
/*/*.mk
239 ifeq ($(BR2_PACKAGE_LINUX
),y
)
240 TARGETS
+=linux26-modules
243 include package
/*/*.mk
245 # target stuff is last so it can override anything else
246 include target
/Makefile.in
248 TARGETS
+=erase-fakeroots
250 TARGETS_CLEAN
:=$(patsubst %,%-clean,$(TARGETS
))
251 TARGETS_SOURCE
:=$(patsubst %,%-source
,$(TARGETS
) $(BASE_TARGETS
))
252 TARGETS_DIRCLEAN
:=$(patsubst %,%-dirclean
,$(TARGETS
))
253 TARGETS_ALL
:=$(patsubst %,__real_tgt_
%,$(TARGETS
))
254 # all targets depend on the crosscompiler and it's prerequisites
255 $(TARGETS_ALL
): __real_tgt_
%: $(BASE_TARGETS
) %
257 $(BR2_DEPENDS_DIR
): .config
260 cp
-dpRf
$(CONFIG
)/buildroot-config
$@
262 dirs
: $(DL_DIR
) $(TOOL_BUILD_DIR
) $(BUILD_DIR
) $(STAGING_DIR
) $(TARGET_DIR
) \
264 $(BINARIES_DIR
) $(PROJECT_BUILD_DIR
)
266 $(BASE_TARGETS
): dirs
268 world
: dependencies dirs target-host-info
$(BASE_TARGETS
) $(TARGETS_ALL
)
271 .PHONY
: all world dirs
clean dirclean
distclean source \
272 $(BASE_TARGETS
) $(TARGETS
) $(TARGETS_ALL
) \
273 $(TARGETS_CLEAN
) $(TARGETS_DIRCLEAN
) $(TARGETS_SOURCE
) \
274 $(DL_DIR
) $(TOOL_BUILD_DIR
) $(BUILD_DIR
) $(STAGING_DIR
) $(TARGET_DIR
) \
276 $(BINARIES_DIR
) $(PROJECT_BUILD_DIR
)
278 #############################################################
280 # staging and target directories do NOT list these as
281 # dependencies anywhere else
283 #############################################################
284 $(DL_DIR
) $(TOOL_BUILD_DIR
) $(BUILD_DIR
) \
285 $(PROJECT_BUILD_DIR
) $(BINARIES_DIR
):
289 @mkdir
-p
$(STAGING_DIR
)/bin
290 @mkdir
-p
$(STAGING_DIR
)/lib
291 ifeq ($(BR2_TOOLCHAIN_SYSROOT
),y
)
292 @mkdir
-p
$(STAGING_DIR
)/usr
/lib
294 @if
test ! -L
$(STAGING_DIR
)/usr
&& test -d
$(STAGING_DIR
)/usr
; then \
295 echo
"You seem to be coming from a toolchain with sysroot support."; \
296 echo
"Reconfiguring without wiping your rootfs will not work, sorry.";\
297 echo
"Please 'rm -rf $(STAGING_DIR)'"; \
298 echo
"Then run 'make' again."; \
302 ln
-snf .
$(STAGING_DIR
)/usr
303 @mkdir
-p
$(STAGING_DIR
)/usr
/$(REAL_GNU_TARGET_NAME
)
304 ln
-snf ..
/lib
$(STAGING_DIR
)/usr
/lib
305 ln
-snf ..
/lib
$(STAGING_DIR
)/usr
/$(REAL_GNU_TARGET_NAME
)/lib
307 @mkdir
-p
$(STAGING_DIR
)/usr
/include
309 $(PROJECT_BUILD_DIR
)/.root
:
310 mkdir
-p
$(TARGET_DIR
)
311 if
! [ -d
"$(TARGET_DIR)/bin" ]; then \
312 if
[ -d
"$(TARGET_SKELETON)" ]; then \
313 cp
-fa
$(TARGET_SKELETON
)/* $(TARGET_DIR
)/; \
315 touch
$(STAGING_DIR
)/.fakeroot
.00000; \
317 -find
$(TARGET_DIR
) -type d
-name CVS | xargs
rm -rf
318 -find
$(TARGET_DIR
) -type d
-name .svn | xargs
rm -rf
319 -find
$(TARGET_DIR
) -type d
-name .gitignore | xargs
rm -rf
322 $(TARGET_DIR
): $(PROJECT_BUILD_DIR
)/.root
325 rm -f
$(PROJECT_BUILD_DIR
)/.fakeroot
*
327 source
: $(TARGETS_SOURCE
) $(HOST_SOURCE
)
330 $(MAKE
) SPIDER
=--spider source
332 #############################################################
334 # Cleanup and misc junk
336 #############################################################
337 clean: $(TARGETS_CLEAN
)
338 rm -rf
$(STAGING_DIR
) $(TARGET_DIR
) $(IMAGE
)
340 dirclean
: $(TARGETS_DIRCLEAN
)
341 rm -rf
$(STAGING_DIR
) $(TARGET_DIR
) $(IMAGE
)
344 ifeq ($(DL_DIR
),$(BASE_DIR
)/dl
)
347 rm -rf
$(BUILD_DIR
) $(PROJECT_BUILD_DIR
) $(BINARIES_DIR
) \
348 $(LINUX_KERNEL
) $(IMAGE
) $(BASE_DIR
)/include \
350 $(MAKE
) -C
$(CONFIG
) clean distclean
353 rm -rf
$(BUILD_DIR
) $(PROJECT_BUILD_DIR
) $(BINARIES_DIR
)
356 rm -f buildroot.
tar.bz2
; \
357 tar -cvf buildroot.
tar buildroot
; \
358 bzip2
-9 buildroot.
tar; \
361 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
366 # ---------------------------------------------------------------------------
368 HOSTCFLAGS
=$(CFLAGS_FOR_BUILD
)
372 @mkdir
-p
$(CONFIG
)/buildroot-config
373 $(MAKE
) CC
="$(HOSTCC)" -C
$(CONFIG
) conf
374 -@if
[ ! -f .config
]; then \
375 cp
$(CONFIG_DEFCONFIG
) .config
; \
378 @mkdir
-p
$(CONFIG
)/buildroot-config
379 $(MAKE
) CC
="$(HOSTCC)" -C
$(CONFIG
) conf mconf
380 -@if
[ ! -f .config
]; then \
381 cp
$(CONFIG_DEFCONFIG
) .config
; \
384 menuconfig
: $(CONFIG
)/mconf
385 @mkdir
-p
$(CONFIG
)/buildroot-config
386 @if
! KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
387 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
388 $(CONFIG
)/mconf
$(CONFIG_CONFIG_IN
); then \
389 test -f .config.cmd ||
rm -f .config
; \
392 config
: $(CONFIG
)/conf
393 @mkdir
-p
$(CONFIG
)/buildroot-config
394 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
395 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
396 $(CONFIG
)/conf
$(CONFIG_CONFIG_IN
)
398 oldconfig
: $(CONFIG
)/conf
399 @mkdir
-p
$(CONFIG
)/buildroot-config
400 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
401 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
402 $(CONFIG
)/conf
-o
$(CONFIG_CONFIG_IN
)
404 randconfig
: $(CONFIG
)/conf
405 @mkdir
-p
$(CONFIG
)/buildroot-config
406 @KCONFIG_AUTOCONFIG
=$(CONFIG
)/buildroot-config
/auto.conf \
407 KCONFIG_AUTOHEADER
=$(CONFIG
)/buildroot-config
/autoconf.h \
408 $(CONFIG
)/conf
-r
$(CONFIG_CONFIG_IN
)
410 allyesconfig
: $(CONFIG
)/conf
411 cat
$(CONFIG_DEFCONFIG
) > .config
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
-y
$(CONFIG_CONFIG_IN
)
416 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
418 allnoconfig
: $(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
-n
$(CONFIG_CONFIG_IN
)
424 defconfig
: $(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
-d
$(CONFIG_CONFIG_IN
)
430 # check if download URLs are outdated
431 source-check
: allyesconfig
432 $(MAKE
) _source-check
434 #############################################################
436 # Cleanup and misc junk
438 #############################################################
440 rm -f .config .config.old .config.cmd .tmpconfig.h
441 -$(MAKE
) -C
$(CONFIG
) clean
446 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
448 %_defconfig
: $(CONFIG
)/conf
449 cp
$(shell find .
/target
/ -name
$@
) .config
452 configured
: dirs host-sed kernel-headers uclibc-config busybox-config linux26-config
454 cross
: $(BASE_TARGETS
)
458 @echo
' clean - delete temporary files created by build'
459 @echo
' distclean - delete all non-source files (including .config)'
462 @echo
' all - make world'
464 @echo
'Configuration:'
465 @echo
' menuconfig - interactive curses-based configurator'
466 @echo
' oldconfig - resolve any unresolved symbols in .config'
468 @echo
'Miscellaneous:'
469 @echo
' source - download all sources needed for offline-build'
470 @echo
' source-check - check all packages for valid download URLs'
472 @echo
'See docs/README and docs/buildroot.html for further details'
475 .PHONY
: dummy subdirs release
distclean clean config oldconfig \
476 menuconfig
tags check test depend defconfig help