add target package/target_name to the master makefile, which will run $(MAKE) -C...
[openwrt/openwrt.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 # In this section, we need .config
78 include .config.cmd
79
80 world: $(DL_DIR) $(BUILD_DIR) configtest target_prepare $(TARGET_DIR) toolchain_install package_install target_install package_index
81
82 .PHONY: all world clean dirclean distclean image_clean target_clean source target_prepare target_install toolchain_install package_install configtest
83
84 configtest:
85 -cp .config .config.test
86 -scripts/configtest.pl
87
88 package_index:
89 (cd $(PACKAGE_DIR); \
90 $(STAGING_DIR)/usr/bin/ipkg-make-index . > Packages \
91 )
92
93 target_prepare:
94 $(MAKE) -C target prepare
95
96 target_compile:
97 $(MAKE) -C target compile
98
99 target_install:
100 $(MAKE) -C target install
101
102 $(DL_DIR):
103 @mkdir -p $(DL_DIR)
104
105 $(BUILD_DIR):
106 @mkdir -p $(BUILD_DIR)
107
108 source: $(TARGETS_SOURCE)
109
110
111 package/%:
112 $(MAKE) -C package $(patsubst package/%,%,$@)
113
114 target/%:
115 $(MAKE) -C target $(patsubst target/%,%,$@)
116
117 toolchain/%:
118 $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
119
120 #############################################################
121 #
122 # Cleanup and misc junk
123 #
124 #############################################################
125 image_clean:
126 rm -f $(STAMP_DIR)/.*-compile
127 rm -f $(STAMP_DIR)/.*-install
128 rm -rf $(BIN_DIR)
129
130 target_clean: image_clean
131 rm -rf $(TARGET_DIR)
132 rm -rf $(BUILD_DIR)/linux-*/root
133
134 clean: target_clean
135 @$(MAKE) -C $(CONFIG) clean
136
137 dirclean: clean
138 rm -rf $(BUILD_DIR)
139
140 distclean: clean
141 rm -rf $(STAMP_DIR) $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
142 rm -f .config* .tmpconfig.h
143
144 sourceball: distclean
145 set -e; \
146 cd ..; \
147 rm -f buildroot.tar.bz2; \
148 tar -cvf buildroot.tar buildroot; \
149 bzip2 -9 buildroot.tar; \
150
151 else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
152
153 all: menuconfig
154
155 # configuration
156 # ---------------------------------------------------------------------------
157
158 $(CONFIG)/conf:
159 $(MAKE) -C $(CONFIG) conf
160 -@if [ ! -f .config ] ; then \
161 cp $(CONFIG_DEFCONFIG) .config; \
162 fi
163 $(CONFIG)/mconf:
164 $(MAKE) -C $(CONFIG)
165 -@if [ ! -f .config ] ; then \
166 cp $(CONFIG_DEFCONFIG) .config; \
167 fi
168
169 menuconfig: $(CONFIG)/mconf
170 -touch .config
171 -cp .config .config.test
172 @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
173 -./scripts/configtest.pl
174
175 config: $(CONFIG)/conf
176 -touch .config
177 -cp .config .config.test
178 @$(CONFIG)/conf $(CONFIG_CONFIG_IN)
179 -./scripts/configtest.pl
180
181 oldconfig: $(CONFIG)/conf
182 -touch .config
183 -cp .config .config.test
184 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
185 -./scripts/configtest.pl
186
187 randconfig: $(CONFIG)/conf
188 -touch .config
189 -cp .config .config.test
190 @$(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
191 -./scripts/configtest.pl
192
193 allyesconfig: $(CONFIG)/conf
194 #@$(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
195 #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
196 -touch .config
197 -cp .config .config.test
198 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
199 -./scripts/configtest.pl
200
201 allnoconfig: $(CONFIG)/conf
202 -touch .config
203 -cp .config .config.test
204 @$(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
205 -./scripts/configtest.pl
206
207 defconfig: $(CONFIG)/conf
208 -touch .config
209 -cp .config .config.test
210 @$(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
211 -./scripts/configtest.pl
212
213 endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
214
215 .PHONY: dummy subdirs release distclean clean config oldconfig \
216 menuconfig tags check test depend
217