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 ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
43 # Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
44 # sets -march=winchip-c6 if supported else falls back to -march=i586
45 # without checking the latter.
46 cc-option = $(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
47 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
50 #############################################################
52 # Setup the proper filename extensions for the host
54 ##############################################################
55 ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
60 ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
65 ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
70 ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
76 # The preferred type of libs we build for the target
77 ifeq ($(BR2_PREFER_STATIC_LIB),y)
84 #############################################################
86 # The list of stuff to build for the target toolchain
87 # along with the packages to build for the target.
89 ##############################################################
90 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
91 TARGETS:=uclibc-configured binutils gcc uclibc-target-utils
95 include toolchain/Makefile.in
96 include package/Makefile.in
98 #############################################################
100 # You should probably leave this stuff alone unless you know
101 # what you are doing.
103 #############################################################
107 # In this section, we need .config
110 # We also need the various per-package makefiles, which also add
111 # each selected package to TARGETS if that package was selected
112 # in the .config file.
113 include toolchain/*/*.mk
114 include package/*/*.mk
116 # target stuff is last so it can override anything else
117 include target/Makefile.in
119 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
120 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS))
121 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
123 world: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) $(TARGETS)
124 dirs: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR)
126 .PHONY: all world dirs clean dirclean distclean source $(TARGETS) \
127 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
128 $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
130 #############################################################
132 # staging and target directories do NOT list these as
133 # dependencies anywhere else
135 #############################################################
136 $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR):
140 @mkdir -p $(STAGING_DIR)/bin
141 @mkdir -p $(STAGING_DIR)/lib
142 @mkdir -p $(STAGING_DIR)/include
143 @mkdir -p $(STAGING_DIR)/usr
144 @mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)
145 @ln -snf ../include $(STAGING_DIR)/usr/include
146 @ln -snf ../lib $(STAGING_DIR)/usr/lib
147 @ln -snf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
150 mkdir -p $(TARGET_DIR)
151 if [ -d "$(TARGET_SKELETON)" ] ; then \
152 cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
154 touch $(STAGING_DIR)/.fakeroot.00000
155 -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf
156 -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf
158 source: $(TARGETS_SOURCE) $(HOST_SOURCE)
160 .config.check: dependencies
161 $(SED) '/BR2_WGET/s/\"$$/ --spider\"/g' .config
164 _source-check: .config.check
167 #############################################################
169 # Cleanup and misc junk
171 #############################################################
172 clean: $(TARGETS_CLEAN)
173 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
175 dirclean: $(TARGETS_DIRCLEAN)
176 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
179 ifeq ($(DL_DIR),$(BASE_DIR)/dl)
182 rm -rf $(BUILD_DIR) $(LINUX_KERNEL) $(IMAGE)
183 $(MAKE) -C $(CONFIG) clean
189 rm -f buildroot.tar.bz2; \
190 tar -cvf buildroot.tar buildroot; \
191 bzip2 -9 buildroot.tar; \
194 else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
199 # ---------------------------------------------------------------------------
202 $(MAKE) -C $(CONFIG) conf
203 -@if [ ! -f .config ] ; then \
204 cp $(CONFIG_DEFCONFIG) .config; \
207 $(MAKE) -C $(CONFIG) ncurses conf mconf
208 -@if [ ! -f .config ] ; then \
209 cp $(CONFIG_DEFCONFIG) .config; \
212 menuconfig: $(CONFIG)/mconf
213 @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
215 config: $(CONFIG)/conf
216 @$(CONFIG)/conf $(CONFIG_CONFIG_IN)
218 oldconfig: $(CONFIG)/conf
219 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
221 randconfig: $(CONFIG)/conf
222 @$(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
224 allyesconfig: $(CONFIG)/conf
225 cp $(CONFIG_DEFCONFIG) .config
226 @$(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
227 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
229 allnoconfig: $(CONFIG)/conf
230 @$(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
232 defconfig: $(CONFIG)/conf
233 @$(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
235 %_defconfig: $(CONFIG)/conf
236 cp $(shell find . -name $@) .config
237 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
239 # check if download URLs are outdated
240 source-check: allyesconfig
241 $(MAKE) _source-check
243 #############################################################
245 # Cleanup and misc junk
247 #############################################################
249 rm -f .config .config.old .config.cmd .tmpconfig.h
250 - $(MAKE) -C $(CONFIG) clean
255 endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
257 .PHONY: dummy subdirs release distclean clean config oldconfig \
258 menuconfig tags check test depend defconfig