package/opencv: fix build failure on x86
[buildroot-gz.git] / Makefile
blob907a0fc34a14151c42c257f9feea6650f1d1647b
1 # Makefile for buildroot
3 # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4 # Copyright (C) 2006-2014 by the Buildroot developers <buildroot@uclibc.org>
5 # Copyright (C) 2014 by the Buildroot developers <buildroot@buildroot.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #--------------------------------------------------------------
23 # Just run 'make menuconfig', configure stuff, then run 'make'.
24 # You shouldn't need to mess with anything beyond this point...
25 #--------------------------------------------------------------
27 # This is our default rule, so must come first
28 all:
30 # Set and export the version string
31 export BR2_VERSION := 2014.11-git
33 # Check for minimal make version (note: this check will break at make 10.x)
34 MIN_MAKE_VERSION = 3.81
35 ifneq ($(firstword $(sort $(MAKE_VERSION) $(MIN_MAKE_VERSION))),$(MIN_MAKE_VERSION))
36 $(error You have make '$(MAKE_VERSION)' installed. GNU make >= $(MIN_MAKE_VERSION) is required)
37 endif
39 export HOSTARCH := $(shell uname -m | \
40 sed -e s/i.86/x86/ \
41 -e s/sun4u/sparc64/ \
42 -e s/arm.*/arm/ \
43 -e s/sa110/arm/ \
44 -e s/ppc64/powerpc64/ \
45 -e s/ppc/powerpc/ \
46 -e s/macppc/powerpc/\
47 -e s/sh.*/sh/)
49 # Parallel execution of this Makefile is disabled because it changes
50 # the packages building order, that can be a problem for two reasons:
51 # - If a package has an unspecified optional dependency and that
52 # dependency is present when the package is built, it is used,
53 # otherwise it isn't (but compilation happily proceeds) so the end
54 # result will differ if the order is swapped due to parallel
55 # building.
56 # - Also changing the building order can be a problem if two packages
57 # manipulate the same file in the target directory.
59 # Taking into account the above considerations, if you still want to execute
60 # this top-level Makefile in parallel comment the ".NOTPARALLEL" line and
61 # build using the following command:
62 # make BR2_JLEVEL= -j$((`getconf _NPROCESSORS_ONLN`+1))
63 .NOTPARALLEL:
65 # absolute path
66 TOPDIR := $(shell pwd)
67 CONFIG_CONFIG_IN = Config.in
68 CONFIG = support/kconfig
69 DATE := $(shell date +%Y%m%d)
71 # Compute the full local version string so packages can use it as-is
72 # Need to export it, so it can be got from environment in children (eg. mconf)
73 export BR2_VERSION_FULL := $(BR2_VERSION)$(shell $(TOPDIR)/support/scripts/setlocalversion)
75 noconfig_targets := menuconfig nconfig gconfig xconfig config oldconfig randconfig \
76 defconfig %_defconfig allyesconfig allnoconfig silentoldconfig release \
77 randpackageconfig allyespackageconfig allnopackageconfig \
78 source-check print-version olddefconfig
80 # Strip quotes and then whitespaces
81 qstrip = $(strip $(subst ",,$(1)))
82 #"))
84 # Variables for use in Make constructs
85 comma := ,
86 empty :=
87 space := $(empty) $(empty)
89 ifneq ("$(origin O)", "command line")
90 O := output
91 CONFIG_DIR := $(TOPDIR)
92 NEED_WRAPPER =
93 else
94 # other packages might also support Linux-style out of tree builds
95 # with the O=<dir> syntax (E.G. BusyBox does). As make automatically
96 # forwards command line variable definitions those packages get very
97 # confused. Fix this by telling make to not do so
98 MAKEOVERRIDES =
99 # strangely enough O is still passed to submakes with MAKEOVERRIDES
100 # (with make 3.81 atleast), the only thing that changes is the output
101 # of the origin function (command line -> environment).
102 # Unfortunately some packages don't look at origin (E.G. uClibc 0.9.31+)
103 # To really make O go away, we have to override it.
104 override O := $(O)
105 CONFIG_DIR := $(O)
106 # we need to pass O= everywhere we call back into the toplevel makefile
107 EXTRAMAKEARGS = O=$(O)
108 NEED_WRAPPER = y
109 endif
111 # bash prints the name of the directory on 'cd <dir>' if CDPATH is
112 # set, so unset it here to not cause problems. Notice that the export
113 # line doesn't affect the environment of $(shell ..) calls, so
114 # explictly throw away any output from 'cd' here.
115 export CDPATH :=
116 BASE_DIR := $(shell mkdir -p $(O) && cd $(O) >/dev/null && pwd)
117 $(if $(BASE_DIR),, $(error output directory "$(O)" does not exist))
120 # Handling of BR2_EXTERNAL.
122 # The value of BR2_EXTERNAL is stored in .br-external in the output directory.
123 # On subsequent invocations of make, it is read in. It can still be overridden
124 # on the command line, therefore the file is re-created every time make is run.
126 # When BR2_EXTERNAL is not set, the .br-external file is removed and we point
127 # to support/dummy-external. This makes sure we can unconditionally include the
128 # Config.in and external.mk from the BR2_EXTERNAL directory. In this case,
129 # override is necessary so the user can clear BR2_EXTERNAL from the command
130 # line, but the dummy path is still used internally.
132 BR2_EXTERNAL_FILE = $(BASE_DIR)/.br-external
133 -include $(BR2_EXTERNAL_FILE)
134 ifeq ($(BR2_EXTERNAL),)
135 override BR2_EXTERNAL = support/dummy-external
136 $(shell rm -f $(BR2_EXTERNAL_FILE))
137 else
138 _BR2_EXTERNAL = $(shell cd $(BR2_EXTERNAL) >/dev/null 2>&1 && pwd)
139 ifeq ($(_BR2_EXTERNAL),)
140 $(error BR2_EXTERNAL='$(BR2_EXTERNAL)' does not exist, relative to $(TOPDIR))
141 endif
142 override BR2_EXTERNAL := $(_BR2_EXTERNAL)
143 $(shell echo BR2_EXTERNAL ?= $(BR2_EXTERNAL) > $(BR2_EXTERNAL_FILE))
144 endif
146 # To make sure the the environment variable overrides the .config option,
147 # set this before including .config.
148 ifneq ($(BR2_DL_DIR),)
149 DL_DIR := $(BR2_DL_DIR)
150 endif
153 # Need that early, before we scan packages
154 # Avoids doing the $(or...) everytime
155 BR_GRAPH_OUT := $(or $(BR2_GRAPH_OUT),pdf)
157 BUILD_DIR := $(BASE_DIR)/build
158 BINARIES_DIR := $(BASE_DIR)/images
159 TARGET_DIR := $(BASE_DIR)/target
160 # initial definition so that 'make clean' works for most users, even without
161 # .config. HOST_DIR will be overwritten later when .config is included.
162 HOST_DIR := $(BASE_DIR)/host
164 LEGAL_INFO_DIR = $(BASE_DIR)/legal-info
165 REDIST_SOURCES_DIR_TARGET = $(LEGAL_INFO_DIR)/sources
166 REDIST_SOURCES_DIR_HOST = $(LEGAL_INFO_DIR)/host-sources
167 LICENSE_FILES_DIR_TARGET = $(LEGAL_INFO_DIR)/licenses
168 LICENSE_FILES_DIR_HOST = $(LEGAL_INFO_DIR)/host-licenses
169 LEGAL_MANIFEST_CSV_TARGET = $(LEGAL_INFO_DIR)/manifest.csv
170 LEGAL_MANIFEST_CSV_HOST = $(LEGAL_INFO_DIR)/host-manifest.csv
171 LEGAL_LICENSES_TXT_TARGET = $(LEGAL_INFO_DIR)/licenses.txt
172 LEGAL_LICENSES_TXT_HOST = $(LEGAL_INFO_DIR)/host-licenses.txt
173 LEGAL_WARNINGS = $(LEGAL_INFO_DIR)/.warnings
174 LEGAL_REPORT = $(LEGAL_INFO_DIR)/README
176 BR2_CONFIG = $(CONFIG_DIR)/.config
178 # Pull in the user's configuration file
179 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
180 -include $(BR2_CONFIG)
181 endif
183 # To put more focus on warnings, be less verbose as default
184 # Use 'make V=1' to see the full commands
185 ifdef V
186 ifeq ("$(origin V)", "command line")
187 KBUILD_VERBOSE = $(V)
188 endif
189 endif
190 ifndef KBUILD_VERBOSE
191 KBUILD_VERBOSE = 0
192 endif
194 ifeq ($(KBUILD_VERBOSE),1)
195 quiet =
197 ifndef VERBOSE
198 VERBOSE = 1
199 endif
200 else
201 quiet = quiet_
202 Q = @
203 endif
205 # we want bash as shell
206 SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
207 else if [ -x /bin/bash ]; then echo /bin/bash; \
208 else echo sh; fi; fi)
210 # kconfig uses CONFIG_SHELL
211 CONFIG_SHELL := $(SHELL)
213 export SHELL CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
215 ifndef HOSTAR
216 HOSTAR := ar
217 endif
218 ifndef HOSTAS
219 HOSTAS := as
220 endif
221 ifndef HOSTCC
222 HOSTCC := gcc
223 HOSTCC := $(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
224 endif
225 HOSTCC_NOCCACHE := $(HOSTCC)
226 ifndef HOSTCXX
227 HOSTCXX := g++
228 HOSTCXX := $(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
229 endif
230 HOSTCXX_NOCCACHE := $(HOSTCXX)
231 ifndef HOSTFC
232 HOSTFC := gfortran
233 endif
234 ifndef HOSTCPP
235 HOSTCPP := cpp
236 endif
237 ifndef HOSTLD
238 HOSTLD := ld
239 endif
240 ifndef HOSTLN
241 HOSTLN := ln
242 endif
243 ifndef HOSTNM
244 HOSTNM := nm
245 endif
246 ifndef HOSTOBJCOPY
247 HOSTOBJCOPY := objcopy
248 endif
249 ifndef HOSTRANLIB
250 HOSTRANLIB := ranlib
251 endif
252 HOSTAR := $(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
253 HOSTAS := $(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
254 HOSTFC := $(shell which $(HOSTLD) || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran)
255 HOSTCPP := $(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
256 HOSTLD := $(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
257 HOSTLN := $(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
258 HOSTNM := $(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
259 HOSTOBJCOPY := $(shell which $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo objcopy)
260 HOSTRANLIB := $(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib)
262 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
263 export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
265 # Make sure pkg-config doesn't look outside the buildroot tree
266 unexport PKG_CONFIG_PATH
267 unexport PKG_CONFIG_SYSROOT_DIR
268 unexport PKG_CONFIG_LIBDIR
270 # Having DESTDIR set in the environment confuses the installation
271 # steps of some packages.
272 unexport DESTDIR
274 # Causes breakage with packages that needs host-ruby
275 unexport RUBYOPT
277 include package/pkg-utils.mk
278 include package/doc-asciidoc.mk
280 ifeq ($(BR2_HAVE_DOT_CONFIG),y)
282 ################################################################################
284 # Hide troublesome environment variables from sub processes
286 ################################################################################
287 unexport CROSS_COMPILE
288 unexport ARCH
289 unexport CC
290 unexport CXX
291 unexport CPP
292 unexport CFLAGS
293 unexport CXXFLAGS
294 unexport GREP_OPTIONS
295 unexport TAR_OPTIONS
296 unexport CONFIG_SITE
297 unexport QMAKESPEC
298 unexport TERMINFO
299 unexport MACHINE
301 GNU_HOST_NAME := $(shell support/gnuconfig/config.guess)
303 TARGETS :=
305 # silent mode requested?
306 QUIET := $(if $(findstring s,$(MAKEFLAGS)),-q)
308 # Strip off the annoying quoting
309 ARCH := $(call qstrip,$(BR2_ARCH))
311 KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
312 -e s/i.86/i386/ -e s/sun4u/sparc64/ \
313 -e s/arcle/arc/ \
314 -e s/arceb/arc/ \
315 -e s/arm.*/arm/ -e s/sa110/arm/ \
316 -e s/aarch64/arm64/ \
317 -e s/bfin/blackfin/ \
318 -e s/parisc64/parisc/ \
319 -e s/powerpc64.*/powerpc/ \
320 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
321 -e s/sh.*/sh/ \
322 -e s/microblazeel/microblaze/)
324 ZCAT := $(call qstrip,$(BR2_ZCAT))
325 BZCAT := $(call qstrip,$(BR2_BZCAT))
326 XZCAT := $(call qstrip,$(BR2_XZCAT))
327 TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
329 # packages compiled for the host go here
330 HOST_DIR := $(call qstrip,$(BR2_HOST_DIR))
332 # Quotes are needed for spaces and all in the original PATH content.
333 BR_PATH = "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(HOST_DIR)/usr/bin:$(HOST_DIR)/usr/sbin:$(PATH)"
335 TARGET_SKELETON = $(TOPDIR)/system/skeleton
337 # Location of a file giving a big fat warning that output/target
338 # should not be used as the root filesystem.
339 TARGET_DIR_WARNING_FILE = $(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
341 ifeq ($(BR2_CCACHE),y)
342 CCACHE := $(HOST_DIR)/usr/bin/ccache
343 BR_CACHE_DIR = $(call qstrip,$(BR2_CCACHE_DIR))
344 export BR_CACHE_DIR
345 HOSTCC := $(CCACHE) $(HOSTCC)
346 HOSTCXX := $(CCACHE) $(HOSTCXX)
347 endif
349 # Scripts in support/ or post-build scripts may need to reference
350 # these locations, so export them so it is easier to use
351 export BR2_CONFIG
352 export TARGET_DIR
353 export STAGING_DIR
354 export HOST_DIR
355 export BINARIES_DIR
356 export BASE_DIR
358 ################################################################################
360 # You should probably leave this stuff alone unless you know
361 # what you are doing.
363 ################################################################################
365 all: world
367 # Include legacy before the other things, because package .mk files
368 # may rely on it.
369 ifneq ($(BR2_DEPRECATED),y)
370 include Makefile.legacy
371 endif
373 include package/Makefile.in
374 include support/dependencies/dependencies.mk
376 # We also need the various per-package makefiles, which also add
377 # each selected package to TARGETS if that package was selected
378 # in the .config file.
379 include toolchain/*.mk
380 include toolchain/*/*.mk
382 # Include the package override file if one has been provided in the
383 # configuration.
384 PACKAGE_OVERRIDE_FILE = $(call qstrip,$(BR2_PACKAGE_OVERRIDE_FILE))
385 ifneq ($(PACKAGE_OVERRIDE_FILE),)
386 -include $(PACKAGE_OVERRIDE_FILE)
387 endif
389 include $(sort $(wildcard package/*/*.mk))
391 include boot/common.mk
392 include linux/linux.mk
393 include system/system.mk
394 include fs/common.mk
396 include $(BR2_EXTERNAL)/external.mk
398 TARGETS_SOURCE := $(patsubst %,%-source,$(TARGETS))
399 TARGETS_DIRCLEAN := $(patsubst %,%-dirclean,$(TARGETS))
401 # host-* dependencies have to be handled specially, as those aren't
402 # visible in Kconfig and hence not added to a variable like TARGETS.
403 # instead, find all the host-* targets listed in each <PKG>_DEPENDENCIES
404 # variable for each enabled target.
405 # Notice: this only works for newstyle gentargets/autotargets packages
406 TARGETS_HOST_DEPS = $(sort $(filter host-%,$(foreach dep,\
407 $(addsuffix _DEPENDENCIES,\
408 $(call UPPERCASE,$(TARGETS) $(TARGETS_ROOTFS))),\
409 $($(dep)))))
410 # Host packages can in turn have their own dependencies. Likewise find
411 # all the package names listed in the HOST_<PKG>_DEPENDENCIES for each
412 # host package found above. Ideally this should be done recursively until
413 # no more packages are found, but that's hard to do in make, so limit to
414 # 1 level for now.
415 HOST_DEPS = $(sort $(foreach dep,\
416 $(addsuffix _DEPENDENCIES,$(call UPPERCASE,$(TARGETS_HOST_DEPS))),\
417 $($(dep))))
418 HOST_SOURCE += $(addsuffix -source,$(sort $(TARGETS_HOST_DEPS) $(HOST_DEPS)))
420 TARGETS_LEGAL_INFO := $(patsubst %,%-legal-info,\
421 $(TARGETS) $(TARGETS_HOST_DEPS) $(HOST_DEPS))
423 dirs: $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
424 $(HOST_DIR) $(BINARIES_DIR)
426 $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG)
427 $(MAKE1) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" silentoldconfig
429 prepare: $(BUILD_DIR)/buildroot-config/auto.conf
431 world: target-post-image
433 .PHONY: all world toolchain dirs clean distclean source outputmakefile \
434 legal-info legal-info-prepare legal-info-clean printvars \
435 target-finalize target-post-image \
436 $(TARGETS) $(TARGETS_ROOTFS) \
437 $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) $(TARGETS_LEGAL_INFO) \
438 $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
439 $(HOST_DIR) $(BINARIES_DIR)
441 ################################################################################
443 # staging and target directories do NOT list these as
444 # dependencies anywhere else
446 ################################################################################
447 $(BUILD_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST):
448 @mkdir -p $@
450 # We make a symlink lib32->lib or lib64->lib as appropriate
451 # MIPS64/n32 requires lib32 even though it's a 64-bit arch.
452 ifeq ($(BR2_ARCH_IS_64)$(BR2_MIPS_NABI32),y)
453 LIB_SYMLINK = lib64
454 else
455 LIB_SYMLINK = lib32
456 endif
458 $(STAGING_DIR):
459 @mkdir -p $(STAGING_DIR)/bin
460 @mkdir -p $(STAGING_DIR)/lib
461 @ln -snf lib $(STAGING_DIR)/$(LIB_SYMLINK)
462 @mkdir -p $(STAGING_DIR)/usr/lib
463 @ln -snf lib $(STAGING_DIR)/usr/$(LIB_SYMLINK)
464 @mkdir -p $(STAGING_DIR)/usr/include
465 @mkdir -p $(STAGING_DIR)/usr/bin
466 @ln -snf $(STAGING_DIR) $(BASE_DIR)/staging
468 ifeq ($(BR2_ROOTFS_SKELETON_CUSTOM),y)
469 TARGET_SKELETON = $(BR2_ROOTFS_SKELETON_CUSTOM_PATH)
470 endif
472 RSYNC_VCS_EXCLUSIONS = \
473 --exclude .svn --exclude .git --exclude .hg --exclude .bzr \
474 --exclude CVS
476 $(BUILD_DIR)/.root:
477 mkdir -p $(TARGET_DIR)
478 rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
479 --chmod=Du+w --exclude .empty --exclude '*~' \
480 $(TARGET_SKELETON)/ $(TARGET_DIR)/
481 $(INSTALL) -m 0644 support/misc/target-dir-warning.txt $(TARGET_DIR_WARNING_FILE)
482 @ln -snf lib $(TARGET_DIR)/$(LIB_SYMLINK)
483 @mkdir -p $(TARGET_DIR)/usr
484 @ln -snf lib $(TARGET_DIR)/usr/$(LIB_SYMLINK)
485 touch $@
487 $(TARGET_DIR): $(BUILD_DIR)/.root
489 STRIP_FIND_CMD = find $(TARGET_DIR)
490 ifneq (,$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)))
491 STRIP_FIND_CMD += \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) -prune -o
492 endif
493 STRIP_FIND_CMD += -type f \( -perm /111 -o -name '*.so*' \)
494 # file exclusions:
495 # - libpthread.so: a non-stripped libpthread shared library is needed for
496 # proper debugging of pthread programs using gdb.
497 # - kernel modules (*.ko): do not function properly when stripped like normal
498 # applications and libraries. Normally kernel modules are already excluded
499 # by the executable permission check above, so the explicit exclusion is only
500 # done for kernel modules with incorrect permissions.
501 STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* *.ko $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print
503 ifeq ($(BR2_ECLIPSE_REGISTER),y)
504 define TOOLCHAIN_ECLIPSE_REGISTER
505 ./support/scripts/eclipse-register-toolchain `readlink -f $(O)` \
506 $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
507 endef
508 TARGET_FINALIZE_HOOKS += TOOLCHAIN_ECLIPSE_REGISTER
509 endif
511 # Generate locale data. Basically, we call the localedef program
512 # (built by the host-localedef package) for each locale. The input
513 # data comes preferably from the toolchain, or if the toolchain does
514 # not have them (Linaro toolchains), we use the ones available on the
515 # host machine.
516 ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
517 GENERATE_LOCALE = $(call qstrip,$(BR2_GENERATE_LOCALE))
518 ifneq ($(GENERATE_LOCALE),)
519 TARGETS += host-localedef
521 define GENERATE_LOCALES
522 $(Q)mkdir -p $(TARGET_DIR)/usr/lib/locale/
523 $(Q)for locale in $(GENERATE_LOCALE) ; do \
524 inputfile=`echo $${locale} | cut -f1 -d'.'` ; \
525 charmap=`echo $${locale} | cut -f2 -d'.' -s` ; \
526 if test -z "$${charmap}" ; then \
527 charmap="UTF-8" ; \
528 fi ; \
529 echo "Generating locale $${inputfile}.$${charmap}" ; \
530 I18NPATH=$(STAGING_DIR)/usr/share/i18n:/usr/share/i18n \
531 $(HOST_DIR)/usr/bin/localedef \
532 --prefix=$(TARGET_DIR) \
533 --$(call LOWERCASE,$(BR2_ENDIAN))-endian \
534 -i $${inputfile} -f $${charmap} \
535 $${locale} ; \
536 done
537 endef
538 TARGET_FINALIZE_HOOKS += GENERATE_LOCALES
539 endif
540 endif
542 ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
543 LOCALE_WHITELIST = $(BUILD_DIR)/locales.nopurge
544 LOCALE_NOPURGE = $(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
546 define PURGE_LOCALES
547 rm -f $(LOCALE_WHITELIST)
548 for i in $(LOCALE_NOPURGE) locale-archive; do echo $$i >> $(LOCALE_WHITELIST); done
550 for dir in $(wildcard $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/man /usr/share/man /usr/lib/locale)); \
551 do \
552 for lang in $$(cd $$dir; ls .|grep -v man); \
553 do \
554 grep -qx $$lang $(LOCALE_WHITELIST) || rm -rf $$dir/$$lang; \
555 done; \
556 done
557 endef
558 TARGET_FINALIZE_HOOKS += PURGE_LOCALES
559 endif
561 $(TARGETS_ROOTFS): target-finalize
563 target-finalize: $(TARGETS)
564 @$(call MESSAGE,"Finalizing target directory")
565 $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
566 rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
567 $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
568 $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake
569 find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
570 find $(TARGET_DIR)/lib \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
571 find $(TARGET_DIR)/usr/lib \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
572 ifneq ($(BR2_PACKAGE_GDB),y)
573 rm -rf $(TARGET_DIR)/usr/share/gdb
574 endif
575 rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
576 rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
577 rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
578 rm -rf $(TARGET_DIR)/usr/share/gtk-doc
579 -rmdir $(TARGET_DIR)/usr/share 2>/dev/null
580 $(STRIP_FIND_CMD) | xargs $(STRIPCMD) 2>/dev/null || true
581 if test -d $(TARGET_DIR)/lib/modules; then \
582 find $(TARGET_DIR)/lib/modules -type f -name '*.ko' | \
583 xargs -r $(KSTRIPCMD); fi
585 # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
586 # besides the one in which crash occurred; or SIGTRAP kills my program when
587 # I set a breakpoint"
588 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
589 find $(TARGET_DIR)/lib -type f -name 'libpthread*.so*' | \
590 xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
591 endif
593 mkdir -p $(TARGET_DIR)/etc
594 # Mandatory configuration file and auxilliary cache directory
595 # for recent versions of ldconfig
596 touch $(TARGET_DIR)/etc/ld.so.conf
597 mkdir -p $(TARGET_DIR)/var/cache/ldconfig
598 if [ -x "$(TARGET_CROSS)ldconfig" ]; \
599 then \
600 $(TARGET_CROSS)ldconfig -r $(TARGET_DIR); \
601 else \
602 /sbin/ldconfig -r $(TARGET_DIR); \
605 echo "NAME=Buildroot"; \
606 echo "VERSION=$(BR2_VERSION_FULL)"; \
607 echo "ID=buildroot"; \
608 echo "VERSION_ID=$(BR2_VERSION)"; \
609 echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
610 ) > $(TARGET_DIR)/etc/os-release
612 @$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
613 $(call MESSAGE,"Copying overlay $(d)"); \
614 rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
615 --chmod=Du+w --exclude .empty --exclude '*~' \
616 $(d)/ $(TARGET_DIR)$(sep))
618 @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
619 $(call MESSAGE,"Executing post-build script $(s)"); \
620 $(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
622 target-post-image: $(TARGETS_ROOTFS) target-finalize
623 @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
624 $(call MESSAGE,"Executing post-image script $(s)"); \
625 $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
627 source: $(TARGETS_SOURCE) $(HOST_SOURCE)
629 external-deps:
630 @$(MAKE1) -Bs DL_MODE=SHOW_EXTERNAL_DEPS $(EXTRAMAKEARGS) source | sort -u
632 legal-info-clean:
633 @rm -fr $(LEGAL_INFO_DIR)
635 legal-info-prepare: $(LEGAL_INFO_DIR)
636 @$(call MESSAGE,"Collecting legal info")
637 @$(call legal-license-file,buildroot,COPYING,COPYING,HOST)
638 @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,TARGET)
639 @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,HOST)
640 @$(call legal-manifest,buildroot,$(BR2_VERSION_FULL),GPLv2+,COPYING,not saved,not saved,HOST)
641 @$(call legal-warning,the Buildroot source code has not been saved)
642 @$(call legal-warning,the toolchain has not been saved)
643 @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
645 legal-info: dirs legal-info-clean legal-info-prepare $(TARGETS_LEGAL_INFO) \
646 $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST)
647 @cat support/legal-info/README.header >>$(LEGAL_REPORT)
648 @if [ -r $(LEGAL_WARNINGS) ]; then \
649 cat support/legal-info/README.warnings-header \
650 $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \
651 cat $(LEGAL_WARNINGS); fi
652 @echo "Legal info produced in $(LEGAL_INFO_DIR)"
653 @rm -f $(LEGAL_WARNINGS)
655 show-targets:
656 @echo $(HOST_DEPS) $(TARGETS_HOST_DEPS) $(TARGETS) $(TARGETS_ROOTFS)
658 graph-build: $(O)/build/build-time.log
659 @install -d $(O)/graphs
660 $(foreach o,name build duration,./support/scripts/graph-build-time \
661 --type=histogram --order=$(o) --input=$(<) \
662 --output=$(O)/graphs/build.hist-$(o).$(BR_GRAPH_OUT) \
663 $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
664 $(foreach t,packages steps,./support/scripts/graph-build-time \
665 --type=pie-$(t) --input=$(<) \
666 --output=$(O)/graphs/build.pie-$(t).$(BR_GRAPH_OUT) \
667 $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
669 graph-depends-requirements:
670 @dot -? >/dev/null 2>&1 || \
671 { echo "ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit 1; }
673 graph-depends: graph-depends-requirements
674 @$(INSTALL) -d $(O)/graphs
675 @cd "$(CONFIG_DIR)"; \
676 $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \
677 |tee $(BASE_DIR)/graphs/$(@).dot \
678 |dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) -o $(BASE_DIR)/graphs/$(@).$(BR_GRAPH_OUT)
680 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
682 all: menuconfig
684 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
686 # configuration
687 # ---------------------------------------------------------------------------
689 HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
690 export HOSTCFLAGS
692 $(BUILD_DIR)/buildroot-config/%onf:
693 mkdir -p $(@D)/lxdialog
694 $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
696 DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
698 # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
699 # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
700 COMMON_CONFIG_ENV = \
701 BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \
702 KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
703 KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
704 KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
705 BR2_CONFIG=$(BR2_CONFIG) \
706 BR2_EXTERNAL=$(BR2_EXTERNAL)
708 xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
709 @mkdir -p $(BUILD_DIR)/buildroot-config
710 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
712 gconfig: $(BUILD_DIR)/buildroot-config/gconf outputmakefile
713 @mkdir -p $(BUILD_DIR)/buildroot-config
714 @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
716 menuconfig: $(BUILD_DIR)/buildroot-config/mconf outputmakefile
717 @mkdir -p $(BUILD_DIR)/buildroot-config
718 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
720 nconfig: $(BUILD_DIR)/buildroot-config/nconf outputmakefile
721 @mkdir -p $(BUILD_DIR)/buildroot-config
722 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
724 config: $(BUILD_DIR)/buildroot-config/conf outputmakefile
725 @mkdir -p $(BUILD_DIR)/buildroot-config
726 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
728 oldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
729 mkdir -p $(BUILD_DIR)/buildroot-config
730 @$(COMMON_CONFIG_ENV) $< --oldconfig $(CONFIG_CONFIG_IN)
732 randconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
733 @mkdir -p $(BUILD_DIR)/buildroot-config
734 @$(COMMON_CONFIG_ENV) $< --randconfig $(CONFIG_CONFIG_IN)
736 allyesconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
737 @mkdir -p $(BUILD_DIR)/buildroot-config
738 @$(COMMON_CONFIG_ENV) $< --allyesconfig $(CONFIG_CONFIG_IN)
740 allnoconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
741 @mkdir -p $(BUILD_DIR)/buildroot-config
742 @$(COMMON_CONFIG_ENV) $< --allnoconfig $(CONFIG_CONFIG_IN)
744 randpackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
745 @mkdir -p $(BUILD_DIR)/buildroot-config
746 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
747 @grep '^config BR2_PACKAGE_' Config.in.legacy | \
748 while read config pkg; do \
749 echo "# $$pkg is not set" >> $(CONFIG_DIR)/.config.nopkg; done
750 @$(COMMON_CONFIG_ENV) \
751 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
752 $< --randconfig $(CONFIG_CONFIG_IN)
753 @rm -f $(CONFIG_DIR)/.config.nopkg
755 allyespackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
756 @mkdir -p $(BUILD_DIR)/buildroot-config
757 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
758 @grep '^config BR2_PACKAGE_' Config.in.legacy | \
759 while read config pkg; do \
760 echo "# $$pkg is not set" >> $(CONFIG_DIR)/.config.nopkg; done
761 @$(COMMON_CONFIG_ENV) \
762 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
763 $< --allyesconfig $(CONFIG_CONFIG_IN)
764 @rm -f $(CONFIG_DIR)/.config.nopkg
766 allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
767 @mkdir -p $(BUILD_DIR)/buildroot-config
768 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
769 @$(COMMON_CONFIG_ENV) \
770 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
771 $< --allnoconfig $(CONFIG_CONFIG_IN)
772 @rm -f $(CONFIG_DIR)/.config.nopkg
774 silentoldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
775 @mkdir -p $(BUILD_DIR)/buildroot-config
776 $(COMMON_CONFIG_ENV) $< --silentoldconfig $(CONFIG_CONFIG_IN)
778 olddefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
779 @mkdir -p $(BUILD_DIR)/buildroot-config
780 $(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN)
782 defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
783 @mkdir -p $(BUILD_DIR)/buildroot-config
784 @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
786 %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(TOPDIR)/configs/%_defconfig outputmakefile
787 @mkdir -p $(BUILD_DIR)/buildroot-config
788 @$(COMMON_CONFIG_ENV) $< --defconfig=$(TOPDIR)/configs/$@ $(CONFIG_CONFIG_IN)
790 %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(BR2_EXTERNAL)/configs/%_defconfig outputmakefile
791 @mkdir -p $(BUILD_DIR)/buildroot-config
792 @$(COMMON_CONFIG_ENV) $< --defconfig=$(BR2_EXTERNAL)/configs/$@ $(CONFIG_CONFIG_IN)
794 savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
795 @mkdir -p $(BUILD_DIR)/buildroot-config
796 @$(COMMON_CONFIG_ENV) $< \
797 --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
798 $(CONFIG_CONFIG_IN)
800 # check if download URLs are outdated
801 source-check:
802 $(MAKE1) DL_MODE=SOURCE_CHECK $(EXTRAMAKEARGS) source
804 .PHONY: defconfig savedefconfig
806 ################################################################################
808 # Cleanup and misc junk
810 ################################################################################
812 # outputmakefile generates a Makefile in the output directory, if using a
813 # separate output directory. This allows convenient use of make in the
814 # output directory.
815 outputmakefile:
816 ifeq ($(NEED_WRAPPER),y)
817 $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
818 endif
820 # printvars prints all the variables currently defined in our Makefiles
821 printvars:
822 @$(foreach V, \
823 $(sort $(.VARIABLES)), \
824 $(if $(filter-out environment% default automatic, \
825 $(origin $V)), \
826 $(info $V=$($V) ($(value $V)))))
828 clean:
829 rm -rf $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \
830 $(BUILD_DIR) $(BASE_DIR)/staging \
831 $(LEGAL_INFO_DIR)
833 distclean: clean
834 ifeq ($(DL_DIR),$(TOPDIR)/dl)
835 rm -rf $(DL_DIR)
836 endif
837 ifeq ($(O),output)
838 rm -rf $(O)
839 endif
840 rm -rf $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/.auto.deps
842 help:
843 @echo 'Cleaning:'
844 @echo ' clean - delete all files created by build'
845 @echo ' distclean - delete all non-source files (including .config)'
846 @echo
847 @echo 'Build:'
848 @echo ' all - make world'
849 @echo ' toolchain - build toolchain'
850 @echo
851 @echo 'Configuration:'
852 @echo ' menuconfig - interactive curses-based configurator'
853 @echo ' nconfig - interactive ncurses-based configurator'
854 @echo ' xconfig - interactive Qt-based configurator'
855 @echo ' gconfig - interactive GTK-based configurator'
856 @echo ' oldconfig - resolve any unresolved symbols in .config'
857 @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
858 @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
859 @echo ' randconfig - New config with random answer to all options'
860 @echo ' defconfig - New config with default answer to all options'
861 @echo ' BR2_DEFCONFIG, if set, is used as input'
862 @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
863 @echo ' allyesconfig - New config where all options are accepted with yes'
864 @echo ' allnoconfig - New config where all options are answered with no'
865 @echo ' randpackageconfig - New config with random answer to package options'
866 @echo ' allyespackageconfig - New config where pkg options are accepted with yes'
867 @echo ' allnopackageconfig - New config where package options are answered with no'
868 ifeq ($(BR2_PACKAGE_BUSYBOX),y)
869 @echo ' busybox-menuconfig - Run BusyBox menuconfig'
870 endif
871 ifeq ($(BR2_LINUX_KERNEL),y)
872 @echo ' linux-menuconfig - Run Linux kernel menuconfig'
873 @echo ' linux-savedefconfig - Run Linux kernel savedefconfig'
874 endif
875 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
876 @echo ' uclibc-menuconfig - Run uClibc menuconfig'
877 endif
878 ifeq ($(BR2_TARGET_BAREBOX),y)
879 @echo ' barebox-menuconfig - Run barebox menuconfig'
880 @echo ' barebox-savedefconfig - Run barebox savedefconfig'
881 endif
882 @echo
883 @echo 'Documentation:'
884 @echo ' manual - build manual in all formats'
885 @echo ' manual-html - build manual in HTML'
886 @echo ' manual-split-html - build manual in split HTML'
887 @echo ' manual-pdf - build manual in PDF'
888 @echo ' manual-text - build manual in text'
889 @echo ' manual-epub - build manual in ePub'
890 @echo ' graph-build - generate graphs of the build times'
891 @echo ' graph-depends - generate graph of the dependency tree'
892 @echo
893 @echo 'Miscellaneous:'
894 @echo ' source - download all sources needed for offline-build'
895 @echo ' source-check - check selected packages for valid download URLs'
896 @echo ' external-deps - list external packages used'
897 @echo ' legal-info - generate info about license compliance'
898 @echo
899 @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
900 @echo ' make O=dir - Locate all output files in "dir", including .config'
901 @echo
902 @echo 'Built-in configs:'
903 @$(foreach b, $(sort $(notdir $(wildcard $(TOPDIR)/configs/*_defconfig))), \
904 printf " %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
905 ifneq ($(wildcard $(BR2_EXTERNAL)/configs/*_defconfig),)
906 @echo
907 @echo 'User-provided configs:'
908 @$(foreach b, $(sort $(notdir $(wildcard $(BR2_EXTERNAL)/configs/*_defconfig))), \
909 printf " %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
910 endif
911 @echo
912 @echo 'For further details, see README, generate the Buildroot manual, or consult'
913 @echo 'it on-line at http://buildroot.org/docs.html'
914 @echo
916 release: OUT = buildroot-$(BR2_VERSION)
918 # Create release tarballs. We need to fiddle a bit to add the generated
919 # documentation to the git output
920 release:
921 git archive --format=tar --prefix=$(OUT)/ HEAD > $(OUT).tar
922 $(MAKE) O=$(OUT) manual-html manual-text manual-pdf
923 tar rf $(OUT).tar $(OUT)
924 gzip -9 -c < $(OUT).tar > $(OUT).tar.gz
925 bzip2 -9 -c < $(OUT).tar > $(OUT).tar.bz2
926 rm -rf $(OUT) $(OUT).tar
928 print-version:
929 @echo $(BR2_VERSION_FULL)
931 include docs/manual/manual.mk
932 -include $(BR2_EXTERNAL)/docs/*/*.mk
934 .PHONY: $(noconfig_targets)