39ffb17fb5e770c8c6983feee5ef3568388665a2
[openwrt-10.03/.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 TOPDIR=${shell pwd}
22 include $(TOPDIR)/include/verbose.mk
23
24 OPENWRTVERSION:=$(RELEASE)
25 ifneq ($(VERSION),)
26   OPENWRTVERSION:=$(VERSION) ($(OPENWRTVERSION))
27 else
28   REV:=$(shell LANG=C svn info | awk '/^Revision:/ { print$$2 }' )
29   ifneq ($(REV),)
30     OPENWRTVERSION:=$(OPENWRTVERSION)/r$(REV)
31   endif
32 endif
33 export OPENWRTVERSION
34
35 ifneq ($(shell ./scripts/timestamp.pl -p .pkginfo package Makefile),.pkginfo)
36   .pkginfo .config: FORCE
37 endif
38
39 ifeq ($(FORCE),)
40   .config scripts/config/conf scripts/config/mconf: .prereq-build
41   world: .prereq-packages
42 endif
43
44 .pkginfo:
45         @echo Collecting package info...
46         @-for dir in package/*/; do \
47                 echo Source-Makefile: $${dir}Makefile; \
48                 $(NO_TRACE_MAKE) --no-print-dir DUMP=1 -C $$dir || echo "ERROR: please fix $${dir}Makefile" >&2; \
49         done > $@
50
51 pkginfo-clean: FORCE
52         -rm -f .pkginfo .config.in
53
54 .config.in: .pkginfo
55         @./scripts/gen_menuconfig.pl < $< > $@ || rm -f $@
56
57 .config: ./scripts/config/conf .config.in
58         @[ -f .config ] || $(NO_TRACE_MAKE) menuconfig
59         @$< -D .config Config.in &> /dev/null
60
61 scripts/config/mconf:
62         @$(MAKE) -C scripts/config all
63
64 scripts/config/conf:
65         @$(MAKE) -C scripts/config conf
66
67 config: scripts/config/conf .config.in FORCE
68         $< Config.in
69
70 config-clean: FORCE
71         $(NO_TRACE_MAKE) -C scripts/config clean
72
73 defconfig: scripts/config/conf .config.in FORCE
74         touch .config
75         $< -D .config Config.in
76
77 oldconfig: scripts/config/conf .config.in FORCE
78         $< -o Config.in
79
80 menuconfig: scripts/config/mconf .config.in FORCE
81         $< Config.in
82
83 package/%: .pkginfo FORCE
84         $(MAKE) -C package $(patsubst package/%,%,$@)
85
86 target/%: .pkginfo FORCE
87         $(MAKE) -C target $(patsubst target/%,%,$@)
88
89 tools/%: FORCE
90         $(MAKE) -C tools $(patsubst tools/%,%,$@)
91
92 toolchain/%: FORCE
93         $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
94
95 .prereq-build: include/prereq-build.mk
96         @$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
97                 echo "Prerequisite check failed. Use FORCE=1 to override."; \
98                 rm -rf $(TOPDIR)/tmp; \
99                 false; \
100         }
101         @rm -rf $(TOPDIR)/tmp
102         @touch $@
103
104 .prereq-packages: include/prereq.mk .pkginfo .config
105         @$(NO_TRACE_MAKE) -s -C package prereq 2>/dev/null || { \
106                 echo "Prerequisite check failed. Use FORCE=1 to override."; \
107                 false; \
108         }
109         @rm -rf "$(TOPDIR)/tmp"
110         @touch $@
111         
112 prereq: .prereq-build .prereq-packages FORCE
113
114 download: .config FORCE
115         $(MAKE) tools/download
116         $(MAKE) toolchain/download
117         $(MAKE) package/download
118         $(MAKE) target/download
119
120 world: .config FORCE
121         $(MAKE) tools/install
122         $(MAKE) toolchain/install
123         $(MAKE) target/compile
124         $(MAKE) package/compile
125         $(MAKE) package/install
126         $(MAKE) target/install
127         $(MAKE) package/index
128
129 clean: FORCE
130         rm -rf build_* bin
131
132 dirclean: clean
133         rm -rf staging_dir_* toolchain_build_* tool_build
134
135 distclean: dirclean config-clean
136         rm -rf dl .*config* .pkg* .prereq 
137
138 .SILENT: clean dirclean distclean config-clean download world
139 FORCE: ;
140 .PHONY: FORCE
141 %: ;