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 LD_LIBRARY_PATH:=$(subst ::,:,$(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):)$(TOPDIR)/staging_dir/host/lib)
26 export DYLD_LIBRARY_PATH:=$(subst ::,:,$(if $(DYLD_LIBRARY_PATH),$(DYLD_LIBRARY_PATH):)$(TOPDIR)/staging_dir/host/lib)
27 export GIT_CONFIG_PARAMETERS='core.autocrlf=false'
28 export MAKE_JOBSERVER=$(filter --jobserver%,$(MAKEFLAGS))
30 # prevent perforce from messing with the patch utility
31 unexport P4PORT P4USER P4CONFIG P4CLIENT
33 # prevent user defaults for quilt from interfering
34 unexport QUILT_PATCHES QUILT_PATCH_OPTS
36 unexport C_INCLUDE_PATH CROSS_COMPILE ARCH
38 # prevent distro default LPATH from interfering
41 # make sure that a predefined CFLAGS variable does not disturb packages
46 ifneq ($(shell $(HOSTCC) 2>&1 | grep clang),)
47 export HOSTCC_REAL?=$(HOSTCC)
48 export HOSTCC_WRAPPER:=$(TOPDIR)/scripts/clang-gcc-wrapper
50 export HOSTCC_WRAPPER:=$(HOSTCC)
54 .config scripts/config/conf scripts/config/mconf: staging_dir/host/.prereq-build
57 SCAN_COOKIE?=$(shell echo $$$$)
60 SUBMAKE:=umask 022; $(SUBMAKE)
62 ULIMIT_FIX=_limit=`ulimit -n`; [ "$$_limit" = "unlimited" -o "$$_limit" -ge 1024 ] || ulimit -n 1024;
66 prepare-tmpinfo: FORCE
67 @+$(MAKE) -r -s staging_dir/host/.prereq-build $(PREP_MK)
69 $(_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=""
70 $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="profiles/*.mk $(TOPDIR)/include/kernel*.mk $(TOPDIR)/include/target.mk" SCAN_DEPTH=2 SCAN_EXTRA="" SCAN_MAKEOPTS="TARGET_BUILD=1"
71 for type in package target; do \
72 f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
73 [ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
75 [ tmp/.config-feeds.in -nt tmp/.packagefeeds ] || ./scripts/feeds feed_config > tmp/.config-feeds.in
76 ./scripts/metadata.pl package_mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
77 ./scripts/metadata.pl package_feeds tmp/.packageinfo > tmp/.packagefeeds || { rm -f tmp/.packagefeeds; false; }
78 touch $(TOPDIR)/tmp/.build
80 .config: ./scripts/config/conf $(if $(CONFIG_HAVE_DOT_CONFIG),,prepare-tmpinfo)
81 @+if [ \! -e .config ] || ! grep CONFIG_HAVE_DOT_CONFIG .config >/dev/null; then \
82 [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
83 $(_SINGLE)$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \
87 @$(_SINGLE)$(SUBMAKE) -s -C scripts/config all CC="$(HOSTCC_WRAPPER)"
89 $(eval $(call rdep,scripts/config,scripts/config/mconf))
92 @$(_SINGLE)$(SUBMAKE) -s -C scripts/config conf CC="$(HOSTCC_WRAPPER)"
94 config: scripts/config/conf prepare-tmpinfo FORCE
98 $(_SINGLE)$(NO_TRACE_MAKE) -C scripts/config clean
100 defconfig: scripts/config/conf prepare-tmpinfo FORCE
102 @if [ -e $(HOME)/.openwrt/defconfig ]; then cp $(HOME)/.openwrt/defconfig .config; fi
103 $< --defconfig=.config Config.in
108 confdefault:=$(confdefault-$(CONFDEFAULT))
110 oldconfig: scripts/config/conf prepare-tmpinfo FORCE
111 $< --$(if $(confdefault),$(confdefault),old)config Config.in
113 menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
114 if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
115 cp $(HOME)/.openwrt/defconfig .config; \
119 prepare_kernel_conf: .config FORCE
121 ifeq ($(wildcard staging_dir/host/bin/quilt),)
123 @+$(SUBMAKE) -r tools/quilt/install
125 prepare_kernel_conf: ;
128 kernel_oldconfig: prepare_kernel_conf
129 $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux oldconfig
131 kernel_menuconfig: prepare_kernel_conf
132 $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux menuconfig
134 kernel_nconfig: prepare_kernel_conf
135 $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux nconfig
137 staging_dir/host/.prereq-build: include/prereq-build.mk
140 @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
141 echo "Prerequisite check failed. Use FORCE=1 to override."; \
144 ifneq ($(realpath $(TOPDIR)/include/prepare.mk),)
145 @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prepare.mk prepare 2>/dev/null || { \
146 echo "Preparation failed."; \
153 @$(_SINGLE)$(NO_TRACE_MAKE) -p $@ V=99 DUMP_TARGET_DB=1 2>&1
155 download: .config FORCE
156 @+$(SUBMAKE) tools/download
157 @+$(SUBMAKE) toolchain/download
158 @+$(SUBMAKE) package/download
159 @+$(SUBMAKE) target/download
161 clean dirclean: .config
164 prereq:: prepare-tmpinfo .config
165 @+$(NO_TRACE_MAKE) -r -s $@
167 WARN_PARALLEL_ERROR = $(if $(BUILD_LOG),,$(and $(filter -j,$(MAKEFLAGS)),$(findstring s,$(OPENWRT_VERBOSE))))
172 @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
173 @./scripts/config/conf --defconfig=.config Config.in
174 @+$(ULIMIT_FIX) $(SUBMAKE) -r $@
179 @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
181 cp .config tmp/.config; \
182 ./scripts/config/conf --defconfig=tmp/.config -w tmp/.config Config.in > /dev/null 2>&1; \
183 if ./scripts/kconfig.pl '>' .config tmp/.config | grep -q CONFIG; then \
184 printf "$(_R)WARNING: your configuration is out of sync. Please run make menuconfig, oldconfig or defconfig!$(_N)\n" >&2; \
187 @+$(ULIMIT_FIX) $(SUBMAKE) -r $@ $(if $(WARN_PARALLEL_ERROR), || { \
188 printf "$(_R)Build failed - please re-run with -j1 to see the real error message$(_N)\n" >&2; \
194 # update all feeds, re-create index files, install symlinks
196 ./scripts/feeds update -a
197 ./scripts/feeds install -a
199 # re-create index files, install symlinks
200 package/symlinks-install:
201 ./scripts/feeds update -i
202 ./scripts/feeds install -a
204 # remove all symlinks, don't touch ./feeds
205 package/symlinks-clean:
206 ./scripts/feeds uninstall -a
211 docs docs/compile: FORCE
212 @$(_SINGLE)$(SUBMAKE) -C docs compile
215 @$(_SINGLE)$(SUBMAKE) -C docs clean
218 rm -rf tmp build_dir staging_dir dl .config* feeds package/feeds package/openwrt-packages bin
219 @$(_SINGLE)$(SUBMAKE) -C scripts/config clean
221 ifeq ($(findstring v,$(DEBUG)),)
222 .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