large build system cleanup. added some stuff to control the verbosity level, but...
[openwrt/staging/dedeckeh.git] / openwrt / 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
64 .PHONY: all world clean dirclean distclean image_clean target_clean source configtest
65
66 configtest:
67 -cp .config .config.test
68 -scripts/configtest.pl
69
70 package_index:
71 (cd $(PACKAGE_DIR); $(STAGING_DIR)/usr/bin/ipkg-make-index . > Packages)
72
73 $(DL_DIR):
74 @mkdir -p $(DL_DIR)
75
76 $(BUILD_DIR):
77 @mkdir -p $(BUILD_DIR)
78
79 source: toolchain/source package/source target/source
80
81 package/%:
82 @$(TRACE) $@
83 $(MAKE) -C package $(patsubst package/%,%,$@)
84
85 target/%:
86 @$(TRACE) $@
87 $(MAKE) -C target $(patsubst target/%,%,$@)
88
89 toolchain/%:
90 @$(TRACE) $@
91 $(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
92
93 #############################################################
94 #
95 # Cleanup and misc junk
96 #
97 #############################################################
98 root_clean:
99 rm -rf $(BUILD_DIR)/linux-*/root $(BUILD_DIR)/root
100
101 target_clean: root_clean
102 rm -f $(STAMP_DIR)/.*-compile
103 rm -f $(STAMP_DIR)/.*-install
104 rm -rf $(BIN_DIR)
105
106 clean: dirclean
107
108 dirclean:
109 @$(MAKE) -C $(CONFIG) clean
110 rm -rf $(BUILD_DIR)
111
112 distclean: dirclean
113 rm -rf $(STAMP_DIR) $(DL_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
114 rm -f .config* .tmpconfig.h
115
116 else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
117
118 all: menuconfig
119
120 # configuration
121 # ---------------------------------------------------------------------------
122
123 $(CONFIG)/conf:
124 $(MAKE) -C $(CONFIG) conf
125 -@if [ ! -f .config ] ; then \
126 cp $(CONFIG_DEFCONFIG) .config; \
127 fi
128 $(CONFIG)/mconf:
129 $(MAKE) -C $(CONFIG)
130 -@if [ ! -f .config ] ; then \
131 cp $(CONFIG_DEFCONFIG) .config; \
132 fi
133
134 menuconfig: $(CONFIG)/mconf
135 -touch .config
136 -cp .config .config.test
137 @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
138 -./scripts/configtest.pl
139
140 config: $(CONFIG)/conf
141 -touch .config
142 -cp .config .config.test
143 @$(CONFIG)/conf $(CONFIG_CONFIG_IN)
144 -./scripts/configtest.pl
145
146 oldconfig: $(CONFIG)/conf
147 -touch .config
148 -cp .config .config.test
149 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
150 -./scripts/configtest.pl
151
152 randconfig: $(CONFIG)/conf
153 -touch .config
154 -cp .config .config.test
155 @$(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
156 -./scripts/configtest.pl
157
158 allyesconfig: $(CONFIG)/conf
159 -touch .config
160 -cp .config .config.test
161 @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
162 -./scripts/configtest.pl
163
164 allnoconfig: $(CONFIG)/conf
165 -touch .config
166 -cp .config .config.test
167 @$(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
168 -./scripts/configtest.pl
169
170 defconfig: $(CONFIG)/conf
171 -touch .config
172 -cp .config .config.test
173 @$(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
174 -./scripts/configtest.pl
175
176 endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
177
178 .PHONY: dummy subdirs release distclean clean config oldconfig \
179 menuconfig tags check test depend
180