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
29 noconfig_targets := menuconfig config oldconfig randconfig \
30 defconfig allyesconfig allnoconfig release tags \
33 # $(shell find . -name *_defconfig |sed 's/.*\///')
35 # Pull in the user's configuration file
36 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
37 -include $(TOPDIR).config
40 # To put more focus on warnings, be less verbose as default
41 # Use 'make V=1' to see the full commands
43 ifeq ("$(origin V)", "command line")
51 ifeq ($(KBUILD_VERBOSE),1)
59 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
60 else if [ -x /bin/bash ]; then echo /bin/bash; \
61 else echo sh; fi ; fi)
63 export CONFIG_SHELL quiet Q KBUILD_VERBOSE
81 HOSTAR:=$(shell $(CONFIG_SHELL) which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
82 HOSTAS:=$(shell $(CONFIG_SHELL) which $(HOSTAS) || type -p $(HOSTAS) || echo as)
83 HOSTCC:=$(shell $(CONFIG_SHELL) which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
84 HOSTCXX:=$(shell $(CONFIG_SHELL) which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
85 HOSTLD:=$(shell $(CONFIG_SHELL) which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
86 ifndef CFLAGS_FOR_BUILD
87 CFLAGS_FOR_BUILD:="-g -O2"
89 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
92 ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
95 # Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
96 # sets -march=winchip-c6 if supported else falls back to -march=i586
97 # without checking the latter.
98 cc-option = $(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
99 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
101 #############################################################
103 # Hide troublesome environment variables from sub processes
105 #############################################################
106 unexport CROSS_COMPILE
109 #############################################################
111 # Setup the proper filename extensions for the host
113 ##############################################################
114 ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
119 ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
124 ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
129 ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
135 # The preferred type of libs we build for the target
136 ifeq ($(BR2_PREFER_STATIC_LIB),y)
138 #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
141 #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
143 PREFERRED_LIB_FLAGS:=--enable-static --enable-shared
146 #############################################################
148 # The list of stuff to build for the target toolchain
149 # along with the packages to build for the target.
151 ##############################################################
152 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
153 TARGETS:=uclibc-configured binutils gcc uclibc-target-utils
157 include toolchain/Makefile.in
158 include package/Makefile.in
160 #############################################################
162 # You should probably leave this stuff alone unless you know
163 # what you are doing.
165 #############################################################
169 # In this section, we need .config
172 # We also need the various per-package makefiles, which also add
173 # each selected package to TARGETS if that package was selected
174 # in the .config file.
175 include toolchain/*/*.mk
176 include package/*/*.mk
178 # target stuff is last so it can override anything else
179 include target/Makefile.in
181 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
182 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS))
183 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
185 world: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) $(TARGETS)
186 dirs: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR)
188 .PHONY: all world dirs clean dirclean distclean source $(TARGETS) \
189 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
190 $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
192 #############################################################
194 # staging and target directories do NOT list these as
195 # dependencies anywhere else
197 #############################################################
198 $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR):
202 @mkdir -p $(STAGING_DIR)/bin
203 @mkdir -p $(STAGING_DIR)/lib
204 ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
205 @mkdir -p $(STAGING_DIR)/usr/lib
207 @ln -snf . $(STAGING_DIR)/usr
208 @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)
209 @ln -snf ../lib $(STAGING_DIR)/usr/lib
210 @ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
212 @mkdir -p $(STAGING_DIR)/usr/include
215 mkdir -p $(TARGET_DIR)
216 if [ -d "$(TARGET_SKELETON)" ] ; then \
217 cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
219 touch $(STAGING_DIR)/.fakeroot.00000
220 -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf
221 -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf
223 source: $(TARGETS_SOURCE) $(HOST_SOURCE)
225 .config.check: dependencies
226 $(SED) '/BR2_WGET/s/\"$$/ --spider\"/g' .config
229 _source-check: .config.check
232 #############################################################
234 # Cleanup and misc junk
236 #############################################################
237 clean: $(TARGETS_CLEAN)
238 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
240 dirclean: $(TARGETS_DIRCLEAN)
241 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
244 ifeq ($(DL_DIR),$(BASE_DIR)/dl)
247 rm -rf $(BUILD_DIR) $(LINUX_KERNEL) $(IMAGE)
248 $(MAKE) -C $(CONFIG) clean
254 rm -f buildroot.tar.bz2; \
255 tar -cvf buildroot.tar buildroot; \
256 bzip2 -9 buildroot.tar; \
259 else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
264 # ---------------------------------------------------------------------------
267 $(MAKE) CC="$(HOSTCC)" CFLAGS=$(CFLAGS_FOR_BUILD) MAKECMDGOALS="$(MAKECMDGOALS)" \
269 -@if [ ! -f .config ] ; then \
270 cp $(CONFIG_DEFCONFIG) .config; \
273 $(MAKE) CC="$(HOSTCC)" CFLAGS=$(CFLAGS_FOR_BUILD) MAKECMDGOALS="$(MAKECMDGOALS)" \
274 -C $(CONFIG) conf mconf
275 -@if [ ! -f .config ] ; then \
276 cp $(CONFIG_DEFCONFIG) .config; \
279 menuconfig: $(CONFIG)/mconf
280 @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
282 config: $(CONFIG)/conf
283 @$(CONFIG)/conf $(CONFIG_CONFIG_IN)
285 oldconfig: $(CONFIG)/conf
286 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
288 randconfig: $(CONFIG)/conf
289 @$(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
291 allyesconfig: $(CONFIG)/conf
292 cp $(CONFIG_DEFCONFIG) .config
293 @$(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
294 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
296 allnoconfig: $(CONFIG)/conf
297 @$(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
299 defconfig: $(CONFIG)/conf
300 @$(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
302 # check if download URLs are outdated
303 source-check: allyesconfig
304 $(MAKE) _source-check
306 #############################################################
308 # Cleanup and misc junk
310 #############################################################
312 rm -f .config .config.old .config.cmd .tmpconfig.h
313 - $(MAKE) -C $(CONFIG) clean
318 endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
320 %_defconfig: $(CONFIG)/conf
321 cp $(shell find ./target/ -name $@) .config
322 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
325 .PHONY: dummy subdirs release distclean clean config oldconfig \
326 menuconfig tags check test depend defconfig