Makefile 27 KB

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