bcbfd561b9804632b9e480dd91ec4b6f3d017397
[openwrt-10.03/.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         @$(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=""
49
50 tmp/.targetinfo: FORCE
51         @$(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=""
52
53 tmpinfo-clean: FORCE
54         @-rm -rf tmp/.pkginfo tmp/.targetinfo
55
56 tmp/.config.in: tmp/.pkginfo
57         @./scripts/metadata.pl package_config < $< > $@ || rm -f $@
58
59 tmp/.config-target.in: tmp/.targetinfo
60         @./scripts/metadata.pl target_config < $< > $@ || rm -f $@
61
62 .config: ./scripts/config/conf tmp/.config.in tmp/.config-target.in
63         @[ -f .config ] || $(NO_TRACE_MAKE) menuconfig
64         @$< -D .config Config.in &> /dev/null
65
66 scripts/config/mconf:
67         @$(MAKE) -C scripts/config all
68
69 scripts/config/conf:
70         @$(MAKE) -C scripts/config conf
71
72 config: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
73         $< Config.in
74
75 config-clean: FORCE
76         $(NO_TRACE_MAKE) -C scripts/config clean
77
78 defconfig: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
79         touch .config
80         $< -D .config Config.in
81
82 oldconfig: scripts/config/conf tmp/.config.in tmp/.config-target.in FORCE
83         $< -o Config.in
84
85 menuconfig: scripts/config/mconf tmp/.config.in tmp/.config-target.in FORCE
86         $< Config.in
87
88 kernel_menuconfig: .config FORCE
89         -$(MAKE) target/linux-prepare
90         $(NO_TRACE_MAKE) -C target/linux menuconfig
91
92 package/%: 
93         @$(NO_TRACE_MAKE) -s tmp/.pkginfo tmp/.targetinfo
94         $(MAKE) -C package $(patsubst package/%,%,$@)
95
96 target/%:
97         @$(NO_TRACE_MAKE) -s tmp/.pkginfo tmp/.targetinfo
98         $(MAKE) -C target $(patsubst target/%,%,$@)
99
100 tools/%: FORCE
101         $(MAKE) -C tools $(patsubst tools/%,%,$@)
102
103 toolchain/%: tmp/.targetinfo FORCE
104         $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
105
106 tmp/.prereq-build: include/prereq-build.mk
107         @mkdir -p tmp
108         @rm -f tmp/.host.mk
109         @$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
110                 echo "Prerequisite check failed. Use FORCE=1 to override."; \
111                 false; \
112         }
113         @touch $@
114
115 tmp/.prereq-packages: include/prereq.mk tmp/.pkginfo .config
116         @mkdir -p tmp
117         @rm -f tmp/.host.mk
118         @$(NO_TRACE_MAKE) -s -C package prereq 2>/dev/null || { \
119                 echo "Prerequisite check failed. Use FORCE=1 to override."; \
120                 false; \
121         }
122         @touch $@
123
124 tmp/.prereq-target: include/prereq.mk tmp/.targetinfo .config
125         @mkdir -p tmp
126         @rm -f tmp/.host.mk
127         @$(NO_TRACE_MAKE) -s -C target prereq 2>/dev/null || { \
128                 echo "Prerequisite check failed. Use FORCE=1 to override."; \
129                 false; \
130         }
131         @touch $@
132
133 prereq: tmp/.prereq-build tmp/.prereq-packages tmp/.prereq-target FORCE
134
135 download: .config FORCE
136         $(MAKE) tools/download
137         $(MAKE) toolchain/download
138         $(MAKE) package/download
139         $(MAKE) target/download
140
141 world: .config FORCE
142         $(MAKE) tools/install
143         $(MAKE) toolchain/install
144         $(MAKE) target/compile
145         $(MAKE) package/compile
146         $(MAKE) package/install
147         $(MAKE) target/install
148         $(MAKE) package/index
149
150 clean: FORCE
151         rm -rf build_* bin tmp
152
153 dirclean: clean
154         rm -rf staging_dir_* toolchain_build_* tool_build
155
156 distclean: dirclean config-clean symlinkclean docclean
157         rm -rf dl
158
159 help:
160         cat README
161
162 doc:
163         $(MAKE) -C docs/ openwrt.pdf
164
165 docclean:
166         $(MAKE) -C docs/ clean
167
168 symlinkclean:
169         find package -type l | xargs rm -f
170
171 .SILENT: clean dirclean distclean symlinkclean config-clean download world
172 FORCE: ;
173 .PHONY: FORCE help
174 %: ;