3 # Copyright (C) 2007-2012 OpenWrt.org
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
9 RELEASE:=Designated Driver
10 PREP_MK= OPENWRT_BUILD= QUIET=0
12 export IS_TTY=$(shell tty -s && echo 1 || echo 0)
14 include $(TOPDIR)/include/verbose.mk
17 include $(TOPDIR)/include/version.mk
19 REVISION:=$(shell $(TOPDIR)/scripts/getver.sh)
25 export GIT_CONFIG_PARAMETERS='core.autocrlf=false'
26 export MAKE_JOBSERVER=$(filter --jobserver%,$(MAKEFLAGS))
27 export SOURCE_DATE_EPOCH:=$(shell $(TOPDIR)/scripts/get_source_date_epoch.sh)
29 # prevent perforce from messing with the patch utility
30 unexport P4PORT P4USER P4CONFIG P4CLIENT
32 # prevent user defaults for quilt from interfering
33 unexport QUILT_PATCHES QUILT_PATCH_OPTS
35 unexport C_INCLUDE_PATH CROSS_COMPILE ARCH
37 # prevent distro default LPATH from interfering
40 # make sure that a predefined CFLAGS variable does not disturb packages
45 space:= $(empty) $(empty)
46 path:=$(subst :,$(space),$(PATH))
47 path:=$(filter-out .%,$(path))
48 path:=$(subst $(space),:,$(path))
53 ifneq ($(shell $(HOSTCC) 2>&1 | grep clang),)
54 export HOSTCC_REAL?=$(HOSTCC)
55 export HOSTCC_WRAPPER:=$(TOPDIR)/scripts/clang-gcc-wrapper
57 export HOSTCC_WRAPPER:=$(HOSTCC)
61 .config scripts/config/conf scripts/config/mconf: staging_dir/host/.prereq-build
64 SCAN_COOKIE?=$(shell echo $$$$)
67 SUBMAKE:=umask 022; $(SUBMAKE)
69 ULIMIT_FIX=_limit=`ulimit -n`; [ "$$_limit" = "unlimited" -o "$$_limit" -ge 1024 ] || ulimit -n 1024;
74 IGNORE_PACKAGES = linux
77 _ignore = $(foreach p,$(IGNORE_PACKAGES),--ignore $(p))
79 prepare-tmpinfo: FORCE
80 @+$(MAKE) -r -s staging_dir/host/.prereq-build $(PREP_MK)
82 $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPS="$(TOPDIR)/include/package*.mk $(TOPDIR)/overlay/*/*.mk" SCAN_DEPTH=5 SCAN_EXTRA=""
83 $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="image/Makefile profiles/*.mk $(TOPDIR)/include/kernel*.mk $(TOPDIR)/include/target.mk" SCAN_DEPTH=2 SCAN_EXTRA="" SCAN_MAKEOPTS="TARGET_BUILD=1"
84 for type in package target; do \
85 f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
86 [ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $(_ignore) $${type}_config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
88 [ tmp/.config-feeds.in -nt tmp/.packagesubdirs ] || ./scripts/feeds feed_config > tmp/.config-feeds.in
89 ./scripts/metadata.pl package_mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
90 ./scripts/metadata.pl package_subdirs tmp/.packageinfo > tmp/.packagesubdirs || { rm -f tmp/.packagesubdirs; false; }
91 touch $(TOPDIR)/tmp/.build
93 .config: ./scripts/config/conf $(if $(CONFIG_HAVE_DOT_CONFIG),,prepare-tmpinfo)
94 @+if [ \! -e .config ] || ! grep CONFIG_HAVE_DOT_CONFIG .config >/dev/null; then \
95 [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
96 $(_SINGLE)$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \
100 @$(_SINGLE)$(SUBMAKE) -s -C scripts/config all CC="$(HOSTCC_WRAPPER)"
102 $(eval $(call rdep,scripts/config,scripts/config/mconf))
105 @$(_SINGLE)$(SUBMAKE) -s -C scripts/config conf CC="$(HOSTCC_WRAPPER)"
107 config: scripts/config/conf prepare-tmpinfo FORCE
111 $(_SINGLE)$(NO_TRACE_MAKE) -C scripts/config clean
113 defconfig: scripts/config/conf prepare-tmpinfo FORCE
115 @if [ -e $(HOME)/.openwrt/defconfig ]; then cp $(HOME)/.openwrt/defconfig .config; fi
116 $< --defconfig=.config Config.in
121 confdefault:=$(confdefault-$(CONFDEFAULT))
123 oldconfig: scripts/config/conf prepare-tmpinfo FORCE
124 $< --$(if $(confdefault),$(confdefault),old)config Config.in
126 menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
127 if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
128 cp $(HOME)/.openwrt/defconfig .config; \
132 prepare_kernel_conf: .config FORCE
134 ifeq ($(wildcard staging_dir/host/bin/quilt),)
136 @+$(SUBMAKE) -r tools/quilt/install
138 prepare_kernel_conf: ;
141 kernel_oldconfig: prepare_kernel_conf
142 $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux oldconfig
144 kernel_menuconfig: prepare_kernel_conf
145 $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux menuconfig
147 kernel_nconfig: prepare_kernel_conf
148 $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux nconfig
150 staging_dir/host/.prereq-build: include/prereq-build.mk
153 @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
154 echo "Prerequisite check failed. Use FORCE=1 to override."; \
157 ifneq ($(realpath $(TOPDIR)/include/prepare.mk),)
158 @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prepare.mk prepare 2>/dev/null || { \
159 echo "Preparation failed."; \
166 @$(_SINGLE)$(NO_TRACE_MAKE) -p $@ V=99 DUMP_TARGET_DB=1 2>&1
168 download: .config FORCE
169 @+$(SUBMAKE) tools/download
170 @+$(SUBMAKE) toolchain/download
171 @+$(SUBMAKE) package/download
172 @+$(SUBMAKE) target/download
174 clean dirclean: .config
177 prereq:: prepare-tmpinfo .config
178 @+$(NO_TRACE_MAKE) -r -s $@
180 WARN_PARALLEL_ERROR = $(if $(BUILD_LOG),,$(and $(filter -j,$(MAKEFLAGS)),$(findstring s,$(OPENWRT_VERBOSE))))
185 @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
186 @./scripts/config/conf --defconfig=.config Config.in
187 @+$(ULIMIT_FIX) $(SUBMAKE) -r $@
192 @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
194 cp .config tmp/.config; \
195 ./scripts/config/conf --defconfig=tmp/.config -w tmp/.config Config.in > /dev/null 2>&1; \
196 if ./scripts/kconfig.pl '>' .config tmp/.config | grep -q CONFIG; then \
197 printf "$(_R)WARNING: your configuration is out of sync. Please run make menuconfig, oldconfig or defconfig!$(_N)\n" >&2; \
200 @+$(ULIMIT_FIX) $(SUBMAKE) -r $@ $(if $(WARN_PARALLEL_ERROR), || { \
201 printf "$(_R)Build failed - please re-run with -j1 to see the real error message$(_N)\n" >&2; \
207 # update all feeds, re-create index files, install symlinks
209 ./scripts/feeds update -a
210 ./scripts/feeds install -a
212 # re-create index files, install symlinks
213 package/symlinks-install:
214 ./scripts/feeds update -i
215 ./scripts/feeds install -a
217 # remove all symlinks, don't touch ./feeds
218 package/symlinks-clean:
219 ./scripts/feeds uninstall -a
224 docs docs/compile: FORCE
225 @$(_SINGLE)$(SUBMAKE) -C docs compile
228 @$(_SINGLE)$(SUBMAKE) -C docs clean
231 rm -rf bin build_dir .config* dl feeds key-build* logs package/feeds package/openwrt-packages staging_dir tmp
232 @$(_SINGLE)$(SUBMAKE) -C scripts/config clean
234 ifeq ($(findstring v,$(DEBUG)),)
235 .SILENT: symlinkclean clean dirclean distclean config-clean download help tmpinfo-clean .config scripts/config/mconf scripts/config/conf menuconfig staging_dir/host/.prereq-build tmp/.prereq-package prepare-tmpinfo