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
30 # Set and export the version string
31 export BR2_VERSION
:= 2015.05-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
)
39 export HOSTARCH
:= $(shell uname
-m | \
44 -e s
/ppc64
/powerpc64
/ \
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
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))
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)))
84 # Variables for use in Make constructs
87 space
:= $(empty
) $(empty
)
89 ifneq ("$(origin O)", "command line")
91 CONFIG_DIR
:= $(TOPDIR
)
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
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.
106 # we need to pass O= everywhere we call back into the toplevel makefile
107 EXTRAMAKEARGS
= O
=$(O
)
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.
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
))
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
))
143 override BR2_EXTERNAL
:= $(_BR2_EXTERNAL
)
144 $(shell echo BR2_EXTERNAL ?
= $(BR2_EXTERNAL
) > $(BR2_EXTERNAL_FILE
))
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
)
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
164 GRAPHS_DIR
:= $(BASE_DIR
)/graphs
166 LEGAL_INFO_DIR
= $(BASE_DIR
)/legal-info
167 REDIST_SOURCES_DIR_TARGET
= $(LEGAL_INFO_DIR
)/sources
168 REDIST_SOURCES_DIR_HOST
= $(LEGAL_INFO_DIR
)/host-sources
169 LICENSE_FILES_DIR_TARGET
= $(LEGAL_INFO_DIR
)/licenses
170 LICENSE_FILES_DIR_HOST
= $(LEGAL_INFO_DIR
)/host-licenses
171 LEGAL_MANIFEST_CSV_TARGET
= $(LEGAL_INFO_DIR
)/manifest.csv
172 LEGAL_MANIFEST_CSV_HOST
= $(LEGAL_INFO_DIR
)/host-manifest.csv
173 LEGAL_LICENSES_TXT_TARGET
= $(LEGAL_INFO_DIR
)/licenses.txt
174 LEGAL_LICENSES_TXT_HOST
= $(LEGAL_INFO_DIR
)/host-licenses.txt
175 LEGAL_WARNINGS
= $(LEGAL_INFO_DIR
)/.warnings
176 LEGAL_REPORT
= $(LEGAL_INFO_DIR
)/README
178 BR2_CONFIG
= $(CONFIG_DIR
)/.config
180 # Pull in the user's configuration file
181 ifeq ($(filter $(noconfig_targets
),$(MAKECMDGOALS
)),)
182 -include $(BR2_CONFIG
)
185 # To put more focus on warnings, be less verbose as default
186 # Use 'make V=1' to see the full commands
188 ifeq ("$(origin V)", "command line")
189 KBUILD_VERBOSE
= $(V
)
192 ifndef KBUILD_VERBOSE
196 ifeq ($(KBUILD_VERBOSE
),1)
207 # we want bash as shell
208 SHELL
:= $(shell if
[ -x
"$$BASH" ]; then echo
$$BASH; \
209 else if
[ -x
/bin
/bash
]; then echo
/bin
/bash
; \
210 else echo sh
; fi
; fi
)
212 # kconfig uses CONFIG_SHELL
213 CONFIG_SHELL
:= $(SHELL
)
215 export SHELL CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
225 HOSTCC
:= $(shell which
$(HOSTCC
) || type
-p
$(HOSTCC
) || echo gcc
)
227 HOSTCC_NOCCACHE
:= $(HOSTCC
)
230 HOSTCXX
:= $(shell which
$(HOSTCXX
) || type
-p
$(HOSTCXX
) || echo g
++)
232 HOSTCXX_NOCCACHE
:= $(HOSTCXX
)
249 HOSTOBJCOPY
:= objcopy
254 HOSTAR
:= $(shell which
$(HOSTAR
) || type
-p
$(HOSTAR
) || echo
ar)
255 HOSTAS
:= $(shell which
$(HOSTAS
) || type
-p
$(HOSTAS
) || echo
as)
256 HOSTFC
:= $(shell which
$(HOSTLD
) || type
-p
$(HOSTLD
) || echo || which g77 || type
-p g77 || echo gfortran
)
257 HOSTCPP
:= $(shell which
$(HOSTCPP
) || type
-p
$(HOSTCPP
) || echo
cpp)
258 HOSTLD
:= $(shell which
$(HOSTLD
) || type
-p
$(HOSTLD
) || echo
ld)
259 HOSTLN
:= $(shell which
$(HOSTLN
) || type
-p
$(HOSTLN
) || echo ln
)
260 HOSTNM
:= $(shell which
$(HOSTNM
) || type
-p
$(HOSTNM
) || echo nm
)
261 HOSTOBJCOPY
:= $(shell which
$(HOSTOBJCOPY
) || type
-p
$(HOSTOBJCOPY
) || echo objcopy
)
262 HOSTRANLIB
:= $(shell which
$(HOSTRANLIB
) || type
-p
$(HOSTRANLIB
) || echo ranlib
)
264 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
265 export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
267 # Make sure pkg-config doesn't look outside the buildroot tree
268 HOST_PKG_CONFIG_PATH
:= $(PKG_CONFIG_PATH
)
269 unexport PKG_CONFIG_PATH
270 unexport PKG_CONFIG_SYSROOT_DIR
271 unexport PKG_CONFIG_LIBDIR
273 # Having DESTDIR set in the environment confuses the installation
274 # steps of some packages.
277 # Causes breakage with packages that needs host-ruby
280 include package
/pkg-utils.mk
281 include package
/doc-asciidoc.mk
283 ifeq ($(BR2_HAVE_DOT_CONFIG
),y
)
285 ################################################################################
287 # Hide troublesome environment variables from sub processes
289 ################################################################################
290 unexport CROSS_COMPILE
297 unexport GREP_OPTIONS
304 GNU_HOST_NAME
:= $(shell support
/gnuconfig
/config.guess
)
308 # silent mode requested?
309 QUIET
:= $(if
$(findstring s
,$(filter-out --%,$(MAKEFLAGS
))),-q
)
311 # Strip off the annoying quoting
312 ARCH
:= $(call qstrip
,$(BR2_ARCH
))
314 KERNEL_ARCH
:= $(shell echo
"$(ARCH)" | sed
-e
"s/-.*//" \
315 -e s
/i
.86/i386
/ -e s
/sun4u
/sparc64
/ \
318 -e s
/arm.
*/arm
/ -e s
/sa110
/arm
/ \
319 -e s
/aarch64
/arm64
/ \
320 -e s
/bfin
/blackfin
/ \
321 -e s
/parisc64
/parisc
/ \
322 -e s
/powerpc64.
*/powerpc
/ \
323 -e s
/ppc.
*/powerpc
/ -e s
/mips.
*/mips
/ \
325 -e s
/microblazeel
/microblaze
/)
327 ZCAT
:= $(call qstrip
,$(BR2_ZCAT
))
328 BZCAT
:= $(call qstrip
,$(BR2_BZCAT
))
329 XZCAT
:= $(call qstrip
,$(BR2_XZCAT
))
330 TAR_OPTIONS
= $(call qstrip
,$(BR2_TAR_OPTIONS
)) -xf
332 # packages compiled for the host go here
333 HOST_DIR
:= $(call qstrip
,$(BR2_HOST_DIR
))
335 # Quotes are needed for spaces and all in the original PATH content.
336 BR_PATH
= "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(HOST_DIR)/usr/bin:$(HOST_DIR)/usr/sbin:$(PATH)"
338 TARGET_SKELETON
= $(TOPDIR
)/system
/skeleton
340 # Location of a file giving a big fat warning that output/target
341 # should not be used as the root filesystem.
342 TARGET_DIR_WARNING_FILE
= $(TARGET_DIR
)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
344 ifeq ($(BR2_CCACHE
),y
)
345 CCACHE
:= $(HOST_DIR
)/usr
/bin
/ccache
346 BR_CACHE_DIR
= $(call qstrip
,$(BR2_CCACHE_DIR
))
348 HOSTCC
:= $(CCACHE
) $(HOSTCC
)
349 HOSTCXX
:= $(CCACHE
) $(HOSTCXX
)
352 # Scripts in support/ or post-build scripts may need to reference
353 # these locations, so export them so it is easier to use
361 ################################################################################
363 # You should probably leave this stuff alone unless you know
364 # what you are doing.
366 ################################################################################
370 # Include legacy before the other things, because package .mk files
372 ifneq ($(BR2_DEPRECATED
),y
)
373 include Makefile.legacy
376 include package
/Makefile.in
377 include support
/dependencies
/dependencies.mk
379 # We also need the various per-package makefiles, which also add
380 # each selected package to TARGETS if that package was selected
381 # in the .config file.
382 include toolchain
/*.mk
383 include toolchain
/*/*.mk
385 # Include the package override file if one has been provided in the
387 PACKAGE_OVERRIDE_FILE
= $(call qstrip
,$(BR2_PACKAGE_OVERRIDE_FILE
))
388 ifneq ($(PACKAGE_OVERRIDE_FILE
),)
389 -include $(PACKAGE_OVERRIDE_FILE
)
392 include $(sort $(wildcard package
/*/*.mk
))
394 include boot
/common.mk
395 include linux
/linux.mk
396 include system
/system.mk
399 include $(BR2_EXTERNAL
)/external.mk
401 TARGETS_SOURCE
:= $(patsubst %,%-source
,$(TARGETS
))
402 TARGETS_DIRCLEAN
:= $(patsubst %,%-dirclean
,$(TARGETS
))
404 # host-* dependencies have to be handled specially, as those aren't
405 # visible in Kconfig and hence not added to a variable like TARGETS.
406 # instead, find all the host-* targets listed in each <PKG>_DEPENDENCIES
407 # variable for each enabled target.
408 # Notice: this only works for newstyle gentargets/autotargets packages
409 TARGETS_HOST_DEPS
= $(sort $(filter host-
%,$(foreach dep
,\
410 $(addsuffix _DEPENDENCIES
,\
411 $(call UPPERCASE
,$(TARGETS
) $(TARGETS_ROOTFS
))),\
413 # Host packages can in turn have their own dependencies. Likewise find
414 # all the package names listed in the HOST_<PKG>_DEPENDENCIES for each
415 # host package found above. Ideally this should be done recursively until
416 # no more packages are found, but that's hard to do in make, so limit to
418 HOST_DEPS
= $(sort $(foreach dep
,\
419 $(addsuffix _DEPENDENCIES
,$(call UPPERCASE
,$(TARGETS_HOST_DEPS
))),\
421 HOST_SOURCE
+= $(addsuffix -source
,$(sort $(TARGETS_HOST_DEPS
) $(HOST_DEPS
)))
423 TARGETS_LEGAL_INFO
:= $(patsubst %,%-legal-info
,\
424 $(TARGETS
) $(TARGETS_HOST_DEPS
) $(HOST_DEPS
))
426 dirs
: $(BUILD_DIR
) $(STAGING_DIR
) $(TARGET_DIR
) \
427 $(HOST_DIR
) $(BINARIES_DIR
)
429 $(BUILD_DIR
)/buildroot-config
/auto.conf
: $(BR2_CONFIG
)
430 $(MAKE1
) $(EXTRAMAKEARGS
) HOSTCC
="$(HOSTCC_NOCCACHE)" HOSTCXX
="$(HOSTCXX_NOCCACHE)" silentoldconfig
432 prepare
: $(BUILD_DIR
)/buildroot-config
/auto.conf
434 world
: target-post-image
436 .PHONY
: all world toolchain dirs
clean distclean source outputmakefile \
437 legal-info legal-info-prepare legal-info-clean printvars help \
438 list-defconfigs target-finalize target-post-image \
439 $(TARGETS
) $(TARGETS_ROOTFS
) \
440 $(TARGETS_DIRCLEAN
) $(TARGETS_SOURCE
) $(TARGETS_LEGAL_INFO
) \
441 $(BUILD_DIR
) $(STAGING_DIR
) $(TARGET_DIR
) \
442 $(HOST_DIR
) $(BINARIES_DIR
)
444 ################################################################################
446 # staging and target directories do NOT list these as
447 # dependencies anywhere else
449 ################################################################################
450 $(BUILD_DIR
) $(HOST_DIR
) $(BINARIES_DIR
) $(LEGAL_INFO_DIR
) $(REDIST_SOURCES_DIR_TARGET
) $(REDIST_SOURCES_DIR_HOST
):
453 # We make a symlink lib32->lib or lib64->lib as appropriate
454 # MIPS64/n32 requires lib32 even though it's a 64-bit arch.
455 ifeq ($(BR2_ARCH_IS_64
)$(BR2_MIPS_NABI32
),y
)
462 @mkdir
-p
$(STAGING_DIR
)/bin
463 @mkdir
-p
$(STAGING_DIR
)/lib
464 @ln
-snf lib
$(STAGING_DIR
)/$(LIB_SYMLINK
)
465 @mkdir
-p
$(STAGING_DIR
)/usr
/lib
466 @ln
-snf lib
$(STAGING_DIR
)/usr
/$(LIB_SYMLINK
)
467 @mkdir
-p
$(STAGING_DIR
)/usr
/include
468 @mkdir
-p
$(STAGING_DIR
)/usr
/bin
469 @ln
-snf
$(STAGING_DIR
) $(BASE_DIR
)/staging
471 ifeq ($(BR2_ROOTFS_SKELETON_CUSTOM
),y
)
472 TARGET_SKELETON
= $(BR2_ROOTFS_SKELETON_CUSTOM_PATH
)
475 RSYNC_VCS_EXCLUSIONS
= \
476 --exclude .svn
--exclude .git
--exclude .hg
--exclude .bzr \
480 mkdir
-p
$(TARGET_DIR
)
481 rsync
-a
--ignore-times
$(RSYNC_VCS_EXCLUSIONS
) \
482 --chmod
=Du
+w
--exclude .empty
--exclude
'*~' \
483 $(TARGET_SKELETON
)/ $(TARGET_DIR
)/
484 $(INSTALL
) -m
0644 support
/misc
/target-dir-warning.txt
$(TARGET_DIR_WARNING_FILE
)
485 @ln
-snf lib
$(TARGET_DIR
)/$(LIB_SYMLINK
)
486 @mkdir
-p
$(TARGET_DIR
)/usr
487 @ln
-snf lib
$(TARGET_DIR
)/usr
/$(LIB_SYMLINK
)
490 $(TARGET_DIR
): $(BUILD_DIR
)/.root
492 STRIP_FIND_CMD
= find
$(TARGET_DIR
)
493 ifneq (,$(call qstrip
,$(BR2_STRIP_EXCLUDE_DIRS
)))
494 STRIP_FIND_CMD
+= \
( $(call finddirclauses
,$(TARGET_DIR
),$(call qstrip
,$(BR2_STRIP_EXCLUDE_DIRS
))) \
) -prune
-o
496 STRIP_FIND_CMD
+= -type f \
( -perm
/111 -o
-name
'*.so*' \
)
498 # - libpthread.so: a non-stripped libpthread shared library is needed for
499 # proper debugging of pthread programs using gdb.
500 # - kernel modules (*.ko): do not function properly when stripped like normal
501 # applications and libraries. Normally kernel modules are already excluded
502 # by the executable permission check above, so the explicit exclusion is only
503 # done for kernel modules with incorrect permissions.
504 STRIP_FIND_CMD
+= -not \
( $(call findfileclauses
,libpthread
*.so
* *.ko
$(call qstrip
,$(BR2_STRIP_EXCLUDE_FILES
))) \
) -print0
506 ifeq ($(BR2_ECLIPSE_REGISTER
),y
)
507 define TOOLCHAIN_ECLIPSE_REGISTER
508 .
/support
/scripts
/eclipse-register-toolchain
`readlink -f $(O)` \
509 $(notdir $(TARGET_CROSS
)) $(BR2_ARCH
)
511 TARGET_FINALIZE_HOOKS
+= TOOLCHAIN_ECLIPSE_REGISTER
514 # Generate locale data. Basically, we call the localedef program
515 # (built by the host-localedef package) for each locale. The input
516 # data comes preferably from the toolchain, or if the toolchain does
517 # not have them (Linaro toolchains), we use the ones available on the
519 ifeq ($(BR2_TOOLCHAIN_USES_GLIBC
),y
)
520 GLIBC_GENERATE_LOCALES
= $(call qstrip
,$(BR2_GENERATE_LOCALE
))
521 ifneq ($(GLIBC_GENERATE_LOCALES
),)
522 TARGETS
+= host-localedef
524 define GENERATE_GLIBC_LOCALES
525 $(Q
)mkdir
-p
$(TARGET_DIR
)/usr
/lib
/locale
/
526 $(Q
)for locale in
$(GLIBC_GENERATE_LOCALES
) ; do \
527 inputfile
=`echo $${locale} | cut -f1 -d'.'` ; \
528 charmap
=`echo $${locale} | cut -f2 -d'.' -s` ; \
529 if
test -z
"$${charmap}" ; then \
532 echo
"Generating locale $${inputfile}.$${charmap}" ; \
533 I18NPATH
=$(STAGING_DIR
)/usr
/share
/i18n
:/usr
/share
/i18n \
534 $(HOST_DIR
)/usr
/bin
/localedef \
535 --prefix=$(TARGET_DIR
) \
536 --$(call LOWERCASE
,$(BR2_ENDIAN
))-endian \
537 -i
$${inputfile} -f
$${charmap} \
541 TARGET_FINALIZE_HOOKS
+= GENERATE_GLIBC_LOCALES
545 ifeq ($(BR2_ENABLE_LOCALE_PURGE
),y
)
546 LOCALE_WHITELIST
= $(BUILD_DIR
)/locales.nopurge
547 LOCALE_NOPURGE
= $(call qstrip
,$(BR2_ENABLE_LOCALE_WHITELIST
))
550 rm -f
$(LOCALE_WHITELIST
)
551 for i in
$(LOCALE_NOPURGE
) locale-archive
; do echo
$$i >> $(LOCALE_WHITELIST
); done
553 for
dir in
$(wildcard $(addprefix $(TARGET_DIR
),/usr
/share
/locale
/usr
/share
/X11
/locale
/usr
/man
/usr
/share
/man
/usr
/lib
/locale
)); \
555 for lang in
$$(cd
$$dir; ls .|grep
-v man
); \
557 grep
-qx
$$lang $(LOCALE_WHITELIST
) ||
rm -rf
$$dir/$$lang; \
561 TARGET_FINALIZE_HOOKS
+= PURGE_LOCALES
564 $(TARGETS_ROOTFS
): target-finalize
566 target-finalize
: $(TARGETS
)
567 @
$(call MESSAGE
,"Finalizing target directory")
568 $(foreach hook
,$(TARGET_FINALIZE_HOOKS
),$($(hook
))$(sep
))
569 rm -rf
$(TARGET_DIR
)/usr
/include $(TARGET_DIR
)/usr
/share
/aclocal \
570 $(TARGET_DIR
)/usr
/lib
/pkgconfig
$(TARGET_DIR
)/usr
/share
/pkgconfig \
571 $(TARGET_DIR
)/usr
/lib
/cmake
$(TARGET_DIR
)/usr
/share
/cmake
572 find
$(TARGET_DIR
)/usr
/{lib
,share
}/ -name
'*.cmake' -print0 | xargs
-0 rm -f
573 find
$(TARGET_DIR
)/lib \
( -name
'*.a' -o
-name
'*.la' \
) -print0 | xargs
-0 rm -f
574 find
$(TARGET_DIR
)/usr
/lib \
( -name
'*.a' -o
-name
'*.la' \
) -print0 | xargs
-0 rm -f
575 ifneq ($(BR2_PACKAGE_GDB
),y
)
576 rm -rf
$(TARGET_DIR
)/usr
/share
/gdb
578 rm -rf
$(TARGET_DIR
)/usr
/man
$(TARGET_DIR
)/usr
/share
/man
579 rm -rf
$(TARGET_DIR
)/usr
/info $(TARGET_DIR
)/usr
/share
/info
580 rm -rf
$(TARGET_DIR
)/usr
/doc
$(TARGET_DIR
)/usr
/share
/doc
581 rm -rf
$(TARGET_DIR
)/usr
/share
/gtk-doc
582 -rmdir
$(TARGET_DIR
)/usr
/share
2>/dev
/null
583 $(STRIP_FIND_CMD
) | xargs
-0 $(STRIPCMD
) 2>/dev
/null || true
584 if
test -d
$(TARGET_DIR
)/lib
/modules
; then \
585 find
$(TARGET_DIR
)/lib
/modules
-type f
-name
'*.ko' | \
586 xargs
-r
$(KSTRIPCMD
); fi
588 # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
589 # besides the one in which crash occurred; or SIGTRAP kills my program when
590 # I set a breakpoint"
591 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS
),y
)
592 find
$(TARGET_DIR
)/lib
-type f
-name
'libpthread*.so*' | \
593 xargs
-r
$(STRIPCMD
) $(STRIP_STRIP_DEBUG
)
596 mkdir
-p
$(TARGET_DIR
)/etc
597 # Mandatory configuration file and auxilliary cache directory
598 # for recent versions of ldconfig
599 touch
$(TARGET_DIR
)/etc
/ld.so.conf
600 mkdir
-p
$(TARGET_DIR
)/var
/cache
/ldconfig
601 if
[ -x
"$(TARGET_CROSS)ldconfig" ]; \
603 $(TARGET_CROSS
)ldconfig
-r
$(TARGET_DIR
); \
605 /sbin
/ldconfig
-r
$(TARGET_DIR
); \
608 echo
"NAME=Buildroot"; \
609 echo
"VERSION=$(BR2_VERSION_FULL)"; \
610 echo
"ID=buildroot"; \
611 echo
"VERSION_ID=$(BR2_VERSION)"; \
612 echo
"PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
613 ) > $(TARGET_DIR
)/etc
/os-release
615 @
$(foreach d
, $(call qstrip
,$(BR2_ROOTFS_OVERLAY
)), \
616 $(call MESSAGE
,"Copying overlay $(d)"); \
617 rsync
-a
--ignore-times
$(RSYNC_VCS_EXCLUSIONS
) \
618 --chmod
=Du
+w
--exclude .empty
--exclude
'*~' \
619 $(d
)/ $(TARGET_DIR
)$(sep
))
621 @
$(foreach s
, $(call qstrip
,$(BR2_ROOTFS_POST_BUILD_SCRIPT
)), \
622 $(call MESSAGE
,"Executing post-build script $(s)"); \
623 $(EXTRA_ENV
) $(s
) $(TARGET_DIR
) $(call qstrip
,$(BR2_ROOTFS_POST_SCRIPT_ARGS
))$(sep
))
625 target-post-image
: $(TARGETS_ROOTFS
) target-finalize
626 @
$(foreach s
, $(call qstrip
,$(BR2_ROOTFS_POST_IMAGE_SCRIPT
)), \
627 $(call MESSAGE
,"Executing post-image script $(s)"); \
628 $(EXTRA_ENV
) $(s
) $(BINARIES_DIR
) $(call qstrip
,$(BR2_ROOTFS_POST_SCRIPT_ARGS
))$(sep
))
630 source
: $(TARGETS_SOURCE
) $(HOST_SOURCE
)
633 @
$(MAKE1
) -Bs DL_MODE
=SHOW_EXTERNAL_DEPS
$(EXTRAMAKEARGS
) source |
sort -u
636 @
rm -fr
$(LEGAL_INFO_DIR
)
638 legal-info-prepare
: $(LEGAL_INFO_DIR
)
639 @
$(call MESSAGE
,"Collecting legal info")
640 @
$(call legal-license-file
,buildroot
,COPYING
,COPYING
,HOST
)
641 @
$(call legal-manifest
,PACKAGE
,VERSION
,LICENSE
,LICENSE FILES
,SOURCE ARCHIVE
,SOURCE SITE
,TARGET
)
642 @
$(call legal-manifest
,PACKAGE
,VERSION
,LICENSE
,LICENSE FILES
,SOURCE ARCHIVE
,SOURCE SITE
,HOST
)
643 @
$(call legal-manifest
,buildroot
,$(BR2_VERSION_FULL
),GPLv2
+,COPYING
,not saved
,not saved
,HOST
)
644 @
$(call legal-warning
,the Buildroot source code has not been saved
)
645 @
$(call legal-warning
,the toolchain has not been saved
)
646 @cp
$(BR2_CONFIG
) $(LEGAL_INFO_DIR
)/buildroot.config
648 legal-info
: dirs legal-info-clean legal-info-prepare
$(TARGETS_LEGAL_INFO
) \
649 $(REDIST_SOURCES_DIR_TARGET
) $(REDIST_SOURCES_DIR_HOST
)
650 @cat support
/legal-info
/README.header
>>$(LEGAL_REPORT
)
651 @if
[ -r
$(LEGAL_WARNINGS
) ]; then \
652 cat support
/legal-info
/README.warnings-header \
653 $(LEGAL_WARNINGS
) >>$(LEGAL_REPORT
); \
654 cat
$(LEGAL_WARNINGS
); fi
655 @echo
"Legal info produced in $(LEGAL_INFO_DIR)"
656 @
rm -f
$(LEGAL_WARNINGS
)
659 @echo
$(HOST_DEPS
) $(TARGETS_HOST_DEPS
) $(TARGETS
) $(TARGETS_ROOTFS
)
661 graph-build
: $(O
)/build
/build-time.log
662 @
install -d
$(GRAPHS_DIR
)
663 $(foreach o
,name build duration
,.
/support
/scripts
/graph-build-time \
664 --type
=histogram
--order
=$(o
) --input
=$(<) \
665 --output
=$(GRAPHS_DIR
)/build.hist-
$(o
).
$(BR_GRAPH_OUT
) \
666 $(if
$(BR2_GRAPH_ALT
),--alternate-colors
)$(sep
))
667 $(foreach t
,packages steps
,.
/support
/scripts
/graph-build-time \
668 --type
=pie-
$(t
) --input
=$(<) \
669 --output
=$(GRAPHS_DIR
)/build.pie-
$(t
).
$(BR_GRAPH_OUT
) \
670 $(if
$(BR2_GRAPH_ALT
),--alternate-colors
)$(sep
))
672 graph-depends-requirements
:
673 @dot
-?
>/dev
/null
2>&1 || \
674 { echo
"ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit
1; }
676 graph-depends
: graph-depends-requirements
677 @
$(INSTALL
) -d
$(GRAPHS_DIR
)
678 @cd
"$(CONFIG_DIR)"; \
679 $(TOPDIR
)/support
/scripts
/graph-depends
$(BR2_GRAPH_DEPS_OPTS
) \
680 |tee
$(GRAPHS_DIR
)/$(@
).dot \
681 |dot
$(BR2_GRAPH_DOT_OPTS
) -T
$(BR_GRAPH_OUT
) -o
$(GRAPHS_DIR
)/$(@
).
$(BR_GRAPH_OUT
)
683 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
687 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
690 # ---------------------------------------------------------------------------
692 HOSTCFLAGS
= $(CFLAGS_FOR_BUILD
)
695 $(BUILD_DIR
)/buildroot-config
/%onf
:
696 mkdir
-p
$(@D
)/lxdialog
697 PKG_CONFIG_PATH
="$(HOST_PKG_CONFIG_PATH)" $(MAKE
) CC
="$(HOSTCC_NOCCACHE)" HOSTCC
="$(HOSTCC_NOCCACHE)" \
698 obj
=$(@D
) -C
$(CONFIG
) -f Makefile.br
$(@F
)
700 DEFCONFIG
= $(call qstrip
,$(BR2_DEFCONFIG
))
702 # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
703 # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
704 COMMON_CONFIG_ENV
= \
705 BR2_DEFCONFIG
='$(call qstrip,$(value BR2_DEFCONFIG))' \
706 KCONFIG_AUTOCONFIG
=$(BUILD_DIR
)/buildroot-config
/auto.conf \
707 KCONFIG_AUTOHEADER
=$(BUILD_DIR
)/buildroot-config
/autoconf.h \
708 KCONFIG_TRISTATE
=$(BUILD_DIR
)/buildroot-config
/tristate.config \
709 BR2_CONFIG
=$(BR2_CONFIG
) \
710 BR2_EXTERNAL
=$(BR2_EXTERNAL
)
712 xconfig
: $(BUILD_DIR
)/buildroot-config
/qconf outputmakefile
713 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
714 @
$(COMMON_CONFIG_ENV
) $< $(CONFIG_CONFIG_IN
)
716 gconfig
: $(BUILD_DIR
)/buildroot-config
/gconf outputmakefile
717 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
718 @
$(COMMON_CONFIG_ENV
) srctree
=$(TOPDIR
) $< $(CONFIG_CONFIG_IN
)
720 menuconfig
: $(BUILD_DIR
)/buildroot-config
/mconf outputmakefile
721 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
722 @
$(COMMON_CONFIG_ENV
) $< $(CONFIG_CONFIG_IN
)
724 nconfig
: $(BUILD_DIR
)/buildroot-config
/nconf outputmakefile
725 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
726 @
$(COMMON_CONFIG_ENV
) $< $(CONFIG_CONFIG_IN
)
728 config
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
729 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
730 @
$(COMMON_CONFIG_ENV
) $< $(CONFIG_CONFIG_IN
)
732 oldconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
733 mkdir
-p
$(BUILD_DIR
)/buildroot-config
734 @
$(COMMON_CONFIG_ENV
) $< --oldconfig
$(CONFIG_CONFIG_IN
)
736 randconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
737 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
738 @
$(COMMON_CONFIG_ENV
) $< --randconfig
$(CONFIG_CONFIG_IN
)
740 allyesconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
741 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
742 @
$(COMMON_CONFIG_ENV
) $< --allyesconfig
$(CONFIG_CONFIG_IN
)
744 allnoconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
745 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
746 @
$(COMMON_CONFIG_ENV
) $< --allnoconfig
$(CONFIG_CONFIG_IN
)
748 randpackageconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
749 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
750 @grep
-v BR2_PACKAGE_
$(BR2_CONFIG
) > $(CONFIG_DIR
)/.config.nopkg
751 @grep
'^config BR2_PACKAGE_' Config.in.legacy | \
752 while read config pkg
; do \
753 echo
"# $$pkg is not set" >> $(CONFIG_DIR
)/.config.nopkg
; done
754 @
$(COMMON_CONFIG_ENV
) \
755 KCONFIG_ALLCONFIG
=$(CONFIG_DIR
)/.config.nopkg \
756 $< --randconfig
$(CONFIG_CONFIG_IN
)
757 @
rm -f
$(CONFIG_DIR
)/.config.nopkg
759 allyespackageconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
760 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
761 @grep
-v BR2_PACKAGE_
$(BR2_CONFIG
) > $(CONFIG_DIR
)/.config.nopkg
762 @grep
'^config BR2_PACKAGE_' Config.in.legacy | \
763 while read config pkg
; do \
764 echo
"# $$pkg is not set" >> $(CONFIG_DIR
)/.config.nopkg
; done
765 @
$(COMMON_CONFIG_ENV
) \
766 KCONFIG_ALLCONFIG
=$(CONFIG_DIR
)/.config.nopkg \
767 $< --allyesconfig
$(CONFIG_CONFIG_IN
)
768 @
rm -f
$(CONFIG_DIR
)/.config.nopkg
770 allnopackageconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
771 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
772 @grep
-v BR2_PACKAGE_
$(BR2_CONFIG
) > $(CONFIG_DIR
)/.config.nopkg
773 @
$(COMMON_CONFIG_ENV
) \
774 KCONFIG_ALLCONFIG
=$(CONFIG_DIR
)/.config.nopkg \
775 $< --allnoconfig
$(CONFIG_CONFIG_IN
)
776 @
rm -f
$(CONFIG_DIR
)/.config.nopkg
778 silentoldconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
779 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
780 $(COMMON_CONFIG_ENV
) $< --silentoldconfig
$(CONFIG_CONFIG_IN
)
782 olddefconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
783 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
784 $(COMMON_CONFIG_ENV
) $< --olddefconfig
$(CONFIG_CONFIG_IN
)
786 defconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
787 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
788 @
$(COMMON_CONFIG_ENV
) $< --defconfig
$(if
$(DEFCONFIG
),=$(DEFCONFIG
)) $(CONFIG_CONFIG_IN
)
790 # Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig
791 %_defconfig
: $(BUILD_DIR
)/buildroot-config
/conf
$(TOPDIR
)/configs
/%_defconfig outputmakefile
792 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
793 @
$(COMMON_CONFIG_ENV
) BR2_DEFCONFIG
=$(TOPDIR
)/configs
/$@ \
794 $< --defconfig
=$(TOPDIR
)/configs
/$@
$(CONFIG_CONFIG_IN
)
796 %_defconfig
: $(BUILD_DIR
)/buildroot-config
/conf
$(BR2_EXTERNAL
)/configs
/%_defconfig outputmakefile
797 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
798 @
$(COMMON_CONFIG_ENV
) BR2_DEFCONFIG
=$(BR2_EXTERNAL
)/configs
/$@ \
799 $< --defconfig
=$(BR2_EXTERNAL
)/configs
/$@
$(CONFIG_CONFIG_IN
)
801 savedefconfig
: $(BUILD_DIR
)/buildroot-config
/conf outputmakefile
802 @mkdir
-p
$(BUILD_DIR
)/buildroot-config
803 @
$(COMMON_CONFIG_ENV
) $< \
804 --savedefconfig
=$(if
$(DEFCONFIG
),$(DEFCONFIG
),$(CONFIG_DIR
)/defconfig
) \
807 # check if download URLs are outdated
809 $(MAKE1
) DL_MODE
=SOURCE_CHECK
$(EXTRAMAKEARGS
) source
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 Makefiles
830 $(sort $(.VARIABLES
)), \
831 $(if
$(filter-out environment
% default automatic
, \
833 $(info $V=$($V) ($(value
$V)))))
836 rm -rf
$(TARGET_DIR
) $(BINARIES_DIR
) $(HOST_DIR
) \
837 $(BUILD_DIR
) $(BASE_DIR
)/staging \
838 $(LEGAL_INFO_DIR
) $(GRAPHS_DIR
)
841 ifeq ($(DL_DIR
),$(TOPDIR
)/dl
)
847 rm -rf
$(BR2_CONFIG
) $(CONFIG_DIR
)/.config.old
$(CONFIG_DIR
)/..config.tmp \
848 $(CONFIG_DIR
)/.auto.deps
852 @echo
' clean - delete all files created by build'
853 @echo
' distclean - delete all non-source files (including .config)'
856 @echo
' all - make world'
857 @echo
' toolchain - build toolchain'
859 @echo
'Configuration:'
860 @echo
' menuconfig - interactive curses-based configurator'
861 @echo
' nconfig - interactive ncurses-based configurator'
862 @echo
' xconfig - interactive Qt-based configurator'
863 @echo
' gconfig - interactive GTK-based configurator'
864 @echo
' oldconfig - resolve any unresolved symbols in .config'
865 @echo
' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
866 @echo
' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
867 @echo
' randconfig - New config with random answer to all options'
868 @echo
' defconfig - New config with default answer to all options'
869 @echo
' BR2_DEFCONFIG, if set, is used as input'
870 @echo
' savedefconfig - Save current config to BR2_DEFCONFIG (minimal config)'
871 @echo
' allyesconfig - New config where all options are accepted with yes'
872 @echo
' allnoconfig - New config where all options are answered with no'
873 @echo
' randpackageconfig - New config with random answer to package options'
874 @echo
' allyespackageconfig - New config where pkg options are accepted with yes'
875 @echo
' allnopackageconfig - New config where package options are answered with no'
877 @echo
'Package-specific:'
878 @echo
' <pkg> - Build and install <pkg> and all its dependencies'
879 @echo
' <pkg>-source - Only download the source files for <pkg>'
880 @echo
' <pkg>-extract - Extract <pkg> sources'
881 @echo
' <pkg>-patch - Apply patches to <pkg>'
882 @echo
' <pkg>-depends - Build <pkg>'\''s dependencies'
883 @echo
' <pkg>-configure - Build <pkg> up to the configure step'
884 @echo
' <pkg>-build - Build <pkg> up to the build step'
885 @echo
' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies'
886 @echo
' <pkg>-dirclean - Remove <pkg> build directory'
887 @echo
' <pkg>-reconfigure - Restart the build from the configure step'
888 @echo
' <pkg>-rebuild - Restart the build from the build step'
889 @echo
' <pkg>-legal-info - Generate license information for <pkg>'
890 ifeq ($(BR2_PACKAGE_BUSYBOX
),y
)
891 @echo
' busybox-menuconfig - Run BusyBox menuconfig'
893 ifeq ($(BR2_LINUX_KERNEL
),y
)
894 @echo
' linux-menuconfig - Run Linux kernel menuconfig'
895 @echo
' linux-savedefconfig - Run Linux kernel savedefconfig'
897 ifeq ($(BR2_TOOLCHAIN_BUILDROOT
),y
)
898 @echo
' uclibc-menuconfig - Run uClibc menuconfig'
900 ifeq ($(BR2_TARGET_BAREBOX
),y
)
901 @echo
' barebox-menuconfig - Run barebox menuconfig'
902 @echo
' barebox-savedefconfig - Run barebox savedefconfig'
905 @echo
'Documentation:'
906 @echo
' manual - build manual in all formats'
907 @echo
' manual-html - build manual in HTML'
908 @echo
' manual-split-html - build manual in split HTML'
909 @echo
' manual-pdf - build manual in PDF'
910 @echo
' manual-text - build manual in text'
911 @echo
' manual-epub - build manual in ePub'
912 @echo
' graph-build - generate graphs of the build times'
913 @echo
' graph-depends - generate graph of the dependency tree'
915 @echo
'Miscellaneous:'
916 @echo
' source - download all sources needed for offline-build'
917 @echo
' source-check - check selected packages for valid download URLs'
918 @echo
' external-deps - list external packages used'
919 @echo
' legal-info - generate info about license compliance'
921 @echo
' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
922 @echo
' make O=dir - Locate all output files in "dir", including .config'
924 @echo
'For further details, see README, generate the Buildroot manual, or consult'
925 @echo
'it on-line at http://buildroot.org/docs.html'
929 @echo
'Built-in configs:'
930 @
$(foreach b
, $(sort $(notdir $(wildcard $(TOPDIR
)/configs
/*_defconfig
))), \
931 printf
" %-35s - Build for %s\\n" $(b
) $(b
:_defconfig
=);)
932 ifneq ($(wildcard $(BR2_EXTERNAL
)/configs
/*_defconfig
),)
934 @echo
'User-provided configs:'
935 @
$(foreach b
, $(sort $(notdir $(wildcard $(BR2_EXTERNAL
)/configs
/*_defconfig
))), \
936 printf
" %-35s - Build for %s\\n" $(b
) $(b
:_defconfig
=);)
940 release
: OUT
= buildroot-
$(BR2_VERSION
)
942 # Create release tarballs. We need to fiddle a bit to add the generated
943 # documentation to the git output
945 git archive
--format
=tar --prefix=$(OUT
)/ HEAD
> $(OUT
).
tar
946 $(MAKE
) O
=$(OUT
) manual-html manual-text manual-pdf
947 tar rf
$(OUT
).
tar $(OUT
)
948 gzip
-9 -c
< $(OUT
).
tar > $(OUT
).
tar.gz
949 bzip2
-9 -c
< $(OUT
).
tar > $(OUT
).
tar.bz2
950 rm -rf
$(OUT
) $(OUT
).
tar
953 @echo
$(BR2_VERSION_FULL
)
955 include docs
/manual
/manual.mk
956 -include $(BR2_EXTERNAL
)/docs
/*/*.mk
958 .PHONY
: $(noconfig_targets
)