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