1 | # Makefile for OpenWrt |
2 | # |
3 | # Copyright (C) 2007 OpenWrt.org |
4 | # |
5 | # This is free software, licensed under the GNU General Public License v2. |
6 | # See /LICENSE for more information. |
7 | # |
8 | |
9 | RELEASE:=Backfire |
10 | SHELL:=/usr/bin/env bash |
11 | PREP_MK= OPENWRT_BUILD= QUIET=0 |
12 | |
13 | include $(TOPDIR)/include/verbose.mk |
14 | |
15 | ifeq ($(SDK),1) |
16 | include $(TOPDIR)/include/version.mk |
17 | else |
18 | REVISION:=$(shell $(TOPDIR)/scripts/getver.sh) |
19 | endif |
20 | |
21 | OPENWRTVERSION:=$(RELEASE)$(if $(REVISION), ($(REVISION))) |
22 | export RELEASE |
23 | export REVISION |
24 | export OPENWRTVERSION |
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 |
28 | |
29 | # prevent perforce from messing with the patch utility |
30 | unexport P4PORT P4USER P4CONFIG P4CLIENT |
31 | |
32 | # prevent user defaults for quilt from interfering |
33 | unexport QUILT_PATCHES QUILT_PATCH_OPTS |
34 | |
35 | # make sure that a predefined CFLAGS variable does not disturb packages |
36 | export CFLAGS= |
37 | |
38 | ifeq ($(FORCE),) |
39 | .config scripts/config/conf scripts/config/mconf: tmp/.prereq-build |
40 | endif |
41 | |
42 | SCAN_COOKIE?=$(shell echo $$$$) |
43 | export SCAN_COOKIE |
44 | |
45 | SUBMAKE:=umask 022; $(SUBMAKE) |
46 | |
47 | prepare-mk: FORCE ; |
48 | |
49 | prepare-tmpinfo: FORCE |
50 | mkdir -p tmp/info |
51 | $(_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="" |
52 | $(_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" |
53 | for type in package target; do \ |
54 | f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \ |
55 | [ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \ |
56 | done |
57 | ./scripts/metadata.pl package_mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; } |
58 | touch $(TOPDIR)/tmp/.build |
59 | |
60 | .config: ./scripts/config/conf $(if $(CONFIG_HAVE_DOT_CONFIG),,prepare-tmpinfo) |
61 | @+if [ \! -e .config ] || ! grep CONFIG_HAVE_DOT_CONFIG .config >/dev/null; then \ |
62 | [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \ |
63 | $(_SINGLE)$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \ |
64 | fi |
65 | |
66 | scripts/config/mconf: |
67 | @$(_SINGLE)$(SUBMAKE) -s -C scripts/config all |
68 | |
69 | $(eval $(call rdep,scripts/config,scripts/config/mconf)) |
70 | |
71 | scripts/config/conf: |
72 | @$(_SINGLE)$(SUBMAKE) -s -C scripts/config conf |
73 | |
74 | config: scripts/config/conf prepare-tmpinfo FORCE |
75 | $< Config.in |
76 | |
77 | config-clean: FORCE |
78 | $(_SINGLE)$(NO_TRACE_MAKE) -C scripts/config clean |
79 | |
80 | defconfig: scripts/config/conf prepare-tmpinfo FORCE |
81 | touch .config |
82 | $< -D .config Config.in |
83 | |
84 | oldconfig: scripts/config/conf prepare-tmpinfo FORCE |
85 | $< -$(if $(CONFDEFAULT),$(CONFDEFAULT),o) Config.in |
86 | |
87 | menuconfig: scripts/config/mconf prepare-tmpinfo FORCE |
88 | if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \ |
89 | cp $(HOME)/.openwrt/defconfig .config; \ |
90 | fi |
91 | $< Config.in |
92 | |
93 | prepare_kernel_conf: .config FORCE |
94 | |
95 | ifeq ($(wildcard staging_dir/host/bin/sed),) |
96 | prepare_kernel_conf: |
97 | @+$(SUBMAKE) -r tools/sed/install |
98 | else |
99 | prepare_kernel_conf: ; |
100 | endif |
101 | |
102 | kernel_oldconfig: prepare_kernel_conf |
103 | $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux oldconfig |
104 | |
105 | kernel_menuconfig: prepare_kernel_conf |
106 | $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux menuconfig |
107 | |
108 | tmp/.prereq-build: include/prereq-build.mk |
109 | mkdir -p tmp |
110 | rm -f tmp/.host.mk |
111 | @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \ |
112 | echo "Prerequisite check failed. Use FORCE=1 to override."; \ |
113 | false; \ |
114 | } |
115 | touch $@ |
116 | |
117 | download: .config FORCE |
118 | @+$(SUBMAKE) tools/download |
119 | @+$(SUBMAKE) toolchain/download |
120 | @+$(SUBMAKE) package/download |
121 | @+$(SUBMAKE) target/download |
122 | |
123 | clean dirclean: .config |
124 | @+$(SUBMAKE) -r $@ |
125 | |
126 | prereq:: prepare-tmpinfo .config |
127 | @+$(MAKE) -r -s tmp/.prereq-build $(PREP_MK) |
128 | @+$(NO_TRACE_MAKE) -r -s $@ |
129 | |
130 | %:: |
131 | @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq |
132 | @+$(SUBMAKE) -r $@ |
133 | |
134 | help: |
135 | cat README |
136 | |
137 | docs docs/compile: FORCE |
138 | @$(_SINGLE)$(SUBMAKE) -C docs compile |
139 | |
140 | docs/clean: FORCE |
141 | @$(_SINGLE)$(SUBMAKE) -C docs clean |
142 | |
143 | distclean: |
144 | rm -rf tmp build_dir staging_dir dl .config* feeds package/feeds package/openwrt-packages bin |
145 | @$(_SINGLE)$(SUBMAKE) -C scripts/config clean |
146 | |
147 | ifeq ($(findstring v,$(DEBUG)),) |
148 | .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 |
149 | endif |
150 | .PHONY: help FORCE |
151 | .NOTPARALLEL: |
152 | |
153 | |