Makefile 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. TARGET_CFLAGS:=$(filter-out -mtext-section-literals,$(TARGET_CFLAGS))
  10. # parallel building is broken at the moment
  11. #ifeq (${ADK_MAKE_PARALLEL},y)
  12. #UCLIBC_MAKEOPTS+= -j${ADK_MAKE_JOBS}
  13. #endif
  14. ifeq ($(ADK_TARGET_HARD_FLOAT),y)
  15. ifeq ($(ADK_TARGET_ARCH_ARM),y)
  16. TARGET_CFLAGS+= -Wa,-mfloat-abi=hard
  17. endif
  18. ifeq ($(ADK_TARGET_ARCH_MIPS),y)
  19. TARGET_CFLAGS+= -Wa,-mhard-float
  20. endif
  21. endif
  22. ifeq ($(ADK_TARGET_SOFT_FLOAT),y)
  23. ifeq ($(ADK_TARGET_ARCH_ARM),y)
  24. TARGET_CFLAGS+= -Wa,-mfloat-abi=soft
  25. endif
  26. ifeq ($(ADK_TARGET_ARCH_MIPS),y)
  27. TARGET_CFLAGS+= -Wa,-msoft-float
  28. endif
  29. endif
  30. $(WRKBUILD)/.headers:
  31. $(SED) 's,^CROSS_COMPILE=.*,CROSS_COMPILE=$(TARGET_CROSS),g' $(WRKBUILD)/Rules.mak
  32. PATH='$(HOST_PATH)' sed -e 's^KERNEL_HEADERS.*$$KERNEL_HEADERS=\"${STAGING_TARGET_DIR}/usr/include\"' \
  33. $(ADK_TOPDIR)/target/$(ADK_TARGET_ARCH)/uclibc.config >${WRKBUILD}/.config
  34. ifeq ($(ADK_TARGET_ENDIAN),little)
  35. $(SED) 's/.*\(ARCH_LITTLE_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  36. $(SED) 's/.*\(ARCH_WANTS_LITTLE_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  37. $(SED) 's/.*\(ARCH_BIG_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  38. $(SED) 's/.*\(ARCH_WANTS_BIG_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  39. else
  40. $(SED) 's/.*\(ARCH_BIG_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  41. $(SED) 's/.*\(ARCH_WANTS_BIG_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  42. $(SED) 's/.*\(ARCH_LITTLE_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  43. $(SED) 's/.*\(ARCH_WANTS_LITTLE_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  44. endif
  45. ifeq ($(ADK_TARGET_SOFT_FLOAT),y)
  46. $(SED) 's/.*\(UCLIBC_HAS_FPU\).*/# \1 is not set/' ${WRKBUILD}/.config
  47. $(SED) 's/.*\(UCLIBC_HAS_SOFT_FLOAT\).*/#\1=y/' ${WRKBUILD}/.config
  48. endif
  49. ifeq ($(ADK_TARGET_HARD_FLOAT),y)
  50. $(SED) 's/.*\(UCLIBC_HAS_FPU\).*/\1=y/' ${WRKBUILD}/.config
  51. $(SED) 's/.*\(UCLIBC_HAS_SOFT_FLOAT\).*/# \1 is not set/' ${WRKBUILD}/.config
  52. endif
  53. ifeq ($(ADK_TARGET_BINFMT_FDPIC),y)
  54. $(SED) 's/.*\(UCLIBC_FORMAT_FDPIC_ELF\).*/\1=y/' ${WRKBUILD}/.config
  55. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT\).*/# \1 is not set/' ${WRKBUILD}/.config
  56. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT_SEP_DATA\).*/# \1 is not set/' ${WRKBUILD}/.config
  57. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT_SHARED\).*/# \1 is not set/' ${WRKBUILD}/.config
  58. endif
  59. ifeq ($(ADK_TARGET_BINFMT_FLAT),y)
  60. ifeq ($(ADK_TARGET_BINFMT_FLAT_ONE),y)
  61. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT\).*/\1=y/' ${WRKBUILD}/.config
  62. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT_SEP_DATA\).*/# \1 is not set/' ${WRKBUILD}/.config
  63. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT_SHARED\).*/# \1 is not set/' ${WRKBUILD}/.config
  64. $(SED) 's/.*\(UCLIBC_FORMAT_FDPIC_ELF\).*/# \1 is not set/' ${WRKBUILD}/.config
  65. endif
  66. ifeq ($(ADK_TARGET_BINFMT_FLAT_SEP_DATA),y)
  67. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT_SEP_DATA\).*/\1=y/' ${WRKBUILD}/.config
  68. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT\).*/# \1 is not set/' ${WRKBUILD}/.config
  69. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT_SHARED\).*/# \1 is not set/' ${WRKBUILD}/.config
  70. $(SED) 's/.*\(UCLIBC_FORMAT_FDPIC_ELF\).*/# \1 is not set/' ${WRKBUILD}/.config
  71. endif
  72. ifeq ($(ADK_TARGET_BINFMT_FLAT_SHARED),y)
  73. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT_SHARED\).*/\1=y/' ${WRKBUILD}/.config
  74. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT\).*/# \1 is not set/' ${WRKBUILD}/.config
  75. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT_SEP_DATA\).*/# \1 is not set/' ${WRKBUILD}/.config
  76. $(SED) 's/.*\(UCLIBC_FORMAT_FDPIC_ELF\).*/# \1 is not set/' ${WRKBUILD}/.config
  77. endif
  78. endif
  79. ifeq ($(ADK_TARGET_UCLINUX),y)
  80. $(SED) 's/.*\(ARCH_USE_MMU\).*/# \1 is not set/' ${WRKBUILD}/.config
  81. endif
  82. ifeq ($(ADK_TARGET_USE_STATIC_LIBS)$(ADK_TARGET_BINFMT_FLAT),)
  83. $(SED) 's/.*\(HAVE_SHARED\).*/\1=y/' ${WRKBUILD}/.config
  84. else
  85. $(SED) 's/.*\(HAVE_SHARED\).*/# \1 is not set/' ${WRKBUILD}/.config
  86. endif
  87. ifeq ($(ADK_TARGET_USE_GNU_HASHSTYLE),y)
  88. $(SED) 's/.*\(LDSO_GNU_HASH_SUPPORT\).*/#\1=y/' ${WRKBUILD}/.config
  89. else
  90. $(SED) 's/.*\(LDSO_GNU_HASH_SUPPORT\).*/# \1 is not set/' ${WRKBUILD}/.config
  91. endif
  92. ifeq ($(ADK_TARGET_USE_SSP),y)
  93. $(SED) 's,.*UCLIBC_HAS_SSP,UCLIBC_HAS_SSP=y,' ${WRKBUILD}/.config
  94. echo "UCLIBC_HAS_SSP_COMPAT=n" >> ${WRKBUILD}/.config
  95. echo "SSP_QUICK_CANARY=n" >> ${WRKBUILD}/.config
  96. echo "UCLIBC_BUILD_SSP=y" >> ${WRKBUILD}/.config
  97. endif
  98. # architecture specific options
  99. # arm
  100. ifeq ($(ADK_TARGET_ARCH_ARM),y)
  101. ifeq ($(ADK_TARGET_ARCH_ARM_WITH_THUMB),y)
  102. $(SED) 's/.*\(COMPILE_IN_THUMB_MODE\).*/\1=y/' ${WRKBUILD}/.config
  103. endif
  104. endif
  105. # mips
  106. ifeq ($(ADK_TARGET_ARCH_MIPS),y)
  107. ifeq ($(ADK_CPU_MIPS32R2),y)
  108. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32 \).*/# \1 is not set/' ${WRKBUILD}/.config
  109. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32R2\).*/\1=y/' ${WRKBUILD}/.config
  110. endif
  111. endif
  112. # x86
  113. ifeq ($(ADK_TARGET_ARCH_X86),y)
  114. ifeq ($(ADK_CPU_I486),y)
  115. $(SED) 's/.*\(CONFIG_686\).*/# \1 is not set/' ${WRKBUILD}/.config
  116. $(SED) 's/.*\(CONFIG_586\).*/# \1 is not set/' ${WRKBUILD}/.config
  117. $(SED) 's/.*\(CONFIG_486\).*/\1=y/' ${WRKBUILD}/.config
  118. endif
  119. ifeq ($(ADK_CPU_I586),y)
  120. $(SED) 's/.*\(CONFIG_686\).*/# \1 is not set/' ${WRKBUILD}/.config
  121. $(SED) 's/.*\(CONFIG_586\).*/\1=y/' ${WRKBUILD}/.config
  122. $(SED) 's/.*\(CONFIG_486\).*/# \1 is not set/' ${WRKBUILD}/.config
  123. endif
  124. ifeq ($(ADK_CPU_I686),y)
  125. $(SED) 's/.*\(CONFIG_686\).*/\1=y/' ${WRKBUILD}/.config
  126. $(SED) 's/.*\(CONFIG_586\).*/# \1 is not set/' ${WRKBUILD}/.config
  127. $(SED) 's/.*\(CONFIG_486\).*/# \1 is not set/' ${WRKBUILD}/.config
  128. endif
  129. endif
  130. # mips64
  131. ifeq ($(ADK_TARGET_ARCH_MIPS64),y)
  132. ifeq ($(ADK_n64),y)
  133. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/\1=y/' ${WRKBUILD}/.config
  134. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  135. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  136. endif
  137. ifeq ($(ADK_n32),y)
  138. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/\1=y/' ${WRKBUILD}/.config
  139. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  140. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  141. endif
  142. ifeq ($(ADK_o32),y)
  143. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/\1=y/' ${WRKBUILD}/.config
  144. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  145. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  146. endif
  147. endif
  148. echo N|PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  149. PREFIX=$(STAGING_TARGET_DIR) \
  150. DEVEL_PREFIX=/usr/ \
  151. RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
  152. HOSTCC="$(HOST_CC)" \
  153. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  154. oldconfig
  155. PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  156. PREFIX=$(STAGING_TARGET_DIR) \
  157. DEVEL_PREFIX=/usr/ \
  158. RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
  159. HOSTCC="$(HOST_CC)" \
  160. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  161. install_headers
  162. touch $(WRKBUILD)/.configured
  163. touch $@
  164. $(WRKBUILD)/.compiled:
  165. PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  166. PREFIX= \
  167. DEVEL_PREFIX=/ \
  168. RUNTIME_PREFIX=/ \
  169. HOSTCC="$(HOST_CC)" \
  170. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  171. VERBOSE=1 \
  172. all
  173. touch $@
  174. $(WRKBUILD)/.install_headers: $(WRKBUILD)/.compiled
  175. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  176. PREFIX=$(STAGING_TARGET_DIR) \
  177. DEVEL_PREFIX=/usr/ \
  178. DEVEL_PREFIX_LIB=/ \
  179. RUNTIME_PREFIX=/ \
  180. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  181. VERBOSE=1 \
  182. install_dev
  183. touch $@
  184. $(WRKBUILD)/.installed: $(WRKBUILD)/.install_headers
  185. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  186. PREFIX=$(STAGING_TARGET_DIR) \
  187. DEVEL_PREFIX=/usr/ \
  188. DEVEL_PREFIX_LIB=/ \
  189. RUNTIME_PREFIX=/ \
  190. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  191. VERBOSE=1 \
  192. install_runtime
  193. touch $@
  194. $(WRKBUILD)/.fixup:
  195. ifeq ($(ADK_UCLIBC_TEST),y)
  196. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  197. CC='$(TARGET_CC)' \
  198. TEST_INSTALLED_UCLIBC=1 \
  199. UCLIBC_ONLY=1 \
  200. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  201. V=1 \
  202. test_compile
  203. endif
  204. ifeq ($(ADK_TARGET_TOOLCHAIN),y)
  205. # cleanup toolchain
  206. -find $(STAGING_TARGET_DIR) $(STAGING_HOST_DIR) -name \*.la -exec rm {} \;
  207. # strip target libs and host tools for toolchain builds
  208. PATH="$(TARGET_PATH)" debug='0' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh \
  209. $(STAGING_TARGET_DIR) $(TOOLCHAIN_DIR)/usr/lib/gcc/$(GNU_TARGET_NAME)
  210. debug='0' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(TOOLCHAIN_DIR)/usr/bin
  211. endif
  212. touch $@
  213. include ${ADK_TOPDIR}/mk/toolchain.mk