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