blob: 9daf0110cbc80d79834e42b61824b46424ab8d80 [file] [log] [blame]
Thomas De Schampheleire6cbdfb62013-09-05 09:12:15 +02001# Makefile for buildroot
Eric Andersenffde94b2001-12-22 00:56:11 +00002#
Eric Andersen15b26ae2005-02-07 22:19:26 +00003# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
Peter Korsgaarde580ce82014-01-08 17:12:04 +01004# Copyright (C) 2006-2014 by the Buildroot developers <buildroot@uclibc.org>
Luca Ceresoli9af3d3f2016-02-01 15:52:20 +01005# Copyright (C) 2014-2016 by the Buildroot developers <buildroot@buildroot.org>
Eric Andersenffde94b2001-12-22 00:56:11 +00006#
Eric Andersen08782ae2002-04-26 11:45:55 +00007# This program is free software; you can redistribute it and/or modify
Eric Andersen2d523c22004-10-09 01:06:03 +00008# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
Eric Andersenffde94b2001-12-22 00:56:11 +000011#
Eric Andersen2d523c22004-10-09 01:06:03 +000012# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
Eric Andersen08782ae2002-04-26 11:45:55 +000014# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Eric Andersen2d523c22004-10-09 01:06:03 +000015# General Public License for more details.
Peter Korsgaardb30d6732009-01-26 19:42:47 +000016#
Eric Andersen2d523c22004-10-09 01:06:03 +000017# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20#
Eric Andersenffde94b2001-12-22 00:56:11 +000021
Eric Andersen2d523c22004-10-09 01:06:03 +000022#--------------------------------------------------------------
23# Just run 'make menuconfig', configure stuff, then run 'make'.
24# You shouldn't need to mess with anything beyond this point...
25#--------------------------------------------------------------
Yann E. MORIN2d239bb2010-10-31 17:35:09 +010026
Guido Martínezbee57452014-11-21 13:19:00 -030027# Trick for always running with a fixed umask
Guido Martínez1e9f6042015-07-17 00:33:07 +020028UMASK = 0022
Guido Martínezbee57452014-11-21 13:19:00 -030029ifneq ($(shell umask),$(UMASK))
Guido Martínez1e9f6042015-07-17 00:33:07 +020030.PHONY: _all $(MAKECMDGOALS)
Guido Martínezbee57452014-11-21 13:19:00 -030031
Guido Martínez1e9f6042015-07-17 00:33:07 +020032$(MAKECMDGOALS): _all
33 @:
Guido Martínezbee57452014-11-21 13:19:00 -030034
Guido Martínez1e9f6042015-07-17 00:33:07 +020035_all:
36 @umask $(UMASK) && $(MAKE) --no-print-directory $(MAKECMDGOALS)
Guido Martínezbee57452014-11-21 13:19:00 -030037
38else # umask
39
Yann E. MORIN5309e2e2014-10-11 19:34:42 +020040# This is our default rule, so must come first
41all:
42
Yann E. MORINe5e8fae2010-10-31 17:35:10 +010043# Set and export the version string
Peter Korsgaard2318c292015-12-01 22:05:46 +010044export BR2_VERSION := 2016.02-git
Yann E. MORINe5e8fae2010-10-31 17:35:10 +010045
Gustavo Zacarias2ac7da02015-07-14 18:30:39 -030046# Save running make version since it's clobbered by the make package
47RUNNING_MAKE_VERSION := $(MAKE_VERSION)
48
Thomas De Schampheleire0edfb242012-02-08 17:22:17 +010049# Check for minimal make version (note: this check will break at make 10.x)
Fabio Porceddac3e49d62014-04-23 10:39:23 +020050MIN_MAKE_VERSION = 3.81
Gustavo Zacarias2ac7da02015-07-14 18:30:39 -030051ifneq ($(firstword $(sort $(RUNNING_MAKE_VERSION) $(MIN_MAKE_VERSION))),$(MIN_MAKE_VERSION))
52$(error You have make '$(RUNNING_MAKE_VERSION)' installed. GNU make >= $(MIN_MAKE_VERSION) is required)
Thomas De Schampheleire0edfb242012-02-08 17:22:17 +010053endif
54
Fabio Porcedda2afb23a2014-02-14 10:55:08 +010055# Parallel execution of this Makefile is disabled because it changes
56# the packages building order, that can be a problem for two reasons:
57# - If a package has an unspecified optional dependency and that
58# dependency is present when the package is built, it is used,
59# otherwise it isn't (but compilation happily proceeds) so the end
60# result will differ if the order is swapped due to parallel
61# building.
62# - Also changing the building order can be a problem if two packages
63# manipulate the same file in the target directory.
64#
65# Taking into account the above considerations, if you still want to execute
66# this top-level Makefile in parallel comment the ".NOTPARALLEL" line and
Fabio Porcedda1668e1d2015-07-01 10:10:46 +020067# use the -j<jobs> option when building, e.g:
68# make -j$((`getconf _NPROCESSORS_ONLN`+1))
Yann E. MORIN2d239bb2010-10-31 17:35:09 +010069.NOTPARALLEL:
70
Peter Korsgaard6b1dd452009-11-30 17:29:01 +010071# absolute path
Fabio Porceddac3e49d62014-04-23 10:39:23 +020072TOPDIR := $(shell pwd)
73CONFIG_CONFIG_IN = Config.in
74CONFIG = support/kconfig
75DATE := $(shell date +%Y%m%d)
Eric Andersen2d523c22004-10-09 01:06:03 +000076
Yann E. MORIN8258df22010-10-31 17:35:12 +010077# Compute the full local version string so packages can use it as-is
78# Need to export it, so it can be got from environment in children (eg. mconf)
Fabio Porceddac3e49d62014-04-23 10:39:23 +020079export BR2_VERSION_FULL := $(BR2_VERSION)$(shell $(TOPDIR)/support/scripts/setlocalversion)
Yann E. MORIN8258df22010-10-31 17:35:12 +010080
Fabio Porceddac3e49d62014-04-23 10:39:23 +020081noconfig_targets := menuconfig nconfig gconfig xconfig config oldconfig randconfig \
Yann E. MORIN063f4ee2013-12-27 00:04:29 +010082 defconfig %_defconfig allyesconfig allnoconfig silentoldconfig release \
Peter Korsgaard66527702009-10-04 21:57:12 +020083 randpackageconfig allyespackageconfig allnopackageconfig \
Thomas Petazzoni7800b962015-04-26 11:51:03 +020084 print-version olddefconfig
Bernhard Reutner-Fischer9e250352006-12-02 19:01:10 +000085
Thomas Petazzoni256f1422015-04-26 11:51:14 +020086# Some global targets do not trigger a build, but are used to collect
87# metadata, or do various checks. When such targets are triggered,
88# some packages should not do their configuration sanity
89# checks. Provide them a BR_BUILDING variable set to 'y' when we're
90# actually building and they should do their sanity checks.
91#
92# We're building in two situations: when MAKECMDGOALS is empty
93# (default target is to build), or when MAKECMDGOALS contains
94# something else than one of the nobuild_targets.
Thomas Petazzoni4feeb2d2015-04-26 11:51:16 +020095nobuild_targets := source source-check \
96 legal-info external-deps _external-deps \
97 clean distclean
Thomas Petazzoni256f1422015-04-26 11:51:14 +020098ifeq ($(MAKECMDGOALS),)
99BR_BUILDING = y
100else ifneq ($(filter-out $(nobuild_targets),$(MAKECMDGOALS)),)
101BR_BUILDING = y
102endif
103
Thomas Petazzoni580c6d92009-07-30 17:26:49 +0200104# Strip quotes and then whitespaces
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200105qstrip = $(strip $(subst ",,$(1)))
Thomas Petazzoni580c6d92009-07-30 17:26:49 +0200106#"))
107
Peter Korsgaardf85f2de2009-01-25 20:19:01 +0000108# Variables for use in Make constructs
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200109comma := ,
110empty :=
111space := $(empty) $(empty)
Peter Korsgaardf85f2de2009-01-25 20:19:01 +0000112
Will Wagner39ca6d52010-01-11 12:28:50 +0000113ifneq ("$(origin O)", "command line")
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200114O := output
115CONFIG_DIR := $(TOPDIR)
116NEED_WRAPPER =
Will Wagner39ca6d52010-01-11 12:28:50 +0000117else
118# other packages might also support Linux-style out of tree builds
Simon Dawson0be303c2014-05-31 08:55:35 +0100119# with the O=<dir> syntax (E.G. BusyBox does). As make automatically
Will Wagner39ca6d52010-01-11 12:28:50 +0000120# forwards command line variable definitions those packages get very
121# confused. Fix this by telling make to not do so
122MAKEOVERRIDES =
123# strangely enough O is still passed to submakes with MAKEOVERRIDES
124# (with make 3.81 atleast), the only thing that changes is the output
125# of the origin function (command line -> environment).
126# Unfortunately some packages don't look at origin (E.G. uClibc 0.9.31+)
127# To really make O go away, we have to override it.
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200128override O := $(O)
129CONFIG_DIR := $(O)
Peter Korsgaardde846f62010-08-29 23:24:07 +0200130# we need to pass O= everywhere we call back into the toplevel makefile
131EXTRAMAKEARGS = O=$(O)
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200132NEED_WRAPPER = y
Will Wagner39ca6d52010-01-11 12:28:50 +0000133endif
134
Thomas De Schampheleirebb335172013-10-02 22:06:40 +0200135# bash prints the name of the directory on 'cd <dir>' if CDPATH is
136# set, so unset it here to not cause problems. Notice that the export
137# line doesn't affect the environment of $(shell ..) calls, so
138# explictly throw away any output from 'cd' here.
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200139export CDPATH :=
Thomas De Schampheleirebb335172013-10-02 22:06:40 +0200140BASE_DIR := $(shell mkdir -p $(O) && cd $(O) >/dev/null && pwd)
141$(if $(BASE_DIR),, $(error output directory "$(O)" does not exist))
142
Thomas Petazzonia4239f72013-12-05 20:11:10 +0100143
144# Handling of BR2_EXTERNAL.
145#
146# The value of BR2_EXTERNAL is stored in .br-external in the output directory.
147# On subsequent invocations of make, it is read in. It can still be overridden
148# on the command line, therefore the file is re-created every time make is run.
149#
Baruch Siachf6e77102014-12-25 07:36:28 +0200150# When BR2_EXTERNAL is set to an empty value (e.g. explicitly in command
151# line), the .br-external file is removed and we point to
152# support/dummy-external. This makes sure we can unconditionally include the
Thomas Petazzonia4239f72013-12-05 20:11:10 +0100153# Config.in and external.mk from the BR2_EXTERNAL directory. In this case,
154# override is necessary so the user can clear BR2_EXTERNAL from the command
155# line, but the dummy path is still used internally.
156
157BR2_EXTERNAL_FILE = $(BASE_DIR)/.br-external
158-include $(BR2_EXTERNAL_FILE)
159ifeq ($(BR2_EXTERNAL),)
160 override BR2_EXTERNAL = support/dummy-external
161 $(shell rm -f $(BR2_EXTERNAL_FILE))
162else
Yann E. MORIN5f5e5f22014-02-21 23:17:52 +0100163 _BR2_EXTERNAL = $(shell cd $(BR2_EXTERNAL) >/dev/null 2>&1 && pwd)
164 ifeq ($(_BR2_EXTERNAL),)
165 $(error BR2_EXTERNAL='$(BR2_EXTERNAL)' does not exist, relative to $(TOPDIR))
166 endif
167 override BR2_EXTERNAL := $(_BR2_EXTERNAL)
Thomas Petazzonia4239f72013-12-05 20:11:10 +0100168 $(shell echo BR2_EXTERNAL ?= $(BR2_EXTERNAL) > $(BR2_EXTERNAL_FILE))
169endif
170
Masahiro Yamada5b686a02015-04-08 09:53:36 +0900171# To make sure that the environment variable overrides the .config option,
Arnout Vandecappelle67680212014-02-04 16:18:51 +0100172# set this before including .config.
173ifneq ($(BR2_DL_DIR),)
174DL_DIR := $(BR2_DL_DIR)
175endif
Gustavo Zacarias3901cb52015-10-15 10:24:39 -0300176ifneq ($(BR2_CCACHE_DIR),)
177BR_CACHE_DIR := $(BR2_CCACHE_DIR)
178endif
Arnout Vandecappelle67680212014-02-04 16:18:51 +0100179
Yann E. MORINf1fedbb2013-12-28 18:39:13 +0100180# Need that early, before we scan packages
181# Avoids doing the $(or...) everytime
Yann E. MORIN22d05902014-04-13 22:42:37 +0200182BR_GRAPH_OUT := $(or $(BR2_GRAPH_OUT),pdf)
Thomas Petazzonia4239f72013-12-05 20:11:10 +0100183
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200184BUILD_DIR := $(BASE_DIR)/build
185BINARIES_DIR := $(BASE_DIR)/images
186TARGET_DIR := $(BASE_DIR)/target
Thomas De Schampheleirebb335172013-10-02 22:06:40 +0200187# initial definition so that 'make clean' works for most users, even without
188# .config. HOST_DIR will be overwritten later when .config is included.
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200189HOST_DIR := $(BASE_DIR)/host
Thomas Petazzoni4a9a21b2015-02-05 22:19:56 +0100190GRAPHS_DIR := $(BASE_DIR)/graphs
Thomas De Schampheleirebb335172013-10-02 22:06:40 +0200191
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200192LEGAL_INFO_DIR = $(BASE_DIR)/legal-info
193REDIST_SOURCES_DIR_TARGET = $(LEGAL_INFO_DIR)/sources
194REDIST_SOURCES_DIR_HOST = $(LEGAL_INFO_DIR)/host-sources
195LICENSE_FILES_DIR_TARGET = $(LEGAL_INFO_DIR)/licenses
196LICENSE_FILES_DIR_HOST = $(LEGAL_INFO_DIR)/host-licenses
197LEGAL_MANIFEST_CSV_TARGET = $(LEGAL_INFO_DIR)/manifest.csv
198LEGAL_MANIFEST_CSV_HOST = $(LEGAL_INFO_DIR)/host-manifest.csv
199LEGAL_LICENSES_TXT_TARGET = $(LEGAL_INFO_DIR)/licenses.txt
200LEGAL_LICENSES_TXT_HOST = $(LEGAL_INFO_DIR)/host-licenses.txt
201LEGAL_WARNINGS = $(LEGAL_INFO_DIR)/.warnings
202LEGAL_REPORT = $(LEGAL_INFO_DIR)/README
Thomas De Schampheleirebb335172013-10-02 22:06:40 +0200203
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200204BR2_CONFIG = $(CONFIG_DIR)/.config
Yann E. MORIN2b0f4552013-01-13 11:52:20 +0000205
Ulf Samuelssona1b06512008-03-28 07:31:28 +0000206# Pull in the user's configuration file
207ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
Arnout Vandecappelle4113b3c2014-02-04 16:18:52 +0100208-include $(BR2_CONFIG)
Ulf Samuelsson7521f372007-09-12 04:34:16 +0000209endif
Eric Andersen2d523c22004-10-09 01:06:03 +0000210
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000211# To put more focus on warnings, be less verbose as default
212# Use 'make V=1' to see the full commands
Masahiro Yamada6bf9e232015-04-07 14:09:09 +0900213ifeq ("$(origin V)", "command line")
214 KBUILD_VERBOSE = $(V)
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000215endif
216ifndef KBUILD_VERBOSE
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200217 KBUILD_VERBOSE = 0
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000218endif
219
220ifeq ($(KBUILD_VERBOSE),1)
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200221 Q =
Bernhard Reutner-Fischer1669b6e2007-09-22 14:19:22 +0000222ifndef VERBOSE
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200223 VERBOSE = 1
Bernhard Reutner-Fischer1669b6e2007-09-22 14:19:22 +0000224endif
Cédric Marie30702982015-06-23 23:36:06 +0200225export VERBOSE
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000226else
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200227 Q = @
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000228endif
229
Peter Korsgaard69f85922009-01-01 21:20:35 +0000230# we want bash as shell
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200231SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
232 else if [ -x /bin/bash ]; then echo /bin/bash; \
233 else echo sh; fi; fi)
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000234
Peter Korsgaard69f85922009-01-01 21:20:35 +0000235# kconfig uses CONFIG_SHELL
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200236CONFIG_SHELL := $(SHELL)
Peter Korsgaard69f85922009-01-01 21:20:35 +0000237
Cédric Marie474d39a2015-10-08 22:03:37 +0200238export SHELL CONFIG_SHELL Q KBUILD_VERBOSE
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000239
240ifndef HOSTAR
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200241HOSTAR := ar
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000242endif
243ifndef HOSTAS
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200244HOSTAS := as
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000245endif
246ifndef HOSTCC
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200247HOSTCC := gcc
248HOSTCC := $(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000249endif
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200250HOSTCC_NOCCACHE := $(HOSTCC)
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000251ifndef HOSTCXX
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200252HOSTCXX := g++
253HOSTCXX := $(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000254endif
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200255HOSTCXX_NOCCACHE := $(HOSTCXX)
Ulf Samuelsson356133b2007-09-28 19:46:58 +0000256ifndef HOSTCPP
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200257HOSTCPP := cpp
Ulf Samuelsson356133b2007-09-28 19:46:58 +0000258endif
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000259ifndef HOSTLD
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200260HOSTLD := ld
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000261endif
Ulf Samuelsson0f9c5b12007-07-15 21:54:11 +0000262ifndef HOSTLN
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200263HOSTLN := ln
Ulf Samuelsson0f9c5b12007-07-15 21:54:11 +0000264endif
Ulf Samuelsson356133b2007-09-28 19:46:58 +0000265ifndef HOSTNM
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200266HOSTNM := nm
Ulf Samuelsson356133b2007-09-28 19:46:58 +0000267endif
Thomas Petazzonif1f44512013-11-11 17:47:26 +0100268ifndef HOSTOBJCOPY
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200269HOSTOBJCOPY := objcopy
Thomas Petazzonif1f44512013-11-11 17:47:26 +0100270endif
271ifndef HOSTRANLIB
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200272HOSTRANLIB := ranlib
Thomas Petazzonif1f44512013-11-11 17:47:26 +0100273endif
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200274HOSTAR := $(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
275HOSTAS := $(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200276HOSTCPP := $(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
277HOSTLD := $(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
278HOSTLN := $(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
279HOSTNM := $(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
280HOSTOBJCOPY := $(shell which $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo objcopy)
281HOSTRANLIB := $(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib)
Ulf Samuelsson54e93322008-07-06 07:34:41 +0000282
Masahiro Yamadaa9847d12015-04-09 20:28:55 +0900283export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
Thomas Petazzoni17b66af2010-12-07 21:09:56 +0100284export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
Bernhard Reutner-Fischerafc61c62007-06-28 10:47:05 +0000285
Yann E. MORIN91ea9332015-11-09 20:00:21 +0100286# Determine the userland we are running on.
287#
288# Note that, despite its name, we are not interested in the actual
289# architecture name. This is mostly used to determine whether some
290# of the binary tools (e.g. pre-built external toolchains) can run
291# on the current host. So we need to know if the userland we're
292# running on can actually run those toolchains.
293#
294# For example, a 64-bit prebuilt toolchain will not run on a 64-bit
295# kernel if the userland is 32-bit (e.g. in a chroot for example).
296#
297# So, we extract the first part of the tuple the host gcc was
298# configured to generate code for; we assume this is our userland.
299#
Romain Naour86229d62016-01-20 22:53:19 +0100300export HOSTARCH := $(shell LC_ALL=C $(HOSTCC_NOCCACHE) -v 2>&1 | \
Yann E. MORIN91ea9332015-11-09 20:00:21 +0100301 sed -e '/^Target: \([^-]*\).*/!d' \
302 -e 's//\1/' \
303 -e 's/i.86/x86/' \
304 -e 's/sun4u/sparc64/' \
305 -e 's/arm.*/arm/' \
306 -e 's/sa110/arm/' \
307 -e 's/ppc64/powerpc64/' \
308 -e 's/ppc/powerpc/' \
309 -e 's/macppc/powerpc/' \
310 -e 's/sh.*/sh/' )
311
Arnout Vandecappelle12825f72015-12-31 01:34:13 +0100312HOSTCC_VERSION := $(shell $(HOSTCC_NOCCACHE) --version | \
313 sed -n -r 's/^.* ([0-9]*)\.([0-9]*)\.([0-9]*)[ ]*.*/\1 \2/p')
314
315# For gcc >= 5.x, we only need the major version.
316ifneq ($(firstword $(HOSTCC_VERSION)),4)
317HOSTCC_VERSION := $(firstword $(HOSTCC_VERSION))
318endif
319
Arnout Vandecappelle670cb302012-06-30 10:29:22 +0000320# Make sure pkg-config doesn't look outside the buildroot tree
Bjørn Forsman0515fe42015-01-03 00:58:47 +0100321HOST_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH)
Arnout Vandecappelle670cb302012-06-30 10:29:22 +0000322unexport PKG_CONFIG_PATH
Charles Manning4f607ed2012-12-02 11:13:04 +0000323unexport PKG_CONFIG_SYSROOT_DIR
Peter Korsgaardbdf472d2013-09-11 14:15:15 +0200324unexport PKG_CONFIG_LIBDIR
Arnout Vandecappelle670cb302012-06-30 10:29:22 +0000325
Thomas Petazzoni91123a62012-07-02 04:21:14 +0000326# Having DESTDIR set in the environment confuses the installation
327# steps of some packages.
328unexport DESTDIR
329
Gustavo Zacariasbed61a72013-07-11 11:37:33 -0300330# Causes breakage with packages that needs host-ruby
331unexport RUBYOPT
332
Thomas De Schampheleire3ed0ead2014-08-15 15:40:34 +0200333include package/pkg-utils.mk
Yann E. MORINab6a6212014-10-03 19:01:52 +0200334include package/doc-asciidoc.mk
Thomas De Schampheleire3ed0ead2014-08-15 15:40:34 +0200335
Bernhard Reutner-Fischercfe511b2007-09-29 13:58:30 +0000336ifeq ($(BR2_HAVE_DOT_CONFIG),y)
Eric Andersenffde94b2001-12-22 00:56:11 +0000337
Alexandre Belloni95442bb2013-06-07 12:13:46 +0200338################################################################################
Peter Korsgaard2c649042007-06-19 15:19:27 +0000339#
340# Hide troublesome environment variables from sub processes
341#
Alexandre Belloni95442bb2013-06-07 12:13:46 +0200342################################################################################
Peter Korsgaard2c649042007-06-19 15:19:27 +0000343unexport CROSS_COMPILE
344unexport ARCH
Daniel Nyström2bf3c162010-12-26 00:29:42 +0100345unexport CC
346unexport CXX
347unexport CPP
Tom Rini344c5a22015-11-17 14:04:04 -0500348unexport RANLIB
Daniel Nyström2bf3c162010-12-26 00:29:42 +0100349unexport CFLAGS
350unexport CXXFLAGS
351unexport GREP_OPTIONS
Nixf5437a62014-01-26 22:58:02 +0000352unexport TAR_OPTIONS
Peter Korsgaard12c9f7d2011-12-12 10:25:50 +0100353unexport CONFIG_SITE
Stephan Hoffmann32314b42012-08-17 13:54:16 +0200354unexport QMAKESPEC
Nathan Lynch20ca0082012-07-10 07:37:22 +0000355unexport TERMINFO
Risto Avila6d3b9752014-09-24 04:37:13 +0000356unexport MACHINE
Guido Martínez2e323302015-07-25 16:07:39 -0300357unexport O
Bernhard Reutner-Fischer7dcbbfb2007-06-02 09:05:40 +0000358
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200359GNU_HOST_NAME := $(shell support/gnuconfig/config.guess)
Thomas Petazzoni60281cb2010-04-10 23:17:25 +0200360
Thomas Petazzoni8a58e022015-04-12 18:37:48 +0200361PACKAGES :=
Yann E. MORIN0ea851c2015-10-22 22:33:56 +0200362PACKAGES_ALL :=
Bernhard Reutner-Fischeracc706b2007-07-23 11:29:38 +0000363
Peter Korsgaard89464a92009-09-30 17:39:44 +0200364# silent mode requested?
Fabio Porceddafffb68a2015-01-01 21:03:50 +0100365QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
Peter Korsgaard89464a92009-09-30 17:39:44 +0200366
Thomas Petazzoni397fe5c2009-09-05 15:49:30 +0200367# Strip off the annoying quoting
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200368ARCH := $(call qstrip,$(BR2_ARCH))
Thomas Petazzoni65e80a02010-04-28 23:40:57 +0200369
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200370KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
Peter Korsgaard891973f2010-10-17 23:32:37 +0200371 -e s/i.86/i386/ -e s/sun4u/sparc64/ \
Maxime Ripardf59aeca2013-05-06 00:14:55 +0000372 -e s/arcle/arc/ \
Peter Korsgaard8332ffa2013-06-10 14:04:03 +0200373 -e s/arceb/arc/ \
Peter Korsgaard891973f2010-10-17 23:32:37 +0200374 -e s/arm.*/arm/ -e s/sa110/arm/ \
Bamvor Jian Zhang827ba462015-03-18 17:49:48 +0800375 -e s/aarch64.*/arm64/ \
Mike Frysinger871db072011-02-07 00:49:11 -0500376 -e s/bfin/blackfin/ \
Peter Korsgaard891973f2010-10-17 23:32:37 +0200377 -e s/parisc64/parisc/ \
Jeff Baileya426a912014-05-24 23:59:22 -0700378 -e s/powerpc64.*/powerpc/ \
Peter Korsgaard891973f2010-10-17 23:32:37 +0200379 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
Jan Drazilc2205812014-03-19 13:01:05 +0100380 -e s/sh.*/sh/ \
381 -e s/microblazeel/microblaze/)
Peter Korsgaard891973f2010-10-17 23:32:37 +0200382
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200383ZCAT := $(call qstrip,$(BR2_ZCAT))
384BZCAT := $(call qstrip,$(BR2_BZCAT))
385XZCAT := $(call qstrip,$(BR2_XZCAT))
386TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
Bernhard Reutner-Fischer1dbe6e32007-08-21 17:56:47 +0000387
Gustavo Zacariasa2b4f7f2011-02-02 10:05:56 -0300388# packages compiled for the host go here
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200389HOST_DIR := $(call qstrip,$(BR2_HOST_DIR))
Thomas Petazzoni397fe5c2009-09-05 15:49:30 +0200390
Samuel Martincaa329b2014-04-15 00:31:04 +0200391# Quotes are needed for spaces and all in the original PATH content.
Samuel Martinc7d660b2014-04-15 00:31:05 +0200392BR_PATH = "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(HOST_DIR)/usr/bin:$(HOST_DIR)/usr/sbin:$(PATH)"
Samuel Martincaa329b2014-04-15 00:31:04 +0200393
Thomas Petazzoni9226a992012-11-17 03:52:14 +0000394# Location of a file giving a big fat warning that output/target
395# should not be used as the root filesystem.
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200396TARGET_DIR_WARNING_FILE = $(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
Thomas Petazzoni9226a992012-11-17 03:52:14 +0000397
Thomas Petazzoni17b66af2010-12-07 21:09:56 +0100398ifeq ($(BR2_CCACHE),y)
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200399CCACHE := $(HOST_DIR)/usr/bin/ccache
Gustavo Zacarias3901cb52015-10-15 10:24:39 -0300400BR_CACHE_DIR ?= $(call qstrip,$(BR2_CCACHE_DIR))
Arnout Vandecappellee7ab4b42014-02-04 16:18:50 +0100401export BR_CACHE_DIR
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200402HOSTCC := $(CCACHE) $(HOSTCC)
Thomas Petazzoni17b66af2010-12-07 21:09:56 +0100403HOSTCXX := $(CCACHE) $(HOSTCXX)
Arnout Vandecappelle792f1272015-10-04 13:28:56 +0100404else
405export BR_NO_CCACHE
Thomas Petazzoni17b66af2010-12-07 21:09:56 +0100406endif
407
Yann E. MORIN2b0f4552013-01-13 11:52:20 +0000408# Scripts in support/ or post-build scripts may need to reference
409# these locations, so export them so it is easier to use
Arnout Vandecappelle4113b3c2014-02-04 16:18:52 +0100410export BR2_CONFIG
Yann E. MORIN2b0f4552013-01-13 11:52:20 +0000411export TARGET_DIR
412export STAGING_DIR
413export HOST_DIR
414export BINARIES_DIR
Peter Korsgaard1300cb52013-01-14 10:02:29 +0100415export BASE_DIR
Yann E. MORIN2b0f4552013-01-13 11:52:20 +0000416
Alexandre Belloni95442bb2013-06-07 12:13:46 +0200417################################################################################
Eric Andersen08782ae2002-04-26 11:45:55 +0000418#
Eric Andersenef407d32004-01-29 23:21:00 +0000419# You should probably leave this stuff alone unless you know
Eric Andersen08782ae2002-04-26 11:45:55 +0000420# what you are doing.
421#
Alexandre Belloni95442bb2013-06-07 12:13:46 +0200422################################################################################
Manuel Novoa III d632d422003-11-01 05:34:41 +0000423
Bernhard Reutner-Fischer6547bce2007-08-22 12:35:41 +0000424all: world
Eric Andersenffde94b2001-12-22 00:56:11 +0000425
Arnout Vandecappelle (Essensium/Mind)ebcfa982012-11-12 10:08:28 +0000426# Include legacy before the other things, because package .mk files
427# may rely on it.
428ifneq ($(BR2_DEPRECATED),y)
429include Makefile.legacy
430endif
431
Thomas Petazzoni486253d2012-04-17 16:45:23 +0200432include package/Makefile.in
Thomas De Schampheleirea7926682012-02-08 17:22:16 +0100433include support/dependencies/dependencies.mk
434
Yann E. MORIN11c10762014-07-27 21:28:32 +0200435include toolchain/*.mk
Thomas Petazzoni8b0905b2013-10-08 20:17:01 +0200436include toolchain/*/*.mk
Bernhard Reutner-Fischeracc706b2007-07-23 11:29:38 +0000437
Thomas Petazzoniee0246e2011-09-29 21:57:38 +0200438# Include the package override file if one has been provided in the
439# configuration.
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200440PACKAGE_OVERRIDE_FILE = $(call qstrip,$(BR2_PACKAGE_OVERRIDE_FILE))
Thomas Petazzoniee0246e2011-09-29 21:57:38 +0200441ifneq ($(PACKAGE_OVERRIDE_FILE),)
442-include $(PACKAGE_OVERRIDE_FILE)
443endif
444
Jérôme Pouiller741cbcc2013-09-03 10:45:41 +0200445include $(sort $(wildcard package/*/*.mk))
Eric Andersend06645d2005-02-10 03:06:39 +0000446
Peter Korsgaard64d8e9a2010-11-07 19:33:11 +0100447include boot/common.mk
Peter Korsgaard64d8e9a2010-11-07 19:33:11 +0100448include linux/linux.mk
Philippe Reynes00b1ff62014-05-05 09:52:13 +0200449include fs/common.mk
Peter Korsgaard64d8e9a2010-11-07 19:33:11 +0100450
Thomas Petazzoni8eb8aaf2013-12-05 20:11:11 +0100451include $(BR2_EXTERNAL)/external.mk
452
Thomas Petazzoni3e1b33a2016-01-01 01:01:23 +0100453# Now we are sure we have all the packages scanned and defined. We now
454# check for each package in the list of enabled packages, that all its
455# dependencies are indeed enabled.
456#
457# Only trigger the check for default builds. If the user forces building
458# a package, even if not enabled in the configuration, we want to accept
459# it.
460#
461ifeq ($(MAKECMDGOALS),)
462
463define CHECK_ONE_DEPENDENCY
464ifeq ($$($(2)_TYPE),target)
465ifeq ($$($(2)_IS_VIRTUAL),)
466ifneq ($$($$($(2)_KCONFIG_VAR)),y)
467$$(error $$($(2)_NAME) is in the dependency chain of $$($(1)_NAME) that \
468has added it to its _DEPENDENCIES variable without selecting it or \
469depending on it from Config.in)
470endif
471endif
472endif
473endef
474
475$(foreach pkg,$(call UPPERCASE,$(PACKAGES)),\
476 $(foreach dep,$(call UPPERCASE,$($(pkg)_FINAL_ALL_DEPENDENCIES)),\
477 $(eval $(call CHECK_ONE_DEPENDENCY,$(pkg),$(dep))$(sep))))
478
479endif
480
Thomas Petazzonid21a1762013-06-30 21:29:06 +0200481dirs: $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
Arnout Vandecappellee0c60672014-03-17 09:22:33 +0100482 $(HOST_DIR) $(BINARIES_DIR)
Ulf Samuelssonf958d892007-08-14 07:45:01 +0000483
Arnout Vandecappelle4113b3c2014-02-04 16:18:52 +0100484$(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG)
Peter Korsgaard879058a2013-12-16 13:49:28 +0100485 $(MAKE1) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" silentoldconfig
Thomas Petazzoni0b368802010-08-22 07:27:09 +0200486
487prepare: $(BUILD_DIR)/buildroot-config/auto.conf
488
Fabio Porceddaa2487752014-02-14 10:55:06 +0100489world: target-post-image
Fabio Porcedda2a786412013-01-14 22:02:00 +0000490
491.PHONY: all world toolchain dirs clean distclean source outputmakefile \
Arnout Vandecappelledf79e352015-03-21 20:49:45 +0100492 legal-info legal-info-prepare legal-info-clean printvars help \
Thomas Petazzoni7800b962015-04-26 11:51:03 +0200493 list-defconfigs target-finalize target-post-image source-check
Jon Nelsonc79e9982002-01-05 20:26:15 +0000494
Alexandre Belloni95442bb2013-06-07 12:13:46 +0200495################################################################################
Eric Andersen08782ae2002-04-26 11:45:55 +0000496#
Eric Andersenef407d32004-01-29 23:21:00 +0000497# staging and target directories do NOT list these as
Mike Frysingerd99c31c2006-05-26 01:18:09 +0000498# dependencies anywhere else
Eric Andersen08782ae2002-04-26 11:45:55 +0000499#
Alexandre Belloni95442bb2013-06-07 12:13:46 +0200500################################################################################
Maxime Hadjinlian7a6b83a2015-07-14 13:36:25 +0200501$(BUILD_DIR) $(TARGET_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST):
Bernhard Reutner-Fischer8d583fc2007-01-30 00:58:18 +0000502 @mkdir -p $@
Manuel Novoa III 3ad3d8a2004-09-03 00:49:43 +0000503
Yann E. MORINcb34ea52015-11-26 23:13:41 +0100504# Populating the staging with the base directories is handled by the skeleton package
Eric Andersen08782ae2002-04-26 11:45:55 +0000505$(STAGING_DIR):
Yann E. MORINcb34ea52015-11-26 23:13:41 +0100506 @mkdir -p $(STAGING_DIR)
Gustavo Zacarias5ad139e2010-12-31 08:39:05 -0300507 @ln -snf $(STAGING_DIR) $(BASE_DIR)/staging
Eric Andersen08782ae2002-04-26 11:45:55 +0000508
Thomas De Schampheleire7ad28652013-11-07 11:41:22 +0100509RSYNC_VCS_EXCLUSIONS = \
510 --exclude .svn --exclude .git --exclude .hg --exclude .bzr \
511 --exclude CVS
512
Thomas De Schampheleire2a970452012-06-21 19:34:50 +0000513STRIP_FIND_CMD = find $(TARGET_DIR)
514ifneq (,$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)))
515STRIP_FIND_CMD += \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) -prune -o
516endif
Thomas Petazzoni12d15072014-02-04 16:36:18 +0100517STRIP_FIND_CMD += -type f \( -perm /111 -o -name '*.so*' \)
Thomas De Schampheleire06635912014-04-30 21:29:02 +0200518# file exclusions:
519# - libpthread.so: a non-stripped libpthread shared library is needed for
520# proper debugging of pthread programs using gdb.
Peter Seiderer1edb4c52015-10-06 21:51:36 +0200521# - ld.so: a non-stripped dynamic linker library is needed for valgrind
Thomas De Schampheleire06635912014-04-30 21:29:02 +0200522# - kernel modules (*.ko): do not function properly when stripped like normal
523# applications and libraries. Normally kernel modules are already excluded
524# by the executable permission check above, so the explicit exclusion is only
525# done for kernel modules with incorrect permissions.
Peter Seiderer1edb4c52015-10-06 21:51:36 +0200526STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* ld-*.so* *.ko $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print0
Thomas De Schampheleire2a970452012-06-21 19:34:50 +0000527
Fabio Porcedda28685d52014-06-27 14:15:57 +0200528ifeq ($(BR2_ECLIPSE_REGISTER),y)
529define TOOLCHAIN_ECLIPSE_REGISTER
530 ./support/scripts/eclipse-register-toolchain `readlink -f $(O)` \
531 $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
532endef
533TARGET_FINALIZE_HOOKS += TOOLCHAIN_ECLIPSE_REGISTER
534endif
535
Fabio Porcedda33de7402014-06-27 14:15:58 +0200536# Generate locale data. Basically, we call the localedef program
537# (built by the host-localedef package) for each locale. The input
538# data comes preferably from the toolchain, or if the toolchain does
539# not have them (Linaro toolchains), we use the ones available on the
540# host machine.
541ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
Thomas Petazzoni404f4932014-11-13 23:17:23 +0100542GLIBC_GENERATE_LOCALES = $(call qstrip,$(BR2_GENERATE_LOCALE))
543ifneq ($(GLIBC_GENERATE_LOCALES),)
Thomas Petazzoni8a58e022015-04-12 18:37:48 +0200544PACKAGES += host-localedef
Fabio Porcedda33de7402014-06-27 14:15:58 +0200545
Thomas Petazzoni404f4932014-11-13 23:17:23 +0100546define GENERATE_GLIBC_LOCALES
Fabio Porcedda33de7402014-06-27 14:15:58 +0200547 $(Q)mkdir -p $(TARGET_DIR)/usr/lib/locale/
Thomas Petazzoni404f4932014-11-13 23:17:23 +0100548 $(Q)for locale in $(GLIBC_GENERATE_LOCALES) ; do \
Fabio Porcedda33de7402014-06-27 14:15:58 +0200549 inputfile=`echo $${locale} | cut -f1 -d'.'` ; \
550 charmap=`echo $${locale} | cut -f2 -d'.' -s` ; \
551 if test -z "$${charmap}" ; then \
552 charmap="UTF-8" ; \
553 fi ; \
554 echo "Generating locale $${inputfile}.$${charmap}" ; \
555 I18NPATH=$(STAGING_DIR)/usr/share/i18n:/usr/share/i18n \
556 $(HOST_DIR)/usr/bin/localedef \
557 --prefix=$(TARGET_DIR) \
558 --$(call LOWERCASE,$(BR2_ENDIAN))-endian \
559 -i $${inputfile} -f $${charmap} \
560 $${locale} ; \
561 done
562endef
Thomas Petazzoni404f4932014-11-13 23:17:23 +0100563TARGET_FINALIZE_HOOKS += GENERATE_GLIBC_LOCALES
Fabio Porcedda33de7402014-06-27 14:15:58 +0200564endif
565endif
566
Fabio Porcedda58d82dd2014-04-29 17:32:34 +0200567ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
568LOCALE_WHITELIST = $(BUILD_DIR)/locales.nopurge
569LOCALE_NOPURGE = $(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
570
Valentine Barshakb7915712015-07-14 01:45:28 +0200571# This piece of junk does the following:
572# First collect the whitelist in a file.
573# Then go over all the locale dirs and for each subdir, check if it exists
574# in the whitelist file. If it doesn't, kill it.
575# Finally, specifically for X11, regenerate locale.dir from the whitelist.
Fabio Porcedda8d384fa2014-06-27 14:15:55 +0200576define PURGE_LOCALES
Fabio Porcedda58d82dd2014-04-29 17:32:34 +0200577 rm -f $(LOCALE_WHITELIST)
Sven Neumann201adef2014-06-18 11:23:30 +0200578 for i in $(LOCALE_NOPURGE) locale-archive; do echo $$i >> $(LOCALE_WHITELIST); done
Fabio Porcedda58d82dd2014-04-29 17:32:34 +0200579
Arnout Vandecappelle36480ea2015-07-13 23:00:34 +0200580 for dir in $(wildcard $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/lib/locale)); \
Fabio Porcedda58d82dd2014-04-29 17:32:34 +0200581 do \
Arnout Vandecappelle805240b2015-07-14 01:45:27 +0200582 for langdir in $$dir/*; \
Fabio Porcedda58d82dd2014-04-29 17:32:34 +0200583 do \
Arnout Vandecappelle805240b2015-07-14 01:45:27 +0200584 grep -qx $${langdir##*/} $(LOCALE_WHITELIST) || rm -rf $$langdir; \
Fabio Porcedda58d82dd2014-04-29 17:32:34 +0200585 done; \
586 done
Valentine Barshakb7915712015-07-14 01:45:28 +0200587 if [ -d $(TARGET_DIR)/usr/share/X11/locale ]; \
588 then \
589 for lang in $(LOCALE_NOPURGE); \
590 do \
591 if [ -f $(TARGET_DIR)/usr/share/X11/locale/$$lang/XLC_LOCALE ]; \
592 then \
593 echo "$$lang/XLC_LOCALE: $$lang"; \
594 fi \
595 done > $(TARGET_DIR)/usr/share/X11/locale/locale.dir; \
596 fi
Fabio Porcedda58d82dd2014-04-29 17:32:34 +0200597endef
Fabio Porcedda8d384fa2014-06-27 14:15:55 +0200598TARGET_FINALIZE_HOOKS += PURGE_LOCALES
Fabio Porcedda58d82dd2014-04-29 17:32:34 +0200599endif
600
Fabio Porceddad4c0c642014-02-20 15:26:18 +0100601$(TARGETS_ROOTFS): target-finalize
602
Thomas Petazzoni8a58e022015-04-12 18:37:48 +0200603target-finalize: $(PACKAGES)
Thomas De Schampheleire6f6a2cf2014-05-12 16:19:27 +0200604 @$(call MESSAGE,"Finalizing target directory")
Fabio Porcedda8d384fa2014-06-27 14:15:55 +0200605 $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
Valentine Barshak94d3aa12012-10-02 08:52:15 +0000606 rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
Luca Ceresolidf99efb2013-03-06 07:14:26 +0000607 $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
608 $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake
609 find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
Herve Codina87f3ede2015-09-15 15:27:06 +0200610 find $(TARGET_DIR)/lib $(TARGET_DIR)/usr/lib $(TARGET_DIR)/usr/libexec \
611 \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
Malte Starostike48a72e2010-07-24 21:29:56 +0200612ifneq ($(BR2_PACKAGE_GDB),y)
613 rm -rf $(TARGET_DIR)/usr/share/gdb
614endif
Maxime Hadjinlian76d1c722015-07-12 17:25:57 +0200615ifneq ($(BR2_PACKAGE_BASH),y)
616 rm -rf $(TARGET_DIR)/usr/share/bash-completion
617endif
618ifneq ($(BR2_PACKAGE_ZSH),y)
619 rm -rf $(TARGET_DIR)/usr/share/zsh
620endif
Peter Korsgaard32faf352009-04-07 21:04:31 +0000621 rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
Peter Korsgaard32faf352009-04-07 21:04:31 +0000622 rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
Thomas Petazzoni87b06372010-04-10 22:42:45 +0200623 rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
Paulius Zaleckasd701a822010-05-05 13:09:36 +0300624 rm -rf $(TARGET_DIR)/usr/share/gtk-doc
Mike Frysinger68ad6d42010-11-18 16:25:58 -0500625 -rmdir $(TARGET_DIR)/usr/share 2>/dev/null
Andrew Parlane26f215d2015-03-18 15:10:29 +0000626 $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true
Peter Korsgaardf627ebe2013-08-26 00:34:45 +0200627 if test -d $(TARGET_DIR)/lib/modules; then \
erico.nunese4dde252015-05-09 17:25:33 -0300628 find $(TARGET_DIR)/lib/modules -type f -name '*.ko' -print0 | \
629 xargs -0 -r $(KSTRIPCMD); fi
Mike Frysinger8101c9a2010-11-17 18:55:43 -0500630
Richard Braun6ae78862012-11-20 07:18:11 +0000631# See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
632# besides the one in which crash occurred; or SIGTRAP kills my program when
633# I set a breakpoint"
634ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
635 find $(TARGET_DIR)/lib -type f -name 'libpthread*.so*' | \
Thomas Petazzoni52e70732013-08-20 13:03:03 +0200636 xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
Richard Braun6ae78862012-11-20 07:18:11 +0000637endif
638
Peter Seiderer1edb4c52015-10-06 21:51:36 +0200639# Valgrind needs ld.so with enough information, so only strip
640# debugging symbols.
641 find $(TARGET_DIR)/lib -type f -name 'ld-*.so*' | \
642 xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
Thomas Petazzoni9c407232016-01-01 22:23:39 +0100643 test -f $(TARGET_DIR)/etc/ld.so.conf && \
644 { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
645 test -d $(TARGET_DIR)/etc/ld.so.conf.d && \
646 { echo "ERROR: we shouldn't have a /etc/ld.so.conf.d directory"; exit 1; } || true
Thomas Petazzoni4ccde7f2010-08-30 22:52:18 +0200647 mkdir -p $(TARGET_DIR)/etc
Peter Korsgaard451a8872012-02-14 12:58:25 +0100648 ( \
649 echo "NAME=Buildroot"; \
650 echo "VERSION=$(BR2_VERSION_FULL)"; \
651 echo "ID=buildroot"; \
652 echo "VERSION_ID=$(BR2_VERSION)"; \
653 echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
654 ) > $(TARGET_DIR)/etc/os-release
Peter Korsgaard912ea812009-09-30 17:40:24 +0200655
Luca Ceresolie9b77122013-04-08 06:50:16 +0000656 @$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
657 $(call MESSAGE,"Copying overlay $(d)"); \
Peter Korsgaard99e82b02014-02-04 17:55:33 +0100658 rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
Guido Martínez361d3572014-11-21 13:19:01 -0300659 --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
Luca Ceresolie9b77122013-04-08 06:50:16 +0000660 $(d)/ $(TARGET_DIR)$(sep))
Arnout Vandecappelle (Essensium/Mind)7f860892013-02-05 07:16:00 +0000661
Philippe Reynesdbf49782012-11-17 13:01:22 +0100662 @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
Luca Ceresoli1b9b1682013-04-08 06:50:14 +0000663 $(call MESSAGE,"Executing post-build script $(s)"); \
Yann E. MORIN9806bf52014-03-10 21:51:33 +0100664 $(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
Daniel Mackeed7d872009-07-08 22:46:58 +0200665
Thomas Petazzonifbb3b862014-02-28 21:05:27 +0100666target-post-image: $(TARGETS_ROOTFS) target-finalize
Thomas Petazzoni9fa32ba2013-02-07 11:58:43 +0000667 @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
Luca Ceresoli6d90a692013-04-08 06:50:15 +0000668 $(call MESSAGE,"Executing post-image script $(s)"); \
Yann E. MORIN9806bf52014-03-10 21:51:33 +0100669 $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
Thomas Petazzoni9fa32ba2013-02-07 11:58:43 +0000670
Thomas Petazzoni17dcad02015-04-26 11:51:12 +0200671source: $(foreach p,$(PACKAGES),$(p)-all-source)
Eric Andersenffde94b2001-12-22 00:56:11 +0000672
Thomas Petazzoni7e679cc2015-04-26 11:51:01 +0200673_external-deps: $(foreach p,$(PACKAGES),$(p)-all-external-deps)
Peter Korsgaard155971e2008-03-04 12:19:16 +0000674external-deps:
Thomas Petazzoni7e679cc2015-04-26 11:51:01 +0200675 @$(MAKE1) -Bs $(EXTRAMAKEARGS) _external-deps | sort -u
Peter Korsgaard155971e2008-03-04 12:19:16 +0000676
Thomas Petazzoni7800b962015-04-26 11:51:03 +0200677# check if download URLs are outdated
Thomas Petazzonif9b92822015-04-26 11:51:06 +0200678source-check: $(foreach p,$(PACKAGES),$(p)-all-source-check)
Thomas Petazzoni7800b962015-04-26 11:51:03 +0200679
Luca Ceresoli7e76f902012-05-17 19:33:00 +0200680legal-info-clean:
681 @rm -fr $(LEGAL_INFO_DIR)
682
683legal-info-prepare: $(LEGAL_INFO_DIR)
684 @$(call MESSAGE,"Collecting legal info")
Thomas De Schampheleire366f17f2013-11-12 09:47:58 +0100685 @$(call legal-license-file,buildroot,COPYING,COPYING,HOST)
Clayton Shotwellaf629e42014-07-21 08:46:31 -0500686 @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,TARGET)
687 @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,HOST)
688 @$(call legal-manifest,buildroot,$(BR2_VERSION_FULL),GPLv2+,COPYING,not saved,not saved,HOST)
Luca Ceresoli7e76f902012-05-17 19:33:00 +0200689 @$(call legal-warning,the Buildroot source code has not been saved)
Arnout Vandecappelle4113b3c2014-02-04 16:18:52 +0100690 @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
Luca Ceresoli7e76f902012-05-17 19:33:00 +0200691
Thomas Petazzoni5db22b32015-04-12 18:37:50 +0200692legal-info: dirs legal-info-clean legal-info-prepare $(foreach p,$(PACKAGES),$(p)-all-legal-info) \
Thomas De Schampheleire858334c2013-11-12 09:47:59 +0100693 $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST)
Luca Ceresoli7e76f902012-05-17 19:33:00 +0200694 @cat support/legal-info/README.header >>$(LEGAL_REPORT)
695 @if [ -r $(LEGAL_WARNINGS) ]; then \
696 cat support/legal-info/README.warnings-header \
697 $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \
698 cat $(LEGAL_WARNINGS); fi
699 @echo "Legal info produced in $(LEGAL_INFO_DIR)"
700 @rm -f $(LEGAL_WARNINGS)
701
Thomas Petazzonib7d6c8a2010-05-13 19:20:33 +0200702show-targets:
Thomas Petazzoniadc88b82015-04-12 18:37:51 +0200703 @echo $(PACKAGES) $(TARGETS_ROOTFS)
Thomas Petazzonib7d6c8a2010-05-13 19:20:33 +0200704
Yann E. MORINe16bf922013-12-28 18:39:11 +0100705graph-build: $(O)/build/build-time.log
Thomas Petazzoni4a9a21b2015-02-05 22:19:56 +0100706 @install -d $(GRAPHS_DIR)
Yann E. MORINe16bf922013-12-28 18:39:11 +0100707 $(foreach o,name build duration,./support/scripts/graph-build-time \
708 --type=histogram --order=$(o) --input=$(<) \
Thomas Petazzoni4a9a21b2015-02-05 22:19:56 +0100709 --output=$(GRAPHS_DIR)/build.hist-$(o).$(BR_GRAPH_OUT) \
Yann E. MORIN8ae78382014-02-23 16:59:11 +0100710 $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
Yann E. MORINe16bf922013-12-28 18:39:11 +0100711 $(foreach t,packages steps,./support/scripts/graph-build-time \
712 --type=pie-$(t) --input=$(<) \
Thomas Petazzoni4a9a21b2015-02-05 22:19:56 +0100713 --output=$(GRAPHS_DIR)/build.pie-$(t).$(BR_GRAPH_OUT) \
Yann E. MORIN8ae78382014-02-23 16:59:11 +0100714 $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
Yann E. MORINe16bf922013-12-28 18:39:11 +0100715
Fabio Porceddad3c1c642014-06-17 11:33:54 +0200716graph-depends-requirements:
Thomas Petazzoni664f2702014-06-13 14:17:19 +0200717 @dot -? >/dev/null 2>&1 || \
Fabio Porceddad3c1c642014-06-17 11:33:54 +0200718 { echo "ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit 1; }
719
720graph-depends: graph-depends-requirements
Thomas Petazzoni4a9a21b2015-02-05 22:19:56 +0100721 @$(INSTALL) -d $(GRAPHS_DIR)
Yann E. MORIN56eb3942014-01-07 23:46:04 +0100722 @cd "$(CONFIG_DIR)"; \
Yann E. MORIN287a8822014-05-16 23:05:13 +0200723 $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \
Yann E. MORIN5e7020e2016-02-07 22:34:26 +0100724 -o $(GRAPHS_DIR)/$(@).dot
725 dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) \
726 -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT) \
727 $(GRAPHS_DIR)/$(@).dot
Yann E. MORIN0cfe3ab2013-12-28 18:39:12 +0100728
Thomas Petazzoni24c75fb2015-10-17 15:33:44 +0200729graph-size:
730 $(Q)mkdir -p $(GRAPHS_DIR)
731 $(Q)$(TOPDIR)/support/scripts/size-stats --builddir $(BASE_DIR) \
732 --graph $(GRAPHS_DIR)/graph-size.$(BR_GRAPH_OUT) \
733 --file-size-csv $(GRAPHS_DIR)/file-size-stats.csv \
734 --package-size-csv $(GRAPHS_DIR)/package-size-stats.csv
735
Yann E. MORIN9dac9862016-02-07 22:34:29 +0100736check-dependencies:
737 @cd "$(CONFIG_DIR)"; \
738 $(TOPDIR)/support/scripts/graph-depends -C
739
Bernhard Reutner-Fischercfe511b2007-09-29 13:58:30 +0000740else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
Eric Andersen2d523c22004-10-09 01:06:03 +0000741
742all: menuconfig
743
Arnout Vandecappelle (Essensium/Mind)1ed49962013-02-05 07:16:02 +0000744endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
745
Eric Andersen2d523c22004-10-09 01:06:03 +0000746# configuration
747# ---------------------------------------------------------------------------
748
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200749HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
Bernhard Reutner-Fischerc0d7d4e2007-07-09 18:23:20 +0000750export HOSTCFLAGS
751
Peter Korsgaard2cc210c2010-06-20 23:05:32 +0200752$(BUILD_DIR)/buildroot-config/%onf:
753 mkdir -p $(@D)/lxdialog
Bjørn Forsman0515fe42015-01-03 00:58:47 +0100754 PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \
755 obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
Alper Yildirimb0df9df2009-07-20 19:17:10 +0200756
Arnout Vandecappelle (Essensium/Mind)1ed49962013-02-05 07:16:02 +0000757DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
758
759# We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
760# recognize that if it's still at its default $(CONFIG_DIR)/defconfig
Thomas Petazzoni1039eb72010-08-21 18:29:27 +0200761COMMON_CONFIG_ENV = \
Arnout Vandecappelle (Essensium/Mind)1ed49962013-02-05 07:16:02 +0000762 BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \
Thomas Petazzoni1039eb72010-08-21 18:29:27 +0200763 KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
764 KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
Thomas Petazzoni0b368802010-08-22 07:27:09 +0200765 KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
Arnout Vandecappelle4113b3c2014-02-04 16:18:52 +0100766 BR2_CONFIG=$(BR2_CONFIG) \
Arnout Vandecappelle53903a12015-04-11 01:49:02 +0200767 BR2_EXTERNAL=$(BR2_EXTERNAL) \
Arnout Vandecappelle12825f72015-12-31 01:34:13 +0100768 HOST_GCC_VERSION="$(HOSTCC_VERSION)" \
Arnout Vandecappelle53903a12015-04-11 01:49:02 +0200769 SKIP_LEGACY=
Alper Yildirimb0df9df2009-07-20 19:17:10 +0200770
Yann E. MORINaefad532010-09-26 10:56:12 +0200771xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
Peter Korsgaard610255e2010-11-24 15:30:54 +0100772 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
Alper Yildirimb0df9df2009-07-20 19:17:10 +0200773
Yann E. MORINaefad532010-09-26 10:56:12 +0200774gconfig: $(BUILD_DIR)/buildroot-config/gconf outputmakefile
Peter Korsgaard610255e2010-11-24 15:30:54 +0100775 @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
Peter Korsgaard2b42aae2010-06-05 21:09:05 +0200776
Yann E. MORINaefad532010-09-26 10:56:12 +0200777menuconfig: $(BUILD_DIR)/buildroot-config/mconf outputmakefile
Peter Korsgaard610255e2010-11-24 15:30:54 +0100778 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
Eric Andersen2d523c22004-10-09 01:06:03 +0000779
Yann E. MORINaefad532010-09-26 10:56:12 +0200780nconfig: $(BUILD_DIR)/buildroot-config/nconf outputmakefile
Peter Korsgaard610255e2010-11-24 15:30:54 +0100781 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
Eric Andersen2d523c22004-10-09 01:06:03 +0000782
Yann E. MORINaefad532010-09-26 10:56:12 +0200783config: $(BUILD_DIR)/buildroot-config/conf outputmakefile
Thomas Petazzoni1039eb72010-08-21 18:29:27 +0200784 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
Eric Andersen2d523c22004-10-09 01:06:03 +0000785
Arnout Vandecappelle53903a12015-04-11 01:49:02 +0200786# For the config targets that automatically select options, we pass
787# SKIP_LEGACY=y to disable the legacy options. However, in that case
788# no values are set for the legacy options so a subsequent oldconfig
789# will query them. Therefore, run an additional olddefconfig.
790
Yann E. MORINaefad532010-09-26 10:56:12 +0200791oldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
Thomas Petazzoni1039eb72010-08-21 18:29:27 +0200792 @$(COMMON_CONFIG_ENV) $< --oldconfig $(CONFIG_CONFIG_IN)
Eric Andersen2d523c22004-10-09 01:06:03 +0000793
Yann E. MORINaefad532010-09-26 10:56:12 +0200794randconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
Arnout Vandecappelle53903a12015-04-11 01:49:02 +0200795 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --randconfig $(CONFIG_CONFIG_IN)
796 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
Eric Andersen2d523c22004-10-09 01:06:03 +0000797
Yann E. MORINaefad532010-09-26 10:56:12 +0200798allyesconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
Arnout Vandecappelle53903a12015-04-11 01:49:02 +0200799 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --allyesconfig $(CONFIG_CONFIG_IN)
800 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
Eric Andersen2d523c22004-10-09 01:06:03 +0000801
Yann E. MORINaefad532010-09-26 10:56:12 +0200802allnoconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
Arnout Vandecappelle53903a12015-04-11 01:49:02 +0200803 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --allnoconfig $(CONFIG_CONFIG_IN)
804 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
Eric Andersen2d523c22004-10-09 01:06:03 +0000805
Yann E. MORINaefad532010-09-26 10:56:12 +0200806randpackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
Arnout Vandecappelle4113b3c2014-02-04 16:18:52 +0100807 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
Arnout Vandecappelle53903a12015-04-11 01:49:02 +0200808 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
Will Wagner39ca6d52010-01-11 12:28:50 +0000809 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
Thomas Petazzoni1039eb72010-08-21 18:29:27 +0200810 $< --randconfig $(CONFIG_CONFIG_IN)
Will Wagner39ca6d52010-01-11 12:28:50 +0000811 @rm -f $(CONFIG_DIR)/.config.nopkg
Arnout Vandecappelle53903a12015-04-11 01:49:02 +0200812 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
Peter Korsgaard66527702009-10-04 21:57:12 +0200813
Yann E. MORINaefad532010-09-26 10:56:12 +0200814allyespackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
Arnout Vandecappelle4113b3c2014-02-04 16:18:52 +0100815 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
Arnout Vandecappelle53903a12015-04-11 01:49:02 +0200816 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
Will Wagner39ca6d52010-01-11 12:28:50 +0000817 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
Thomas Petazzoni1039eb72010-08-21 18:29:27 +0200818 $< --allyesconfig $(CONFIG_CONFIG_IN)
Will Wagner39ca6d52010-01-11 12:28:50 +0000819 @rm -f $(CONFIG_DIR)/.config.nopkg
Arnout Vandecappelle53903a12015-04-11 01:49:02 +0200820 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
Peter Korsgaard66527702009-10-04 21:57:12 +0200821
Yann E. MORINaefad532010-09-26 10:56:12 +0200822allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
Arnout Vandecappelle4113b3c2014-02-04 16:18:52 +0100823 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
Arnout Vandecappelle53903a12015-04-11 01:49:02 +0200824 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
Will Wagner39ca6d52010-01-11 12:28:50 +0000825 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
Thomas Petazzoni1039eb72010-08-21 18:29:27 +0200826 $< --allnoconfig $(CONFIG_CONFIG_IN)
Will Wagner39ca6d52010-01-11 12:28:50 +0000827 @rm -f $(CONFIG_DIR)/.config.nopkg
Arnout Vandecappelle53903a12015-04-11 01:49:02 +0200828 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
Peter Korsgaard66527702009-10-04 21:57:12 +0200829
Yann E. MORINaefad532010-09-26 10:56:12 +0200830silentoldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
Thomas Petazzoni0b368802010-08-22 07:27:09 +0200831 $(COMMON_CONFIG_ENV) $< --silentoldconfig $(CONFIG_CONFIG_IN)
832
Thomas Petazzoni9db3b472013-04-04 11:24:25 +0000833olddefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
Thomas Petazzoni9db3b472013-04-04 11:24:25 +0000834 $(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN)
835
Yann E. MORINaefad532010-09-26 10:56:12 +0200836defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
Arnout Vandecappelle (Essensium/Mind)1ed49962013-02-05 07:16:02 +0000837 @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
Eric Andersen2d523c22004-10-09 01:06:03 +0000838
Arnout Vandecappelle32babbf2015-02-02 16:34:46 +0100839# Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig
Yann E. MORINaefad532010-09-26 10:56:12 +0200840%_defconfig: $(BUILD_DIR)/buildroot-config/conf $(TOPDIR)/configs/%_defconfig outputmakefile
Arnout Vandecappelle32babbf2015-02-02 16:34:46 +0100841 @$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(TOPDIR)/configs/$@ \
842 $< --defconfig=$(TOPDIR)/configs/$@ $(CONFIG_CONFIG_IN)
Thomas Petazzoni6f381192010-08-11 20:01:23 +0200843
Thomas Petazzoniff9d6e32013-12-05 20:11:12 +0100844%_defconfig: $(BUILD_DIR)/buildroot-config/conf $(BR2_EXTERNAL)/configs/%_defconfig outputmakefile
Arnout Vandecappelle32babbf2015-02-02 16:34:46 +0100845 @$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(BR2_EXTERNAL)/configs/$@ \
846 $< --defconfig=$(BR2_EXTERNAL)/configs/$@ $(CONFIG_CONFIG_IN)
Thomas Petazzoniff9d6e32013-12-05 20:11:12 +0100847
Yann E. MORINaefad532010-09-26 10:56:12 +0200848savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
Arnout Vandecappelle (Essensium/Mind)1ed49962013-02-05 07:16:02 +0000849 @$(COMMON_CONFIG_ENV) $< \
850 --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
851 $(CONFIG_CONFIG_IN)
Herve Codinaf71a6212015-06-04 10:16:33 +0200852 @$(SED) '/BR2_DEFCONFIG=/d' $(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig)
Eric Andersen2d523c22004-10-09 01:06:03 +0000853
Arnout Vandecappelle (Essensium/Mind)1ed49962013-02-05 07:16:02 +0000854.PHONY: defconfig savedefconfig
Peter Korsgaard406053d2009-11-20 14:05:48 +0100855
Alexandre Belloni95442bb2013-06-07 12:13:46 +0200856################################################################################
Eric Andersen2d523c22004-10-09 01:06:03 +0000857#
858# Cleanup and misc junk
859#
Alexandre Belloni95442bb2013-06-07 12:13:46 +0200860################################################################################
Yann E. MORINaefad532010-09-26 10:56:12 +0200861
862# outputmakefile generates a Makefile in the output directory, if using a
863# separate output directory. This allows convenient use of make in the
864# output directory.
865outputmakefile:
866ifeq ($(NEED_WRAPPER),y)
Thomas Petazzonif082c7c2011-08-31 23:35:02 +0200867 $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
Yann E. MORINaefad532010-09-26 10:56:12 +0200868endif
869
Yann E. MORIN376fda82015-11-04 22:42:39 +0100870# printvars prints all the variables currently defined in our
871# Makefiles. Alternatively, if a non-empty VARS variable is passed,
872# only the variables matching the make pattern passed in VARS are
873# displayed.
Émeric Vigier98b616d2013-05-29 00:41:11 +0200874printvars:
875 @$(foreach V, \
Yann E. MORIN376fda82015-11-04 22:42:39 +0100876 $(sort $(if $(VARS),$(filter $(VARS),$(.VARIABLES)),$(.VARIABLES))), \
Émeric Vigier98b616d2013-05-29 00:41:11 +0200877 $(if $(filter-out environment% default automatic, \
878 $(origin $V)), \
879 $(info $V=$($V) ($(value $V)))))
880
Eric Andersen2d523c22004-10-09 01:06:03 +0000881clean:
Thomas De Schampheleire300eb6b2013-09-30 13:09:27 +0200882 rm -rf $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \
Arnout Vandecappellee0c60672014-03-17 09:22:33 +0100883 $(BUILD_DIR) $(BASE_DIR)/staging \
Thomas Petazzoni4a9a21b2015-02-05 22:19:56 +0100884 $(LEGAL_INFO_DIR) $(GRAPHS_DIR)
Eric Andersen2d523c22004-10-09 01:06:03 +0000885
886distclean: clean
Peter Korsgaard406053d2009-11-20 14:05:48 +0100887ifeq ($(DL_DIR),$(TOPDIR)/dl)
888 rm -rf $(DL_DIR)
889endif
890ifeq ($(O),output)
891 rm -rf $(O)
892endif
Yann E. MORINad24d832015-03-29 11:56:21 +0200893 rm -rf $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/..config.tmp \
Yann E. MORINf8c0e452015-10-22 22:34:00 +0200894 $(CONFIG_DIR)/.auto.deps $(BR2_EXTERNAL_FILE)
Eric Andersen2d523c22004-10-09 01:06:03 +0000895
Bernhard Reutner-Fischere491fba2007-07-08 12:20:58 +0000896help:
897 @echo 'Cleaning:'
Peter Korsgaard406053d2009-11-20 14:05:48 +0100898 @echo ' clean - delete all files created by build'
Bernhard Reutner-Fischere491fba2007-07-08 12:20:58 +0000899 @echo ' distclean - delete all non-source files (including .config)'
900 @echo
901 @echo 'Build:'
902 @echo ' all - make world'
Fabio Porcedda2a786412013-01-14 22:02:00 +0000903 @echo ' toolchain - build toolchain'
Bernhard Reutner-Fischere491fba2007-07-08 12:20:58 +0000904 @echo
905 @echo 'Configuration:'
906 @echo ' menuconfig - interactive curses-based configurator'
Peter Korsgaard15f5bef2011-02-01 08:41:01 +0100907 @echo ' nconfig - interactive ncurses-based configurator'
Peter Korsgaardc48bbb82009-10-04 21:42:54 +0200908 @echo ' xconfig - interactive Qt-based configurator'
Peter Korsgaard2b42aae2010-06-05 21:09:05 +0200909 @echo ' gconfig - interactive GTK-based configurator'
Bernhard Reutner-Fischere491fba2007-07-08 12:20:58 +0000910 @echo ' oldconfig - resolve any unresolved symbols in .config'
Thomas Petazzoni9db3b472013-04-04 11:24:25 +0000911 @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
912 @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
Peter Korsgaardc48bbb82009-10-04 21:42:54 +0200913 @echo ' randconfig - New config with random answer to all options'
914 @echo ' defconfig - New config with default answer to all options'
Arnout Vandecappelle33f454b2012-04-28 07:14:50 +0000915 @echo ' BR2_DEFCONFIG, if set, is used as input'
Frank Hunleth5c1a75c2015-02-11 08:14:49 -0500916 @echo ' savedefconfig - Save current config to BR2_DEFCONFIG (minimal config)'
Peter Korsgaardc48bbb82009-10-04 21:42:54 +0200917 @echo ' allyesconfig - New config where all options are accepted with yes'
918 @echo ' allnoconfig - New config where all options are answered with no'
Peter Korsgaard66527702009-10-04 21:57:12 +0200919 @echo ' randpackageconfig - New config with random answer to package options'
920 @echo ' allyespackageconfig - New config where pkg options are accepted with yes'
921 @echo ' allnopackageconfig - New config where package options are answered with no'
Arnout Vandecappelleb1e0b6d2015-03-21 20:49:47 +0100922 @echo
923 @echo 'Package-specific:'
924 @echo ' <pkg> - Build and install <pkg> and all its dependencies'
925 @echo ' <pkg>-source - Only download the source files for <pkg>'
926 @echo ' <pkg>-extract - Extract <pkg> sources'
927 @echo ' <pkg>-patch - Apply patches to <pkg>'
928 @echo ' <pkg>-depends - Build <pkg>'\''s dependencies'
929 @echo ' <pkg>-configure - Build <pkg> up to the configure step'
930 @echo ' <pkg>-build - Build <pkg> up to the build step'
931 @echo ' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies'
932 @echo ' <pkg>-dirclean - Remove <pkg> build directory'
933 @echo ' <pkg>-reconfigure - Restart the build from the configure step'
934 @echo ' <pkg>-rebuild - Restart the build from the build step'
Peter Korsgaard4bb33dc2011-04-25 00:10:45 +0200935ifeq ($(BR2_PACKAGE_BUSYBOX),y)
936 @echo ' busybox-menuconfig - Run BusyBox menuconfig'
937endif
938ifeq ($(BR2_LINUX_KERNEL),y)
939 @echo ' linux-menuconfig - Run Linux kernel menuconfig'
Jean-Christophe PLAGNIOL-VILLARDf5777ce2011-08-22 21:28:47 +0200940 @echo ' linux-savedefconfig - Run Linux kernel savedefconfig'
Yegor Yefremov7916b972015-04-02 21:34:46 +0200941 @echo ' linux-update-defconfig - Save the Linux configuration to the path specified'
942 @echo ' by BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE'
Peter Korsgaard4bb33dc2011-04-25 00:10:45 +0200943endif
944ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
945 @echo ' uclibc-menuconfig - Run uClibc menuconfig'
946endif
Jean-Christophe PLAGNIOL-VILLARD83f1bf92011-08-22 21:28:48 +0200947ifeq ($(BR2_TARGET_BAREBOX),y)
948 @echo ' barebox-menuconfig - Run barebox menuconfig'
949 @echo ' barebox-savedefconfig - Run barebox savedefconfig'
950endif
Bernhard Reutner-Fischere491fba2007-07-08 12:20:58 +0000951 @echo
Thomas Petazzoni8792cf92011-10-10 10:46:40 +0200952 @echo 'Documentation:'
Thomas De Schampheleire55ecab12013-09-19 12:47:14 +0200953 @echo ' manual - build manual in all formats'
Thomas Petazzoni8792cf92011-10-10 10:46:40 +0200954 @echo ' manual-html - build manual in HTML'
955 @echo ' manual-split-html - build manual in split HTML'
956 @echo ' manual-pdf - build manual in PDF'
Thomas De Schampheleire462e9912013-10-18 22:31:26 +0200957 @echo ' manual-text - build manual in text'
Thomas Petazzoni8792cf92011-10-10 10:46:40 +0200958 @echo ' manual-epub - build manual in ePub'
Yann E. MORINe16bf922013-12-28 18:39:11 +0100959 @echo ' graph-build - generate graphs of the build times'
Yann E. MORIN0cfe3ab2013-12-28 18:39:12 +0100960 @echo ' graph-depends - generate graph of the dependency tree'
Thomas Petazzoni24c75fb2015-10-17 15:33:44 +0200961 @echo ' graph-size - generate stats of the filesystem size'
Yann E. MORINde6377e2015-04-23 23:04:06 +0200962 @echo ' list-defconfigs - list all defconfigs (pre-configured minimal systems)'
Thomas Petazzoni8792cf92011-10-10 10:46:40 +0200963 @echo
Bernhard Reutner-Fischere491fba2007-07-08 12:20:58 +0000964 @echo 'Miscellaneous:'
965 @echo ' source - download all sources needed for offline-build'
Thomas De Schampheleire07bae752012-06-21 19:38:42 +0000966 @echo ' source-check - check selected packages for valid download URLs'
Peter Korsgaard155971e2008-03-04 12:19:16 +0000967 @echo ' external-deps - list external packages used'
Luca Ceresoli7e76f902012-05-17 19:33:00 +0200968 @echo ' legal-info - generate info about license compliance'
Bernhard Reutner-Fischere491fba2007-07-08 12:20:58 +0000969 @echo
Peter Korsgaard15f5bef2011-02-01 08:41:01 +0100970 @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
971 @echo ' make O=dir - Locate all output files in "dir", including .config'
972 @echo
Arnout Vandecappellef42a5802015-03-21 20:49:46 +0100973 @echo 'For further details, see README, generate the Buildroot manual, or consult'
974 @echo 'it on-line at http://buildroot.org/docs.html'
975 @echo
976
977list-defconfigs:
Thomas Petazzoniff9d6e32013-12-05 20:11:12 +0100978 @echo 'Built-in configs:'
Danomi Mocelopolisb9796192011-07-17 22:17:08 +0200979 @$(foreach b, $(sort $(notdir $(wildcard $(TOPDIR)/configs/*_defconfig))), \
Peter Korsgaard58fd7792009-10-04 22:09:25 +0200980 printf " %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
Thomas Petazzoniff9d6e32013-12-05 20:11:12 +0100981ifneq ($(wildcard $(BR2_EXTERNAL)/configs/*_defconfig),)
982 @echo
983 @echo 'User-provided configs:'
984 @$(foreach b, $(sort $(notdir $(wildcard $(BR2_EXTERNAL)/configs/*_defconfig))), \
985 printf " %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
986endif
Peter Korsgaard58fd7792009-10-04 22:09:25 +0200987 @echo
Bernhard Reutner-Fischerba2e7e02007-06-25 10:56:13 +0000988
Fabio Porceddac3e49d62014-04-23 10:39:23 +0200989release: OUT = buildroot-$(BR2_VERSION)
Peter Korsgaard0dca7062010-11-04 00:00:00 +0100990
Peter Korsgaard134ab1c2012-02-03 22:03:29 +0100991# Create release tarballs. We need to fiddle a bit to add the generated
992# documentation to the git output
Peter Korsgaard0dca7062010-11-04 00:00:00 +0100993release:
Peter Korsgaardc6715b62013-09-17 13:42:07 +0200994 git archive --format=tar --prefix=$(OUT)/ HEAD > $(OUT).tar
Thomas De Schampheleire462e9912013-10-18 22:31:26 +0200995 $(MAKE) O=$(OUT) manual-html manual-text manual-pdf
Thomas De Schampheleire15cb9872015-07-17 12:20:35 +0200996 $(MAKE) O=$(OUT) manual-clean
Peter Korsgaard134ab1c2012-02-03 22:03:29 +0100997 tar rf $(OUT).tar $(OUT)
998 gzip -9 -c < $(OUT).tar > $(OUT).tar.gz
999 bzip2 -9 -c < $(OUT).tar > $(OUT).tar.bz2
1000 rm -rf $(OUT) $(OUT).tar
Peter Korsgaarde62d2ec2009-01-15 19:36:06 +00001001
Arnout Vandecappelle (Essensium/Mind)2b91ab72012-03-11 12:16:39 +01001002print-version:
1003 @echo $(BR2_VERSION_FULL)
1004
Thomas Petazzonib7285d02012-04-17 16:45:22 +02001005include docs/manual/manual.mk
Yann E. MORINf70d6412014-10-03 19:01:58 +02001006-include $(BR2_EXTERNAL)/docs/*/*.mk
Thomas Petazzoni8792cf92011-10-10 10:46:40 +02001007
Peter Korsgaard66527702009-10-04 21:57:12 +02001008.PHONY: $(noconfig_targets)
Guido Martínezbee57452014-11-21 13:19:00 -03001009
1010endif #umask