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 PREP_MK
= OPENWRT_BUILD
= QUIET
=0
11 export IS_TTY
=$(shell tty
-s
&& echo
1 || echo
0)
13 include $(TOPDIR
)/include/verbose.mk
16 include $(TOPDIR
)/include/version.mk
18 REVISION
:=$(shell $(TOPDIR
)/scripts
/getver.sh
)
19 SOURCE_DATE_EPOCH
:=$(shell $(TOPDIR
)/scripts
/get_source_date_epoch.sh
)
23 export SOURCE_DATE_EPOCH
24 export GIT_CONFIG_PARAMETERS
='core.autocrlf=false'
25 export GIT_ASKPASS
:=/bin
/true
26 export MAKE_JOBSERVER
=$(filter --jobserver
%,$(MAKEFLAGS
))
27 export GNU_HOST_NAME
:=$(shell $(TOPDIR
)/scripts
/config.guess
)
28 export HOST_OS
:=$(shell uname
)
29 export HOST_ARCH
:=$(shell uname
-m
)
31 ifeq ($(HOST_OS
),Darwin
)
32 ifneq ($(filter /Applications
/Xcode.app
/% /Library
/Developer
/%,$(MAKE
)),)
33 $(error Please use a newer version of GNU make. The version shipped by Apple is not supported
)
37 # prevent perforce from messing with the patch utility
38 unexport P4PORT P4USER P4CONFIG P4CLIENT
40 # prevent user defaults for quilt from interfering
41 unexport QUILT_PATCHES QUILT_PATCH_OPTS
43 unexport C_INCLUDE_PATH CROSS_COMPILE ARCH
45 # prevent distro default LPATH from interfering
48 # make sure that a predefined CFLAGS variable does not disturb packages
53 space
:= $(empty
) $(empty
)
54 path
:=$(subst :,$(space
),$(PATH
))
55 path
:=$(filter-out .
%,$(path
))
56 path
:=$(subst $(space
),:,$(path
))
62 .config scripts
/config
/conf scripts
/config
/mconf
: staging_dir
/host
/.prereq-build
65 SCAN_COOKIE?
=$(shell echo
$$$$)
68 SUBMAKE
:=umask
022; $(SUBMAKE
)
70 ULIMIT_FIX
=_limit
=`ulimit -n`; [ "$$_limit" = "unlimited" -o
"$$_limit" -ge
1024 ] || ulimit
-n
1024;
72 prepare-mk
: staging_dir
/host
/.prereq-build FORCE
;
75 IGNORE_PACKAGES
= linux
78 _ignore
= $(foreach p
,$(IGNORE_PACKAGES
),--ignore
$(p
))
80 prepare-tmpinfo
: FORCE
81 @
+$(MAKE
) -r
-s staging_dir
/host
/.prereq-build
$(PREP_MK
)
83 $(_SINGLE
)$(NO_TRACE_MAKE
) -j1
-r
-s
-f
include/scan.mk SCAN_TARGET
="packageinfo" SCAN_DIR
="package" SCAN_NAME
="package" SCAN_DEPTH
=5 SCAN_EXTRA
=""
84 $(_SINGLE
)$(NO_TRACE_MAKE
) -j1
-r
-s
-f
include/scan.mk SCAN_TARGET
="targetinfo" SCAN_DIR
="target/linux" SCAN_NAME
="target" SCAN_DEPTH
=2 SCAN_EXTRA
="" SCAN_MAKEOPTS
="TARGET_BUILD=1"
85 for type in package target
; do \
86 f
=tmp
/.
$${type}info; t
=tmp
/.config-
$${type}.in
; \
87 [ "$$t" -nt
"$$f" ] || .
/scripts
/$${type}-metadata.pl
$(_ignore
) config
"$$f" > "$$t" ||
{ rm -f
"$$t"; echo
"Failed to build $$t"; false
; break
; }; \
89 [ tmp
/.config-feeds.in
-nt tmp
/.packageauxvars
] || .
/scripts
/feeds feed_config
> tmp
/.config-feeds.in
90 .
/scripts
/package-metadata.pl mk tmp
/.packageinfo
> tmp
/.packagedeps ||
{ rm -f tmp
/.packagedeps
; false
; }
91 .
/scripts
/package-metadata.pl pkgaux tmp
/.packageinfo
> tmp
/.packageauxvars ||
{ rm -f tmp
/.packageauxvars
; false
; }
92 .
/scripts
/package-metadata.pl usergroup tmp
/.packageinfo
> tmp
/.packageusergroup ||
{ rm -f tmp
/.packageusergroup
; false
; }
93 touch
$(TOPDIR
)/tmp
/.build
95 .config
: .
/scripts
/config
/conf
$(if
$(CONFIG_HAVE_DOT_CONFIG
),,prepare-tmpinfo
)
96 @
+if
[ \
! -e .config
] ||
! grep CONFIG_HAVE_DOT_CONFIG .config
>/dev
/null
; then \
97 [ -e
$(HOME
)/.openwrt
/defconfig
] && cp
$(HOME
)/.openwrt
/defconfig .config
; \
98 $(_SINGLE
)$(NO_TRACE_MAKE
) menuconfig
$(PREP_MK
); \
101 ifeq ($(RECURSIVE_DEP_IS_ERROR
),1)
102 KCONF_FLAGS
=--fatalrecursive
104 ifneq ($(DISTRO_PKG_CONFIG
),)
105 scripts
/config
/%onf
: export PATH
:=$(dir $(DISTRO_PKG_CONFIG
)):$(PATH
)
107 scripts
/config
/%onf
: CFLAGS
+= -O2
109 @
$(_SINGLE
)$(SUBMAKE
) $(if
$(findstring s
,$(OPENWRT_VERBOSE
)),,-s
) \
110 -C scripts
/config
$(notdir $@
)
112 $(eval
$(call rdep
,scripts
/config
,scripts
/config
/mconf
))
114 config
: scripts
/config
/conf prepare-tmpinfo FORCE
115 [ -L .config
] && export KCONFIG_OVERWRITECONFIG
=1; \
116 $< $(KCONF_FLAGS
) Config.in
119 $(_SINGLE
)$(NO_TRACE_MAKE
) -C scripts
/config
clean
121 defconfig
: scripts
/config
/conf prepare-tmpinfo FORCE
123 @if
[ ! -s .config
-a
-e
$(HOME
)/.openwrt
/defconfig
]; then cp
$(HOME
)/.openwrt
/defconfig .config
; fi
124 [ -L .config
] && export KCONFIG_OVERWRITECONFIG
=1; \
125 $< $(KCONF_FLAGS
) --defconfig
=.config Config.in
130 confdefault
:=$(confdefault-
$(CONFDEFAULT
))
132 oldconfig
: scripts
/config
/conf prepare-tmpinfo FORCE
133 [ -L .config
] && export KCONFIG_OVERWRITECONFIG
=1; \
134 $< $(KCONF_FLAGS
) --$(if
$(confdefault
),$(confdefault
),old
)config Config.in
136 menuconfig
: scripts
/config
/mconf prepare-tmpinfo FORCE
137 if
[ \
! -e .config
-a
-e
$(HOME
)/.openwrt
/defconfig
]; then \
138 cp
$(HOME
)/.openwrt
/defconfig .config
; \
140 [ -L .config
] && export KCONFIG_OVERWRITECONFIG
=1; \
143 nconfig
: scripts
/config
/nconf prepare-tmpinfo FORCE
144 if
[ \
! -e .config
-a
-e
$(HOME
)/.openwrt
/defconfig
]; then \
145 cp
$(HOME
)/.openwrt
/defconfig .config
; \
147 [ -L .config
] && export KCONFIG_OVERWRITECONFIG
=1; \
150 xconfig
: scripts
/config
/qconf prepare-tmpinfo FORCE
151 if
[ \
! -e .config
-a
-e
$(HOME
)/.openwrt
/defconfig
]; then \
152 cp
$(HOME
)/.openwrt
/defconfig .config
; \
156 prepare_kernel_conf
: .config toolchain
/install FORCE
158 ifeq ($(wildcard staging_dir
/host
/bin
/quilt
),)
160 @
+$(SUBMAKE
) -r tools
/quilt
/compile
162 prepare_kernel_conf
: ;
165 kernel_oldconfig
: prepare_kernel_conf
166 $(_SINGLE
)$(NO_TRACE_MAKE
) -C target
/linux oldconfig
168 ifneq ($(DISTRO_PKG_CONFIG
),)
169 kernel_menuconfig
: export PATH
:=$(dir $(DISTRO_PKG_CONFIG
)):$(PATH
)
170 kernel_nconfig
: export PATH
:=$(dir $(DISTRO_PKG_CONFIG
)):$(PATH
)
171 kernel_xconfig
: export PATH
:=$(dir $(DISTRO_PKG_CONFIG
)):$(PATH
)
173 kernel_menuconfig
: prepare_kernel_conf
174 $(_SINGLE
)$(NO_TRACE_MAKE
) -C target
/linux menuconfig
176 kernel_nconfig
: prepare_kernel_conf
177 $(_SINGLE
)$(NO_TRACE_MAKE
) -C target
/linux nconfig
179 kernel_xconfig
: prepare_kernel_conf
180 $(_SINGLE
)$(NO_TRACE_MAKE
) -C target
/linux xconfig
182 staging_dir
/host
/.prereq-build
: include/prereq-build.mk
184 @
$(_SINGLE
)$(NO_TRACE_MAKE
) -j1
-r
-s
-f
$(TOPDIR
)/include/prereq-build.mk prereq
2>/dev
/null ||
{ \
185 echo
"Prerequisite check failed. Use FORCE=1 to override."; \
188 ifneq ($(realpath
$(TOPDIR
)/include/prepare.mk
),)
189 @
$(_SINGLE
)$(NO_TRACE_MAKE
) -j1
-r
-s
-f
$(TOPDIR
)/include/prepare.mk prepare
2>/dev
/null ||
{ \
190 echo
"Preparation failed."; \
197 @
$(_SINGLE
)$(NO_TRACE_MAKE
) -p
$@ V
=99 DUMP_TARGET_DB
=1 2>&1
200 DOWNLOAD_DIRS
= tools
/download toolchain
/download package
/download target
/download
202 DOWNLOAD_DIRS
= package
/download
205 download
: .config FORCE
$(if
$(wildcard $(TOPDIR
)/staging_dir
/host
/bin
/flock
),,tools
/flock
/compile
)
206 @
+$(foreach dir,$(DOWNLOAD_DIRS
),$(SUBMAKE
) $(dir);)
208 clean dirclean
: .config
211 prereq
:: prepare-tmpinfo .config
212 @
+$(NO_TRACE_MAKE
) -r
-s
$@
215 @
+$(NO_TRACE_MAKE
) -r
-s
$@ QUIET
= V
=s
218 @
+$(NO_TRACE_MAKE
) -r
-s
$@ QUIET
= V
=s
220 WARN_PARALLEL_ERROR
= $(if
$(BUILD_LOG
),,$(and
$(filter -j
,$(MAKEFLAGS
)),$(findstring s
,$(OPENWRT_VERBOSE
))))
225 @
+$(PREP_MK
) $(NO_TRACE_MAKE
) -r
-s prereq
226 @.
/scripts
/config
/conf
$(KCONF_FLAGS
) --defconfig
=.config Config.in
227 @
+$(ULIMIT_FIX
) $(SUBMAKE
) -r
$@
232 @
+$(PREP_MK
) $(NO_TRACE_MAKE
) -r
-s prereq
234 cp .config tmp
/.config
; \
235 .
/scripts
/config
/conf
$(KCONF_FLAGS
) --defconfig
=tmp
/.config
-w tmp
/.config Config.in
> /dev
/null
2>&1; \
236 if .
/scripts
/kconfig.pl
'>' .config tmp
/.config | grep
-q CONFIG
; then \
237 printf
"$(_R)WARNING: your configuration is out of sync. Please run make menuconfig, oldconfig or defconfig!$(_N)\n" >&2; \
240 @
+$(ULIMIT_FIX
) $(SUBMAKE
) -r
$@
$(if
$(WARN_PARALLEL_ERROR
), ||
{ \
241 printf
"$(_R)Build failed - please re-run with -j1 to see the real error message$(_N)\n" >&2; \
247 # update all feeds, re-create index files, install symlinks
249 .
/scripts
/feeds update
-a
250 .
/scripts
/feeds
install -a
252 # re-create index files, install symlinks
253 package
/symlinks-install
:
254 .
/scripts
/feeds update
-i
255 .
/scripts
/feeds
install -a
257 # remove all symlinks, don't touch ./feeds
258 package
/symlinks-clean
:
259 .
/scripts
/feeds
uninstall -a
265 rm -rf bin build_dir .ccache .config
* dl feeds key-build
* logs package
/feeds package
/openwrt-packages staging_dir tmp
266 @
$(_SINGLE
)$(SUBMAKE
) -C scripts
/config
clean
268 ifeq ($(findstring v
,$(DEBUG
)),)
269 .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