Makefile 5.8 KB

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