]> Git Repo - buildroot-mgba.git/blame - Makefile
manual: minor fix in patch-policy.txt
[buildroot-mgba.git] / Makefile
CommitLineData
2d523c23 1# Makefile for buildroot2
ffde94bd 2#
15b26aee 3# Copyright (C) 1999-2005 by Erik Andersen <[email protected]>
9fc43591 4# Copyright (C) 2006-2012 by the Buildroot developers <[email protected]>
ffde94bd 5#
08782ae7 6# This program is free software; you can redistribute it and/or modify
2d523c23
EA
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
ffde94bd 10#
2d523c23
EA
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
08782ae7 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2d523c23 14# General Public License for more details.
b30d673c 15#
2d523c23
EA
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3ad3d8a1 19#
02bf5816 20
2d523c23
EA
21#--------------------------------------------------------------
22# Just run 'make menuconfig', configure stuff, then run 'make'.
23# You shouldn't need to mess with anything beyond this point...
24#--------------------------------------------------------------
2d239bbe 25
e5e8fae8 26# Set and export the version string
d65bb7e3 27export BR2_VERSION:=2013.02-rc3
e5e8fae8 28
0edfb24c
TDS
29# Check for minimal make version (note: this check will break at make 10.x)
30MIN_MAKE_VERSION=3.81
8139e21c 31ifneq ($(firstword $(sort $(MAKE_VERSION) $(MIN_MAKE_VERSION))),$(MIN_MAKE_VERSION))
0edfb24c
TDS
32$(error You have make '$(MAKE_VERSION)' installed. GNU make >= $(MIN_MAKE_VERSION) is required)
33endif
34
1d4104f0
FP
35export HOSTARCH := $(shell uname -m | \
36 sed -e s/i.86/x86/ \
37 -e s/sun4u/sparc64/ \
38 -e s/arm.*/arm/ \
39 -e s/sa110/arm/ \
40 -e s/ppc64/powerpc/ \
41 -e s/ppc/powerpc/ \
42 -e s/macppc/powerpc/\
43 -e s/sh.*/sh/)
44
2d239bbe
YM
45# This top-level Makefile can *not* be executed in parallel
46.NOTPARALLEL:
47
6b1dd45b
PK
48# absolute path
49TOPDIR:=$(shell pwd)
18d979c7 50CONFIG_CONFIG_IN=Config.in
56da3859 51CONFIG=support/kconfig
a8ee1240 52DATE:=$(shell date +%Y%m%d)
a0aef7c4 53
8258df27
YM
54# Compute the full local version string so packages can use it as-is
55# Need to export it, so it can be got from environment in children (eg. mconf)
f082c7c5 56export BR2_VERSION_FULL:=$(BR2_VERSION)$(shell $(TOPDIR)/support/scripts/setlocalversion)
8258df27 57
8b6585a9 58noconfig_targets:=menuconfig nconfig gconfig xconfig config oldconfig randconfig \
1ed49963 59 %_defconfig allyesconfig allnoconfig silentoldconfig release \
6652770f 60 randpackageconfig allyespackageconfig allnopackageconfig \
2b91ab7a 61 source-check print-version
9e250356 62
580c6d9b
TP
63# Strip quotes and then whitespaces
64qstrip=$(strip $(subst ",,$(1)))
65#"))
66
f85f2de1
PK
67# Variables for use in Make constructs
68comma:=,
69empty:=
70space:=$(empty) $(empty)
71
39ca6d50
WW
72ifneq ("$(origin O)", "command line")
73O:=output
74CONFIG_DIR:=$(TOPDIR)
aefad531 75NEED_WRAPPER=
39ca6d50
WW
76else
77# other packages might also support Linux-style out of tree builds
78# with the O=<dir> syntax (E.G. Busybox does). As make automatically
79# forwards command line variable definitions those packages get very
80# confused. Fix this by telling make to not do so
81MAKEOVERRIDES =
82# strangely enough O is still passed to submakes with MAKEOVERRIDES
83# (with make 3.81 atleast), the only thing that changes is the output
84# of the origin function (command line -> environment).
85# Unfortunately some packages don't look at origin (E.G. uClibc 0.9.31+)
86# To really make O go away, we have to override it.
87override O:=$(O)
88CONFIG_DIR:=$(O)
de846f6e
PK
89# we need to pass O= everywhere we call back into the toplevel makefile
90EXTRAMAKEARGS = O=$(O)
aefad531 91NEED_WRAPPER=y
39ca6d50
WW
92endif
93
2b0f4552
YM
94BUILDROOT_CONFIG=$(CONFIG_DIR)/.config
95
a1b0651a
US
96# Pull in the user's configuration file
97ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
dcb79995 98-include $(BUILDROOT_CONFIG)
7521f373 99endif
9741a49e 100
afc61c6e
BRF
101# To put more focus on warnings, be less verbose as default
102# Use 'make V=1' to see the full commands
103ifdef V
104 ifeq ("$(origin V)", "command line")
18d979c7 105 KBUILD_VERBOSE=$(V)
afc61c6e
BRF
106 endif
107endif
108ifndef KBUILD_VERBOSE
18d979c7 109 KBUILD_VERBOSE=0
afc61c6e
BRF
110endif
111
112ifeq ($(KBUILD_VERBOSE),1)
4df454e9 113 quiet=
18d979c7 114 Q=
1669b6ed
BRF
115ifndef VERBOSE
116 VERBOSE=1
117endif
afc61c6e
BRF
118else
119 quiet=quiet_
18d979c7 120 Q=@
afc61c6e
BRF
121endif
122
69f85924
PK
123# we want bash as shell
124SHELL:=$(shell if [ -x "$$BASH" ]; then echo $$BASH; \
afc61c6e 125 else if [ -x /bin/bash ]; then echo /bin/bash; \
18d979c7 126 else echo sh; fi; fi)
afc61c6e 127
69f85924
PK
128# kconfig uses CONFIG_SHELL
129CONFIG_SHELL:=$(SHELL)
130
131export SHELL CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
afc61c6e
BRF
132
133ifndef HOSTAR
134HOSTAR:=ar
135endif
136ifndef HOSTAS
137HOSTAS:=as
138endif
139ifndef HOSTCC
140HOSTCC:=gcc
17b66aff 141HOSTCC:=$(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
afc61c6e 142endif
0df02e12 143HOSTCC_NOCCACHE:=$(HOSTCC)
afc61c6e
BRF
144ifndef HOSTCXX
145HOSTCXX:=g++
17b66aff 146HOSTCXX:=$(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
afc61c6e 147endif
0df02e12 148HOSTCXX_NOCCACHE:=$(HOSTCXX)
5f97580e
BRF
149ifndef HOSTFC
150HOSTFC:=gfortran
151endif
356133b4
US
152ifndef HOSTCPP
153HOSTCPP:=cpp
154endif
afc61c6e
BRF
155ifndef HOSTLD
156HOSTLD:=ld
157endif
0f9c5b11
US
158ifndef HOSTLN
159HOSTLN:=ln
160endif
356133b4
US
161ifndef HOSTNM
162HOSTNM:=nm
163endif
69f85924
PK
164HOSTAR:=$(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
165HOSTAS:=$(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
69f85924
PK
166HOSTFC:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran)
167HOSTCPP:=$(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
168HOSTLD:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
169HOSTLN:=$(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
170HOSTNM:=$(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
54e93328 171
5f97580e 172export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
17b66aff 173export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
afc61c6e 174
670cb306
AV
175# Make sure pkg-config doesn't look outside the buildroot tree
176unexport PKG_CONFIG_PATH
4f607edf 177unexport PKG_CONFIG_SYSROOT_DIR
670cb306 178
91123a6f
TP
179# Having DESTDIR set in the environment confuses the installation
180# steps of some packages.
181unexport DESTDIR
182
39ca6d50
WW
183# bash prints the name of the directory on 'cd <dir>' if CDPATH is
184# set, so unset it here to not cause problems. Notice that the export
185# line doesn't affect the environment of $(shell ..) calls, so
186# explictly throw away any output from 'cd' here.
187export CDPATH:=
188BASE_DIR := $(shell mkdir -p $(O) && cd $(O) >/dev/null && pwd)
189$(if $(BASE_DIR),, $(error output directory "$(O)" does not exist))
190
191BUILD_DIR:=$(BASE_DIR)/build
192
afc61c6e 193
cfe511b2 194ifeq ($(BR2_HAVE_DOT_CONFIG),y)
54e098e4 195
2c649045
PK
196#############################################################
197#
198# Hide troublesome environment variables from sub processes
199#
200#############################################################
201unexport CROSS_COMPILE
202unexport ARCH
2bf3c166
DN
203unexport CC
204unexport CXX
205unexport CPP
206unexport CFLAGS
207unexport CXXFLAGS
208unexport GREP_OPTIONS
12c9f7dd 209unexport CONFIG_SITE
32314b44 210unexport QMAKESPEC
27bc59d4 211
102a93bd 212GNU_HOST_NAME:=$(shell support/gnuconfig/config.guess)
60281cbf 213
6ad07203 214##############################################################
7dcbbfbb
BRF
215#
216# The list of stuff to build for the target toolchain
217# along with the packages to build for the target.
218#
219##############################################################
17b66aff
TP
220
221ifeq ($(BR2_CCACHE),y)
222BASE_TARGETS += host-ccache
223endif
224
bc994c53 225ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
009407e6 226BASE_TARGETS += uclibc-configured host-binutils cross_compiler uclibc-target-utils kernel-headers
10c1eec2 227else
17b66aff 228BASE_TARGETS += uclibc
7dcbbfbb 229endif
acc706b7
BRF
230TARGETS:=
231
89464a96
PK
232# silent mode requested?
233QUIET:=$(if $(findstring s,$(MAKEFLAGS)),-q)
234
397fe5cc
TP
235# Strip off the annoying quoting
236ARCH:=$(call qstrip,$(BR2_ARCH))
65e80a0b 237
891973f5
PK
238KERNEL_ARCH:=$(shell echo "$(ARCH)" | sed -e "s/-.*//" \
239 -e s/i.86/i386/ -e s/sun4u/sparc64/ \
240 -e s/arm.*/arm/ -e s/sa110/arm/ \
b90a1030 241 -e s/aarch64/arm64/ \
871db074 242 -e s/bfin/blackfin/ \
891973f5
PK
243 -e s/parisc64/parisc/ \
244 -e s/powerpc64/powerpc/ \
245 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
246 -e s/sh.*/sh/)
247
397fe5cc
TP
248ZCAT:=$(call qstrip,$(BR2_ZCAT))
249BZCAT:=$(call qstrip,$(BR2_BZCAT))
177b4b4a 250XZCAT:=$(call qstrip,$(BR2_XZCAT))
397fe5cc
TP
251TAR_OPTIONS=$(call qstrip,$(BR2_TAR_OPTIONS)) -xf
252
a2b4f7fb
GZ
253# packages compiled for the host go here
254HOST_DIR:=$(call qstrip,$(BR2_HOST_DIR))
397fe5cc 255
aebf199f
TP
256# locales to generate
257GENERATE_LOCALE=$(call qstrip,$(BR2_GENERATE_LOCALE))
258
397fe5cc 259# stamp (dependency) files go here
3b2a803d 260STAMP_DIR:=$(BASE_DIR)/stamps
397fe5cc 261
3b2a803d
TP
262BINARIES_DIR:=$(BASE_DIR)/images
263TARGET_DIR:=$(BASE_DIR)/target
4c5bf461 264TOOLCHAIN_DIR=$(BASE_DIR)/toolchain
6c3e3ad4 265TARGET_SKELETON=$(TOPDIR)/system/skeleton
397fe5cc 266
7e76f904
LC
267LEGAL_INFO_DIR=$(BASE_DIR)/legal-info
268REDIST_SOURCES_DIR=$(LEGAL_INFO_DIR)/sources
269LICENSE_FILES_DIR=$(LEGAL_INFO_DIR)/licenses
270LEGAL_MANIFEST_CSV=$(LEGAL_INFO_DIR)/manifest.csv
271LEGAL_LICENSES_TXT=$(LEGAL_INFO_DIR)/licenses.txt
272LEGAL_WARNINGS=$(LEGAL_INFO_DIR)/.warnings
273LEGAL_REPORT=$(LEGAL_INFO_DIR)/README
274
9226a990
TP
275# Location of a file giving a big fat warning that output/target
276# should not be used as the root filesystem.
277TARGET_DIR_WARNING_FILE=$(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
278
17b66aff
TP
279ifeq ($(BR2_CCACHE),y)
280CCACHE:=$(HOST_DIR)/usr/bin/ccache
43329076
TDS
281BUILDROOT_CACHE_DIR = $(call qstrip,$(BR2_CCACHE_DIR))
282export BUILDROOT_CACHE_DIR
17b66aff
TP
283HOSTCC := $(CCACHE) $(HOSTCC)
284HOSTCXX := $(CCACHE) $(HOSTCXX)
285endif
286
2b0f4552
YM
287# Scripts in support/ or post-build scripts may need to reference
288# these locations, so export them so it is easier to use
289export BUILDROOT_CONFIG
290export TARGET_DIR
291export STAGING_DIR
292export HOST_DIR
293export BINARIES_DIR
1300cb55 294export BASE_DIR
2b0f4552 295
7dcbbfbb
BRF
296#############################################################
297#
298# You should probably leave this stuff alone unless you know
299# what you are doing.
300#
301#############################################################
302
6547bced 303all: world
ffde94bd 304
ebcfa987
AVEM
305# Include legacy before the other things, because package .mk files
306# may rely on it.
307ifneq ($(BR2_DEPRECATED),y)
308include Makefile.legacy
309endif
310
486253db 311include package/Makefile.in
a792668b
TDS
312include support/dependencies/dependencies.mk
313
d06645d8
EA
314# We also need the various per-package makefiles, which also add
315# each selected package to TARGETS if that package was selected
316# in the .config file.
bc994c53 317ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
ed020099 318include toolchain/toolchain-buildroot.mk
26b44b2b 319else ifeq ($(BR2_TOOLCHAIN_EXTERNAL),y)
ed020099 320include toolchain/toolchain-external.mk
10c1eec2
YM
321else ifeq ($(BR2_TOOLCHAIN_CTNG),y)
322include toolchain/toolchain-crosstool-ng.mk
acc706b7
BRF
323endif
324
ee0246e1
TP
325# Include the package override file if one has been provided in the
326# configuration.
327PACKAGE_OVERRIDE_FILE=$(call qstrip,$(BR2_PACKAGE_OVERRIDE_FILE))
328ifneq ($(PACKAGE_OVERRIDE_FILE),)
329-include $(PACKAGE_OVERRIDE_FILE)
330endif
331
d06645d8 332include package/*/*.mk
d06645d8 333
64d8e9a0 334include boot/common.mk
64d8e9a0 335include linux/linux.mk
ec100c7e 336include system/system.mk
64d8e9a0 337
32faf351 338TARGETS+=target-finalize
d45de0ca 339
b87b4742
PK
340ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
341TARGETS+=target-purgelocales
342endif
343
aebf199f
TP
344ifneq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC)$(BR2_TOOLCHAIN_CTNG_eglibc)$(BR2_TOOLCHAIN_CTNG_glibc),)
345ifneq ($(GENERATE_LOCALE),)
346TARGETS+=target-generatelocales
347endif
348endif
349
217ef08a
TP
350ifeq ($(BR2_ECLIPSE_REGISTER),y)
351TARGETS+=toolchain-eclipse-register
352endif
353
649b5b92 354include fs/common.mk
79f5f1e8 355
9fa32ba0
TP
356TARGETS+=target-post-image
357
08782ae7 358TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
3b08e64d 359TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS) $(BASE_TARGETS))
08782ae7 360TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
b3efde23 361TARGETS_ALL:=$(patsubst %,__real_tgt_%,$(TARGETS))
22c2c6b5
PK
362
363# host-* dependencies have to be handled specially, as those aren't
364# visible in Kconfig and hence not added to a variable like TARGETS.
365# instead, find all the host-* targets listed in each <PKG>_DEPENDENCIES
366# variable for each enabled target.
367# Notice: this only works for newstyle gentargets/autotargets packages
368TARGETS_HOST_DEPS = $(sort $(filter host-%,$(foreach dep,\
369 $(addsuffix _DEPENDENCIES,$(call UPPERCASE,$(TARGETS))),\
370 $($(dep)))))
371# Host packages can in turn have their own dependencies. Likewise find
372# all the package names listed in the HOST_<PKG>_DEPENDENCIES for each
373# host package found above. Ideally this should be done recursively until
374# no more packages are found, but that's hard to do in make, so limit to
375# 1 level for now.
376HOST_DEPS = $(sort $(foreach dep,\
377 $(addsuffix _DEPENDENCIES,$(call UPPERCASE,$(TARGETS_HOST_DEPS))),\
378 $($(dep))))
379HOST_SOURCE += $(addsuffix -source,$(sort $(TARGETS_HOST_DEPS) $(HOST_DEPS)))
380
7e76f904
LC
381TARGETS_LEGAL_INFO:=$(patsubst %,%-legal-info,\
382 $(TARGETS) $(BASE_TARGETS) $(TARGETS_HOST_DEPS) $(HOST_DEPS))))
383
acc706b7 384# all targets depend on the crosscompiler and it's prerequisites
b3efde23 385$(TARGETS_ALL): __real_tgt_%: $(BASE_TARGETS) %
acc706b7 386
a77ee7fd 387dirs: $(TOOLCHAIN_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
d0880f70 388 $(HOST_DIR) $(BINARIES_DIR) $(STAMP_DIR)
f958d897 389
ed7791e2 390$(BASE_TARGETS): dirs $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake
f958d897 391
dcb79995 392$(BUILD_DIR)/buildroot-config/auto.conf: $(BUILDROOT_CONFIG)
c729829c 393 $(MAKE) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" silentoldconfig
0b368800
TP
394
395prepare: $(BUILD_DIR)/buildroot-config/auto.conf
396
2a786415 397toolchain: prepare dirs dependencies $(BASE_TARGETS)
ffde94bd 398
2a786415
FP
399world: toolchain $(TARGETS_ALL)
400
401.PHONY: all world toolchain dirs clean distclean source outputmakefile \
7e76f904 402 legal-info legal-info-prepare legal-info-clean \
b3efde23 403 $(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
7e76f904 404 $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) $(TARGETS_LEGAL_INFO) \
a77ee7fd 405 $(TOOLCHAIN_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
d0880f70 406 $(HOST_DIR) $(BINARIES_DIR) $(STAMP_DIR)
ffde94bd 407
08782ae7
EA
408#############################################################
409#
ef407d3d 410# staging and target directories do NOT list these as
d99c31c6 411# dependencies anywhere else
08782ae7
EA
412#
413#############################################################
a77ee7fd 414$(TOOLCHAIN_DIR) $(BUILD_DIR) $(HOST_DIR) $(BINARIES_DIR) $(STAMP_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR):
8d583fc0 415 @mkdir -p $@
3ad3d8a1 416
08782ae7 417$(STAGING_DIR):
9c865d75 418 @mkdir -p $(STAGING_DIR)/bin
bf38723f 419 @mkdir -p $(STAGING_DIR)/lib
8027784c 420 @mkdir -p $(STAGING_DIR)/usr/lib
8027784c 421 @mkdir -p $(STAGING_DIR)/usr/include
a05c337d 422 @mkdir -p $(STAGING_DIR)/usr/bin
5ad139eb 423 @ln -snf $(STAGING_DIR) $(BASE_DIR)/staging
ffde94bd 424
2b3a43f4
DM
425ifeq ($(BR2_ROOTFS_SKELETON_CUSTOM),y)
426TARGET_SKELETON=$(BR2_ROOTFS_SKELETON_CUSTOM_PATH)
427endif
428
397fe5cc 429$(BUILD_DIR)/.root:
7547c7eb 430 mkdir -p $(TARGET_DIR)
f0ca4b82
BRF
431 if ! [ -d "$(TARGET_DIR)/bin" ]; then \
432 if [ -d "$(TARGET_SKELETON)" ]; then \
18d979c7 433 cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
74cda1e4 434 fi; \
f0ca4b82 435 fi
9226a990 436 cp support/misc/target-dir-warning.txt $(TARGET_DIR_WARNING_FILE)
fc3eb18b 437 -find $(TARGET_DIR) -type d -name CVS -print0 -o -name .svn -print0 | xargs -0 rm -rf
b9656e81 438 -find $(TARGET_DIR) -type f \( -name .empty -o -name '*~' \) -print0 | xargs -0 rm -rf
7547c7eb 439 touch $@
08782ae7 440
397fe5cc 441$(TARGET_DIR): $(BUILD_DIR)/.root
c6771dfb 442
2a97045d
TDS
443STRIP_FIND_CMD = find $(TARGET_DIR)
444ifneq (,$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)))
445STRIP_FIND_CMD += \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) -prune -o
446endif
447STRIP_FIND_CMD += -type f -perm +111
6ae7886f 448STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print
2a97045d 449
32faf351 450target-finalize:
d45de0ca 451ifeq ($(BR2_HAVE_DEVFILES),y)
f082c7c5 452 ( support/scripts/copy.sh $(STAGING_DIR) $(TARGET_DIR) )
bc67ca29 453else
94d3aa17
VB
454 rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
455 $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig
027aa1d2
WB
456 find $(TARGET_DIR)/lib \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
457 find $(TARGET_DIR)/usr/lib \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
bc67ca29 458endif
e48a72e5
MS
459ifneq ($(BR2_PACKAGE_GDB),y)
460 rm -rf $(TARGET_DIR)/usr/share/gdb
461endif
87b0637b 462ifneq ($(BR2_HAVE_DOCUMENTATION),y)
32faf351 463 rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
32faf351 464 rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
87b0637b 465 rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
d701a823 466 rm -rf $(TARGET_DIR)/usr/share/gtk-doc
68ad6d4e 467 -rmdir $(TARGET_DIR)/usr/share 2>/dev/null
b0c86bcc
TP
468endif
469ifeq ($(BR2_PACKAGE_PYTHON_PY_ONLY),y)
470 find $(TARGET_DIR)/usr/lib/ -name '*.pyc' -print0 | xargs -0 rm -f
471endif
472ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY),y)
473 find $(TARGET_DIR)/usr/lib/ -name '*.py' -print0 | xargs -0 rm -f
32faf351 474endif
2a97045d 475 $(STRIP_FIND_CMD) | xargs $(STRIPCMD) 2>/dev/null || true
8101c9a3 476 find $(TARGET_DIR)/lib/modules -type f -name '*.ko' | \
0dc940cd 477 xargs -r $(KSTRIPCMD) || true
8101c9a3 478
6ae7886f
RB
479# See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
480# besides the one in which crash occurred; or SIGTRAP kills my program when
481# I set a breakpoint"
482ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
483 find $(TARGET_DIR)/lib -type f -name 'libpthread*.so*' | \
484 xargs $(STRIPCMD) $(STRIP_STRIP_DEBUG) || true
485endif
486
4ccde7fa
TP
487 mkdir -p $(TARGET_DIR)/etc
488 # Mandatory configuration file and auxilliary cache directory
489 # for recent versions of ldconfig
490 touch $(TARGET_DIR)/etc/ld.so.conf
491 mkdir -p $(TARGET_DIR)/var/cache/ldconfig
e49e2fed
PK
492 if [ -x "$(TARGET_CROSS)ldconfig" ]; \
493 then \
4ccde7fa 494 $(TARGET_CROSS)ldconfig -r $(TARGET_DIR); \
e49e2fed 495 else \
4ccde7fa 496 /sbin/ldconfig -r $(TARGET_DIR); \
e49e2fed 497 fi
451a8878
PK
498 ( \
499 echo "NAME=Buildroot"; \
500 echo "VERSION=$(BR2_VERSION_FULL)"; \
501 echo "ID=buildroot"; \
502 echo "VERSION_ID=$(BR2_VERSION)"; \
503 echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
504 ) > $(TARGET_DIR)/etc/os-release
912ea81a 505
7f860892
AVEM
506 @for dir in $(call qstrip,$(BR2_ROOTFS_OVERLAY)); do \
507 $(call MESSAGE,"Copying overlay $${dir}"); \
508 rsync -a \
afea3037
AVEM
509 --exclude .empty --exclude .svn --exclude .git \
510 --exclude .hg --exclude '*~' \
7f860892
AVEM
511 $${dir}/ $(TARGET_DIR); \
512 done
513
eed7d873 514ifneq ($(BR2_ROOTFS_POST_BUILD_SCRIPT),"")
dbf4978e
PR
515 @$(call MESSAGE,"Executing post-build script\(s\)")
516 @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
517 $(s) $(TARGET_DIR)$(sep))
eed7d873
DM
518endif
519
b87b4742 520ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
397fe5cc 521LOCALE_WHITELIST=$(BUILD_DIR)/locales.nopurge
6cdf2481 522LOCALE_NOPURGE=$(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
b87b4742
PK
523
524target-purgelocales:
525 rm -f $(LOCALE_WHITELIST)
526 for i in $(LOCALE_NOPURGE); do echo $$i >> $(LOCALE_WHITELIST); done
527
528 for dir in $(wildcard $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/man /usr/share/man)); \
529 do \
530 for lang in $$(cd $$dir; ls .|grep -v man); \
531 do \
532 grep -qx $$lang $(LOCALE_WHITELIST) || rm -rf $$dir/$$lang; \
533 done; \
534 done
535endif
536
aebf199f
TP
537ifneq ($(GENERATE_LOCALE),)
538# Generate locale data. Basically, we call the localedef program
539# (built by the host-localedef package) for each locale. The input
540# data comes preferably from the toolchain, or if the toolchain does
541# not have them (Linaro toolchains), we use the ones available on the
542# host machine.
543target-generatelocales: host-localedef
544 $(Q)mkdir -p $(TARGET_DIR)/usr/lib/locale/
545 $(Q)for locale in $(GENERATE_LOCALE) ; do \
546 inputfile=`echo $${locale} | cut -f1 -d'.'` ; \
547 charmap=`echo $${locale} | cut -f2 -d'.'` ; \
548 if test -z "$${charmap}" ; then \
549 charmap="UTF-8" ; \
550 fi ; \
551 echo "Generating locale $${inputfile}.$${charmap}" ; \
552 I18NPATH=$(STAGING_DIR)/usr/share/i18n:/usr/share/i18n \
553 $(HOST_DIR)/usr/bin/localedef \
554 --prefix=$(TARGET_DIR) \
555 --`echo $(BR2_ENDIAN) | tr [A-Z] [a-z]`-endian \
556 -i $${inputfile} -f $${charmap} \
557 $${locale} ; \
558 done
559endif
560
9fa32ba0
TP
561target-post-image:
562ifneq ($(BR2_ROOTFS_POST_IMAGE_SCRIPT),"")
563 @$(call MESSAGE,"Executing post-image script\(s\)")
564 @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
565 $(s) $(BINARIES_DIR)$(sep))
566endif
567
217ef08a
TP
568toolchain-eclipse-register:
569 ./support/scripts/eclipse-register-toolchain `readlink -f $(O)` $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
570
4eb982cf 571source: dirs $(TARGETS_SOURCE) $(HOST_SOURCE)
08782ae7 572
155971e0 573external-deps:
22c2c6b5 574 @$(MAKE) -Bs DL_MODE=SHOW_EXTERNAL_DEPS $(EXTRAMAKEARGS) source | sort -u
155971e0 575
7e76f904
LC
576legal-info-clean:
577 @rm -fr $(LEGAL_INFO_DIR)
578
579legal-info-prepare: $(LEGAL_INFO_DIR)
580 @$(call MESSAGE,"Collecting legal info")
581 @$(call legal-license-file,buildroot,COPYING,COPYING)
582 @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE)
583 @$(call legal-manifest,buildroot,$(BR2_VERSION_FULL),GPLv2+,COPYING,not saved)
584 @$(call legal-warning,the Buildroot source code has not been saved)
585 @$(call legal-warning,the toolchain has not been saved)
dcb79995 586 @cp $(BUILDROOT_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
7e76f904
LC
587
588legal-info: dirs legal-info-clean legal-info-prepare $(REDIST_SOURCES_DIR) \
589 $(TARGETS_LEGAL_INFO)
590 @cat support/legal-info/README.header >>$(LEGAL_REPORT)
591 @if [ -r $(LEGAL_WARNINGS) ]; then \
592 cat support/legal-info/README.warnings-header \
593 $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \
594 cat $(LEGAL_WARNINGS); fi
595 @echo "Legal info produced in $(LEGAL_INFO_DIR)"
596 @rm -f $(LEGAL_WARNINGS)
597
b7d6c8ad
TP
598show-targets:
599 @echo $(TARGETS)
600
cfe511b2 601else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
2d523c23
EA
602
603all: menuconfig
604
1ed49963
AVEM
605endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
606
2d523c23
EA
607# configuration
608# ---------------------------------------------------------------------------
609
c0d7d4e0
BRF
610HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
611export HOSTCFLAGS
612
2cc210c9
PK
613$(BUILD_DIR)/buildroot-config/%onf:
614 mkdir -p $(@D)/lxdialog
17b66aff 615 $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
2d523c23 616
1ed49963
AVEM
617DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
618
619# We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
620# recognize that if it's still at its default $(CONFIG_DIR)/defconfig
1039eb74 621COMMON_CONFIG_ENV = \
1ed49963 622 BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \
1039eb74
TP
623 KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
624 KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
0b368800 625 KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
dcb79995 626 BUILDROOT_CONFIG=$(BUILDROOT_CONFIG)
2d523c23 627
aefad531 628xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
39ca6d50 629 @mkdir -p $(BUILD_DIR)/buildroot-config
610255e7 630 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
b0df9df3 631
aefad531 632gconfig: $(BUILD_DIR)/buildroot-config/gconf outputmakefile
39ca6d50 633 @mkdir -p $(BUILD_DIR)/buildroot-config
610255e7 634 @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
2b42aae7 635
aefad531 636menuconfig: $(BUILD_DIR)/buildroot-config/mconf outputmakefile
39ca6d50 637 @mkdir -p $(BUILD_DIR)/buildroot-config
610255e7 638 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
2d523c23 639
aefad531 640nconfig: $(BUILD_DIR)/buildroot-config/nconf outputmakefile
8b6585a9 641 @mkdir -p $(BUILD_DIR)/buildroot-config
610255e7 642 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
2d523c23 643
aefad531 644config: $(BUILD_DIR)/buildroot-config/conf outputmakefile
39ca6d50 645 @mkdir -p $(BUILD_DIR)/buildroot-config
1039eb74 646 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
2d523c23 647
aefad531 648oldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
39ca6d50 649 mkdir -p $(BUILD_DIR)/buildroot-config
1039eb74 650 @$(COMMON_CONFIG_ENV) $< --oldconfig $(CONFIG_CONFIG_IN)
2d523c23 651
aefad531 652randconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
39ca6d50 653 @mkdir -p $(BUILD_DIR)/buildroot-config
1039eb74 654 @$(COMMON_CONFIG_ENV) $< --randconfig $(CONFIG_CONFIG_IN)
2d523c23 655
aefad531 656allyesconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
39ca6d50 657 @mkdir -p $(BUILD_DIR)/buildroot-config
1039eb74 658 @$(COMMON_CONFIG_ENV) $< --allyesconfig $(CONFIG_CONFIG_IN)
2d523c23 659
aefad531 660allnoconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
39ca6d50 661 @mkdir -p $(BUILD_DIR)/buildroot-config
1039eb74 662 @$(COMMON_CONFIG_ENV) $< --allnoconfig $(CONFIG_CONFIG_IN)
2d523c23 663
aefad531 664randpackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
39ca6d50 665 @mkdir -p $(BUILD_DIR)/buildroot-config
dcb79995 666 @grep -v BR2_PACKAGE_ $(BUILDROOT_CONFIG) > $(CONFIG_DIR)/.config.nopkg
8a46d4bf
PK
667 @grep '^config BR2_PACKAGE_' Config.in.legacy | \
668 while read config pkg; do \
669 echo "# $$pkg is not set" >> $(CONFIG_DIR)/.config.nopkg; done
1039eb74 670 @$(COMMON_CONFIG_ENV) \
39ca6d50 671 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
1039eb74 672 $< --randconfig $(CONFIG_CONFIG_IN)
39ca6d50 673 @rm -f $(CONFIG_DIR)/.config.nopkg
6652770f 674
aefad531 675allyespackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
39ca6d50 676 @mkdir -p $(BUILD_DIR)/buildroot-config
dcb79995 677 @grep -v BR2_PACKAGE_ $(BUILDROOT_CONFIG) > $(CONFIG_DIR)/.config.nopkg
8a46d4bf
PK
678 @grep '^config BR2_PACKAGE_' Config.in.legacy | \
679 while read config pkg; do \
680 echo "# $$pkg is not set" >> $(CONFIG_DIR)/.config.nopkg; done
1039eb74 681 @$(COMMON_CONFIG_ENV) \
39ca6d50 682 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
1039eb74 683 $< --allyesconfig $(CONFIG_CONFIG_IN)
39ca6d50 684 @rm -f $(CONFIG_DIR)/.config.nopkg
6652770f 685
aefad531 686allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
39ca6d50 687 @mkdir -p $(BUILD_DIR)/buildroot-config
dcb79995 688 @grep -v BR2_PACKAGE_ $(BUILDROOT_CONFIG) > $(CONFIG_DIR)/.config.nopkg
1039eb74 689 @$(COMMON_CONFIG_ENV) \
39ca6d50 690 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
1039eb74 691 $< --allnoconfig $(CONFIG_CONFIG_IN)
39ca6d50 692 @rm -f $(CONFIG_DIR)/.config.nopkg
6652770f 693
aefad531 694silentoldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
0b368800
TP
695 @mkdir -p $(BUILD_DIR)/buildroot-config
696 $(COMMON_CONFIG_ENV) $< --silentoldconfig $(CONFIG_CONFIG_IN)
697
aefad531 698defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
39ca6d50 699 @mkdir -p $(BUILD_DIR)/buildroot-config
1ed49963 700 @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
2d523c23 701
aefad531 702%_defconfig: $(BUILD_DIR)/buildroot-config/conf $(TOPDIR)/configs/%_defconfig outputmakefile
6f38119c 703 @mkdir -p $(BUILD_DIR)/buildroot-config
1039eb74 704 @$(COMMON_CONFIG_ENV) $< --defconfig=$(TOPDIR)/configs/$@ $(CONFIG_CONFIG_IN)
6f38119c 705
aefad531 706savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
e1b1a18a 707 @mkdir -p $(BUILD_DIR)/buildroot-config
1ed49963
AVEM
708 @$(COMMON_CONFIG_ENV) $< \
709 --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
710 $(CONFIG_CONFIG_IN)
2d523c23 711
6547bced 712# check if download URLs are outdated
07bae756 713source-check:
7c297459 714 $(MAKE) DL_MODE=SOURCE_CHECK $(EXTRAMAKEARGS) source
825ff341 715
1ed49963 716.PHONY: defconfig savedefconfig
406053d5 717
2d523c23
EA
718#############################################################
719#
720# Cleanup and misc junk
721#
722#############################################################
aefad531
YM
723
724# outputmakefile generates a Makefile in the output directory, if using a
725# separate output directory. This allows convenient use of make in the
726# output directory.
727outputmakefile:
728ifeq ($(NEED_WRAPPER),y)
f082c7c5 729 $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
aefad531
YM
730endif
731
2d523c23 732clean:
406053d5 733 rm -rf $(STAGING_DIR) $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \
7e76f904
LC
734 $(STAMP_DIR) $(BUILD_DIR) $(TOOLCHAIN_DIR) $(BASE_DIR)/staging \
735 $(LEGAL_INFO_DIR)
2d523c23
EA
736
737distclean: clean
406053d5
PK
738ifeq ($(DL_DIR),$(TOPDIR)/dl)
739 rm -rf $(DL_DIR)
740endif
741ifeq ($(O),output)
742 rm -rf $(O)
743endif
dcb79995 744 rm -rf $(BUILDROOT_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/.auto.deps
2d523c23 745
e491fba2
BRF
746help:
747 @echo 'Cleaning:'
406053d5 748 @echo ' clean - delete all files created by build'
e491fba2
BRF
749 @echo ' distclean - delete all non-source files (including .config)'
750 @echo
751 @echo 'Build:'
752 @echo ' all - make world'
2a786415 753 @echo ' toolchain - build toolchain'
040f6a32
SH
754 @echo ' <package>-rebuild - force recompile <package>'
755 @echo ' <package>-reconfigure - force reconfigure <package>'
e491fba2
BRF
756 @echo
757 @echo 'Configuration:'
758 @echo ' menuconfig - interactive curses-based configurator'
15f5bef0 759 @echo ' nconfig - interactive ncurses-based configurator'
c48bbb8c 760 @echo ' xconfig - interactive Qt-based configurator'
2b42aae7 761 @echo ' gconfig - interactive GTK-based configurator'
e491fba2 762 @echo ' oldconfig - resolve any unresolved symbols in .config'
c48bbb8c
PK
763 @echo ' randconfig - New config with random answer to all options'
764 @echo ' defconfig - New config with default answer to all options'
33f454bb 765 @echo ' BR2_DEFCONFIG, if set, is used as input'
d7051da8 766 @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
c48bbb8c
PK
767 @echo ' allyesconfig - New config where all options are accepted with yes'
768 @echo ' allnoconfig - New config where all options are answered with no'
6652770f
PK
769 @echo ' randpackageconfig - New config with random answer to package options'
770 @echo ' allyespackageconfig - New config where pkg options are accepted with yes'
771 @echo ' allnopackageconfig - New config where package options are answered with no'
4bb33dce
PK
772ifeq ($(BR2_PACKAGE_BUSYBOX),y)
773 @echo ' busybox-menuconfig - Run BusyBox menuconfig'
774endif
775ifeq ($(BR2_LINUX_KERNEL),y)
776 @echo ' linux-menuconfig - Run Linux kernel menuconfig'
f5777ce8 777 @echo ' linux-savedefconfig - Run Linux kernel savedefconfig'
4bb33dce
PK
778endif
779ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
780 @echo ' uclibc-menuconfig - Run uClibc menuconfig'
781endif
782ifeq ($(BR2_TOOLCHAIN_CTNG),y)
783 @echo ' ctng-menuconfig - Run crosstool-NG menuconfig'
83f1bf9e
JCPV
784endif
785ifeq ($(BR2_TARGET_BAREBOX),y)
786 @echo ' barebox-menuconfig - Run barebox menuconfig'
787 @echo ' barebox-savedefconfig - Run barebox savedefconfig'
4bb33dce 788endif
8792cf9e
TP
789 @echo
790 @echo 'Documentation:'
791 @echo ' manual - build manual in HTML, split HTML, PDF and txt'
792 @echo ' manual-html - build manual in HTML'
793 @echo ' manual-split-html - build manual in split HTML'
794 @echo ' manual-pdf - build manual in PDF'
795 @echo ' manual-txt - build manual in txt'
796 @echo ' manual-epub - build manual in ePub'
e491fba2
BRF
797 @echo
798 @echo 'Miscellaneous:'
799 @echo ' source - download all sources needed for offline-build'
07bae756 800 @echo ' source-check - check selected packages for valid download URLs'
155971e0 801 @echo ' external-deps - list external packages used'
7e76f904 802 @echo ' legal-info - generate info about license compliance'
e491fba2 803 @echo
15f5bef0
PK
804 @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
805 @echo ' make O=dir - Locate all output files in "dir", including .config'
806 @echo
b9796199 807 @$(foreach b, $(sort $(notdir $(wildcard $(TOPDIR)/configs/*_defconfig))), \
58fd779a
PK
808 printf " %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
809 @echo
8792cf9e 810 @echo 'See docs/README, or generate the Buildroot manual for further details'
663dee48 811 @echo
ba2e7e02 812
e5e8fae8 813release: OUT=buildroot-$(BR2_VERSION)
0dca7065 814
134ab1ce
PK
815# Create release tarballs. We need to fiddle a bit to add the generated
816# documentation to the git output
0dca7065 817release:
134ab1ce
PK
818 git archive --format=tar --prefix=$(OUT)/ master > $(OUT).tar
819 $(MAKE) O=$(OUT) manual-html manual-txt manual-pdf
820 tar rf $(OUT).tar $(OUT)
821 gzip -9 -c < $(OUT).tar > $(OUT).tar.gz
822 bzip2 -9 -c < $(OUT).tar > $(OUT).tar.bz2
823 rm -rf $(OUT) $(OUT).tar
e62d2ecd 824
2b91ab7a
AVEM
825print-version:
826 @echo $(BR2_VERSION_FULL)
827
b7285d00 828include docs/manual/manual.mk
8792cf9e 829
6652770f 830.PHONY: $(noconfig_targets)
This page took 0.420895 seconds and 4 git commands to generate.