more build system cleanup
[openwrt/openwrt.git] / include / toplevel.mk
1 # Makefile for OpenWrt
2 #
3 # Copyright (C) 2007 OpenWrt.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 RELEASE:=Kamikaze
10 #VERSION:=2.0 # uncomment for final release
11
12 all: world
13
14 SHELL:=/usr/bin/env bash
15 OPENWRTVERSION:=$(RELEASE)
16 ifneq ($(VERSION),)
17 OPENWRTVERSION:=$(VERSION) ($(OPENWRTVERSION))
18 else
19 REV:=$(shell LANG=C svn info | awk '/^Revision:/ { print$$2 }' )
20 ifneq ($(REV),)
21 OPENWRTVERSION:=$(OPENWRTVERSION)/r$(REV)
22 endif
23 endif
24 export OPENWRTVERSION
25
26 ifeq ($(FORCE),)
27 .config scripts/config/conf scripts/config/mconf: tmp/.prereq-build
28 world: prereq
29 endif
30
31 SCAN_COOKIE?=$(shell echo $$$$)
32 export SCAN_COOKIE
33
34 tmp/.packageinfo tmp/.targetinfo prepare-tmpinfo:
35 @mkdir -p tmp/info
36 @$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPS="$(TOPDIR)/include/package*.mk" SCAN_DEPTH=4 SCAN_EXTRA=""
37 @$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="profiles/*.mk $(TOPDIR)/include/kernel*.mk" SCAN_DEPTH=2 SCAN_EXTRA=""
38 @for type in package target; do \
39 f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
40 [ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config < "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
41 done
42
43 .config: ./scripts/config/conf prepare-tmpinfo
44 if [ \! -f .config ]; then \
45 [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
46 $(NO_TRACE_MAKE) menuconfig; \
47 fi
48 $< -D .config Config.in &> /dev/null
49
50 scripts/config/mconf:
51 $(MAKE) -C scripts/config all
52
53 scripts/config/conf:
54 $(MAKE) -C scripts/config conf
55
56 config: scripts/config/conf prepare-tmpinfo FORCE
57 $< Config.in
58
59 config-clean: FORCE
60 $(NO_TRACE_MAKE) -C scripts/config clean
61
62 defconfig: scripts/config/conf prepare-tmpinfo FORCE
63 touch .config
64 $< -D .config Config.in
65
66 oldconfig: scripts/config/conf prepare-tmpinfo FORCE
67 $< -o Config.in
68
69 menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
70 if [ \! -f .config -a -e $(HOME)/.openwrt/defconfig ]; then \
71 cp $(HOME)/.openwrt/defconfig .config; \
72 fi
73 $< Config.in
74
75 kernel_oldconfig: .config FORCE
76 $(NO_TRACE_MAKE) -C target/linux oldconfig
77
78 kernel_menuconfig: .config FORCE
79 $(NO_TRACE_MAKE) -C target/linux menuconfig
80
81 tmp/.prereq-build: include/prereq-build.mk
82 mkdir -p tmp
83 rm -f tmp/.host.mk
84 $(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
85 echo "Prerequisite check failed. Use FORCE=1 to override."; \
86 false; \
87 }
88 touch $@
89
90 tmp/.prereq-package: tmp/.packageinfo
91 tmp/.prereq-target: tmp/.targetinfo .config
92 tmp/.prereq-package tmp/.prereq-target: include/prereq.mk
93 mkdir -p tmp
94 rm -f tmp/.host.mk
95 $(NO_TRACE_MAKE) -s -C $(patsubst tmp/.prereq-%,%,$@) prereq 2>/dev/null || { \
96 echo "Prerequisite check failed. Use FORCE=1 to override."; \
97 false; \
98 }
99 touch $@
100
101 prereq: tmp/.prereq-build tmp/.prereq-package tmp/.prereq-target .config FORCE ;
102
103 download: .config FORCE
104 $(MAKE) -j1 tools/download
105 $(MAKE) -j1 toolchain/download
106 $(MAKE) -j1 package/download
107 $(MAKE) -j1 target/download
108
109 clean dirclean distclean:
110 @$(MAKE) $@
111
112 %::
113 @$(SUBMAKE) -s prereq QUIET=0 OPENWRT_BUILD=
114 @$(MAKE) $@
115
116 help:
117 cat README
118
119 docs docs/compile: FORCE
120 $(MAKE) -C docs compile
121
122 docs/clean: FORCE
123 $(MAKE) -C docs clean
124
125 symlinkclean:
126 -find package -type l | xargs rm -f
127 rm -rf tmp
128
129 .SILENT: symlinkclean clean dirclean distclean config-clean download help tmpinfo-clean .config scripts/config/mconf scripts/config/conf menuconfig tmp/.prereq-build tmp/.prereq-package tmp/.prereq-target
130 .PHONY: help FORCE
131 .NOTPARALLEL:
132