Makefile 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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_ALPHA)$(ADK_LINUX_XTENSA)$(ADK_LINUX_M68K),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_M68K)$(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. GCC_CONFOPTS+= --with-long-double-64 --enable-secureplt
  88. ifneq ($(ADK_TARGET_CPU_WITH_FPU),y)
  89. GCC_CONFOPTS+= --with-float=soft
  90. endif
  91. endif
  92. ifeq ($(ADK_TARGET_ARCH),arm)
  93. GCC_CONFOPTS+= --with-float=$(ADK_TARGET_FLOAT)
  94. ifneq ($(ADK_TARGET_FPU),)
  95. GCC_CONFOPTS+= --with-fpu=$(ADK_TARGET_FPU)
  96. endif
  97. endif
  98. ifeq ($(ADK_CPU_ARMV5TE),y)
  99. GCC_CONFOPTS+= --with-arch=armv5te
  100. endif
  101. ifeq ($(ADK_CPU_ARMV6),y)
  102. GCC_CONFOPTS+= --with-arch=armv6
  103. endif
  104. ifeq ($(ADK_CPU_ARMV7A),y)
  105. GCC_CONFOPTS+= --with-arch=armv7-a
  106. endif
  107. ifeq ($(ADK_CPU_ARM926EJ_S),y)
  108. GCC_CONFOPTS+= --with-arch=armv5te --with-tune=arm926ej-s
  109. endif
  110. ifeq ($(ADK_CPU_ARM1176JZF_S),y)
  111. GCC_CONFOPTS+= --with-arch=armv6 --with-tune=arm1176jzf-s
  112. endif
  113. ifeq ($(ADK_CPU_CORTEX_A9),y)
  114. GCC_CONFOPTS+= --with-arch=armv7-a --with-tune=cortex-a9
  115. endif
  116. ifeq ($(ADK_CPU_SPARC_V9),y)
  117. GCC_CONFOPTS+= --with-cpu=ultrasparc
  118. endif
  119. ifeq ($(ADK_CPU_CF_5208),y)
  120. GCC_CONFOPTS+= --enable-multilib --with-arch=cf --with-cpu=5208
  121. endif
  122. ifneq ($(ADK_TARGET_MIPS_ABI),)
  123. GCC_CONFOPTS+= --with-abi=${ADK_TARGET_MIPS_ABI}
  124. endif
  125. ifeq (${ADK_MAKE_PARALLEL},y)
  126. GCC_MAKEOPTS+= -j${ADK_MAKE_JOBS}
  127. endif
  128. ifeq ($(ADK_TARGET_UCLINUX),y)
  129. LANGUAGES:=c
  130. else
  131. LANGUAGES:=c,c++
  132. endif
  133. include ${ADK_TOPDIR}/mk/buildhlp.mk
  134. GCC_BUILD_DIR_MINIMAL:= $(WRKBUILD)-minimal
  135. GCC_BUILD_DIR_INITIAL:= $(WRKBUILD)-initial
  136. GCC_BUILD_DIR_FINAL:= $(WRKBUILD)-final
  137. $(GCC_BUILD_DIR_MINIMAL)/.configured:
  138. ifeq ($(ADK_LINUX_XTENSA),y)
  139. tar xf $(ADK_TOPDIR)/target/xtensa/overlay/xtensa_dc232b.tar \
  140. --strip-components=1 -C $(WRKSRC) gcc
  141. endif
  142. mkdir -p $(GCC_BUILD_DIR_MINIMAL)
  143. # these symlinks are very important, do not remove
  144. rm -rf $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)/sys-include
  145. mkdir -p $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)
  146. (cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME); \
  147. ln -s ../$(STAGING_HOST2TARGET)/usr/include sys-include)
  148. rm -rf ${TOOLCHAIN_DIR}/usr/$(GNU_TARGET_NAME)/lib
  149. (cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME); \
  150. ln -s ../$(STAGING_HOST2TARGET)/lib lib)
  151. ifeq ($(ADK_LINUX_SH),y)
  152. (cd ${STAGING_TARGET_DIR}/ && ln -sf . m4 && ln -sf . m4-nofpu)
  153. endif
  154. $(SED) '/k prot/agcc_cv_libc_provides_ssp=yes' $(WRKBUILD)/gcc/configure
  155. cd $(GCC_BUILD_DIR_MINIMAL); \
  156. PATH='$(TARGET_PATH)' \
  157. CFLAGS="-O0 -g0" \
  158. CXXFLAGS="-O0 -g0" \
  159. $(WRKBUILD)/configure \
  160. ${GCC_CONFOPTS} \
  161. --enable-languages=c \
  162. --disable-libssp \
  163. --disable-shared \
  164. --without-headers
  165. touch $@
  166. $(GCC_BUILD_DIR_MINIMAL)/.compiled: $(GCC_BUILD_DIR_MINIMAL)/.configured
  167. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_MINIMAL) all-gcc
  168. touch $@
  169. $(WRKBUILD)/.headers: $(GCC_BUILD_DIR_MINIMAL)/.compiled
  170. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_MINIMAL) install-gcc
  171. touch $@
  172. $(GCC_BUILD_DIR_INITIAL)/.configured:
  173. mkdir -p $(GCC_BUILD_DIR_INITIAL)
  174. cd $(GCC_BUILD_DIR_INITIAL); \
  175. PATH='$(TARGET_PATH)' \
  176. CFLAGS="-O0 -g0" \
  177. CXXFLAGS="-O0 -g0" \
  178. $(WRKBUILD)/configure \
  179. ${GCC_CONFOPTS} \
  180. ${GCC_FINAL_CONFOPTS} \
  181. --enable-languages=c \
  182. --disable-shared \
  183. --disable-threads \
  184. --with-sysroot=$(STAGING_TARGET_DIR)
  185. touch $@
  186. $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
  187. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc all-target-libgcc
  188. touch $@
  189. $(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
  190. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
  191. touch $@
  192. $(GCC_BUILD_DIR_FINAL)/.configured:
  193. mkdir -p $(GCC_BUILD_DIR_FINAL)
  194. cd $(GCC_BUILD_DIR_FINAL); \
  195. PATH='$(TARGET_PATH)' \
  196. $(WRKBUILD)/configure \
  197. ${GCC_CONFOPTS} \
  198. ${GCC_FINAL_CONFOPTS} \
  199. --enable-languages=$(LANGUAGES) \
  200. --with-build-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  201. --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}'
  202. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_FINAL) configure-host
  203. touch $@
  204. $(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured
  205. cd $(GCC_BUILD_DIR_FINAL); \
  206. PATH='$(TARGET_PATH)' \
  207. $(MAKE) ${GCC_MAKEOPTS} all
  208. touch $@
  209. $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
  210. cd $(GCC_BUILD_DIR_FINAL); \
  211. PATH='$(TARGET_PATH)' \
  212. $(MAKE) install
  213. # remove duplicate tools, convert hardlinks to symlinks
  214. set -e; \
  215. cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)/bin; \
  216. for app in ar as c++ g++ gcc ld ld.gold ld.bfd nm objcopy objdump ranlib strip; do \
  217. ln -sf ../../bin/$(GNU_TARGET_NAME)-$${app} $${app}; \
  218. done;
  219. (cd $(TOOLCHAIN_DIR)/usr/bin && \
  220. ln -sf $(GNU_TARGET_NAME)-gcc $(GNU_TARGET_NAME)-gcc-${PKG_VERSION})
  221. ifeq ($(ADK_TARGET_USE_GOLD),y)
  222. (cd $(TOOLCHAIN_DIR)/usr/bin && \
  223. ln -sf $(GNU_TARGET_NAME)-ld.gold $(GNU_TARGET_NAME)-ld)
  224. else
  225. (cd $(TOOLCHAIN_DIR)/usr/bin && \
  226. ln -sf $(GNU_TARGET_NAME)-ld.bfd $(GNU_TARGET_NAME)-ld)
  227. endif
  228. cd $(STAGING_TARGET_DIR)/lib && \
  229. ln -sf libstdc++.so.6.0.19 libstdc++.so && \
  230. ln -sf libstdc++.so.6.0.19 libstdc++.so.6
  231. # cleanup unneeded docs
  232. rm -rf $(TOOLCHAIN_DIR)/usr/share
  233. touch $@
  234. include ${ADK_TOPDIR}/mk/toolchain.mk