target/jffs2/blocksize.mk for setting block size (req. for wrt54g)
[openwrt-10.03/.git] / Makefile
1 # Makefile for buildroot2
2 #
3 # Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #
19
20 #--------------------------------------------------------------
21 # Just run 'make menuconfig', configure stuff, then run 'make'.
22 # You shouldn't need to mess with anything beyond this point...
23 #--------------------------------------------------------------
24 TOPDIR=./
25 CONFIG_CONFIG_IN = Config.in
26 CONFIG_DEFCONFIG = .defconfig
27 CONFIG = package/config
28
29 noconfig_targets := menuconfig config oldconfig randconfig \
30         defconfig allyesconfig allnoconfig release tags
31
32 # Pull in the user's configuration file
33 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
34 -include $(TOPDIR).config
35 endif
36
37 ifeq ($(BR2_TAR_VERBOSITY),y)
38 TAR_OPTIONS=-xvf
39 else
40 TAR_OPTIONS=-xf
41 endif
42
43 ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
44
45 #############################################################
46 #
47 # The list of stuff to build for the target toolchain
48 # along with the packages to build for the target.
49 #
50 ##############################################################
51 TARGETS:=host-sed kernel-headers uclibc-configured binutils gcc uclibc-target-utils linux openwrt
52
53 include toolchain/Makefile.in
54 include package/Makefile.in
55
56 #############################################################
57 #
58 # You should probably leave this stuff alone unless you know
59 # what you are doing.
60 #
61 #############################################################
62
63
64
65 all:   world
66
67 # In this section, we need .config
68 include .config.cmd
69
70 # We also need the various per-package makefiles, which also add
71 # each selected package to TARGETS if that package was selected
72 # in the .config file.
73 include toolchain/*/*.mk
74 include package/*/*.mk
75 include target/*/*.mk
76
77 # target stuff is last so it can override anything else
78 include target/Makefile.in
79
80 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
81 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS))
82 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
83
84 world: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) $(TARGETS)
85
86 .PHONY: all world clean dirclean distclean source $(TARGETS) \
87         $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
88         $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
89
90 #############################################################
91 #
92 # staging and target directories do NOT list these as
93 # dependancies anywhere else
94 #
95 #############################################################
96 $(DL_DIR):
97         @mkdir -p $(DL_DIR)
98
99 $(BUILD_DIR):
100         @mkdir -p $(BUILD_DIR)
101
102 $(TOOL_BUILD_DIR):
103         @mkdir -p $(TOOL_BUILD_DIR)
104
105 $(STAGING_DIR):
106         @mkdir -p $(STAGING_DIR)/lib
107         @mkdir -p $(STAGING_DIR)/include
108         @mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)
109         @ln -sf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
110
111 $(TARGET_DIR):
112         if [ -f "$(TARGET_SKELETON)" ] ; then \
113                 zcat $(TARGET_SKELETON) | tar -C $(BUILD_DIR) -xf -; \
114         fi;
115         if [ -d "$(TARGET_SKEL_DIR)" ] ; then \
116                 cp -a $(TARGET_SKEL_DIR)/* $(TARGET_DIR)/; \
117         fi;
118         -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf
119         -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf
120         -ln -sf /tmp/resolv.conf $(TARGET_DIR)/etc
121         -mkdir -p $(TARGET_DIR)/jffs
122
123 source: $(TARGETS_SOURCE)
124
125 #############################################################
126 #
127 # Cleanup and misc junk
128 #
129 #############################################################
130 clean: 
131         rm -rf $(TARGET_DIR) $(IMAGE).*
132         $(MAKE) openwrt-image-clean
133
134 dirclean: $(TARGETS_DIRCLEAN)
135         rm -rf $(TARGET_DIR) $(IMAGE).*
136         $(MAKE) openwrt-image-dirclean
137
138 distclean: clean
139         rm -rf $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) 
140         rm .config* .tmpconfig.h
141
142 sourceball:
143         rm -rf $(BUILD_DIR)
144         set -e; \
145         cd ..; \
146         rm -f buildroot.tar.bz2; \
147         tar -cvf buildroot.tar buildroot; \
148         bzip2 -9 buildroot.tar; \
149
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) ncurses conf mconf
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
174 config: $(CONFIG)/conf
175         -touch .config
176         -cp .config .config.test
177         @$(CONFIG)/conf $(CONFIG_CONFIG_IN)
178
179 oldconfig: $(CONFIG)/conf
180         -touch .config
181         -cp .config .config.test
182         @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
183
184 randconfig: $(CONFIG)/conf
185         -touch .config
186         -cp .config .config.test
187         @$(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
188
189 allyesconfig: $(CONFIG)/conf
190         #@$(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
191         #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
192         -touch .config
193         -cp .config .config.test
194         @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
195
196 allnoconfig: $(CONFIG)/conf
197         -touch .config
198         -cp .config .config.test
199         @$(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
200
201 defconfig: $(CONFIG)/conf
202         -touch .config
203         -cp .config .config.test
204         @$(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
205
206 #############################################################
207 #
208 # Cleanup and misc junk
209 #
210 #############################################################
211 clean:
212         @$(MAKE) -C $(CONFIG) clean
213
214 distclean: clean
215
216 endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
217
218 .PHONY: dummy subdirs release distclean clean config oldconfig \
219         menuconfig tags check test depend
220
221 targets:
222         @echo $(TARGETS)