1*4882a593Smuzhiyun# Makefile for buildroot 2*4882a593Smuzhiyun# 3*4882a593Smuzhiyun# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org> 4*4882a593Smuzhiyun# Copyright (C) 2006-2014 by the Buildroot developers <buildroot@uclibc.org> 5*4882a593Smuzhiyun# Copyright (C) 2014-2020 by the Buildroot developers <buildroot@buildroot.org> 6*4882a593Smuzhiyun# 7*4882a593Smuzhiyun# This program is free software; you can redistribute it and/or modify 8*4882a593Smuzhiyun# it under the terms of the GNU General Public License as published by 9*4882a593Smuzhiyun# the Free Software Foundation; either version 2 of the License, or 10*4882a593Smuzhiyun# (at your option) any later version. 11*4882a593Smuzhiyun# 12*4882a593Smuzhiyun# This program is distributed in the hope that it will be useful, 13*4882a593Smuzhiyun# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*4882a593Smuzhiyun# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15*4882a593Smuzhiyun# General Public License for more details. 16*4882a593Smuzhiyun# 17*4882a593Smuzhiyun# You should have received a copy of the GNU General Public License 18*4882a593Smuzhiyun# along with this program; if not, write to the Free Software 19*4882a593Smuzhiyun# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20*4882a593Smuzhiyun# 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun#-------------------------------------------------------------- 23*4882a593Smuzhiyun# Just run 'make menuconfig', configure stuff, then run 'make'. 24*4882a593Smuzhiyun# You shouldn't need to mess with anything beyond this point... 25*4882a593Smuzhiyun#-------------------------------------------------------------- 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun# Delete default rules. We don't use them. This saves a bit of time. 28*4882a593Smuzhiyun.SUFFIXES: 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun# we want bash as shell 31*4882a593SmuzhiyunSHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ 32*4882a593Smuzhiyun else if [ -x /bin/bash ]; then echo /bin/bash; \ 33*4882a593Smuzhiyun else echo sh; fi; fi) 34*4882a593Smuzhiyun 35*4882a593SmuzhiyunO_LATEST := $(CURDIR)/output/latest 36*4882a593SmuzhiyunDEFCONFIG = $(firstword $(filter %_defconfig,$(MAKECMDGOALS))) 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun# Set O variable if not already done on the command line; 39*4882a593Smuzhiyun# or avoid confusing packages that can use the O=<dir> syntax for out-of-tree 40*4882a593Smuzhiyun# build by preventing it from being forwarded to sub-make calls. 41*4882a593Smuzhiyunifneq ("$(origin O)", "command line") 42*4882a593Smuzhiyunifneq ($(DEFCONFIG),) 43*4882a593Smuzhiyun# Set O=output/<board> for defconfig 44*4882a593SmuzhiyunO := $(patsubst %_defconfig,$(CURDIR)/output/%,$(DEFCONFIG)) 45*4882a593Smuzhiyunelse 46*4882a593Smuzhiyun# Prefer BUILDROOT_OUTPUT_DIR env and $(CURDIR)/output/latest symlink 47*4882a593SmuzhiyunO := $(BUILDROOT_OUTPUT_DIR) 48*4882a593SmuzhiyunO := $(if $(O),$(O),$(realpath $(CURDIR)/output/latest)) 49*4882a593Smuzhiyunendif 50*4882a593Smuzhiyun# Fallback to $(CURDIR)/output 51*4882a593SmuzhiyunO := $(if $(O),$(O),$(CURDIR)/output) 52*4882a593Smuzhiyunendif 53*4882a593Smuzhiyun 54*4882a593Smuzhiyunifneq ($(BUILDROOT_OUTPUT_DIR),) 55*4882a593Smuzhiyunifneq ($(BUILDROOT_OUTPUT_DIR),$(O)) 56*4882a593Smuzhiyun$(warning "BUILDROOT_OUTPUT_DIR environment unmatched with output dir!") 57*4882a593Smuzhiyun$(warning "BUILDROOT_OUTPUT_DIR: $(BUILDROOT_OUTPUT_DIR)") 58*4882a593Smuzhiyun$(warning "Output dir: $(O)") 59*4882a593Smuzhiyun$(error "Please unset it: unset BUILDROOT_OUTPUT_DIR") 60*4882a593Smuzhiyunendif 61*4882a593Smuzhiyunendif 62*4882a593Smuzhiyun 63*4882a593Smuzhiyunifneq ($(DEFCONFIG),) 64*4882a593Smuzhiyun$(shell rm -rf $(O_LATEST); mkdir -p $(CURDIR)/output) 65*4882a593Smuzhiyun$(shell ln -rsf $(O) $(O_LATEST)) 66*4882a593Smuzhiyunendif 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun# Check if the current Buildroot execution meets all the pre-requisites. 69*4882a593Smuzhiyun# If they are not met, Buildroot will actually do its job in a sub-make meeting 70*4882a593Smuzhiyun# its pre-requisites, which are: 71*4882a593Smuzhiyun# 1- Permissive enough umask: 72*4882a593Smuzhiyun# Wrong or too restrictive umask will prevent Buildroot and packages from 73*4882a593Smuzhiyun# creating files and directories. 74*4882a593Smuzhiyun# 2- Absolute canonical CWD (i.e. $(CURDIR)): 75*4882a593Smuzhiyun# Otherwise, some packages will use CWD as-is, others will compute its 76*4882a593Smuzhiyun# absolute canonical path. This makes harder tracking and fixing host 77*4882a593Smuzhiyun# machine path leaks. 78*4882a593Smuzhiyun# 3- Absolute canonical output location (i.e. $(O)): 79*4882a593Smuzhiyun# For the same reason as the one for CWD. 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun# Remove the trailing '/.' from $(O) as it can be added by the makefile wrapper 82*4882a593Smuzhiyun# installed in the $(O) directory. 83*4882a593Smuzhiyun# Also remove the trailing '/' the user can set when on the command line. 84*4882a593Smuzhiyunoverride O := $(patsubst %/,%,$(patsubst %.,%,$(O))) 85*4882a593Smuzhiyun# Make sure $(O) actually exists before calling realpath on it; this is to 86*4882a593Smuzhiyun# avoid empty CANONICAL_O in case on non-existing entry. 87*4882a593SmuzhiyunCANONICAL_O := $(shell mkdir -p $(O) >/dev/null 2>&1)$(realpath $(O)) 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun# gcc fails to build when the srcdir contains a '@' 90*4882a593Smuzhiyunifneq ($(findstring @,$(CANONICAL_O)),) 91*4882a593Smuzhiyun$(error The build directory can not contain a '@') 92*4882a593Smuzhiyunendif 93*4882a593Smuzhiyun 94*4882a593SmuzhiyunCANONICAL_CURDIR = $(realpath $(CURDIR)) 95*4882a593Smuzhiyun 96*4882a593SmuzhiyunREQ_UMASK = 0022 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun# Make sure O= is passed (with its absolute canonical path) everywhere the 99*4882a593Smuzhiyun# toplevel makefile is called back. 100*4882a593SmuzhiyunEXTRAMAKEARGS := O=$(CANONICAL_O) 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun# Check Buildroot execution pre-requisites here. 103*4882a593Smuzhiyunifneq ($(shell umask):$(CURDIR):$(O),$(REQ_UMASK):$(CANONICAL_CURDIR):$(CANONICAL_O)) 104*4882a593Smuzhiyun.PHONY: _all $(MAKECMDGOALS) 105*4882a593Smuzhiyun 106*4882a593Smuzhiyun$(MAKECMDGOALS): _all 107*4882a593Smuzhiyun @: 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun_all: 110*4882a593Smuzhiyun @umask $(REQ_UMASK) && \ 111*4882a593Smuzhiyun $(MAKE) -C $(CANONICAL_CURDIR) --no-print-directory \ 112*4882a593Smuzhiyun $(MAKECMDGOALS) $(EXTRAMAKEARGS) 113*4882a593Smuzhiyun 114*4882a593Smuzhiyunelse # umask / $(CURDIR) / $(O) 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun# This is our default rule, so must come first 117*4882a593Smuzhiyunall: 118*4882a593Smuzhiyun.PHONY: all 119*4882a593Smuzhiyun 120*4882a593Smuzhiyun# Set and export the version string 121*4882a593Smuzhiyunexport BR2_VERSION := 2021.11 122*4882a593Smuzhiyun# Actual time the release is cut (for reproducible builds) 123*4882a593SmuzhiyunBR2_VERSION_EPOCH = 1638734000 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun# Save running make version since it's clobbered by the make package 126*4882a593SmuzhiyunRUNNING_MAKE_VERSION := $(MAKE_VERSION) 127*4882a593Smuzhiyun 128*4882a593Smuzhiyun# Check for minimal make version (note: this check will break at make 10.x) 129*4882a593SmuzhiyunMIN_MAKE_VERSION = 3.81 130*4882a593Smuzhiyunifneq ($(firstword $(sort $(RUNNING_MAKE_VERSION) $(MIN_MAKE_VERSION))),$(MIN_MAKE_VERSION)) 131*4882a593Smuzhiyun$(error You have make '$(RUNNING_MAKE_VERSION)' installed. GNU make >= $(MIN_MAKE_VERSION) is required) 132*4882a593Smuzhiyunendif 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun# absolute path 135*4882a593SmuzhiyunTOPDIR := $(CURDIR) 136*4882a593SmuzhiyunCONFIG_CONFIG_IN = Config.in 137*4882a593SmuzhiyunCONFIG = support/kconfig 138*4882a593SmuzhiyunDATE := $(shell date +%Y%m%d) 139*4882a593Smuzhiyun 140*4882a593Smuzhiyun# Compute the full local version string so packages can use it as-is 141*4882a593Smuzhiyun# Need to export it, so it can be got from environment in children (eg. mconf) 142*4882a593Smuzhiyun 143*4882a593SmuzhiyunBR2_LOCALVERSION := $(shell $(TOPDIR)/support/scripts/setlocalversion) 144*4882a593Smuzhiyunifeq ($(BR2_LOCALVERSION),) 145*4882a593Smuzhiyunexport BR2_VERSION_FULL := $(BR2_VERSION) 146*4882a593Smuzhiyunelse 147*4882a593Smuzhiyunexport BR2_VERSION_FULL := $(BR2_LOCALVERSION) 148*4882a593Smuzhiyunendif 149*4882a593Smuzhiyun 150*4882a593Smuzhiyun# List of targets and target patterns for which .config doesn't need to be read in 151*4882a593Smuzhiyunnoconfig_targets := menuconfig nconfig gconfig xconfig config oldconfig randconfig \ 152*4882a593Smuzhiyun defconfig %_defconfig allyesconfig allnoconfig alldefconfig syncconfig release \ 153*4882a593Smuzhiyun randpackageconfig allyespackageconfig allnopackageconfig \ 154*4882a593Smuzhiyun print-version olddefconfig distclean manual manual-% check-package check-flake8 155*4882a593Smuzhiyun 156*4882a593Smuzhiyun# Some global targets do not trigger a build, but are used to collect 157*4882a593Smuzhiyun# metadata, or do various checks. When such targets are triggered, 158*4882a593Smuzhiyun# some packages should not do their configuration sanity 159*4882a593Smuzhiyun# checks. Provide them a BR_BUILDING variable set to 'y' when we're 160*4882a593Smuzhiyun# actually building and they should do their sanity checks. 161*4882a593Smuzhiyun# 162*4882a593Smuzhiyun# We're building in two situations: when MAKECMDGOALS is empty 163*4882a593Smuzhiyun# (default target is to build), or when MAKECMDGOALS contains 164*4882a593Smuzhiyun# something else than one of the nobuild_targets. 165*4882a593Smuzhiyunnobuild_targets := source %-source \ 166*4882a593Smuzhiyun legal-info %-legal-info external-deps _external-deps \ 167*4882a593Smuzhiyun clean distclean help show-targets graph-depends \ 168*4882a593Smuzhiyun %-graph-depends %-show-depends %-show-version \ 169*4882a593Smuzhiyun graph-build graph-size list-defconfigs \ 170*4882a593Smuzhiyun savedefconfig update-defconfig printvars 171*4882a593Smuzhiyunifeq ($(MAKECMDGOALS),) 172*4882a593SmuzhiyunBR_BUILDING = y 173*4882a593Smuzhiyunelse ifneq ($(filter-out $(nobuild_targets),$(MAKECMDGOALS)),) 174*4882a593SmuzhiyunBR_BUILDING = y 175*4882a593Smuzhiyunendif 176*4882a593Smuzhiyun 177*4882a593Smuzhiyun# We call make recursively to build packages. The command-line overrides that 178*4882a593Smuzhiyun# are passed to Buildroot don't apply to those package build systems. In 179*4882a593Smuzhiyun# particular, we don't want to pass down the O=<dir> option for out-of-tree 180*4882a593Smuzhiyun# builds, because the value specified on the command line will not be correct 181*4882a593Smuzhiyun# for packages. 182*4882a593SmuzhiyunMAKEOVERRIDES := 183*4882a593Smuzhiyun 184*4882a593Smuzhiyun# Include some helper macros and variables 185*4882a593Smuzhiyuninclude support/misc/utils.mk 186*4882a593Smuzhiyun 187*4882a593Smuzhiyun# Set variables related to in-tree or out-of-tree build. 188*4882a593Smuzhiyun# Here, both $(O) and $(CURDIR) are absolute canonical paths. 189*4882a593Smuzhiyunifeq ($(O),$(CURDIR)/output) 190*4882a593SmuzhiyunCONFIG_DIR := $(CURDIR) 191*4882a593SmuzhiyunNEED_WRAPPER = 192*4882a593Smuzhiyunelse 193*4882a593SmuzhiyunCONFIG_DIR := $(O) 194*4882a593SmuzhiyunNEED_WRAPPER = y 195*4882a593Smuzhiyunendif 196*4882a593Smuzhiyun 197*4882a593Smuzhiyun# bash prints the name of the directory on 'cd <dir>' if CDPATH is 198*4882a593Smuzhiyun# set, so unset it here to not cause problems. Notice that the export 199*4882a593Smuzhiyun# line doesn't affect the environment of $(shell ..) calls. 200*4882a593Smuzhiyunexport CDPATH := 201*4882a593Smuzhiyun 202*4882a593SmuzhiyunBASE_DIR := $(CANONICAL_O) 203*4882a593Smuzhiyun$(if $(BASE_DIR),, $(error output directory "$(O)" does not exist)) 204*4882a593Smuzhiyun 205*4882a593Smuzhiyun 206*4882a593Smuzhiyun# Handling of BR2_EXTERNAL. 207*4882a593Smuzhiyun# 208*4882a593Smuzhiyun# The value of BR2_EXTERNAL is stored in .br-external in the output directory. 209*4882a593Smuzhiyun# The location of the external.mk makefile fragments is computed in that file. 210*4882a593Smuzhiyun# On subsequent invocations of make, this file is read in. BR2_EXTERNAL can 211*4882a593Smuzhiyun# still be overridden on the command line, therefore the file is re-created 212*4882a593Smuzhiyun# every time make is run. 213*4882a593Smuzhiyun 214*4882a593SmuzhiyunBR2_EXTERNAL_FILE = $(BASE_DIR)/.br2-external.mk 215*4882a593Smuzhiyun-include $(BR2_EXTERNAL_FILE) 216*4882a593Smuzhiyun$(shell support/scripts/br2-external -d '$(BASE_DIR)' $(BR2_EXTERNAL)) 217*4882a593SmuzhiyunBR2_EXTERNAL_ERROR = 218*4882a593Smuzhiyuninclude $(BR2_EXTERNAL_FILE) 219*4882a593Smuzhiyunifneq ($(BR2_EXTERNAL_ERROR),) 220*4882a593Smuzhiyun$(error $(BR2_EXTERNAL_ERROR)) 221*4882a593Smuzhiyunendif 222*4882a593Smuzhiyun 223*4882a593Smuzhiyun# Workaround bug in make-4.3: https://savannah.gnu.org/bugs/?57676 224*4882a593Smuzhiyun$(BASE_DIR)/.br2-external.mk:; 225*4882a593Smuzhiyun 226*4882a593Smuzhiyun# To make sure that the environment variable overrides the .config option, 227*4882a593Smuzhiyun# set this before including .config. 228*4882a593Smuzhiyunifneq ($(BR2_DL_DIR),) 229*4882a593SmuzhiyunDL_DIR := $(BR2_DL_DIR) 230*4882a593Smuzhiyunendif 231*4882a593Smuzhiyunifneq ($(BR2_CCACHE_DIR),) 232*4882a593SmuzhiyunBR_CACHE_DIR := $(BR2_CCACHE_DIR) 233*4882a593Smuzhiyunendif 234*4882a593Smuzhiyun 235*4882a593Smuzhiyun# Need that early, before we scan packages 236*4882a593Smuzhiyun# Avoids doing the $(or...) everytime 237*4882a593SmuzhiyunBR_GRAPH_OUT := $(or $(BR2_GRAPH_OUT),pdf) 238*4882a593Smuzhiyun 239*4882a593SmuzhiyunBUILD_DIR := $(BASE_DIR)/build 240*4882a593SmuzhiyunBINARIES_DIR := $(BASE_DIR)/images 241*4882a593SmuzhiyunBASE_TARGET_DIR := $(BASE_DIR)/target 242*4882a593SmuzhiyunPER_PACKAGE_DIR := $(BASE_DIR)/per-package 243*4882a593Smuzhiyun# initial definition so that 'make clean' works for most users, even without 244*4882a593Smuzhiyun# .config. HOST_DIR will be overwritten later when .config is included. 245*4882a593SmuzhiyunHOST_DIR := $(BASE_DIR)/host 246*4882a593SmuzhiyunGRAPHS_DIR := $(BASE_DIR)/graphs 247*4882a593Smuzhiyun 248*4882a593SmuzhiyunLEGAL_INFO_DIR = $(BASE_DIR)/legal-info 249*4882a593SmuzhiyunREDIST_SOURCES_DIR_TARGET = $(LEGAL_INFO_DIR)/sources 250*4882a593SmuzhiyunREDIST_SOURCES_DIR_HOST = $(LEGAL_INFO_DIR)/host-sources 251*4882a593SmuzhiyunLICENSE_FILES_DIR_TARGET = $(LEGAL_INFO_DIR)/licenses 252*4882a593SmuzhiyunLICENSE_FILES_DIR_HOST = $(LEGAL_INFO_DIR)/host-licenses 253*4882a593SmuzhiyunLEGAL_MANIFEST_CSV_TARGET = $(LEGAL_INFO_DIR)/manifest.csv 254*4882a593SmuzhiyunLEGAL_MANIFEST_CSV_HOST = $(LEGAL_INFO_DIR)/host-manifest.csv 255*4882a593SmuzhiyunLEGAL_WARNINGS = $(LEGAL_INFO_DIR)/.warnings 256*4882a593SmuzhiyunLEGAL_REPORT = $(LEGAL_INFO_DIR)/README 257*4882a593Smuzhiyun 258*4882a593SmuzhiyunCPE_UPDATES_DIR = $(BASE_DIR)/cpe-updates 259*4882a593Smuzhiyun 260*4882a593SmuzhiyunBR2_CONFIG = $(CONFIG_DIR)/.config 261*4882a593Smuzhiyun 262*4882a593Smuzhiyun# Pull in the user's configuration file 263*4882a593Smuzhiyunifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) 264*4882a593Smuzhiyun-include $(BR2_CONFIG) 265*4882a593Smuzhiyunendif 266*4882a593Smuzhiyun 267*4882a593Smuzhiyunifeq ($(BR2_PER_PACKAGE_DIRECTORIES),) 268*4882a593Smuzhiyun# Disable top-level parallel build if per-package directories is not 269*4882a593Smuzhiyun# used. Indeed, per-package directories is necessary to guarantee 270*4882a593Smuzhiyun# determinism and reproducibility with top-level parallel build. 271*4882a593Smuzhiyun.NOTPARALLEL: 272*4882a593Smuzhiyunendif 273*4882a593Smuzhiyun 274*4882a593Smuzhiyun# timezone and locale may affect build output 275*4882a593Smuzhiyunifeq ($(BR2_REPRODUCIBLE),y) 276*4882a593Smuzhiyunexport TZ = UTC 277*4882a593Smuzhiyunexport LANG = C 278*4882a593Smuzhiyunexport LC_ALL = C 279*4882a593Smuzhiyunendif 280*4882a593Smuzhiyun 281*4882a593Smuzhiyun# To put more focus on warnings, be less verbose as default 282*4882a593Smuzhiyun# Use 'make V=1' to see the full commands 283*4882a593Smuzhiyunifeq ("$(origin V)", "command line") 284*4882a593Smuzhiyun KBUILD_VERBOSE = $(V) 285*4882a593Smuzhiyunendif 286*4882a593Smuzhiyunifndef KBUILD_VERBOSE 287*4882a593Smuzhiyun KBUILD_VERBOSE = 0 288*4882a593Smuzhiyunendif 289*4882a593Smuzhiyun 290*4882a593Smuzhiyunifeq ($(KBUILD_VERBOSE),1) 291*4882a593Smuzhiyun Q = 292*4882a593Smuzhiyunifndef VERBOSE 293*4882a593Smuzhiyun VERBOSE = 1 294*4882a593Smuzhiyunendif 295*4882a593Smuzhiyunexport VERBOSE 296*4882a593Smuzhiyunelse 297*4882a593Smuzhiyun Q = @ 298*4882a593Smuzhiyunendif 299*4882a593Smuzhiyun 300*4882a593Smuzhiyun# kconfig uses CONFIG_SHELL 301*4882a593SmuzhiyunCONFIG_SHELL := $(SHELL) 302*4882a593Smuzhiyun 303*4882a593Smuzhiyunexport SHELL CONFIG_SHELL Q KBUILD_VERBOSE 304*4882a593Smuzhiyun 305*4882a593SmuzhiyunCUSTOM_KERNEL := $(CURDIR)/../kernel 306*4882a593SmuzhiyunCUSTOM_KERNEL_VERSION := $(shell if [ -f "$(CUSTOM_KERNEL)/Makefile" ]; then grep -A 1 "^VERSION = " "$(CUSTOM_KERNEL)/Makefile" | cut -d' ' -f 3 | paste -sd'.'; fi) 307*4882a593Smuzhiyun 308*4882a593Smuzhiyunifndef HOSTAR 309*4882a593SmuzhiyunHOSTAR := ar 310*4882a593Smuzhiyunendif 311*4882a593Smuzhiyunifndef HOSTAS 312*4882a593SmuzhiyunHOSTAS := as 313*4882a593Smuzhiyunendif 314*4882a593Smuzhiyunifndef HOSTCC 315*4882a593SmuzhiyunHOSTCC := gcc 316*4882a593SmuzhiyunHOSTCC := $(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc) 317*4882a593Smuzhiyunendif 318*4882a593SmuzhiyunHOSTCC_NOCCACHE := $(HOSTCC) 319*4882a593Smuzhiyunifndef HOSTCXX 320*4882a593SmuzhiyunHOSTCXX := g++ 321*4882a593SmuzhiyunHOSTCXX := $(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++) 322*4882a593Smuzhiyunendif 323*4882a593SmuzhiyunHOSTCXX_NOCCACHE := $(HOSTCXX) 324*4882a593Smuzhiyunifndef HOSTCPP 325*4882a593SmuzhiyunHOSTCPP := cpp 326*4882a593Smuzhiyunendif 327*4882a593Smuzhiyunifndef HOSTLD 328*4882a593SmuzhiyunHOSTLD := ld 329*4882a593Smuzhiyunendif 330*4882a593Smuzhiyunifndef HOSTLN 331*4882a593SmuzhiyunHOSTLN := ln 332*4882a593Smuzhiyunendif 333*4882a593Smuzhiyunifndef HOSTNM 334*4882a593SmuzhiyunHOSTNM := nm 335*4882a593Smuzhiyunendif 336*4882a593Smuzhiyunifndef HOSTOBJCOPY 337*4882a593SmuzhiyunHOSTOBJCOPY := objcopy 338*4882a593Smuzhiyunendif 339*4882a593Smuzhiyunifndef HOSTRANLIB 340*4882a593SmuzhiyunHOSTRANLIB := ranlib 341*4882a593Smuzhiyunendif 342*4882a593SmuzhiyunHOSTAR := $(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar) 343*4882a593SmuzhiyunHOSTAS := $(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as) 344*4882a593SmuzhiyunHOSTCPP := $(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp) 345*4882a593SmuzhiyunHOSTLD := $(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld) 346*4882a593SmuzhiyunHOSTLN := $(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln) 347*4882a593SmuzhiyunHOSTNM := $(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm) 348*4882a593SmuzhiyunHOSTOBJCOPY := $(shell which $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo objcopy) 349*4882a593SmuzhiyunHOSTRANLIB := $(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib) 350*4882a593SmuzhiyunSED := $(shell which sed || type -p sed) -i -e 351*4882a593Smuzhiyun 352*4882a593Smuzhiyunexport HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD 353*4882a593Smuzhiyunexport HOSTCC_NOCCACHE HOSTCXX_NOCCACHE 354*4882a593Smuzhiyun 355*4882a593Smuzhiyun# Determine the userland we are running on. 356*4882a593Smuzhiyun# 357*4882a593Smuzhiyun# Note that, despite its name, we are not interested in the actual 358*4882a593Smuzhiyun# architecture name. This is mostly used to determine whether some 359*4882a593Smuzhiyun# of the binary tools (e.g. pre-built external toolchains) can run 360*4882a593Smuzhiyun# on the current host. So we need to know if the userland we're 361*4882a593Smuzhiyun# running on can actually run those toolchains. 362*4882a593Smuzhiyun# 363*4882a593Smuzhiyun# For example, a 64-bit prebuilt toolchain will not run on a 64-bit 364*4882a593Smuzhiyun# kernel if the userland is 32-bit (e.g. in a chroot for example). 365*4882a593Smuzhiyun# 366*4882a593Smuzhiyun# So, we extract the first part of the tuple the host gcc was 367*4882a593Smuzhiyun# configured to generate code for; we assume this is our userland. 368*4882a593Smuzhiyun# 369*4882a593Smuzhiyunexport HOSTARCH := $(shell LC_ALL=C $(HOSTCC_NOCCACHE) -v 2>&1 | \ 370*4882a593Smuzhiyun sed -e '/^Target: \([^-]*\).*/!d' \ 371*4882a593Smuzhiyun -e 's//\1/' \ 372*4882a593Smuzhiyun -e 's/i.86/x86/' \ 373*4882a593Smuzhiyun -e 's/sun4u/sparc64/' \ 374*4882a593Smuzhiyun -e 's/arm.*/arm/' \ 375*4882a593Smuzhiyun -e 's/sa110/arm/' \ 376*4882a593Smuzhiyun -e 's/ppc64/powerpc64/' \ 377*4882a593Smuzhiyun -e 's/ppc/powerpc/' \ 378*4882a593Smuzhiyun -e 's/macppc/powerpc/' \ 379*4882a593Smuzhiyun -e 's/sh.*/sh/' ) 380*4882a593Smuzhiyun 381*4882a593Smuzhiyun# When adding a new host gcc version in Config.in, 382*4882a593Smuzhiyun# update the HOSTCC_MAX_VERSION variable: 383*4882a593SmuzhiyunHOSTCC_MAX_VERSION := 9 384*4882a593Smuzhiyun 385*4882a593SmuzhiyunHOSTCC_VERSION := $(shell V=$$($(HOSTCC_NOCCACHE) --version | \ 386*4882a593Smuzhiyun sed -n -r 's/^.* ([0-9]*)\.([0-9]*)\.([0-9]*)[ ]*.*/\1 \2/p'); \ 387*4882a593Smuzhiyun [ "$${V%% *}" -le $(HOSTCC_MAX_VERSION) ] || V=$(HOSTCC_MAX_VERSION); \ 388*4882a593Smuzhiyun printf "%s" "$${V}") 389*4882a593Smuzhiyun 390*4882a593Smuzhiyun# For gcc >= 5.x, we only need the major version. 391*4882a593Smuzhiyunifneq ($(firstword $(HOSTCC_VERSION)),4) 392*4882a593SmuzhiyunHOSTCC_VERSION := $(firstword $(HOSTCC_VERSION)) 393*4882a593Smuzhiyunendif 394*4882a593Smuzhiyun 395*4882a593Smuzhiyunifeq ($(BR2_NEEDS_HOST_UTF8_LOCALE),y) 396*4882a593Smuzhiyun# First, we try to use the user's configured locale (as that's the 397*4882a593Smuzhiyun# language they'd expect messages to be displayed), then we favour 398*4882a593Smuzhiyun# a non language-specific locale like C.UTF-8 if one is available, 399*4882a593Smuzhiyun# so we sort with the C locale to get it at the top. 400*4882a593Smuzhiyun# This is guaranteed to not be empty, because of the check in 401*4882a593Smuzhiyun# support/dependencies/dependencies.sh 402*4882a593SmuzhiyunHOST_UTF8_LOCALE := $(shell \ 403*4882a593Smuzhiyun ( echo $${LC_ALL:-$${LC_MESSAGES:-$${LANG}}}; \ 404*4882a593Smuzhiyun locale -a 2>/dev/null | LC_ALL=C sort \ 405*4882a593Smuzhiyun ) \ 406*4882a593Smuzhiyun | grep -i -E 'utf-?8$$' \ 407*4882a593Smuzhiyun | head -n 1) 408*4882a593SmuzhiyunHOST_UTF8_LOCALE_ENV := LC_ALL=$(HOST_UTF8_LOCALE) 409*4882a593Smuzhiyunendif 410*4882a593Smuzhiyun 411*4882a593Smuzhiyun# Make sure pkg-config doesn't look outside the buildroot tree 412*4882a593SmuzhiyunHOST_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH) 413*4882a593Smuzhiyununexport PKG_CONFIG_PATH 414*4882a593Smuzhiyununexport PKG_CONFIG_SYSROOT_DIR 415*4882a593Smuzhiyununexport PKG_CONFIG_LIBDIR 416*4882a593Smuzhiyun 417*4882a593Smuzhiyun# Having DESTDIR set in the environment confuses the installation 418*4882a593Smuzhiyun# steps of some packages. 419*4882a593Smuzhiyununexport DESTDIR 420*4882a593Smuzhiyun 421*4882a593Smuzhiyun# Causes breakage with packages that needs host-ruby 422*4882a593Smuzhiyununexport RUBYOPT 423*4882a593Smuzhiyun 424*4882a593Smuzhiyuninclude package/pkg-utils.mk 425*4882a593Smuzhiyuninclude package/doc-asciidoc.mk 426*4882a593Smuzhiyun 427*4882a593Smuzhiyunifeq ($(BR2_HAVE_DOT_CONFIG),y) 428*4882a593Smuzhiyun 429*4882a593Smuzhiyun################################################################################ 430*4882a593Smuzhiyun# 431*4882a593Smuzhiyun# Hide troublesome environment variables from sub processes 432*4882a593Smuzhiyun# 433*4882a593Smuzhiyun################################################################################ 434*4882a593Smuzhiyununexport CROSS_COMPILE 435*4882a593Smuzhiyununexport ARCH 436*4882a593Smuzhiyununexport CC 437*4882a593Smuzhiyununexport LD 438*4882a593Smuzhiyununexport AR 439*4882a593Smuzhiyununexport CXX 440*4882a593Smuzhiyununexport CPP 441*4882a593Smuzhiyununexport RANLIB 442*4882a593Smuzhiyununexport CFLAGS 443*4882a593Smuzhiyununexport CXXFLAGS 444*4882a593Smuzhiyununexport UNZIP 445*4882a593Smuzhiyununexport GREP_OPTIONS 446*4882a593Smuzhiyununexport TAR_OPTIONS 447*4882a593Smuzhiyununexport CONFIG_SITE 448*4882a593Smuzhiyununexport QMAKESPEC 449*4882a593Smuzhiyununexport TERMINFO 450*4882a593Smuzhiyununexport MACHINE 451*4882a593Smuzhiyununexport O 452*4882a593Smuzhiyununexport GCC_COLORS 453*4882a593Smuzhiyununexport PLATFORM 454*4882a593Smuzhiyununexport OS 455*4882a593Smuzhiyun 456*4882a593SmuzhiyunGNU_HOST_NAME := $(shell support/gnuconfig/config.guess) 457*4882a593Smuzhiyun 458*4882a593SmuzhiyunPACKAGES := 459*4882a593SmuzhiyunPACKAGES_ALL := 460*4882a593Smuzhiyun 461*4882a593Smuzhiyun# silent mode requested? 462*4882a593SmuzhiyunQUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q) 463*4882a593Smuzhiyun 464*4882a593Smuzhiyun# Strip off the annoying quoting 465*4882a593SmuzhiyunARCH := $(call qstrip,$(BR2_ARCH)) 466*4882a593SmuzhiyunNORMALIZED_ARCH := $(call qstrip,$(BR2_NORMALIZED_ARCH)) 467*4882a593SmuzhiyunKERNEL_ARCH := $(call qstrip,$(BR2_NORMALIZED_ARCH)) 468*4882a593Smuzhiyun 469*4882a593SmuzhiyunZCAT := $(call qstrip,$(BR2_ZCAT)) 470*4882a593SmuzhiyunBZCAT := $(call qstrip,$(BR2_BZCAT)) 471*4882a593SmuzhiyunXZCAT := $(call qstrip,$(BR2_XZCAT)) 472*4882a593SmuzhiyunLZCAT := $(call qstrip,$(BR2_LZCAT)) 473*4882a593SmuzhiyunTAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf 474*4882a593Smuzhiyun 475*4882a593Smuzhiyunifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y) 476*4882a593SmuzhiyunHOST_DIR = $(if $(PKG),$(PER_PACKAGE_DIR)/$($(PKG)_NAME)/host,$(call qstrip,$(BR2_HOST_DIR))) 477*4882a593SmuzhiyunTARGET_DIR = $(if $(ROOTFS),$(ROOTFS_$(ROOTFS)_TARGET_DIR),$(if $(PKG),$(PER_PACKAGE_DIR)/$($(PKG)_NAME)/target,$(BASE_TARGET_DIR))) 478*4882a593Smuzhiyunelse 479*4882a593SmuzhiyunHOST_DIR := $(call qstrip,$(BR2_HOST_DIR)) 480*4882a593SmuzhiyunTARGET_DIR = $(if $(ROOTFS),$(ROOTFS_$(ROOTFS)_TARGET_DIR),$(BASE_TARGET_DIR))$(if $($(PKG)_OEM_INSTALL),/oem) 481*4882a593Smuzhiyun 482*4882a593Smuzhiyunifeq ($(BR2_PACKAGE_OEM),y) 483*4882a593Smuzhiyun$(eval $(foreach pkg,$(call qstrip,$(BR2_PACKAGE_OEM_PACKAGES)), \ 484*4882a593Smuzhiyun $(eval $(call UPPERCASE,$(pkg))_OEM_INSTALL := y)$(sep) \ 485*4882a593Smuzhiyun $(eval OEM_DEPENDENCIES += $(pkg))$(sep))) 486*4882a593Smuzhiyunendif 487*4882a593Smuzhiyunendif 488*4882a593Smuzhiyun 489*4882a593Smuzhiyunifneq ($(HOST_DIR),$(BASE_DIR)/host) 490*4882a593SmuzhiyunHOST_DIR_SYMLINK = $(BASE_DIR)/host 491*4882a593Smuzhiyun$(HOST_DIR_SYMLINK): | $(BASE_DIR) 492*4882a593Smuzhiyun ln -snf $(HOST_DIR) $(HOST_DIR_SYMLINK) 493*4882a593Smuzhiyunendif 494*4882a593Smuzhiyun 495*4882a593SmuzhiyunSTAGING_DIR_SYMLINK = $(BASE_DIR)/staging 496*4882a593Smuzhiyun$(STAGING_DIR_SYMLINK): | $(BASE_DIR) 497*4882a593Smuzhiyun ln -snf $(STAGING_DIR) $(STAGING_DIR_SYMLINK) 498*4882a593Smuzhiyun 499*4882a593Smuzhiyun# Quotes are needed for spaces and all in the original PATH content. 500*4882a593SmuzhiyunBR_PATH = "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(PATH)" 501*4882a593Smuzhiyun 502*4882a593Smuzhiyun# Location of a file giving a big fat warning that output/target 503*4882a593Smuzhiyun# should not be used as the root filesystem. 504*4882a593SmuzhiyunTARGET_DIR_WARNING_FILE = $(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM 505*4882a593Smuzhiyun 506*4882a593Smuzhiyunifeq ($(BR2_CCACHE),y) 507*4882a593SmuzhiyunCCACHE = $(HOST_DIR)/bin/ccache 508*4882a593SmuzhiyunBR_CACHE_DIR ?= $(call qstrip,$(BR2_CCACHE_DIR)) 509*4882a593Smuzhiyunexport BR_CACHE_DIR 510*4882a593SmuzhiyunHOSTCC = $(CCACHE) $(HOSTCC_NOCCACHE) 511*4882a593SmuzhiyunHOSTCXX = $(CCACHE) $(HOSTCXX_NOCCACHE) 512*4882a593Smuzhiyunelse 513*4882a593Smuzhiyunexport BR_NO_CCACHE 514*4882a593Smuzhiyunendif 515*4882a593Smuzhiyun 516*4882a593Smuzhiyun# Scripts in support/ or post-build scripts may need to reference 517*4882a593Smuzhiyun# these locations, so export them so it is easier to use 518*4882a593Smuzhiyunexport BR2_CONFIG 519*4882a593Smuzhiyunexport BR2_REPRODUCIBLE 520*4882a593Smuzhiyunexport TARGET_DIR 521*4882a593Smuzhiyunexport STAGING_DIR 522*4882a593Smuzhiyunexport HOST_DIR 523*4882a593Smuzhiyunexport BINARIES_DIR 524*4882a593Smuzhiyunexport BASE_DIR 525*4882a593Smuzhiyun 526*4882a593Smuzhiyun################################################################################ 527*4882a593Smuzhiyun# 528*4882a593Smuzhiyun# You should probably leave this stuff alone unless you know 529*4882a593Smuzhiyun# what you are doing. 530*4882a593Smuzhiyun# 531*4882a593Smuzhiyun################################################################################ 532*4882a593Smuzhiyun 533*4882a593Smuzhiyunall: world 534*4882a593Smuzhiyun 535*4882a593Smuzhiyun# Include legacy before the other things, because package .mk files 536*4882a593Smuzhiyun# may rely on it. 537*4882a593Smuzhiyuninclude Makefile.legacy 538*4882a593Smuzhiyun 539*4882a593Smuzhiyuninclude system/system.mk 540*4882a593Smuzhiyuninclude package/Makefile.in 541*4882a593Smuzhiyun# arch/arch.mk must be after package/Makefile.in because it may need to 542*4882a593Smuzhiyun# complement variables defined therein, like BR_NO_CHECK_HASH_FOR. 543*4882a593Smuzhiyuninclude arch/arch.mk 544*4882a593Smuzhiyuninclude support/dependencies/dependencies.mk 545*4882a593Smuzhiyun 546*4882a593Smuzhiyuninclude $(sort $(wildcard toolchain/*.mk)) 547*4882a593Smuzhiyuninclude $(sort $(wildcard toolchain/*/*.mk)) 548*4882a593Smuzhiyun 549*4882a593Smuzhiyunifeq ($(BR2_REPRODUCIBLE),y) 550*4882a593Smuzhiyun# If SOURCE_DATE_EPOCH has not been set then use the commit date, or the last 551*4882a593Smuzhiyun# release date if the source tree is not within a Git repository. 552*4882a593Smuzhiyun# See: https://reproducible-builds.org/specs/source-date-epoch/ 553*4882a593SmuzhiyunBR2_VERSION_GIT_EPOCH := $(shell $(GIT) log -1 --format=%at 2> /dev/null) 554*4882a593Smuzhiyunexport SOURCE_DATE_EPOCH ?= $(or $(BR2_VERSION_GIT_EPOCH),$(BR2_VERSION_EPOCH)) 555*4882a593Smuzhiyunendif 556*4882a593Smuzhiyun 557*4882a593Smuzhiyun# Include the package override file if one has been provided in the 558*4882a593Smuzhiyun# configuration. 559*4882a593SmuzhiyunPACKAGE_OVERRIDE_FILE = $(call qstrip,$(BR2_PACKAGE_OVERRIDE_FILE)) 560*4882a593Smuzhiyunifneq ($(PACKAGE_OVERRIDE_FILE),) 561*4882a593Smuzhiyun-include $(PACKAGE_OVERRIDE_FILE) 562*4882a593Smuzhiyunendif 563*4882a593Smuzhiyun 564*4882a593Smuzhiyuninclude $(sort $(wildcard package/*/*.mk)) 565*4882a593Smuzhiyun 566*4882a593Smuzhiyuninclude boot/common.mk 567*4882a593Smuzhiyuninclude linux/linux.mk 568*4882a593Smuzhiyuninclude fs/common.mk 569*4882a593Smuzhiyun 570*4882a593Smuzhiyun# If using a br2-external tree, the BR2_EXTERNAL_$(NAME)_PATH variables 571*4882a593Smuzhiyun# are also present in the .config file. Since .config is included after 572*4882a593Smuzhiyun# we defined them in the Makefile, the values for those variables are 573*4882a593Smuzhiyun# quoted. We just include the generated Makefile fragment .br2-external.mk 574*4882a593Smuzhiyun# a third time, which will set those variables to the un-quoted values. 575*4882a593Smuzhiyuninclude $(BR2_EXTERNAL_FILE) 576*4882a593Smuzhiyun 577*4882a593Smuzhiyun# Nothing to include if no BR2_EXTERNAL tree in use 578*4882a593Smuzhiyuninclude $(BR2_EXTERNAL_MKS) 579*4882a593Smuzhiyun 580*4882a593Smuzhiyun# Now we are sure we have all the packages scanned and defined. We now 581*4882a593Smuzhiyun# check for each package in the list of enabled packages, that all its 582*4882a593Smuzhiyun# dependencies are indeed enabled. 583*4882a593Smuzhiyun# 584*4882a593Smuzhiyun# Only trigger the check for default builds. If the user forces building 585*4882a593Smuzhiyun# a package, even if not enabled in the configuration, we want to accept 586*4882a593Smuzhiyun# it. However; we also want to be able to force checking the dependencies 587*4882a593Smuzhiyun# if the user so desires. Forcing a dependency check is useful in the case 588*4882a593Smuzhiyun# of test-pkg, as we want to make sure during testing, that a package has 589*4882a593Smuzhiyun# all the dependencies selected in the config file. 590*4882a593Smuzhiyun# 591*4882a593Smuzhiyunifeq ($(MAKECMDGOALS),) 592*4882a593SmuzhiyunBR_FORCE_CHECK_DEPENDENCIES = YES 593*4882a593Smuzhiyunendif 594*4882a593Smuzhiyun 595*4882a593Smuzhiyunifeq ($(BR_FORCE_CHECK_DEPENDENCIES),YES) 596*4882a593Smuzhiyun 597*4882a593Smuzhiyundefine CHECK_ONE_DEPENDENCY 598*4882a593Smuzhiyunifneq ($(2)|$(BR2_LINUX_KERNEL),LINUX|) 599*4882a593Smuzhiyunifeq ($$($(2)_TYPE),target) 600*4882a593Smuzhiyunifeq ($$($(2)_IS_VIRTUAL),) 601*4882a593Smuzhiyunifneq ($$($$($(2)_KCONFIG_VAR)),y) 602*4882a593Smuzhiyun$$(error $$($(2)_NAME) is in the dependency chain of $$($(1)_NAME) that \ 603*4882a593Smuzhiyunhas added it to its _DEPENDENCIES variable without selecting it or \ 604*4882a593Smuzhiyundepending on it from Config.in) 605*4882a593Smuzhiyunendif 606*4882a593Smuzhiyunendif 607*4882a593Smuzhiyunendif 608*4882a593Smuzhiyunendif 609*4882a593Smuzhiyunendef 610*4882a593Smuzhiyun 611*4882a593Smuzhiyun$(foreach pkg,$(call UPPERCASE,$(PACKAGES)),\ 612*4882a593Smuzhiyun $(foreach dep,$(call UPPERCASE,$($(pkg)_FINAL_ALL_DEPENDENCIES)),\ 613*4882a593Smuzhiyun $(eval $(call CHECK_ONE_DEPENDENCY,$(pkg),$(dep))$(sep)))) 614*4882a593Smuzhiyun 615*4882a593Smuzhiyunendif 616*4882a593Smuzhiyun 617*4882a593Smuzhiyun$(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG) 618*4882a593Smuzhiyun $(MAKE1) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" syncconfig 619*4882a593Smuzhiyun 620*4882a593Smuzhiyun.PHONY: prepare 621*4882a593Smuzhiyunprepare: $(BUILD_DIR)/buildroot-config/auto.conf 622*4882a593Smuzhiyun 623*4882a593Smuzhiyun.PHONY: world 624*4882a593Smuzhiyunworld: target-post-image 625*4882a593Smuzhiyun 626*4882a593Smuzhiyun.PHONY: prepare-sdk 627*4882a593Smuzhiyunprepare-sdk: world 628*4882a593Smuzhiyun @$(call MESSAGE,"Rendering the SDK relocatable") 629*4882a593Smuzhiyun PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) $(TOPDIR)/support/scripts/fix-rpath host 630*4882a593Smuzhiyun PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) $(TOPDIR)/support/scripts/fix-rpath staging 631*4882a593Smuzhiyun $(INSTALL) -m 755 $(TOPDIR)/support/misc/relocate-sdk.sh $(HOST_DIR)/relocate-sdk.sh 632*4882a593Smuzhiyun mkdir -p $(HOST_DIR)/share/buildroot 633*4882a593Smuzhiyun echo $(HOST_DIR) > $(HOST_DIR)/share/buildroot/sdk-location 634*4882a593Smuzhiyun 635*4882a593Smuzhiyun 636*4882a593Smuzhiyun.PHONY: reinstall 637*4882a593Smuzhiyunclean-for-reinstall: $(patsubst %,%-clean-for-reinstall,$(PACKAGES)) 638*4882a593Smuzhiyun rm -rf $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) 639*4882a593Smuzhiyun find $(BUILD_DIR) -name ".stamp_*_installed" -delete 640*4882a593Smuzhiyun 641*4882a593Smuzhiyunreinstall: clean-for-reinstall all 642*4882a593Smuzhiyun 643*4882a593SmuzhiyunBR2_SDK_PREFIX ?= $(GNU_TARGET_NAME)_sdk-buildroot 644*4882a593Smuzhiyun.PHONY: sdk 645*4882a593Smuzhiyunsdk: prepare-sdk $(BR2_TAR_HOST_DEPENDENCY) 646*4882a593Smuzhiyun @$(call MESSAGE,"Generating SDK tarball") 647*4882a593Smuzhiyun $(if $(BR2_SDK_PREFIX),,$(error BR2_SDK_PREFIX can not be empty)) 648*4882a593Smuzhiyun $(Q)mkdir -p $(BINARIES_DIR) 649*4882a593Smuzhiyun $(TAR) czf "$(BINARIES_DIR)/$(BR2_SDK_PREFIX).tar.gz" \ 650*4882a593Smuzhiyun --owner=0 --group=0 --numeric-owner \ 651*4882a593Smuzhiyun --transform='s#^$(patsubst /%,%,$(HOST_DIR))#$(BR2_SDK_PREFIX)#' \ 652*4882a593Smuzhiyun -C / $(patsubst /%,%,$(HOST_DIR)) 653*4882a593Smuzhiyun 654*4882a593SmuzhiyunRSYNC_VCS_EXCLUSIONS = \ 655*4882a593Smuzhiyun --exclude .svn --exclude .git --exclude .hg --exclude .bzr \ 656*4882a593Smuzhiyun --exclude CVS 657*4882a593Smuzhiyun 658*4882a593Smuzhiyun# When stripping, obey to BR2_STRIP_EXCLUDE_DIRS and 659*4882a593Smuzhiyun# BR2_STRIP_EXCLUDE_FILES 660*4882a593SmuzhiyunSTRIP_FIND_COMMON_CMD = \ 661*4882a593Smuzhiyun find $(TARGET_DIR) \ 662*4882a593Smuzhiyun $(if $(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)), \ 663*4882a593Smuzhiyun \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) \ 664*4882a593Smuzhiyun -prune -o \ 665*4882a593Smuzhiyun ) \ 666*4882a593Smuzhiyun $(if $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES)), \ 667*4882a593Smuzhiyun -not \( $(call findfileclauses,$(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) ) 668*4882a593Smuzhiyun 669*4882a593Smuzhiyun# Regular stripping for everything, except libpthread, ld-*.so and 670*4882a593Smuzhiyun# kernel modules: 671*4882a593Smuzhiyun# - libpthread.so: a non-stripped libpthread shared library is needed for 672*4882a593Smuzhiyun# proper debugging of pthread programs using gdb. 673*4882a593Smuzhiyun# - ld.so: a non-stripped dynamic linker library is needed for valgrind 674*4882a593Smuzhiyun# - kernel modules (*.ko): do not function properly when stripped like normal 675*4882a593Smuzhiyun# applications and libraries. Normally kernel modules are already excluded 676*4882a593Smuzhiyun# by the executable permission check, so the explicit exclusion is only 677*4882a593Smuzhiyun# done for kernel modules with incorrect permissions. 678*4882a593SmuzhiyunSTRIP_FIND_CMD = \ 679*4882a593Smuzhiyun $(STRIP_FIND_COMMON_CMD) \ 680*4882a593Smuzhiyun -type f \( -perm /111 -o -name '*.so*' \) \ 681*4882a593Smuzhiyun -not \( $(call findfileclauses,libpthread*.so* ld-*.so* *.ko) \) \ 682*4882a593Smuzhiyun -print0 683*4882a593Smuzhiyun 684*4882a593Smuzhiyun# Special stripping (only debugging symbols) for libpthread and ld-*.so. 685*4882a593SmuzhiyunSTRIP_FIND_SPECIAL_LIBS_CMD = \ 686*4882a593Smuzhiyun $(STRIP_FIND_COMMON_CMD) \ 687*4882a593Smuzhiyun \( -name 'ld-*.so*' -o -name 'libpthread*.so*' \) \ 688*4882a593Smuzhiyun -print0 689*4882a593Smuzhiyun 690*4882a593Smuzhiyunifeq ($(BR2_ECLIPSE_REGISTER),y) 691*4882a593Smuzhiyundefine TOOLCHAIN_ECLIPSE_REGISTER 692*4882a593Smuzhiyun ./support/scripts/eclipse-register-toolchain `readlink -f $(O)` \ 693*4882a593Smuzhiyun $(notdir $(TARGET_CROSS)) $(BR2_ARCH) 694*4882a593Smuzhiyunendef 695*4882a593SmuzhiyunTARGET_FINALIZE_HOOKS += TOOLCHAIN_ECLIPSE_REGISTER 696*4882a593Smuzhiyunendif 697*4882a593Smuzhiyun 698*4882a593Smuzhiyun# Generate locale data. 699*4882a593Smuzhiyunifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y) 700*4882a593SmuzhiyunGLIBC_GENERATE_LOCALES = $(call qstrip,$(BR2_GENERATE_LOCALE)) 701*4882a593Smuzhiyunifneq ($(GLIBC_GENERATE_LOCALES),) 702*4882a593SmuzhiyunPACKAGES += host-localedef 703*4882a593Smuzhiyun 704*4882a593Smuzhiyundefine GENERATE_GLIBC_LOCALES 705*4882a593Smuzhiyun $(MAKE) -f support/misc/gen-glibc-locales.mk \ 706*4882a593Smuzhiyun ENDIAN=$(call LOWERCASE,$(BR2_ENDIAN)) \ 707*4882a593Smuzhiyun LOCALES="$(GLIBC_GENERATE_LOCALES)" \ 708*4882a593Smuzhiyun Q=$(Q) 709*4882a593Smuzhiyunendef 710*4882a593SmuzhiyunTARGET_FINALIZE_HOOKS += GENERATE_GLIBC_LOCALES 711*4882a593Smuzhiyunendif 712*4882a593Smuzhiyunendif 713*4882a593Smuzhiyun 714*4882a593Smuzhiyunifeq ($(BR2_ENABLE_LOCALE_PURGE),y) 715*4882a593SmuzhiyunLOCALE_WHITELIST = $(BUILD_DIR)/locales.nopurge 716*4882a593SmuzhiyunLOCALE_NOPURGE = $(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST)) 717*4882a593Smuzhiyun 718*4882a593Smuzhiyun# This piece of junk does the following: 719*4882a593Smuzhiyun# First collect the whitelist in a file. 720*4882a593Smuzhiyun# Then go over all the locale dirs and for each subdir, check if it exists 721*4882a593Smuzhiyun# in the whitelist file. If it doesn't, kill it. 722*4882a593Smuzhiyun# Finally, specifically for X11, regenerate locale.dir from the whitelist. 723*4882a593Smuzhiyundefine PURGE_LOCALES 724*4882a593Smuzhiyun printf '%s\n' $(LOCALE_NOPURGE) locale-archive > $(LOCALE_WHITELIST) 725*4882a593Smuzhiyun 726*4882a593Smuzhiyun for dir in $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/lib/locale); \ 727*4882a593Smuzhiyun do \ 728*4882a593Smuzhiyun if [ ! -d $$dir ]; then continue; fi; \ 729*4882a593Smuzhiyun for langdir in $$dir/*; \ 730*4882a593Smuzhiyun do \ 731*4882a593Smuzhiyun if [ -e "$${langdir}" ]; \ 732*4882a593Smuzhiyun then \ 733*4882a593Smuzhiyun grep -qx "$${langdir##*/}" $(LOCALE_WHITELIST) || rm -rf $$langdir; \ 734*4882a593Smuzhiyun fi \ 735*4882a593Smuzhiyun done; \ 736*4882a593Smuzhiyun done 737*4882a593Smuzhiyun if [ -d $(TARGET_DIR)/usr/share/X11/locale ]; \ 738*4882a593Smuzhiyun then \ 739*4882a593Smuzhiyun for lang in $(LOCALE_NOPURGE); \ 740*4882a593Smuzhiyun do \ 741*4882a593Smuzhiyun if [ -f $(TARGET_DIR)/usr/share/X11/locale/$$lang/XLC_LOCALE ]; \ 742*4882a593Smuzhiyun then \ 743*4882a593Smuzhiyun echo "$$lang/XLC_LOCALE: $$lang"; \ 744*4882a593Smuzhiyun fi \ 745*4882a593Smuzhiyun done > $(TARGET_DIR)/usr/share/X11/locale/locale.dir; \ 746*4882a593Smuzhiyun fi 747*4882a593Smuzhiyunendef 748*4882a593SmuzhiyunTARGET_FINALIZE_HOOKS += PURGE_LOCALES 749*4882a593Smuzhiyunendif 750*4882a593Smuzhiyun 751*4882a593Smuzhiyun$(TARGETS_ROOTFS): target-finalize 752*4882a593Smuzhiyun 753*4882a593Smuzhiyun# Avoid the rootfs name leaking down the dependency chain 754*4882a593Smuzhiyuntarget-finalize: ROOTFS= 755*4882a593Smuzhiyun 756*4882a593SmuzhiyunTARGET_DIR_FILES_LISTS = $(sort $(wildcard $(BUILD_DIR)/*/.files-list.txt)) 757*4882a593SmuzhiyunHOST_DIR_FILES_LISTS = $(sort $(wildcard $(BUILD_DIR)/*/.files-list-host.txt)) 758*4882a593SmuzhiyunSTAGING_DIR_FILES_LISTS = $(sort $(wildcard $(BUILD_DIR)/*/.files-list-staging.txt)) 759*4882a593Smuzhiyun 760*4882a593Smuzhiyun.PHONY: host-finalize 761*4882a593Smuzhiyunhost-finalize: $(PACKAGES) $(HOST_DIR) $(HOST_DIR_SYMLINK) 762*4882a593Smuzhiyun @$(call MESSAGE,"Finalizing host directory") 763*4882a593Smuzhiyun $(call per-package-rsync,$(sort $(PACKAGES)),host,$(HOST_DIR)) 764*4882a593Smuzhiyun 765*4882a593Smuzhiyun.PHONY: staging-finalize 766*4882a593Smuzhiyunstaging-finalize: $(STAGING_DIR_SYMLINK) 767*4882a593Smuzhiyun 768*4882a593Smuzhiyun.PHONY: target-finalize 769*4882a593Smuzhiyuntarget-finalize: $(PACKAGES) $(TARGET_DIR) host-finalize 770*4882a593Smuzhiyun @$(call MESSAGE,"Finalizing target directory") 771*4882a593Smuzhiyun $(call per-package-rsync,$(sort $(PACKAGES)),target,$(TARGET_DIR)) 772*4882a593Smuzhiyun $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep)) 773*4882a593Smuzhiyun rm -rf $(TARGET_DIR)/usr/share/aclocal \ 774*4882a593Smuzhiyun $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake \ 775*4882a593Smuzhiyun $(TARGET_DIR)/usr/doc 776*4882a593Smuzhiyun find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f 777*4882a593Smuzhiyun find $(TARGET_DIR)/lib/ $(TARGET_DIR)/usr/lib/ $(TARGET_DIR)/usr/libexec/ \ 778*4882a593Smuzhiyun \( -name '*.la' -o -name '*.prl' \) -print0 | xargs -0 rm -f 779*4882a593Smuzhiyunifneq ($(BR2_PACKAGE_GCC_TARGET),y) 780*4882a593Smuzhiyun rm -rf $(TARGET_DIR)/usr/include \ 781*4882a593Smuzhiyun $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig 782*4882a593Smuzhiyun find $(TARGET_DIR)/lib/ $(TARGET_DIR)/usr/lib/ $(TARGET_DIR)/usr/libexec/ \ 783*4882a593Smuzhiyun -name '*.a' -print0 | xargs -0 rm -f 784*4882a593Smuzhiyunendif 785*4882a593Smuzhiyunifneq ($(BR2_PACKAGE_GDB),y) 786*4882a593Smuzhiyun rm -rf $(TARGET_DIR)/usr/share/gdb 787*4882a593Smuzhiyunendif 788*4882a593Smuzhiyunifneq ($(BR2_PACKAGE_BASH),y) 789*4882a593Smuzhiyun rm -rf $(TARGET_DIR)/usr/share/bash-completion 790*4882a593Smuzhiyun rm -rf $(TARGET_DIR)/etc/bash_completion.d 791*4882a593Smuzhiyunendif 792*4882a593Smuzhiyunifneq ($(BR2_PACKAGE_ZSH),y) 793*4882a593Smuzhiyun rm -rf $(TARGET_DIR)/usr/share/zsh 794*4882a593Smuzhiyunendif 795*4882a593Smuzhiyun rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man 796*4882a593Smuzhiyun rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info 797*4882a593Smuzhiyun rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc 798*4882a593Smuzhiyun rm -rf $(TARGET_DIR)/usr/share/gtk-doc 799*4882a593Smuzhiyun rmdir $(TARGET_DIR)/usr/share 2>/dev/null || true 800*4882a593Smuzhiyunifneq ($(BR2_ENABLE_DEBUG):$(BR2_STRIP_strip),y:) 801*4882a593Smuzhiyun rm -rf $(TARGET_DIR)/lib/debug $(TARGET_DIR)/usr/lib/debug 802*4882a593Smuzhiyunendif 803*4882a593Smuzhiyun $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true 804*4882a593Smuzhiyun $(STRIP_FIND_SPECIAL_LIBS_CMD) | xargs -0 -r $(STRIPCMD) $(STRIP_STRIP_DEBUG) 2>/dev/null || true 805*4882a593Smuzhiyun 806*4882a593Smuzhiyunifneq ($(BR2_TOOLCHAIN_USES_GLIBC),y) 807*4882a593Smuzhiyun test -f $(TARGET_DIR)/etc/ld.so.conf && \ 808*4882a593Smuzhiyun { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true 809*4882a593Smuzhiyun test -d $(TARGET_DIR)/etc/ld.so.conf.d && \ 810*4882a593Smuzhiyun { echo "ERROR: we shouldn't have a /etc/ld.so.conf.d directory"; exit 1; } || true 811*4882a593Smuzhiyunendif 812*4882a593Smuzhiyun 813*4882a593Smuzhiyun mkdir -p $(TARGET_DIR)/etc 814*4882a593Smuzhiyun ( \ 815*4882a593Smuzhiyun echo "NAME=Buildroot"; \ 816*4882a593Smuzhiyun echo "VERSION=$(BR2_VERSION_FULL)"; \ 817*4882a593Smuzhiyun echo "ID=buildroot"; \ 818*4882a593Smuzhiyun echo "VERSION_ID=$(BR2_VERSION)"; \ 819*4882a593Smuzhiyun echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \ 820*4882a593Smuzhiyun ) > $(TARGET_DIR)/usr/lib/os-release 821*4882a593Smuzhiyun ln -sf ../usr/lib/os-release $(TARGET_DIR)/etc 822*4882a593Smuzhiyun 823*4882a593Smuzhiyun @$(call MESSAGE,"Sanitizing RPATH in target tree") 824*4882a593Smuzhiyun PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) $(TOPDIR)/support/scripts/fix-rpath target 825*4882a593Smuzhiyun 826*4882a593Smuzhiyun# For a merged /usr, ensure that /lib, /bin and /sbin and their /usr 827*4882a593Smuzhiyun# counterparts are appropriately setup as symlinks ones to the others. 828*4882a593Smuzhiyunifeq ($(BR2_ROOTFS_MERGED_USR),y) 829*4882a593Smuzhiyun 830*4882a593Smuzhiyun $(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \ 831*4882a593Smuzhiyun @$(call MESSAGE,"Sanity check in overlay $(d)")$(sep) \ 832*4882a593Smuzhiyun $(Q)not_merged_dirs="$$(support/scripts/check-merged-usr.sh $(d))"; \ 833*4882a593Smuzhiyun test -n "$$not_merged_dirs" && { \ 834*4882a593Smuzhiyun echo "ERROR: The overlay in $(d) is not" \ 835*4882a593Smuzhiyun "using a merged /usr for the following directories:" \ 836*4882a593Smuzhiyun $$not_merged_dirs; \ 837*4882a593Smuzhiyun exit 1; \ 838*4882a593Smuzhiyun } || true$(sep)) 839*4882a593Smuzhiyun 840*4882a593Smuzhiyunendif # merged /usr 841*4882a593Smuzhiyun 842*4882a593Smuzhiyun $(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \ 843*4882a593Smuzhiyun @$(call MESSAGE,"Copying overlay $(d)")$(sep) \ 844*4882a593Smuzhiyun $(Q)$(call SYSTEM_RSYNC,$(d),$(TARGET_DIR))$(sep)) 845*4882a593Smuzhiyun 846*4882a593Smuzhiyun $(Q)$(if $(TARGET_DIR_FILES_LISTS), \ 847*4882a593Smuzhiyun cat $(TARGET_DIR_FILES_LISTS)) > $(BUILD_DIR)/packages-file-list.txt 848*4882a593Smuzhiyun $(Q)$(if $(HOST_DIR_FILES_LISTS), \ 849*4882a593Smuzhiyun cat $(HOST_DIR_FILES_LISTS)) > $(BUILD_DIR)/packages-file-list-host.txt 850*4882a593Smuzhiyun $(Q)$(if $(STAGING_DIR_FILES_LISTS), \ 851*4882a593Smuzhiyun cat $(STAGING_DIR_FILES_LISTS)) > $(BUILD_DIR)/packages-file-list-staging.txt 852*4882a593Smuzhiyun 853*4882a593Smuzhiyun $(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \ 854*4882a593Smuzhiyun @$(call MESSAGE,"Executing post-build script $(s)")$(sep) \ 855*4882a593Smuzhiyun $(Q)$(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep)) 856*4882a593Smuzhiyun 857*4882a593Smuzhiyun touch $(TARGET_DIR)/usr 858*4882a593Smuzhiyun 859*4882a593Smuzhiyun.PHONY: target-post-image 860*4882a593Smuzhiyuntarget-post-image: $(TARGETS_ROOTFS) target-finalize staging-finalize 861*4882a593Smuzhiyun @rm -f $(ROOTFS_COMMON_TAR) 862*4882a593Smuzhiyun $(Q)mkdir -p $(BINARIES_DIR) 863*4882a593Smuzhiyun @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \ 864*4882a593Smuzhiyun $(call MESSAGE,"Executing post-image script $(s)"); \ 865*4882a593Smuzhiyun $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep)) 866*4882a593Smuzhiyun 867*4882a593Smuzhiyun.PHONY: source 868*4882a593Smuzhiyunsource: $(foreach p,$(PACKAGES),$(p)-all-source) 869*4882a593Smuzhiyun 870*4882a593Smuzhiyun.PHONY: _external-deps external-deps 871*4882a593Smuzhiyun_external-deps: $(foreach p,$(PACKAGES),$(p)-all-external-deps) 872*4882a593Smuzhiyunexternal-deps: 873*4882a593Smuzhiyun @$(MAKE1) -Bs $(EXTRAMAKEARGS) _external-deps | sort -u 874*4882a593Smuzhiyun 875*4882a593Smuzhiyun.PHONY: legal-info-clean 876*4882a593Smuzhiyunlegal-info-clean: 877*4882a593Smuzhiyun @rm -fr $(LEGAL_INFO_DIR) 878*4882a593Smuzhiyun 879*4882a593Smuzhiyun.PHONY: legal-info-prepare 880*4882a593Smuzhiyunlegal-info-prepare: $(LEGAL_INFO_DIR) 881*4882a593Smuzhiyun @$(call MESSAGE,"Buildroot $(BR2_VERSION_FULL) Collecting legal info") 882*4882a593Smuzhiyun @$(call legal-license-file,buildroot,buildroot,support/legal-info/buildroot.hash,COPYING,COPYING,HOST) 883*4882a593Smuzhiyun @$(call legal-manifest,TARGET,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,DEPENDENCIES WITH LICENSES) 884*4882a593Smuzhiyun @$(call legal-manifest,HOST,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,DEPENDENCIES WITH LICENSES) 885*4882a593Smuzhiyun @$(call legal-manifest,HOST,buildroot,$(BR2_VERSION_FULL),GPL-2.0+,COPYING,not saved,not saved) 886*4882a593Smuzhiyun @$(call legal-warning,the Buildroot source code has not been saved) 887*4882a593Smuzhiyun @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config 888*4882a593Smuzhiyun 889*4882a593Smuzhiyun.PHONY: legal-info 890*4882a593Smuzhiyunlegal-info: legal-info-clean legal-info-prepare $(foreach p,$(PACKAGES),$(p)-all-legal-info) \ 891*4882a593Smuzhiyun $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST) 892*4882a593Smuzhiyun @cat support/legal-info/README.header >>$(LEGAL_REPORT) 893*4882a593Smuzhiyun @if [ -r $(LEGAL_WARNINGS) ]; then \ 894*4882a593Smuzhiyun cat support/legal-info/README.warnings-header \ 895*4882a593Smuzhiyun $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \ 896*4882a593Smuzhiyun cat $(LEGAL_WARNINGS); fi 897*4882a593Smuzhiyun @rm -f $(LEGAL_WARNINGS) 898*4882a593Smuzhiyun @(cd $(LEGAL_INFO_DIR); \ 899*4882a593Smuzhiyun find * -type f -exec sha256sum {} + | LC_ALL=C sort -k2 \ 900*4882a593Smuzhiyun >.legal-info.sha256; \ 901*4882a593Smuzhiyun mv .legal-info.sha256 legal-info.sha256) 902*4882a593Smuzhiyun @echo "Legal info produced in $(LEGAL_INFO_DIR)" 903*4882a593Smuzhiyun 904*4882a593Smuzhiyun.PHONY: show-targets 905*4882a593Smuzhiyunshow-targets: 906*4882a593Smuzhiyun @echo $(sort $(PACKAGES)) $(sort $(TARGETS_ROOTFS)) 907*4882a593Smuzhiyun 908*4882a593Smuzhiyun.PHONY: show-build-order 909*4882a593Smuzhiyunshow-build-order: $(patsubst %,%-show-build-order,$(PACKAGES)) 910*4882a593Smuzhiyun 911*4882a593Smuzhiyun.PHONY: graph-build 912*4882a593Smuzhiyungraph-build: $(O)/build/build-time.log 913*4882a593Smuzhiyun @install -d $(GRAPHS_DIR) 914*4882a593Smuzhiyun $(foreach o,name build duration,./support/scripts/graph-build-time \ 915*4882a593Smuzhiyun --type=histogram --order=$(o) --input=$(<) \ 916*4882a593Smuzhiyun --output=$(GRAPHS_DIR)/build.hist-$(o).$(BR_GRAPH_OUT) \ 917*4882a593Smuzhiyun $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep)) 918*4882a593Smuzhiyun $(foreach t,packages steps,./support/scripts/graph-build-time \ 919*4882a593Smuzhiyun --type=pie-$(t) --input=$(<) \ 920*4882a593Smuzhiyun --output=$(GRAPHS_DIR)/build.pie-$(t).$(BR_GRAPH_OUT) \ 921*4882a593Smuzhiyun $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep)) 922*4882a593Smuzhiyun 923*4882a593Smuzhiyun.PHONY: graph-depends-requirements 924*4882a593Smuzhiyungraph-depends-requirements: 925*4882a593Smuzhiyun @dot -? >/dev/null 2>&1 || \ 926*4882a593Smuzhiyun { echo "ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit 1; } 927*4882a593Smuzhiyun 928*4882a593Smuzhiyun.PHONY: graph-depends 929*4882a593Smuzhiyungraph-depends: graph-depends-requirements 930*4882a593Smuzhiyun @$(INSTALL) -d $(GRAPHS_DIR) 931*4882a593Smuzhiyun @cd "$(CONFIG_DIR)"; \ 932*4882a593Smuzhiyun $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \ 933*4882a593Smuzhiyun --direct -o $(GRAPHS_DIR)/$(@).dot 934*4882a593Smuzhiyun dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) \ 935*4882a593Smuzhiyun -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT) \ 936*4882a593Smuzhiyun $(GRAPHS_DIR)/$(@).dot 937*4882a593Smuzhiyun 938*4882a593Smuzhiyun.PHONY: graph-size 939*4882a593Smuzhiyungraph-size: 940*4882a593Smuzhiyun $(Q)mkdir -p $(GRAPHS_DIR) 941*4882a593Smuzhiyun $(Q)$(TOPDIR)/support/scripts/size-stats --builddir $(BASE_DIR) \ 942*4882a593Smuzhiyun --graph $(GRAPHS_DIR)/graph-size.$(BR_GRAPH_OUT) \ 943*4882a593Smuzhiyun --file-size-csv $(GRAPHS_DIR)/file-size-stats.csv \ 944*4882a593Smuzhiyun --package-size-csv $(GRAPHS_DIR)/package-size-stats.csv \ 945*4882a593Smuzhiyun $(BR2_GRAPH_SIZE_OPTS) 946*4882a593Smuzhiyun 947*4882a593Smuzhiyun.PHONY: check-dependencies 948*4882a593Smuzhiyuncheck-dependencies: 949*4882a593Smuzhiyun @cd "$(CONFIG_DIR)"; \ 950*4882a593Smuzhiyun $(TOPDIR)/support/scripts/graph-depends -C 951*4882a593Smuzhiyun 952*4882a593Smuzhiyun.PHONY: show-info 953*4882a593Smuzhiyunshow-info: 954*4882a593Smuzhiyun @: 955*4882a593Smuzhiyun $(info $(call clean-json, \ 956*4882a593Smuzhiyun { $(foreach p, \ 957*4882a593Smuzhiyun $(sort $(foreach i,$(PACKAGES) $(TARGETS_ROOTFS), \ 958*4882a593Smuzhiyun $(i) \ 959*4882a593Smuzhiyun $($(call UPPERCASE,$(i))_FINAL_RECURSIVE_DEPENDENCIES) \ 960*4882a593Smuzhiyun ) \ 961*4882a593Smuzhiyun ), \ 962*4882a593Smuzhiyun $(call json-info,$(call UPPERCASE,$(p)))$(comma) \ 963*4882a593Smuzhiyun ) } \ 964*4882a593Smuzhiyun ) \ 965*4882a593Smuzhiyun ) 966*4882a593Smuzhiyun 967*4882a593Smuzhiyun.PHONY: pkg-stats 968*4882a593Smuzhiyunpkg-stats: 969*4882a593Smuzhiyun @cd "$(CONFIG_DIR)" ; \ 970*4882a593Smuzhiyun $(TOPDIR)/support/scripts/pkg-stats -c \ 971*4882a593Smuzhiyun --json $(O)/pkg-stats.json \ 972*4882a593Smuzhiyun --html $(O)/pkg-stats.html \ 973*4882a593Smuzhiyun --nvd-path $(DL_DIR)/buildroot-nvd 974*4882a593Smuzhiyun 975*4882a593Smuzhiyun.PHONY: missing-cpe 976*4882a593Smuzhiyunmissing-cpe: 977*4882a593Smuzhiyun $(Q)mkdir -p $(CPE_UPDATES_DIR) 978*4882a593Smuzhiyun $(Q)cd "$(CONFIG_DIR)" ; \ 979*4882a593Smuzhiyun $(TOPDIR)/support/scripts/gen-missing-cpe \ 980*4882a593Smuzhiyun --nvd-path $(DL_DIR)/buildroot-nvd \ 981*4882a593Smuzhiyun --output $(CPE_UPDATES_DIR) 982*4882a593Smuzhiyun 983*4882a593Smuzhiyunelse # ifeq ($(BR2_HAVE_DOT_CONFIG),y) 984*4882a593Smuzhiyun 985*4882a593Smuzhiyun# Some subdirectories are also package names. To avoid that "make linux" 986*4882a593Smuzhiyun# on an unconfigured tree produces "Nothing to be done", add an explicit 987*4882a593Smuzhiyun# rule for it. 988*4882a593Smuzhiyun# Also for 'all' we error out and ask the user to configure first. 989*4882a593Smuzhiyun.PHONY: linux toolchain 990*4882a593Smuzhiyunlinux toolchain all: outputmakefile 991*4882a593Smuzhiyun $(error Please configure Buildroot first (e.g. "make menuconfig")) 992*4882a593Smuzhiyun @exit 1 993*4882a593Smuzhiyun 994*4882a593Smuzhiyunendif # ifeq ($(BR2_HAVE_DOT_CONFIG),y) 995*4882a593Smuzhiyun 996*4882a593Smuzhiyun# configuration 997*4882a593Smuzhiyun# --------------------------------------------------------------------------- 998*4882a593Smuzhiyun 999*4882a593SmuzhiyunHOSTCFLAGS = $(CFLAGS_FOR_BUILD) 1000*4882a593Smuzhiyunexport HOSTCFLAGS 1001*4882a593Smuzhiyun 1002*4882a593Smuzhiyun$(BUILD_DIR)/buildroot-config/%onf: 1003*4882a593Smuzhiyun mkdir -p $(@D)/lxdialog 1004*4882a593Smuzhiyun PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \ 1005*4882a593Smuzhiyun obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F) 1006*4882a593Smuzhiyun 1007*4882a593SmuzhiyunDEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG)) 1008*4882a593Smuzhiyun 1009*4882a593Smuzhiyun# We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will 1010*4882a593Smuzhiyun# recognize that if it's still at its default $(CONFIG_DIR)/defconfig 1011*4882a593SmuzhiyunCOMMON_CONFIG_ENV = \ 1012*4882a593Smuzhiyun BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \ 1013*4882a593Smuzhiyun KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \ 1014*4882a593Smuzhiyun KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \ 1015*4882a593Smuzhiyun KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \ 1016*4882a593Smuzhiyun BR2_CONFIG=$(BR2_CONFIG) \ 1017*4882a593Smuzhiyun HOST_GCC_VERSION="$(HOSTCC_VERSION)" \ 1018*4882a593Smuzhiyun BASE_DIR=$(BASE_DIR) \ 1019*4882a593Smuzhiyun SKIP_LEGACY= \ 1020*4882a593Smuzhiyun CUSTOM_KERNEL_VERSION="$(CUSTOM_KERNEL_VERSION)" 1021*4882a593Smuzhiyun 1022*4882a593Smuzhiyunxconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile 1023*4882a593Smuzhiyun @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN) 1024*4882a593Smuzhiyun 1025*4882a593Smuzhiyungconfig: $(BUILD_DIR)/buildroot-config/gconf outputmakefile 1026*4882a593Smuzhiyun @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN) 1027*4882a593Smuzhiyun 1028*4882a593Smuzhiyunmenuconfig: $(BUILD_DIR)/buildroot-config/mconf outputmakefile 1029*4882a593Smuzhiyun @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN) 1030*4882a593Smuzhiyun 1031*4882a593Smuzhiyunnconfig: $(BUILD_DIR)/buildroot-config/nconf outputmakefile 1032*4882a593Smuzhiyun @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN) 1033*4882a593Smuzhiyun 1034*4882a593Smuzhiyunconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile 1035*4882a593Smuzhiyun @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN) 1036*4882a593Smuzhiyun 1037*4882a593Smuzhiyun# For the config targets that automatically select options, we pass 1038*4882a593Smuzhiyun# SKIP_LEGACY=y to disable the legacy options. However, in that case 1039*4882a593Smuzhiyun# no values are set for the legacy options so a subsequent oldconfig 1040*4882a593Smuzhiyun# will query them. Therefore, run an additional olddefconfig. 1041*4882a593Smuzhiyun 1042*4882a593Smuzhiyunrandconfig allyesconfig alldefconfig allnoconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile 1043*4882a593Smuzhiyun @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --$@ $(CONFIG_CONFIG_IN) 1044*4882a593Smuzhiyun @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null 1045*4882a593Smuzhiyun 1046*4882a593Smuzhiyunrandpackageconfig allyespackageconfig allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile 1047*4882a593Smuzhiyun @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg 1048*4882a593Smuzhiyun @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \ 1049*4882a593Smuzhiyun KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \ 1050*4882a593Smuzhiyun $< --$(subst package,,$@) $(CONFIG_CONFIG_IN) 1051*4882a593Smuzhiyun @rm -f $(CONFIG_DIR)/.config.nopkg 1052*4882a593Smuzhiyun @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null 1053*4882a593Smuzhiyun 1054*4882a593Smuzhiyunoldconfig syncconfig olddefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile 1055*4882a593Smuzhiyun @$(COMMON_CONFIG_ENV) $< --$@ $(CONFIG_CONFIG_IN) 1056*4882a593Smuzhiyun 1057*4882a593Smuzhiyundefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile 1058*4882a593Smuzhiyun @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN) 1059*4882a593Smuzhiyun 1060*4882a593Smuzhiyundefine percent_defconfig 1061*4882a593Smuzhiyun# Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig 1062*4882a593Smuzhiyunrockchip_%_defconfig: $(BUILD_DIR)/buildroot-config/conf $(1)/configs/rockchip_%_defconfig outputmakefile 1063*4882a593Smuzhiyun $(TOPDIR)/build/parse_defconfig.sh $(1)/configs/$$@ \ 1064*4882a593Smuzhiyun $(BASE_DIR)/.config.in 1065*4882a593Smuzhiyun $$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(1)/configs/$$@ \ 1066*4882a593Smuzhiyun $$< --defconfig=$(BASE_DIR)/.config.in $$(CONFIG_CONFIG_IN) 1067*4882a593Smuzhiyun 1068*4882a593Smuzhiyun%_defconfig: $(BUILD_DIR)/buildroot-config/conf $(1)/configs/%_defconfig outputmakefile 1069*4882a593Smuzhiyun $(TOPDIR)/build/parse_defconfig.sh $(1)/configs/$$@ \ 1070*4882a593Smuzhiyun $(BASE_DIR)/.config.in 1071*4882a593Smuzhiyun $$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(1)/configs/$$@ \ 1072*4882a593Smuzhiyun $$< --defconfig=$(BASE_DIR)/.config.in $$(CONFIG_CONFIG_IN) 1073*4882a593Smuzhiyunendef 1074*4882a593Smuzhiyun$(eval $(foreach d,$(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)),$(call percent_defconfig,$(d))$(sep))) 1075*4882a593Smuzhiyun 1076*4882a593Smuzhiyunupdate-defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile 1077*4882a593Smuzhiyun $(TOPDIR)/build/update_defconfig.sh \ 1078*4882a593Smuzhiyun $(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) 1079*4882a593Smuzhiyun 1080*4882a593Smuzhiyunsavedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile 1081*4882a593Smuzhiyun @$(COMMON_CONFIG_ENV) $< \ 1082*4882a593Smuzhiyun --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \ 1083*4882a593Smuzhiyun $(CONFIG_CONFIG_IN) 1084*4882a593Smuzhiyun @$(SED) '/^BR2_DEFCONFIG=/d' $(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) 1085*4882a593Smuzhiyun 1086*4882a593Smuzhiyun.PHONY: defconfig savedefconfig update-defconfig 1087*4882a593Smuzhiyun 1088*4882a593Smuzhiyun################################################################################ 1089*4882a593Smuzhiyun# 1090*4882a593Smuzhiyun# Cleanup and misc junk 1091*4882a593Smuzhiyun# 1092*4882a593Smuzhiyun################################################################################ 1093*4882a593Smuzhiyun 1094*4882a593Smuzhiyun# staging and target directories do NOT list these as 1095*4882a593Smuzhiyun# dependencies anywhere else 1096*4882a593Smuzhiyun$(BUILD_DIR) $(BASE_TARGET_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST) $(PER_PACKAGE_DIR): 1097*4882a593Smuzhiyun @mkdir -p $@ 1098*4882a593Smuzhiyun 1099*4882a593Smuzhiyun# outputmakefile generates a Makefile in the output directory, if using a 1100*4882a593Smuzhiyun# separate output directory. This allows convenient use of make in the 1101*4882a593Smuzhiyun# output directory. 1102*4882a593Smuzhiyun.PHONY: outputmakefile 1103*4882a593Smuzhiyunoutputmakefile: 1104*4882a593Smuzhiyunifeq ($(NEED_WRAPPER),y) 1105*4882a593Smuzhiyun $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O) 1106*4882a593Smuzhiyunendif 1107*4882a593Smuzhiyun 1108*4882a593Smuzhiyun# printvars prints all the variables currently defined in our 1109*4882a593Smuzhiyun# Makefiles. Alternatively, if a non-empty VARS variable is passed, 1110*4882a593Smuzhiyun# only the variables matching the make pattern passed in VARS are 1111*4882a593Smuzhiyun# displayed. 1112*4882a593Smuzhiyun.PHONY: printvars 1113*4882a593Smuzhiyunprintvars: 1114*4882a593Smuzhiyun @: 1115*4882a593Smuzhiyun $(foreach V, \ 1116*4882a593Smuzhiyun $(sort $(filter $(VARS),$(.VARIABLES))), \ 1117*4882a593Smuzhiyun $(if $(filter-out environment% default automatic, \ 1118*4882a593Smuzhiyun $(origin $V)), \ 1119*4882a593Smuzhiyun $(if $(QUOTED_VARS),\ 1120*4882a593Smuzhiyun $(info $V='$(subst ','\'',$(if $(RAW_VARS),$(value $V),$($V)))'), \ 1121*4882a593Smuzhiyun $(info $V=$(if $(RAW_VARS),$(value $V),$($V)))))) 1122*4882a593Smuzhiyun# ')))) # Syntax colouring... 1123*4882a593Smuzhiyun 1124*4882a593Smuzhiyun.PHONY: clean 1125*4882a593Smuzhiyunclean: 1126*4882a593Smuzhiyun rm -rf $(BASE_TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) $(HOST_DIR_SYMLINK) \ 1127*4882a593Smuzhiyun $(BUILD_DIR) $(BASE_DIR)/staging \ 1128*4882a593Smuzhiyun $(LEGAL_INFO_DIR) $(GRAPHS_DIR) $(PER_PACKAGE_DIR) $(CPE_UPDATES_DIR) \ 1129*4882a593Smuzhiyun $(O)/pkg-stats.* 1130*4882a593Smuzhiyun 1131*4882a593Smuzhiyun.PHONY: distclean 1132*4882a593Smuzhiyundistclean: clean 1133*4882a593Smuzhiyunifeq ($(O),$(CURDIR)/output) 1134*4882a593Smuzhiyun rm -rf $(O) 1135*4882a593Smuzhiyunendif 1136*4882a593Smuzhiyun rm -rf $(TOPDIR)/dl $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/..config.tmp \ 1137*4882a593Smuzhiyun $(CONFIG_DIR)/.auto.deps $(BASE_DIR)/.br2-external.* 1138*4882a593Smuzhiyun 1139*4882a593Smuzhiyun.PHONY: help 1140*4882a593Smuzhiyunhelp: 1141*4882a593Smuzhiyun @echo 'Cleaning:' 1142*4882a593Smuzhiyun @echo ' clean - delete all files created by build' 1143*4882a593Smuzhiyun @echo ' distclean - delete all non-source files (including .config)' 1144*4882a593Smuzhiyun @echo 1145*4882a593Smuzhiyun @echo 'Build:' 1146*4882a593Smuzhiyun @echo ' all - make world' 1147*4882a593Smuzhiyun @echo ' toolchain - build toolchain' 1148*4882a593Smuzhiyun @echo ' sdk - build relocatable SDK' 1149*4882a593Smuzhiyun @echo ' reinstall - reinstall all' 1150*4882a593Smuzhiyun @echo 1151*4882a593Smuzhiyun @echo 'Configuration:' 1152*4882a593Smuzhiyun @echo ' menuconfig - interactive curses-based configurator' 1153*4882a593Smuzhiyun @echo ' nconfig - interactive ncurses-based configurator' 1154*4882a593Smuzhiyun @echo ' xconfig - interactive Qt-based configurator' 1155*4882a593Smuzhiyun @echo ' gconfig - interactive GTK-based configurator' 1156*4882a593Smuzhiyun @echo ' oldconfig - resolve any unresolved symbols in .config' 1157*4882a593Smuzhiyun @echo ' syncconfig - Same as oldconfig, but quietly, additionally update deps' 1158*4882a593Smuzhiyun @echo ' olddefconfig - Same as syncconfig but sets new symbols to their default value' 1159*4882a593Smuzhiyun @echo ' randconfig - New config with random answer to all options' 1160*4882a593Smuzhiyun @echo ' defconfig - New config with default answer to all options;' 1161*4882a593Smuzhiyun @echo ' BR2_DEFCONFIG, if set on the command line, is used as input' 1162*4882a593Smuzhiyun @echo ' savedefconfig - Save current config to BR2_DEFCONFIG (minimal config)' 1163*4882a593Smuzhiyun @echo ' update-defconfig - Same as savedefconfig, but with fragments' 1164*4882a593Smuzhiyun @echo ' allyesconfig - New config where all options are accepted with yes' 1165*4882a593Smuzhiyun @echo ' allnoconfig - New config where all options are answered with no' 1166*4882a593Smuzhiyun @echo ' alldefconfig - New config where all options are set to default' 1167*4882a593Smuzhiyun @echo ' randpackageconfig - New config with random answer to package options' 1168*4882a593Smuzhiyun @echo ' allyespackageconfig - New config where pkg options are accepted with yes' 1169*4882a593Smuzhiyun @echo ' allnopackageconfig - New config where package options are answered with no' 1170*4882a593Smuzhiyun @echo 1171*4882a593Smuzhiyun @echo 'Package-specific:' 1172*4882a593Smuzhiyun @echo ' <pkg> - Build and install <pkg> and all its dependencies' 1173*4882a593Smuzhiyun @echo ' <pkg>-source - Only download the source files for <pkg>' 1174*4882a593Smuzhiyun @echo ' <pkg>-extract - Extract <pkg> sources' 1175*4882a593Smuzhiyun @echo ' <pkg>-patch - Apply patches to <pkg>' 1176*4882a593Smuzhiyun @echo ' <pkg>-depends - Build <pkg>'\''s dependencies' 1177*4882a593Smuzhiyun @echo ' <pkg>-configure - Build <pkg> up to the configure step' 1178*4882a593Smuzhiyun @echo ' <pkg>-build - Build <pkg> up to the build step' 1179*4882a593Smuzhiyun @echo ' <pkg>-show-info - generate info about <pkg>, as a JSON blurb' 1180*4882a593Smuzhiyun @echo ' <pkg>-show-depends - List packages on which <pkg> depends' 1181*4882a593Smuzhiyun @echo ' <pkg>-show-rdepends - List packages which have <pkg> as a dependency' 1182*4882a593Smuzhiyun @echo ' <pkg>-show-recursive-depends' 1183*4882a593Smuzhiyun @echo ' - Recursively list packages on which <pkg> depends' 1184*4882a593Smuzhiyun @echo ' <pkg>-show-recursive-rdepends' 1185*4882a593Smuzhiyun @echo ' - Recursively list packages which have <pkg> as a dependency' 1186*4882a593Smuzhiyun @echo ' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies' 1187*4882a593Smuzhiyun @echo ' <pkg>-graph-rdepends - Generate a graph of <pkg>'\''s reverse dependencies' 1188*4882a593Smuzhiyun @echo ' <pkg>-dirclean - Remove <pkg> build directory' 1189*4882a593Smuzhiyun @echo ' <pkg>-reconfigure - Restart the build from the configure step' 1190*4882a593Smuzhiyun @echo ' <pkg>-rebuild - Restart the build from the build step' 1191*4882a593Smuzhiyun @echo ' <pkg>-reinstall - Restart the build from the install step' 1192*4882a593Smuzhiyun $(foreach p,$(HELP_PACKAGES), \ 1193*4882a593Smuzhiyun @echo $(sep) \ 1194*4882a593Smuzhiyun @echo '$($(p)_NAME):' $(sep) \ 1195*4882a593Smuzhiyun $($(p)_HELP_CMDS)$(sep)) 1196*4882a593Smuzhiyun @echo 1197*4882a593Smuzhiyun @echo 'Documentation:' 1198*4882a593Smuzhiyun @echo ' manual - build manual in all formats' 1199*4882a593Smuzhiyun @echo ' manual-html - build manual in HTML' 1200*4882a593Smuzhiyun @echo ' manual-split-html - build manual in split HTML' 1201*4882a593Smuzhiyun @echo ' manual-pdf - build manual in PDF' 1202*4882a593Smuzhiyun @echo ' manual-text - build manual in text' 1203*4882a593Smuzhiyun @echo ' manual-epub - build manual in ePub' 1204*4882a593Smuzhiyun @echo ' graph-build - generate graphs of the build times' 1205*4882a593Smuzhiyun @echo ' graph-depends - generate graph of the dependency tree' 1206*4882a593Smuzhiyun @echo ' graph-size - generate stats of the filesystem size' 1207*4882a593Smuzhiyun @echo ' list-defconfigs - list all defconfigs (pre-configured minimal systems)' 1208*4882a593Smuzhiyun @echo 1209*4882a593Smuzhiyun @echo 'Miscellaneous:' 1210*4882a593Smuzhiyun @echo ' source - download all sources needed for offline-build' 1211*4882a593Smuzhiyun @echo ' external-deps - list external packages used' 1212*4882a593Smuzhiyun @echo ' legal-info - generate info about license compliance' 1213*4882a593Smuzhiyun @echo ' show-info - generate info about packages, as a JSON blurb' 1214*4882a593Smuzhiyun @echo ' pkg-stats - generate info about packages as JSON and HTML' 1215*4882a593Smuzhiyun @echo ' missing-cpe - generate XML snippets for missing CPE identifiers' 1216*4882a593Smuzhiyun @echo ' printvars - dump internal variables selected with VARS=...' 1217*4882a593Smuzhiyun @echo 1218*4882a593Smuzhiyun @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build' 1219*4882a593Smuzhiyun @echo ' make O=dir - Locate all output files in "dir", including .config' 1220*4882a593Smuzhiyun @echo 1221*4882a593Smuzhiyun @echo 'For further details, see README, generate the Buildroot manual, or consult' 1222*4882a593Smuzhiyun @echo 'it on-line at http://buildroot.org/docs.html' 1223*4882a593Smuzhiyun @echo 1224*4882a593Smuzhiyun 1225*4882a593Smuzhiyun# List the defconfig files 1226*4882a593Smuzhiyun# $(1): base directory 1227*4882a593Smuzhiyun# $(2): br2-external name, empty for bundled 1228*4882a593Smuzhiyundefine list-defconfigs 1229*4882a593Smuzhiyun @first=true; \ 1230*4882a593Smuzhiyun for defconfig in $(1)/configs/*_defconfig; do \ 1231*4882a593Smuzhiyun [ -f "$${defconfig}" ] || continue; \ 1232*4882a593Smuzhiyun if $${first}; then \ 1233*4882a593Smuzhiyun if [ "$(2)" ]; then \ 1234*4882a593Smuzhiyun printf 'External configs in "$(call qstrip,$(2))":\n'; \ 1235*4882a593Smuzhiyun else \ 1236*4882a593Smuzhiyun printf "Built-in configs:\n"; \ 1237*4882a593Smuzhiyun fi; \ 1238*4882a593Smuzhiyun first=false; \ 1239*4882a593Smuzhiyun fi; \ 1240*4882a593Smuzhiyun defconfig="$${defconfig##*/}"; \ 1241*4882a593Smuzhiyun printf " %-35s - Build for %s\n" "$${defconfig}" "$${defconfig%_defconfig}"; \ 1242*4882a593Smuzhiyun done; \ 1243*4882a593Smuzhiyun $${first} || printf "\n" 1244*4882a593Smuzhiyunendef 1245*4882a593Smuzhiyun 1246*4882a593Smuzhiyun# We iterate over BR2_EXTERNAL_NAMES rather than BR2_EXTERNAL_DIRS, 1247*4882a593Smuzhiyun# because we want to display the name of the br2-external tree. 1248*4882a593Smuzhiyun.PHONY: list-defconfigs 1249*4882a593Smuzhiyunlist-defconfigs: 1250*4882a593Smuzhiyun $(call list-defconfigs,$(TOPDIR)) 1251*4882a593Smuzhiyun $(foreach name,$(BR2_EXTERNAL_NAMES),\ 1252*4882a593Smuzhiyun $(call list-defconfigs,$(BR2_EXTERNAL_$(name)_PATH),\ 1253*4882a593Smuzhiyun $(BR2_EXTERNAL_$(name)_DESC))$(sep)) 1254*4882a593Smuzhiyun 1255*4882a593Smuzhiyunrelease: OUT = buildroot-$(BR2_VERSION) 1256*4882a593Smuzhiyun 1257*4882a593Smuzhiyun# Create release tarballs. We need to fiddle a bit to add the generated 1258*4882a593Smuzhiyun# documentation to the git output 1259*4882a593Smuzhiyunrelease: 1260*4882a593Smuzhiyun git archive --format=tar --prefix=$(OUT)/ HEAD > $(OUT).tar 1261*4882a593Smuzhiyun $(MAKE) O=$(OUT) manual-html manual-text manual-pdf 1262*4882a593Smuzhiyun $(MAKE) O=$(OUT) distclean 1263*4882a593Smuzhiyun tar rf $(OUT).tar $(OUT) 1264*4882a593Smuzhiyun gzip -9 -c < $(OUT).tar > $(OUT).tar.gz 1265*4882a593Smuzhiyun xz -9 -c < $(OUT).tar > $(OUT).tar.xz 1266*4882a593Smuzhiyun rm -rf $(OUT) $(OUT).tar 1267*4882a593Smuzhiyun 1268*4882a593Smuzhiyunprint-version: 1269*4882a593Smuzhiyun @echo $(BR2_VERSION_FULL) 1270*4882a593Smuzhiyun 1271*4882a593Smuzhiyuncheck-flake8: 1272*4882a593Smuzhiyun $(Q)git ls-tree -r --name-only HEAD \ 1273*4882a593Smuzhiyun | xargs file \ 1274*4882a593Smuzhiyun | grep 'Python script' \ 1275*4882a593Smuzhiyun | cut -d':' -f1 \ 1276*4882a593Smuzhiyun | xargs -- python3 -m flake8 --statistics 1277*4882a593Smuzhiyun 1278*4882a593Smuzhiyuncheck-package: 1279*4882a593Smuzhiyun find $(TOPDIR) -type f \( -name '*.mk' -o -name '*.hash' -o -name 'Config.*' \) \ 1280*4882a593Smuzhiyun -exec ./utils/check-package {} + 1281*4882a593Smuzhiyun 1282*4882a593Smuzhiyuninclude docs/manual/manual.mk 1283*4882a593Smuzhiyun-include $(foreach dir,$(BR2_EXTERNAL_DIRS),$(sort $(wildcard $(dir)/docs/*/*.mk))) 1284*4882a593Smuzhiyun 1285*4882a593Smuzhiyun.PHONY: $(noconfig_targets) 1286*4882a593Smuzhiyun 1287*4882a593Smuzhiyunendif #umask / $(CURDIR) / $(O) 1288