Makefile 29 KB

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