Makefile 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. 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. 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_LINUX_64),y)
  29. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS64\).*/\1=y/' ${WRKBUILD}/.config
  30. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32\).*/# \1 is not set/' ${WRKBUILD}/.config
  31. else
  32. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32\).*/\1=y/' ${WRKBUILD}/.config
  33. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS64\).*/# \1 is not set/' ${WRKBUILD}/.config
  34. endif
  35. ifeq ($(ADK_n64),y)
  36. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/\1=y/' ${WRKBUILD}/.config
  37. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  38. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  39. endif
  40. ifeq ($(ADK_n32),y)
  41. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/\1=y/' ${WRKBUILD}/.config
  42. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  43. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  44. endif
  45. ifeq ($(ADK_o32),y)
  46. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/\1=y/' ${WRKBUILD}/.config
  47. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  48. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  49. endif
  50. ifneq ($(ADK_PACKAGE_GDB),)
  51. $(SED) "s/.*\(PTHREADS_DEBUG_SUPPORT\).*/\1=y/" ${WRKBUILD}/.config
  52. endif
  53. ifeq ($(ADK_LINUX_ARM_WITH_THUMB),y)
  54. $(SED) 's/.*\(COMPILE_IN_THUMB_MODE\).*/\1=y/' ${WRKBUILD}/.config
  55. endif
  56. ifeq ($(ADK_TARGET_USE_SSP),y)
  57. $(SED) 's,.*UCLIBC_HAS_SSP,UCLIBC_HAS_SSP=y,' ${WRKBUILD}/.config
  58. echo "UCLIBC_HAS_SSP_COMPAT=n" >> ${WRKBUILD}/.config
  59. echo "SSP_QUICK_CANARY=n" >> ${WRKBUILD}/.config
  60. echo "UCLIBC_BUILD_SSP=y" >> ${WRKBUILD}/.config
  61. endif
  62. echo N|$(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  63. PREFIX=$(STAGING_TARGET_DIR) \
  64. DEVEL_PREFIX=/usr/ \
  65. RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
  66. HOSTCC="$(HOST_CC)" \
  67. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  68. oldconfig
  69. $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  70. PREFIX=$(STAGING_TARGET_DIR) \
  71. DEVEL_PREFIX=/usr/ \
  72. RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
  73. HOSTCC="$(HOST_CC)" \
  74. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  75. install_headers
  76. touch $(WRKBUILD)/.configured
  77. touch $@
  78. $(WRKBUILD)/.compiled:
  79. $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  80. PREFIX= \
  81. DEVEL_PREFIX=/ \
  82. RUNTIME_PREFIX=/ \
  83. HOSTCC="$(HOST_CC)" \
  84. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  85. all
  86. touch $@
  87. $(WRKBUILD)/.install_headers: $(WRKBUILD)/.compiled
  88. $(MAKE) -C $(WRKBUILD) \
  89. PREFIX=$(STAGING_TARGET_DIR) \
  90. DEVEL_PREFIX=/usr/ \
  91. DEVEL_PREFIX_LIB=/ \
  92. RUNTIME_PREFIX=/ \
  93. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  94. install_dev
  95. touch $@
  96. $(WRKBUILD)/.installed: $(WRKBUILD)/.install_headers
  97. touch $@
  98. $(WRKBUILD)/.fixup:
  99. $(MAKE) -C $(WRKBUILD) \
  100. PREFIX=$(STAGING_TARGET_DIR) \
  101. DEVEL_PREFIX=/usr/ \
  102. DEVEL_PREFIX_LIB=/ \
  103. RUNTIME_PREFIX=/ \
  104. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  105. all install_runtime
  106. ifeq ($(ADK_TARGET_TOOLCHAIN),y)
  107. # cleanup toolchain
  108. -find $(STAGING_TARGET_DIR) $(STAGING_HOST_DIR) -name \*.la -delete
  109. # strip target libs and host tools for toolchain builds
  110. PATH="$(TARGET_PATH)" debug='0' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh \
  111. $(STAGING_TARGET_DIR) $(TOOLCHAIN_DIR)/usr/lib/gcc/$(GNU_TARGET_NAME)
  112. debug='0' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(TOOLCHAIN_DIR)/usr/bin
  113. endif
  114. touch $@
  115. include ${ADK_TOPDIR}/mk/toolchain.mk