Makefile 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. ifeq ($(ADK_TARGET_LIB_UCLIBC_NG_GIT),y)
  31. PATH='$(HOST_PATH)' sed -e 's^KERNEL_HEADERS.*$$KERNEL_HEADERS=\"${STAGING_TARGET_DIR}/usr/include\"' \
  32. $(ADK_TOPDIR)/target/$(ADK_TARGET_ARCH)/uclibc-ng.config >${WRKBUILD}/.config
  33. else
  34. PATH='$(HOST_PATH)' sed -e 's^KERNEL_HEADERS.*$$KERNEL_HEADERS=\"${STAGING_TARGET_DIR}/usr/include\"' \
  35. $(ADK_TOPDIR)/target/$(ADK_TARGET_ARCH)/uclibc.config >${WRKBUILD}/.config
  36. endif
  37. ifeq ($(ADK_TARGET_ENDIAN),little)
  38. $(SED) 's/.*\(ARCH_LITTLE_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  39. $(SED) 's/.*\(ARCH_WANTS_LITTLE_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  40. $(SED) 's/.*\(ARCH_BIG_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  41. $(SED) 's/.*\(ARCH_WANTS_BIG_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  42. else
  43. $(SED) 's/.*\(ARCH_BIG_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  44. $(SED) 's/.*\(ARCH_WANTS_BIG_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  45. $(SED) 's/.*\(ARCH_LITTLE_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  46. $(SED) 's/.*\(ARCH_WANTS_LITTLE_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  47. endif
  48. ifeq ($(ADK_TARGET_SOFT_FLOAT),y)
  49. $(SED) 's/.*\(UCLIBC_HAS_FPU\).*/# \1 is not set/' ${WRKBUILD}/.config
  50. $(SED) 's/.*\(UCLIBC_HAS_SOFT_FLOAT\).*/#\1=y/' ${WRKBUILD}/.config
  51. endif
  52. ifeq ($(ADK_TARGET_HARD_FLOAT),y)
  53. $(SED) 's/.*\(UCLIBC_HAS_FPU\).*/\1=y/' ${WRKBUILD}/.config
  54. $(SED) 's/.*\(UCLIBC_HAS_SOFT_FLOAT\).*/# \1 is not set/' ${WRKBUILD}/.config
  55. endif
  56. ifeq ($(ADK_TARGET_BINFMT_FLAT),y)
  57. ifeq ($(ADK_TARGET_BINFMT_FLAT_ONE),y)
  58. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT_ONE\).*/\1=y/' ${WRKBUILD}/.config
  59. endif
  60. ifeq ($(ADK_TARGET_BINFMT_FLAT_SEP_DATA),y)
  61. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT_SEP_DATA\).*/\1=y/' ${WRKBUILD}/.config
  62. endif
  63. ifeq ($(ADK_TARGET_BINFMT_FLAT_SHARED),y)
  64. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT_SHARED\).*/\1=y/' ${WRKBUILD}/.config
  65. endif
  66. endif
  67. ifeq ($(ADK_TARGET_UCLINUX),y)
  68. $(SED) 's/.*\(ARCH_USE_MMU\).*/# \1 is not set/' ${WRKBUILD}/.config
  69. endif
  70. ifeq ($(ADK_TARGET_LIB_UCLIBC_NG_GIT),y)
  71. ifeq ($(ADK_TARGET_WITH_NPTL),y)
  72. $(SED) 's/.*\(UCLIBC_HAS_THREADS_NATIVE\).*/\1=y/' ${WRKBUILD}/.config
  73. $(SED) 's/.*\(UCLIBC_HAS_TLS\).*/\1=y/' ${WRKBUILD}/.config
  74. $(SED) 's/.*\(PTHREADS_DEBUG_SUPPORT\).*/\1=y/' ${WRKBUILD}/.config
  75. $(SED) 's/.*\(UCLIBC_HAS_LINUXTHREADS\).*/# \1 is not set/' ${WRKBUILD}/.config
  76. $(SED) 's/.*\(HAS_NO_THREADS\).*/# \1 is not set/' ${WRKBUILD}/.config
  77. endif
  78. ifeq ($(ADK_TARGET_WITH_LT),y)
  79. $(SED) 's/.*\(UCLIBC_HAS_LINUXTHREADS\).*/\1=y/' ${WRKBUILD}/.config
  80. $(SED) 's/.*\(UCLIBC_HAS_THREADS_NATIVE\).*/# \1 is not set/' ${WRKBUILD}/.config
  81. $(SED) 's/.*\(UCLIBC_HAS_TLS\).*/# \1 is not set/' ${WRKBUILD}/.config
  82. $(SED) 's/.*\(PTHREADS_DEBUG_SUPPORT\).*/\1=y/' ${WRKBUILD}/.config
  83. $(SED) 's/.*\(HAS_NO_THREADS\).*/# \1 is not set/' ${WRKBUILD}/.config
  84. endif
  85. endif
  86. ifeq ($(ADK_TARGET_LIB_UCLIBC_NG_1_0_0),y)
  87. ifeq ($(ADK_TARGET_WITH_NPTL),y)
  88. $(SED) 's/.*\(UCLIBC_HAS_THREADS_NATIVE\).*/\1=y/' ${WRKBUILD}/.config
  89. $(SED) 's/.*\(UCLIBC_HAS_TLS\).*/\1=y/' ${WRKBUILD}/.config
  90. $(SED) 's/.*\(PTHREADS_DEBUG_SUPPORT\).*/\1=y/' ${WRKBUILD}/.config
  91. $(SED) 's/.*\(LINUXTHREADS_OLD\).*/# \1 is not set/' ${WRKBUILD}/.config
  92. $(SED) 's/.*\(LINUXTHREADS_NEW\).*/# \1 is not set/' ${WRKBUILD}/.config
  93. $(SED) 's/.*\(HAS_NO_THREADS\).*/# \1 is not set/' ${WRKBUILD}/.config
  94. endif
  95. ifeq ($(ADK_TARGET_WITH_LT),y)
  96. $(SED) 's/.*\(UCLIBC_HAS_THREADS_NATIVE\).*/# \1 is not set/' ${WRKBUILD}/.config
  97. $(SED) 's/.*\(UCLIBC_HAS_TLS\).*/# \1 is not set/' ${WRKBUILD}/.config
  98. $(SED) 's/.*\(LINUXTHREADS_OLD\).*/\1=y/' ${WRKBUILD}/.config
  99. $(SED) 's/.*\(LINUXTHREADS_NEW\).*/# \1 is not set/' ${WRKBUILD}/.config
  100. $(SED) 's/.*\(HAS_NO_THREADS\).*/# \1 is not set/' ${WRKBUILD}/.config
  101. endif
  102. endif
  103. ifeq ($(ADK_TARGET_USE_STATIC_LIBS)$(ADK_TARGET_BINFMT_FLAT),)
  104. $(SED) 's/.*\(HAVE_SHARED\).*/\1=y/' ${WRKBUILD}/.config
  105. else
  106. $(SED) 's/.*\(HAVE_SHARED\).*/# \1 is not set/' ${WRKBUILD}/.config
  107. endif
  108. ifeq ($(ADK_TARGET_USE_GNU_HASHSTYLE),y)
  109. $(SED) 's/.*\(LDSO_GNU_HASH_SUPPORT\).*/#\1=y/' ${WRKBUILD}/.config
  110. else
  111. $(SED) 's/.*\(LDSO_GNU_HASH_SUPPORT\).*/# \1 is not set/' ${WRKBUILD}/.config
  112. endif
  113. ifeq ($(ADK_TARGET_USE_SSP),y)
  114. $(SED) 's,.*UCLIBC_HAS_SSP,UCLIBC_HAS_SSP=y,' ${WRKBUILD}/.config
  115. echo "UCLIBC_HAS_SSP_COMPAT=n" >> ${WRKBUILD}/.config
  116. echo "SSP_QUICK_CANARY=n" >> ${WRKBUILD}/.config
  117. echo "UCLIBC_BUILD_SSP=y" >> ${WRKBUILD}/.config
  118. endif
  119. #
  120. # architecture specific options
  121. #
  122. # arm
  123. ifeq ($(ADK_TARGET_ARCH_ARM),y)
  124. ifeq ($(ADK_TARGET_ARCH_ARM_WITH_THUMB),y)
  125. $(SED) 's/.*\(COMPILE_IN_THUMB_MODE\).*/\1=y/' ${WRKBUILD}/.config
  126. endif
  127. endif
  128. # mips
  129. ifeq ($(ADK_TARGET_ARCH_MIPS),y)
  130. ifeq ($(ADK_CPU_MIPS32R2),y)
  131. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32 \).*/# \1 is not set/' ${WRKBUILD}/.config
  132. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32R2\).*/\1=y/' ${WRKBUILD}/.config
  133. endif
  134. endif
  135. ifeq ($(ADK_TARGET_ARCH_X86),y)
  136. ifeq ($(ADK_CPU_I486),y)
  137. $(SED) 's/.*\(CONFIG_686\).*/# \1 is not set/' ${WRKBUILD}/.config
  138. $(SED) 's/.*\(CONFIG_586\).*/# \1 is not set/' ${WRKBUILD}/.config
  139. $(SED) 's/.*\(CONFIG_486\).*/\1=y/' ${WRKBUILD}/.config
  140. endif
  141. ifeq ($(ADK_CPU_I586),y)
  142. $(SED) 's/.*\(CONFIG_686\).*/# \1 is not set/' ${WRKBUILD}/.config
  143. $(SED) 's/.*\(CONFIG_586\).*/\1=y/' ${WRKBUILD}/.config
  144. $(SED) 's/.*\(CONFIG_486\).*/# \1 is not set/' ${WRKBUILD}/.config
  145. endif
  146. ifeq ($(ADK_CPU_I686),y)
  147. $(SED) 's/.*\(CONFIG_686\).*/\1=y/' ${WRKBUILD}/.config
  148. $(SED) 's/.*\(CONFIG_586\).*/# \1 is not set/' ${WRKBUILD}/.config
  149. $(SED) 's/.*\(CONFIG_486\).*/# \1 is not set/' ${WRKBUILD}/.config
  150. endif
  151. endif
  152. # mips64
  153. ifeq ($(ADK_TARGET_ARCH_MIPS64),y)
  154. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS64\).*/\1=y/' ${WRKBUILD}/.config
  155. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32\).*/# \1 is not set/' ${WRKBUILD}/.config
  156. ifeq ($(ADK_n64),y)
  157. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/\1=y/' ${WRKBUILD}/.config
  158. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  159. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  160. endif
  161. ifeq ($(ADK_n32),y)
  162. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/\1=y/' ${WRKBUILD}/.config
  163. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  164. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  165. endif
  166. ifeq ($(ADK_o32),y)
  167. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/\1=y/' ${WRKBUILD}/.config
  168. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  169. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  170. endif
  171. endif
  172. echo N|PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  173. PREFIX=$(STAGING_TARGET_DIR) \
  174. DEVEL_PREFIX=/usr/ \
  175. RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
  176. HOSTCC="$(HOST_CC)" \
  177. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  178. UCLIBC_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
  179. oldconfig
  180. PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  181. PREFIX=$(STAGING_TARGET_DIR) \
  182. DEVEL_PREFIX=/usr/ \
  183. RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
  184. HOSTCC="$(HOST_CC)" \
  185. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  186. UCLIBC_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
  187. install_headers
  188. touch $(WRKBUILD)/.configured
  189. touch $@
  190. $(WRKBUILD)/.compiled:
  191. PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  192. PREFIX= \
  193. DEVEL_PREFIX=/ \
  194. RUNTIME_PREFIX=/ \
  195. HOSTCC="$(HOST_CC)" \
  196. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  197. UCLIBC_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
  198. VERBOSE=1 \
  199. all
  200. touch $@
  201. $(WRKBUILD)/.install_headers: $(WRKBUILD)/.compiled
  202. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  203. PREFIX=$(STAGING_TARGET_DIR) \
  204. DEVEL_PREFIX=/usr/ \
  205. DEVEL_PREFIX_LIB=/ \
  206. RUNTIME_PREFIX=/ \
  207. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  208. UCLIBC_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
  209. VERBOSE=1 \
  210. install_dev
  211. touch $@
  212. $(WRKBUILD)/.installed: $(WRKBUILD)/.install_headers
  213. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  214. PREFIX=$(STAGING_TARGET_DIR) \
  215. DEVEL_PREFIX=/usr/ \
  216. DEVEL_PREFIX_LIB=/ \
  217. RUNTIME_PREFIX=/ \
  218. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  219. UCLIBC_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
  220. VERBOSE=1 \
  221. install_runtime
  222. touch $@
  223. $(WRKBUILD)/.fixup:
  224. ifeq ($(ADK_UCLIBC_TEST),y)
  225. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  226. CC='$(TARGET_CC)' \
  227. TEST_INSTALLED_UCLIBC=1 \
  228. UCLIBC_ONLY=1 \
  229. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  230. UCLIBC_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" \
  231. VERBOSE=1 \
  232. test_compile
  233. endif
  234. ifeq ($(ADK_TARGET_TOOLCHAIN),y)
  235. # cleanup toolchain
  236. -find $(STAGING_TARGET_DIR) $(STAGING_HOST_DIR) -name \*.la -exec rm {} \;
  237. # strip target libs and host tools for toolchain builds
  238. PATH="$(TARGET_PATH)" debug='0' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh \
  239. $(STAGING_TARGET_DIR) $(TOOLCHAIN_DIR)/usr/lib/gcc/$(GNU_TARGET_NAME)
  240. debug='0' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(TOOLCHAIN_DIR)/usr/bin
  241. endif
  242. touch $@
  243. include ${ADK_TOPDIR}/mk/toolchain.mk