1
0

Makefile 6.0 KB

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