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
41 # To put more focus on warnings, be less verbose as default
42 # Use 'make V=1' to see the full commands
44 ifeq ("$(origin V)", "command line")
52 ifeq ($(KBUILD_VERBOSE),1)
60 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
61 else if [ -x /bin/bash ]; then echo /bin/bash; \
62 else echo sh; fi ; fi)
64 export CONFIG_SHELL quiet Q KBUILD_VERBOSE
82 HOSTAR :=$(shell $(CONFIG_SHELL) -c "which $(HOSTAR)" || type -p $(HOSTAR) || echo ar)
83 HOSTAS :=$(shell $(CONFIG_SHELL) -c "which $(HOSTAS)" || type -p $(HOSTAS) || echo as)
84 HOSTCC :=$(shell $(CONFIG_SHELL) -c "which $(HOSTCC)" || type -p $(HOSTCC) || echo gcc)
85 HOSTCXX:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCXX)" || type -p $(HOSTCXX) || echo g++)
86 HOSTLD :=$(shell $(CONFIG_SHELL) -c "which $(HOSTLD)" || type -p $(HOSTLD) || echo ld)
87 ifndef CFLAGS_FOR_BUILD
88 CFLAGS_FOR_BUILD:=-g -O2
90 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
93 ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
96 # Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
97 # sets -march=winchip-c6 if supported else falls back to -march=i586
98 # without checking the latter.
99 cc-option = $(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
100 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
102 #############################################################
104 # Hide troublesome environment variables from sub processes
106 #############################################################
107 unexport CROSS_COMPILE
110 #############################################################
112 # Setup the proper filename extensions for the host
114 ##############################################################
115 ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
120 ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
125 ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
130 ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
136 # The preferred type of libs we build for the target
137 ifeq ($(BR2_PREFER_STATIC_LIB),y)
139 #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
142 #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
144 PREFERRED_LIB_FLAGS:=--enable-static --enable-shared
147 #############################################################
149 # The list of stuff to build for the target toolchain
150 # along with the packages to build for the target.
152 ##############################################################
153 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
154 TARGETS:=uclibc-configured binutils gcc uclibc-target-utils
159 PROJECT:=$(strip $(subst ",,$(BR2_PROJECT))) # "))
160 TARGET_HOSTNAME:=$(strip $(subst ",,$(BR2_HOSTNAME))) # " ))
161 BANNER:=$(strip $(subst ",,$(BR2_BANNER))) # " ))
164 include toolchain/Makefile.in
165 include package/Makefile.in
167 #############################################################
169 # You should probably leave this stuff alone unless you know
170 # what you are doing.
172 #############################################################
176 # In this section, we need .config
179 # We also need the various per-package makefiles, which also add
180 # each selected package to TARGETS if that package was selected
181 # in the .config file.
182 include toolchain/*/*.mk
183 include package/*/*.mk
185 # target stuff is last so it can override anything else
186 include target/Makefile.in
188 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
189 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS))
190 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
192 world: $(DL_DIR) $(BUILD_DIR) $(PROJECT_BUILD_DIR) \
193 $(BINARIES_DIR) $(STAGING_DIR) $(TARGET_DIR) bsp $(TARGETS)
194 dirs: $(DL_DIR) $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(STAGING_DIR)
196 .PHONY: all world dirs clean dirclean distclean source bsp $(TARGETS) \
197 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
198 $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR) \
199 $(PROJECT_BUILD_DIR) $(BINARIES_DIR)
201 #############################################################
203 # staging and target directories do NOT list these as
204 # dependencies anywhere else
206 #############################################################
207 $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) \
208 $(PROJECT_BUILD_DIR) $(BINARIES_DIR) :
212 @mkdir -p $(STAGING_DIR)/bin
213 @mkdir -p $(STAGING_DIR)/lib
214 ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
215 @mkdir -p $(STAGING_DIR)/usr/lib
217 @ln -snf . $(STAGING_DIR)/usr
218 @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)
219 @ln -snf ../lib $(STAGING_DIR)/usr/lib
220 @ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
222 @mkdir -p $(STAGING_DIR)/usr/include
225 mkdir -p $(TARGET_DIR)
226 if [ -d "$(TARGET_SKELETON)" ] ; then \
227 cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
229 touch $(STAGING_DIR)/.fakeroot.00000
230 -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf
231 -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf
233 bsp: $(TARGET_DIR)/etc/issue $(TARGET_DIR)/etc/hostname
235 $(TARGET_DIR)/etc/issue: $(TARGET_DIR) .config
236 echo "" > $(TARGET_DIR)/etc/issue
237 echo "" >> $(TARGET_DIR)/etc/issue
238 echo "$(BANNER)" >> $(TARGET_DIR)/etc/issue
240 $(TARGET_DIR)/etc/hostname: $(TARGET_DIR) .config
241 echo "$(TARGET_HOSTNAME)" > $(TARGET_DIR)/etc/hostname
243 source: $(TARGETS_SOURCE) $(HOST_SOURCE)
245 .config.check: dependencies
246 $(SED) '/BR2_WGET/s/\"$$/ --spider\"/g' .config
249 _source-check: .config.check
252 #############################################################
254 # Cleanup and misc junk
256 #############################################################
257 clean: $(TARGETS_CLEAN)
258 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
260 dirclean: $(TARGETS_DIRCLEAN)
261 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
264 ifeq ($(DL_DIR),$(BASE_DIR)/dl)
267 rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR) \
268 $(LINUX_KERNEL) $(IMAGE) $(BASE_DIR)/include \
270 $(MAKE) -C $(CONFIG) clean
273 rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR)
276 rm -f buildroot.tar.bz2; \
277 tar -cvf buildroot.tar buildroot; \
278 bzip2 -9 buildroot.tar; \
281 else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
286 # ---------------------------------------------------------------------------
288 HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
292 $(MAKE) CC="$(HOSTCC)" MAKECMDGOALS="$(MAKECMDGOALS)" \
294 -@if [ ! -f .config ] ; then \
295 cp $(CONFIG_DEFCONFIG) .config; \
298 $(MAKE) CC="$(HOSTCC)" MAKECMDGOALS="$(MAKECMDGOALS)" \
299 -C $(CONFIG) conf mconf
300 -@if [ ! -f .config ] ; then \
301 cp $(CONFIG_DEFCONFIG) .config; \
304 menuconfig: $(CONFIG)/mconf
305 @-mkdir -p include/config
306 @KCONFIG_AUTOCONFIG=include/config/auto.conf \
307 KCONFIG_AUTOHEADER=include/autoconf.h \
308 $(CONFIG)/mconf $(CONFIG_CONFIG_IN)
310 config: $(CONFIG)/conf
311 @-mkdir -p include/config
312 @KCONFIG_AUTOCONFIG=include/config/auto.conf \
313 KCONFIG_AUTOHEADER=include/autoconf.h \
314 $(CONFIG)/conf $(CONFIG_CONFIG_IN)
316 oldconfig: $(CONFIG)/conf
317 @-mkdir -p include/config
318 @KCONFIG_AUTOCONFIG=include/config/auto.conf \
319 KCONFIG_AUTOHEADER=include/autoconf.h \
320 $(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
322 randconfig: $(CONFIG)/conf
323 @-mkdir -p include/config
324 @KCONFIG_AUTOCONFIG=include/config/auto.conf \
325 KCONFIG_AUTOHEADER=include/autoconf.h \
326 $(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
328 allyesconfig: $(CONFIG)/conf
329 cat $(CONFIG_DEFCONFIG) > .config
330 @-mkdir -p include/config
331 @KCONFIG_AUTOCONFIG=include/config/auto.conf \
332 KCONFIG_AUTOHEADER=include/autoconf.h \
333 $(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
334 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
336 allnoconfig: $(CONFIG)/conf
337 @-mkdir -p include/config
338 @KCONFIG_AUTOCONFIG=include/config/auto.conf \
339 KCONFIG_AUTOHEADER=include/autoconf.h \
340 $(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
342 defconfig: $(CONFIG)/conf
343 @-mkdir -p include/config
344 @KCONFIG_AUTOCONFIG=include/config/auto.conf \
345 KCONFIG_AUTOHEADER=include/autoconf.h \
346 $(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
348 # check if download URLs are outdated
349 source-check: allyesconfig
350 $(MAKE) _source-check
352 #############################################################
354 # Cleanup and misc junk
356 #############################################################
358 rm -f .config .config.old .config.cmd .tmpconfig.h
359 - $(MAKE) -C $(CONFIG) clean
364 endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
366 %_defconfig: $(CONFIG)/conf
367 cp $(shell find ./target/ -name $@) .config
368 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
372 @echo ' clean - delete temporary files created by build'
373 @echo ' distclean - delete all non-source files (including .config)'
376 @echo ' all - make world'
378 @echo 'Configuration:'
379 @echo ' menuconfig - interactive curses-based configurator'
380 @echo ' oldconfig - resolve any unresolved symbols in .config'
382 @echo 'Miscellaneous:'
383 @echo ' source - download all sources needed for offline-build'
384 @echo ' source-check - check all packages for valid download URLS'
387 .PHONY: dummy subdirs release distclean clean config oldconfig \
388 menuconfig tags check test depend defconfig help