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
27 CONFIG = package/config
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)),)
38 -include $(TOPDIR).config
40 ifneq ($(BUILDROOT_DL_DIR),)
41 BR2_DL_DIR:=$(BUILDROOT_DL_DIR)
44 # To put more focus on warnings, be less verbose as default
45 # Use 'make V=1' to see the full commands
47 ifeq ("$(origin V)", "command line")
55 ifeq ($(KBUILD_VERBOSE),1)
63 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
64 else if [ -x /bin/bash ]; then echo /bin/bash; \
65 else echo sh; fi ; fi)
67 export CONFIG_SHELL quiet Q KBUILD_VERBOSE
88 HOSTAR :=$(shell $(CONFIG_SHELL) -c "which $(HOSTAR)" || type -p $(HOSTAR) || echo ar)
89 HOSTAS :=$(shell $(CONFIG_SHELL) -c "which $(HOSTAS)" || type -p $(HOSTAS) || echo as)
90 HOSTCC :=$(shell $(CONFIG_SHELL) -c "which $(HOSTCC)" || type -p $(HOSTCC) || echo gcc)
91 HOSTCXX:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCXX)" || type -p $(HOSTCXX) || echo g++)
92 HOSTLD :=$(shell $(CONFIG_SHELL) -c "which $(HOSTLD)" || type -p $(HOSTLD) || echo ld)
93 HOSTLN :=$(shell $(CONFIG_SHELL) -c "which $(HOSTLN)" || type -p $(HOSTLN) || echo ln)
94 ifndef CFLAGS_FOR_BUILD
95 CFLAGS_FOR_BUILD:=-g -O2
97 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
100 ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
103 # Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
104 # sets -march=winchip-c6 if supported else falls back to -march=i586
105 # without checking the latter.
106 cc-option = $(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
107 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
109 #############################################################
111 # Hide troublesome environment variables from sub processes
113 #############################################################
114 unexport CROSS_COMPILE
117 #############################################################
119 # Setup the proper filename extensions for the host
121 ##############################################################
122 ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
127 ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
132 ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
137 ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
143 # The preferred type of libs we build for the target
144 ifeq ($(BR2_PREFER_STATIC_LIB),y)
146 #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
149 #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
151 PREFERRED_LIB_FLAGS:=--enable-static --enable-shared
153 BR2_DEPENDS_DIR=$(BASE_DIR)/package/config/buildroot-config/
155 ##############################################################
157 # The list of stuff to build for the target toolchain
158 # along with the packages to build for the target.
160 ##############################################################
161 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
162 BASE_TARGETS:=uclibc-configured binutils gcc uclibc-target-utils
168 include project/Makefile.in
169 include toolchain/Makefile.in
170 include package/Makefile.in
172 #############################################################
174 # You should probably leave this stuff alone unless you know
175 # what you are doing.
177 #############################################################
181 # In this section, we need .config
186 # We also need the various per-package makefiles, which also add
187 # each selected package to TARGETS if that package was selected
188 # in the .config file.
189 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
190 # avoid pulling in external toolchain which is broken for toplvl parallel builds
191 include $(filter-out $(wildcard toolchain/external-toolchain/*),$(wildcard toolchain/*/*.mk))
193 include toolchain/*/*.mk
196 ifeq ($(BR2_PACKAGE_LINUX),y)
197 TARGETS+=linux26-modules
200 include package/*/*.mk
202 # target stuff is last so it can override anything else
203 include target/Makefile.in
205 TARGETS+=erase-fakeroots
207 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
208 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS))
209 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
211 # all targets depend on the crosscompiler and it's prerequisites
212 $(TARGETS): $(BASE_TARGETS)
214 dirs: $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
215 $(BINARIES_DIR) $(PROJECT_BUILD_DIR)
217 $(BASE_TARGETS): dirs
219 world: dependencies dirs target-host-info $(BASE_TARGETS) $(TARGETS)
222 .PHONY: all world dirs clean dirclean distclean source \
223 $(BASE_TARGETS) $(TARGETS) \
224 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
225 $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
226 $(BINARIES_DIR) $(PROJECT_BUILD_DIR)
228 #############################################################
230 # staging and target directories do NOT list these as
231 # dependencies anywhere else
233 #############################################################
234 $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) \
235 $(PROJECT_BUILD_DIR) $(BINARIES_DIR):
239 @mkdir -p $(STAGING_DIR)/bin
240 @mkdir -p $(STAGING_DIR)/lib
241 ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
242 @mkdir -p $(STAGING_DIR)/usr/lib
244 @ln -snf . $(STAGING_DIR)/usr
245 @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)
246 @ln -snf ../lib $(STAGING_DIR)/usr/lib
247 @ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
249 @mkdir -p $(STAGING_DIR)/usr/include
251 $(PROJECT_BUILD_DIR)/.root:
252 mkdir -p $(TARGET_DIR)
253 if ! [ -d "$(TARGET_DIR)/bin" ] ; then \
254 if [ -d "$(TARGET_SKELETON)" ] ; then \
255 cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
257 touch $(STAGING_DIR)/.fakeroot.00000 ; \
258 -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf ; \
259 -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf ; \
263 $(TARGET_DIR): $(PROJECT_BUILD_DIR)/.root
266 rm -f $(PROJECT_BUILD_DIR)/.fakeroot*
268 source: $(TARGETS_SOURCE) $(HOST_SOURCE)
271 $(MAKE) SPIDER=--spider source
273 #############################################################
275 # Cleanup and misc junk
277 #############################################################
278 clean: $(TARGETS_CLEAN)
279 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
281 dirclean: $(TARGETS_DIRCLEAN)
282 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
285 ifeq ($(DL_DIR),$(BASE_DIR)/dl)
288 rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR) \
289 $(LINUX_KERNEL) $(IMAGE) $(BASE_DIR)/include \
291 $(MAKE) -C $(CONFIG) clean
294 rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR)
297 rm -f buildroot.tar.bz2; \
298 tar -cvf buildroot.tar buildroot; \
299 bzip2 -9 buildroot.tar; \
302 else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
307 # ---------------------------------------------------------------------------
309 HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
313 $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf
314 -@if [ ! -f .config ] ; then \
315 cp $(CONFIG_DEFCONFIG) .config; \
318 $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf mconf
319 -@if [ ! -f .config ] ; then \
320 cp $(CONFIG_DEFCONFIG) .config; \
323 menuconfig: $(CONFIG)/mconf
324 @-mkdir -p $(CONFIG)/buildroot-config
325 @if ! KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
326 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
327 $(CONFIG)/mconf $(CONFIG_CONFIG_IN); then \
328 test -f .config.cmd || rm -f .config; \
331 config: $(CONFIG)/conf
332 @-mkdir -p $(CONFIG)/buildroot-config
333 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
334 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
335 $(CONFIG)/conf $(CONFIG_CONFIG_IN)
337 oldconfig: $(CONFIG)/conf
338 @-mkdir -p $(CONFIG)/buildroot-config
339 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
340 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
341 $(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
343 randconfig: $(CONFIG)/conf
344 @-mkdir -p $(CONFIG)/buildroot-config
345 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
346 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
347 $(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
349 allyesconfig: $(CONFIG)/conf
350 cat $(CONFIG_DEFCONFIG) > .config
351 @-mkdir -p $(CONFIG)/buildroot-config
352 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
353 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
354 $(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
355 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
357 allnoconfig: $(CONFIG)/conf
358 @-mkdir -p $(CONFIG)/buildroot-config
359 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
360 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
361 $(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
363 defconfig: $(CONFIG)/conf
364 @-mkdir -p $(CONFIG)/buildroot-config
365 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
366 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
367 $(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
369 # check if download URLs are outdated
370 source-check: allyesconfig
371 $(MAKE) _source-check
373 #############################################################
375 # Cleanup and misc junk
377 #############################################################
379 rm -f .config .config.old .config.cmd .tmpconfig.h
380 - $(MAKE) -C $(CONFIG) clean
385 endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
387 %_defconfig: $(CONFIG)/conf
388 cp $(shell find ./target/ -name $@) .config
389 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
393 @echo ' clean - delete temporary files created by build'
394 @echo ' distclean - delete all non-source files (including .config)'
397 @echo ' all - make world'
399 @echo 'Configuration:'
400 @echo ' menuconfig - interactive curses-based configurator'
401 @echo ' oldconfig - resolve any unresolved symbols in .config'
403 @echo 'Miscellaneous:'
404 @echo ' source - download all sources needed for offline-build'
405 @echo ' source-check - check all packages for valid download URLS'
408 .PHONY: dummy subdirs release distclean clean config oldconfig \
409 menuconfig tags check test depend defconfig help