]> Git Repo - buildroot-mgba.git/blob - Makefile
core: introduce the BR2_EXTERNAL variable
[buildroot-mgba.git] / Makefile
1 # Makefile for buildroot
2 #
3 # Copyright (C) 1999-2005 by Erik Andersen <[email protected]>
4 # Copyright (C) 2006-2013 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
26 # Set and export the version string
27 export BR2_VERSION:=2014.02-git
28
29 # Check for minimal make version (note: this check will break at make 10.x)
30 MIN_MAKE_VERSION=3.81
31 ifneq ($(firstword $(sort $(MAKE_VERSION) $(MIN_MAKE_VERSION))),$(MIN_MAKE_VERSION))
32 $(error You have make '$(MAKE_VERSION)' installed. GNU make >= $(MIN_MAKE_VERSION) is required)
33 endif
34
35 export HOSTARCH := $(shell uname -m | \
36         sed -e s/i.86/x86/ \
37             -e s/sun4u/sparc64/ \
38             -e s/arm.*/arm/ \
39             -e s/sa110/arm/ \
40             -e s/ppc64/powerpc/ \
41             -e s/ppc/powerpc/ \
42             -e s/macppc/powerpc/\
43             -e s/sh.*/sh/)
44
45 # This top-level Makefile can *not* be executed in parallel
46 .NOTPARALLEL:
47
48 # absolute path
49 TOPDIR:=$(shell pwd)
50 CONFIG_CONFIG_IN=Config.in
51 CONFIG=support/kconfig
52 DATE:=$(shell date +%Y%m%d)
53
54 # Compute the full local version string so packages can use it as-is
55 # Need to export it, so it can be got from environment in children (eg. mconf)
56 export BR2_VERSION_FULL:=$(BR2_VERSION)$(shell $(TOPDIR)/support/scripts/setlocalversion)
57
58 noconfig_targets:=menuconfig nconfig gconfig xconfig config oldconfig randconfig \
59         %_defconfig allyesconfig allnoconfig silentoldconfig release \
60         randpackageconfig allyespackageconfig allnopackageconfig \
61         source-check print-version olddefconfig
62
63 # Strip quotes and then whitespaces
64 qstrip=$(strip $(subst ",,$(1)))
65 #"))
66
67 # Variables for use in Make constructs
68 comma:=,
69 empty:=
70 space:=$(empty) $(empty)
71
72 ifneq ("$(origin O)", "command line")
73 O:=output
74 CONFIG_DIR:=$(TOPDIR)
75 NEED_WRAPPER=
76 else
77 # other packages might also support Linux-style out of tree builds
78 # with the O=<dir> syntax (E.G. Busybox does). As make automatically
79 # forwards command line variable definitions those packages get very
80 # confused. Fix this by telling make to not do so
81 MAKEOVERRIDES =
82 # strangely enough O is still passed to submakes with MAKEOVERRIDES
83 # (with make 3.81 atleast), the only thing that changes is the output
84 # of the origin function (command line -> environment).
85 # Unfortunately some packages don't look at origin (E.G. uClibc 0.9.31+)
86 # To really make O go away, we have to override it.
87 override O:=$(O)
88 CONFIG_DIR:=$(O)
89 # we need to pass O= everywhere we call back into the toplevel makefile
90 EXTRAMAKEARGS = O=$(O)
91 NEED_WRAPPER=y
92 endif
93
94 # bash prints the name of the directory on 'cd <dir>' if CDPATH is
95 # set, so unset it here to not cause problems. Notice that the export
96 # line doesn't affect the environment of $(shell ..) calls, so
97 # explictly throw away any output from 'cd' here.
98 export CDPATH:=
99 BASE_DIR := $(shell mkdir -p $(O) && cd $(O) >/dev/null && pwd)
100 $(if $(BASE_DIR),, $(error output directory "$(O)" does not exist))
101
102
103 # Handling of BR2_EXTERNAL.
104 #
105 # The value of BR2_EXTERNAL is stored in .br-external in the output directory.
106 # On subsequent invocations of make, it is read in. It can still be overridden
107 # on the command line, therefore the file is re-created every time make is run.
108 #
109 # When BR2_EXTERNAL is not set, the .br-external file is removed and we point
110 # to support/dummy-external. This makes sure we can unconditionally include the
111 # Config.in and external.mk from the BR2_EXTERNAL directory. In this case,
112 # override is necessary so the user can clear BR2_EXTERNAL from the command
113 # line, but the dummy path is still used internally.
114
115 BR2_EXTERNAL_FILE = $(BASE_DIR)/.br-external
116 -include $(BR2_EXTERNAL_FILE)
117 ifeq ($(BR2_EXTERNAL),)
118   override BR2_EXTERNAL = support/dummy-external
119   $(shell rm -f $(BR2_EXTERNAL_FILE))
120 else
121   $(shell echo BR2_EXTERNAL ?= $(BR2_EXTERNAL) > $(BR2_EXTERNAL_FILE))
122 endif
123
124
125 BUILD_DIR:=$(BASE_DIR)/build
126 STAMP_DIR:=$(BASE_DIR)/stamps
127 BINARIES_DIR:=$(BASE_DIR)/images
128 TARGET_DIR:=$(BASE_DIR)/target
129 # initial definition so that 'make clean' works for most users, even without
130 # .config. HOST_DIR will be overwritten later when .config is included.
131 HOST_DIR:=$(BASE_DIR)/host
132
133 LEGAL_INFO_DIR=$(BASE_DIR)/legal-info
134 REDIST_SOURCES_DIR_TARGET=$(LEGAL_INFO_DIR)/sources
135 REDIST_SOURCES_DIR_HOST=$(LEGAL_INFO_DIR)/host-sources
136 LICENSE_FILES_DIR_TARGET=$(LEGAL_INFO_DIR)/licenses
137 LICENSE_FILES_DIR_HOST=$(LEGAL_INFO_DIR)/host-licenses
138 LEGAL_MANIFEST_CSV_TARGET=$(LEGAL_INFO_DIR)/manifest.csv
139 LEGAL_MANIFEST_CSV_HOST=$(LEGAL_INFO_DIR)/host-manifest.csv
140 LEGAL_LICENSES_TXT_TARGET=$(LEGAL_INFO_DIR)/licenses.txt
141 LEGAL_LICENSES_TXT_HOST=$(LEGAL_INFO_DIR)/host-licenses.txt
142 LEGAL_WARNINGS=$(LEGAL_INFO_DIR)/.warnings
143 LEGAL_REPORT=$(LEGAL_INFO_DIR)/README
144
145 BUILDROOT_CONFIG=$(CONFIG_DIR)/.config
146
147 # Pull in the user's configuration file
148 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
149 -include $(BUILDROOT_CONFIG)
150 endif
151
152 # To put more focus on warnings, be less verbose as default
153 # Use 'make V=1' to see the full commands
154 ifdef V
155   ifeq ("$(origin V)", "command line")
156     KBUILD_VERBOSE=$(V)
157   endif
158 endif
159 ifndef KBUILD_VERBOSE
160   KBUILD_VERBOSE=0
161 endif
162
163 ifeq ($(KBUILD_VERBOSE),1)
164   quiet=
165   Q=
166 ifndef VERBOSE
167   VERBOSE=1
168 endif
169 else
170   quiet=quiet_
171   Q=@
172 endif
173
174 # we want bash as shell
175 SHELL:=$(shell if [ -x "$$BASH" ]; then echo $$BASH; \
176         else if [ -x /bin/bash ]; then echo /bin/bash; \
177         else echo sh; fi; fi)
178
179 # kconfig uses CONFIG_SHELL
180 CONFIG_SHELL:=$(SHELL)
181
182 export SHELL CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
183
184 ifndef HOSTAR
185 HOSTAR:=ar
186 endif
187 ifndef HOSTAS
188 HOSTAS:=as
189 endif
190 ifndef HOSTCC
191 HOSTCC:=gcc
192 HOSTCC:=$(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
193 endif
194 HOSTCC_NOCCACHE:=$(HOSTCC)
195 ifndef HOSTCXX
196 HOSTCXX:=g++
197 HOSTCXX:=$(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
198 endif
199 HOSTCXX_NOCCACHE:=$(HOSTCXX)
200 ifndef HOSTFC
201 HOSTFC:=gfortran
202 endif
203 ifndef HOSTCPP
204 HOSTCPP:=cpp
205 endif
206 ifndef HOSTLD
207 HOSTLD:=ld
208 endif
209 ifndef HOSTLN
210 HOSTLN:=ln
211 endif
212 ifndef HOSTNM
213 HOSTNM:=nm
214 endif
215 ifndef HOSTOBJCOPY
216 HOSTOBJCOPY:=objcopy
217 endif
218 ifndef HOSTRANLIB
219 HOSTRANLIB:=ranlib
220 endif
221 HOSTAR:=$(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
222 HOSTAS:=$(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
223 HOSTFC:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran)
224 HOSTCPP:=$(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
225 HOSTLD:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
226 HOSTLN:=$(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
227 HOSTNM:=$(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
228 HOSTOBJCOPY:=$(shell which $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo objcopy)
229 HOSTRANLIB:=$(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib)
230
231 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
232 export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
233
234 # Make sure pkg-config doesn't look outside the buildroot tree
235 unexport PKG_CONFIG_PATH
236 unexport PKG_CONFIG_SYSROOT_DIR
237 unexport PKG_CONFIG_LIBDIR
238
239 # Having DESTDIR set in the environment confuses the installation
240 # steps of some packages.
241 unexport DESTDIR
242
243 # Causes breakage with packages that needs host-ruby
244 unexport RUBYOPT
245
246 ifeq ($(BR2_HAVE_DOT_CONFIG),y)
247
248 ################################################################################
249 #
250 # Hide troublesome environment variables from sub processes
251 #
252 ################################################################################
253 unexport CROSS_COMPILE
254 unexport ARCH
255 unexport CC
256 unexport CXX
257 unexport CPP
258 unexport CFLAGS
259 unexport CXXFLAGS
260 unexport GREP_OPTIONS
261 unexport CONFIG_SITE
262 unexport QMAKESPEC
263 unexport TERMINFO
264
265 GNU_HOST_NAME:=$(shell support/gnuconfig/config.guess)
266
267 ################################################################################
268 #
269 # The list of stuff to build for the target toolchain
270 # along with the packages to build for the target.
271 #
272 ################################################################################
273
274 BASE_TARGETS = toolchain
275
276 TARGETS:=
277
278 # silent mode requested?
279 QUIET:=$(if $(findstring s,$(MAKEFLAGS)),-q)
280
281 # Strip off the annoying quoting
282 ARCH:=$(call qstrip,$(BR2_ARCH))
283
284 KERNEL_ARCH:=$(shell echo "$(ARCH)" | sed -e "s/-.*//" \
285         -e s/i.86/i386/ -e s/sun4u/sparc64/ \
286         -e s/arcle/arc/ \
287         -e s/arceb/arc/ \
288         -e s/arm.*/arm/ -e s/sa110/arm/ \
289         -e s/aarch64/arm64/ \
290         -e s/bfin/blackfin/ \
291         -e s/parisc64/parisc/ \
292         -e s/powerpc64/powerpc/ \
293         -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
294         -e s/sh.*/sh/)
295
296 ZCAT:=$(call qstrip,$(BR2_ZCAT))
297 BZCAT:=$(call qstrip,$(BR2_BZCAT))
298 XZCAT:=$(call qstrip,$(BR2_XZCAT))
299 TAR_OPTIONS=$(call qstrip,$(BR2_TAR_OPTIONS)) -xf
300
301 # packages compiled for the host go here
302 HOST_DIR:=$(call qstrip,$(BR2_HOST_DIR))
303
304 # locales to generate
305 GENERATE_LOCALE=$(call qstrip,$(BR2_GENERATE_LOCALE))
306
307 TARGET_SKELETON=$(TOPDIR)/system/skeleton
308
309 # Location of a file giving a big fat warning that output/target
310 # should not be used as the root filesystem.
311 TARGET_DIR_WARNING_FILE=$(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
312
313 ifeq ($(BR2_CCACHE),y)
314 CCACHE:=$(HOST_DIR)/usr/bin/ccache
315 BUILDROOT_CACHE_DIR = $(call qstrip,$(BR2_CCACHE_DIR))
316 export BUILDROOT_CACHE_DIR
317 HOSTCC  := $(CCACHE) $(HOSTCC)
318 HOSTCXX := $(CCACHE) $(HOSTCXX)
319 endif
320
321 # Scripts in support/ or post-build scripts may need to reference
322 # these locations, so export them so it is easier to use
323 export BUILDROOT_CONFIG
324 export TARGET_DIR
325 export STAGING_DIR
326 export HOST_DIR
327 export BINARIES_DIR
328 export BASE_DIR
329
330 ################################################################################
331 #
332 # You should probably leave this stuff alone unless you know
333 # what you are doing.
334 #
335 ################################################################################
336
337 all: world
338
339 # Include legacy before the other things, because package .mk files
340 # may rely on it.
341 ifneq ($(BR2_DEPRECATED),y)
342 include Makefile.legacy
343 endif
344
345 include package/Makefile.in
346 include support/dependencies/dependencies.mk
347
348 # We also need the various per-package makefiles, which also add
349 # each selected package to TARGETS if that package was selected
350 # in the .config file.
351 include toolchain/helpers.mk
352 include toolchain/*/*.mk
353
354 # Include the package override file if one has been provided in the
355 # configuration.
356 PACKAGE_OVERRIDE_FILE=$(call qstrip,$(BR2_PACKAGE_OVERRIDE_FILE))
357 ifneq ($(PACKAGE_OVERRIDE_FILE),)
358 -include $(PACKAGE_OVERRIDE_FILE)
359 endif
360
361 include $(sort $(wildcard package/*/*.mk))
362
363 include boot/common.mk
364 include linux/linux.mk
365 include system/system.mk
366
367 TARGETS+=target-finalize
368
369 ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
370 TARGETS+=target-purgelocales
371 endif
372
373 ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
374 ifneq ($(GENERATE_LOCALE),)
375 TARGETS+=target-generatelocales
376 endif
377 endif
378
379 ifeq ($(BR2_ECLIPSE_REGISTER),y)
380 TARGETS+=toolchain-eclipse-register
381 endif
382
383 include fs/common.mk
384
385 TARGETS+=target-post-image
386
387 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS) $(BASE_TARGETS))
388 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
389 TARGETS_ALL:=$(patsubst %,__real_tgt_%,$(TARGETS))
390
391 # host-* dependencies have to be handled specially, as those aren't
392 # visible in Kconfig and hence not added to a variable like TARGETS.
393 # instead, find all the host-* targets listed in each <PKG>_DEPENDENCIES
394 # variable for each enabled target.
395 # Notice: this only works for newstyle gentargets/autotargets packages
396 TARGETS_HOST_DEPS = $(sort $(filter host-%,$(foreach dep,\
397                 $(addsuffix _DEPENDENCIES,$(call UPPERCASE,$(TARGETS))),\
398                 $($(dep)))))
399 # Host packages can in turn have their own dependencies. Likewise find
400 # all the package names listed in the HOST_<PKG>_DEPENDENCIES for each
401 # host package found above. Ideally this should be done recursively until
402 # no more packages are found, but that's hard to do in make, so limit to
403 # 1 level for now.
404 HOST_DEPS = $(sort $(foreach dep,\
405                 $(addsuffix _DEPENDENCIES,$(call UPPERCASE,$(TARGETS_HOST_DEPS))),\
406                 $($(dep))))
407 HOST_SOURCE += $(addsuffix -source,$(sort $(TARGETS_HOST_DEPS) $(HOST_DEPS)))
408
409 TARGETS_LEGAL_INFO:=$(patsubst %,%-legal-info,\
410                 $(TARGETS) $(BASE_TARGETS) $(TARGETS_HOST_DEPS) $(HOST_DEPS))))
411
412 # all targets depend on the crosscompiler and it's prerequisites
413 $(TARGETS_ALL): __real_tgt_%: $(BASE_TARGETS) %
414
415 dirs: $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
416         $(HOST_DIR) $(BINARIES_DIR) $(STAMP_DIR)
417
418 $(BUILD_DIR)/buildroot-config/auto.conf: $(BUILDROOT_CONFIG)
419         $(MAKE) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" silentoldconfig
420
421 prepare: $(BUILD_DIR)/buildroot-config/auto.conf
422
423 world: $(BASE_TARGETS) $(TARGETS_ALL)
424
425 .PHONY: all world toolchain dirs clean distclean source outputmakefile \
426         legal-info legal-info-prepare legal-info-clean printvars \
427         $(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
428         $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) $(TARGETS_LEGAL_INFO) \
429         $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
430         $(HOST_DIR) $(BINARIES_DIR) $(STAMP_DIR)
431
432 ################################################################################
433 #
434 # staging and target directories do NOT list these as
435 # dependencies anywhere else
436 #
437 ################################################################################
438 $(BUILD_DIR) $(HOST_DIR) $(BINARIES_DIR) $(STAMP_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST):
439         @mkdir -p $@
440
441 # We make a symlink lib32->lib or lib64->lib as appropriate
442 # MIPS64/n32 requires lib32 even though it's a 64-bit arch.
443 ifeq ($(BR2_ARCH_IS_64)$(BR2_MIPS_NABI32),y)
444 LIB_SYMLINK = lib64
445 else
446 LIB_SYMLINK = lib32
447 endif
448
449 $(STAGING_DIR):
450         @mkdir -p $(STAGING_DIR)/bin
451         @mkdir -p $(STAGING_DIR)/lib
452         @ln -snf lib $(STAGING_DIR)/$(LIB_SYMLINK)
453         @mkdir -p $(STAGING_DIR)/usr/lib
454         @ln -snf lib $(STAGING_DIR)/usr/$(LIB_SYMLINK)
455         @mkdir -p $(STAGING_DIR)/usr/include
456         @mkdir -p $(STAGING_DIR)/usr/bin
457         @ln -snf $(STAGING_DIR) $(BASE_DIR)/staging
458
459 ifeq ($(BR2_ROOTFS_SKELETON_CUSTOM),y)
460 TARGET_SKELETON=$(BR2_ROOTFS_SKELETON_CUSTOM_PATH)
461 endif
462
463 RSYNC_VCS_EXCLUSIONS = \
464         --exclude .svn --exclude .git --exclude .hg --exclude .bzr \
465         --exclude CVS
466
467 $(BUILD_DIR)/.root:
468         mkdir -p $(TARGET_DIR)
469         rsync -a $(RSYNC_VCS_EXCLUSIONS) \
470                 --exclude .empty --exclude '*~' \
471                 $(TARGET_SKELETON)/ $(TARGET_DIR)/
472         cp support/misc/target-dir-warning.txt $(TARGET_DIR_WARNING_FILE)
473         @ln -snf lib $(TARGET_DIR)/$(LIB_SYMLINK)
474         @mkdir -p $(TARGET_DIR)/usr
475         @ln -snf lib $(TARGET_DIR)/usr/$(LIB_SYMLINK)
476         touch $@
477
478 $(TARGET_DIR): $(BUILD_DIR)/.root
479
480 STRIP_FIND_CMD = find $(TARGET_DIR)
481 ifneq (,$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)))
482 STRIP_FIND_CMD += \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) -prune -o
483 endif
484 STRIP_FIND_CMD += -type f -perm /111
485 STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print
486
487 target-finalize:
488         rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
489                 $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
490                 $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake
491         find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
492         find $(TARGET_DIR)/lib \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
493         find $(TARGET_DIR)/usr/lib \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
494 ifneq ($(BR2_PACKAGE_GDB),y)
495         rm -rf $(TARGET_DIR)/usr/share/gdb
496 endif
497 ifneq ($(BR2_HAVE_DOCUMENTATION),y)
498         rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
499         rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
500         rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
501         rm -rf $(TARGET_DIR)/usr/share/gtk-doc
502         -rmdir $(TARGET_DIR)/usr/share 2>/dev/null
503 endif
504 ifeq ($(BR2_PACKAGE_PYTHON_PY_ONLY),y)
505         find $(TARGET_DIR)/usr/lib/ -name '*.pyc' -print0 | xargs -0 rm -f
506 endif
507 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY),y)
508         find $(TARGET_DIR)/usr/lib/ -name '*.py' -print0 | xargs -0 rm -f
509 endif
510         $(STRIP_FIND_CMD) | xargs $(STRIPCMD) 2>/dev/null || true
511         if test -d $(TARGET_DIR)/lib/modules; then \
512                 find $(TARGET_DIR)/lib/modules -type f -name '*.ko' | \
513                 xargs -r $(KSTRIPCMD); fi
514
515 # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
516 # besides the one in which crash occurred; or SIGTRAP kills my program when
517 # I set a breakpoint"
518 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
519         find $(TARGET_DIR)/lib -type f -name 'libpthread*.so*' | \
520                 xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
521 endif
522
523         mkdir -p $(TARGET_DIR)/etc
524         # Mandatory configuration file and auxilliary cache directory
525         # for recent versions of ldconfig
526         touch $(TARGET_DIR)/etc/ld.so.conf
527         mkdir -p $(TARGET_DIR)/var/cache/ldconfig
528         if [ -x "$(TARGET_CROSS)ldconfig" ]; \
529         then \
530                 $(TARGET_CROSS)ldconfig -r $(TARGET_DIR); \
531         else \
532                 /sbin/ldconfig -r $(TARGET_DIR); \
533         fi
534         ( \
535                 echo "NAME=Buildroot"; \
536                 echo "VERSION=$(BR2_VERSION_FULL)"; \
537                 echo "ID=buildroot"; \
538                 echo "VERSION_ID=$(BR2_VERSION)"; \
539                 echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
540         ) >  $(TARGET_DIR)/etc/os-release
541
542         @$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
543                 $(call MESSAGE,"Copying overlay $(d)"); \
544                 rsync -a $(RSYNC_VCS_EXCLUSIONS) \
545                         --exclude .empty --exclude '*~' \
546                         $(d)/ $(TARGET_DIR)$(sep))
547
548         @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
549                 $(call MESSAGE,"Executing post-build script $(s)"); \
550                 $(USER_HOOKS_EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
551
552 ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
553 LOCALE_WHITELIST=$(BUILD_DIR)/locales.nopurge
554 LOCALE_NOPURGE=$(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
555
556 target-purgelocales:
557         rm -f $(LOCALE_WHITELIST)
558         for i in $(LOCALE_NOPURGE); do echo $$i >> $(LOCALE_WHITELIST); done
559
560         for dir in $(wildcard $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/man /usr/share/man)); \
561         do \
562                 for lang in $$(cd $$dir; ls .|grep -v man); \
563                 do \
564                         grep -qx $$lang $(LOCALE_WHITELIST) || rm -rf $$dir/$$lang; \
565                 done; \
566         done
567 endif
568
569 ifneq ($(GENERATE_LOCALE),)
570 # Generate locale data. Basically, we call the localedef program
571 # (built by the host-localedef package) for each locale. The input
572 # data comes preferably from the toolchain, or if the toolchain does
573 # not have them (Linaro toolchains), we use the ones available on the
574 # host machine.
575 target-generatelocales: host-localedef
576         $(Q)mkdir -p $(TARGET_DIR)/usr/lib/locale/
577         $(Q)for locale in $(GENERATE_LOCALE) ; do \
578                 inputfile=`echo $${locale} | cut -f1 -d'.'` ; \
579                 charmap=`echo $${locale} | cut -f2 -d'.' -s` ; \
580                 if test -z "$${charmap}" ; then \
581                         charmap="UTF-8" ; \
582                 fi ; \
583                 echo "Generating locale $${inputfile}.$${charmap}" ; \
584                 I18NPATH=$(STAGING_DIR)/usr/share/i18n:/usr/share/i18n \
585                 $(HOST_DIR)/usr/bin/localedef \
586                         --prefix=$(TARGET_DIR) \
587                         --$(call LOWERCASE,$(BR2_ENDIAN))-endian \
588                         -i $${inputfile} -f $${charmap} \
589                         $${locale} ; \
590         done
591 endif
592
593 target-post-image:
594         @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
595                 $(call MESSAGE,"Executing post-image script $(s)"); \
596                 $(USER_HOOKS_EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
597
598 toolchain-eclipse-register:
599         ./support/scripts/eclipse-register-toolchain `readlink -f $(O)` $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
600
601 source: dirs $(TARGETS_SOURCE) $(HOST_SOURCE)
602
603 external-deps:
604         @$(MAKE) -Bs DL_MODE=SHOW_EXTERNAL_DEPS $(EXTRAMAKEARGS) source | sort -u
605
606 legal-info-clean:
607         @rm -fr $(LEGAL_INFO_DIR)
608
609 legal-info-prepare: $(LEGAL_INFO_DIR)
610         @$(call MESSAGE,"Collecting legal info")
611         @$(call legal-license-file,buildroot,COPYING,COPYING,HOST)
612         @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,TARGET)
613         @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,HOST)
614         @$(call legal-manifest,buildroot,$(BR2_VERSION_FULL),GPLv2+,COPYING,not saved,HOST)
615         @$(call legal-warning,the Buildroot source code has not been saved)
616         @$(call legal-warning,the toolchain has not been saved)
617         @cp $(BUILDROOT_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
618
619 legal-info: dirs legal-info-clean legal-info-prepare $(TARGETS_LEGAL_INFO) \
620                 $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST)
621         @cat support/legal-info/README.header >>$(LEGAL_REPORT)
622         @if [ -r $(LEGAL_WARNINGS) ]; then \
623                 cat support/legal-info/README.warnings-header \
624                         $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \
625                 cat $(LEGAL_WARNINGS); fi
626         @echo "Legal info produced in $(LEGAL_INFO_DIR)"
627         @rm -f $(LEGAL_WARNINGS)
628
629 show-targets:
630         @echo $(TARGETS)
631
632 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
633
634 all: menuconfig
635
636 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
637
638 # configuration
639 # ---------------------------------------------------------------------------
640
641 HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
642 export HOSTCFLAGS
643
644 $(BUILD_DIR)/buildroot-config/%onf:
645         mkdir -p $(@D)/lxdialog
646         $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
647
648 DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
649
650 # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
651 # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
652 COMMON_CONFIG_ENV = \
653         BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \
654         KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
655         KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
656         KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
657         BUILDROOT_CONFIG=$(BUILDROOT_CONFIG) \
658         BR2_EXTERNAL=$(BR2_EXTERNAL)
659
660 xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
661         @mkdir -p $(BUILD_DIR)/buildroot-config
662         @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
663
664 gconfig: $(BUILD_DIR)/buildroot-config/gconf outputmakefile
665         @mkdir -p $(BUILD_DIR)/buildroot-config
666         @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
667
668 menuconfig: $(BUILD_DIR)/buildroot-config/mconf outputmakefile
669         @mkdir -p $(BUILD_DIR)/buildroot-config
670         @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
671
672 nconfig: $(BUILD_DIR)/buildroot-config/nconf outputmakefile
673         @mkdir -p $(BUILD_DIR)/buildroot-config
674         @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
675
676 config: $(BUILD_DIR)/buildroot-config/conf outputmakefile
677         @mkdir -p $(BUILD_DIR)/buildroot-config
678         @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
679
680 oldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
681         mkdir -p $(BUILD_DIR)/buildroot-config
682         @$(COMMON_CONFIG_ENV) $< --oldconfig $(CONFIG_CONFIG_IN)
683
684 randconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
685         @mkdir -p $(BUILD_DIR)/buildroot-config
686         @$(COMMON_CONFIG_ENV) $< --randconfig $(CONFIG_CONFIG_IN)
687
688 allyesconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
689         @mkdir -p $(BUILD_DIR)/buildroot-config
690         @$(COMMON_CONFIG_ENV) $< --allyesconfig $(CONFIG_CONFIG_IN)
691
692 allnoconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
693         @mkdir -p $(BUILD_DIR)/buildroot-config
694         @$(COMMON_CONFIG_ENV) $< --allnoconfig $(CONFIG_CONFIG_IN)
695
696 randpackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
697         @mkdir -p $(BUILD_DIR)/buildroot-config
698         @grep -v BR2_PACKAGE_ $(BUILDROOT_CONFIG) > $(CONFIG_DIR)/.config.nopkg
699         @grep '^config BR2_PACKAGE_' Config.in.legacy | \
700                 while read config pkg; do \
701                 echo "# $$pkg is not set" >> $(CONFIG_DIR)/.config.nopkg; done
702         @$(COMMON_CONFIG_ENV) \
703                 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
704                 $< --randconfig $(CONFIG_CONFIG_IN)
705         @rm -f $(CONFIG_DIR)/.config.nopkg
706
707 allyespackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
708         @mkdir -p $(BUILD_DIR)/buildroot-config
709         @grep -v BR2_PACKAGE_ $(BUILDROOT_CONFIG) > $(CONFIG_DIR)/.config.nopkg
710         @grep '^config BR2_PACKAGE_' Config.in.legacy | \
711                 while read config pkg; do \
712                 echo "# $$pkg is not set" >> $(CONFIG_DIR)/.config.nopkg; done
713         @$(COMMON_CONFIG_ENV) \
714                 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
715                 $< --allyesconfig $(CONFIG_CONFIG_IN)
716         @rm -f $(CONFIG_DIR)/.config.nopkg
717
718 allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
719         @mkdir -p $(BUILD_DIR)/buildroot-config
720         @grep -v BR2_PACKAGE_ $(BUILDROOT_CONFIG) > $(CONFIG_DIR)/.config.nopkg
721         @$(COMMON_CONFIG_ENV) \
722                 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
723                 $< --allnoconfig $(CONFIG_CONFIG_IN)
724         @rm -f $(CONFIG_DIR)/.config.nopkg
725
726 silentoldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
727         @mkdir -p $(BUILD_DIR)/buildroot-config
728         $(COMMON_CONFIG_ENV) $< --silentoldconfig $(CONFIG_CONFIG_IN)
729
730 olddefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
731         @mkdir -p $(BUILD_DIR)/buildroot-config
732         $(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN)
733
734 defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
735         @mkdir -p $(BUILD_DIR)/buildroot-config
736         @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
737
738 %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(TOPDIR)/configs/%_defconfig outputmakefile
739         @mkdir -p $(BUILD_DIR)/buildroot-config
740         @$(COMMON_CONFIG_ENV) $< --defconfig=$(TOPDIR)/configs/$@ $(CONFIG_CONFIG_IN)
741
742 savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
743         @mkdir -p $(BUILD_DIR)/buildroot-config
744         @$(COMMON_CONFIG_ENV) $< \
745                 --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
746                 $(CONFIG_CONFIG_IN)
747
748 # check if download URLs are outdated
749 source-check:
750         $(MAKE) DL_MODE=SOURCE_CHECK $(EXTRAMAKEARGS) source
751
752 .PHONY: defconfig savedefconfig
753
754 ################################################################################
755 #
756 # Cleanup and misc junk
757 #
758 ################################################################################
759
760 # outputmakefile generates a Makefile in the output directory, if using a
761 # separate output directory. This allows convenient use of make in the
762 # output directory.
763 outputmakefile:
764 ifeq ($(NEED_WRAPPER),y)
765         $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
766 endif
767
768 # printvars prints all the variables currently defined in our Makefiles
769 printvars:
770         @$(foreach V, \
771                 $(sort $(.VARIABLES)), \
772                 $(if $(filter-out environment% default automatic, \
773                                 $(origin $V)), \
774                 $(info $V=$($V) ($(value $V)))))
775
776 clean:
777         rm -rf $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \
778                 $(STAMP_DIR) $(BUILD_DIR) $(BASE_DIR)/staging \
779                 $(LEGAL_INFO_DIR)
780
781 distclean: clean
782 ifeq ($(DL_DIR),$(TOPDIR)/dl)
783         rm -rf $(DL_DIR)
784 endif
785 ifeq ($(O),output)
786         rm -rf $(O)
787 endif
788         rm -rf $(BUILDROOT_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/.auto.deps
789
790 help:
791         @echo 'Cleaning:'
792         @echo '  clean                  - delete all files created by build'
793         @echo '  distclean              - delete all non-source files (including .config)'
794         @echo
795         @echo 'Build:'
796         @echo '  all                    - make world'
797         @echo '  toolchain              - build toolchain'
798         @echo '  <package>-rebuild      - force recompile <package>'
799         @echo '  <package>-reconfigure  - force reconfigure <package>'
800         @echo
801         @echo 'Configuration:'
802         @echo '  menuconfig             - interactive curses-based configurator'
803         @echo '  nconfig                - interactive ncurses-based configurator'
804         @echo '  xconfig                - interactive Qt-based configurator'
805         @echo '  gconfig                - interactive GTK-based configurator'
806         @echo '  oldconfig              - resolve any unresolved symbols in .config'
807         @echo '  silentoldconfig        - Same as oldconfig, but quietly, additionally update deps'
808         @echo '  olddefconfig           - Same as silentoldconfig but sets new symbols to their default value'
809         @echo '  randconfig             - New config with random answer to all options'
810         @echo '  defconfig              - New config with default answer to all options'
811         @echo '                             BR2_DEFCONFIG, if set, is used as input'
812         @echo '  savedefconfig          - Save current config as ./defconfig (minimal config)'
813         @echo '  allyesconfig           - New config where all options are accepted with yes'
814         @echo '  allnoconfig            - New config where all options are answered with no'
815         @echo '  randpackageconfig      - New config with random answer to package options'
816         @echo '  allyespackageconfig    - New config where pkg options are accepted with yes'
817         @echo '  allnopackageconfig     - New config where package options are answered with no'
818 ifeq ($(BR2_PACKAGE_BUSYBOX),y)
819         @echo '  busybox-menuconfig     - Run BusyBox menuconfig'
820 endif
821 ifeq ($(BR2_LINUX_KERNEL),y)
822         @echo '  linux-menuconfig       - Run Linux kernel menuconfig'
823         @echo '  linux-savedefconfig    - Run Linux kernel savedefconfig'
824 endif
825 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
826         @echo '  uclibc-menuconfig      - Run uClibc menuconfig'
827 endif
828 ifeq ($(BR2_TARGET_BAREBOX),y)
829         @echo '  barebox-menuconfig     - Run barebox menuconfig'
830         @echo '  barebox-savedefconfig  - Run barebox savedefconfig'
831 endif
832         @echo
833         @echo 'Documentation:'
834         @echo '  manual                 - build manual in all formats'
835         @echo '  manual-html            - build manual in HTML'
836         @echo '  manual-split-html      - build manual in split HTML'
837         @echo '  manual-pdf             - build manual in PDF'
838         @echo '  manual-text            - build manual in text'
839         @echo '  manual-epub            - build manual in ePub'
840         @echo
841         @echo 'Miscellaneous:'
842         @echo '  source                 - download all sources needed for offline-build'
843         @echo '  source-check           - check selected packages for valid download URLs'
844         @echo '  external-deps          - list external packages used'
845         @echo '  legal-info             - generate info about license compliance'
846         @echo
847         @echo '  make V=0|1             - 0 => quiet build (default), 1 => verbose build'
848         @echo '  make O=dir             - Locate all output files in "dir", including .config'
849         @echo
850         @$(foreach b, $(sort $(notdir $(wildcard $(TOPDIR)/configs/*_defconfig))), \
851           printf "  %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
852         @echo
853         @echo 'See docs/README, or generate the Buildroot manual for further details'
854         @echo
855
856 release: OUT=buildroot-$(BR2_VERSION)
857
858 # Create release tarballs. We need to fiddle a bit to add the generated
859 # documentation to the git output
860 release:
861         git archive --format=tar --prefix=$(OUT)/ HEAD > $(OUT).tar
862         $(MAKE) O=$(OUT) manual-html manual-text manual-pdf
863         tar rf $(OUT).tar $(OUT)
864         gzip -9 -c < $(OUT).tar > $(OUT).tar.gz
865         bzip2 -9 -c < $(OUT).tar > $(OUT).tar.bz2
866         rm -rf $(OUT) $(OUT).tar
867
868 print-version:
869         @echo $(BR2_VERSION_FULL)
870
871 include docs/manual/manual.mk
872
873 .PHONY: $(noconfig_targets)
This page took 0.075036 seconds and 4 git commands to generate.