]> Git Repo - buildroot-mgba.git/blame - Makefile
- pull from upstream
[buildroot-mgba.git] / Makefile
CommitLineData
2d523c23 1# Makefile for buildroot2
ffde94bd 2#
15b26aee 3# Copyright (C) 1999-2005 by Erik Andersen <[email protected]>
ffde94bd 4#
08782ae7 5# This program is free software; you can redistribute it and/or modify
2d523c23
EA
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.
ffde94bd 9#
2d523c23
EA
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
08782ae7 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2d523c23 13# General Public License for more details.
ffde94bd 14#
2d523c23
EA
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
3ad3d8a1 18#
02bf5816 19
2d523c23
EA
20#--------------------------------------------------------------
21# Just run 'make menuconfig', configure stuff, then run 'make'.
22# You shouldn't need to mess with anything beyond this point...
23#--------------------------------------------------------------
24TOPDIR=./
25CONFIG_CONFIG_IN = Config.in
26CONFIG_DEFCONFIG = .defconfig
27CONFIG = package/config
a0aef7c4 28
2d523c23 29noconfig_targets := menuconfig config oldconfig randconfig \
0c1e709e 30 defconfig allyesconfig allnoconfig release tags \
e491fba2 31 source-check help
9e250356
BRF
32
33# $(shell find . -name *_defconfig |sed 's/.*\///')
cad58108 34
2d523c23
EA
35# Pull in the user's configuration file
36ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
37-include $(TOPDIR).config
38endif
9741a49e 39
afc61c6e
BRF
40# To put more focus on warnings, be less verbose as default
41# Use 'make V=1' to see the full commands
42ifdef V
43 ifeq ("$(origin V)", "command line")
44 KBUILD_VERBOSE = $(V)
45 endif
46endif
47ifndef KBUILD_VERBOSE
48 KBUILD_VERBOSE = 0
49endif
50
51ifeq ($(KBUILD_VERBOSE),1)
4df454e9 52 quiet=
afc61c6e
BRF
53 Q =
54else
55 quiet=quiet_
56 Q = @
57endif
58
59CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
60 else if [ -x /bin/bash ]; then echo /bin/bash; \
61 else echo sh; fi ; fi)
62
63export CONFIG_SHELL quiet Q KBUILD_VERBOSE
64
65ifndef HOSTAR
66HOSTAR:=ar
67endif
68ifndef HOSTAS
69HOSTAS:=as
70endif
71ifndef HOSTCC
72HOSTCC:=gcc
73else
74endif
75ifndef HOSTCXX
76HOSTCXX:=g++
77endif
78ifndef HOSTLD
79HOSTLD:=ld
80endif
83832cda
US
81HOSTAR :=$(shell $(CONFIG_SHELL) -c "which $(HOSTAR)" || type -p $(HOSTAR) || echo ar)
82HOSTAS :=$(shell $(CONFIG_SHELL) -c "which $(HOSTAS)" || type -p $(HOSTAS) || echo as)
83HOSTCC :=$(shell $(CONFIG_SHELL) -c "which $(HOSTCC)" || type -p $(HOSTCC) || echo gcc)
84HOSTCXX:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCXX)" || type -p $(HOSTCXX) || echo g++)
85HOSTLD :=$(shell $(CONFIG_SHELL) -c "which $(HOSTLD)" || type -p $(HOSTLD) || echo ld)
afc61c6e 86ifndef CFLAGS_FOR_BUILD
f987b7a5 87CFLAGS_FOR_BUILD:=-g -O2
afc61c6e
BRF
88endif
89export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
90
91
2d523c23 92ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
54e098e4 93
99cf7293
BRF
94# cc-option
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.
98cc-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 ;)
100
2c649045
PK
101#############################################################
102#
103# Hide troublesome environment variables from sub processes
104#
105#############################################################
106unexport CROSS_COMPILE
107unexport ARCH
27bc59d4 108
08782ae7
EA
109#############################################################
110#
c6e43c9d 111# Setup the proper filename extensions for the host
08782ae7 112#
7dcbbfbb
BRF
113##############################################################
114ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
c6e43c9d
BRF
115HOST_EXEEXT:=
116HOST_LIBEXT:=.a
117HOST_SHREXT:=.so
3096f34d 118endif
7dcbbfbb 119ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
c6e43c9d
BRF
120HOST_EXEEXT:=
121HOST_LIBEXT:=.a
122HOST_SHREXT:=.dylib
3096f34d 123endif
7dcbbfbb 124ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
c6e43c9d
BRF
125HOST_EXEEXT:=.exe
126HOST_LIBEXT:=.lib
127HOST_SHREXT:=.dll
3096f34d 128endif
7dcbbfbb 129ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
c6e43c9d
BRF
130HOST_EXEEXT:=.exe
131HOST_LIBEXT:=.lib
132HOST_SHREXT:=.dll
3096f34d 133endif
cb7d5b81 134
c6e43c9d 135# The preferred type of libs we build for the target
3096f34d 136ifeq ($(BR2_PREFER_STATIC_LIB),y)
c6e43c9d 137LIBTGTEXT=.a
8027784c 138#PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
3096f34d 139else
c6e43c9d 140LIBTGTEXT=.so
8027784c 141#PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
3096f34d 142endif
8027784c 143PREFERRED_LIB_FLAGS:=--enable-static --enable-shared
ffde94bd 144
7dcbbfbb 145
7dcbbfbb
BRF
146#############################################################
147#
148# The list of stuff to build for the target toolchain
149# along with the packages to build for the target.
150#
151##############################################################
152ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
153TARGETS:=uclibc-configured binutils gcc uclibc-target-utils
154else
155TARGETS:=uclibc
156endif
157include toolchain/Makefile.in
158include package/Makefile.in
159
160#############################################################
161#
162# You should probably leave this stuff alone unless you know
163# what you are doing.
164#
165#############################################################
166
08782ae7 167all: world
ffde94bd 168
2d523c23
EA
169# In this section, we need .config
170include .config.cmd
171
d06645d8
EA
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.
175include toolchain/*/*.mk
176include package/*/*.mk
d06645d8 177
79f5f1e8
EA
178# target stuff is last so it can override anything else
179include target/Makefile.in
180
08782ae7 181TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
a5c23541 182TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS))
08782ae7 183TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
ffde94bd 184
6e2823c1 185world: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) $(TARGETS)
870cb9e8 186dirs: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR)
ffde94bd 187
870cb9e8 188.PHONY: all world dirs clean dirclean distclean source $(TARGETS) \
747b16dd
EA
189 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
190 $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
ffde94bd 191
08782ae7
EA
192#############################################################
193#
ef407d3d 194# staging and target directories do NOT list these as
d99c31c6 195# dependencies anywhere else
08782ae7
EA
196#
197#############################################################
8d583fc0
BRF
198$(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR):
199 @mkdir -p $@
3ad3d8a1 200
08782ae7 201$(STAGING_DIR):
9c865d75 202 @mkdir -p $(STAGING_DIR)/bin
bf38723f 203 @mkdir -p $(STAGING_DIR)/lib
7e0c890c 204ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
8027784c
BRF
205 @mkdir -p $(STAGING_DIR)/usr/lib
206else
207 @ln -snf . $(STAGING_DIR)/usr
208 @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)
3da708e4 209 @ln -snf ../lib $(STAGING_DIR)/usr/lib
8027784c
BRF
210 @ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
211endif
212 @mkdir -p $(STAGING_DIR)/usr/include
ffde94bd 213
08782ae7 214$(TARGET_DIR):
a4c685f1 215 mkdir -p $(TARGET_DIR)
ba70f94e
EA
216 if [ -d "$(TARGET_SKELETON)" ] ; then \
217 cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
bb15c221 218 fi;
5418a923 219 touch $(STAGING_DIR)/.fakeroot.00000
bb15c221
EA
220 -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf
221 -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf
08782ae7 222
73be7f9e 223source: $(TARGETS_SOURCE) $(HOST_SOURCE)
08782ae7 224
825ff341
BRF
225.config.check: dependencies
226 $(SED) '/BR2_WGET/s/\"$$/ --spider\"/g' .config
227 touch $@
228
229_source-check: .config.check
230 $(MAKE) source
231
08782ae7
EA
232#############################################################
233#
234# Cleanup and misc junk
235#
236#############################################################
237clean: $(TARGETS_CLEAN)
3ad3d8a1 238 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
08782ae7
EA
239
240dirclean: $(TARGETS_DIRCLEAN)
3ad3d8a1 241 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
08782ae7
EA
242
243distclean:
5bc1f0c3
MF
244ifeq ($(DL_DIR),$(BASE_DIR)/dl)
245 rm -rf $(DL_DIR)
246endif
81df2264
BRF
247 rm -rf $(BUILD_DIR) $(LINUX_KERNEL) $(IMAGE) $(BASE_DIR)/include \
248 .config.cmd
b5136193 249 $(MAKE) -C $(CONFIG) clean
08782ae7 250
3ad3d8a1 251sourceball:
08782ae7
EA
252 rm -rf $(BUILD_DIR)
253 set -e; \
254 cd ..; \
255 rm -f buildroot.tar.bz2; \
256 tar -cvf buildroot.tar buildroot; \
257 bzip2 -9 buildroot.tar; \
2d523c23
EA
258
259
260else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
261
262all: menuconfig
263
264# configuration
265# ---------------------------------------------------------------------------
266
267$(CONFIG)/conf:
f987b7a5 268 $(MAKE) CC="$(HOSTCC)" HOSTCFLAGS="$(CFLAGS_FOR_BUILD)" MAKECMDGOALS="$(MAKECMDGOALS)" \
afc61c6e 269 -C $(CONFIG) conf
2d523c23
EA
270 -@if [ ! -f .config ] ; then \
271 cp $(CONFIG_DEFCONFIG) .config; \
272 fi
273$(CONFIG)/mconf:
f987b7a5 274 $(MAKE) CC="$(HOSTCC)" HOSTCFLAGS="$(CFLAGS_FOR_BUILD)" MAKECMDGOALS="$(MAKECMDGOALS)" \
afc61c6e 275 -C $(CONFIG) conf mconf
2d523c23
EA
276 -@if [ ! -f .config ] ; then \
277 cp $(CONFIG_DEFCONFIG) .config; \
278 fi
279
280menuconfig: $(CONFIG)/mconf
f987b7a5
BRF
281 @-mkdir -p include/config
282 @KCONFIG_AUTOCONFIG=include/config/auto.conf \
283 KCONFIG_AUTOHEADER=include/autoconf.h \
284 $(CONFIG)/mconf $(CONFIG_CONFIG_IN)
2d523c23
EA
285
286config: $(CONFIG)/conf
f987b7a5
BRF
287 @-mkdir -p include/config
288 @KCONFIG_AUTOCONFIG=include/config/auto.conf \
289 KCONFIG_AUTOHEADER=include/autoconf.h \
290 $(CONFIG)/conf $(CONFIG_CONFIG_IN)
2d523c23
EA
291
292oldconfig: $(CONFIG)/conf
f987b7a5
BRF
293 @-mkdir -p include/config
294 @KCONFIG_AUTOCONFIG=include/config/auto.conf \
295 KCONFIG_AUTOHEADER=include/autoconf.h \
296 $(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
2d523c23
EA
297
298randconfig: $(CONFIG)/conf
f987b7a5
BRF
299 @-mkdir -p include/config
300 @KCONFIG_AUTOCONFIG=include/config/auto.conf \
301 KCONFIG_AUTOHEADER=include/autoconf.h \
302 $(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
2d523c23
EA
303
304allyesconfig: $(CONFIG)/conf
f987b7a5
BRF
305 cat $(CONFIG_DEFCONFIG) > .config
306 @-mkdir -p include/config
307 @KCONFIG_AUTOCONFIG=include/config/auto.conf \
308 KCONFIG_AUTOHEADER=include/autoconf.h \
309 $(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
2d523c23 310 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
2d523c23
EA
311
312allnoconfig: $(CONFIG)/conf
f987b7a5
BRF
313 @-mkdir -p include/config
314 @KCONFIG_AUTOCONFIG=include/config/auto.conf \
315 KCONFIG_AUTOHEADER=include/autoconf.h \
316 $(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
2d523c23
EA
317
318defconfig: $(CONFIG)/conf
f987b7a5
BRF
319 @-mkdir -p include/config
320 @KCONFIG_AUTOCONFIG=include/config/auto.conf \
321 KCONFIG_AUTOHEADER=include/autoconf.h \
322 $(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
2d523c23 323
825ff341
BRF
324# check if download URLs are outdated
325source-check: allyesconfig
326 $(MAKE) _source-check
327
2d523c23
EA
328#############################################################
329#
330# Cleanup and misc junk
331#
332#############################################################
333clean:
334 rm -f .config .config.old .config.cmd .tmpconfig.h
335 - $(MAKE) -C $(CONFIG) clean
336
337distclean: clean
338 rm -rf sources/*
339
340endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
341
ba2e7e02
BRF
342%_defconfig: $(CONFIG)/conf
343 cp $(shell find ./target/ -name $@) .config
344 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
345
e491fba2
BRF
346help:
347 @echo 'Cleaning:'
348 @echo ' clean - delete temporary files created by build'
349 @echo ' distclean - delete all non-source files (including .config)'
350 @echo
351 @echo 'Build:'
352 @echo ' all - make world'
353 @echo
354 @echo 'Configuration:'
355 @echo ' menuconfig - interactive curses-based configurator'
356 @echo ' oldconfig - resolve any unresolved symbols in .config'
357 @echo
358 @echo 'Miscellaneous:'
359 @echo ' source - download all sources needed for offline-build'
360 @echo ' source-check - check all packages for valid download URLS'
361 @echo
ba2e7e02 362
2d523c23 363.PHONY: dummy subdirs release distclean clean config oldconfig \
e491fba2 364 menuconfig tags check test depend defconfig help
2d523c23
EA
365
366
This page took 0.110438 seconds and 4 git commands to generate.