Makefile 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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=$(TOOLCHAIN_DIR)/usr \
  8. --with-bugurl="http://www.openadk.org/" \
  9. --build=$(GNU_HOST_NAME) \
  10. --host=$(GNU_HOST_NAME) \
  11. --target=$(GNU_TARGET_NAME) \
  12. --with-gmp=$(STAGING_HOST_DIR)/usr \
  13. --with-mpfr=$(STAGING_HOST_DIR)/usr \
  14. --with-libelf=$(STAGING_HOST_DIR)/usr \
  15. --disable-__cxa_atexit \
  16. --with-gnu-ld \
  17. --with-gnu-as \
  18. --enable-tls \
  19. --disable-libsanitizer \
  20. --disable-libitm \
  21. --disable-libmudflap \
  22. --disable-libgomp \
  23. --disable-decimal-float \
  24. --disable-libstdcxx-pch \
  25. --disable-ppl-version-check \
  26. --disable-cloog-version-check \
  27. --with-system-zlib \
  28. --without-ppl \
  29. --without-cloog \
  30. --without-isl \
  31. --disable-nls
  32. GCC_FINAL_CONFOPTS:=
  33. ifeq ($(ADK_LINUX_SH)$(ADK_LINUX_X86_64)$(ADK_LINUX_X86),)
  34. GCC_FINAL_CONFOPTS+= --disable-biarch --disable-multilib
  35. endif
  36. ifeq ($(ADK_LINUX_SH),y)
  37. ifeq ($(ADK_little),y)
  38. GCC_CONFOPTS+= --with-endian=little
  39. else
  40. GCC_CONFOPTS+= --with-endian=big
  41. endif
  42. GCC_FINAL_CONFOPTS+= --enable-multilib --with-multilib-list=m4,m4-nofpu
  43. endif
  44. ifeq ($(ADK_LINUX_X86),y)
  45. ifeq ($(ADK_TARGET_KERNEL_64),y)
  46. GCC_FINAL_CONFOPTS+= --enable-biarch --enable-targets=all --disable-multilib
  47. else
  48. GCC_FINAL_CONFOPTS+= --disable-biarch --disable-multilib
  49. endif
  50. endif
  51. ifeq ($(ADK_LINUX_X86_64),y)
  52. ifeq ($(ADK_x32),y)
  53. GCC_FINAL_CONFOPTS+= --with-abi=x32
  54. endif
  55. ifeq ($(ADK_64),y)
  56. GCC_FINAL_CONFOPTS+= --disable-biarch --disable-multilib
  57. endif
  58. endif
  59. ifeq ($(ADK_TOOLCHAIN_GCC_SSP),y)
  60. GCC_FINAL_CONFOPTS+= --enable-libssp
  61. else
  62. GCC_FINAL_CONFOPTS+= --disable-libssp
  63. endif
  64. ifeq ($(ADK_TOOLCHAIN_GCC_LTO),y)
  65. GCC_FINAL_CONFOPTS+= --enable-lto
  66. else
  67. GCC_FINAL_CONFOPTS+= --disable-lto
  68. endif
  69. ifeq ($(ADK_LINUX_PPC),y)
  70. ifeq ($(ADK_TARGET_LIBC),uclibc)
  71. GCC_CONFOPTS+= --disable-target-optspace --with-long-double-128 --enable-secureplt
  72. else
  73. GCC_CONFOPTS+= --disable-target-optspace --with-long-double-64 --enable-secureplt
  74. endif
  75. else
  76. GCC_CONFOPTS+= --enable-target-optspace
  77. endif
  78. ifneq ($(ADK_TARGET_MIPS_ABI),)
  79. GCC_CONFOPTS+= --with-abi=${ADK_TARGET_MIPS_ABI}
  80. endif
  81. ifeq (${ADK_MAKE_PARALLEL},y)
  82. GCC_MAKEOPTS+= -j${ADK_MAKE_JOBS}
  83. endif
  84. LANGUAGES:=c
  85. ifeq ($(ADK_TOOLCHAIN_GCC_CXX),y)
  86. LANGUAGES:=${LANGUAGES},c++
  87. endif
  88. include ${TOPDIR}/mk/buildhlp.mk
  89. GCC_BUILD_DIR_MINIMAL:= $(WRKBUILD)-minimal
  90. GCC_BUILD_DIR_INITIAL:= $(WRKBUILD)-initial
  91. GCC_BUILD_DIR_FINAL:= $(WRKBUILD)-final
  92. $(GCC_BUILD_DIR_MINIMAL)/.configured:
  93. mkdir -p $(GCC_BUILD_DIR_MINIMAL)
  94. # these symlinks are very important, do not remove
  95. rm -rf $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)/sys-include
  96. mkdir -p $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)
  97. (cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME); \
  98. ln -s ../$(STAGING_HOST2TARGET)/usr/include sys-include)
  99. rm -rf ${TOOLCHAIN_DIR}/usr/$(GNU_TARGET_NAME)/lib
  100. (cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME); \
  101. ln -s ../$(STAGING_HOST2TARGET)/lib lib)
  102. ifeq ($(ADK_LINUX_SH),y)
  103. (cd ${STAGING_TARGET_DIR}/ && ln -sf . m4 && ln -sf . m4-nofpu)
  104. endif
  105. $(SED) '/k prot/agcc_cv_libc_provides_ssp=yes' $(WRKBUILD)/gcc/configure
  106. cd $(GCC_BUILD_DIR_MINIMAL); \
  107. PATH='$(TARGET_PATH)' \
  108. CFLAGS="-O0 -g0" \
  109. CXXFLAGS="-O0 -g0" \
  110. $(WRKBUILD)/configure \
  111. ${GCC_CONFOPTS} \
  112. --enable-languages=c \
  113. --disable-multilib \
  114. --disable-lto \
  115. --disable-libssp \
  116. --disable-shared \
  117. --without-headers
  118. touch $@
  119. $(GCC_BUILD_DIR_MINIMAL)/.compiled: $(GCC_BUILD_DIR_MINIMAL)/.configured
  120. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_MINIMAL) all-gcc
  121. touch $@
  122. $(WRKBUILD)/.headers: $(GCC_BUILD_DIR_MINIMAL)/.compiled
  123. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_MINIMAL) install-gcc
  124. touch $@
  125. $(GCC_BUILD_DIR_INITIAL)/.configured:
  126. mkdir -p $(GCC_BUILD_DIR_INITIAL)
  127. cd $(GCC_BUILD_DIR_INITIAL); \
  128. PATH='$(TARGET_PATH)' \
  129. CFLAGS="-O0 -g0" \
  130. CXXFLAGS="-O0 -g0" \
  131. $(WRKBUILD)/configure \
  132. ${GCC_CONFOPTS} \
  133. ${GCC_FINAL_CONFOPTS} \
  134. --enable-languages=c \
  135. --disable-shared \
  136. --disable-threads \
  137. --with-sysroot=$(STAGING_TARGET_DIR)
  138. touch $@
  139. $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
  140. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc all-target-libgcc
  141. touch $@
  142. $(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
  143. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
  144. touch $@
  145. $(GCC_BUILD_DIR_FINAL)/.configured:
  146. mkdir -p $(GCC_BUILD_DIR_FINAL)
  147. cd $(GCC_BUILD_DIR_FINAL); \
  148. PATH='$(TARGET_PATH)' \
  149. $(WRKBUILD)/configure \
  150. ${GCC_CONFOPTS} \
  151. ${GCC_FINAL_CONFOPTS} \
  152. --enable-languages=$(LANGUAGES) \
  153. --with-build-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  154. --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  155. --enable-shared
  156. touch $@
  157. $(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured
  158. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_FINAL) all
  159. touch $@
  160. $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
  161. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_FINAL) install
  162. # remove duplicate tools, convert hardlinks to symlinks
  163. set -e; \
  164. cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)/bin; \
  165. for app in ar as c++ g++ gcc ld ld.gold ld.bfd nm objcopy objdump ranlib strip; do \
  166. ln -sf ../../bin/$(GNU_TARGET_NAME)-$${app} $${app}; \
  167. done;
  168. (cd $(TOOLCHAIN_DIR)/usr/bin && \
  169. ln -sf $(GNU_TARGET_NAME)-gcc $(GNU_TARGET_NAME)-gcc-${PKG_VERSION})
  170. ifeq ($(ADK_TOOLCHAIN_USE_GOLD),y)
  171. (cd $(TOOLCHAIN_DIR)/usr/bin && \
  172. ln -sf $(GNU_TARGET_NAME)-ld.gold $(GNU_TARGET_NAME)-ld)
  173. else
  174. (cd $(TOOLCHAIN_DIR)/usr/bin && \
  175. ln -sf $(GNU_TARGET_NAME)-ld.bfd $(GNU_TARGET_NAME)-ld)
  176. endif
  177. cd $(STAGING_TARGET_DIR)/lib && \
  178. ln -sf libstdc++.so.6.0.18 libstdc++.so && \
  179. ln -sf libstdc++.so.6.0.18 libstdc++.so.6
  180. # cleanup unneeded docs
  181. rm -rf $(TOOLCHAIN_DIR)/usr/share
  182. touch $@
  183. include ${TOPDIR}/mk/toolchain.mk