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