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