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-2015 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 # Trick for always running with a fixed umask
29 ifneq ($(shell umask
),$(UMASK
))
30 .PHONY
: _all
$(MAKECMDGOALS
)
36 @umask
$(UMASK
) && $(MAKE
) --no-print-directory
$(MAKECMDGOALS
)
40 # This is our default rule, so must come first
43 # Set and export the version string
44 export BR2_VERSION
:= 2016.02-git
46 # Save running make version since it's clobbered by the make package
47 RUNNING_MAKE_VERSION
:= $(MAKE_VERSION
)
49 # Check for minimal make version (note: this check will break at make 10.x)
50 MIN_MAKE_VERSION
= 3.81
51 ifneq ($(firstword $(sort $(RUNNING_MAKE_VERSION
) $(MIN_MAKE_VERSION
))),$(MIN_MAKE_VERSION
))
52 $(error You have make
'$(RUNNING_MAKE_VERSION)' installed. GNU make
>= $(MIN_MAKE_VERSION
) is required
)
55 export HOSTARCH
:= $(shell uname
-m | \
60 -e s
/ppc64
/powerpc64
/ \
65 # Parallel execution of this Makefile is disabled because it changes
66 # the packages building order, that can be a problem for two reasons:
67 # - If a package has an unspecified optional dependency and that
68 # dependency is present when the package is built, it is used,
69 # otherwise it isn't (but compilation happily proceeds) so the end
70 # result will differ if the order is swapped due to parallel
72 # - Also changing the building order can be a problem if two packages
73 # manipulate the same file in the target directory.
75 # Taking into account the above considerations, if you still want to execute
76 # this top-level Makefile in parallel comment the ".NOTPARALLEL" line and
77 # use the -j<jobs> option when building, e.g:
78 # make -j$((`getconf _NPROCESSORS_ONLN`+1))
82 TOPDIR
:= $(shell pwd
)
83 CONFIG_CONFIG_IN
= Config.in
84 CONFIG
= support
/kconfig
85 DATE
:= $(shell date
+%Y
%m
%d
)
87 # Compute the full local version string so packages can use it as-is
88 # Need to export it, so it can be got from environment in children (eg. mconf)
89 export BR2_VERSION_FULL
:= $(BR2_VERSION
)$(shell $(TOPDIR
)/support
/scripts
/setlocalversion
)
91 noconfig_targets
:= menuconfig nconfig gconfig xconfig config oldconfig randconfig \
92 defconfig
%_defconfig allyesconfig allnoconfig silentoldconfig release \
93 randpackageconfig allyespackageconfig allnopackageconfig \
94 print-version olddefconfig
96 # Some global targets do not trigger a build, but are used to collect
97 # metadata, or do various checks. When such targets are triggered,
98 # some packages should not do their configuration sanity
99 # checks. Provide them a BR_BUILDING variable set to 'y' when we're
100 # actually building and they should do their sanity checks.
102 # We're building in two situations: when MAKECMDGOALS is empty
103 # (default target is to build), or when MAKECMDGOALS contains
104 # something else than one of the nobuild_targets.
105 nobuild_targets
:= source source-check \
106 legal-info external-deps _external-deps \
108 ifeq ($(MAKECMDGOALS
),)
110 else ifneq ($(filter-out $(nobuild_targets
),$(MAKECMDGOALS
)),)
114 # Strip quotes and then whitespaces
115 qstrip
= $(strip $(subst ",,$(1)))
118 # Variables for use in Make constructs
121 space
:= $(empty
) $(empty
)
123 ifneq ("$(origin O)", "command line")
125 CONFIG_DIR
:= $(TOPDIR
)
128 # other packages might also support Linux-style out of tree builds
129 # with the O=<dir> syntax (E.G. BusyBox does). As make automatically
130 # forwards command line variable definitions those packages get very
131 # confused. Fix this by telling make to not do so
133 # strangely enough O is still passed to submakes with MAKEOVERRIDES
134 # (with make 3.81 atleast), the only thing that changes is the output
135 # of the origin function (command line -> environment).
136 # Unfortunately some packages don't look at origin (E.G. uClibc 0.9.31+)
137 # To really make O go away, we have to override it.
140 # we need to pass O= everywhere we call back into the toplevel makefile
141 EXTRAMAKEARGS
= O
=$(O
)
145 # bash prints the name of the directory on 'cd <dir>' if CDPATH is
146 # set, so unset it here to not cause problems. Notice that the export
147 # line doesn't affect the environment of $(shell ..) calls, so
148 # explictly throw away any output from 'cd' here.
150 BASE_DIR
:= $(shell mkdir
-p
$(O
) && cd
$(O
) >/dev
/null
&& pwd
)
151 $(if
$(BASE_DIR
),, $(error output directory
"$(O)" does not exist
))
154 # Handling of BR2_EXTERNAL.
156 # The value of BR2_EXTERNAL is stored in .br-external in the output directory.
157 # On subsequent invocations of make, it is read in. It can still be overridden
158 # on the command line, therefore the file is re-created every time make is run.
160 # When BR2_EXTERNAL is set to an empty value (e.g. explicitly in command
161 # line), the .br-external file is removed and we point to
162 # support/dummy-external. This makes sure we can unconditionally include the
163 # Config.in and external.mk from the BR2_EXTERNAL directory. In this case,
164 # override is necessary so the user can clear BR2_EXTERNAL from the command
165 # line, but the dummy path is still used internally.
167 BR2_EXTERNAL_FILE
= $(BASE_DIR
)/.br-external
168 -include $(BR2_EXTERNAL_FILE
)
169 ifeq ($(BR2_EXTERNAL
),)
170 override BR2_EXTERNAL
= support
/dummy-external
171 $(shell rm -f
$(BR2_EXTERNAL_FILE
))
173 _BR2_EXTERNAL
= $(shell cd
$(BR2_EXTERNAL
) >/dev
/null
2>&1 && pwd
)
174 ifeq ($(_BR2_EXTERNAL
),)
175 $(error BR2_EXTERNAL
='$(BR2_EXTERNAL)' does not exist
, relative to
$(TOPDIR
))
177 override BR2_EXTERNAL
:= $(_BR2_EXTERNAL
)
178 $(shell echo BR2_EXTERNAL ?
= $(BR2_EXTERNAL
) > $(BR2_EXTERNAL_FILE
))
181 # To make sure that the environment variable overrides the .config option,
182 # set this before including .config.
183 ifneq ($(BR2_DL_DIR
),)
184 DL_DIR
:= $(BR2_DL_DIR
)
186 ifneq ($(BR2_CCACHE_DIR
),)
187 BR_CACHE_DIR
:= $(BR2_CCACHE_DIR
)
190 # Need that early, before we scan packages
191 # Avoids doing the $(or...) everytime
192 BR_GRAPH_OUT
:= $(or
$(BR2_GRAPH_OUT
),pdf
)
194 BUILD_DIR
:= $(BASE_DIR
)/build
195 BINARIES_DIR
:= $(BASE_DIR
)/images
196 TARGET_DIR
:= $(BASE_DIR
)/target
197 # initial definition so that 'make clean' works for most users, even without
198 # .config. HOST_DIR will be overwritten later when .config is included.
199 HOST_DIR
:= $(BASE_DIR
)/host
200 GRAPHS_DIR
:= $(BASE_DIR
)/graphs
202 LEGAL_INFO_DIR
= $(BASE_DIR
)/legal-info
203 REDIST_SOURCES_DIR_TARGET
= $(LEGAL_INFO_DIR
)/sources
204 REDIST_SOURCES_DIR_HOST
= $(LEGAL_INFO_DIR
)/host-sources
205 LICENSE_FILES_DIR_TARGET
= $(LEGAL_INFO_DIR
)/licenses
206 LICENSE_FILES_DIR_HOST
= $(LEGAL_INFO_DIR
)/host-licenses
207 LEGAL_MANIFEST_CSV_TARGET
= $(LEGAL_INFO_DIR
)/manifest.csv
208 LEGAL_MANIFEST_CSV_HOST
= $(LEGAL_INFO_DIR
)/host-manifest.csv
209 LEGAL_LICENSES_TXT_TARGET
= $(LEGAL_INFO_DIR
)/licenses.txt
210 LEGAL_LICENSES_TXT_HOST
= $(LEGAL_INFO_DIR
)/host-licenses.txt
211 LEGAL_WARNINGS
= $(LEGAL_INFO_DIR
)/.warnings
212 LEGAL_REPORT
= $(LEGAL_INFO_DIR
)/README
214 BR2_CONFIG
= $(CONFIG_DIR
)/.config
216 # Pull in the user's configuration file
217 ifeq ($(filter $(noconfig_targets
),$(MAKECMDGOALS
)),)
218 -include $(BR2_CONFIG
)
221 # To put more focus on warnings, be less verbose as default
222 # Use 'make V=1' to see the full commands
223 ifeq ("$(origin V)", "command line")
224 KBUILD_VERBOSE
= $(V
)
226 ifndef KBUILD_VERBOSE
230 ifeq ($(KBUILD_VERBOSE
),1)
240 # we want bash as shell
241 SHELL
:= $(shell if
[ -x
"$$BASH" ]; then echo
$$BASH; \
242 else if
[ -x
/bin
/bash
]; then echo
/bin
/bash
; \
243 else echo sh
; fi
; fi
)
245 # kconfig uses CONFIG_SHELL
246 CONFIG_SHELL
:= $(SHELL
)
248 export SHELL CONFIG_SHELL Q KBUILD_VERBOSE
258 HOSTCC
:= $(shell which
$(HOSTCC
) || type
-p
$(HOSTCC
) || echo gcc
)
260 HOSTCC_NOCCACHE
:= $(HOSTCC
)
263 HOSTCXX
:= $(shell which
$(HOSTCXX
) || type
-p
$(HOSTCXX
) || echo g
++)
265 HOSTCXX_NOCCACHE
:= $(HOSTCXX
)
279 HOSTOBJCOPY
:= objcopy
284 HOSTAR
:= $(shell which
$(HOSTAR
) || type
-p
$(HOSTAR
) || echo
ar)
285 HOSTAS
:= $(shell which
$(HOSTAS
) || type
-p
$(HOSTAS
) || echo
as)
286 HOSTCPP
:= $(shell which
$(HOSTCPP
) || type
-p
$(HOSTCPP
) || echo
cpp)
287 HOSTLD
:= $(shell which
$(HOSTLD
) || type
-p
$(HOSTLD
) || echo
ld)
288 HOSTLN
:= $(shell which
$(HOSTLN
) || type
-p
$(HOSTLN
) || echo ln
)
289 HOSTNM
:= $(shell which
$(HOSTNM
) || type
-p
$(HOSTNM
) || echo nm
)
290 HOSTOBJCOPY
:= $(shell which
$(HOSTOBJCOPY
) || type
-p
$(HOSTOBJCOPY
) || echo objcopy
)
291 HOSTRANLIB
:= $(shell which
$(HOSTRANLIB
) || type
-p
$(HOSTRANLIB
) || echo ranlib
)
293 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
294 export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
296 # Make sure pkg-config doesn't look outside the buildroot tree
297 HOST_PKG_CONFIG_PATH
:= $(PKG_CONFIG_PATH
)
298 unexport PKG_CONFIG_PATH
299 unexport PKG_CONFIG_SYSROOT_DIR
300 unexport PKG_CONFIG_LIBDIR
302 # Having DESTDIR set in the environment confuses the installation
303 # steps of some packages.
306 # Causes breakage with packages that needs host-ruby
309 include package
/pkg-utils.mk
310 include package
/doc-asciidoc.mk
312 ifeq ($(BR2_HAVE_DOT_CONFIG
),y
)
314 ################################################################################
316 # Hide troublesome environment variables from sub processes
318 ################################################################################
319 unexport CROSS_COMPILE
326 unexport GREP_OPTIONS
334 GNU_HOST_NAME
:= $(shell support
/gnuconfig
/config.guess
)
339 # silent mode requested?
340 QUIET
:= $(if
$(findstring s
,$(filter-out --%,$(MAKEFLAGS
))),-q
)
342 # Strip off the annoying quoting
343 ARCH
:= $(call qstrip
,$(BR2_ARCH
))
345 KERNEL_ARCH
:= $(shell echo
"$(ARCH)" | sed
-e
"s/-.*//" \
346 -e s
/i
.86/i386
/ -e s
/sun4u
/sparc64
/ \
349 -e s
/arm.
*/arm
/ -e s
/sa110
/arm
/ \
350 -e s
/aarch64.
*/arm64
/ \
351 -e s
/bfin
/blackfin
/ \
352 -e s
/parisc64
/parisc
/ \
353 -e s
/powerpc64.
*/powerpc
/ \
354 -e s
/ppc.
*/powerpc
/ -e s
/mips.
*/mips
/ \
356 -e s
/microblazeel
/microblaze
/)
358 ZCAT
:= $(call qstrip
,$(BR2_ZCAT
))
359 BZCAT
:= $(call qstrip
,$(BR2_BZCAT
))
360 XZCAT
:= $(call qstrip
,$(BR2_XZCAT
))
361 TAR_OPTIONS
= $(call qstrip
,$(BR2_TAR_OPTIONS
)) -xf
363 # packages compiled for the host go here
364 HOST_DIR
:= $(call qstrip
,$(BR2_HOST_DIR
))
366 # Quotes are needed for spaces and all in the original PATH content.
367 BR_PATH
= "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(HOST_DIR)/usr/bin:$(HOST_DIR)/usr/sbin:$(PATH)"
369 # Location of a file giving a big fat warning that output/target
370 # should not be used as the root filesystem.
371 TARGET_DIR_WARNING_FILE
= $(TARGET_DIR
)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
373 ifeq ($(BR2_CCACHE
),y
)
374 CCACHE
:= $(HOST_DIR
)/usr
/bin
/ccache
375 BR_CACHE_DIR ?
= $(call qstrip
,$(BR2_CCACHE_DIR
))
377 HOSTCC
:= $(CCACHE
) $(HOSTCC
)
378 HOSTCXX
:= $(CCACHE
) $(HOSTCXX
)
383 # Scripts in support/ or post-build scripts may need to reference
384 # these locations, so export them so it is easier to use
392 ################################################################################
394 # You should probably leave this stuff alone unless you know
395 # what you are doing.
397 ################################################################################
401 # Include legacy before the other things, because package .mk files
403 ifneq ($(BR2_DEPRECATED
),y
)
404 include Makefile.legacy
407 include package
/Makefile.in
408 include support
/dependencies
/dependencies.mk
410 include toolchain
/*.mk
411 include toolchain
/*/*.mk
413 # Include the package override file if one has been provided in the
415 PACKAGE_OVERRIDE_FILE
= $(call qstrip
,$(BR2_PACKAGE_OVERRIDE_FILE
))
416 ifneq ($(PACKAGE_OVERRIDE_FILE
),)
417 -include $(PACKAGE_OVERRIDE_FILE
)
420 include $(sort $(wildcard package
/*/*.mk
))
422 include boot
/common.mk
423 include linux
/linux.mk
426 include $(BR2_EXTERNAL
)/external.mk
428 dirs
: $(BUILD_DIR
) $(STAGING_DIR
) $(TARGET_DIR
) \
429 $(HOST_DIR
) $(BINARIES_DIR
)
431 $(BUILD_DIR
)/buildroot-config
/auto.conf
: $(BR2_CONFIG
)
432 $(MAKE1
) $(EXTRAMAKEARGS
) HOSTCC
="$(HOSTCC_NOCCACHE)" HOSTCXX
="$(HOSTCXX_NOCCACHE)" silentoldconfig
434 prepare
: $(BUILD_DIR
)/buildroot-config
/auto.conf
436 world
: target-post-image
438 .PHONY
: all world toolchain dirs
clean distclean source outputmakefile \
439 legal-info legal-info-prepare legal-info-clean printvars help \
440 list-defconfigs target-finalize target-post-image source-check
442 ################################################################################
444 # staging and target directories do NOT list these as
445 # dependencies anywhere else
447 ################################################################################
448 $(BUILD_DIR
) $(TARGET_DIR
) $(HOST_DIR
) $(BINARIES_DIR
) $(LEGAL_INFO_DIR
) $(REDIST_SOURCES_DIR_TARGET
) $(REDIST_SOURCES_DIR_HOST
):
451 # We make a symlink lib32->lib or lib64->lib as appropriate
452 # MIPS64/n32 requires lib32 even though it's a 64-bit arch.
453 ifeq ($(BR2_ARCH_IS_64
)$(BR2_MIPS_NABI32
),y
)
459 # Populating the staging with the base directories is handled by the skeleton package
461 @mkdir
-p
$(STAGING_DIR
)
462 @ln
-snf
$(STAGING_DIR
) $(BASE_DIR
)/staging
464 RSYNC_VCS_EXCLUSIONS
= \
465 --exclude .svn
--exclude .git
--exclude .hg
--exclude .bzr \
468 STRIP_FIND_CMD
= find
$(TARGET_DIR
)
469 ifneq (,$(call qstrip
,$(BR2_STRIP_EXCLUDE_DIRS
)))
470 STRIP_FIND_CMD
+= \
( $(call finddirclauses
,$(TARGET_DIR
),$(call qstrip
,$(BR2_STRIP_EXCLUDE_DIRS
))) \
) -prune
-o
472 STRIP_FIND_CMD
+= -type f \
( -perm
/111 -o
-name
'*.so*' \
)
474 # - libpthread.so: a non-stripped libpthread shared library is needed for
475 # proper debugging of pthread programs using gdb.
476 # - ld.so: a non-stripped dynamic linker library is needed for valgrind
477 # - kernel modules (*.ko): do not function properly when stripped like normal
478 # applications and libraries. Normally kernel modules are already excluded
479 # by the executable permission check above, so the explicit exclusion is only
480 # done for kernel modules with incorrect permissions.
481 STRIP_FIND_CMD
+= -not \
( $(call findfileclauses
,libpthread
*.so
* ld-
*.so
* *.ko
$(call qstrip
,$(BR2_STRIP_EXCLUDE_FILES
))) \
) -print0
483 ifeq ($(BR2_ECLIPSE_REGISTER
),y
)
484 define TOOLCHAIN_ECLIPSE_REGISTER
485 .
/support
/scripts
/eclipse-register-toolchain
`readlink -f $(O)` \
486 $(notdir $(TARGET_CROSS
)) $(BR2_ARCH
)
488 TARGET_FINALIZE_HOOKS
+= TOOLCHAIN_ECLIPSE_REGISTER
491 # Generate locale data. Basically, we call the localedef program
492 # (built by the host-localedef package) for each locale. The input
493 # data comes preferably from the toolchain, or if the toolchain does
494 # not have them (Linaro toolchains), we use the ones available on the
496 ifeq ($(BR2_TOOLCHAIN_USES_GLIBC
),y
)
497 GLIBC_GENERATE_LOCALES
= $(call qstrip
,$(BR2_GENERATE_LOCALE
))
498 ifneq ($(GLIBC_GENERATE_LOCALES
),)
499 PACKAGES
+= host-localedef
501 define GENERATE_GLIBC_LOCALES
502 $(Q
)mkdir
-p
$(TARGET_DIR
)/usr
/lib
/locale
/
503 $(Q
)for locale in
$(GLIBC_GENERATE_LOCALES
) ; do \
504 inputfile
=`echo $${locale} | cut -f1 -d'.'` ; \
505 charmap
=`echo $${locale} | cut -f2 -d'.' -s` ; \
506 if
test -z
"$${charmap}" ; then \
509 echo
"Generating locale $${inputfile}.$${charmap}" ; \
510 I18NPATH
=$(STAGING_DIR
)/usr
/share
/i18n
:/usr
/share
/i18n \
511 $(HOST_DIR
)/usr
/bin
/localedef \
512 --prefix=$(TARGET_DIR
) \
513 --$(call LOWERCASE
,$(BR2_ENDIAN
))-endian \
514 -i
$${inputfile} -f
$${charmap} \
518 TARGET_FINALIZE_HOOKS
+= GENERATE_GLIBC_LOCALES
522 ifeq ($(BR2_ENABLE_LOCALE_PURGE
),y
)
523 LOCALE_WHITELIST
= $(BUILD_DIR
)/locales.nopurge
524 LOCALE_NOPURGE
= $(call qstrip
,$(BR2_ENABLE_LOCALE_WHITELIST
))
526 # This piece of junk does the following:
527 # First collect the whitelist in a file.
528 # Then go over all the locale dirs and for each subdir, check if it exists
529 # in the whitelist file. If it doesn't, kill it.
530 # Finally, specifically for X11, regenerate locale.dir from the whitelist.
532 rm -f
$(LOCALE_WHITELIST
)
533 for i in
$(LOCALE_NOPURGE
) locale-archive
; do echo
$$i >> $(LOCALE_WHITELIST
); done
535 for
dir in
$(wildcard $(addprefix $(TARGET_DIR
),/usr
/share
/locale
/usr
/share
/X11
/locale
/usr
/lib
/locale
)); \
537 for langdir in
$$dir/*; \
539 grep
-qx
$${langdir
##*/} $(LOCALE_WHITELIST) || rm -rf $$langdir; \
542 if
[ -d
$(TARGET_DIR
)/usr
/share
/X11
/locale
]; \
544 for lang in
$(LOCALE_NOPURGE
); \
546 if
[ -f
$(TARGET_DIR
)/usr
/share
/X11
/locale
/$$lang/XLC_LOCALE
]; \
548 echo
"$$lang/XLC_LOCALE: $$lang"; \
550 done
> $(TARGET_DIR
)/usr
/share
/X11
/locale
/locale.
dir; \
553 TARGET_FINALIZE_HOOKS
+= PURGE_LOCALES
556 $(TARGETS_ROOTFS
): target-finalize
558 target-finalize
: $(PACKAGES
)
559 @
$(call MESSAGE
,"Finalizing target directory")
560 $(foreach hook
,$(TARGET_FINALIZE_HOOKS
),$($(hook
))$(sep
))
561 rm -rf
$(TARGET_DIR
)/usr
/include $(TARGET_DIR
)/usr
/share
/aclocal \
562 $(TARGET_DIR
)/usr
/lib
/pkgconfig
$(TARGET_DIR
)/usr
/share
/pkgconfig \
563 $(TARGET_DIR
)/usr
/lib
/cmake
$(TARGET_DIR
)/usr
/share
/cmake
564 find
$(TARGET_DIR
)/usr
/{lib
,share
}/ -name
'*.cmake' -print0 | xargs
-0 rm -f
565 find
$(TARGET_DIR
)/lib
$(TARGET_DIR
)/usr
/lib
$(TARGET_DIR
)/usr
/libexec \
566 \
( -name
'*.a' -o
-name
'*.la' \
) -print0 | xargs
-0 rm -f
567 ifneq ($(BR2_PACKAGE_GDB
),y
)
568 rm -rf
$(TARGET_DIR
)/usr
/share
/gdb
570 ifneq ($(BR2_PACKAGE_BASH
),y
)
571 rm -rf
$(TARGET_DIR
)/usr
/share
/bash-completion
573 ifneq ($(BR2_PACKAGE_ZSH
),y
)
574 rm -rf
$(TARGET_DIR
)/usr
/share
/zsh
576 rm -rf
$(TARGET_DIR
)/usr
/man
$(TARGET_DIR
)/usr
/share
/man
577 rm -rf
$(TARGET_DIR
)/usr
/info $(TARGET_DIR
)/usr
/share
/info
578 rm -rf
$(TARGET_DIR
)/usr
/doc
$(TARGET_DIR
)/usr
/share
/doc
579 rm -rf
$(TARGET_DIR
)/usr
/share
/gtk-doc
580 -rmdir
$(TARGET_DIR
)/usr
/share
2>/dev
/null
581 $(STRIP_FIND_CMD
) | xargs
-0 $(STRIPCMD
) 2>/dev
/null || true
582 if
test -d
$(TARGET_DIR
)/lib
/modules
; then \
583 find
$(TARGET_DIR
)/lib
/modules
-type f
-name
'*.ko' -print0 | \
584 xargs
-0 -r
$(KSTRIPCMD
); fi
586 # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
587 # besides the one in which crash occurred; or SIGTRAP kills my program when
588 # I set a breakpoint"
589 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS
),y
)
590 find
$(TARGET_DIR
)/lib
-type f
-name
'libpthread*.so*' | \
591 xargs
-r
$(STRIPCMD
) $(STRIP_STRIP_DEBUG
)
594 # Valgrind needs ld.so with enough information, so only strip
596 find
$(TARGET_DIR
)/lib
-type f
-name
'ld-*.so*' | \
597 xargs
-r
$(STRIPCMD
) $(STRIP_STRIP_DEBUG
)
599 mkdir
-p
$(TARGET_DIR
)/etc
600 # Mandatory configuration file and auxiliary cache directory
601 # for recent versions of ldconfig
602 touch
$(TARGET_DIR
)/etc
/ld.so.conf
603 mkdir
-p
$(TARGET_DIR
)/var
/cache
/ldconfig
604 if
[ -x
"$(TARGET_CROSS)ldconfig" ]; \
606 $(TARGET_CROSS
)ldconfig
-r
$(TARGET_DIR
) \
607 -f
$(TARGET_DIR
)/etc
/ld.so.conf
; \
609 /sbin
/ldconfig
-r
$(TARGET_DIR
) \
610 -f
$(TARGET_DIR
)/etc
/ld.so.conf
; \
613 echo
"NAME=Buildroot"; \
614 echo
"VERSION=$(BR2_VERSION_FULL)"; \
615 echo
"ID=buildroot"; \
616 echo
"VERSION_ID=$(BR2_VERSION)"; \
617 echo
"PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
618 ) > $(TARGET_DIR
)/etc
/os-release
620 @
$(foreach d
, $(call qstrip
,$(BR2_ROOTFS_OVERLAY
)), \
621 $(call MESSAGE
,"Copying overlay $(d)"); \
622 rsync
-a
--ignore-times
$(RSYNC_VCS_EXCLUSIONS
) \
623 --chmod
=u
=rwX
,go
=rX
--exclude .empty
--exclude
'*~' \
624 $(d
)/ $(TARGET_DIR
)$(sep
))
626 @
$(foreach s
, $(call qstrip
,$(BR2_ROOTFS_POST_BUILD_SCRIPT
)), \
627 $(call MESSAGE
,"Executing post-build script $(s)"); \
628 $(EXTRA_ENV
) $(s
) $(TARGET_DIR
) $(call qstrip
,$(BR2_ROOTFS_POST_SCRIPT_ARGS
))$(sep
))
630 target-post-image
: $(TARGETS_ROOTFS
) target-finalize
631 @
$(foreach s
, $(call qstrip
,$(BR2_ROOTFS_POST_IMAGE_SCRIPT
)), \
632 $(call MESSAGE
,"Executing post-image script $(s)"); \
633 $(EXTRA_ENV
) $(s
) $(BINARIES_DIR
) $(call qstrip
,$(BR2_ROOTFS_POST_SCRIPT_ARGS
))$(sep
))
635 source
: $(foreach p
,$(PACKAGES
),$(p
)-all-source
)
637 _external-deps
: $(foreach p
,$(PACKAGES
),$(p
)-all-external-deps
)
639 @
$(MAKE1
) -Bs
$(EXTRAMAKEARGS
) _external-deps |
sort -u
641 # check if download URLs are outdated
642 source-check
: $(foreach p
,$(PACKAGES
),$(p
)-all-source-check
)
645 @
rm -fr
$(LEGAL_INFO_DIR
)
647 legal-info-prepare
: $(LEGAL_INFO_DIR
)
648 @
$(call MESSAGE
,"Collecting legal info")
649 @
$(call legal-license-file
,buildroot
,COPYING
,COPYING
,HOST
)
650 @
$(call legal-manifest
,PACKAGE
,VERSION
,LICENSE
,LICENSE FILES
,SOURCE ARCHIVE
,SOURCE SITE
,TARGET
)
651 @
$(call legal-manifest
,PACKAGE
,VERSION
,LICENSE
,LICENSE FILES
,SOURCE ARCHIVE
,SOURCE SITE
,HOST
)
652 @
$(call legal-manifest
,buildroot
,$(BR2_VERSION_FULL
),GPLv2
+,COPYING
,not saved
,not saved
,HOST
)
653 @
$(call legal-warning
,the Buildroot source code has not been saved
)
654 @cp
$(BR2_CONFIG
) $(LEGAL_INFO_DIR
)/buildroot.config
656 legal-info
: dirs legal-info-clean legal-info-prepare
$(foreach p
,$(PACKAGES
),$(p
)-all-legal-info
) \
657 $(REDIST_SOURCES_DIR_TARGET
) $(REDIST_SOURCES_DIR_HOST
)
658 @cat support
/legal-info
/README.header
>>$(LEGAL_REPORT
)
659 @if
[ -r
$(LEGAL_WARNINGS
) ]; then \
660 cat support
/legal-info
/README.warnings-header \
661 $(LEGAL_WARNINGS
) >>$(LEGAL_REPORT
); \
662 cat
$(LEGAL_WARNINGS
); fi
663 @echo
"Legal info produced in $(LEGAL_INFO_DIR)"
664 @
rm -f
$(LEGAL_WARNINGS
)
667 @echo
$(PACKAGES
) $(TARGETS_ROOTFS
)
669 graph-build
: $(O
)/build
/build-time.log
670 @
install -d
$(GRAPHS_DIR
)
671 $(foreach o
,name build duration
,.
/support
/scripts
/graph-build-time \
672 --type
=histogram
--order
=$(o
) --input
=$(<) \
673 --output
=$(GRAPHS_DIR
)/build.hist-
$(o
).
$(BR_GRAPH_OUT
) \
674 $(if
$(BR2_GRAPH_ALT
),--alternate-colors
)$(sep
))
675 $(foreach t
,packages steps
,.
/support
/scripts
/graph-build-time \
676 --type
=pie-
$(t
) --input
=$(<) \
677 --output
=$(GRAPHS_DIR
)/build.pie-
$(t
).
$(BR_GRAPH_OUT
) \
678 $(if
$(BR2_GRAPH_ALT
),--alternate-colors
)$(sep
))
680 graph-depends-requirements
:
681 @dot
-?
>/dev
/null
2>&1 || \
682 { echo
"ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit
1; }
684 graph-depends
: graph-depends-requirements
685 @
$(INSTALL
) -d
$(GRAPHS_DIR
)
686 @cd
"$(CONFIG_DIR)"; \
687 $(TOPDIR
)/support
/scripts
/graph-depends
$(BR2_GRAPH_DEPS_OPTS
) \
688 |tee
$(GRAPHS_DIR
)/$(@
).dot \
689 |dot
$(BR2_GRAPH_DOT_OPTS
) -T
$(BR_GRAPH_OUT
) -o
$(GRAPHS_DIR
)/$(@
).
$(BR_GRAPH_OUT
)
692 $(Q
)mkdir
-p
$(GRAPHS_DIR
)
693 $(Q
)$(TOPDIR
)/support
/scripts
/size-stats
--builddir
$(BASE_DIR
) \
694 --graph
$(GRAPHS_DIR
)/graph-size.
$(BR_GRAPH_OUT
) \
695 --file-size-csv
$(GRAPHS_DIR
)/file-size-stats.csv \
696 --package-size-csv
$(GRAPHS_DIR
)/package-size-stats.csv
698 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
702 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
705 # ---------------------------------------------------------------------------
707 HOSTCFLAGS
= $(CFLAGS_FOR_BUILD
)
710 $(BUILD_DIR
)/buildroot-config
/%onf
:
711 mkdir
-p
$(@D
)/lxdialog
712 PKG_CONFIG_PATH
="$(HOST_PKG_CONFIG_PATH)" $(MAKE
) CC
="$(HOSTCC_NOCCACHE)" HOSTCC
="$(HOSTCC_NOCCACHE)" \
713 obj
=$(@D
) -C
$(CONFIG
) -f Makefile.br
$(@F
)
715 DEFCONFIG
= $(call qstrip
,$(BR2_DEFCONFIG
))
717 # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
718 # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
719 COMMON_CONFIG_ENV
= \
720 BR2_DEFCONFIG
='$(call qstrip,$(value BR2_DEFCONFIG))' \
721 KCONFIG_AUTOCONFIG
=$(BUILD_DIR
)/buildroot-config
/auto.conf \
722 KCONFIG_AUTOHEADER
=$(BUILD_DIR
)/buildroot-config
/autoconf.h \
723 KCONFIG_TRISTATE
=$(BUILD_DIR
)/buildroot-config
/tristate.config \
724 BR2_CONFIG
=$(BR2_CONFIG
) \
725 BR2_EXTERNAL
=$(BR2_EXTERNAL
) \
728 xconfig
: $(BUILD_DIR
)/buildroot-config
/qconf outputmakefile
729 @
$(COMMON_CONFIG_ENV
) $< $(CONFIG_CONFIG_IN
)
731 gconfig
: $(BUILD_DIR
)/buildroot-config
/gconf outputmakefile
732 @
$(COMMON_CONFIG_ENV
) srctree
=$(TOPDIR
) $< $(CONFIG_CONFIG_IN
)
734 menuconfig
: $(BUILD_DIR
)/buildroot-config
/mconf outputmakefile
735 @
$(COMMON_CONFIG_ENV
) $< $(CONFIG_CONFIG_IN
)
737 nconfig
: $(BUILD_DIR
)/buildroot-config
/nconf outputmakefile
738 @
$(COMMON_CONFIG_ENV
) $< $(CONFIG_CONFIG_IN
)
740 config
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
741 @
$(COMMON_CONFIG_ENV
) $< $(CONFIG_CONFIG_IN
)
743 # For the config targets that automatically select options, we pass
744 # SKIP_LEGACY=y to disable the legacy options. However, in that case
745 # no values are set for the legacy options so a subsequent oldconfig
746 # will query them. Therefore, run an additional olddefconfig.
748 oldconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
749 @
$(COMMON_CONFIG_ENV
) $< --oldconfig
$(CONFIG_CONFIG_IN
)
751 randconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
752 @
$(COMMON_CONFIG_ENV
) SKIP_LEGACY
=y
$< --randconfig
$(CONFIG_CONFIG_IN
)
753 @
$(COMMON_CONFIG_ENV
) $< --olddefconfig
$(CONFIG_CONFIG_IN
) >/dev
/null
755 allyesconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
756 @
$(COMMON_CONFIG_ENV
) SKIP_LEGACY
=y
$< --allyesconfig
$(CONFIG_CONFIG_IN
)
757 @
$(COMMON_CONFIG_ENV
) $< --olddefconfig
$(CONFIG_CONFIG_IN
) >/dev
/null
759 allnoconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
760 @
$(COMMON_CONFIG_ENV
) SKIP_LEGACY
=y
$< --allnoconfig
$(CONFIG_CONFIG_IN
)
761 @
$(COMMON_CONFIG_ENV
) $< --olddefconfig
$(CONFIG_CONFIG_IN
) >/dev
/null
763 randpackageconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
764 @grep
-v BR2_PACKAGE_
$(BR2_CONFIG
) > $(CONFIG_DIR
)/.config.nopkg
765 @
$(COMMON_CONFIG_ENV
) SKIP_LEGACY
=y \
766 KCONFIG_ALLCONFIG
=$(CONFIG_DIR
)/.config.nopkg \
767 $< --randconfig
$(CONFIG_CONFIG_IN
)
768 @
rm -f
$(CONFIG_DIR
)/.config.nopkg
769 @
$(COMMON_CONFIG_ENV
) $< --olddefconfig
$(CONFIG_CONFIG_IN
) >/dev
/null
771 allyespackageconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
772 @grep
-v BR2_PACKAGE_
$(BR2_CONFIG
) > $(CONFIG_DIR
)/.config.nopkg
773 @
$(COMMON_CONFIG_ENV
) SKIP_LEGACY
=y \
774 KCONFIG_ALLCONFIG
=$(CONFIG_DIR
)/.config.nopkg \
775 $< --allyesconfig
$(CONFIG_CONFIG_IN
)
776 @
rm -f
$(CONFIG_DIR
)/.config.nopkg
777 @
$(COMMON_CONFIG_ENV
) $< --olddefconfig
$(CONFIG_CONFIG_IN
) >/dev
/null
779 allnopackageconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
780 @grep
-v BR2_PACKAGE_
$(BR2_CONFIG
) > $(CONFIG_DIR
)/.config.nopkg
781 @
$(COMMON_CONFIG_ENV
) SKIP_LEGACY
=y \
782 KCONFIG_ALLCONFIG
=$(CONFIG_DIR
)/.config.nopkg \
783 $< --allnoconfig
$(CONFIG_CONFIG_IN
)
784 @
rm -f
$(CONFIG_DIR
)/.config.nopkg
785 @
$(COMMON_CONFIG_ENV
) $< --olddefconfig
$(CONFIG_CONFIG_IN
) >/dev
/null
787 silentoldconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
788 $(COMMON_CONFIG_ENV
) $< --silentoldconfig
$(CONFIG_CONFIG_IN
)
790 olddefconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
791 $(COMMON_CONFIG_ENV
) $< --olddefconfig
$(CONFIG_CONFIG_IN
)
793 defconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
794 @
$(COMMON_CONFIG_ENV
) $< --defconfig
$(if
$(DEFCONFIG
),=$(DEFCONFIG
)) $(CONFIG_CONFIG_IN
)
796 # Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig
797 %_defconfig
: $(BUILD_DIR
)/buildroot-config
/conf
$(TOPDIR
)/configs
/%_defconfig outputmakefile
798 @
$(COMMON_CONFIG_ENV
) BR2_DEFCONFIG
=$(TOPDIR
)/configs
/$@ \
799 $< --defconfig
=$(TOPDIR
)/configs
/$@
$(CONFIG_CONFIG_IN
)
801 %_defconfig
: $(BUILD_DIR
)/buildroot-config
/conf
$(BR2_EXTERNAL
)/configs
/%_defconfig outputmakefile
802 @
$(COMMON_CONFIG_ENV
) BR2_DEFCONFIG
=$(BR2_EXTERNAL
)/configs
/$@ \
803 $< --defconfig
=$(BR2_EXTERNAL
)/configs
/$@
$(CONFIG_CONFIG_IN
)
805 savedefconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
806 @
$(COMMON_CONFIG_ENV
) $< \
807 --savedefconfig
=$(if
$(DEFCONFIG
),$(DEFCONFIG
),$(CONFIG_DIR
)/defconfig
) \
809 @
$(SED
) '/BR2_DEFCONFIG=/d' $(if
$(DEFCONFIG
),$(DEFCONFIG
),$(CONFIG_DIR
)/defconfig
)
811 .PHONY
: defconfig savedefconfig
813 ################################################################################
815 # Cleanup and misc junk
817 ################################################################################
819 # outputmakefile generates a Makefile in the output directory, if using a
820 # separate output directory. This allows convenient use of make in the
823 ifeq ($(NEED_WRAPPER
),y
)
824 $(Q
)$(TOPDIR
)/support
/scripts
/mkmakefile
$(TOPDIR
) $(O
)
827 # printvars prints all the variables currently defined in our
828 # Makefiles. Alternatively, if a non-empty VARS variable is passed,
829 # only the variables matching the make pattern passed in VARS are
833 $(sort $(if
$(VARS
),$(filter $(VARS
),$(.VARIABLES
)),$(.VARIABLES
))), \
834 $(if
$(filter-out environment
% default automatic
, \
836 $(info $V=$($V) ($(value
$V)))))
839 rm -rf
$(TARGET_DIR
) $(BINARIES_DIR
) $(HOST_DIR
) \
840 $(BUILD_DIR
) $(BASE_DIR
)/staging \
841 $(LEGAL_INFO_DIR
) $(GRAPHS_DIR
)
844 ifeq ($(DL_DIR
),$(TOPDIR
)/dl
)
850 rm -rf
$(BR2_CONFIG
) $(CONFIG_DIR
)/.config.old
$(CONFIG_DIR
)/..config.tmp \
851 $(CONFIG_DIR
)/.auto.deps
$(BR2_EXTERNAL_FILE
)
855 @echo
' clean - delete all files created by build'
856 @echo
' distclean - delete all non-source files (including .config)'
859 @echo
' all - make world'
860 @echo
' toolchain - build toolchain'
862 @echo
'Configuration:'
863 @echo
' menuconfig - interactive curses-based configurator'
864 @echo
' nconfig - interactive ncurses-based configurator'
865 @echo
' xconfig - interactive Qt-based configurator'
866 @echo
' gconfig - interactive GTK-based configurator'
867 @echo
' oldconfig - resolve any unresolved symbols in .config'
868 @echo
' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
869 @echo
' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
870 @echo
' randconfig - New config with random answer to all options'
871 @echo
' defconfig - New config with default answer to all options'
872 @echo
' BR2_DEFCONFIG, if set, is used as input'
873 @echo
' savedefconfig - Save current config to BR2_DEFCONFIG (minimal config)'
874 @echo
' allyesconfig - New config where all options are accepted with yes'
875 @echo
' allnoconfig - New config where all options are answered with no'
876 @echo
' randpackageconfig - New config with random answer to package options'
877 @echo
' allyespackageconfig - New config where pkg options are accepted with yes'
878 @echo
' allnopackageconfig - New config where package options are answered with no'
880 @echo
'Package-specific:'
881 @echo
' <pkg> - Build and install <pkg> and all its dependencies'
882 @echo
' <pkg>-source - Only download the source files for <pkg>'
883 @echo
' <pkg>-extract - Extract <pkg> sources'
884 @echo
' <pkg>-patch - Apply patches to <pkg>'
885 @echo
' <pkg>-depends - Build <pkg>'\''s dependencies'
886 @echo
' <pkg>-configure - Build <pkg> up to the configure step'
887 @echo
' <pkg>-build - Build <pkg> up to the build step'
888 @echo
' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies'
889 @echo
' <pkg>-dirclean - Remove <pkg> build directory'
890 @echo
' <pkg>-reconfigure - Restart the build from the configure step'
891 @echo
' <pkg>-rebuild - Restart the build from the build step'
892 ifeq ($(BR2_PACKAGE_BUSYBOX
),y
)
893 @echo
' busybox-menuconfig - Run BusyBox menuconfig'
895 ifeq ($(BR2_LINUX_KERNEL
),y
)
896 @echo
' linux-menuconfig - Run Linux kernel menuconfig'
897 @echo
' linux-savedefconfig - Run Linux kernel savedefconfig'
898 @echo
' linux-update-defconfig - Save the Linux configuration to the path specified'
899 @echo
' by BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE'
901 ifeq ($(BR2_TOOLCHAIN_BUILDROOT
),y
)
902 @echo
' uclibc-menuconfig - Run uClibc menuconfig'
904 ifeq ($(BR2_TARGET_BAREBOX
),y
)
905 @echo
' barebox-menuconfig - Run barebox menuconfig'
906 @echo
' barebox-savedefconfig - Run barebox savedefconfig'
909 @echo
'Documentation:'
910 @echo
' manual - build manual in all formats'
911 @echo
' manual-html - build manual in HTML'
912 @echo
' manual-split-html - build manual in split HTML'
913 @echo
' manual-pdf - build manual in PDF'
914 @echo
' manual-text - build manual in text'
915 @echo
' manual-epub - build manual in ePub'
916 @echo
' graph-build - generate graphs of the build times'
917 @echo
' graph-depends - generate graph of the dependency tree'
918 @echo
' graph-size - generate stats of the filesystem size'
919 @echo
' list-defconfigs - list all defconfigs (pre-configured minimal systems)'
921 @echo
'Miscellaneous:'
922 @echo
' source - download all sources needed for offline-build'
923 @echo
' source-check - check selected packages for valid download URLs'
924 @echo
' external-deps - list external packages used'
925 @echo
' legal-info - generate info about license compliance'
927 @echo
' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
928 @echo
' make O=dir - Locate all output files in "dir", including .config'
930 @echo
'For further details, see README, generate the Buildroot manual, or consult'
931 @echo
'it on-line at http://buildroot.org/docs.html'
935 @echo
'Built-in configs:'
936 @
$(foreach b
, $(sort $(notdir $(wildcard $(TOPDIR
)/configs
/*_defconfig
))), \
937 printf
" %-35s - Build for %s\\n" $(b
) $(b
:_defconfig
=);)
938 ifneq ($(wildcard $(BR2_EXTERNAL
)/configs
/*_defconfig
),)
940 @echo
'User-provided configs:'
941 @
$(foreach b
, $(sort $(notdir $(wildcard $(BR2_EXTERNAL
)/configs
/*_defconfig
))), \
942 printf
" %-35s - Build for %s\\n" $(b
) $(b
:_defconfig
=);)
946 release
: OUT
= buildroot-
$(BR2_VERSION
)
948 # Create release tarballs. We need to fiddle a bit to add the generated
949 # documentation to the git output
951 git archive
--format
=tar --prefix=$(OUT
)/ HEAD
> $(OUT
).
tar
952 $(MAKE
) O
=$(OUT
) manual-html manual-text manual-pdf
953 $(MAKE
) O
=$(OUT
) manual-clean
954 tar rf
$(OUT
).
tar $(OUT
)
955 gzip
-9 -c
< $(OUT
).
tar > $(OUT
).
tar.gz
956 bzip2
-9 -c
< $(OUT
).
tar > $(OUT
).
tar.bz2
957 rm -rf
$(OUT
) $(OUT
).
tar
960 @echo
$(BR2_VERSION_FULL
)
962 include docs
/manual
/manual.mk
963 -include $(BR2_EXTERNAL
)/docs
/*/*.mk
965 .PHONY
: $(noconfig_targets
)