Makefile 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. # Makefile for buildroot2
  2. #
  3. # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. #
  19. #--------------------------------------------------------------
  20. # Just run 'make menuconfig', configure stuff, then run 'make'.
  21. # You shouldn't need to mess with anything beyond this point...
  22. #--------------------------------------------------------------
  23. TOPDIR=./
  24. CONFIG_CONFIG_IN=Config.in
  25. CONFIG_DEFCONFIG=.defconfig
  26. CONFIG=package/config
  27. DATE:=$(shell date -u +%Y%m%d)
  28. noconfig_targets:=menuconfig config oldconfig randconfig \
  29. defconfig allyesconfig allnoconfig release tags \
  30. source-check help
  31. # $(shell find . -name *_defconfig |sed 's/.*\///')
  32. # Pull in the user's configuration file
  33. ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
  34. ifeq ($(BOARD),)
  35. -include $(TOPDIR).config
  36. else
  37. -include $(TOPDIR)/local/$(BOARD)/$(BOARD).config
  38. endif
  39. endif
  40. ifneq ($(BUILDROOT_DL_DIR),)
  41. BR2_DL_DIR:=$(BUILDROOT_DL_DIR)
  42. endif
  43. ifneq ($(BUILDROOT_LOCAL),)
  44. LOCAL:=$(BUILDROOT_LOCAL)
  45. else
  46. LOCAL:=local
  47. endif
  48. # To put more focus on warnings, be less verbose as default
  49. # Use 'make V=1' to see the full commands
  50. ifdef V
  51. ifeq ("$(origin V)", "command line")
  52. KBUILD_VERBOSE=$(V)
  53. endif
  54. endif
  55. ifndef KBUILD_VERBOSE
  56. KBUILD_VERBOSE=0
  57. endif
  58. ifeq ($(KBUILD_VERBOSE),1)
  59. quiet=
  60. Q=
  61. ifndef VERBOSE
  62. VERBOSE=1
  63. endif
  64. else
  65. quiet=quiet_
  66. Q=@
  67. endif
  68. CONFIG_SHELL:=$(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  69. else if [ -x /bin/bash ]; then echo /bin/bash; \
  70. else echo sh; fi; fi)
  71. export CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
  72. HOSTCCACHE:=$(shell $(CONFIG_SHELL) -c "which ccache")
  73. ifneq ($(HOSTCCACHE),)
  74. BR2_HAVE_HOST_CCACHE=y
  75. endif
  76. ifndef HOSTAR
  77. HOSTAR:=ar
  78. endif
  79. ifndef HOSTAS
  80. HOSTAS:=as
  81. endif
  82. ifndef HOSTCC
  83. HOSTCC:=gcc
  84. else
  85. endif
  86. ifndef HOSTCXX
  87. HOSTCXX:=g++
  88. endif
  89. ifndef HOSTFC
  90. HOSTFC:=gfortran
  91. endif
  92. ifndef HOSTCPP
  93. HOSTCPP:=cpp
  94. endif
  95. ifndef HOSTLD
  96. HOSTLD:=ld
  97. endif
  98. ifndef HOSTLN
  99. HOSTLN:=ln
  100. endif
  101. ifndef HOSTNM
  102. HOSTNM:=nm
  103. endif
  104. HOSTAR:=$(shell $(CONFIG_SHELL) -c "which $(HOSTAR)" || type -p $(HOSTAR) || echo ar)
  105. HOSTAS:=$(shell $(CONFIG_SHELL) -c "which $(HOSTAS)" || type -p $(HOSTAS) || echo as)
  106. HOSTCC:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCC)" || type -p $(HOSTCC) || echo gcc)
  107. HOSTCXX:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCXX)" || type -p $(HOSTCXX) || echo g++)
  108. HOSTFC:=$(shell $(CONFIG_SHELL) -c "which $(HOSTLD)" || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran)
  109. HOSTCPP:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCPP)" || type -p $(HOSTCPP) || echo cpp)
  110. HOSTLD:=$(shell $(CONFIG_SHELL) -c "which $(HOSTLD)" || type -p $(HOSTLD) || echo ld)
  111. HOSTLN:=$(shell $(CONFIG_SHELL) -c "which $(HOSTLN)" || type -p $(HOSTLN) || echo ln)
  112. HOSTNM:=$(shell $(CONFIG_SHELL) -c "which $(HOSTNM)" || type -p $(HOSTNM) || echo nm)
  113. ifndef CFLAGS_FOR_BUILD
  114. CFLAGS_FOR_BUILD:=-g -O2
  115. endif
  116. ifndef CXXFLAGS_FOR_BUILD
  117. CXXFLAGS_FOR_BUILD:=-g -O2
  118. endif
  119. ifndef FCFLAGS_FOR_BUILD
  120. FCFLAGS_FOR_BUILD:=-g -O2
  121. endif
  122. ifeq ($(BR2_HAVE_HOST_CCACHE),y)
  123. HOSTCC:=$(HOSTCCACHE) $(HOSTCC)
  124. HOSTCXX:=$(HOSTCCACHE) $(HOSTCXX)
  125. endif
  126. export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
  127. ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  128. # cc-option
  129. # Usage: cflags-y+=$(call cc-option, -march=winchip-c6, -march=i586)
  130. # sets -march=winchip-c6 if supported else falls back to -march=i586
  131. # without checking the latter.
  132. cc-option=$(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
  133. > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
  134. #############################################################
  135. #
  136. # Hide troublesome environment variables from sub processes
  137. #
  138. #############################################################
  139. unexport CROSS_COMPILE
  140. unexport ARCH
  141. #############################################################
  142. #
  143. # Setup the proper filename extensions for the host
  144. #
  145. ##############################################################
  146. ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
  147. HOST_EXEEXT:=
  148. HOST_LIBEXT:=.a
  149. HOST_SHREXT:=.so
  150. endif
  151. ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
  152. HOST_EXEEXT:=
  153. HOST_LIBEXT:=.a
  154. HOST_SHREXT:=.dylib
  155. endif
  156. ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
  157. HOST_EXEEXT:=.exe
  158. HOST_LIBEXT:=.lib
  159. HOST_SHREXT:=.dll
  160. endif
  161. ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
  162. HOST_EXEEXT:=.exe
  163. HOST_LIBEXT:=.lib
  164. HOST_SHREXT:=.dll
  165. endif
  166. # The preferred type of libs we build for the target
  167. ifeq ($(BR2_PREFER_STATIC_LIB),y)
  168. LIBTGTEXT=.a
  169. #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
  170. else
  171. LIBTGTEXT=.so
  172. #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
  173. endif
  174. PREFERRED_LIB_FLAGS:=--enable-static --enable-shared
  175. ##############################################################
  176. #
  177. # The list of stuff to build for the target toolchain
  178. # along with the packages to build for the target.
  179. #
  180. ##############################################################
  181. ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
  182. BASE_TARGETS:=uclibc-configured binutils cross_compiler uclibc-target-utils kernel-headers
  183. else
  184. BASE_TARGETS:=uclibc
  185. endif
  186. TARGETS:=
  187. # setup our pathes
  188. include project/Makefile.in
  189. BR2_DEPENDS_DIR=$(PROJECT_BUILD_DIR)/buildroot-config
  190. include toolchain/Makefile.in
  191. include package/Makefile.in
  192. #############################################################
  193. #
  194. # You should probably leave this stuff alone unless you know
  195. # what you are doing.
  196. #
  197. #############################################################
  198. all: world
  199. # In this section, we need .config
  200. include .config.cmd
  201. include project/*.mk
  202. # We also need the various per-package makefiles, which also add
  203. # each selected package to TARGETS if that package was selected
  204. # in the .config file.
  205. ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
  206. # avoid pulling in external toolchain which is broken for toplvl parallel builds
  207. # Explicit ordering:
  208. include toolchain/dependencies/dependencies.mk
  209. include toolchain/binutils/binutils.mk
  210. include toolchain/ccache/ccache.mk
  211. include toolchain/elf2flt/elf2flt.mk
  212. include toolchain/gcc/gcc-uclibc-3.x.mk
  213. include toolchain/gcc/gcc-uclibc-4.x.mk
  214. include toolchain/gdb/gdb.mk
  215. include toolchain/kernel-headers/kernel-headers.mk
  216. include toolchain/mklibs/mklibs.mk
  217. include toolchain/sstrip/sstrip.mk
  218. include toolchain/uClibc/uclibc.mk
  219. else
  220. include toolchain/*/*.mk
  221. endif
  222. ifeq ($(BR2_PACKAGE_LINUX),y)
  223. TARGETS+=linux26-modules
  224. endif
  225. include package/*/*.mk
  226. TARGETS+=target-devfiles
  227. # target stuff is last so it can override anything else
  228. include target/Makefile.in
  229. TARGETS+=erase-fakeroots
  230. TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
  231. TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS) $(BASE_TARGETS))
  232. TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
  233. TARGETS_ALL:=$(patsubst %,__real_tgt_%,$(TARGETS))
  234. # all targets depend on the crosscompiler and it's prerequisites
  235. $(TARGETS_ALL): __real_tgt_%: $(BASE_TARGETS) %
  236. $(BR2_DEPENDS_DIR): .config
  237. rm -rf $@
  238. mkdir -p $(@D)
  239. cp -dpRf $(CONFIG)/buildroot-config $@
  240. dirs: $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
  241. $(BR2_DEPENDS_DIR) \
  242. $(BINARIES_DIR) $(PROJECT_BUILD_DIR)
  243. $(BASE_TARGETS): dirs
  244. world: dependencies dirs target-host-info $(BASE_TARGETS) $(TARGETS_ALL)
  245. .PHONY: all world dirs clean dirclean distclean source \
  246. $(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
  247. $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
  248. $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
  249. $(BR2_DEPENDS_DIR) \
  250. $(BINARIES_DIR) $(PROJECT_BUILD_DIR)
  251. #############################################################
  252. #
  253. # staging and target directories do NOT list these as
  254. # dependencies anywhere else
  255. #
  256. #############################################################
  257. $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) \
  258. $(PROJECT_BUILD_DIR) $(BINARIES_DIR):
  259. @mkdir -p $@
  260. $(STAGING_DIR):
  261. @mkdir -p $(STAGING_DIR)/bin
  262. @mkdir -p $(STAGING_DIR)/lib
  263. ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
  264. @mkdir -p $(STAGING_DIR)/usr/lib
  265. else
  266. ifneq ($(BR2_TOOLCHAIN_EXTERNAL),y)
  267. @ln -snf . $(STAGING_DIR)/usr
  268. @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)
  269. @ln -snf ../lib $(STAGING_DIR)/usr/lib
  270. @ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
  271. endif
  272. endif
  273. @mkdir -p $(STAGING_DIR)/usr/include
  274. $(PROJECT_BUILD_DIR)/.root:
  275. mkdir -p $(TARGET_DIR)
  276. if ! [ -d "$(TARGET_DIR)/bin" ]; then \
  277. if [ -d "$(TARGET_SKELETON)" ]; then \
  278. cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
  279. fi; \
  280. touch $(STAGING_DIR)/.fakeroot.00000; \
  281. fi
  282. -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf
  283. -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf
  284. touch $@
  285. $(TARGET_DIR): $(PROJECT_BUILD_DIR)/.root
  286. erase-fakeroots:
  287. rm -f $(PROJECT_BUILD_DIR)/.fakeroot*
  288. target-devfiles:
  289. ifeq ($(BR2_HAVE_DEVFILES),y)
  290. ( scripts/copy.sh $(STAGING_DIR) $(TARGET_DIR) )
  291. else
  292. rm -rf $(TARGET_DIR)/usr/include
  293. find $(TARGET_DIR)/usr/lib -name '*.a' -delete
  294. find $(TARGET_DIR)/lib -name '*.a' -delete
  295. find $(TARGET_DIR)/usr/lib -name '*.la' -delete
  296. find $(TARGET_DIR)/lib -name '*.la' -delete
  297. endif
  298. source: $(TARGETS_SOURCE) $(HOST_SOURCE)
  299. _source-check:
  300. $(MAKE) SPIDER=--spider source
  301. external-deps:
  302. @$(MAKE) -Bs BR2_WGET=$(TOPDIR)toolchain/wget-show-external-deps.sh \
  303. source
  304. #############################################################
  305. #
  306. # Cleanup and misc junk
  307. #
  308. #############################################################
  309. clean: $(TARGETS_CLEAN)
  310. rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
  311. dirclean: $(TARGETS_DIRCLEAN)
  312. rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
  313. distclean:
  314. ifeq ($(DL_DIR),$(BASE_DIR)/dl)
  315. rm -rf $(DL_DIR)
  316. endif
  317. rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR) \
  318. $(LINUX_KERNEL) $(IMAGE) $(BASE_DIR)/include \
  319. .config.cmd
  320. $(MAKE) -C $(CONFIG) clean
  321. sourceball:
  322. rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR)
  323. set -e; \
  324. cd ..; \
  325. rm -f buildroot.tar.bz2; \
  326. tar -cvf buildroot.tar buildroot; \
  327. bzip2 -9 buildroot.tar; \
  328. else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  329. all: menuconfig
  330. # configuration
  331. # ---------------------------------------------------------------------------
  332. HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
  333. export HOSTCFLAGS
  334. $(CONFIG)/conf:
  335. @mkdir -p $(CONFIG)/buildroot-config
  336. $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf
  337. -@if [ ! -f .config ]; then \
  338. cp $(CONFIG_DEFCONFIG) .config; \
  339. fi
  340. $(CONFIG)/mconf:
  341. @mkdir -p $(CONFIG)/buildroot-config
  342. $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf mconf
  343. -@if [ ! -f .config ]; then \
  344. cp $(CONFIG_DEFCONFIG) .config; \
  345. fi
  346. menuconfig: $(CONFIG)/mconf
  347. @mkdir -p $(CONFIG)/buildroot-config
  348. @if ! KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
  349. KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
  350. $(CONFIG)/mconf $(CONFIG_CONFIG_IN); then \
  351. test -f .config.cmd || rm -f .config; \
  352. fi
  353. config: $(CONFIG)/conf
  354. @mkdir -p $(CONFIG)/buildroot-config
  355. @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
  356. KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
  357. $(CONFIG)/conf $(CONFIG_CONFIG_IN)
  358. oldconfig: $(CONFIG)/conf
  359. @mkdir -p $(CONFIG)/buildroot-config
  360. @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
  361. KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
  362. $(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
  363. randconfig: $(CONFIG)/conf
  364. @mkdir -p $(CONFIG)/buildroot-config
  365. @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
  366. KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
  367. $(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
  368. allyesconfig: $(CONFIG)/conf
  369. cat $(CONFIG_DEFCONFIG) > .config
  370. @mkdir -p $(CONFIG)/buildroot-config
  371. @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
  372. KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
  373. $(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
  374. #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
  375. allnoconfig: $(CONFIG)/conf
  376. @mkdir -p $(CONFIG)/buildroot-config
  377. @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
  378. KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
  379. $(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
  380. defconfig: $(CONFIG)/conf
  381. @mkdir -p $(CONFIG)/buildroot-config
  382. @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
  383. KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
  384. $(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
  385. # check if download URLs are outdated
  386. source-check: allyesconfig
  387. $(MAKE) _source-check
  388. #############################################################
  389. #
  390. # Cleanup and misc junk
  391. #
  392. #############################################################
  393. clean:
  394. rm -f .config .config.old .config.cmd .tmpconfig.h
  395. -$(MAKE) -C $(CONFIG) clean
  396. distclean: clean
  397. rm -rf sources/*
  398. endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  399. %_defconfig: $(CONFIG)/conf
  400. cp $(shell find ./target/ -name $@) .config
  401. -@$(MAKE) oldconfig
  402. configured: dirs host-sed kernel-headers uclibc-config busybox-config linux26-config
  403. cross: $(BASE_TARGETS)
  404. help:
  405. @echo 'Cleaning:'
  406. @echo ' clean - delete temporary files created by build'
  407. @echo ' distclean - delete all non-source files (including .config)'
  408. @echo
  409. @echo 'Build:'
  410. @echo ' all - make world'
  411. @echo
  412. @echo 'Configuration:'
  413. @echo ' menuconfig - interactive curses-based configurator'
  414. @echo ' oldconfig - resolve any unresolved symbols in .config'
  415. @echo
  416. @echo 'Miscellaneous:'
  417. @echo ' source - download all sources needed for offline-build'
  418. @echo ' source-check - check all packages for valid download URLs'
  419. @echo ' external-deps - list external packages used'
  420. @echo
  421. @echo 'See docs/README and docs/buildroot.html for further details'
  422. @echo
  423. .PHONY: dummy subdirs release distclean clean config oldconfig \
  424. menuconfig tags check test depend defconfig help