Makefile 15 KB

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