remove all copies of the root fs on make target_clean
[openwrt/svn-archive/archive.git] / openwrt / Makefile
1 # Makefile for OpenWRT
2 #
3 # Copyright (C) 2005 by Felix Fietkau <nbd@vd-s.ath.cx>
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 ifneq ($(DEVELOPER),)
28 CONFIG_CONFIG_IN = Config.in.devel
29 else
30 CONFIG_CONFIG_IN = Config.in
31 endif
32 CONFIG_DEFCONFIG = .defconfig
33 CONFIG = package/config
34
35 noconfig_targets := menuconfig config oldconfig randconfig \
36 defconfig allyesconfig allnoconfig release tags
37
38 # Pull in the user's configuration file
39 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
40 -include $(TOPDIR)/.config
41 endif
42
43 ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
44 include $(TOPDIR)/rules.mk
45
46 all: world
47
48 .NOTPARALLEL:
49
50 ##############################################################
51 #
52 # Build the toolchain
53 #
54 ##############################################################
55 toolchain_install:
56 $(MAKE) -C toolchain install
57
58 ##############################################################
59 #
60 # Make all packages
61 #
62 ##############################################################
63
64 package_compile: target_compile
65 $(MAKE) -C package compile
66
67 package_install: package_compile toolchain
68 $(MAKE) -C package install
69
70 #############################################################
71 #
72 # You should probably leave this stuff alone unless you know
73 # what you are doing.
74 #
75 #############################################################
76
77
78 # In this section, we need .config
79 include .config.cmd
80
81 world: $(DL_DIR) $(BUILD_DIR) configtest target_prepare $(TARGET_DIR) toolchain_install package_install target_install package_index
82
83 .PHONY: all world clean dirclean distclean image_clean target_clean source target_prepare target_install toolchain_install package_install configtest
84
85 configtest:
86 -cp .config .config.test
87 -scripts/configtest.pl
88
89 package_index:
90 (cd $(PACKAGE_DIR); \
91 $(STAGING_DIR)/usr/bin/ipkg-make-index . > Packages \
92 )
93
94 target_prepare:
95 $(MAKE) -C target prepare
96
97 target_compile:
98 $(MAKE) -C target compile
99
100 target_install:
101 $(MAKE) -C target install
102
103 $(DL_DIR):
104 @mkdir -p $(DL_DIR)
105
106 $(BUILD_DIR):
107 @mkdir -p $(BUILD_DIR)
108
109 source: $(TARGETS_SOURCE)
110
111 #############################################################
112 #
113 # Cleanup and misc junk
114 #
115 #############################################################
116 image_clean:
117 rm -f $(STAMP_DIR)/.*-compile
118 rm -f $(STAMP_DIR)/.*-install
119 rm -rf $(BIN_DIR)
120
121 target_clean: image_clean
122 rm -rf $(TARGET_DIR)
123 rm -rf $(BUILD_DIR)/linux-*/root
124
125 clean: target_clean
126 @$(MAKE) -C $(CONFIG) clean
127
128 dirclean: clean
129 rm -rf $(BUILD_DIR)
130
131 distclean: clean
132 rm -rf $(STAMP_DIR) $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
133 rm -f .config* .tmpconfig.h
134
135 sourceball: distclean
136 set -e; \
137 cd ..; \
138 rm -f buildroot.tar.bz2; \
139 tar -cvf buildroot.tar buildroot; \
140 bzip2 -9 buildroot.tar; \
141
142 else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
143
144 all: menuconfig
145
146 # configuration
147 # ---------------------------------------------------------------------------
148
149 $(CONFIG)/conf:
150 $(MAKE) -C $(CONFIG) conf
151 -@if [ ! -f .config ] ; then \
152 cp $(CONFIG_DEFCONFIG) .config; \
153 fi
154 $(CONFIG)/mconf:
155 $(MAKE) -C $(CONFIG)
156 -@if [ ! -f .config ] ; then \
157 cp $(CONFIG_DEFCONFIG) .config; \
158 fi
159
160 menuconfig: $(CONFIG)/mconf
161 -touch .config
162 -cp .config .config.test
163 @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
164 -./scripts/configtest.pl
165
166 config: $(CONFIG)/conf
167 -touch .config
168 -cp .config .config.test
169 @$(CONFIG)/conf $(CONFIG_CONFIG_IN)
170 -./scripts/configtest.pl
171
172 oldconfig: $(CONFIG)/conf
173 -touch .config
174 -cp .config .config.test
175 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
176 -./scripts/configtest.pl
177
178 randconfig: $(CONFIG)/conf
179 -touch .config
180 -cp .config .config.test
181 @$(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
182 -./scripts/configtest.pl
183
184 allyesconfig: $(CONFIG)/conf
185 #@$(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
186 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
187 -touch .config
188 -cp .config .config.test
189 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
190 -./scripts/configtest.pl
191
192 allnoconfig: $(CONFIG)/conf
193 -touch .config
194 -cp .config .config.test
195 @$(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
196 -./scripts/configtest.pl
197
198 defconfig: $(CONFIG)/conf
199 -touch .config
200 -cp .config .config.test
201 @$(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
202 -./scripts/configtest.pl
203
204 endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
205
206 .PHONY: dummy subdirs release distclean clean config oldconfig \
207 menuconfig tags check test depend
208