c92686019dc691694f28c76eda004b60d03a7e4d
[openwrt/svn-archive/archive.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 SHELL:=/usr/bin/env bash
13 OPENWRTVERSION:=$(RELEASE)
14 PREP_MK= OPENWRT_BUILD= QUIET=0
15 include $(TOPDIR)/include/verbose.mk
16 ifneq ($(VERSION),)
17 OPENWRTVERSION:=$(VERSION) ($(OPENWRTVERSION))
18 else
19 REV:=$(if $(wildcard .svn/entries),$(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 endif
29
30 SCAN_COOKIE?=$(shell echo $$$$)
31 export SCAN_COOKIE
32
33 prepare-mk: FORCE ;
34
35 prepare-tmpinfo: FORCE
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="" SCAN_MAKEOPTS="TARGET_BUILD=1"
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 ./scripts/metadata.pl package_mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
44 touch $(TOPDIR)/tmp/.build
45
46 .config: ./scripts/config/conf prepare-tmpinfo
47 @+if [ \! -f .config ]; then \
48 [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
49 $(NO_TRACE_MAKE) menuconfig $(PREP_MK); \
50 fi
51
52 scripts/config/mconf:
53 @+$(MAKE) -C scripts/config all
54
55 $(eval $(call rdep,scripts/config,scripts/config/mconf))
56
57 scripts/config/conf:
58 @+$(MAKE) -C scripts/config conf
59
60 config: scripts/config/conf prepare-tmpinfo FORCE
61 $< Config.in
62
63 config-clean: FORCE
64 $(NO_TRACE_MAKE) -C scripts/config clean
65
66 defconfig: scripts/config/conf prepare-tmpinfo FORCE
67 touch .config
68 $< -D .config Config.in
69
70 oldconfig: scripts/config/conf prepare-tmpinfo FORCE
71 $< -$(if $(CONFDEFAULT),$(CONFDEFAULT),o) Config.in
72
73 menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
74 if [ \! -f .config -a -e $(HOME)/.openwrt/defconfig ]; then \
75 cp $(HOME)/.openwrt/defconfig .config; \
76 fi
77 $< Config.in
78
79 kernel_oldconfig: .config FORCE
80 $(NO_TRACE_MAKE) -C target/linux oldconfig
81
82 kernel_menuconfig: .config FORCE
83 $(NO_TRACE_MAKE) -C target/linux menuconfig
84
85 tmp/.prereq-build: include/prereq-build.mk
86 mkdir -p tmp
87 rm -f tmp/.host.mk
88 @+$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
89 echo "Prerequisite check failed. Use FORCE=1 to override."; \
90 false; \
91 }
92 touch $@
93
94 download: .config FORCE
95 $(MAKE) -j1 tools/download
96 $(MAKE) -j1 toolchain/download
97 $(MAKE) -j1 package/download
98 $(MAKE) -j1 target/download
99
100 clean dirclean:
101 @$(MAKE) $@
102
103 prereq:: .config
104 @+$(SUBMAKE) -s tmp/.prereq-build $(PREP_MK)
105 @$(NO_TRACE_MAKE) -s $@
106
107 %::
108 @+$(PREP_MK) $(NO_TRACE_MAKE) -s prereq
109 @+$(MAKE) -r $@
110
111 help:
112 cat README
113
114 docs docs/compile: FORCE
115 $(MAKE) -C docs compile
116
117 docs/clean: FORCE
118 $(MAKE) -C docs clean
119
120 symlinkclean:
121 -find package -type l | xargs rm -f
122 rm -rf tmp
123
124 distclean:
125 rm -rf tmp build_dir staging_dir dl .config* feeds
126
127 ifeq ($(findstring v,$(DEBUG)),)
128 .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 prepare-tmpinfo
129 endif
130 .PHONY: help FORCE
131 .NOTPARALLEL:
132