Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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-libmudflap \
  17. --disable-libgomp \
  18. --disable-biarch \
  19. --disable-decimal-float \
  20. --disable-multilib \
  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. ifeq ($(ADK_LINUX_MIPS64),y)
  52. GCC_CONFOPTS+= --with-abi=64
  53. endif
  54. ifeq ($(ADK_LINUX_MIPS64EL),y)
  55. GCC_CONFOPTS+= --with-abi=64
  56. endif
  57. ifeq (${ADK_MAKE_PARALLEL},y)
  58. GCC_MAKEOPTS+= -j${ADK_MAKE_JOBS}
  59. endif
  60. LANGUAGES:=c
  61. ifeq ($(ADK_TOOLCHAIN_GCC_CXX),y)
  62. LANGUAGES:=${LANGUAGES},c++
  63. endif
  64. ifeq ($(ADK_TOOLCHAIN_GCC_JAVA),y)
  65. LANGUAGES:=${LANGUAGES},java
  66. GCC_CONFOPTS+= --enable-java-home
  67. endif
  68. ifeq ($(ADK_TOOLCHAIN_GCC_ADA),y)
  69. LANGUAGES:=${LANGUAGES},ada
  70. endif
  71. include ${TOPDIR}/mk/buildhlp.mk
  72. GCC_BUILD_DIR_MINIMAL:= $(WRKBUILD)-minimal
  73. GCC_BUILD_DIR_INITIAL:= $(WRKBUILD)-initial
  74. GCC_BUILD_DIR_FINAL:= $(WRKBUILD)-final
  75. $(GCC_BUILD_DIR_MINIMAL)/.configured:
  76. mkdir -p $(GCC_BUILD_DIR_MINIMAL)
  77. # these symlinks are very important, do not remove
  78. rm -rf $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  79. ln -sf ${STAGING_TARGET_DIR}/include $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  80. rm -rf ${STAGING_HOST_DIR}/$(REAL_GNU_TARGET_NAME)/lib
  81. ln -sf ${STAGING_TARGET_DIR}/lib $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  82. (cd $(GCC_BUILD_DIR_MINIMAL); \
  83. PATH='$(TARGET_PATH)' \
  84. $(WRKBUILD)/configure \
  85. ${GCC_CONFOPTS} \
  86. --enable-languages=c \
  87. --disable-shared \
  88. --with-newlib \
  89. --without-headers \
  90. );
  91. touch $@
  92. $(GCC_BUILD_DIR_MINIMAL)/.compiled: $(GCC_BUILD_DIR_MINIMAL)/.configured
  93. PATH='$(TARGET_PATH)' \
  94. $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_MINIMAL) all-gcc
  95. touch $@
  96. $(WRKBUILD)/.headers: $(GCC_BUILD_DIR_MINIMAL)/.compiled
  97. PATH='$(TARGET_PATH)' \
  98. $(MAKE) -C $(GCC_BUILD_DIR_MINIMAL) install-gcc
  99. touch $@
  100. $(GCC_BUILD_DIR_INITIAL)/.configured:
  101. mkdir -p $(GCC_BUILD_DIR_INITIAL)
  102. (cd $(GCC_BUILD_DIR_INITIAL); \
  103. PATH='$(TARGET_PATH)' \
  104. $(WRKBUILD)/configure \
  105. ${GCC_CONFOPTS} \
  106. --enable-languages=c \
  107. --disable-shared \
  108. --disable-threads \
  109. --with-newlib \
  110. --with-sysroot=$(STAGING_TARGET_DIR) \
  111. );
  112. touch $@
  113. $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
  114. PATH='$(TARGET_PATH)' \
  115. $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc all-target-libgcc
  116. touch $@
  117. $(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
  118. PATH='$(TARGET_PATH)' \
  119. $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
  120. touch $@
  121. $(GCC_BUILD_DIR_FINAL)/.configured:
  122. mkdir -p $(GCC_BUILD_DIR_FINAL)
  123. (cd $(GCC_BUILD_DIR_FINAL); \
  124. PATH='$(TARGET_PATH)' \
  125. $(WRKBUILD)/configure \
  126. ${GCC_CONFOPTS} \
  127. --enable-languages=$(LANGUAGES) \
  128. --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  129. --with-slibdir=$(STAGING_TARGET_DIR)/lib \
  130. --enable-shared \
  131. );
  132. touch $@
  133. $(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured
  134. PATH='$(TARGET_PATH)' \
  135. $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_FINAL) all
  136. touch $@
  137. $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
  138. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_FINAL) install
  139. # workaround if you cross-compile binutils
  140. @-rm $(STAGING_TARGET_DIR)/lib/libiberty.a $(STAGING_TARGET_DIR)/usr/lib/libiberty.a
  141. # Set up the symlinks to enable lying about target name.
  142. set -e; \
  143. (cd $(STAGING_HOST_DIR); \
  144. ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
  145. cd bin; \
  146. for app in $(REAL_GNU_TARGET_NAME)-* ; do \
  147. ln -sf $${app} \
  148. $(GNU_TARGET_NAME)$${app##$(REAL_GNU_TARGET_NAME)}; \
  149. done; \
  150. )
  151. touch $@
  152. include ${TOPDIR}/mk/toolchain.mk