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