Makefile 6.8 KB

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