ejabberd: new package.
[buildroot-gz.git] / Makefile
blob9c870d929b6593d4ba51609bede023d0bcd7d70f
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 := 2015.02-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 set to an empty value (e.g. explicitly in command
127 # line), the .br-external file is removed and we point to
128 # support/dummy-external. This makes sure we can unconditionally include the
129 # Config.in and external.mk from the BR2_EXTERNAL directory. In this case,
130 # override is necessary so the user can clear BR2_EXTERNAL from the command
131 # line, but the dummy path is still used internally.
133 BR2_EXTERNAL_FILE = $(BASE_DIR)/.br-external
134 -include $(BR2_EXTERNAL_FILE)
135 ifeq ($(BR2_EXTERNAL),)
136 override BR2_EXTERNAL = support/dummy-external
137 $(shell rm -f $(BR2_EXTERNAL_FILE))
138 else
139 _BR2_EXTERNAL = $(shell cd $(BR2_EXTERNAL) >/dev/null 2>&1 && pwd)
140 ifeq ($(_BR2_EXTERNAL),)
141 $(error BR2_EXTERNAL='$(BR2_EXTERNAL)' does not exist, relative to $(TOPDIR))
142 endif
143 override BR2_EXTERNAL := $(_BR2_EXTERNAL)
144 $(shell echo BR2_EXTERNAL ?= $(BR2_EXTERNAL) > $(BR2_EXTERNAL_FILE))
145 endif
147 # To make sure the the environment variable overrides the .config option,
148 # set this before including .config.
149 ifneq ($(BR2_DL_DIR),)
150 DL_DIR := $(BR2_DL_DIR)
151 endif
154 # Need that early, before we scan packages
155 # Avoids doing the $(or...) everytime
156 BR_GRAPH_OUT := $(or $(BR2_GRAPH_OUT),pdf)
158 BUILD_DIR := $(BASE_DIR)/build
159 BINARIES_DIR := $(BASE_DIR)/images
160 TARGET_DIR := $(BASE_DIR)/target
161 # initial definition so that 'make clean' works for most users, even without
162 # .config. HOST_DIR will be overwritten later when .config is included.
163 HOST_DIR := $(BASE_DIR)/host
165 LEGAL_INFO_DIR = $(BASE_DIR)/legal-info
166 REDIST_SOURCES_DIR_TARGET = $(LEGAL_INFO_DIR)/sources
167 REDIST_SOURCES_DIR_HOST = $(LEGAL_INFO_DIR)/host-sources
168 LICENSE_FILES_DIR_TARGET = $(LEGAL_INFO_DIR)/licenses
169 LICENSE_FILES_DIR_HOST = $(LEGAL_INFO_DIR)/host-licenses
170 LEGAL_MANIFEST_CSV_TARGET = $(LEGAL_INFO_DIR)/manifest.csv
171 LEGAL_MANIFEST_CSV_HOST = $(LEGAL_INFO_DIR)/host-manifest.csv
172 LEGAL_LICENSES_TXT_TARGET = $(LEGAL_INFO_DIR)/licenses.txt
173 LEGAL_LICENSES_TXT_HOST = $(LEGAL_INFO_DIR)/host-licenses.txt
174 LEGAL_WARNINGS = $(LEGAL_INFO_DIR)/.warnings
175 LEGAL_REPORT = $(LEGAL_INFO_DIR)/README
177 BR2_CONFIG = $(CONFIG_DIR)/.config
179 # Pull in the user's configuration file
180 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
181 -include $(BR2_CONFIG)
182 endif
184 # To put more focus on warnings, be less verbose as default
185 # Use 'make V=1' to see the full commands
186 ifdef V
187 ifeq ("$(origin V)", "command line")
188 KBUILD_VERBOSE = $(V)
189 endif
190 endif
191 ifndef KBUILD_VERBOSE
192 KBUILD_VERBOSE = 0
193 endif
195 ifeq ($(KBUILD_VERBOSE),1)
196 quiet =
198 ifndef VERBOSE
199 VERBOSE = 1
200 endif
201 else
202 quiet = quiet_
203 Q = @
204 endif
206 # we want bash as shell
207 SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
208 else if [ -x /bin/bash ]; then echo /bin/bash; \
209 else echo sh; fi; fi)
211 # kconfig uses CONFIG_SHELL
212 CONFIG_SHELL := $(SHELL)
214 export SHELL CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
216 ifndef HOSTAR
217 HOSTAR := ar
218 endif
219 ifndef HOSTAS
220 HOSTAS := as
221 endif
222 ifndef HOSTCC
223 HOSTCC := gcc
224 HOSTCC := $(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
225 endif
226 HOSTCC_NOCCACHE := $(HOSTCC)
227 ifndef HOSTCXX
228 HOSTCXX := g++
229 HOSTCXX := $(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
230 endif
231 HOSTCXX_NOCCACHE := $(HOSTCXX)
232 ifndef HOSTFC
233 HOSTFC := gfortran
234 endif
235 ifndef HOSTCPP
236 HOSTCPP := cpp
237 endif
238 ifndef HOSTLD
239 HOSTLD := ld
240 endif
241 ifndef HOSTLN
242 HOSTLN := ln
243 endif
244 ifndef HOSTNM
245 HOSTNM := nm
246 endif
247 ifndef HOSTOBJCOPY
248 HOSTOBJCOPY := objcopy
249 endif
250 ifndef HOSTRANLIB
251 HOSTRANLIB := ranlib
252 endif
253 HOSTAR := $(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
254 HOSTAS := $(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
255 HOSTFC := $(shell which $(HOSTLD) || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran)
256 HOSTCPP := $(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
257 HOSTLD := $(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
258 HOSTLN := $(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
259 HOSTNM := $(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
260 HOSTOBJCOPY := $(shell which $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo objcopy)
261 HOSTRANLIB := $(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib)
263 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
264 export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
266 # Make sure pkg-config doesn't look outside the buildroot tree
267 HOST_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH)
268 unexport PKG_CONFIG_PATH
269 unexport PKG_CONFIG_SYSROOT_DIR
270 unexport PKG_CONFIG_LIBDIR
272 # Having DESTDIR set in the environment confuses the installation
273 # steps of some packages.
274 unexport DESTDIR
276 # Causes breakage with packages that needs host-ruby
277 unexport RUBYOPT
279 include package/pkg-utils.mk
280 include package/doc-asciidoc.mk
282 ifeq ($(BR2_HAVE_DOT_CONFIG),y)
284 ################################################################################
286 # Hide troublesome environment variables from sub processes
288 ################################################################################
289 unexport CROSS_COMPILE
290 unexport ARCH
291 unexport CC
292 unexport CXX
293 unexport CPP
294 unexport CFLAGS
295 unexport CXXFLAGS
296 unexport GREP_OPTIONS
297 unexport TAR_OPTIONS
298 unexport CONFIG_SITE
299 unexport QMAKESPEC
300 unexport TERMINFO
301 unexport MACHINE
303 GNU_HOST_NAME := $(shell support/gnuconfig/config.guess)
305 TARGETS :=
307 # silent mode requested?
308 QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
310 # Strip off the annoying quoting
311 ARCH := $(call qstrip,$(BR2_ARCH))
313 KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
314 -e s/i.86/i386/ -e s/sun4u/sparc64/ \
315 -e s/arcle/arc/ \
316 -e s/arceb/arc/ \
317 -e s/arm.*/arm/ -e s/sa110/arm/ \
318 -e s/aarch64/arm64/ \
319 -e s/bfin/blackfin/ \
320 -e s/parisc64/parisc/ \
321 -e s/powerpc64.*/powerpc/ \
322 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
323 -e s/sh.*/sh/ \
324 -e s/microblazeel/microblaze/)
326 ZCAT := $(call qstrip,$(BR2_ZCAT))
327 BZCAT := $(call qstrip,$(BR2_BZCAT))
328 XZCAT := $(call qstrip,$(BR2_XZCAT))
329 TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
331 # packages compiled for the host go here
332 HOST_DIR := $(call qstrip,$(BR2_HOST_DIR))
334 # Quotes are needed for spaces and all in the original PATH content.
335 BR_PATH = "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(HOST_DIR)/usr/bin:$(HOST_DIR)/usr/sbin:$(PATH)"
337 TARGET_SKELETON = $(TOPDIR)/system/skeleton
339 # Location of a file giving a big fat warning that output/target
340 # should not be used as the root filesystem.
341 TARGET_DIR_WARNING_FILE = $(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
343 ifeq ($(BR2_CCACHE),y)
344 CCACHE := $(HOST_DIR)/usr/bin/ccache
345 BR_CACHE_DIR = $(call qstrip,$(BR2_CCACHE_DIR))
346 export BR_CACHE_DIR
347 HOSTCC := $(CCACHE) $(HOSTCC)
348 HOSTCXX := $(CCACHE) $(HOSTCXX)
349 endif
351 # Scripts in support/ or post-build scripts may need to reference
352 # these locations, so export them so it is easier to use
353 export BR2_CONFIG
354 export TARGET_DIR
355 export STAGING_DIR
356 export HOST_DIR
357 export BINARIES_DIR
358 export BASE_DIR
360 ################################################################################
362 # You should probably leave this stuff alone unless you know
363 # what you are doing.
365 ################################################################################
367 all: world
369 # Include legacy before the other things, because package .mk files
370 # may rely on it.
371 ifneq ($(BR2_DEPRECATED),y)
372 include Makefile.legacy
373 endif
375 include package/Makefile.in
376 include support/dependencies/dependencies.mk
378 # We also need the various per-package makefiles, which also add
379 # each selected package to TARGETS if that package was selected
380 # in the .config file.
381 include toolchain/*.mk
382 include toolchain/*/*.mk
384 # Include the package override file if one has been provided in the
385 # configuration.
386 PACKAGE_OVERRIDE_FILE = $(call qstrip,$(BR2_PACKAGE_OVERRIDE_FILE))
387 ifneq ($(PACKAGE_OVERRIDE_FILE),)
388 -include $(PACKAGE_OVERRIDE_FILE)
389 endif
391 include $(sort $(wildcard package/*/*.mk))
393 include boot/common.mk
394 include linux/linux.mk
395 include system/system.mk
396 include fs/common.mk
398 include $(BR2_EXTERNAL)/external.mk
400 TARGETS_SOURCE := $(patsubst %,%-source,$(TARGETS))
401 TARGETS_DIRCLEAN := $(patsubst %,%-dirclean,$(TARGETS))
403 # host-* dependencies have to be handled specially, as those aren't
404 # visible in Kconfig and hence not added to a variable like TARGETS.
405 # instead, find all the host-* targets listed in each <PKG>_DEPENDENCIES
406 # variable for each enabled target.
407 # Notice: this only works for newstyle gentargets/autotargets packages
408 TARGETS_HOST_DEPS = $(sort $(filter host-%,$(foreach dep,\
409 $(addsuffix _DEPENDENCIES,\
410 $(call UPPERCASE,$(TARGETS) $(TARGETS_ROOTFS))),\
411 $($(dep)))))
412 # Host packages can in turn have their own dependencies. Likewise find
413 # all the package names listed in the HOST_<PKG>_DEPENDENCIES for each
414 # host package found above. Ideally this should be done recursively until
415 # no more packages are found, but that's hard to do in make, so limit to
416 # 1 level for now.
417 HOST_DEPS = $(sort $(foreach dep,\
418 $(addsuffix _DEPENDENCIES,$(call UPPERCASE,$(TARGETS_HOST_DEPS))),\
419 $($(dep))))
420 HOST_SOURCE += $(addsuffix -source,$(sort $(TARGETS_HOST_DEPS) $(HOST_DEPS)))
422 TARGETS_LEGAL_INFO := $(patsubst %,%-legal-info,\
423 $(TARGETS) $(TARGETS_HOST_DEPS) $(HOST_DEPS))
425 dirs: $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
426 $(HOST_DIR) $(BINARIES_DIR)
428 $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG)
429 $(MAKE1) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" silentoldconfig
431 prepare: $(BUILD_DIR)/buildroot-config/auto.conf
433 world: target-post-image
435 .PHONY: all world toolchain dirs clean distclean source outputmakefile \
436 legal-info legal-info-prepare legal-info-clean printvars \
437 target-finalize target-post-image \
438 $(TARGETS) $(TARGETS_ROOTFS) \
439 $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) $(TARGETS_LEGAL_INFO) \
440 $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
441 $(HOST_DIR) $(BINARIES_DIR)
443 ################################################################################
445 # staging and target directories do NOT list these as
446 # dependencies anywhere else
448 ################################################################################
449 $(BUILD_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST):
450 @mkdir -p $@
452 # We make a symlink lib32->lib or lib64->lib as appropriate
453 # MIPS64/n32 requires lib32 even though it's a 64-bit arch.
454 ifeq ($(BR2_ARCH_IS_64)$(BR2_MIPS_NABI32),y)
455 LIB_SYMLINK = lib64
456 else
457 LIB_SYMLINK = lib32
458 endif
460 $(STAGING_DIR):
461 @mkdir -p $(STAGING_DIR)/bin
462 @mkdir -p $(STAGING_DIR)/lib
463 @ln -snf lib $(STAGING_DIR)/$(LIB_SYMLINK)
464 @mkdir -p $(STAGING_DIR)/usr/lib
465 @ln -snf lib $(STAGING_DIR)/usr/$(LIB_SYMLINK)
466 @mkdir -p $(STAGING_DIR)/usr/include
467 @mkdir -p $(STAGING_DIR)/usr/bin
468 @ln -snf $(STAGING_DIR) $(BASE_DIR)/staging
470 ifeq ($(BR2_ROOTFS_SKELETON_CUSTOM),y)
471 TARGET_SKELETON = $(BR2_ROOTFS_SKELETON_CUSTOM_PATH)
472 endif
474 RSYNC_VCS_EXCLUSIONS = \
475 --exclude .svn --exclude .git --exclude .hg --exclude .bzr \
476 --exclude CVS
478 $(BUILD_DIR)/.root:
479 mkdir -p $(TARGET_DIR)
480 rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
481 --chmod=Du+w --exclude .empty --exclude '*~' \
482 $(TARGET_SKELETON)/ $(TARGET_DIR)/
483 $(INSTALL) -m 0644 support/misc/target-dir-warning.txt $(TARGET_DIR_WARNING_FILE)
484 @ln -snf lib $(TARGET_DIR)/$(LIB_SYMLINK)
485 @mkdir -p $(TARGET_DIR)/usr
486 @ln -snf lib $(TARGET_DIR)/usr/$(LIB_SYMLINK)
487 touch $@
489 $(TARGET_DIR): $(BUILD_DIR)/.root
491 STRIP_FIND_CMD = find $(TARGET_DIR)
492 ifneq (,$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)))
493 STRIP_FIND_CMD += \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) -prune -o
494 endif
495 STRIP_FIND_CMD += -type f \( -perm /111 -o -name '*.so*' \)
496 # file exclusions:
497 # - libpthread.so: a non-stripped libpthread shared library is needed for
498 # proper debugging of pthread programs using gdb.
499 # - kernel modules (*.ko): do not function properly when stripped like normal
500 # applications and libraries. Normally kernel modules are already excluded
501 # by the executable permission check above, so the explicit exclusion is only
502 # done for kernel modules with incorrect permissions.
503 STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* *.ko $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print
505 ifeq ($(BR2_ECLIPSE_REGISTER),y)
506 define TOOLCHAIN_ECLIPSE_REGISTER
507 ./support/scripts/eclipse-register-toolchain `readlink -f $(O)` \
508 $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
509 endef
510 TARGET_FINALIZE_HOOKS += TOOLCHAIN_ECLIPSE_REGISTER
511 endif
513 # Generate locale data. Basically, we call the localedef program
514 # (built by the host-localedef package) for each locale. The input
515 # data comes preferably from the toolchain, or if the toolchain does
516 # not have them (Linaro toolchains), we use the ones available on the
517 # host machine.
518 ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
519 GLIBC_GENERATE_LOCALES = $(call qstrip,$(BR2_GENERATE_LOCALE))
520 ifneq ($(GLIBC_GENERATE_LOCALES),)
521 TARGETS += host-localedef
523 define GENERATE_GLIBC_LOCALES
524 $(Q)mkdir -p $(TARGET_DIR)/usr/lib/locale/
525 $(Q)for locale in $(GLIBC_GENERATE_LOCALES) ; do \
526 inputfile=`echo $${locale} | cut -f1 -d'.'` ; \
527 charmap=`echo $${locale} | cut -f2 -d'.' -s` ; \
528 if test -z "$${charmap}" ; then \
529 charmap="UTF-8" ; \
530 fi ; \
531 echo "Generating locale $${inputfile}.$${charmap}" ; \
532 I18NPATH=$(STAGING_DIR)/usr/share/i18n:/usr/share/i18n \
533 $(HOST_DIR)/usr/bin/localedef \
534 --prefix=$(TARGET_DIR) \
535 --$(call LOWERCASE,$(BR2_ENDIAN))-endian \
536 -i $${inputfile} -f $${charmap} \
537 $${locale} ; \
538 done
539 endef
540 TARGET_FINALIZE_HOOKS += GENERATE_GLIBC_LOCALES
541 endif
542 endif
544 ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
545 LOCALE_WHITELIST = $(BUILD_DIR)/locales.nopurge
546 LOCALE_NOPURGE = $(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
548 define PURGE_LOCALES
549 rm -f $(LOCALE_WHITELIST)
550 for i in $(LOCALE_NOPURGE) locale-archive; do echo $$i >> $(LOCALE_WHITELIST); done
552 for dir in $(wildcard $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/man /usr/share/man /usr/lib/locale)); \
553 do \
554 for lang in $$(cd $$dir; ls .|grep -v man); \
555 do \
556 grep -qx $$lang $(LOCALE_WHITELIST) || rm -rf $$dir/$$lang; \
557 done; \
558 done
559 endef
560 TARGET_FINALIZE_HOOKS += PURGE_LOCALES
561 endif
563 $(TARGETS_ROOTFS): target-finalize
565 target-finalize: $(TARGETS)
566 @$(call MESSAGE,"Finalizing target directory")
567 $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
568 rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
569 $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
570 $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake
571 find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
572 find $(TARGET_DIR)/lib \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
573 find $(TARGET_DIR)/usr/lib \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
574 ifneq ($(BR2_PACKAGE_GDB),y)
575 rm -rf $(TARGET_DIR)/usr/share/gdb
576 endif
577 rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
578 rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
579 rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
580 rm -rf $(TARGET_DIR)/usr/share/gtk-doc
581 -rmdir $(TARGET_DIR)/usr/share 2>/dev/null
582 $(STRIP_FIND_CMD) | xargs $(STRIPCMD) 2>/dev/null || true
583 if test -d $(TARGET_DIR)/lib/modules; then \
584 find $(TARGET_DIR)/lib/modules -type f -name '*.ko' | \
585 xargs -r $(KSTRIPCMD); fi
587 # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
588 # besides the one in which crash occurred; or SIGTRAP kills my program when
589 # I set a breakpoint"
590 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
591 find $(TARGET_DIR)/lib -type f -name 'libpthread*.so*' | \
592 xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
593 endif
595 mkdir -p $(TARGET_DIR)/etc
596 # Mandatory configuration file and auxilliary cache directory
597 # for recent versions of ldconfig
598 touch $(TARGET_DIR)/etc/ld.so.conf
599 mkdir -p $(TARGET_DIR)/var/cache/ldconfig
600 if [ -x "$(TARGET_CROSS)ldconfig" ]; \
601 then \
602 $(TARGET_CROSS)ldconfig -r $(TARGET_DIR); \
603 else \
604 /sbin/ldconfig -r $(TARGET_DIR); \
607 echo "NAME=Buildroot"; \
608 echo "VERSION=$(BR2_VERSION_FULL)"; \
609 echo "ID=buildroot"; \
610 echo "VERSION_ID=$(BR2_VERSION)"; \
611 echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
612 ) > $(TARGET_DIR)/etc/os-release
614 @$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
615 $(call MESSAGE,"Copying overlay $(d)"); \
616 rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
617 --chmod=Du+w --exclude .empty --exclude '*~' \
618 $(d)/ $(TARGET_DIR)$(sep))
620 @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
621 $(call MESSAGE,"Executing post-build script $(s)"); \
622 $(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
624 target-post-image: $(TARGETS_ROOTFS) target-finalize
625 @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
626 $(call MESSAGE,"Executing post-image script $(s)"); \
627 $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
629 source: $(TARGETS_SOURCE) $(HOST_SOURCE)
631 external-deps:
632 @$(MAKE1) -Bs DL_MODE=SHOW_EXTERNAL_DEPS $(EXTRAMAKEARGS) source | sort -u
634 legal-info-clean:
635 @rm -fr $(LEGAL_INFO_DIR)
637 legal-info-prepare: $(LEGAL_INFO_DIR)
638 @$(call MESSAGE,"Collecting legal info")
639 @$(call legal-license-file,buildroot,COPYING,COPYING,HOST)
640 @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,TARGET)
641 @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,HOST)
642 @$(call legal-manifest,buildroot,$(BR2_VERSION_FULL),GPLv2+,COPYING,not saved,not saved,HOST)
643 @$(call legal-warning,the Buildroot source code has not been saved)
644 @$(call legal-warning,the toolchain has not been saved)
645 @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
647 legal-info: dirs legal-info-clean legal-info-prepare $(TARGETS_LEGAL_INFO) \
648 $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST)
649 @cat support/legal-info/README.header >>$(LEGAL_REPORT)
650 @if [ -r $(LEGAL_WARNINGS) ]; then \
651 cat support/legal-info/README.warnings-header \
652 $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \
653 cat $(LEGAL_WARNINGS); fi
654 @echo "Legal info produced in $(LEGAL_INFO_DIR)"
655 @rm -f $(LEGAL_WARNINGS)
657 show-targets:
658 @echo $(HOST_DEPS) $(TARGETS_HOST_DEPS) $(TARGETS) $(TARGETS_ROOTFS)
660 graph-build: $(O)/build/build-time.log
661 @install -d $(O)/graphs
662 $(foreach o,name build duration,./support/scripts/graph-build-time \
663 --type=histogram --order=$(o) --input=$(<) \
664 --output=$(O)/graphs/build.hist-$(o).$(BR_GRAPH_OUT) \
665 $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
666 $(foreach t,packages steps,./support/scripts/graph-build-time \
667 --type=pie-$(t) --input=$(<) \
668 --output=$(O)/graphs/build.pie-$(t).$(BR_GRAPH_OUT) \
669 $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
671 graph-depends-requirements:
672 @dot -? >/dev/null 2>&1 || \
673 { echo "ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit 1; }
675 graph-depends: graph-depends-requirements
676 @$(INSTALL) -d $(O)/graphs
677 @cd "$(CONFIG_DIR)"; \
678 $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \
679 |tee $(BASE_DIR)/graphs/$(@).dot \
680 |dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) -o $(BASE_DIR)/graphs/$(@).$(BR_GRAPH_OUT)
682 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
684 all: menuconfig
686 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
688 # configuration
689 # ---------------------------------------------------------------------------
691 HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
692 export HOSTCFLAGS
694 $(BUILD_DIR)/buildroot-config/%onf:
695 mkdir -p $(@D)/lxdialog
696 PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \
697 obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
699 DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
701 # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
702 # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
703 COMMON_CONFIG_ENV = \
704 BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \
705 KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
706 KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
707 KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
708 BR2_CONFIG=$(BR2_CONFIG) \
709 BR2_EXTERNAL=$(BR2_EXTERNAL)
711 xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
712 @mkdir -p $(BUILD_DIR)/buildroot-config
713 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
715 gconfig: $(BUILD_DIR)/buildroot-config/gconf outputmakefile
716 @mkdir -p $(BUILD_DIR)/buildroot-config
717 @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
719 menuconfig: $(BUILD_DIR)/buildroot-config/mconf outputmakefile
720 @mkdir -p $(BUILD_DIR)/buildroot-config
721 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
723 nconfig: $(BUILD_DIR)/buildroot-config/nconf outputmakefile
724 @mkdir -p $(BUILD_DIR)/buildroot-config
725 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
727 config: $(BUILD_DIR)/buildroot-config/conf outputmakefile
728 @mkdir -p $(BUILD_DIR)/buildroot-config
729 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
731 oldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
732 mkdir -p $(BUILD_DIR)/buildroot-config
733 @$(COMMON_CONFIG_ENV) $< --oldconfig $(CONFIG_CONFIG_IN)
735 randconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
736 @mkdir -p $(BUILD_DIR)/buildroot-config
737 @$(COMMON_CONFIG_ENV) $< --randconfig $(CONFIG_CONFIG_IN)
739 allyesconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
740 @mkdir -p $(BUILD_DIR)/buildroot-config
741 @$(COMMON_CONFIG_ENV) $< --allyesconfig $(CONFIG_CONFIG_IN)
743 allnoconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
744 @mkdir -p $(BUILD_DIR)/buildroot-config
745 @$(COMMON_CONFIG_ENV) $< --allnoconfig $(CONFIG_CONFIG_IN)
747 randpackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
748 @mkdir -p $(BUILD_DIR)/buildroot-config
749 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
750 @grep '^config BR2_PACKAGE_' Config.in.legacy | \
751 while read config pkg; do \
752 echo "# $$pkg is not set" >> $(CONFIG_DIR)/.config.nopkg; done
753 @$(COMMON_CONFIG_ENV) \
754 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
755 $< --randconfig $(CONFIG_CONFIG_IN)
756 @rm -f $(CONFIG_DIR)/.config.nopkg
758 allyespackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
759 @mkdir -p $(BUILD_DIR)/buildroot-config
760 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
761 @grep '^config BR2_PACKAGE_' Config.in.legacy | \
762 while read config pkg; do \
763 echo "# $$pkg is not set" >> $(CONFIG_DIR)/.config.nopkg; done
764 @$(COMMON_CONFIG_ENV) \
765 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
766 $< --allyesconfig $(CONFIG_CONFIG_IN)
767 @rm -f $(CONFIG_DIR)/.config.nopkg
769 allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
770 @mkdir -p $(BUILD_DIR)/buildroot-config
771 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
772 @$(COMMON_CONFIG_ENV) \
773 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
774 $< --allnoconfig $(CONFIG_CONFIG_IN)
775 @rm -f $(CONFIG_DIR)/.config.nopkg
777 silentoldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
778 @mkdir -p $(BUILD_DIR)/buildroot-config
779 $(COMMON_CONFIG_ENV) $< --silentoldconfig $(CONFIG_CONFIG_IN)
781 olddefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
782 @mkdir -p $(BUILD_DIR)/buildroot-config
783 $(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN)
785 defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
786 @mkdir -p $(BUILD_DIR)/buildroot-config
787 @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
789 # Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig
790 %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(TOPDIR)/configs/%_defconfig outputmakefile
791 @mkdir -p $(BUILD_DIR)/buildroot-config
792 @$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(TOPDIR)/configs/$@ \
793 $< --defconfig=$(TOPDIR)/configs/$@ $(CONFIG_CONFIG_IN)
795 %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(BR2_EXTERNAL)/configs/%_defconfig outputmakefile
796 @mkdir -p $(BUILD_DIR)/buildroot-config
797 @$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(BR2_EXTERNAL)/configs/$@ \
798 $< --defconfig=$(BR2_EXTERNAL)/configs/$@ $(CONFIG_CONFIG_IN)
800 savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
801 @mkdir -p $(BUILD_DIR)/buildroot-config
802 @$(COMMON_CONFIG_ENV) $< \
803 --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
804 $(CONFIG_CONFIG_IN)
806 # check if download URLs are outdated
807 source-check:
808 $(MAKE1) DL_MODE=SOURCE_CHECK $(EXTRAMAKEARGS) source
810 .PHONY: defconfig savedefconfig
812 ################################################################################
814 # Cleanup and misc junk
816 ################################################################################
818 # outputmakefile generates a Makefile in the output directory, if using a
819 # separate output directory. This allows convenient use of make in the
820 # output directory.
821 outputmakefile:
822 ifeq ($(NEED_WRAPPER),y)
823 $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
824 endif
826 # printvars prints all the variables currently defined in our Makefiles
827 printvars:
828 @$(foreach V, \
829 $(sort $(.VARIABLES)), \
830 $(if $(filter-out environment% default automatic, \
831 $(origin $V)), \
832 $(info $V=$($V) ($(value $V)))))
834 clean:
835 rm -rf $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \
836 $(BUILD_DIR) $(BASE_DIR)/staging \
837 $(LEGAL_INFO_DIR)
839 distclean: clean
840 ifeq ($(DL_DIR),$(TOPDIR)/dl)
841 rm -rf $(DL_DIR)
842 endif
843 ifeq ($(O),output)
844 rm -rf $(O)
845 endif
846 rm -rf $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/.auto.deps
848 help:
849 @echo 'Cleaning:'
850 @echo ' clean - delete all files created by build'
851 @echo ' distclean - delete all non-source files (including .config)'
852 @echo
853 @echo 'Build:'
854 @echo ' all - make world'
855 @echo ' toolchain - build toolchain'
856 @echo
857 @echo 'Configuration:'
858 @echo ' menuconfig - interactive curses-based configurator'
859 @echo ' nconfig - interactive ncurses-based configurator'
860 @echo ' xconfig - interactive Qt-based configurator'
861 @echo ' gconfig - interactive GTK-based configurator'
862 @echo ' oldconfig - resolve any unresolved symbols in .config'
863 @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
864 @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
865 @echo ' randconfig - New config with random answer to all options'
866 @echo ' defconfig - New config with default answer to all options'
867 @echo ' BR2_DEFCONFIG, if set, is used as input'
868 @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
869 @echo ' allyesconfig - New config where all options are accepted with yes'
870 @echo ' allnoconfig - New config where all options are answered with no'
871 @echo ' randpackageconfig - New config with random answer to package options'
872 @echo ' allyespackageconfig - New config where pkg options are accepted with yes'
873 @echo ' allnopackageconfig - New config where package options are answered with no'
874 ifeq ($(BR2_PACKAGE_BUSYBOX),y)
875 @echo ' busybox-menuconfig - Run BusyBox menuconfig'
876 endif
877 ifeq ($(BR2_LINUX_KERNEL),y)
878 @echo ' linux-menuconfig - Run Linux kernel menuconfig'
879 @echo ' linux-savedefconfig - Run Linux kernel savedefconfig'
880 endif
881 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
882 @echo ' uclibc-menuconfig - Run uClibc menuconfig'
883 endif
884 ifeq ($(BR2_TARGET_BAREBOX),y)
885 @echo ' barebox-menuconfig - Run barebox menuconfig'
886 @echo ' barebox-savedefconfig - Run barebox savedefconfig'
887 endif
888 @echo
889 @echo 'Documentation:'
890 @echo ' manual - build manual in all formats'
891 @echo ' manual-html - build manual in HTML'
892 @echo ' manual-split-html - build manual in split HTML'
893 @echo ' manual-pdf - build manual in PDF'
894 @echo ' manual-text - build manual in text'
895 @echo ' manual-epub - build manual in ePub'
896 @echo ' graph-build - generate graphs of the build times'
897 @echo ' graph-depends - generate graph of the dependency tree'
898 @echo
899 @echo 'Miscellaneous:'
900 @echo ' source - download all sources needed for offline-build'
901 @echo ' source-check - check selected packages for valid download URLs'
902 @echo ' external-deps - list external packages used'
903 @echo ' legal-info - generate info about license compliance'
904 @echo
905 @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
906 @echo ' make O=dir - Locate all output files in "dir", including .config'
907 @echo
908 @echo 'Built-in configs:'
909 @$(foreach b, $(sort $(notdir $(wildcard $(TOPDIR)/configs/*_defconfig))), \
910 printf " %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
911 ifneq ($(wildcard $(BR2_EXTERNAL)/configs/*_defconfig),)
912 @echo
913 @echo 'User-provided configs:'
914 @$(foreach b, $(sort $(notdir $(wildcard $(BR2_EXTERNAL)/configs/*_defconfig))), \
915 printf " %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
916 endif
917 @echo
918 @echo 'For further details, see README, generate the Buildroot manual, or consult'
919 @echo 'it on-line at http://buildroot.org/docs.html'
920 @echo
922 release: OUT = buildroot-$(BR2_VERSION)
924 # Create release tarballs. We need to fiddle a bit to add the generated
925 # documentation to the git output
926 release:
927 git archive --format=tar --prefix=$(OUT)/ HEAD > $(OUT).tar
928 $(MAKE) O=$(OUT) manual-html manual-text manual-pdf
929 tar rf $(OUT).tar $(OUT)
930 gzip -9 -c < $(OUT).tar > $(OUT).tar.gz
931 bzip2 -9 -c < $(OUT).tar > $(OUT).tar.bz2
932 rm -rf $(OUT) $(OUT).tar
934 print-version:
935 @echo $(BR2_VERSION_FULL)
937 include docs/manual/manual.mk
938 -include $(BR2_EXTERNAL)/docs/*/*.mk
940 .PHONY: $(noconfig_targets)