Makefile 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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-decimal-float \
  19. --disable-libstdcxx-pch \
  20. --disable-ppl-version-check \
  21. --disable-cloog-version-check \
  22. --without-ppl \
  23. --without-cloog \
  24. --disable-nls
  25. ifeq ($(ADK_TOOLCHAIN_GCC_SJLJ),y)
  26. GCC_CONFOPTS+= --enable-sjlj-exceptions
  27. else
  28. GCC_CONFOPTS+= --disable-sjlj-exceptions
  29. endif
  30. ifeq ($(ADK_LINUX_SH),y)
  31. GCC_CONFOPTS+= --with-multilib-list=m4,m4-nofpu
  32. else
  33. GCC_CONFOPTS+= --disable-biarch \
  34. --disable-multilib
  35. endif
  36. ifeq ($(ADK_TOOLCHAIN_GCC_SSP),y)
  37. GCC_CONFOPTS+= --enable-libssp
  38. else
  39. GCC_CONFOPTS+= --disable-libssp
  40. endif
  41. ifeq ($(ADK_TOOLCHAIN_GCC_LTO),y)
  42. GCC_CONFOPTS+= --enable-lto
  43. else
  44. GCC_CONFOPTS+= --disable-lto
  45. endif
  46. ifeq ($(ARCH),cris)
  47. GCC_CONFOPTS+= --disable-tls
  48. else
  49. GCC_CONFOPTS+= --enable-tls
  50. endif
  51. ifeq ($(ARCH),powerpc)
  52. ifeq ($(ADK_TARGET_LIBC),musl)
  53. GCC_CONFOPTS+= --disable-target-optspace --with-long-double-64 --enable-secureplt
  54. else
  55. GCC_CONFOPTS+= --disable-target-optspace --with-long-double-128 --enable-secureplt
  56. endif
  57. else
  58. GCC_CONFOPTS+= --enable-target-optspace
  59. endif
  60. ifeq ($(ARCH),mips)
  61. ifeq ($(ADK_TARGET_NO_FPU),y)
  62. GCC_CONFOPTS+= --with-float=soft
  63. else
  64. GCC_CONFOPTS+= --with-float=hard
  65. endif
  66. endif
  67. ifeq ($(ADK_TARGET_SYSTEM_RASPBERRY_PI),y)
  68. GCC_CONFOPTS+= --with-arch=armv6 --with-fpu=vfp --with-float=hard
  69. endif
  70. ifneq ($(ADK_TARGET_ABI),)
  71. GCC_CONFOPTS+= --with-abi=${ADK_TARGET_ABI}
  72. endif
  73. ifeq (${ADK_MAKE_PARALLEL},y)
  74. GCC_MAKEOPTS+= -j${ADK_MAKE_JOBS}
  75. endif
  76. LANGUAGES:=c
  77. ifeq ($(ADK_TOOLCHAIN_GCC_CXX),y)
  78. LANGUAGES:=${LANGUAGES},c++
  79. endif
  80. ifeq ($(ADK_TOOLCHAIN_GCC_JAVA),y)
  81. LANGUAGES:=${LANGUAGES},java
  82. GCC_CONFOPTS+= --enable-java-home
  83. endif
  84. ifeq ($(ADK_TOOLCHAIN_GCC_ADA),y)
  85. LANGUAGES:=${LANGUAGES},ada
  86. endif
  87. include ${TOPDIR}/mk/buildhlp.mk
  88. GCC_BUILD_DIR_MINIMAL:= $(WRKBUILD)-minimal
  89. GCC_BUILD_DIR_INITIAL:= $(WRKBUILD)-initial
  90. GCC_BUILD_DIR_FINAL:= $(WRKBUILD)-final
  91. $(GCC_BUILD_DIR_MINIMAL)/.configured:
  92. mkdir -p $(GCC_BUILD_DIR_MINIMAL)
  93. # these symlinks are very important, do not remove
  94. rm -rf $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  95. ln -sf ${STAGING_TARGET_DIR}/include $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  96. rm -rf ${STAGING_HOST_DIR}/$(REAL_GNU_TARGET_NAME)/lib
  97. ln -sf ${STAGING_TARGET_DIR}/lib $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  98. ifeq ($(ADK_LINUX_SH),y)
  99. (cd ${STAGING_TARGET_DIR}/ && ln -sf . m4 && ln -sf . m4-nofpu)
  100. endif
  101. sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' $(WRKBUILD)/gcc/configure
  102. cd $(GCC_BUILD_DIR_MINIMAL); PATH='$(TARGET_PATH)' \
  103. $(WRKBUILD)/configure \
  104. ${GCC_CONFOPTS} \
  105. --enable-languages=c \
  106. --disable-shared \
  107. --with-newlib \
  108. --without-headers
  109. touch $@
  110. $(GCC_BUILD_DIR_MINIMAL)/.compiled: $(GCC_BUILD_DIR_MINIMAL)/.configured
  111. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_MINIMAL) all-gcc
  112. touch $@
  113. $(WRKBUILD)/.headers: $(GCC_BUILD_DIR_MINIMAL)/.compiled
  114. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_MINIMAL) install-gcc
  115. touch $@
  116. $(GCC_BUILD_DIR_INITIAL)/.configured:
  117. mkdir -p $(GCC_BUILD_DIR_INITIAL)
  118. cd $(GCC_BUILD_DIR_INITIAL); PATH='$(TARGET_PATH)' \
  119. $(WRKBUILD)/configure \
  120. ${GCC_CONFOPTS} \
  121. --enable-languages=c \
  122. --disable-shared \
  123. --disable-threads \
  124. --with-newlib \
  125. --with-sysroot=$(STAGING_TARGET_DIR)
  126. touch $@
  127. $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
  128. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc all-target-libgcc
  129. touch $@
  130. $(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
  131. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
  132. touch $@
  133. $(GCC_BUILD_DIR_FINAL)/.configured:
  134. mkdir -p $(GCC_BUILD_DIR_FINAL)
  135. cd $(GCC_BUILD_DIR_FINAL); PATH='$(TARGET_PATH)' \
  136. $(WRKBUILD)/configure \
  137. ${GCC_CONFOPTS} \
  138. --enable-languages=$(LANGUAGES) \
  139. --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  140. --enable-shared
  141. touch $@
  142. $(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured
  143. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_FINAL) all
  144. touch $@
  145. $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
  146. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_FINAL) install
  147. # workaround if you cross-compile binutils
  148. @-rm $(STAGING_TARGET_DIR)/lib/libiberty.a $(STAGING_TARGET_DIR)/usr/lib/libiberty.a
  149. # Set up the symlinks to enable lying about target name.
  150. set -e; \
  151. cd $(STAGING_HOST_DIR); \
  152. ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
  153. cd bin; \
  154. for app in $(REAL_GNU_TARGET_NAME)-* ; do \
  155. ln -sf $${app} \
  156. $(GNU_TARGET_NAME)$${app##$(REAL_GNU_TARGET_NAME)}; \
  157. done;
  158. # workaround for openjdk
  159. cd $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/bin ; cp * ..
  160. touch $@
  161. include ${TOPDIR}/mk/toolchain.mk