3 # Copyright (C) 2007 OpenWrt.org
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
10 SHELL
:=/usr
/bin
/env bash
11 PREP_MK
= OPENWRT_BUILD
= QUIET
=0
13 include $(TOPDIR
)/include/verbose.mk
16 include $(TOPDIR
)/include/version.mk
18 REVISION
:=$(shell $(TOPDIR
)/scripts
/getver.sh
)
21 OPENWRTVERSION
:=$(RELEASE
)$(if
$(REVISION
), ($(REVISION
)))
25 export IS_TTY
=$(shell tty
-s
&& echo
1 || echo
0)
26 export LD_LIBRARY_PATH
:=$(if
$(LD_LIBRARY_PATH
),$(LD_LIBRARY_PATH
):)$(STAGING_DIR_HOST
)/lib
27 export DYLD_LIBRARY_PATH
:=$(if
$(DYLD_LIBRARY_PATH
),$(DYLD_LIBRARY_PATH
):)$(STAGING_DIR_HOST
)/lib
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 # make sure that a predefined CFLAGS variable does not disturb packages
39 .config scripts
/config
/conf scripts
/config
/mconf
: tmp
/.prereq-build
42 SCAN_COOKIE?
=$(shell echo
$$$$)
47 prepare-tmpinfo
: FORCE
49 $(_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
=""
50 $(_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"
51 for type in package target
; do \
52 f
=tmp
/.
$${type}info; t
=tmp
/.config-
$${type}.in
; \
53 [ "$$t" -nt
"$$f" ] || .
/scripts
/metadata.pl
$${type}_config
"$$f" > "$$t" ||
{ rm -f
"$$t"; echo
"Failed to build $$t"; false
; break
; }; \
55 .
/scripts
/metadata.pl package_mk tmp
/.packageinfo
> tmp
/.packagedeps ||
{ rm -f tmp
/.packagedeps
; false
; }
56 touch
$(TOPDIR
)/tmp
/.build
58 .config
: .
/scripts
/config
/conf
$(if
$(CONFIG_HAVE_DOT_CONFIG
),,prepare-tmpinfo
)
59 @
+if
[ \
! -e .config
] ||
! grep CONFIG_HAVE_DOT_CONFIG .config
>/dev
/null
; then \
60 [ -e
$(HOME
)/.openwrt
/defconfig
] && cp
$(HOME
)/.openwrt
/defconfig .config
; \
61 $(_SINGLE
)$(NO_TRACE_MAKE
) menuconfig
$(PREP_MK
); \
65 @
$(_SINGLE
)$(SUBMAKE
) -s
-C scripts
/config
all
67 $(eval
$(call rdep
,scripts
/config
,scripts
/config
/mconf
))
70 @
$(_SINGLE
)$(SUBMAKE
) -s
-C scripts
/config conf
72 config
: scripts
/config
/conf prepare-tmpinfo FORCE
76 $(_SINGLE
)$(NO_TRACE_MAKE
) -C scripts
/config
clean
78 defconfig
: scripts
/config
/conf prepare-tmpinfo FORCE
80 $< -D .config Config.in
82 oldconfig
: scripts
/config
/conf prepare-tmpinfo FORCE
83 $< -$(if
$(CONFDEFAULT
),$(CONFDEFAULT
),o
) Config.in
85 menuconfig
: scripts
/config
/mconf prepare-tmpinfo FORCE
86 if
[ \
! -e .config
-a
-e
$(HOME
)/.openwrt
/defconfig
]; then \
87 cp
$(HOME
)/.openwrt
/defconfig .config
; \
91 prepare_kernel_conf
: .config FORCE
93 ifeq ($(wildcard staging_dir
/host
/bin
/sed
),)
95 @
+$(SUBMAKE
) -r tools
/sed
/install
97 prepare_kernel_conf
: ;
100 kernel_oldconfig
: prepare_kernel_conf
101 $(_SINGLE
)$(NO_TRACE_MAKE
) -C target
/linux oldconfig
103 kernel_menuconfig
: prepare_kernel_conf
104 $(_SINGLE
)$(NO_TRACE_MAKE
) -C target
/linux menuconfig
106 tmp
/.prereq-build
: include/prereq-build.mk
109 @
$(_SINGLE
)$(NO_TRACE_MAKE
) -j1
-r
-s
-f
$(TOPDIR
)/include/prereq-build.mk prereq
2>/dev
/null ||
{ \
110 echo
"Prerequisite check failed. Use FORCE=1 to override."; \
115 download
: .config FORCE
116 @
+$(SUBMAKE
) tools
/download
117 @
+$(SUBMAKE
) toolchain
/download
118 @
+$(SUBMAKE
) package
/download
119 @
+$(SUBMAKE
) target
/download
121 clean dirclean
: .config
124 prereq
:: prepare-tmpinfo .config
125 @
+$(MAKE
) -r
-s tmp
/.prereq-build
$(PREP_MK
)
126 @
+$(NO_TRACE_MAKE
) -r
-s
$@
129 @
+$(PREP_MK
) $(NO_TRACE_MAKE
) -r
-s prereq
135 docs docs
/compile
: FORCE
136 @
$(_SINGLE
)$(SUBMAKE
) -C docs compile
139 @
$(_SINGLE
)$(SUBMAKE
) -C docs
clean
142 rm -rf tmp build_dir staging_dir dl .config
* feeds package
/feeds package
/openwrt-packages bin
143 @
$(_SINGLE
)$(SUBMAKE
) -C scripts
/config
clean
145 ifeq ($(findstring v
,$(DEBUG
)),)
146 .SILENT
: symlinkclean
clean dirclean
distclean config-clean download help tmpinfo-clean .config scripts
/config
/mconf scripts
/config
/conf menuconfig tmp
/.prereq-build tmp
/.prereq-package prepare-tmpinfo