]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - Makefile
Update for 2011.08
[coffee/buildroot.git] / Makefile
1 # Makefile for buildroot2
2 #
3 # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4 # Copyright (C) 2006-2011 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:=2011.08
28
29 # This top-level Makefile can *not* be executed in parallel
30 .NOTPARALLEL:
31
32 # absolute path
33 TOPDIR:=$(shell pwd)
34 CONFIG_CONFIG_IN=Config.in
35 CONFIG=package/config
36 DATE:=$(shell date +%Y%m%d)
37
38 # Compute the full local version string so packages can use it as-is
39 # Need to export it, so it can be got from environment in children (eg. mconf)
40 export BR2_VERSION_FULL:=$(BR2_VERSION)$(shell $(TOPDIR)/scripts/setlocalversion)
41
42 noconfig_targets:=menuconfig nconfig gconfig xconfig config oldconfig randconfig \
43         defconfig %_defconfig savedefconfig allyesconfig allnoconfig silentoldconfig release \
44         randpackageconfig allyespackageconfig allnopackageconfig \
45         source-check
46
47 # Strip quotes and then whitespaces
48 qstrip=$(strip $(subst ",,$(1)))
49 #"))
50
51 # Variables for use in Make constructs
52 comma:=,
53 empty:=
54 space:=$(empty) $(empty)
55
56 ifneq ("$(origin O)", "command line")
57 O:=output
58 CONFIG_DIR:=$(TOPDIR)
59 NEED_WRAPPER=
60 else
61 # other packages might also support Linux-style out of tree builds
62 # with the O=<dir> syntax (E.G. Busybox does). As make automatically
63 # forwards command line variable definitions those packages get very
64 # confused. Fix this by telling make to not do so
65 MAKEOVERRIDES =
66 # strangely enough O is still passed to submakes with MAKEOVERRIDES
67 # (with make 3.81 atleast), the only thing that changes is the output
68 # of the origin function (command line -> environment).
69 # Unfortunately some packages don't look at origin (E.G. uClibc 0.9.31+)
70 # To really make O go away, we have to override it.
71 override O:=$(O)
72 CONFIG_DIR:=$(O)
73 # we need to pass O= everywhere we call back into the toplevel makefile
74 EXTRAMAKEARGS = O=$(O)
75 NEED_WRAPPER=y
76 endif
77
78 # Pull in the user's configuration file
79 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
80 -include $(CONFIG_DIR)/.config
81 endif
82
83 # Override BR2_DL_DIR if shell variable defined
84 ifneq ($(BUILDROOT_DL_DIR),)
85 BR2_DL_DIR:=$(BUILDROOT_DL_DIR)
86 endif
87
88 # To put more focus on warnings, be less verbose as default
89 # Use 'make V=1' to see the full commands
90 ifdef V
91   ifeq ("$(origin V)", "command line")
92     KBUILD_VERBOSE=$(V)
93   endif
94 endif
95 ifndef KBUILD_VERBOSE
96   KBUILD_VERBOSE=0
97 endif
98
99 ifeq ($(KBUILD_VERBOSE),1)
100   quiet=
101   Q=
102 ifndef VERBOSE
103   VERBOSE=1
104 endif
105 else
106   quiet=quiet_
107   Q=@
108 endif
109
110 # we want bash as shell
111 SHELL:=$(shell if [ -x "$$BASH" ]; then echo $$BASH; \
112         else if [ -x /bin/bash ]; then echo /bin/bash; \
113         else echo sh; fi; fi)
114
115 # kconfig uses CONFIG_SHELL
116 CONFIG_SHELL:=$(SHELL)
117
118 export SHELL CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
119
120 ifndef HOSTAR
121 HOSTAR:=ar
122 endif
123 ifndef HOSTAS
124 HOSTAS:=as
125 endif
126 ifndef HOSTCC
127 HOSTCC:=gcc
128 HOSTCC:=$(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
129 endif
130 HOSTCC_NOCCACHE:=$(HOSTCC)
131 ifndef HOSTCXX
132 HOSTCXX:=g++
133 HOSTCXX:=$(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
134 endif
135 HOSTCXX_NOCCACHE:=$(HOSTCXX)
136 ifndef HOSTFC
137 HOSTFC:=gfortran
138 endif
139 ifndef HOSTCPP
140 HOSTCPP:=cpp
141 endif
142 ifndef HOSTLD
143 HOSTLD:=ld
144 endif
145 ifndef HOSTLN
146 HOSTLN:=ln
147 endif
148 ifndef HOSTNM
149 HOSTNM:=nm
150 endif
151 HOSTAR:=$(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
152 HOSTAS:=$(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
153 HOSTFC:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran)
154 HOSTCPP:=$(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
155 HOSTLD:=$(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
156 HOSTLN:=$(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
157 HOSTNM:=$(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
158
159 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
160 export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
161
162 # bash prints the name of the directory on 'cd <dir>' if CDPATH is
163 # set, so unset it here to not cause problems. Notice that the export
164 # line doesn't affect the environment of $(shell ..) calls, so
165 # explictly throw away any output from 'cd' here.
166 export CDPATH:=
167 BASE_DIR := $(shell mkdir -p $(O) && cd $(O) >/dev/null && pwd)
168 $(if $(BASE_DIR),, $(error output directory "$(O)" does not exist))
169
170 BUILD_DIR:=$(BASE_DIR)/build
171
172
173 ifeq ($(BR2_HAVE_DOT_CONFIG),y)
174
175 # cc-option
176 # Usage: cflags-y+=$(call cc-option, -march=winchip-c6, -march=i586)
177 # sets -march=winchip-c6 if supported else falls back to -march=i586
178 # without checking the latter.
179 cc-option=$(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
180         > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
181
182 #############################################################
183 #
184 # Hide troublesome environment variables from sub processes
185 #
186 #############################################################
187 unexport CROSS_COMPILE
188 unexport ARCH
189 unexport CC
190 unexport CXX
191 unexport CPP
192 unexport CFLAGS
193 unexport CXXFLAGS
194 unexport GREP_OPTIONS
195
196 GNU_HOST_NAME:=$(shell package/gnuconfig/config.guess)
197
198 #############################################################
199 #
200 # Setup the proper filename extensions for the host
201 #
202 ##############################################################
203 ifneq ($(findstring linux,$(GNU_HOST_NAME)),)
204 HOST_EXEEXT:=
205 HOST_LIBEXT:=.a
206 HOST_SHREXT:=.so
207 endif
208 ifneq ($(findstring apple,$(GNU_HOST_NAME)),)
209 HOST_EXEEXT:=
210 HOST_LIBEXT:=.a
211 HOST_SHREXT:=.dylib
212 endif
213 ifneq ($(findstring cygwin,$(GNU_HOST_NAME)),)
214 HOST_EXEEXT:=.exe
215 HOST_LIBEXT:=.lib
216 HOST_SHREXT:=.dll
217 HOST_LOADLIBES=-lcurses -lintl
218 export HOST_LOADLIBES
219 endif
220 ifneq ($(findstring mingw,$(GNU_HOST_NAME)),)
221 HOST_EXEEXT:=.exe
222 HOST_LIBEXT:=.lib
223 HOST_SHREXT:=.dll
224 endif
225
226 ##############################################################
227 #
228 # The list of stuff to build for the target toolchain
229 # along with the packages to build for the target.
230 #
231 ##############################################################
232
233 ifeq ($(BR2_CCACHE),y)
234 BASE_TARGETS += host-ccache
235 endif
236
237 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
238 BASE_TARGETS += uclibc-configured host-binutils cross_compiler uclibc-target-utils kernel-headers
239 else
240 BASE_TARGETS += uclibc
241 endif
242 TARGETS:=
243
244 # silent mode requested?
245 QUIET:=$(if $(findstring s,$(MAKEFLAGS)),-q)
246
247 # Strip off the annoying quoting
248 ARCH:=$(call qstrip,$(BR2_ARCH))
249 ifeq ($(ARCH),xtensa)
250 ARCH:=$(ARCH)_$(call qstrip,$(BR2_xtensa_core_name))
251 endif
252
253 KERNEL_ARCH:=$(shell echo "$(ARCH)" | sed -e "s/-.*//" \
254         -e s/i.86/i386/ -e s/sun4u/sparc64/ \
255         -e s/arm.*/arm/ -e s/sa110/arm/ \
256         -e s/bfin/blackfin/ \
257         -e s/parisc64/parisc/ \
258         -e s/powerpc64/powerpc/ \
259         -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
260         -e s/sh.*/sh/)
261
262 ZCAT:=$(call qstrip,$(BR2_ZCAT))
263 BZCAT:=$(call qstrip,$(BR2_BZCAT))
264 XZCAT:=$(call qstrip,$(BR2_XZCAT))
265 TAR_OPTIONS=$(call qstrip,$(BR2_TAR_OPTIONS)) -xf
266
267 GNU_TARGET_SUFFIX:=-$(call qstrip,$(BR2_GNU_TARGET_SUFFIX))
268
269 # packages compiled for the host go here
270 HOST_DIR:=$(call qstrip,$(BR2_HOST_DIR))
271
272 # stamp (dependency) files go here
273 STAMP_DIR:=$(BASE_DIR)/stamps
274
275 BINARIES_DIR:=$(BASE_DIR)/images
276 TARGET_DIR:=$(BASE_DIR)/target
277 TOOLCHAIN_DIR=$(BASE_DIR)/toolchain
278 TARGET_SKELETON=$(TOPDIR)/fs/skeleton
279
280 BR2_DEPENDS_DIR=$(BUILD_DIR)/buildroot-config
281
282 ifeq ($(BR2_CCACHE),y)
283 CCACHE:=$(HOST_DIR)/usr/bin/ccache
284 CCACHE_CACHE_DIR=$(HOME)/.buildroot-ccache
285 HOSTCC  := $(CCACHE) $(HOSTCC)
286 HOSTCXX := $(CCACHE) $(HOSTCXX)
287 endif
288
289 include toolchain/Makefile.in
290 include package/Makefile.in
291
292 #############################################################
293 #
294 # You should probably leave this stuff alone unless you know
295 # what you are doing.
296 #
297 #############################################################
298
299 all: world
300
301 # We also need the various per-package makefiles, which also add
302 # each selected package to TARGETS if that package was selected
303 # in the .config file.
304 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
305 include toolchain/toolchain-buildroot.mk
306 else ifeq ($(BR2_TOOLCHAIN_EXTERNAL),y)
307 include toolchain/toolchain-external.mk
308 else ifeq ($(BR2_TOOLCHAIN_CTNG),y)
309 include toolchain/toolchain-crosstool-ng.mk
310 endif
311
312 include package/*/*.mk
313
314 include boot/common.mk
315 include target/Makefile.in
316 include linux/linux.mk
317
318 TARGETS+=target-finalize
319
320 ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
321 TARGETS+=target-purgelocales
322 endif
323
324 include fs/common.mk
325
326 TARGETS+=erase-fakeroots
327
328 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
329 TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS) $(BASE_TARGETS))
330 TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
331 TARGETS_ALL:=$(patsubst %,__real_tgt_%,$(TARGETS))
332
333 # host-* dependencies have to be handled specially, as those aren't
334 # visible in Kconfig and hence not added to a variable like TARGETS.
335 # instead, find all the host-* targets listed in each <PKG>_DEPENDENCIES
336 # variable for each enabled target.
337 # Notice: this only works for newstyle gentargets/autotargets packages
338 TARGETS_HOST_DEPS = $(sort $(filter host-%,$(foreach dep,\
339                 $(addsuffix _DEPENDENCIES,$(call UPPERCASE,$(TARGETS))),\
340                 $($(dep)))))
341 # Host packages can in turn have their own dependencies. Likewise find
342 # all the package names listed in the HOST_<PKG>_DEPENDENCIES for each
343 # host package found above. Ideally this should be done recursively until
344 # no more packages are found, but that's hard to do in make, so limit to
345 # 1 level for now.
346 HOST_DEPS = $(sort $(foreach dep,\
347                 $(addsuffix _DEPENDENCIES,$(call UPPERCASE,$(TARGETS_HOST_DEPS))),\
348                 $($(dep))))
349 HOST_SOURCE += $(addsuffix -source,$(sort $(TARGETS_HOST_DEPS) $(HOST_DEPS)))
350
351 # all targets depend on the crosscompiler and it's prerequisites
352 $(TARGETS_ALL): __real_tgt_%: $(BASE_TARGETS) %
353
354 dirs: $(DL_DIR) $(TOOLCHAIN_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
355         $(HOST_DIR) $(BR2_DEPENDS_DIR) $(BINARIES_DIR) $(STAMP_DIR)
356
357 $(BASE_TARGETS): dirs $(O)/toolchainfile.cmake
358
359 $(BUILD_DIR)/buildroot-config/auto.conf: $(CONFIG_DIR)/.config
360         $(MAKE) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" silentoldconfig
361
362 prepare: $(BUILD_DIR)/buildroot-config/auto.conf
363
364 world: prepare dependencies dirs $(BASE_TARGETS) $(TARGETS_ALL)
365
366 $(O)/toolchainfile.cmake:
367         @echo -en "\
368         set(CMAKE_SYSTEM_NAME Linux)\n\
369         set(CMAKE_C_COMPILER $(TARGET_CC_NOCCACHE))\n\
370         set(CMAKE_CXX_COMPILER $(TARGET_CXX_NOCCACHE))\n\
371         set(CMAKE_C_FLAGS \"\$${CMAKE_C_FLAGS} $(TARGET_CFLAGS)\" CACHE STRING \"Buildroot CFLAGS\" FORCE)\n\
372         set(CMAKE_CXX_FLAGS \"\$${CMAKE_CXX_FLAGS} $(TARGET_CXXFLAGS)\" CACHE STRING \"Buildroot CXXFLAGS\" FORCE)\n\
373         set(CMAKE_INSTALL_SO_NO_EXE 0)\n\
374         set(CMAKE_PROGRAM_PATH \"$(HOST_DIR)/usr/bin\")\n\
375         set(CMAKE_FIND_ROOT_PATH \"$(STAGING_DIR)\")\n\
376         set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\n\
377         set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\n\
378         set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n\
379         set(ENV{PKG_CONFIG_SYSROOT_DIR} \"$(STAGING_DIR)\")\n\
380         " > $@
381
382 .PHONY: all world dirs clean distclean source outputmakefile \
383         $(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
384         $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
385         $(DL_DIR) $(TOOLCHAIN_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
386         $(HOST_DIR) $(BR2_DEPENDS_DIR) $(BINARIES_DIR) $(STAMP_DIR)
387
388 #############################################################
389 #
390 # staging and target directories do NOT list these as
391 # dependencies anywhere else
392 #
393 #############################################################
394 $(DL_DIR) $(TOOLCHAIN_DIR) $(BUILD_DIR) $(HOST_DIR) $(BINARIES_DIR) $(STAMP_DIR):
395         @mkdir -p $@
396
397 $(STAGING_DIR):
398         @mkdir -p $(STAGING_DIR)/bin
399         @mkdir -p $(STAGING_DIR)/lib
400         @mkdir -p $(STAGING_DIR)/usr/lib
401         @mkdir -p $(STAGING_DIR)/usr/include
402         @mkdir -p $(STAGING_DIR)/usr/bin
403         @ln -snf $(STAGING_DIR) $(BASE_DIR)/staging
404
405 ifeq ($(BR2_ROOTFS_SKELETON_CUSTOM),y)
406 TARGET_SKELETON=$(BR2_ROOTFS_SKELETON_CUSTOM_PATH)
407 endif
408
409 $(BUILD_DIR)/.root:
410         mkdir -p $(TARGET_DIR)
411         if ! [ -d "$(TARGET_DIR)/bin" ]; then \
412                 if [ -d "$(TARGET_SKELETON)" ]; then \
413                         cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
414                 fi; \
415                 touch $(STAGING_DIR)/.fakeroot.00000; \
416         fi
417         -find $(TARGET_DIR) -type d -name CVS -print0 -o -name .svn -print0 | xargs -0 rm -rf
418         -find $(TARGET_DIR) -type f \( -name .empty -o -name '*~' \) -print0 | xargs -0 rm -rf
419         touch $@
420
421 $(TARGET_DIR): $(BUILD_DIR)/.root
422
423 erase-fakeroots:
424         rm -f $(BUILD_DIR)/.fakeroot*
425
426 target-finalize:
427 ifeq ($(BR2_HAVE_DEVFILES),y)
428         ( scripts/copy.sh $(STAGING_DIR) $(TARGET_DIR) )
429 else
430         rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/aclocal
431         find $(TARGET_DIR)/lib \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
432         find $(TARGET_DIR)/usr/lib \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
433 endif
434 ifneq ($(BR2_PACKAGE_GDB),y)
435         rm -rf $(TARGET_DIR)/usr/share/gdb
436 endif
437 ifneq ($(BR2_HAVE_DOCUMENTATION),y)
438         rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
439         rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
440         rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
441         rm -rf $(TARGET_DIR)/usr/share/gtk-doc
442         -rmdir $(TARGET_DIR)/usr/share 2>/dev/null
443 endif
444 ifeq ($(BR2_PACKAGE_PYTHON_PY_ONLY),y)
445         find $(TARGET_DIR)/usr/lib/ -name '*.pyc' -print0 | xargs -0 rm -f
446 endif
447 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY),y)
448         find $(TARGET_DIR)/usr/lib/ -name '*.py' -print0 | xargs -0 rm -f
449 endif
450         find $(TARGET_DIR) -type f -perm +111 '!' -name 'libthread_db*.so*' | \
451                 xargs $(STRIPCMD) 2>/dev/null || true
452         find $(TARGET_DIR)/lib/modules -type f -name '*.ko' | \
453                 xargs -r $(KSTRIPCMD) || true
454
455         mkdir -p $(TARGET_DIR)/etc
456         # Mandatory configuration file and auxilliary cache directory
457         # for recent versions of ldconfig
458         touch $(TARGET_DIR)/etc/ld.so.conf
459         mkdir -p $(TARGET_DIR)/var/cache/ldconfig
460         if [ -x "$(TARGET_CROSS)ldconfig" ]; \
461         then \
462                 $(TARGET_CROSS)ldconfig -r $(TARGET_DIR); \
463         else \
464                 /sbin/ldconfig -r $(TARGET_DIR); \
465         fi
466         echo $(BR2_VERSION_FULL) > $(TARGET_DIR)/etc/br-version
467
468 ifneq ($(BR2_ROOTFS_POST_BUILD_SCRIPT),"")
469         $(BR2_ROOTFS_POST_BUILD_SCRIPT) $(TARGET_DIR)
470 endif
471
472 ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
473 LOCALE_WHITELIST=$(BUILD_DIR)/locales.nopurge
474 LOCALE_NOPURGE=$(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
475
476 target-purgelocales:
477         rm -f $(LOCALE_WHITELIST)
478         for i in $(LOCALE_NOPURGE); do echo $$i >> $(LOCALE_WHITELIST); done
479
480         for dir in $(wildcard $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/man /usr/share/man)); \
481         do \
482                 for lang in $$(cd $$dir; ls .|grep -v man); \
483                 do \
484                         grep -qx $$lang $(LOCALE_WHITELIST) || rm -rf $$dir/$$lang; \
485                 done; \
486         done
487 endif
488
489 source: dirs $(TARGETS_SOURCE) $(HOST_SOURCE)
490
491 external-deps:
492         @$(MAKE) -Bs DL_MODE=SHOW_EXTERNAL_DEPS $(EXTRAMAKEARGS) source | sort -u
493
494 show-targets:
495         @echo $(TARGETS)
496
497 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
498
499 all: menuconfig
500
501 # configuration
502 # ---------------------------------------------------------------------------
503
504 HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
505 export HOSTCFLAGS
506
507 $(BUILD_DIR)/buildroot-config/%onf:
508         mkdir -p $(@D)/lxdialog
509         $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
510
511 COMMON_CONFIG_ENV = \
512         KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
513         KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
514         KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
515         BUILDROOT_CONFIG=$(CONFIG_DIR)/.config
516
517 xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
518         @mkdir -p $(BUILD_DIR)/buildroot-config
519         @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
520
521 gconfig: $(BUILD_DIR)/buildroot-config/gconf outputmakefile
522         @mkdir -p $(BUILD_DIR)/buildroot-config
523         @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
524
525 menuconfig: $(BUILD_DIR)/buildroot-config/mconf outputmakefile
526         @mkdir -p $(BUILD_DIR)/buildroot-config
527         @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
528
529 nconfig: $(BUILD_DIR)/buildroot-config/nconf outputmakefile
530         @mkdir -p $(BUILD_DIR)/buildroot-config
531         @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
532
533 config: $(BUILD_DIR)/buildroot-config/conf outputmakefile
534         @mkdir -p $(BUILD_DIR)/buildroot-config
535         @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
536
537 oldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
538         mkdir -p $(BUILD_DIR)/buildroot-config
539         @$(COMMON_CONFIG_ENV) $< --oldconfig $(CONFIG_CONFIG_IN)
540
541 randconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
542         @mkdir -p $(BUILD_DIR)/buildroot-config
543         @$(COMMON_CONFIG_ENV) $< --randconfig $(CONFIG_CONFIG_IN)
544
545 allyesconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
546         @mkdir -p $(BUILD_DIR)/buildroot-config
547         @$(COMMON_CONFIG_ENV) $< --allyesconfig $(CONFIG_CONFIG_IN)
548
549 allnoconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
550         @mkdir -p $(BUILD_DIR)/buildroot-config
551         @$(COMMON_CONFIG_ENV) $< --allnoconfig $(CONFIG_CONFIG_IN)
552
553 randpackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
554         @mkdir -p $(BUILD_DIR)/buildroot-config
555         @grep -v BR2_PACKAGE_ $(CONFIG_DIR)/.config > $(CONFIG_DIR)/.config.nopkg
556         @$(COMMON_CONFIG_ENV) \
557                 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
558                 $< --randconfig $(CONFIG_CONFIG_IN)
559         @rm -f $(CONFIG_DIR)/.config.nopkg
560
561 allyespackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
562         @mkdir -p $(BUILD_DIR)/buildroot-config
563         @grep -v BR2_PACKAGE_ $(CONFIG_DIR)/.config > $(CONFIG_DIR)/.config.nopkg
564         @$(COMMON_CONFIG_ENV) \
565                 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
566                 $< --allyesconfig $(CONFIG_CONFIG_IN)
567         @rm -f $(CONFIG_DIR)/.config.nopkg
568
569 allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
570         @mkdir -p $(BUILD_DIR)/buildroot-config
571         @grep -v BR2_PACKAGE_ $(CONFIG_DIR)/.config > $(CONFIG_DIR)/.config.nopkg
572         @$(COMMON_CONFIG_ENV) \
573                 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
574                 $< --allnoconfig $(CONFIG_CONFIG_IN)
575         @rm -f $(CONFIG_DIR)/.config.nopkg
576
577 silentoldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
578         @mkdir -p $(BUILD_DIR)/buildroot-config
579         $(COMMON_CONFIG_ENV) $< --silentoldconfig $(CONFIG_CONFIG_IN)
580
581 defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
582         @mkdir -p $(BUILD_DIR)/buildroot-config
583         @$(COMMON_CONFIG_ENV) $< --defconfig $(CONFIG_CONFIG_IN)
584
585 %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(TOPDIR)/configs/%_defconfig outputmakefile
586         @mkdir -p $(BUILD_DIR)/buildroot-config
587         @$(COMMON_CONFIG_ENV) $< --defconfig=$(TOPDIR)/configs/$@ $(CONFIG_CONFIG_IN)
588
589 savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
590         @mkdir -p $(BUILD_DIR)/buildroot-config
591         @$(COMMON_CONFIG_ENV) $< --savedefconfig=$(CONFIG_DIR)/defconfig $(CONFIG_CONFIG_IN)
592
593 # check if download URLs are outdated
594 source-check: allyesconfig
595         $(MAKE) DL_MODE=SOURCE_CHECK $(EXTRAMAKEARGS) source
596
597 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
598
599 #############################################################
600 #
601 # Cleanup and misc junk
602 #
603 #############################################################
604
605 # outputmakefile generates a Makefile in the output directory, if using a
606 # separate output directory. This allows convenient use of make in the
607 # output directory.
608 outputmakefile:
609 ifeq ($(NEED_WRAPPER),y)
610         $(Q)$(TOPDIR)/scripts/mkmakefile $(TOPDIR) $(O)
611 endif
612
613 clean:
614         rm -rf $(STAGING_DIR) $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \
615                 $(STAMP_DIR) $(BUILD_DIR) $(TOOLCHAIN_DIR) $(BASE_DIR)/staging
616
617 distclean: clean
618 ifeq ($(DL_DIR),$(TOPDIR)/dl)
619         rm -rf $(DL_DIR)
620 endif
621 ifeq ($(O),output)
622         rm -rf $(O)
623 endif
624         rm -rf $(CONFIG_DIR)/.config $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/.auto.deps
625
626 cross: $(BASE_TARGETS)
627
628 help:
629         @echo 'Cleaning:'
630         @echo '  clean                  - delete all files created by build'
631         @echo '  distclean              - delete all non-source files (including .config)'
632         @echo
633         @echo 'Build:'
634         @echo '  all                    - make world'
635         @echo
636         @echo 'Configuration:'
637         @echo '  menuconfig             - interactive curses-based configurator'
638         @echo '  nconfig                - interactive ncurses-based configurator'
639         @echo '  xconfig                - interactive Qt-based configurator'
640         @echo '  gconfig                - interactive GTK-based configurator'
641         @echo '  oldconfig              - resolve any unresolved symbols in .config'
642         @echo '  randconfig             - New config with random answer to all options'
643         @echo '  defconfig              - New config with default answer to all options'
644         @echo '  savedefconfig          - Save current config as ./defconfig (minimal config)'
645         @echo '  allyesconfig           - New config where all options are accepted with yes'
646         @echo '  allnoconfig            - New config where all options are answered with no'
647         @echo '  randpackageconfig      - New config with random answer to package options'
648         @echo '  allyespackageconfig    - New config where pkg options are accepted with yes'
649         @echo '  allnopackageconfig     - New config where package options are answered with no'
650 ifeq ($(BR2_PACKAGE_BUSYBOX),y)
651         @echo '  busybox-menuconfig     - Run BusyBox menuconfig'
652 endif
653 ifeq ($(BR2_LINUX_KERNEL),y)
654         @echo '  linux-menuconfig       - Run Linux kernel menuconfig'
655         @echo '  linux-savedefconfig    - Run Linux kernel savedefconfig'
656 endif
657 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
658         @echo '  uclibc-menuconfig      - Run uClibc menuconfig'
659 endif
660 ifeq ($(BR2_TOOLCHAIN_CTNG),y)
661         @echo '  ctng-menuconfig        - Run crosstool-NG menuconfig'
662 endif
663 ifeq ($(BR2_TARGET_BAREBOX),y)
664         @echo '  barebox-menuconfig     - Run barebox menuconfig'
665         @echo '  barebox-savedefconfig  - Run barebox savedefconfig'
666 endif
667         @echo
668         @echo 'Miscellaneous:'
669         @echo '  source                 - download all sources needed for offline-build'
670         @echo '  source-check           - check all packages for valid download URLs'
671         @echo '  external-deps          - list external packages used'
672         @echo
673         @echo '  make V=0|1             - 0 => quiet build (default), 1 => verbose build'
674         @echo '  make O=dir             - Locate all output files in "dir", including .config'
675         @echo
676         @$(foreach b, $(sort $(notdir $(wildcard $(TOPDIR)/configs/*_defconfig))), \
677           printf "  %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
678         @echo
679         @echo 'See docs/README and docs/buildroot.html for further details'
680         @echo
681
682 release: OUT=buildroot-$(BR2_VERSION)
683
684 release:
685         git archive --format=tar --prefix=$(OUT)/ master|gzip -9 >$(OUT).tar.gz
686
687 .PHONY: $(noconfig_targets)
688