Makefile 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 $(TOPDIR)/rules.mk
  5. include ../rules.mk
  6. include Makefile.inc
  7. include ${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. UCLIBCCFG=uclibc.config
  13. ifeq ($(ADK_TARGET_ENDIAN),little)
  14. ifeq ($(ADK_CPU_MIPS64),y)
  15. UCLIBCCFG=uclibc.config.little.mips64
  16. else
  17. UCLIBCCFG=uclibc.config.little
  18. endif
  19. endif
  20. ifeq ($(ADK_TARGET_ENDIAN),big)
  21. ifeq ($(ADK_CPU_MIPS64),y)
  22. UCLIBCCFG=uclibc.config.big.mips64
  23. else
  24. UCLIBCCFG=uclibc.config.big
  25. endif
  26. endif
  27. ifeq ($(ADK_TARGET_SYSTEM_LEMOTE_YEELONG),y)
  28. UCLIBCCFG=uclibc.config.little.mips64
  29. endif
  30. $(WRKBUILD)/.headers:
  31. $(SED) 's,^CROSS_COMPILE=.*,CROSS_COMPILE=$(TARGET_CROSS),g' $(WRKBUILD)/Rules.mak
  32. sed -e 's^KERNEL_HEADERS.*$$KERNEL_HEADERS=\"${STAGING_TARGET_DIR}/usr/include\"' \
  33. $(TOPDIR)/target/$(ADK_TARGET_ARCH)/$(UCLIBCCFG) >${WRKBUILD}/.config
  34. ifeq ($(ADK_TARGET_ABI_N64),y)
  35. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/\1=y/' ${WRKBUILD}/.config
  36. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  37. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  38. endif
  39. ifeq ($(ADK_TARGET_ABI_N32),y)
  40. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/\1=y/' ${WRKBUILD}/.config
  41. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  42. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  43. endif
  44. ifeq ($(ADK_TARGET_ABI_O32),y)
  45. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/\1=y/' ${WRKBUILD}/.config
  46. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  47. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  48. endif
  49. ifneq ($(ADK_PACKAGE_GDB),)
  50. $(SED) "s/.*\(PTHREADS_DEBUG_SUPPORT\).*/\1=y/" ${WRKBUILD}/.config
  51. endif
  52. ifeq ($(ADK_LINUX_ARM_WITH_THUMB),y)
  53. $(SED) 's/.*\(COMPILE_IN_THUMB_MODE\).*/\1=y/' ${WRKBUILD}/.config
  54. endif
  55. ifeq ($(ADK_TOOLCHAIN_GCC_USE_SSP),y)
  56. $(SED) 's,.*UCLIBC_HAS_SSP,UCLIBC_HAS_SSP=y,' ${WRKBUILD}/.config
  57. echo "UCLIBC_HAS_SSP_COMPAT=n" >> ${WRKBUILD}/.config
  58. echo "SSP_QUICK_CANARY=n" >> ${WRKBUILD}/.config
  59. echo "UCLIBC_BUILD_SSP=y" >> ${WRKBUILD}/.config
  60. endif
  61. echo N|$(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  62. PREFIX=$(STAGING_TARGET_DIR) \
  63. DEVEL_PREFIX=/usr/ \
  64. RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
  65. HOSTCC="$(CC_FOR_BUILD)" \
  66. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  67. oldconfig
  68. $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  69. PREFIX=$(STAGING_TARGET_DIR) \
  70. DEVEL_PREFIX=/usr/ \
  71. RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
  72. HOSTCC="$(CC_FOR_BUILD)" \
  73. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  74. install_headers
  75. touch $(WRKBUILD)/.configured
  76. touch $@
  77. $(WRKBUILD)/.compiled:
  78. $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  79. PREFIX= \
  80. DEVEL_PREFIX=/ \
  81. RUNTIME_PREFIX=/ \
  82. HOSTCC="$(CC_FOR_BUILD)" \
  83. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  84. all
  85. touch $@
  86. $(WRKBUILD)/.install_headers: $(WRKBUILD)/.compiled
  87. $(MAKE) -C $(WRKBUILD) \
  88. PREFIX=$(STAGING_TARGET_DIR) \
  89. DEVEL_PREFIX=/usr/ \
  90. DEVEL_PREFIX_LIB=/ \
  91. RUNTIME_PREFIX=/ \
  92. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  93. install_dev
  94. touch $@
  95. $(WRKBUILD)/.installed: $(WRKBUILD)/.install_headers
  96. touch $@
  97. $(WRKBUILD)/.fixup:
  98. ifneq ($(ADK_DEBUG),)
  99. $(SED) 's,DOSTRIP,DODEBUG,' ${WRKBUILD}/.config
  100. endif
  101. $(MAKE) -C $(WRKBUILD) \
  102. PREFIX=$(STAGING_TARGET_DIR) \
  103. DEVEL_PREFIX=/usr/ \
  104. DEVEL_PREFIX_LIB=/ \
  105. RUNTIME_PREFIX=/ \
  106. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  107. all install_runtime
  108. rm -rf $(STAGING_TARGET_DIR)/lib/libc.so
  109. ln -s libc.so.0 $(STAGING_TARGET_DIR)/lib/libc.so
  110. # cleanup toolchain
  111. -find $(STAGING_TARGET_DIR) $(STAGING_HOST_DIR) -name \*.la -delete
  112. ifeq ($(ADK_TOOLCHAIN),y)
  113. # strip target libs and host tools for toolchain builds
  114. PATH="$(TARGET_PATH)" debug='0' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_TARGET_DIR)
  115. debug='0' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(STAGING_HOST_DIR)
  116. endif
  117. touch $@
  118. include ${TOPDIR}/mk/toolchain.mk