another batch of V= stuff
[openwrt.git] / Makefile
1 # Makefile for OpenWrt
2 #
3 # Copyright (C) 2005 by Felix Fietkau <openwrt@nbd.name>
4 # Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #
20
21 #--------------------------------------------------------------
22 # Just run 'make menuconfig', configure stuff, then run 'make'.
23 # You shouldn't need to mess with anything beyond this point...
24 #--------------------------------------------------------------
25 TOPDIR=${shell pwd}
26 export TOPDIR
27
28 ifneq ($(DEVELOPER),)
29 CONFIG_CONFIG_IN = Config.in.devel
30 else
31 CONFIG_CONFIG_IN = Config.in
32 endif
33 CONFIG_DEFCONFIG = .defconfig
34 CONFIG = package/config
35
36 noconfig_targets := menuconfig config oldconfig randconfig \
37         defconfig allyesconfig allnoconfig release tags
38
39 # Pull in the user's configuration file
40 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
41 -include $(TOPDIR)/.config
42 endif
43
44 ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
45 include $(TOPDIR)/rules.mk
46
47 all: world
48
49 .NOTPARALLEL:
50
51 #############################################################
52 #
53 # You should probably leave this stuff alone unless you know
54 # what you are doing.
55 #
56 #############################################################
57
58 # In this section, we need .config
59 include .config.cmd
60
61 world: $(DL_DIR) $(BUILD_DIR) configtest 
62         $(MAKE) toolchain/install target/compile package/compile root_clean package/install target/install package_index
63         $(TRACE) Build complete.
64
65 .PHONY: all world clean dirclean distclean image_clean target_clean source configtest
66
67 configtest:
68         -cp .config .config.test
69         -scripts/configtest.pl
70
71 package_index:
72         (cd $(PACKAGE_DIR); $(STAGING_DIR)/usr/bin/ipkg-make-index . > Packages)
73
74 $(DL_DIR):
75         @mkdir -p $(DL_DIR)
76
77 $(BUILD_DIR):
78         @mkdir -p $(BUILD_DIR)
79
80 source: toolchain/source package/source target/source
81
82 package/%:
83         @$(TRACE) $@
84         $(MAKE) -C package $(patsubst package/%,%,$@)
85
86 target/%:
87         @$(TRACE) $@
88         $(MAKE) -C target $(patsubst target/%,%,$@)
89
90 toolchain/%:
91         @$(TRACE) $@
92         $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
93
94 #############################################################
95 #
96 # Cleanup and misc junk
97 #
98 #############################################################
99 root_clean:
100         @$(TRACE) root_clean
101         rm -rf $(BUILD_DIR)/linux-*/root $(BUILD_DIR)/root
102
103 target_clean: root_clean
104         rm -f $(STAMP_DIR)/.*-compile
105         rm -f $(STAMP_DIR)/.*-install
106         rm -rf $(BIN_DIR)
107
108 clean: dirclean
109
110 dirclean:
111         @$(TRACE) dirclean
112         @$(MAKE) -C $(CONFIG) clean
113         rm -rf $(BUILD_DIR)
114
115 distclean: dirclean
116         rm -rf $(STAMP_DIR) $(DL_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
117         rm -f .config* .tmpconfig.h
118
119 else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
120
121 all: menuconfig
122
123 # configuration
124 # ---------------------------------------------------------------------------
125
126 $(CONFIG)/conf:
127         $(MAKE) -C $(CONFIG) conf
128         -@if [ ! -f .config ] ; then \
129                 cp $(CONFIG_DEFCONFIG) .config; \
130         fi
131 $(CONFIG)/mconf:
132         $(MAKE) -C $(CONFIG) 
133         -@if [ ! -f .config ] ; then \
134                 cp $(CONFIG_DEFCONFIG) .config; \
135         fi
136
137 menuconfig: $(CONFIG)/mconf
138         -touch .config
139         -cp .config .config.test
140         @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
141         -./scripts/configtest.pl
142
143 config: $(CONFIG)/conf
144         -touch .config
145         -cp .config .config.test
146         @$(CONFIG)/conf $(CONFIG_CONFIG_IN)
147         -./scripts/configtest.pl
148
149 oldconfig: $(CONFIG)/conf
150         -touch .config
151         -cp .config .config.test
152         @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
153         -./scripts/configtest.pl
154
155 randconfig: $(CONFIG)/conf
156         -touch .config
157         -cp .config .config.test
158         @$(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
159         -./scripts/configtest.pl
160
161 allyesconfig: $(CONFIG)/conf
162         -touch .config
163         -cp .config .config.test
164         @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
165         -./scripts/configtest.pl
166
167 allnoconfig: $(CONFIG)/conf
168         -touch .config
169         -cp .config .config.test
170         @$(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
171         -./scripts/configtest.pl
172
173 defconfig: $(CONFIG)/conf
174         -touch .config
175         -cp .config .config.test
176         @$(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
177         -./scripts/configtest.pl
178
179 endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
180
181 .PHONY: dummy subdirs release distclean clean config oldconfig \
182         menuconfig tags check test depend
183