]> Git Repo - buildroot-mgba.git/blame - Makefile
- fix whitespace damage..
[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
7def5559 28DATE:=$(shell date -u +%Y%m%d)
a0aef7c4 29
2d523c23 30noconfig_targets := menuconfig config oldconfig randconfig \
0c1e709e 31 defconfig allyesconfig allnoconfig release tags \
e491fba2 32 source-check help
9e250356
BRF
33
34# $(shell find . -name *_defconfig |sed 's/.*\///')
cad58108 35
2d523c23
EA
36# Pull in the user's configuration file
37ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
38-include $(TOPDIR).config
39endif
adbc5a18 40ifneq ($(BUILDROOT_DL_DIR),)
3c567e64
US
41BR2_DL_DIR:=$(BUILDROOT_DL_DIR)
42endif
9741a49e 43
afc61c6e
BRF
44# To put more focus on warnings, be less verbose as default
45# Use 'make V=1' to see the full commands
46ifdef V
47 ifeq ("$(origin V)", "command line")
48 KBUILD_VERBOSE = $(V)
49 endif
50endif
51ifndef KBUILD_VERBOSE
52 KBUILD_VERBOSE = 0
53endif
54
55ifeq ($(KBUILD_VERBOSE),1)
4df454e9 56 quiet=
afc61c6e
BRF
57 Q =
58else
59 quiet=quiet_
60 Q = @
61endif
62
63CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
64 else if [ -x /bin/bash ]; then echo /bin/bash; \
65 else echo sh; fi ; fi)
66
67export CONFIG_SHELL quiet Q KBUILD_VERBOSE
68
69ifndef HOSTAR
70HOSTAR:=ar
71endif
72ifndef HOSTAS
73HOSTAS:=as
74endif
75ifndef HOSTCC
76HOSTCC:=gcc
77else
78endif
79ifndef HOSTCXX
80HOSTCXX:=g++
81endif
82ifndef HOSTLD
83HOSTLD:=ld
84endif
0f9c5b11
US
85ifndef HOSTLN
86HOSTLN:=ln
87endif
83832cda
US
88HOSTAR :=$(shell $(CONFIG_SHELL) -c "which $(HOSTAR)" || type -p $(HOSTAR) || echo ar)
89HOSTAS :=$(shell $(CONFIG_SHELL) -c "which $(HOSTAS)" || type -p $(HOSTAS) || echo as)
90HOSTCC :=$(shell $(CONFIG_SHELL) -c "which $(HOSTCC)" || type -p $(HOSTCC) || echo gcc)
91HOSTCXX:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCXX)" || type -p $(HOSTCXX) || echo g++)
92HOSTLD :=$(shell $(CONFIG_SHELL) -c "which $(HOSTLD)" || type -p $(HOSTLD) || echo ld)
0f9c5b11 93HOSTLN :=$(shell $(CONFIG_SHELL) -c "which $(HOSTLN)" || type -p $(HOSTLN) || echo ln)
afc61c6e 94ifndef CFLAGS_FOR_BUILD
f987b7a5 95CFLAGS_FOR_BUILD:=-g -O2
afc61c6e
BRF
96endif
97export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
98
99
2d523c23 100ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
54e098e4 101
99cf7293
BRF
102# cc-option
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.
106cc-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 ;)
108
2c649045
PK
109#############################################################
110#
111# Hide troublesome environment variables from sub processes
112#
113#############################################################
114unexport CROSS_COMPILE
115unexport ARCH
27bc59d4 116
08782ae7
EA
117#############################################################
118#
c6e43c9d 119# Setup the proper filename extensions for the host
08782ae7 120#
7dcbbfbb
BRF
121##############################################################
122ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
c6e43c9d
BRF
123HOST_EXEEXT:=
124HOST_LIBEXT:=.a
125HOST_SHREXT:=.so
3096f34d 126endif
7dcbbfbb 127ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
c6e43c9d
BRF
128HOST_EXEEXT:=
129HOST_LIBEXT:=.a
130HOST_SHREXT:=.dylib
3096f34d 131endif
7dcbbfbb 132ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
c6e43c9d
BRF
133HOST_EXEEXT:=.exe
134HOST_LIBEXT:=.lib
135HOST_SHREXT:=.dll
3096f34d 136endif
7dcbbfbb 137ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
c6e43c9d
BRF
138HOST_EXEEXT:=.exe
139HOST_LIBEXT:=.lib
140HOST_SHREXT:=.dll
3096f34d 141endif
cb7d5b81 142
c6e43c9d 143# The preferred type of libs we build for the target
3096f34d 144ifeq ($(BR2_PREFER_STATIC_LIB),y)
c6e43c9d 145LIBTGTEXT=.a
8027784c 146#PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
3096f34d 147else
c6e43c9d 148LIBTGTEXT=.so
8027784c 149#PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
3096f34d 150endif
8027784c 151PREFERRED_LIB_FLAGS:=--enable-static --enable-shared
ffde94bd 152
6ad07203 153BR2_DEPENDS_DIR=$(BASE_DIR)/package/config/buildroot-config/
7dcbbfbb 154
6ad07203 155##############################################################
7dcbbfbb
BRF
156#
157# The list of stuff to build for the target toolchain
158# along with the packages to build for the target.
159#
160##############################################################
161ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
acc706b7 162BASE_TARGETS:=uclibc-configured binutils gcc uclibc-target-utils
7dcbbfbb 163else
acc706b7 164BASE_TARGETS:=uclibc
7dcbbfbb 165endif
acc706b7
BRF
166TARGETS:=
167
f958d897 168include project/Makefile.in
7dcbbfbb
BRF
169include toolchain/Makefile.in
170include package/Makefile.in
171
172#############################################################
173#
174# You should probably leave this stuff alone unless you know
175# what you are doing.
176#
177#############################################################
178
08782ae7 179all: world
ffde94bd 180
2d523c23
EA
181# In this section, we need .config
182include .config.cmd
183
f958d897
US
184include project/*.mk
185
d06645d8
EA
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.
acc706b7
BRF
189ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
190# avoid pulling in external toolchain which is broken for toplvl parallel builds
191include $(filter-out $(wildcard toolchain/external-toolchain/*),$(wildcard toolchain/*/*.mk))
192else
d06645d8 193include toolchain/*/*.mk
acc706b7
BRF
194endif
195
62b5ae4b
SH
196ifeq ($(BR2_PACKAGE_LINUX),y)
197TARGETS+=linux26-modules
198endif
acc706b7 199
d06645d8 200include package/*/*.mk
d06645d8 201
79f5f1e8
EA
202# target stuff is last so it can override anything else
203include target/Makefile.in
204
c2fc93bc
US
205TARGETS+=erase-fakeroots
206
08782ae7 207TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
a5c23541 208TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS))
08782ae7 209TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
ffde94bd 210
acc706b7
BRF
211# all targets depend on the crosscompiler and it's prerequisites
212$(TARGETS): $(BASE_TARGETS)
213
5ef9e52b
BRF
214dirs: $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
215 $(BINARIES_DIR) $(PROJECT_BUILD_DIR)
f958d897 216
5ef9e52b 217$(BASE_TARGETS): dirs
f958d897 218
69d692e4 219world: dependencies dirs target-host-info $(BASE_TARGETS) $(TARGETS)
ffde94bd 220
5ef9e52b 221
f958d897 222.PHONY: all world dirs clean dirclean distclean source \
5ef9e52b 223 $(BASE_TARGETS) $(TARGETS) \
747b16dd 224 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
5ef9e52b
BRF
225 $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
226 $(BINARIES_DIR) $(PROJECT_BUILD_DIR)
ffde94bd 227
08782ae7
EA
228#############################################################
229#
ef407d3d 230# staging and target directories do NOT list these as
d99c31c6 231# dependencies anywhere else
08782ae7
EA
232#
233#############################################################
5ef9e52b 234$(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) \
c6771dfb 235 $(PROJECT_BUILD_DIR) $(BINARIES_DIR):
8d583fc0 236 @mkdir -p $@
3ad3d8a1 237
08782ae7 238$(STAGING_DIR):
9c865d75 239 @mkdir -p $(STAGING_DIR)/bin
bf38723f 240 @mkdir -p $(STAGING_DIR)/lib
7e0c890c 241ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
8027784c
BRF
242 @mkdir -p $(STAGING_DIR)/usr/lib
243else
244 @ln -snf . $(STAGING_DIR)/usr
245 @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)
3da708e4 246 @ln -snf ../lib $(STAGING_DIR)/usr/lib
8027784c
BRF
247 @ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
248endif
249 @mkdir -p $(STAGING_DIR)/usr/include
ffde94bd 250
c6771dfb 251$(PROJECT_BUILD_DIR)/.root:
7547c7eb 252 mkdir -p $(TARGET_DIR)
74cda1e4 253 if ! [ -d "$(TARGET_DIR)/bin" ] ; then \
74cda1e4
US
254 if [ -d "$(TARGET_SKELETON)" ] ; then \
255 cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
256 fi; \
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 ; \
bb15c221 260 fi;
7547c7eb 261 touch $@
08782ae7 262
c6771dfb
US
263$(TARGET_DIR): $(PROJECT_BUILD_DIR)/.root
264
c2fc93bc 265erase-fakeroots:
5d2be049 266 rm -f $(PROJECT_BUILD_DIR)/.fakeroot*
412ca2a4 267
73be7f9e 268source: $(TARGETS_SOURCE) $(HOST_SOURCE)
08782ae7 269
e7c08c29
US
270_source-check:
271 $(MAKE) SPIDER=--spider source
825ff341 272
08782ae7
EA
273#############################################################
274#
275# Cleanup and misc junk
276#
277#############################################################
278clean: $(TARGETS_CLEAN)
3ad3d8a1 279 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
08782ae7
EA
280
281dirclean: $(TARGETS_DIRCLEAN)
3ad3d8a1 282 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
08782ae7
EA
283
284distclean:
5bc1f0c3
MF
285ifeq ($(DL_DIR),$(BASE_DIR)/dl)
286 rm -rf $(DL_DIR)
287endif
412ca2a4
US
288 rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR) \
289 $(LINUX_KERNEL) $(IMAGE) $(BASE_DIR)/include \
81df2264 290 .config.cmd
b5136193 291 $(MAKE) -C $(CONFIG) clean
08782ae7 292
3ad3d8a1 293sourceball:
412ca2a4 294 rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR)
08782ae7
EA
295 set -e; \
296 cd ..; \
297 rm -f buildroot.tar.bz2; \
298 tar -cvf buildroot.tar buildroot; \
299 bzip2 -9 buildroot.tar; \
2d523c23
EA
300
301
302else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
303
304all: menuconfig
305
306# configuration
307# ---------------------------------------------------------------------------
308
c0d7d4e0
BRF
309HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
310export HOSTCFLAGS
311
2d523c23 312$(CONFIG)/conf:
fb2c8fec 313 $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf
2d523c23
EA
314 -@if [ ! -f .config ] ; then \
315 cp $(CONFIG_DEFCONFIG) .config; \
316 fi
317$(CONFIG)/mconf:
fb2c8fec 318 $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf mconf
2d523c23
EA
319 -@if [ ! -f .config ] ; then \
320 cp $(CONFIG_DEFCONFIG) .config; \
321 fi
322
323menuconfig: $(CONFIG)/mconf
62b5ae4b 324 @-mkdir -p $(CONFIG)/buildroot-config
153b1bea 325 @if ! KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
62b5ae4b 326 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
153b1bea
BRF
327 $(CONFIG)/mconf $(CONFIG_CONFIG_IN); then \
328 test -f .config.cmd || rm -f .config; \
329 fi
2d523c23
EA
330
331config: $(CONFIG)/conf
62b5ae4b
SH
332 @-mkdir -p $(CONFIG)/buildroot-config
333 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
334 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
f987b7a5 335 $(CONFIG)/conf $(CONFIG_CONFIG_IN)
2d523c23
EA
336
337oldconfig: $(CONFIG)/conf
62b5ae4b
SH
338 @-mkdir -p $(CONFIG)/buildroot-config
339 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
340 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
f987b7a5 341 $(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
2d523c23
EA
342
343randconfig: $(CONFIG)/conf
62b5ae4b
SH
344 @-mkdir -p $(CONFIG)/buildroot-config
345 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
346 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
f987b7a5 347 $(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
2d523c23
EA
348
349allyesconfig: $(CONFIG)/conf
f987b7a5 350 cat $(CONFIG_DEFCONFIG) > .config
62b5ae4b
SH
351 @-mkdir -p $(CONFIG)/buildroot-config
352 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
353 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
f987b7a5 354 $(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
2d523c23 355 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
2d523c23
EA
356
357allnoconfig: $(CONFIG)/conf
62b5ae4b
SH
358 @-mkdir -p $(CONFIG)/buildroot-config
359 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
360 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
f987b7a5 361 $(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
2d523c23
EA
362
363defconfig: $(CONFIG)/conf
62b5ae4b
SH
364 @-mkdir -p $(CONFIG)/buildroot-config
365 @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
366 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
f987b7a5 367 $(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
2d523c23 368
825ff341
BRF
369# check if download URLs are outdated
370source-check: allyesconfig
371 $(MAKE) _source-check
372
2d523c23
EA
373#############################################################
374#
375# Cleanup and misc junk
376#
377#############################################################
378clean:
379 rm -f .config .config.old .config.cmd .tmpconfig.h
380 - $(MAKE) -C $(CONFIG) clean
381
382distclean: clean
383 rm -rf sources/*
384
385endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
386
ba2e7e02
BRF
387%_defconfig: $(CONFIG)/conf
388 cp $(shell find ./target/ -name $@) .config
389 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
390
e491fba2
BRF
391help:
392 @echo 'Cleaning:'
393 @echo ' clean - delete temporary files created by build'
394 @echo ' distclean - delete all non-source files (including .config)'
395 @echo
396 @echo 'Build:'
397 @echo ' all - make world'
398 @echo
399 @echo 'Configuration:'
400 @echo ' menuconfig - interactive curses-based configurator'
401 @echo ' oldconfig - resolve any unresolved symbols in .config'
402 @echo
403 @echo 'Miscellaneous:'
404 @echo ' source - download all sources needed for offline-build'
03380402 405 @echo ' source-check - check all packages for valid download URLs'
e491fba2 406 @echo
ba2e7e02 407
2d523c23 408.PHONY: dummy subdirs release distclean clean config oldconfig \
e491fba2 409 menuconfig tags check test depend defconfig help
2d523c23
EA
410
411
This page took 0.177992 seconds and 4 git commands to generate.