05839832d2e8a6931abf7eae47fcb9ba2e7fff8d
[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 include $(TOPDIR)/include/verbose.mk
17 ifneq ($(VERSION),)
18   OPENWRTVERSION:=$(VERSION) ($(OPENWRTVERSION))
19 else
20   REV:=$(shell LANG=C svn info | awk '/^Revision:/ { print$$2 }' )
21   ifneq ($(REV),)
22     OPENWRTVERSION:=$(OPENWRTVERSION)/r$(REV)
23   endif
24 endif
25 export OPENWRTVERSION
26
27 ifeq ($(FORCE),)
28   .config scripts/config/conf scripts/config/mconf: tmp/.prereq-build
29   world: prereq
30 endif
31
32 SCAN_COOKIE?=$(shell echo $$$$)
33 export SCAN_COOKIE
34
35 tmp/.packageinfo tmp/.targetinfo prepare-tmpinfo:
36         @mkdir -p tmp/info
37         @+$(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=""
38         @+$(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=""
39         @for type in package target; do \
40                 f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
41                 [ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config < "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
42         done
43
44 .config: ./scripts/config/conf prepare-tmpinfo
45         @+if [ \! -f .config ]; then \
46                 [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
47                 $(NO_TRACE_MAKE) menuconfig QUIET=0 OPENWRT_BUILD=; \
48         fi
49         $< -D .config Config.in &> /dev/null
50
51 scripts/config/mconf:
52         @+$(MAKE) -C scripts/config all
53
54 scripts/config/conf:
55         @+$(MAKE) -C scripts/config conf
56
57 config: scripts/config/conf prepare-tmpinfo FORCE
58         $< Config.in
59
60 config-clean: FORCE
61         $(NO_TRACE_MAKE) -C scripts/config clean
62
63 defconfig: scripts/config/conf prepare-tmpinfo FORCE
64         touch .config
65         $< -D .config Config.in
66
67 oldconfig: scripts/config/conf prepare-tmpinfo FORCE
68         $< -o Config.in
69
70 menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
71         if [ \! -f .config -a -e $(HOME)/.openwrt/defconfig ]; then \
72                 cp $(HOME)/.openwrt/defconfig .config; \
73         fi
74         $< Config.in
75
76 kernel_oldconfig: .config FORCE
77         $(NO_TRACE_MAKE) -C target/linux oldconfig
78
79 kernel_menuconfig: .config FORCE
80         $(NO_TRACE_MAKE) -C target/linux menuconfig
81
82 tmp/.prereq-build: include/prereq-build.mk
83         mkdir -p tmp
84         rm -f tmp/.host.mk
85         @+$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
86                 echo "Prerequisite check failed. Use FORCE=1 to override."; \
87                 false; \
88         }
89         touch $@
90
91 tmp/.prereq-package: tmp/.packageinfo .config
92 tmp/.prereq-target: tmp/.targetinfo .config
93 tmp/.prereq-package tmp/.prereq-target: include/prereq.mk 
94         mkdir -p tmp
95         rm -f tmp/.host.mk
96         @+$(NO_TRACE_MAKE) -s -C $(patsubst tmp/.prereq-%,%,$@) prereq 2>/dev/null || { \
97                 echo "Prerequisite check failed. Use FORCE=1 to override."; \
98                 false; \
99         }
100         touch $@
101
102 prereq: tmp/.prereq-build tmp/.prereq-package tmp/.prereq-target .config FORCE
103         @true
104
105 download: .config FORCE
106         $(MAKE) -j1 tools/download
107         $(MAKE) -j1 toolchain/download
108         $(MAKE) -j1 package/download
109         $(MAKE) -j1 target/download
110
111 clean dirclean distclean:
112         @$(MAKE) $@ 
113
114 %::
115         @$(SUBMAKE) -s prereq QUIET=0 OPENWRT_BUILD=
116         @+$(MAKE) $@ 
117
118 help:
119         cat README
120
121 docs docs/compile: FORCE
122         $(MAKE) -C docs compile
123
124 docs/clean: FORCE
125         $(MAKE) -C docs clean
126
127 symlinkclean:
128         -find package -type l | xargs rm -f
129         rm -rf tmp
130
131 .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
132 .PHONY: help FORCE
133 .NOTPARALLEL:
134