]> Git Repo - buildroot-mgba.git/blob - Makefile
Applied patch from Brian Foster <[email protected]>:
[buildroot-mgba.git] / Makefile
1 # Makefile for buildroot2
2 #
3 # Copyright (C) 1999-2005 by Erik Andersen <[email protected]>
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 DATE:=$(shell date +%Y%m%d)
29
30 noconfig_targets:=menuconfig config oldconfig randconfig \
31         defconfig allyesconfig allnoconfig release tags \
32         source-check help
33
34
35 # Use shell variables, if defined
36 ifneq ($(BUILDROOT_LOCAL),)
37 BR2_LOCAL:=$(BUILDROOT_LOCAL)
38 else
39 BR2_LOCAL:=$(TOPDIR)/local
40 endif
41
42 # $(shell find . -name *_defconfig |sed 's/.*\///')
43 # Pull in the user's configuration file
44 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
45 ifeq ($(BOARD),)
46 # if "make BOARD=xyz" command
47 -include .config
48 else
49 # if "make" command
50 -include $(BR2_LOCAL)/$(BOARD)/$(BOARD).config
51 endif
52 endif
53
54 # Override BR2_DL_DIR if shell variable defined
55 ifneq ($(BUILDROOT_DL_DIR),)
56 BR2_DL_DIR:=$(BUILDROOT_DL_DIR)
57 endif
58 LOCAL:=$(BR2_LOCAL)
59
60 # To put more focus on warnings, be less verbose as default
61 # Use 'make V=1' to see the full commands
62 ifdef V
63   ifeq ("$(origin V)", "command line")
64     KBUILD_VERBOSE=$(V)
65   endif
66 endif
67 ifndef KBUILD_VERBOSE
68   KBUILD_VERBOSE=0
69 endif
70
71 ifeq ($(KBUILD_VERBOSE),1)
72   quiet=
73   Q=
74 ifndef VERBOSE
75   VERBOSE=1
76 endif
77 else
78   quiet=quiet_
79   Q=@
80 endif
81
82 CONFIG_SHELL:=$(shell if [ -x "$$BASH" ]; then echo $$BASH; \
83         else if [ -x /bin/bash ]; then echo /bin/bash; \
84         else echo sh; fi; fi)
85
86 export CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
87
88 ifndef HOSTAR
89 HOSTAR:=ar
90 endif
91 ifndef HOSTAS
92 HOSTAS:=as
93 endif
94 ifndef HOSTCC
95 HOSTCC:=gcc
96 else
97 endif
98 ifndef HOSTCXX
99 HOSTCXX:=g++
100 endif
101 ifndef HOSTFC
102 HOSTFC:=gfortran
103 endif
104 ifndef HOSTCPP
105 HOSTCPP:=cpp
106 endif
107 ifndef HOSTLD
108 HOSTLD:=ld
109 endif
110 ifndef HOSTLN
111 HOSTLN:=ln
112 endif
113 ifndef HOSTNM
114 HOSTNM:=nm
115 endif
116 HOSTAR:=$(shell $(CONFIG_SHELL) -c "which $(HOSTAR)" || type -p $(HOSTAR) || echo ar)
117 HOSTAS:=$(shell $(CONFIG_SHELL) -c "which $(HOSTAS)" || type -p $(HOSTAS) || echo as)
118 HOSTCC:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCC)" || type -p $(HOSTCC) || echo gcc)
119 HOSTCXX:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCXX)" || type -p $(HOSTCXX) || echo g++)
120 HOSTFC:=$(shell $(CONFIG_SHELL) -c "which $(HOSTLD)" || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran)
121 HOSTCPP:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCPP)" || type -p $(HOSTCPP) || echo cpp)
122 HOSTLD:=$(shell $(CONFIG_SHELL) -c "which $(HOSTLD)" || type -p $(HOSTLD) || echo ld)
123 HOSTLN:=$(shell $(CONFIG_SHELL) -c "which $(HOSTLN)" || type -p $(HOSTLN) || echo ln)
124 HOSTNM:=$(shell $(CONFIG_SHELL) -c "which $(HOSTNM)" || type -p $(HOSTNM) || echo nm)
125 HOST_GLIB_BIN:=`dirname $(shell $(CONFIG_SHELL) -c "which glib-genmarshal" || echo /usr/bin/glib-genmarshal)`
126 HOST_GLIB:=$(shell $(CONFIG_SHELL) -c "dirname $(HOST_GLIB_BIN)" || echo /usr)
127
128
129 ifndef CFLAGS_FOR_BUILD
130 CFLAGS_FOR_BUILD:=-g -O2
131 endif
132 ifndef CXXFLAGS_FOR_BUILD
133 CXXFLAGS_FOR_BUILD:=-g -O2
134 endif
135 ifndef FCFLAGS_FOR_BUILD
136 FCFLAGS_FOR_BUILD:=-g -O2
137 endif
138 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
139
140
141 ifeq ($(BR2_HAVE_DOT_CONFIG),y)
142
143 # cc-option
144 # Usage: cflags-y+=$(call cc-option, -march=winchip-c6, -march=i586)
145 # sets -march=winchip-c6 if supported else falls back to -march=i586
146 # without checking the latter.
147 cc-option=$(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
148         > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
149
150 #############################################################
151 #
152 # Hide troublesome environment variables from sub processes
153 #
154 #############################################################
155 unexport CROSS_COMPILE
156 unexport ARCH
157
158 #############################################################
159 #
160 # Setup the proper filename extensions for the host
161 #
162 ##############################################################
163 ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
164 HOST_EXEEXT:=
165 HOST_LIBEXT:=.a
166 HOST_SHREXT:=.so
167 endif
168 ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
169 HOST_EXEEXT:=
170 HOST_LIBEXT:=.a
171 HOST_SHREXT:=.dylib
172 endif
173 ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
174 HOST_EXEEXT:=.exe
175 HOST_LIBEXT:=.lib
176 HOST_SHREXT:=.dll
177 HOST_LOADLIBES="-lcurses -lintl"
178 export HOST_LOADLIBES
179 endif
180 ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
181 HOST_EXEEXT:=.exe
182 HOST_LIBEXT:=.lib
183 HOST_SHREXT:=.dll
184 endif
185
186 # The preferred type of libs we build for the target
187 ifeq ($(BR2_PREFER_STATIC_LIB),y)
188 LIBTGTEXT=.a
189 #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
190 else
191 LIBTGTEXT=.so
192 #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
193 endif
194 PREFERRED_LIB_FLAGS:=--enable-static --enable-shared
195
196 ##############################################################
197 #
198 # The list of stuff to build for the target toolchain
199 # along with the packages to build for the target.
200 #
201 ##############################################################
202 ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
203 BASE_TARGETS:=uclibc-configured binutils cross_compiler uclibc-target-utils kernel-headers
204 else
205 BASE_TARGETS:=uclibc kernel-headers
206 endif
207 TARGETS:=
208
209 # setup our pathes
210 include project/Makefile.in
211
212 BR2_DEPENDS_DIR=$(PROJECT_BUILD_DIR)/buildroot-config
213
214 include toolchain/Makefile.in
215 include package/Makefile.in
216
217 #############################################################
218 #
219 # You should probably leave this stuff alone unless you know
220 # what you are doing.
221 #
222 #############################################################
223
224 all: world
225
226 # In this section, we need .config
227 include .config.cmd
228
229 include project/*.mk
230
231 # We also need the various per-package makefiles, which also add
232 # each selected package to TARGETS if that package was selected
233 # in the .config file.
234 ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
235 # avoid pulling in external toolchain which is broken for toplvl parallel builds
236 # Explicit ordering:
237 include toolchain/dependencies/dependencies.mk
238 include toolchain/binutils/binutils.mk
239 include toolchain/ccache/ccache.mk
240 include toolchain/elf2flt/elf2flt.mk
241 include toolchain/gcc/gcc-uclibc-3.x.mk
242 include toolchain/gcc/gcc-uclibc-4.x.mk
243 include toolchain/gdb/gdb.mk
244 include toolchain/kernel-headers/kernel-headers.mk
245 include toolchain/mklibs/mklibs.mk
246 include toolchain/sstrip/sstrip.mk
247 include toolchain/uClibc/uclibc.mk
248 else
249 include toolchain/*/*.mk
250 endif
251
252 ifeq ($(BR2_PACKAGE_LINUX),y)
253 TARGETS+=linux26-modules
254 endif
255
256 include package/*/*.mk
257
258 TARGETS+=target-devfiles
259
260 # target stuff is last so it can override anything else
261 include target/Makefile.in
262
263 TARGETS+=erase-fakeroots
264
265 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
266 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS) $(BASE_TARGETS))
267 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
268 TARGETS_ALL:=$(patsubst %,__real_tgt_%,$(TARGETS))
269 # all targets depend on the crosscompiler and it's prerequisites
270 $(TARGETS_ALL): __real_tgt_%: $(BASE_TARGETS) %
271
272 $(BR2_DEPENDS_DIR): .config
273         rm -rf $@
274         mkdir -p $(@D)
275         cp -dpRf $(CONFIG)/buildroot-config $@
276
277 dirs: $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
278         $(BR2_DEPENDS_DIR) \
279         $(BINARIES_DIR) $(PROJECT_BUILD_DIR)
280
281 $(BASE_TARGETS): dirs
282
283 world: dependencies dirs target-host-info $(BASE_TARGETS) $(TARGETS_ALL)
284
285
286 .PHONY: all world dirs clean dirclean distclean source \
287         $(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
288         $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
289         $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
290         $(BR2_DEPENDS_DIR) \
291         $(BINARIES_DIR) $(PROJECT_BUILD_DIR)
292
293 #############################################################
294 #
295 # staging and target directories do NOT list these as
296 # dependencies anywhere else
297 #
298 #############################################################
299 $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) \
300         $(PROJECT_BUILD_DIR) $(BINARIES_DIR):
301         @mkdir -p $@
302
303 $(STAGING_DIR):
304         @mkdir -p $(STAGING_DIR)/bin
305         @mkdir -p $(STAGING_DIR)/lib
306 ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
307         @mkdir -p $(STAGING_DIR)/usr/lib
308 else
309 ifneq ($(BR2_TOOLCHAIN_EXTERNAL),y)
310         @ln -snf . $(STAGING_DIR)/usr
311         @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)
312         @ln -snf ../lib $(STAGING_DIR)/usr/lib
313         @ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
314 endif
315 endif
316         @mkdir -p $(STAGING_DIR)/usr/include
317
318 $(PROJECT_BUILD_DIR)/.root:
319         mkdir -p $(TARGET_DIR)
320         if ! [ -d "$(TARGET_DIR)/bin" ]; then \
321                 if [ -d "$(TARGET_SKELETON)" ]; then \
322                         cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
323                 fi; \
324                 touch $(STAGING_DIR)/.fakeroot.00000; \
325         fi
326         -find $(TARGET_DIR) -type d -name CVS -o -name .svn | xargs rm -rf
327         -find $(TARGET_DIR) -type f -name .empty | xargs rm -rf 
328         touch $@
329
330 $(TARGET_DIR): $(PROJECT_BUILD_DIR)/.root
331
332 erase-fakeroots:
333         rm -f $(PROJECT_BUILD_DIR)/.fakeroot*
334
335 target-devfiles:
336 ifeq ($(BR2_HAVE_DEVFILES),y)
337         ( scripts/copy.sh $(STAGING_DIR) $(TARGET_DIR) )
338 else
339         rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/lib/pkgconfig
340         find $(TARGET_DIR)/usr/lib -name '*.a' -delete
341         find $(TARGET_DIR)/lib -name '*.a' -delete
342         find $(TARGET_DIR)/usr/lib -name '*.la' -delete
343         find $(TARGET_DIR)/lib -name '*.la' -delete
344 endif
345
346 source: $(TARGETS_SOURCE) $(HOST_SOURCE)
347
348 _source-check:
349         $(MAKE) SPIDER=--spider source
350
351 external-deps:
352         @$(MAKE) -Bs BR2_WGET=$(TOPDIR)/toolchain/wget-show-external-deps.sh \
353                 SPIDER=--spider source
354
355 #############################################################
356 #
357 # Cleanup and misc junk
358 #
359 #############################################################
360 clean: $(TARGETS_CLEAN)
361         rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) $(PROJECT_BUILD_DIR)/.root $(PROJECT_BUILD_DIR)/autotools-stamps
362
363 dirclean: $(TARGETS_DIRCLEAN)
364         rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE) $(PROJECT_BUILD_DIR)/.root $(PROJECT_BUILD_DIR)/autotools-stamps
365
366 distclean:
367 ifeq ($(DL_DIR),$(BASE_DIR)/dl)
368         rm -rf $(DL_DIR)
369 endif
370         rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR) \
371         $(LINUX_KERNEL) $(BASE_DIR)/include \
372                 .config.cmd
373         $(MAKE) -C $(CONFIG) clean
374
375 sourceball:
376         rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR)
377         set -e; \
378         cd ..; \
379         rm -f buildroot.tar.bz2; \
380         tar -cvf buildroot.tar buildroot; \
381         bzip2 -9 buildroot.tar; \
382
383
384 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
385
386 all: menuconfig
387
388 # configuration
389 # ---------------------------------------------------------------------------
390
391 HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
392 export HOSTCFLAGS
393
394 $(CONFIG)/conf:
395         @mkdir -p $(CONFIG)/buildroot-config
396         $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf
397         -@if [ ! -f .config ]; then \
398                 cp $(CONFIG_DEFCONFIG) .config; \
399         fi
400 $(CONFIG)/mconf:
401         @mkdir -p $(CONFIG)/buildroot-config
402         $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf mconf
403         -@if [ ! -f .config ]; then \
404                 cp $(CONFIG_DEFCONFIG) .config; \
405         fi
406
407 menuconfig: $(CONFIG)/mconf
408         @mkdir -p $(CONFIG)/buildroot-config
409         @if ! KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
410                 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
411                 $(CONFIG)/mconf $(CONFIG_CONFIG_IN); then \
412                 test -f .config.cmd || rm -f .config; \
413         fi
414
415 config: $(CONFIG)/conf
416         @mkdir -p $(CONFIG)/buildroot-config
417         @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
418                 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
419                 $(CONFIG)/conf $(CONFIG_CONFIG_IN)
420
421 oldconfig: $(CONFIG)/conf
422         @mkdir -p $(CONFIG)/buildroot-config
423         @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
424                 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
425                 $(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
426
427 randconfig: $(CONFIG)/conf
428         @mkdir -p $(CONFIG)/buildroot-config
429         @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
430                 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
431                 $(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
432
433 allyesconfig: $(CONFIG)/conf
434         cat $(CONFIG_DEFCONFIG) > .config
435         @mkdir -p $(CONFIG)/buildroot-config
436         @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
437                 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
438                 $(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
439         #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
440
441 allnoconfig: $(CONFIG)/conf
442         @mkdir -p $(CONFIG)/buildroot-config
443         @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
444                 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
445                 $(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
446
447 defconfig: $(CONFIG)/conf
448         @mkdir -p $(CONFIG)/buildroot-config
449         @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
450                 KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
451                 $(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
452
453 # check if download URLs are outdated
454 source-check: allyesconfig
455         $(MAKE) _source-check
456
457 #############################################################
458 #
459 # Cleanup and misc junk
460 #
461 #############################################################
462 clean:
463         rm -f .config .config.old .config.cmd .tmpconfig.h .lognr.*
464         -$(MAKE) -C $(CONFIG) clean
465
466 distclean: clean
467         rm -rf sources/*
468
469 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
470
471 %_defconfig: $(CONFIG)/conf
472         cp $(shell find ./target/ -name $@) .config
473         -@$(MAKE) oldconfig
474
475 update:
476         cp .config $(BOARD_PATH)/$(BOARD_NAME)_defconfig
477
478 configured: dirs host-sed kernel-headers uclibc-config busybox-config linux26-config
479
480 prepatch:       gcc-patched binutils-patched gdb-patched uclibc-patched
481
482 .lognr.$(PROJECT):
483         @echo "0" > .lognr.$(PROJECT)
484
485 log:    .lognr.$(PROJECT)
486         @expr `cat .lognr.$(PROJECT)` + 1 > .lognr.$(PROJECT)   
487         @echo Creating $(PROJECT)-`cat .lognr.$(PROJECT)`.log
488         @$(MAKE) > $(PROJECT)-`cat .lognr.$(PROJECT)`.log 2>&1
489
490
491 cross: $(BASE_TARGETS)
492
493 help:
494         @echo 'Cleaning:'
495         @echo '  clean                  - delete temporary files created by build'
496         @echo '  distclean              - delete all non-source files (including .config)'
497         @echo
498         @echo 'Build:'
499         @echo '  all                    - make world'
500         @echo
501         @echo 'Configuration:'
502         @echo '  menuconfig             - interactive curses-based configurator'
503         @echo '  oldconfig              - resolve any unresolved symbols in .config'
504         @echo
505         @echo 'Miscellaneous:'
506         @echo '  source                 - download all sources needed for offline-build'
507         @echo '  source-check           - check all packages for valid download URLs'
508         @echo '  external-deps          - list external packages used'
509         @echo
510         @echo 'See docs/README and docs/buildroot.html for further details'
511         @echo
512
513 .PHONY: dummy subdirs release distclean clean config oldconfig \
514         menuconfig tags check test depend defconfig help
515
This page took 0.053666 seconds and 4 git commands to generate.