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
14 ifeq ($(OPENWRT_VARS
),)
15 include $(TOPDIR
)/include/toplevel-vars.mk
19 .config scripts
/config
/conf scripts
/config
/mconf
: staging_dir
/host
/.prereq-build
22 SUBMAKE
:=umask
022; $(SUBMAKE
)
24 ULIMIT_FIX
=_limit
=`ulimit -n`; [ "$$_limit" = "unlimited" -o
"$$_limit" -ge
1024 ] || ulimit
-n
1024;
26 prepare-mk
: staging_dir
/host
/.prereq-build FORCE
;
29 IGNORE_PACKAGES
= linux
32 _ignore
= $(foreach p
,$(IGNORE_PACKAGES
),--ignore
$(p
))
34 prepare-tmpinfo
: FORCE
35 @
+$(MAKE
) -r
-s staging_dir
/host
/.prereq-build
$(PREP_MK
)
37 $(_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
=""
38 $(_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"
39 for type in package target
; do \
40 f
=tmp
/.
$${type}info; t
=tmp
/.config-
$${type}.in
; \
41 [ "$$t" -nt
"$$f" ] || .
/scripts
/$${type}-metadata.pl
$(_ignore
) config
"$$f" > "$$t" ||
{ rm -f
"$$t"; echo
"Failed to build $$t"; false
; break
; }; \
43 [ tmp
/.config-feeds.in
-nt tmp
/.packageauxvars
] || .
/scripts
/feeds feed_config
> tmp
/.config-feeds.in
44 .
/scripts
/package-metadata.pl mk tmp
/.packageinfo
> tmp
/.packagedeps ||
{ rm -f tmp
/.packagedeps
; false
; }
45 .
/scripts
/package-metadata.pl pkgaux tmp
/.packageinfo
> tmp
/.packageauxvars ||
{ rm -f tmp
/.packageauxvars
; false
; }
46 .
/scripts
/package-metadata.pl usergroup tmp
/.packageinfo
> tmp
/.packageusergroup ||
{ rm -f tmp
/.packageusergroup
; false
; }
47 touch
$(TOPDIR
)/tmp
/.build
49 .config
: .
/scripts
/config
/conf
$(if
$(CONFIG_HAVE_DOT_CONFIG
),,prepare-tmpinfo
)
50 @
+if
[ \
! -e .config
] ||
! grep CONFIG_HAVE_DOT_CONFIG .config
>/dev
/null
; then \
51 [ -e
$(HOME
)/.openwrt
/defconfig
] && cp
$(HOME
)/.openwrt
/defconfig .config
; \
52 $(_SINGLE
)$(NO_TRACE_MAKE
) menuconfig
$(PREP_MK
); \
55 ifeq ($(RECURSIVE_DEP_IS_ERROR
),1)
56 KCONF_FLAGS
=--fatalrecursive
58 ifneq ($(DISTRO_PKG_CONFIG
),)
59 scripts
/config
/%onf
: export PATH
:=$(dir $(DISTRO_PKG_CONFIG
)):$(PATH
)
61 scripts
/config
/%onf
: CFLAGS
+= -O2
63 @
$(_SINGLE
)$(SUBMAKE
) $(if
$(findstring s
,$(OPENWRT_VERBOSE
)),,-s
) \
64 -C scripts
/config
$(notdir $@
) CC
="$(HOSTCC_WRAPPER)"
66 $(eval
$(call rdep
,scripts
/config
,scripts
/config
/mconf
))
68 config
: scripts
/config
/conf prepare-tmpinfo FORCE
69 [ -L .config
] && export KCONFIG_OVERWRITECONFIG
=1; \
70 $< $(KCONF_FLAGS
) Config.in
73 $(_SINGLE
)$(NO_TRACE_MAKE
) -C scripts
/config
clean
75 defconfig
: scripts
/config
/conf prepare-tmpinfo FORCE
77 @if
[ ! -s .config
-a
-e
$(HOME
)/.openwrt
/defconfig
]; then cp
$(HOME
)/.openwrt
/defconfig .config
; fi
78 [ -L .config
] && export KCONFIG_OVERWRITECONFIG
=1; \
79 $< $(KCONF_FLAGS
) --defconfig
=.config Config.in
84 confdefault
:=$(confdefault-
$(CONFDEFAULT
))
86 oldconfig
: scripts
/config
/conf prepare-tmpinfo FORCE
87 [ -L .config
] && export KCONFIG_OVERWRITECONFIG
=1; \
88 $< $(KCONF_FLAGS
) --$(if
$(confdefault
),$(confdefault
),old
)config Config.in
90 menuconfig
: scripts
/config
/mconf prepare-tmpinfo FORCE
91 if
[ \
! -e .config
-a
-e
$(HOME
)/.openwrt
/defconfig
]; then \
92 cp
$(HOME
)/.openwrt
/defconfig .config
; \
94 [ -L .config
] && export KCONFIG_OVERWRITECONFIG
=1; \
97 nconfig
: scripts
/config
/nconf prepare-tmpinfo FORCE
98 if
[ \
! -e .config
-a
-e
$(HOME
)/.openwrt
/defconfig
]; then \
99 cp
$(HOME
)/.openwrt
/defconfig .config
; \
101 [ -L .config
] && export KCONFIG_OVERWRITECONFIG
=1; \
104 xconfig
: scripts
/config
/qconf prepare-tmpinfo FORCE
105 if
[ \
! -e .config
-a
-e
$(HOME
)/.openwrt
/defconfig
]; then \
106 cp
$(HOME
)/.openwrt
/defconfig .config
; \
110 prepare_kernel_conf
: .config toolchain
/install FORCE
112 ifeq ($(wildcard staging_dir
/host
/bin
/quilt
),)
114 @
+$(SUBMAKE
) -r tools
/quilt
/compile
116 prepare_kernel_conf
: ;
119 kernel_oldconfig
: prepare_kernel_conf
120 $(_SINGLE
)$(NO_TRACE_MAKE
) -C target
/linux oldconfig
122 ifneq ($(DISTRO_PKG_CONFIG
),)
123 kernel_menuconfig
: export PATH
:=$(dir $(DISTRO_PKG_CONFIG
)):$(PATH
)
124 kernel_nconfig
: export PATH
:=$(dir $(DISTRO_PKG_CONFIG
)):$(PATH
)
125 kernel_xconfig
: export PATH
:=$(dir $(DISTRO_PKG_CONFIG
)):$(PATH
)
127 kernel_menuconfig
: prepare_kernel_conf
128 $(_SINGLE
)$(NO_TRACE_MAKE
) -C target
/linux menuconfig
130 kernel_nconfig
: prepare_kernel_conf
131 $(_SINGLE
)$(NO_TRACE_MAKE
) -C target
/linux nconfig
133 kernel_xconfig
: prepare_kernel_conf
134 $(_SINGLE
)$(NO_TRACE_MAKE
) -C target
/linux xconfig
136 staging_dir
/host
/.prereq-build
: include/prereq-build.mk
138 @
$(_SINGLE
)$(NO_TRACE_MAKE
) -j1
-r
-s
-f
$(TOPDIR
)/include/prereq-build.mk prereq
2>/dev
/null ||
{ \
139 echo
"Prerequisite check failed. Use FORCE=1 to override."; \
142 ifneq ($(realpath
$(TOPDIR
)/include/prepare.mk
),)
143 @
$(_SINGLE
)$(NO_TRACE_MAKE
) -j1
-r
-s
-f
$(TOPDIR
)/include/prepare.mk prepare
2>/dev
/null ||
{ \
144 echo
"Preparation failed."; \
151 @
$(_SINGLE
)$(NO_TRACE_MAKE
) -p
$@ V
=99 DUMP_TARGET_DB
=1 2>&1
154 DOWNLOAD_DIRS
= tools
/download toolchain
/download package
/download target
/download
156 DOWNLOAD_DIRS
= package
/download
159 download
: .config FORCE
$(if
$(wildcard $(TOPDIR
)/staging_dir
/host
/bin
/flock
),,tools
/flock
/compile
)
160 @
+$(foreach dir,$(DOWNLOAD_DIRS
),$(SUBMAKE
) $(dir);)
162 clean dirclean
: .config
165 prereq
:: prepare-tmpinfo .config
166 @
+$(NO_TRACE_MAKE
) -r
-s
$@
169 @
+$(NO_TRACE_MAKE
) -r
-s
$@ QUIET
= V
=s
172 @
+$(NO_TRACE_MAKE
) -r
-s
$@ QUIET
= V
=s
174 WARN_PARALLEL_ERROR
= $(if
$(BUILD_LOG
),,$(and
$(filter -j
,$(MAKEFLAGS
)),$(findstring s
,$(OPENWRT_VERBOSE
))))
179 @
+$(PREP_MK
) $(NO_TRACE_MAKE
) -r
-s prereq
180 @.
/scripts
/config
/conf
$(KCONF_FLAGS
) --defconfig
=.config Config.in
181 @
+$(ULIMIT_FIX
) $(SUBMAKE
) -r
$@
186 @
+$(PREP_MK
) $(NO_TRACE_MAKE
) -r
-s prereq
188 cp .config tmp
/.config
; \
189 .
/scripts
/config
/conf
$(KCONF_FLAGS
) --defconfig
=tmp
/.config
-w tmp
/.config Config.in
> /dev
/null
2>&1; \
190 if .
/scripts
/kconfig.pl
'>' .config tmp
/.config | grep
-q CONFIG
; then \
191 printf
"$(_R)WARNING: your configuration is out of sync. Please run make menuconfig, oldconfig or defconfig!$(_N)\n" >&2; \
194 @
+$(ULIMIT_FIX
) $(SUBMAKE
) -r
$@
$(if
$(WARN_PARALLEL_ERROR
), ||
{ \
195 printf
"$(_R)Build failed - please re-run with -j1 to see the real error message$(_N)\n" >&2; \
201 # update all feeds, re-create index files, install symlinks
203 .
/scripts
/feeds update
-a
204 .
/scripts
/feeds
install -a
206 # re-create index files, install symlinks
207 package
/symlinks-install
:
208 .
/scripts
/feeds update
-i
209 .
/scripts
/feeds
install -a
211 # remove all symlinks, don't touch ./feeds
212 package
/symlinks-clean
:
213 .
/scripts
/feeds
uninstall -a
218 distclean: cacheclean
219 rm -rf bin build_dir .config
* dl feeds key-build
* logs package
/feeds package
/openwrt-packages staging_dir tmp
220 @
$(_SINGLE
)$(SUBMAKE
) -C scripts
/config
clean
222 ifeq ($(findstring v
,$(DEBUG
)),)
223 .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