Makefile 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. ifeq ($(ADK_TARGET_UCLINUX),y)
  16. PATH='$(HOST_PATH)' sed -e 's^KERNEL_HEADERS.*$$KERNEL_HEADERS=\"${STAGING_TARGET_DIR}/usr/include\"' \
  17. $(ADK_TOPDIR)/target/$(ADK_TARGET_ARCH)/uclibc-nommu.config >${WRKBUILD}/.config
  18. else
  19. PATH='$(HOST_PATH)' sed -e 's^KERNEL_HEADERS.*$$KERNEL_HEADERS=\"${STAGING_TARGET_DIR}/usr/include\"' \
  20. $(ADK_TOPDIR)/target/$(ADK_TARGET_ARCH)/uclibc.config >${WRKBUILD}/.config
  21. endif
  22. ifeq ($(ADK_TARGET_ENDIAN),little)
  23. $(SED) 's/.*\(ARCH_LITTLE_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  24. $(SED) 's/.*\(ARCH_WANTS_LITTLE_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  25. $(SED) 's/.*\(ARCH_BIG_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  26. $(SED) 's/.*\(ARCH_WANTS_BIG_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  27. else
  28. $(SED) 's/.*\(ARCH_BIG_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  29. $(SED) 's/.*\(ARCH_WANTS_BIG_ENDIAN\).*/\1=y/' ${WRKBUILD}/.config
  30. $(SED) 's/.*\(ARCH_LITTLE_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  31. $(SED) 's/.*\(ARCH_WANTS_LITTLE_ENDIAN\).*/# \1 is not set/' ${WRKBUILD}/.config
  32. endif
  33. ifeq ($(ADK_LINUX_64),y)
  34. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS64\).*/\1=y/' ${WRKBUILD}/.config
  35. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32\).*/# \1 is not set/' ${WRKBUILD}/.config
  36. else
  37. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS32\).*/\1=y/' ${WRKBUILD}/.config
  38. $(SED) 's/.*\(CONFIG_MIPS_ISA_MIPS64\).*/# \1 is not set/' ${WRKBUILD}/.config
  39. endif
  40. ifeq ($(ADK_n64),y)
  41. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/\1=y/' ${WRKBUILD}/.config
  42. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  43. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  44. endif
  45. ifeq ($(ADK_n32),y)
  46. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/\1=y/' ${WRKBUILD}/.config
  47. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  48. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  49. endif
  50. ifeq ($(ADK_o32),y)
  51. $(SED) 's/.*\(CONFIG_MIPS_O32_ABI\).*/\1=y/' ${WRKBUILD}/.config
  52. $(SED) 's/.*\(CONFIG_MIPS_N32_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  53. $(SED) 's/.*\(CONFIG_MIPS_N64_ABI\).*/# \1 is not set/' ${WRKBUILD}/.config
  54. endif
  55. ifneq ($(ADK_PACKAGE_GDB),)
  56. $(SED) "s/.*\(PTHREADS_DEBUG_SUPPORT\).*/\1=y/" ${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. ifeq ($(ADK_TARGET_USE_SSP),y)
  62. $(SED) 's,.*UCLIBC_HAS_SSP,UCLIBC_HAS_SSP=y,' ${WRKBUILD}/.config
  63. echo "UCLIBC_HAS_SSP_COMPAT=n" >> ${WRKBUILD}/.config
  64. echo "SSP_QUICK_CANARY=n" >> ${WRKBUILD}/.config
  65. echo "UCLIBC_BUILD_SSP=y" >> ${WRKBUILD}/.config
  66. endif
  67. echo N|PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  68. PREFIX=$(STAGING_TARGET_DIR) \
  69. DEVEL_PREFIX=/usr/ \
  70. RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
  71. HOSTCC="$(HOST_CC)" \
  72. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  73. oldconfig
  74. PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  75. PREFIX=$(STAGING_TARGET_DIR) \
  76. DEVEL_PREFIX=/usr/ \
  77. RUNTIME_PREFIX=$(STAGING_TARGET_DIR) \
  78. HOSTCC="$(HOST_CC)" \
  79. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  80. install_headers
  81. touch $(WRKBUILD)/.configured
  82. touch $@
  83. $(WRKBUILD)/.compiled:
  84. PATH='$(HOST_PATH)' $(MAKE) ${UCLIBC_MAKEOPTS} -C $(WRKBUILD) \
  85. PREFIX= \
  86. DEVEL_PREFIX=/ \
  87. RUNTIME_PREFIX=/ \
  88. HOSTCC="$(HOST_CC)" \
  89. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  90. all
  91. touch $@
  92. $(WRKBUILD)/.install_headers: $(WRKBUILD)/.compiled
  93. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  94. PREFIX=$(STAGING_TARGET_DIR) \
  95. DEVEL_PREFIX=/usr/ \
  96. DEVEL_PREFIX_LIB=/ \
  97. RUNTIME_PREFIX=/ \
  98. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  99. install_dev
  100. touch $@
  101. $(WRKBUILD)/.installed: $(WRKBUILD)/.install_headers
  102. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  103. PREFIX=$(STAGING_TARGET_DIR) \
  104. DEVEL_PREFIX=/usr/ \
  105. DEVEL_PREFIX_LIB=/ \
  106. RUNTIME_PREFIX=/ \
  107. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  108. install_runtime
  109. touch $@
  110. $(WRKBUILD)/.fixup:
  111. ifeq ($(ADK_UCLIBC_TEST),y)
  112. PATH='$(HOST_PATH)' $(MAKE) -C $(WRKBUILD) \
  113. TEST_INSTALLED_UCLIBC=1 \
  114. UCLIBC_ONLY=1 \
  115. CPU_CFLAGS="$(TARGET_CFLAGS)" \
  116. test_compile
  117. endif
  118. ifeq ($(ADK_TARGET_TOOLCHAIN),y)
  119. # cleanup toolchain
  120. -find $(STAGING_TARGET_DIR) $(STAGING_HOST_DIR) -name \*.la -exec {} \;
  121. # strip target libs and host tools for toolchain builds
  122. PATH="$(TARGET_PATH)" debug='0' prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh \
  123. $(STAGING_TARGET_DIR) $(TOOLCHAIN_DIR)/usr/lib/gcc/$(GNU_TARGET_NAME)
  124. debug='0' prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh $(TOOLCHAIN_DIR)/usr/bin
  125. endif
  126. touch $@
  127. include ${ADK_TOPDIR}/mk/toolchain.mk