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