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