rename uci-update.awk to uci.awk and add a few config_* functions
[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 define stamp
48 tmp/info/.stamp-$(1)-$(shell ls $(2)/*/Makefile $(5) | (md5sum || md5) 2>/dev/null | cut -d' ' -f1)
49 endef
50
51 STAMP_pkginfo=$(call stamp,pkginfo,package)
52 STAMP_targetinfo=$(call stamp,targetinfo,target/linux)
53 define scan_info
54
55 $(STAMP_$(1)):
56 @mkdir -p tmp/info
57 @rm -f tmp/info/.stamp-$(1)*
58 @touch $$@
59
60 $(foreach FILE,$(shell ls $(2)/*/Makefile $(5)),
61 tmp/.$(1): $(FILE)
62 $(FILE):
63 )
64
65 ifneq ($(5),)
66 tmp/.$(1): $(shell ls $(5))
67 endif
68
69 tmp/.$(1): $(STAMP_$(1)) $(4)
70 @echo -n Collecting $(3) info...
71 @$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="$(1)" SCAN_DIR="$(2)" SCAN_NAME="$(3)" SCAN_DEPS="$(4)" SCAN_EXTRA="$(5)"
72
73 endef
74
75 $(eval $(call scan_info,pkginfo,package,package,include/package.mk))
76 $(eval $(call scan_info,targetinfo,target/linux,target,include/kernel-build.mk include/kernel-version.mk,target/linux/*/profiles/*.mk))
77
78 tmpinfo-clean: FORCE
79 @-rm -rf tmp/.pkginfo tmp/.targetinfo
80
81 tmp/.config.in: tmp/.pkginfo
82 @./scripts/metadata.pl package_config < $< > $@ || rm -f $@
83
84 tmp/.config-target.in: tmp/.targetinfo
85 @./scripts/metadata.pl target_config < $< > $@ || rm -f $@
86
87 .config: ./scripts/config/conf tmp/.config.in tmp/.config-target.in
88 @[ -f .config ] || $(NO_TRACE_MAKE) menuconfig
89 @$< -D .config Config.in &> /dev/null
90
91 scripts/config/mconf:
92 @$(MAKE) -C scripts/config all
93
94 scripts/config/conf:
95 @$(MAKE) -C scripts/config conf
96
97 config: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
98 $< Config.in
99
100 config-clean: FORCE
101 $(NO_TRACE_MAKE) -C scripts/config clean
102
103 defconfig: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
104 touch .config
105 $< -D .config Config.in
106
107 oldconfig: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
108 $< -o Config.in
109
110 menuconfig: scripts/config/mconf tmp/.config.in tmp/.config-target.in FORCE
111 $< Config.in
112
113 kernel_menuconfig: .config FORCE
114 -$(MAKE) target/linux-prepare
115 $(NO_TRACE_MAKE) -C target/linux menuconfig
116
117 package/%:
118 @$(NO_TRACE_MAKE) -s tmp/.pkginfo tmp/.targetinfo
119 $(MAKE) -C package $(patsubst package/%,%,$@)
120
121 target/%:
122 @$(NO_TRACE_MAKE) -s tmp/.pkginfo tmp/.targetinfo
123 $(MAKE) -C target $(patsubst target/%,%,$@)
124
125 tools/%: FORCE
126 $(MAKE) -C tools $(patsubst tools/%,%,$@)
127
128 toolchain/%: tmp/.targetinfo FORCE
129 $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
130
131 tmp/.prereq-build: include/prereq-build.mk
132 @mkdir -p tmp
133 @rm -f tmp/.host.mk
134 @$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
135 echo "Prerequisite check failed. Use FORCE=1 to override."; \
136 false; \
137 }
138 @touch $@
139
140 tmp/.prereq-packages: include/prereq.mk tmp/.pkginfo .config
141 @mkdir -p tmp
142 @rm -f tmp/.host.mk
143 @$(NO_TRACE_MAKE) -s -C package prereq 2>/dev/null || { \
144 echo "Prerequisite check failed. Use FORCE=1 to override."; \
145 false; \
146 }
147 @touch $@
148
149 tmp/.prereq-target: include/prereq.mk tmp/.targetinfo .config
150 @mkdir -p tmp
151 @rm -f tmp/.host.mk
152 @$(NO_TRACE_MAKE) -s -C target prereq 2>/dev/null || { \
153 echo "Prerequisite check failed. Use FORCE=1 to override."; \
154 false; \
155 }
156 @touch $@
157
158 prereq: tmp/.prereq-build tmp/.prereq-packages tmp/.prereq-target FORCE
159
160 download: .config FORCE
161 $(MAKE) tools/download
162 $(MAKE) toolchain/download
163 $(MAKE) package/download
164 $(MAKE) target/download
165
166 world: .config FORCE
167 $(MAKE) tools/install
168 $(MAKE) toolchain/install
169 $(MAKE) target/compile
170 $(MAKE) package/compile
171 $(MAKE) package/install
172 $(MAKE) target/install
173 $(MAKE) package/index
174
175 clean: FORCE
176 rm -rf build_* bin tmp
177
178 dirclean: clean
179 rm -rf staging_dir_* toolchain_build_* tool_build
180
181 distclean: dirclean config-clean
182 rm -rf dl
183
184 help:
185 cat README
186
187 doc:
188 $(MAKE) -C docs/ openwrt.pdf
189
190 docclean:
191 $(MAKE) -C docs/ clean
192
193 .SILENT: clean dirclean distclean config-clean download world
194 FORCE: ;
195 .PHONY: FORCE help
196 %: ;
This page took 0.048755 seconds and 5 git commands to generate.