Makefile 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  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. ifndef HOSTAR
  73. HOSTAR:=ar
  74. endif
  75. ifndef HOSTAS
  76. HOSTAS:=as
  77. endif
  78. ifndef HOSTCC
  79. HOSTCC:=gcc
  80. else
  81. endif
  82. ifndef HOSTCXX
  83. HOSTCXX:=g++
  84. endif
  85. ifndef HOSTFC
  86. HOSTFC:=gfortran
  87. endif
  88. ifndef HOSTCPP
  89. HOSTCPP:=cpp
  90. endif
  91. ifndef HOSTLD
  92. HOSTLD:=ld
  93. endif
  94. ifndef HOSTLN
  95. HOSTLN:=ln
  96. endif
  97. ifndef HOSTNM
  98. HOSTNM:=nm
  99. endif
  100. HOSTAR:=$(shell $(CONFIG_SHELL) -c "which $(HOSTAR)" || type -p $(HOSTAR) || echo ar)
  101. HOSTAS:=$(shell $(CONFIG_SHELL) -c "which $(HOSTAS)" || type -p $(HOSTAS) || echo as)
  102. HOSTCC:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCC)" || type -p $(HOSTCC) || echo gcc)
  103. HOSTCXX:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCXX)" || type -p $(HOSTCXX) || echo g++)
  104. HOSTFC:=$(shell $(CONFIG_SHELL) -c "which $(HOSTLD)" || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran)
  105. HOSTCPP:=$(shell $(CONFIG_SHELL) -c "which $(HOSTCPP)" || type -p $(HOSTCPP) || echo cpp)
  106. HOSTLD:=$(shell $(CONFIG_SHELL) -c "which $(HOSTLD)" || type -p $(HOSTLD) || echo ld)
  107. HOSTLN:=$(shell $(CONFIG_SHELL) -c "which $(HOSTLN)" || type -p $(HOSTLN) || echo ln)
  108. HOSTNM:=$(shell $(CONFIG_SHELL) -c "which $(HOSTNM)" || type -p $(HOSTNM) || echo nm)
  109. ifndef CFLAGS_FOR_BUILD
  110. CFLAGS_FOR_BUILD:=-g -O2
  111. endif
  112. ifndef CXXFLAGS_FOR_BUILD
  113. CXXFLAGS_FOR_BUILD:=-g -O2
  114. endif
  115. ifndef FCFLAGS_FOR_BUILD
  116. FCFLAGS_FOR_BUILD:=-g -O2
  117. endif
  118. export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
  119. ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  120. # cc-option
  121. # Usage: cflags-y+=$(call cc-option, -march=winchip-c6, -march=i586)
  122. # sets -march=winchip-c6 if supported else falls back to -march=i586
  123. # without checking the latter.
  124. cc-option=$(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
  125. > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
  126. #############################################################
  127. #
  128. # Hide troublesome environment variables from sub processes
  129. #
  130. #############################################################
  131. unexport CROSS_COMPILE
  132. unexport ARCH
  133. #############################################################
  134. #
  135. # Setup the proper filename extensions for the host
  136. #
  137. ##############################################################
  138. ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
  139. HOST_EXEEXT:=
  140. HOST_LIBEXT:=.a
  141. HOST_SHREXT:=.so
  142. endif
  143. ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
  144. HOST_EXEEXT:=
  145. HOST_LIBEXT:=.a
  146. HOST_SHREXT:=.dylib
  147. endif
  148. ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
  149. HOST_EXEEXT:=.exe
  150. HOST_LIBEXT:=.lib
  151. HOST_SHREXT:=.dll
  152. endif
  153. ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
  154. HOST_EXEEXT:=.exe
  155. HOST_LIBEXT:=.lib
  156. HOST_SHREXT:=.dll
  157. endif
  158. # The preferred type of libs we build for the target
  159. ifeq ($(BR2_PREFER_STATIC_LIB),y)
  160. LIBTGTEXT=.a
  161. #PREFERRED_LIB_FLAGS:=--disable-shared --enable-static
  162. else
  163. LIBTGTEXT=.so
  164. #PREFERRED_LIB_FLAGS:=--disable-static --enable-shared
  165. endif
  166. PREFERRED_LIB_FLAGS:=--enable-static --enable-shared
  167. ##############################################################
  168. #
  169. # The list of stuff to build for the target toolchain
  170. # along with the packages to build for the target.
  171. #
  172. ##############################################################
  173. ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
  174. BASE_TARGETS:=uclibc-configured binutils cross_compiler uclibc-target-utils kernel-headers
  175. else
  176. BASE_TARGETS:=uclibc
  177. endif
  178. TARGETS:=
  179. # setup our pathes
  180. include project/Makefile.in
  181. BR2_DEPENDS_DIR=$(PROJECT_BUILD_DIR)/buildroot-config
  182. include toolchain/Makefile.in
  183. include package/Makefile.in
  184. #############################################################
  185. #
  186. # You should probably leave this stuff alone unless you know
  187. # what you are doing.
  188. #
  189. #############################################################
  190. all: world
  191. # In this section, we need .config
  192. include .config.cmd
  193. include project/*.mk
  194. # We also need the various per-package makefiles, which also add
  195. # each selected package to TARGETS if that package was selected
  196. # in the .config file.
  197. ifeq ($(BR2_TOOLCHAIN_SOURCE),y)
  198. # avoid pulling in external toolchain which is broken for toplvl parallel builds
  199. # Explicit ordering:
  200. include toolchain/dependencies/dependencies.mk
  201. include toolchain/binutils/binutils.mk
  202. include toolchain/ccache/ccache.mk
  203. include toolchain/elf2flt/elf2flt.mk
  204. include toolchain/gcc/gcc-uclibc-3.x.mk
  205. include toolchain/gcc/gcc-uclibc-4.x.mk
  206. include toolchain/gdb/gdb.mk
  207. include toolchain/kernel-headers/kernel-headers.mk
  208. include toolchain/mklibs/mklibs.mk
  209. include toolchain/sstrip/sstrip.mk
  210. include toolchain/uClibc/uclibc.mk
  211. else
  212. include toolchain/*/*.mk
  213. endif
  214. ifeq ($(BR2_PACKAGE_LINUX),y)
  215. TARGETS+=linux26-modules
  216. endif
  217. include package/*/*.mk
  218. TARGETS+=target-devfiles
  219. # target stuff is last so it can override anything else
  220. include target/Makefile.in
  221. TARGETS+=erase-fakeroots
  222. TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
  223. TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS) $(BASE_TARGETS))
  224. TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
  225. TARGETS_ALL:=$(patsubst %,__real_tgt_%,$(TARGETS))
  226. # all targets depend on the crosscompiler and it's prerequisites
  227. $(TARGETS_ALL): __real_tgt_%: $(BASE_TARGETS) %
  228. $(BR2_DEPENDS_DIR): .config
  229. rm -rf $@
  230. mkdir -p $(@D)
  231. cp -dpRf $(CONFIG)/buildroot-config $@
  232. dirs: $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
  233. $(BR2_DEPENDS_DIR) \
  234. $(BINARIES_DIR) $(PROJECT_BUILD_DIR)
  235. $(BASE_TARGETS): dirs
  236. world: dependencies dirs target-host-info $(BASE_TARGETS) $(TARGETS_ALL)
  237. .PHONY: all world dirs clean dirclean distclean source \
  238. $(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
  239. $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
  240. $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
  241. $(BR2_DEPENDS_DIR) \
  242. $(BINARIES_DIR) $(PROJECT_BUILD_DIR)
  243. #############################################################
  244. #
  245. # staging and target directories do NOT list these as
  246. # dependencies anywhere else
  247. #
  248. #############################################################
  249. $(DL_DIR) $(TOOL_BUILD_DIR) $(BUILD_DIR) \
  250. $(PROJECT_BUILD_DIR) $(BINARIES_DIR):
  251. @mkdir -p $@
  252. $(STAGING_DIR):
  253. @mkdir -p $(STAGING_DIR)/bin
  254. @mkdir -p $(STAGING_DIR)/lib
  255. ifeq ($(BR2_TOOLCHAIN_SYSROOT),y)
  256. @mkdir -p $(STAGING_DIR)/usr/lib
  257. else
  258. ifneq ($(BR2_TOOLCHAIN_EXTERNAL),y)
  259. @ln -snf . $(STAGING_DIR)/usr
  260. @mkdir -p $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)
  261. @ln -snf ../lib $(STAGING_DIR)/usr/lib
  262. @ln -snf ../lib $(STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
  263. endif
  264. endif
  265. @mkdir -p $(STAGING_DIR)/usr/include
  266. $(PROJECT_BUILD_DIR)/.root:
  267. mkdir -p $(TARGET_DIR)
  268. if ! [ -d "$(TARGET_DIR)/bin" ]; then \
  269. if [ -d "$(TARGET_SKELETON)" ]; then \
  270. cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
  271. fi; \
  272. touch $(STAGING_DIR)/.fakeroot.00000; \
  273. fi
  274. -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf
  275. -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf
  276. touch $@
  277. $(TARGET_DIR): $(PROJECT_BUILD_DIR)/.root
  278. erase-fakeroots:
  279. rm -f $(PROJECT_BUILD_DIR)/.fakeroot*
  280. target-devfiles:
  281. ifeq ($(BR2_HAVE_DEVFILES),y)
  282. ( scripts/copy.sh $(STAGING_DIR) $(TARGET_DIR) )
  283. else
  284. rm -rf $(TARGET_DIR)/usr/include
  285. find $(TARGET_DIR)/usr/lib -name '*.a' -delete
  286. find $(TARGET_DIR)/lib -name '*.a' -delete
  287. find $(TARGET_DIR)/usr/lib -name '*.la' -delete
  288. find $(TARGET_DIR)/lib -name '*.la' -delete
  289. endif
  290. source: $(TARGETS_SOURCE) $(HOST_SOURCE)
  291. _source-check:
  292. $(MAKE) SPIDER=--spider source
  293. external-deps:
  294. @$(MAKE) -Bs BR2_WGET=$(TOPDIR)toolchain/wget-show-external-deps.sh \
  295. source
  296. #############################################################
  297. #
  298. # Cleanup and misc junk
  299. #
  300. #############################################################
  301. clean: $(TARGETS_CLEAN)
  302. rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
  303. dirclean: $(TARGETS_DIRCLEAN)
  304. rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
  305. distclean:
  306. ifeq ($(DL_DIR),$(BASE_DIR)/dl)
  307. rm -rf $(DL_DIR)
  308. endif
  309. rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR) \
  310. $(LINUX_KERNEL) $(IMAGE) $(BASE_DIR)/include \
  311. .config.cmd
  312. $(MAKE) -C $(CONFIG) clean
  313. sourceball:
  314. rm -rf $(BUILD_DIR) $(PROJECT_BUILD_DIR) $(BINARIES_DIR)
  315. set -e; \
  316. cd ..; \
  317. rm -f buildroot.tar.bz2; \
  318. tar -cvf buildroot.tar buildroot; \
  319. bzip2 -9 buildroot.tar; \
  320. else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  321. all: menuconfig
  322. # configuration
  323. # ---------------------------------------------------------------------------
  324. HOSTCFLAGS=$(CFLAGS_FOR_BUILD)
  325. export HOSTCFLAGS
  326. $(CONFIG)/conf:
  327. @mkdir -p $(CONFIG)/buildroot-config
  328. $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf
  329. -@if [ ! -f .config ]; then \
  330. cp $(CONFIG_DEFCONFIG) .config; \
  331. fi
  332. $(CONFIG)/mconf:
  333. @mkdir -p $(CONFIG)/buildroot-config
  334. $(MAKE) CC="$(HOSTCC)" -C $(CONFIG) conf mconf
  335. -@if [ ! -f .config ]; then \
  336. cp $(CONFIG_DEFCONFIG) .config; \
  337. fi
  338. menuconfig: $(CONFIG)/mconf
  339. @mkdir -p $(CONFIG)/buildroot-config
  340. @if ! KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
  341. KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
  342. $(CONFIG)/mconf $(CONFIG_CONFIG_IN); then \
  343. test -f .config.cmd || rm -f .config; \
  344. fi
  345. config: $(CONFIG)/conf
  346. @mkdir -p $(CONFIG)/buildroot-config
  347. @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
  348. KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
  349. $(CONFIG)/conf $(CONFIG_CONFIG_IN)
  350. oldconfig: $(CONFIG)/conf
  351. @mkdir -p $(CONFIG)/buildroot-config
  352. @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
  353. KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
  354. $(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
  355. randconfig: $(CONFIG)/conf
  356. @mkdir -p $(CONFIG)/buildroot-config
  357. @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
  358. KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
  359. $(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
  360. allyesconfig: $(CONFIG)/conf
  361. cat $(CONFIG_DEFCONFIG) > .config
  362. @mkdir -p $(CONFIG)/buildroot-config
  363. @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
  364. KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
  365. $(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
  366. #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
  367. allnoconfig: $(CONFIG)/conf
  368. @mkdir -p $(CONFIG)/buildroot-config
  369. @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
  370. KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
  371. $(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
  372. defconfig: $(CONFIG)/conf
  373. @mkdir -p $(CONFIG)/buildroot-config
  374. @KCONFIG_AUTOCONFIG=$(CONFIG)/buildroot-config/auto.conf \
  375. KCONFIG_AUTOHEADER=$(CONFIG)/buildroot-config/autoconf.h \
  376. $(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
  377. # check if download URLs are outdated
  378. source-check: allyesconfig
  379. $(MAKE) _source-check
  380. #############################################################
  381. #
  382. # Cleanup and misc junk
  383. #
  384. #############################################################
  385. clean:
  386. rm -f .config .config.old .config.cmd .tmpconfig.h
  387. -$(MAKE) -C $(CONFIG) clean
  388. distclean: clean
  389. rm -rf sources/*
  390. endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  391. %_defconfig: $(CONFIG)/conf
  392. cp $(shell find ./target/ -name $@) .config
  393. -@$(MAKE) oldconfig
  394. configured: dirs host-sed kernel-headers uclibc-config busybox-config linux26-config
  395. cross: $(BASE_TARGETS)
  396. help:
  397. @echo 'Cleaning:'
  398. @echo ' clean - delete temporary files created by build'
  399. @echo ' distclean - delete all non-source files (including .config)'
  400. @echo
  401. @echo 'Build:'
  402. @echo ' all - make world'
  403. @echo
  404. @echo 'Configuration:'
  405. @echo ' menuconfig - interactive curses-based configurator'
  406. @echo ' oldconfig - resolve any unresolved symbols in .config'
  407. @echo
  408. @echo 'Miscellaneous:'
  409. @echo ' source - download all sources needed for offline-build'
  410. @echo ' source-check - check all packages for valid download URLs'
  411. @echo ' external-deps - list external packages used'
  412. @echo
  413. @echo 'See docs/README and docs/buildroot.html for further details'
  414. @echo
  415. .PHONY: dummy subdirs release distclean clean config oldconfig \
  416. menuconfig tags check test depend defconfig help