Makefile 6.3 KB

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