run metadata scanning only once when multiple targets are specified on the command...
[openwrt/openwrt.git] / Makefile
1 # Makefile for OpenWrt
2 #
3 # Copyright (C) 2006 OpenWrt.org
4 # Copyright (C) 2006 by Felix Fietkau <openwrt@nbd.name>
5 #
6 # This is free software, licensed under the GNU General Public License v2.
7 # See /LICENSE for more information.
8 #
9
10 RELEASE:=Kamikaze
11 #VERSION:=2.0 # uncomment for final release
12
13 #--------------------------------------------------------------
14 # Just run 'make menuconfig', configure stuff, then run 'make'.
15 # You shouldn't need to mess with anything beyond this point...
16 #--------------------------------------------------------------
17
18 all: world
19
20 SHELL:=/usr/bin/env bash
21 export LC_ALL=C
22 export LANG=C
23 export TOPDIR=${CURDIR}
24 ifeq ($(KBUILD_VERBOSE),99)
25 MAKE:=3>/dev/null $(MAKE)
26 endif
27 export IS_TTY=$(shell tty -s && echo 1 || echo 0)
28
29 include $(TOPDIR)/include/verbose.mk
30
31 OPENWRTVERSION:=$(RELEASE)
32 ifneq ($(VERSION),)
33 OPENWRTVERSION:=$(VERSION) ($(OPENWRTVERSION))
34 else
35 REV:=$(shell LANG=C svn info | awk '/^Revision:/ { print$$2 }' )
36 ifneq ($(REV),)
37 OPENWRTVERSION:=$(OPENWRTVERSION)/r$(REV)
38 endif
39 endif
40 export OPENWRTVERSION
41
42 ifeq ($(FORCE),)
43 .config scripts/config/conf scripts/config/mconf: tmp/.prereq-build
44 world: tmp/.prereq-packages tmp/.prereq-target
45 endif
46
47 tmp/.pkginfo: FORCE
48 @mkdir -p tmp/info
49 @$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="pkginfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPS="$(shell ls include/package*.mk) include/kernel.mk" SCAN_EXTRA=""
50
51 tmp/.targetinfo: FORCE
52 @mkdir -p tmp/info
53 @$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="$(shell ls include/kernel*.mk)" SCAN_EXTRA=""
54
55 tmpinfo-clean: FORCE
56 @-rm -rf tmp/.pkginfo tmp/.targetinfo
57
58 tmp/.config.in: tmp/.pkginfo
59 @./scripts/metadata.pl package_config < $< > $@ || rm -f $@
60
61 tmp/.config-target.in: tmp/.targetinfo
62 @./scripts/metadata.pl target_config < $< > $@ || rm -f $@
63
64 .config: ./scripts/config/conf tmp/.config.in tmp/.config-target.in
65 @[ -f .config ] || $(NO_TRACE_MAKE) menuconfig
66 @$< -D .config Config.in &> /dev/null
67
68 scripts/config/mconf:
69 @$(MAKE) -C scripts/config all
70
71 scripts/config/conf:
72 @$(MAKE) -C scripts/config conf
73
74 config: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
75 $< Config.in
76
77 config-clean: FORCE
78 $(NO_TRACE_MAKE) -C scripts/config clean
79
80 defconfig: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
81 touch .config
82 $< -D .config Config.in
83
84 oldconfig: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
85 $< -o Config.in
86
87 menuconfig: scripts/config/mconf tmp/.config.in tmp/.config-target.in FORCE
88 $< Config.in
89
90 kernel_menuconfig: .config FORCE
91 -$(MAKE) target/linux-prepare
92 $(NO_TRACE_MAKE) -C target/linux menuconfig
93
94 scan_packages:
95 @$(NO_TRACE_MAKE) -s tmp/.pkginfo tmp/.targetinfo
96
97
98 package/%: scan_packages
99 $(MAKE) -C package $(patsubst package/%,%,$@)
100
101 target/%: scan_packages
102 @$(NO_TRACE_MAKE) -s tmp/.pkginfo tmp/.targetinfo
103 $(MAKE) -C target $(patsubst target/%,%,$@)
104
105 tools/%: FORCE
106 $(MAKE) -C tools $(patsubst tools/%,%,$@)
107
108 toolchain/%: tmp/.targetinfo FORCE
109 $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
110
111 tmp/.prereq-build: include/prereq-build.mk
112 @mkdir -p tmp
113 @rm -f tmp/.host.mk
114 @$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
115 echo "Prerequisite check failed. Use FORCE=1 to override."; \
116 false; \
117 }
118 @touch $@
119
120 tmp/.prereq-packages: include/prereq.mk tmp/.pkginfo .config
121 @mkdir -p tmp
122 @rm -f tmp/.host.mk
123 @$(NO_TRACE_MAKE) -s -C package prereq 2>/dev/null || { \
124 echo "Prerequisite check failed. Use FORCE=1 to override."; \
125 false; \
126 }
127 @touch $@
128
129 tmp/.prereq-target: include/prereq.mk tmp/.targetinfo .config
130 @mkdir -p tmp
131 @rm -f tmp/.host.mk
132 @$(NO_TRACE_MAKE) -s -C target prereq 2>/dev/null || { \
133 echo "Prerequisite check failed. Use FORCE=1 to override."; \
134 false; \
135 }
136 @touch $@
137
138 prereq: tmp/.prereq-build tmp/.prereq-packages tmp/.prereq-target FORCE
139
140 download: .config FORCE
141 $(MAKE) tools/download
142 $(MAKE) toolchain/download
143 $(MAKE) package/download
144 $(MAKE) target/download
145
146 world: .config FORCE
147 $(MAKE) tools/install
148 $(MAKE) toolchain/install
149 $(MAKE) target/compile
150 $(MAKE) package/compile
151 $(MAKE) package/install
152 $(MAKE) target/install
153 $(MAKE) package/index
154
155 clean: FORCE
156 rm -rf build_* bin tmp
157
158 dirclean: clean
159 rm -rf staging_dir_* toolchain_build_* tool_build
160
161 distclean: dirclean config-clean symlinkclean docclean
162 rm -rf dl
163
164 help:
165 cat README
166
167 doc:
168 $(MAKE) -C docs/ openwrt.pdf
169
170 docclean:
171 $(MAKE) -C docs/ clean
172
173 symlinkclean:
174 find package -type l | xargs rm -f
175
176 .SILENT: clean dirclean distclean symlinkclean config-clean download world
177 FORCE: ;
178 .PHONY: FORCE help
179 %: ;