Makefile 31 KB

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