Makefile 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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_UCLINUX),y)
  54. $(SED) 's/.*\(UCLIBC_FORMAT_FLAT_SEP_DATA\).*/\1=y/' ${WRKBUILD}/.config
  55. $(SED) 's/.*\(ARCH_USE_MMU\).*/# \1 is not set/' ${WRKBUILD}/.config
  56. endif
  57. ifeq ($(ADK_TARGET_USE_STATIC_LIBS)$(ADK_TARGET_BINFMT_FLAT),)
  58. $(SED) 's/.*\(HAVE_SHARED\).*/\1=y/' ${WRKBUILD}/.config
  59. else
  60. $(SED) 's/.*\(HAVE_SHARED\).*/# \1 is not set/' ${WRKBUILD}/.config
  61. endif
  62. ifeq ($(ADK_TARGET_USE_GNU_HASHSTYLE),y)
  63. $(SED) 's/.*\(LDSO_GNU_HASH_SUPPORT\).*/#\1=y/' ${WRKBUILD}/.config
  64. else
  65. $(SED) 's/.*\(LDSO_GNU_HASH_SUPPORT\).*/# \1 is not set/' ${WRKBUILD}/.config
  66. endif
  67. ifeq ($(ADK_TARGET_USE_SSP),y)
  68. $(SED) 's,.*UCLIBC_HAS_SSP,UCLIBC_HAS_SSP=y,' ${WRKBUILD}/.config
  69. echo "UCLIBC_HAS_SSP_COMPAT=n" >> ${WRKBUILD}/.config
  70. echo "SSP_QUICK_CANARY=n" >> ${WRKBUILD}/.config
  71. echo "UCLIBC_BUILD_SSP=y" >> ${WRKBUILD}/.config
  72. endif
  73. # architecture specific options
  74. # arm
  75. ifeq ($(ADK_TARGET_ARCH_ARM),y)
  76. ifeq ($(ADK_TARGET_ARCH_ARM_WITH_THUMB),y)
  77. $(SED) 's/.*\(COMPILE_IN_THUMB_MODE\).*/\1=y/' ${WRKBUILD}/.config
  78. endif
  79. endif
  80. # mips
  81. ifeq ($(ADK_TARGET_ARCH_MIPS),y)
  82. ifeq ($(ADK_CPU_MIPS32R2),y)
  83. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32 \).*/# \1 is not set/' ${WRKBUILD}/.config
  84. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32R2\).*/\1=y/' ${WRKBUILD}/.config
  85. endif
  86. endif
  87. # x86
  88. ifeq ($(ADK_TARGET_ARCH_X86),y)
  89. ifeq ($(ADK_CPU_I486),y)
  90. $(SED) 's/.*\(CONFIG_686\).*/# \1 is not set/' ${WRKBUILD}/.config
  91. $(SED) 's/.*\(CONFIG_586\).*/# \1 is not set/' ${WRKBUILD}/.config
  92. $(SED) 's/.*\(CONFIG_486\).*/\1=y/' ${WRKBUILD}/.config
  93. endif
  94. ifeq ($(ADK_CPU_I586),y)
  95. $(SED) 's/.*\(CONFIG_686\).*/# \1 is not set/' ${WRKBUILD}/.config
  96. $(SED) 's/.*\(CONFIG_586\).*/\1=y/' ${WRKBUILD}/.config
  97. $(SED) 's/.*\(CONFIG_486\).*/# \1 is not set/' ${WRKBUILD}/.config
  98. endif
  99. ifeq ($(ADK_CPU_I686),y)
  100. $(SED) 's/.*\(CONFIG_686\).*/\1=y/' ${WRKBUILD}/.config
  101. $(SED) 's/.*\(CONFIG_586\).*/# \1 is not set/' ${WRKBUILD}/.config
  102. $(SED) 's/.*\(CONFIG_486\).*/# \1 is not set/' ${WRKBUILD}/.config
  103. endif
  104. endif
  105. # mips64
  106. ifeq ($(ADK_TARGET_ARCH_MIPS64),y)
  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. V=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