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