Makefile 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. noconfig_targets := menuconfig config oldconfig randconfig \
  28. defconfig allyesconfig allnoconfig release tags \
  29. # $(shell find . -name *_defconfig |sed 's/.*\///')
  30. # Pull in the user's configuration file
  31. ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
  32. -include $(TOPDIR).config
  33. endif
  34. ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
  35. # cc-option
  36. # Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
  37. # sets -march=winchip-c6 if supported else falls back to -march=i586
  38. # without checking the latter.
  39. cc-option = $(shell if $(TARGET_CC) $(TARGET_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
  40. > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
  41. #############################################################
  42. #
  43. # Setup the proper filename extensions for the target
  44. #
  45. ##############################################################
  46. ifneq ($(findstring linux,$(BR2_GNU_BUILD_SUFFIX)),)
  47. EXEEXT:=
  48. LIBEXT:=.a
  49. SHREXT:=.so
  50. endif
  51. ifneq ($(findstring apple,$(BR2_GNU_BUILD_SUFFIX)),)
  52. EXEEXT:=
  53. LIBEXT:=.a
  54. SHREXT:=.dylib
  55. endif
  56. ifneq ($(findstring cygwin,$(BR2_GNU_BUILD_SUFFIX)),)
  57. EXEEXT:=.exe
  58. LIBEXT:=.lib
  59. SHREXT:=.dll
  60. endif
  61. ifneq ($(findstring mingw,$(BR2_GNU_BUILD_SUFFIX)),)
  62. EXEEXT:=.exe
  63. LIBEXT:=.lib
  64. SHREXT:=.dll
  65. endif
  66. ifeq ($(BR2_PREFER_STATIC_LIB),y)
  67. LIBTGTEXT=$(LIBEXT)
  68. else
  69. LIBTGTEXT=$(SHREXT)
  70. endif
  71. #############################################################
  72. #
  73. # The list of stuff to build for the target toolchain
  74. # along with the packages to build for the target.
  75. #
  76. ##############################################################
  77. ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
  78. TARGETS:=uclibc-configured binutils gcc uclibc-target-utils
  79. else
  80. TARGETS:=uclibc
  81. endif
  82. include toolchain/Makefile.in
  83. include package/Makefile.in
  84. #############################################################
  85. #
  86. # You should probably leave this stuff alone unless you know
  87. # what you are doing.
  88. #
  89. #############################################################
  90. all: world
  91. # In this section, we need .config
  92. include .config.cmd
  93. # We also need the various per-package makefiles, which also add
  94. # each selected package to TARGETS if that package was selected
  95. # in the .config file.
  96. include toolchain/*/*.mk
  97. include package/*/*.mk
  98. # target stuff is last so it can override anything else
  99. include target/Makefile.in
  100. TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
  101. TARGETS_SOURCE:=$(patsubst %,%-source,$(TARGETS))
  102. TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS))
  103. world: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) $(TARGETS)
  104. dirs: $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR)
  105. .PHONY: all world dirs clean dirclean distclean source $(TARGETS) \
  106. $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \
  107. $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
  108. #############################################################
  109. #
  110. # staging and target directories do NOT list these as
  111. # dependencies anywhere else
  112. #
  113. #############################################################
  114. $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR):
  115. @mkdir -p $@
  116. $(STAGING_DIR):
  117. @mkdir -p $(STAGING_DIR)/bin
  118. @mkdir -p $(STAGING_DIR)/lib
  119. @mkdir -p $(STAGING_DIR)/include
  120. @mkdir -p $(STAGING_DIR)/usr
  121. @mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)
  122. @ln -snf ../include $(STAGING_DIR)/usr/include
  123. @ln -snf ../lib $(STAGING_DIR)/usr/lib
  124. @ln -snf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  125. $(TARGET_DIR):
  126. mkdir -p $(TARGET_DIR)
  127. if [ -d "$(TARGET_SKELETON)" ] ; then \
  128. cp -fa $(TARGET_SKELETON)/* $(TARGET_DIR)/; \
  129. fi;
  130. touch $(STAGING_DIR)/.fakeroot.00000
  131. -find $(TARGET_DIR) -type d -name CVS | xargs rm -rf
  132. -find $(TARGET_DIR) -type d -name .svn | xargs rm -rf
  133. source: $(TARGETS_SOURCE) $(HOST_SOURCE)
  134. #############################################################
  135. #
  136. # Cleanup and misc junk
  137. #
  138. #############################################################
  139. clean: $(TARGETS_CLEAN)
  140. rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
  141. dirclean: $(TARGETS_DIRCLEAN)
  142. rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE)
  143. distclean:
  144. ifeq ($(DL_DIR),$(BASE_DIR)/dl)
  145. rm -rf $(DL_DIR)
  146. endif
  147. rm -rf $(BUILD_DIR) $(LINUX_KERNEL) $(IMAGE)
  148. $(MAKE) -C $(CONFIG) clean
  149. sourceball:
  150. rm -rf $(BUILD_DIR)
  151. set -e; \
  152. cd ..; \
  153. rm -f buildroot.tar.bz2; \
  154. tar -cvf buildroot.tar buildroot; \
  155. bzip2 -9 buildroot.tar; \
  156. else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
  157. all: menuconfig
  158. # configuration
  159. # ---------------------------------------------------------------------------
  160. $(CONFIG)/conf:
  161. $(MAKE) -C $(CONFIG) conf
  162. -@if [ ! -f .config ] ; then \
  163. cp $(CONFIG_DEFCONFIG) .config; \
  164. fi
  165. $(CONFIG)/mconf:
  166. $(MAKE) -C $(CONFIG) ncurses conf mconf
  167. -@if [ ! -f .config ] ; then \
  168. cp $(CONFIG_DEFCONFIG) .config; \
  169. fi
  170. menuconfig: $(CONFIG)/mconf
  171. @$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
  172. config: $(CONFIG)/conf
  173. @$(CONFIG)/conf $(CONFIG_CONFIG_IN)
  174. oldconfig: $(CONFIG)/conf
  175. @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
  176. randconfig: $(CONFIG)/conf
  177. @$(CONFIG)/conf -r $(CONFIG_CONFIG_IN)
  178. allyesconfig: $(CONFIG)/conf
  179. #@$(CONFIG)/conf -y $(CONFIG_CONFIG_IN)
  180. #sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
  181. @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
  182. allnoconfig: $(CONFIG)/conf
  183. @$(CONFIG)/conf -n $(CONFIG_CONFIG_IN)
  184. defconfig: $(CONFIG)/conf
  185. @$(CONFIG)/conf -d $(CONFIG_CONFIG_IN)
  186. %_defconfig: $(CONFIG)/conf
  187. cp $(shell find . -name $@) .config
  188. @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN)
  189. #############################################################
  190. #
  191. # Cleanup and misc junk
  192. #
  193. #############################################################
  194. clean:
  195. rm -f .config .config.old .config.cmd .tmpconfig.h
  196. - $(MAKE) -C $(CONFIG) clean
  197. distclean: clean
  198. rm -rf sources/*
  199. endif # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
  200. .PHONY: dummy subdirs release distclean clean config oldconfig \
  201. menuconfig tags check test depend defconfig