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