Makefile 7.1 KB

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