hide experimental/developer options from the user. can be reenabled by using make...
[openwrt.git] / 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 ##############################################################
49 #
50 # Build the toolchain
51 #
52 ##############################################################
53 toolchain_install:
54         $(MAKE) -C toolchain install
55
56 ##############################################################
57 #
58 # Make all packages
59 #
60 ##############################################################
61
62 package_install: toolchain
63         $(MAKE) -C package compile install
64
65 #############################################################
66 #
67 # You should probably leave this stuff alone unless you know
68 # what you are doing.
69 #
70 #############################################################
71
72
73 # In this section, we need .config
74 include .config.cmd
75
76 world: $(DL_DIR) $(BUILD_DIR) configtest target_prepare $(TARGET_DIR) toolchain_install package_install target_install package_index
77
78 .PHONY: all world clean dirclean distclean image_clean target_clean source target_prepare target_install toolchain_install package_install configtest
79
80 configtest:
81         -cp .config .config.test
82         -scripts/configtest.pl
83
84 package_index:
85         (cd $(PACKAGE_DIR); \
86                 $(STAGING_DIR)/usr/bin/ipkg-make-index . > Packages \
87         )
88
89 target_prepare:
90         $(MAKE) -C target prepare
91
92 target_install:
93         $(MAKE) -C target install
94
95 $(DL_DIR):
96         @mkdir -p $(DL_DIR)
97
98 $(BUILD_DIR):
99         @mkdir -p $(BUILD_DIR)
100
101 source: $(TARGETS_SOURCE)
102
103 #############################################################
104 #
105 # Cleanup and misc junk
106 #
107 #############################################################
108 image_clean:
109         rm -f $(STAMP_DIR)/.*-compile
110         rm -f $(STAMP_DIR)/.*-install
111         rm -rf $(BIN_DIR)
112         
113 target_clean: image_clean
114         rm -rf $(TARGET_DIR)
115
116 clean: target_clean
117         @$(MAKE) -C $(CONFIG) clean
118
119 dirclean: clean
120         rm -rf $(BUILD_DIR)
121
122 distclean: clean
123         rm -rf $(STAMP_DIR) $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
124         rm -f .config* .tmpconfig.h
125
126 sourceball: distclean
127         set -e; \
128         cd ..; \
129         rm -f buildroot.tar.bz2; \
130         tar -cvf buildroot.tar buildroot; \
131         bzip2 -9 buildroot.tar; \
132
133 else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
134
135 all: menuconfig
136
137 # configuration
138 # ---------------------------------------------------------------------------
139
140 $(CONFIG)/conf:
141         $(MAKE) -C $(CONFIG) conf
142         -@if [ ! -f .config ] ; then \
143                 cp $(CONFIG_DEFCONFIG) .config; \
144         fi
145 $(CONFIG)/mconf:
146         $(MAKE) -C $(CONFIG) 
147         -@if [ ! -f .config ] ; then \
148                 cp $(CONFIG_DEFCONFIG) .config; \
149         fi
150
151 menuconfig: $(CONFIG)/mconf
152         -touch .config
153         -cp .config .config.test
154         @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
155         -./scripts/configtest.pl
156
157 config: $(CONFIG)/conf
158         -touch .config
159         -cp .config .config.test
160         @$(CONFIG)/conf $(CONFIG_CONFIG_IN)
161         -./scripts/configtest.pl
162
163 oldconfig: $(CONFIG)/conf
164         -touch .config
165         -cp .config .config.test
166         @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
167         -./scripts/configtest.pl
168
169 randconfig: $(CONFIG)/conf
170         -touch .config
171         -cp .config .config.test
172         @$(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
173         -./scripts/configtest.pl
174
175 allyesconfig: $(CONFIG)/conf
176         #@$(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
177         #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
178         -touch .config
179         -cp .config .config.test
180         @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
181         -./scripts/configtest.pl
182
183 allnoconfig: $(CONFIG)/conf
184         -touch .config
185         -cp .config .config.test
186         @$(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
187         -./scripts/configtest.pl
188
189 defconfig: $(CONFIG)/conf
190         -touch .config
191         -cp .config .config.test
192         @$(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
193         -./scripts/configtest.pl
194
195 endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
196
197 .PHONY: dummy subdirs release distclean clean config oldconfig \
198         menuconfig tags check test depend
199