make sure tmp/info gets created
[librecmc/librecmc.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 package/%: 
95         @$(NO_TRACE_MAKE) -s tmp/.pkginfo tmp/.targetinfo
96         $(MAKE) -C package $(patsubst package/%,%,$@)
97
98 target/%:
99         @$(NO_TRACE_MAKE) -s tmp/.pkginfo tmp/.targetinfo
100         $(MAKE) -C target $(patsubst target/%,%,$@)
101
102 tools/%: FORCE
103         $(MAKE) -C tools $(patsubst tools/%,%,$@)
104
105 toolchain/%: tmp/.targetinfo FORCE
106         $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
107
108 tmp/.prereq-build: include/prereq-build.mk
109         @mkdir -p tmp
110         @rm -f tmp/.host.mk
111         @$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
112                 echo "Prerequisite check failed. Use FORCE=1 to override."; \
113                 false; \
114         }
115         @touch $@
116
117 tmp/.prereq-packages: include/prereq.mk tmp/.pkginfo .config
118         @mkdir -p tmp
119         @rm -f tmp/.host.mk
120         @$(NO_TRACE_MAKE) -s -C package prereq 2>/dev/null || { \
121                 echo "Prerequisite check failed. Use FORCE=1 to override."; \
122                 false; \
123         }
124         @touch $@
125
126 tmp/.prereq-target: include/prereq.mk tmp/.targetinfo .config
127         @mkdir -p tmp
128         @rm -f tmp/.host.mk
129         @$(NO_TRACE_MAKE) -s -C target prereq 2>/dev/null || { \
130                 echo "Prerequisite check failed. Use FORCE=1 to override."; \
131                 false; \
132         }
133         @touch $@
134
135 prereq: tmp/.prereq-build tmp/.prereq-packages tmp/.prereq-target FORCE
136
137 download: .config FORCE
138         $(MAKE) tools/download
139         $(MAKE) toolchain/download
140         $(MAKE) package/download
141         $(MAKE) target/download
142
143 world: .config FORCE
144         $(MAKE) tools/install
145         $(MAKE) toolchain/install
146         $(MAKE) target/compile
147         $(MAKE) package/compile
148         $(MAKE) package/install
149         $(MAKE) target/install
150         $(MAKE) package/index
151
152 clean: FORCE
153         rm -rf build_* bin tmp
154
155 dirclean: clean
156         rm -rf staging_dir_* toolchain_build_* tool_build
157
158 distclean: dirclean config-clean symlinkclean docclean
159         rm -rf dl
160
161 help:
162         cat README
163
164 doc:
165         $(MAKE) -C docs/ openwrt.pdf
166
167 docclean:
168         $(MAKE) -C docs/ clean
169
170 symlinkclean:
171         find package -type l | xargs rm -f
172
173 .SILENT: clean dirclean distclean symlinkclean config-clean download world
174 FORCE: ;
175 .PHONY: FORCE help
176 %: ;