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