Makefile 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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_USE_STATIC_LIBS)$(ADK_TARGET_BINFMT_FLAT),)
  35. $(SED) 's/.*\(HAVE_SHARED\).*/\1=y/' ${WRKBUILD}/.config
  36. else
  37. $(SED) 's/.*\(HAVE_SHARED\).*/# \1 is not set/' ${WRKBUILD}/.config
  38. endif
  39. ifeq ($(ADK_TARGET_USE_GNU_HASHSTYLE),y)
  40. $(SED) 's/.*\(LDSO_GNU_HASH_SUPPORT\).*/#\1=y/' ${WRKBUILD}/.config
  41. else
  42. $(SED) 's/.*\(LDSO_GNU_HASH_SUPPORT\).*/# \1 is not set/' ${WRKBUILD}/.config
  43. endif
  44. ifeq ($(ADK_TARGET_USE_SSP),y)
  45. $(SED) 's,.*UCLIBC_HAS_SSP,UCLIBC_HAS_SSP=y,' ${WRKBUILD}/.config
  46. echo "UCLIBC_HAS_SSP_COMPAT=n" >> ${WRKBUILD}/.config
  47. echo "SSP_QUICK_CANARY=n" >> ${WRKBUILD}/.config
  48. echo "UCLIBC_BUILD_SSP=y" >> ${WRKBUILD}/.config
  49. endif
  50. # architecture specific options
  51. # arm
  52. ifeq ($(ADK_TARGET_ARCH_ARM),y)
  53. ifeq ($(ADK_TARGET_ABI_EABI),y)
  54. $(SED) 's/.*\(UCLIBC_HAS_FPU\).*/# \1 is not set/' ${WRKBUILD}/.config
  55. $(SED) 's/.*\(UCLIBC_HAS_SOFT_FLOAT\).*/#\1=y/' ${WRKBUILD}/.config
  56. endif
  57. ifeq ($(ADK_TARGET_ABI_EABIHF),y)
  58. $(SED) 's/.*\(UCLIBC_HAS_FPU\).*/\1=y/' ${WRKBUILD}/.config
  59. $(SED) 's/.*\(UCLIBC_HAS_SOFT_FLOAT\).*/# \1 is not set/' ${WRKBUILD}/.config
  60. endif
  61. ifeq ($(ADK_LINUX_ARM_WITH_THUMB),y)
  62. $(SED) 's/.*\(COMPILE_IN_THUMB_MODE\).*/\1=y/' ${WRKBUILD}/.config
  63. endif
  64. endif
  65. # mips/mips64
  66. ifeq ($(ADK_TARGET_ARCH_MIPS64),y)
  67. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS64\).*/\1=y/' ${WRKBUILD}/.config
  68. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32\).*/# \1 is not set/' ${WRKBUILD}/.config
  69. endif
  70. ifeq ($(ADK_TARGET_ARCH_MIPS),y)
  71. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32\).*/\1=y/' ${WRKBUILD}/.config
  72. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS64\).*/# \1 is not set/' ${WRKBUILD}/.config
  73. endif
  74. ifeq ($(ADK_TARGET_ARCH_MIPS64),y)
  75. ifeq ($(ADK_n64),y)
  76. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/\1=y/' ${WRKBUILD}/.config
  77. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  78. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  79. endif
  80. ifeq ($(ADK_n32),y)
  81. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/\1=y/' ${WRKBUILD}/.config
  82. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  83. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  84. endif
  85. ifeq ($(ADK_o32),y)
  86. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/\1=y/' ${WRKBUILD}/.config
  87. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  88. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  89. endif
  90. endif
  91. # powerpc
  92. ifeq ($(ADK_TARGET_ARCH_PPC),y)
  93. ifeq ($(ADK_TARGET_CPU_WITH_FPU),y)
  94. $(SED) 's/.*\(UCLIBC_HAS_FPU\).*/\1=y/' ${WRKBUILD}/.config
  95. $(SED) 's/.*\(UCLIBC_HAS_SOFT_FLOAT\).*/# \1 is not set/' ${WRKBUILD}/.config
  96. else
  97. $(SED) 's/.*\(UCLIBC_HAS_FPU\).*/# \1 is not set/' ${WRKBUILD}/.config
  98. $(SED) 's/.*\(UCLIBC_HAS_SOFT_FLOAT\).*/#\1=y/' ${WRKBUILD}/.config
  99. endif
  100. endif
  101. echo N|PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  102. PREFIX=$(STAGING_TARGET_DIR) \
  103. DEVEL_PREFIX=/usr/ \
  104. RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
  105. HOSTCC="$(HOST_CC)" \
  106. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  107. oldconfig
  108. PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  109. PREFIX=$(STAGING_TARGET_DIR) \
  110. DEVEL_PREFIX=/usr/ \
  111. RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
  112. HOSTCC="$(HOST_CC)" \
  113. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  114. install_headers
  115. touch $(WRKBUILD)/.configured
  116. touch $@
  117. $(WRKBUILD)/.compiled:
  118. PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  119. PREFIX= \
  120. DEVEL_PREFIX=/ \
  121. RUNTIME_PREFIX=/ \
  122. HOSTCC="$(HOST_CC)" \
  123. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  124. VERBOSE=1 \
  125. all
  126. touch $@
  127. $(WRKBUILD)/.install_headers: $(WRKBUILD)/.compiled
  128. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  129. PREFIX=$(STAGING_TARGET_DIR) \
  130. DEVEL_PREFIX=/usr/ \
  131. DEVEL_PREFIX_LIB=/ \
  132. RUNTIME_PREFIX=/ \
  133. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  134. VERBOSE=1 \
  135. install_dev
  136. touch $@
  137. $(WRKBUILD)/.installed: $(WRKBUILD)/.install_headers
  138. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  139. PREFIX=$(STAGING_TARGET_DIR) \
  140. DEVEL_PREFIX=/usr/ \
  141. DEVEL_PREFIX_LIB=/ \
  142. RUNTIME_PREFIX=/ \
  143. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  144. VERBOSE=1 \
  145. install_runtime
  146. touch $@
  147. $(WRKBUILD)/.fixup:
  148. ifeq ($(ADK_UCLIBC_TEST),y)
  149. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  150. CC='$(TARGET_CC)' \
  151. TEST_INSTALLED_UCLIBC=1 \
  152. UCLIBC_ONLY=1 \
  153. UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
  154. V=1 \
  155. test_compile
  156. endif
  157. ifeq ($(ADK_TARGET_TOOLCHAIN),y)
  158. # cleanup toolchain
  159. -find $(STAGING_TARGET_DIR) $(STAGING_HOST_DIR) -name \*.la -exec {} \;
  160. # strip target libs and host tools for toolchain builds
  161. PATH="$(TARGET_PATH)" debug='0' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh \
  162. $(STAGING_TARGET_DIR) $(TOOLCHAIN_DIR)/usr/lib/gcc/$(GNU_TARGET_NAME)
  163. debug='0' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(TOOLCHAIN_DIR)/usr/bin
  164. endif
  165. touch $@
  166. include ${ADK_TOPDIR}/mk/toolchain.mk