Makefile 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. _IN_CVTC= 1
  4. include $(ADK_TOPDIR)/rules.mk
  5. include ../rules.mk
  6. include Makefile.inc
  7. include ${ADK_TOPDIR}/mk/buildhlp.mk
  8. TARGET_CFLAGS:=$(filter-out -flto,$(TARGET_CFLAGS))
  9. ifeq ($(ADK_TARGET_HARD_FLOAT),y)
  10. ifeq ($(ADK_TARGET_ARCH_ARM),y)
  11. TARGET_CFLAGS+= -Wa,-mfloat-abi=hard
  12. endif
  13. ifeq ($(ADK_TARGET_ARCH_MIPS),y)
  14. TARGET_CFLAGS+= -Wa,-mhard-float
  15. endif
  16. endif
  17. ifeq ($(ADK_TARGET_SOFT_FLOAT),y)
  18. ifeq ($(ADK_TARGET_ARCH_ARM),y)
  19. TARGET_CFLAGS+= -Wa,-mfloat-abi=soft
  20. endif
  21. ifeq ($(ADK_TARGET_ARCH_MIPS),y)
  22. TARGET_CFLAGS+= -Wa,-msoft-float
  23. endif
  24. endif
  25. ifeq (${ADK_MAKE_PARALLEL},y)
  26. UCLIBC_MAKEOPTS+= -j${ADK_MAKE_JOBS}
  27. endif
  28. $(WRKBUILD)/.headers:
  29. $(SED) 's,^CROSS_COMPILE=.*,CROSS_COMPILE=$(TARGET_CROSS),g' $(WRKBUILD)/Rules.mak
  30. PATH='$(HOST_PATH)' sed -e 's^KERNEL_HEADERS.*$$KERNEL_HEADERS=\"${STAGING_TARGET_DIR}/usr/include\"' \
  31. $(ADK_TOPDIR)/target/$(ADK_TARGET_ARCH)/uclibc.config >${WRKBUILD}/.config
  32. ifeq ($(ADK_TARGET_ENDIAN),little)
  33. $(SED) 's/.*\(ARCH_LITTLE_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  34. $(SED) 's/.*\(ARCH_WANTS_LITTLE_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  35. $(SED) 's/.*\(ARCH_BIG_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  36. $(SED) 's/.*\(ARCH_WANTS_BIG_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  37. else
  38. $(SED) 's/.*\(ARCH_BIG_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  39. $(SED) 's/.*\(ARCH_WANTS_BIG_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  40. $(SED) 's/.*\(ARCH_LITTLE_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  41. $(SED) 's/.*\(ARCH_WANTS_LITTLE_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  42. endif
  43. ifeq ($(ADK_TARGET_SOFT_FLOAT),y)
  44. $(SED) 's/.*\(UCLIBC_HAS_FPU\).*/# \1 is not set/' ${WRKBUILD}/.config
  45. $(SED) 's/.*\(UCLIBC_HAS_SOFT_FLOAT\).*/#\1=y/' ${WRKBUILD}/.config
  46. endif
  47. ifeq ($(ADK_TARGET_HARD_FLOAT),y)
  48. $(SED) 's/.*\(UCLIBC_HAS_FPU\).*/\1=y/' ${WRKBUILD}/.config
  49. $(SED) 's/.*\(UCLIBC_HAS_SOFT_FLOAT\).*/# \1 is not set/' ${WRKBUILD}/.config
  50. endif
  51. ifeq ($(ADK_TARGET_BINFMT_FLAT),y)
  52. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT_SEP_DATA\).*/\1=y/' ${WRKBUILD}/.config
  53. endif
  54. ifeq ($(ADK_TARGET_UCLINUX),y)
  55. $(SED) 's/.*\(ARCH_USE_MMU\).*/# \1 is not set/' ${WRKBUILD}/.config
  56. endif
  57. ifeq ($(ADK_TARGET_WITH_NPTL),y)
  58. $(SED) 's/.*\(UCLIBC_HAS_THREADS_NATIVE\).*/\1=y/' ${WRKBUILD}/.config
  59. $(SED) 's/.*\(UCLIBC_HAS_TLS\).*/\1=y/' ${WRKBUILD}/.config
  60. $(SED) 's/.*\(PTHREADS_DEBUG_SUPPORT\).*/\1=y/' ${WRKBUILD}/.config
  61. $(SED) 's/.*\(LINUXTHREADS_OLD\).*/# \1 is not set/' ${WRKBUILD}/.config
  62. $(SED) 's/.*\(LINUXTHREADS_NEW\).*/# \1 is not set/' ${WRKBUILD}/.config
  63. $(SED) 's/.*\(HAS_NO_THREADS\).*/# \1 is not set/' ${WRKBUILD}/.config
  64. else
  65. $(SED) 's/.*\(UCLIBC_HAS_THREADS_NATIVE\).*/# \1 is not set/' ${WRKBUILD}/.config
  66. $(SED) 's/.*\(UCLIBC_HAS_TLS\).*/# \1 is not set/' ${WRKBUILD}/.config
  67. $(SED) 's/.*\(LINUXTHREADS_OLD\).*/\1=y/' ${WRKBUILD}/.config
  68. $(SED) 's/.*\(LINUXTHREADS_NEW\).*/# \1 is not set/' ${WRKBUILD}/.config
  69. $(SED) 's/.*\(HAS_NO_THREADS\).*/# \1 is not set/' ${WRKBUILD}/.config
  70. endif
  71. ifeq ($(ADK_TARGET_USE_STATIC_LIBS)$(ADK_TARGET_BINFMT_FLAT),)
  72. $(SED) 's/.*\(HAVE_SHARED\).*/\1=y/' ${WRKBUILD}/.config
  73. else
  74. $(SED) 's/.*\(HAVE_SHARED\).*/# \1 is not set/' ${WRKBUILD}/.config
  75. endif
  76. ifeq ($(ADK_TARGET_USE_GNU_HASHSTYLE),y)
  77. $(SED) 's/.*\(LDSO_GNU_HASH_SUPPORT\).*/#\1=y/' ${WRKBUILD}/.config
  78. else
  79. $(SED) 's/.*\(LDSO_GNU_HASH_SUPPORT\).*/# \1 is not set/' ${WRKBUILD}/.config
  80. endif
  81. ifeq ($(ADK_TARGET_USE_SSP),y)
  82. $(SED) 's,.*UCLIBC_HAS_SSP,UCLIBC_HAS_SSP=y,' ${WRKBUILD}/.config
  83. echo "UCLIBC_HAS_SSP_COMPAT=n" >> ${WRKBUILD}/.config
  84. echo "SSP_QUICK_CANARY=n" >> ${WRKBUILD}/.config
  85. echo "UCLIBC_BUILD_SSP=y" >> ${WRKBUILD}/.config
  86. endif
  87. #
  88. # architecture specific options
  89. #
  90. # arm
  91. ifeq ($(ADK_TARGET_ARCH_ARM),y)
  92. ifeq ($(ADK_TARGET_ARCH_ARM_WITH_THUMB),y)
  93. $(SED) 's/.*\(COMPILE_IN_THUMB_MODE\).*/\1=y/' ${WRKBUILD}/.config
  94. endif
  95. endif
  96. # mips
  97. ifeq ($(ADK_TARGET_ARCH_MIPS),y)
  98. ifeq ($(ADK_CPU_MIPS32R2),y)
  99. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32 \).*/# \1 is not set/' ${WRKBUILD}/.config
  100. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32R2\).*/\1=y/' ${WRKBUILD}/.config
  101. endif
  102. endif
  103. # mips64
  104. ifeq ($(ADK_TARGET_ARCH_MIPS64),y)
  105. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS64\).*/\1=y/' ${WRKBUILD}/.config
  106. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32\).*/# \1 is not set/' ${WRKBUILD}/.config
  107. ifeq ($(ADK_n64),y)
  108. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/\1=y/' ${WRKBUILD}/.config
  109. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  110. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  111. endif
  112. ifeq ($(ADK_n32),y)
  113. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/\1=y/' ${WRKBUILD}/.config
  114. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  115. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  116. endif
  117. ifeq ($(ADK_o32),y)
  118. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/\1=y/' ${WRKBUILD}/.config
  119. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  120. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  121. endif
  122. endif
  123. echo N|PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  124. PREFIX=$(STAGING_TARGET_DIR) \
  125. DEVEL_PREFIX=/usr/ \
  126. RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
  127. HOSTCC="$(HOST_CC)" \
  128. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  129. oldconfig
  130. PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  131. PREFIX=$(STAGING_TARGET_DIR) \
  132. DEVEL_PREFIX=/usr/ \
  133. RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
  134. HOSTCC="$(HOST_CC)" \
  135. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  136. install_headers
  137. touch $(WRKBUILD)/.configured
  138. touch $@
  139. $(WRKBUILD)/.compiled:
  140. PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  141. PREFIX= \
  142. DEVEL_PREFIX=/ \
  143. RUNTIME_PREFIX=/ \
  144. HOSTCC="$(HOST_CC)" \
  145. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  146. VERBOSE=1 \
  147. all
  148. touch $@
  149. $(WRKBUILD)/.install_headers: $(WRKBUILD)/.compiled
  150. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  151. PREFIX=$(STAGING_TARGET_DIR) \
  152. DEVEL_PREFIX=/usr/ \
  153. DEVEL_PREFIX_LIB=/ \
  154. RUNTIME_PREFIX=/ \
  155. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  156. VERBOSE=1 \
  157. install_dev
  158. touch $@
  159. $(WRKBUILD)/.installed: $(WRKBUILD)/.install_headers
  160. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  161. PREFIX=$(STAGING_TARGET_DIR) \
  162. DEVEL_PREFIX=/usr/ \
  163. DEVEL_PREFIX_LIB=/ \
  164. RUNTIME_PREFIX=/ \
  165. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  166. VERBOSE=1 \
  167. install_runtime
  168. touch $@
  169. $(WRKBUILD)/.fixup:
  170. ifeq ($(ADK_UCLIBC_TEST),y)
  171. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  172. CC='$(TARGET_CC)' \
  173. TEST_INSTALLED_UCLIBC=1 \
  174. UCLIBC_ONLY=1 \
  175. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  176. VERBOSE=1 \
  177. test_compile
  178. endif
  179. ifeq ($(ADK_TARGET_TOOLCHAIN),y)
  180. # cleanup toolchain
  181. -find $(STAGING_TARGET_DIR) $(STAGING_HOST_DIR) -name \*.la -exec rm {} \;
  182. # strip target libs and host tools for toolchain builds
  183. PATH="$(TARGET_PATH)" debug='0' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh \
  184. $(STAGING_TARGET_DIR) $(TOOLCHAIN_DIR)/usr/lib/gcc/$(GNU_TARGET_NAME)
  185. debug='0' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(TOOLCHAIN_DIR)/usr/bin
  186. endif
  187. touch $@
  188. include ${ADK_TOPDIR}/mk/toolchain.mk