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