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