Makefile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. include $(TOPDIR)/rules.mk
  4. include ../rules.mk
  5. TARGET_CFLAGS:= $(filter-out -fstack-protector,$(TARGET_CFLAGS))
  6. include Makefile.inc
  7. GCC_CONFOPTS= --prefix=$(STAGING_HOST_DIR) \
  8. --build=$(GNU_HOST_NAME) \
  9. --host=$(GNU_HOST_NAME) \
  10. --target=$(REAL_GNU_TARGET_NAME) \
  11. --with-gmp=$(STAGING_HOST_DIR) \
  12. --with-mpfr=$(STAGING_HOST_DIR) \
  13. --with-libelf=$(STAGING_HOST_DIR) \
  14. --disable-__cxa_atexit \
  15. --with-gnu-ld \
  16. --disable-multilib \
  17. --disable-libmudflap \
  18. --disable-libgomp \
  19. --disable-biarch \
  20. --disable-decimal-float \
  21. --disable-sjlj-exceptions \
  22. --disable-libstdcxx-pch \
  23. --disable-ppl-version-check \
  24. --disable-cloog-version-check \
  25. --without-ppl \
  26. --without-cloog \
  27. --disable-nls
  28. ifeq ($(ADK_TOOLCHAIN_GCC_SSP),y)
  29. GCC_CONFOPTS+= --enable-libssp
  30. else
  31. GCC_CONFOPTS+= --disable-libssp
  32. endif
  33. ifeq ($(ADK_TOOLCHAIN_GCC_LTO),y)
  34. GCC_CONFOPTS+= --enable-lto
  35. else
  36. GCC_CONFOPTS+= --disable-lto
  37. endif
  38. ifeq ($(ARCH),cris)
  39. GCC_CONFOPTS+= --disable-tls
  40. else
  41. GCC_CONFOPTS+= --enable-tls
  42. endif
  43. ifeq ($(ARCH),powerpc)
  44. GCC_CONFOPTS+= --disable-target-optspace
  45. else
  46. GCC_CONFOPTS+= --enable-target-optspace
  47. endif
  48. ifeq ($(ADK_TARGET_NO_FPU),y)
  49. GCC_CONFOPTS+= --with-float=soft
  50. endif
  51. ifneq ($(ADK_TARGET_ABI),)
  52. GCC_CONFOPTS+= --with-abi=${ADK_TARGET_ABI}
  53. endif
  54. ifeq (${ADK_MAKE_PARALLEL},y)
  55. GCC_MAKEOPTS+= -j${ADK_MAKE_JOBS}
  56. endif
  57. LANGUAGES:=c
  58. ifeq ($(ADK_TOOLCHAIN_GCC_CXX),y)
  59. LANGUAGES:=${LANGUAGES},c++
  60. endif
  61. ifeq ($(ADK_TOOLCHAIN_GCC_JAVA),y)
  62. LANGUAGES:=${LANGUAGES},java
  63. GCC_CONFOPTS+= --enable-java-home
  64. endif
  65. ifeq ($(ADK_TOOLCHAIN_GCC_ADA),y)
  66. LANGUAGES:=${LANGUAGES},ada
  67. endif
  68. include ${TOPDIR}/mk/buildhlp.mk
  69. GCC_BUILD_DIR_MINIMAL:= $(WRKBUILD)-minimal
  70. GCC_BUILD_DIR_INITIAL:= $(WRKBUILD)-initial
  71. GCC_BUILD_DIR_FINAL:= $(WRKBUILD)-final
  72. $(GCC_BUILD_DIR_MINIMAL)/.configured:
  73. mkdir -p $(GCC_BUILD_DIR_MINIMAL)
  74. # these symlinks are very important, do not remove
  75. rm -rf $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  76. ln -sf ${STAGING_TARGET_DIR}/include $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  77. rm -rf ${STAGING_HOST_DIR}/$(REAL_GNU_TARGET_NAME)/lib
  78. ln -sf ${STAGING_TARGET_DIR}/lib $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  79. cd $(GCC_BUILD_DIR_MINIMAL); PATH='$(TARGET_PATH)' \
  80. $(WRKBUILD)/configure \
  81. ${GCC_CONFOPTS} \
  82. --enable-languages=c \
  83. --disable-shared \
  84. --with-newlib \
  85. --without-headers
  86. touch $@
  87. $(GCC_BUILD_DIR_MINIMAL)/.compiled: $(GCC_BUILD_DIR_MINIMAL)/.configured
  88. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_MINIMAL) all-gcc
  89. touch $@
  90. $(WRKBUILD)/.headers: $(GCC_BUILD_DIR_MINIMAL)/.compiled
  91. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_MINIMAL) install-gcc
  92. touch $@
  93. $(GCC_BUILD_DIR_INITIAL)/.configured:
  94. mkdir -p $(GCC_BUILD_DIR_INITIAL)
  95. cd $(GCC_BUILD_DIR_INITIAL); PATH='$(TARGET_PATH)' \
  96. $(WRKBUILD)/configure \
  97. ${GCC_CONFOPTS} \
  98. --enable-languages=c \
  99. --disable-shared \
  100. --disable-threads \
  101. --with-newlib \
  102. --with-sysroot=$(STAGING_TARGET_DIR)
  103. touch $@
  104. $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
  105. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc all-target-libgcc
  106. touch $@
  107. $(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
  108. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
  109. # -lgcc_eh workaround
  110. (cd $(STAGING_HOST_DIR)/lib/gcc/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION) && ln -sf libgcc.a libgcc_eh.a)
  111. touch $@
  112. $(GCC_BUILD_DIR_FINAL)/.configured:
  113. mkdir -p $(GCC_BUILD_DIR_FINAL)
  114. cd $(GCC_BUILD_DIR_FINAL); PATH='$(TARGET_PATH)' \
  115. $(WRKBUILD)/configure \
  116. ${GCC_CONFOPTS} \
  117. --enable-languages=$(LANGUAGES) \
  118. --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  119. --with-slibdir=$(STAGING_TARGET_DIR)/lib \
  120. --enable-shared
  121. touch $@
  122. $(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured
  123. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_FINAL) all
  124. touch $@
  125. $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
  126. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_FINAL) install
  127. # workaround if you cross-compile binutils
  128. @-rm $(STAGING_TARGET_DIR)/lib/libiberty.a $(STAGING_TARGET_DIR)/usr/lib/libiberty.a
  129. # Set up the symlinks to enable lying about target name.
  130. set -e; \
  131. cd $(STAGING_HOST_DIR); \
  132. ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
  133. cd bin; \
  134. for app in $(REAL_GNU_TARGET_NAME)-* ; do \
  135. ln -sf $${app} \
  136. $(GNU_TARGET_NAME)$${app##$(REAL_GNU_TARGET_NAME)}; \
  137. done;
  138. # workaround for openjdk
  139. cd $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/bin ; cp * ..
  140. touch $@
  141. include ${TOPDIR}/mk/toolchain.mk