Makefile 7.1 KB

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