Makefile 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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_WITH_SSP),y)
  60. GCC_FINAL_CONFOPTS+= --enable-libssp
  61. else
  62. GCC_FINAL_CONFOPTS+= --disable-libssp
  63. endif
  64. ifeq ($(ADK_TOOLCHAIN_WITH_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. ifeq ($(ARCH),arm)
  79. GCC_CONFOPTS+= --with-float=$(ADK_TARGET_FLOAT)
  80. ifneq ($(ADK_TARGET_FPU),)
  81. GCC_CONFOPTS+= --with-fpu=$(ADK_TARGET_FPU)
  82. endif
  83. endif
  84. ifeq ($(ADK_CPU_ARM926EJ_S),y)
  85. GCC_CONFOPTS+= --with-arch=armv5te --with-tune=arm1176jzf-s
  86. endif
  87. ifeq ($(ADK_CPU_ARM1176JZF_S),y)
  88. GCC_CONFOPTS+= --with-arch=armv6 --with-tune=arm1176jzf-s
  89. endif
  90. ifeq ($(ADK_CPU_CORTEX_A9),y)
  91. GCC_CONFOPTS+= --with-arch=armv7-a --with-tune=cortex-a9
  92. endif
  93. ifeq ($(ADK_CPU_SPARC_V9),y)
  94. GCC_CONFOPTS+= --with-cpu=ultrasparc
  95. endif
  96. ifneq ($(ADK_TARGET_MIPS_ABI),)
  97. GCC_CONFOPTS+= --with-abi=${ADK_TARGET_MIPS_ABI}
  98. endif
  99. ifeq (${ADK_MAKE_PARALLEL},y)
  100. GCC_MAKEOPTS+= -j${ADK_MAKE_JOBS}
  101. endif
  102. LANGUAGES:=c,c++
  103. include ${TOPDIR}/mk/buildhlp.mk
  104. GCC_BUILD_DIR_MINIMAL:= $(WRKBUILD)-minimal
  105. GCC_BUILD_DIR_INITIAL:= $(WRKBUILD)-initial
  106. GCC_BUILD_DIR_FINAL:= $(WRKBUILD)-final
  107. $(GCC_BUILD_DIR_MINIMAL)/.configured:
  108. mkdir -p $(GCC_BUILD_DIR_MINIMAL)
  109. # these symlinks are very important, do not remove
  110. rm -rf $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)/sys-include
  111. mkdir -p $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)
  112. (cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME); \
  113. ln -s ../$(STAGING_HOST2TARGET)/usr/include sys-include)
  114. rm -rf ${TOOLCHAIN_DIR}/usr/$(GNU_TARGET_NAME)/lib
  115. (cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME); \
  116. ln -s ../$(STAGING_HOST2TARGET)/lib lib)
  117. ifeq ($(ADK_LINUX_SH),y)
  118. (cd ${STAGING_TARGET_DIR}/ && ln -sf . m4 && ln -sf . m4-nofpu)
  119. endif
  120. $(SED) '/k prot/agcc_cv_libc_provides_ssp=yes' $(WRKBUILD)/gcc/configure
  121. cd $(GCC_BUILD_DIR_MINIMAL); \
  122. PATH='$(TARGET_PATH)' \
  123. CFLAGS="-O0 -g0" \
  124. CXXFLAGS="-O0 -g0" \
  125. $(WRKBUILD)/configure \
  126. ${GCC_CONFOPTS} \
  127. --enable-languages=c \
  128. --disable-multilib \
  129. --disable-lto \
  130. --disable-libssp \
  131. --disable-shared \
  132. --without-headers
  133. touch $@
  134. $(GCC_BUILD_DIR_MINIMAL)/.compiled: $(GCC_BUILD_DIR_MINIMAL)/.configured
  135. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_MINIMAL) all-gcc
  136. touch $@
  137. $(WRKBUILD)/.headers: $(GCC_BUILD_DIR_MINIMAL)/.compiled
  138. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_MINIMAL) install-gcc
  139. touch $@
  140. $(GCC_BUILD_DIR_INITIAL)/.configured:
  141. mkdir -p $(GCC_BUILD_DIR_INITIAL)
  142. cd $(GCC_BUILD_DIR_INITIAL); \
  143. PATH='$(TARGET_PATH)' \
  144. CFLAGS="-O0 -g0" \
  145. CXXFLAGS="-O0 -g0" \
  146. $(WRKBUILD)/configure \
  147. ${GCC_CONFOPTS} \
  148. ${GCC_FINAL_CONFOPTS} \
  149. --enable-languages=c \
  150. --disable-shared \
  151. --disable-threads \
  152. --with-sysroot=$(STAGING_TARGET_DIR)
  153. touch $@
  154. $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
  155. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc all-target-libgcc
  156. touch $@
  157. $(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
  158. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
  159. touch $@
  160. $(GCC_BUILD_DIR_FINAL)/.configured:
  161. mkdir -p $(GCC_BUILD_DIR_FINAL)
  162. cd $(GCC_BUILD_DIR_FINAL); \
  163. PATH='$(TARGET_PATH)' \
  164. $(WRKBUILD)/configure \
  165. ${GCC_CONFOPTS} \
  166. ${GCC_FINAL_CONFOPTS} \
  167. --enable-languages=$(LANGUAGES) \
  168. --with-build-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  169. --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  170. --enable-shared='libstdc++' \
  171. --enable-cxx-flags='$(TARGET_CXXFLAGS)'
  172. touch $@
  173. $(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured
  174. cd $(GCC_BUILD_DIR_FINAL); \
  175. PATH='$(TARGET_PATH)' \
  176. $(MAKE) ${GCC_MAKEOPTS} all
  177. touch $@
  178. $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
  179. cd $(GCC_BUILD_DIR_FINAL); \
  180. PATH='$(TARGET_PATH)' \
  181. $(MAKE) install
  182. # remove duplicate tools, convert hardlinks to symlinks
  183. set -e; \
  184. cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)/bin; \
  185. for app in ar as c++ g++ gcc ld ld.gold ld.bfd nm objcopy objdump ranlib strip; do \
  186. ln -sf ../../bin/$(GNU_TARGET_NAME)-$${app} $${app}; \
  187. done;
  188. (cd $(TOOLCHAIN_DIR)/usr/bin && \
  189. ln -sf $(GNU_TARGET_NAME)-gcc $(GNU_TARGET_NAME)-gcc-${PKG_VERSION})
  190. ifeq ($(ADK_TARGET_USE_GOLD),y)
  191. (cd $(TOOLCHAIN_DIR)/usr/bin && \
  192. ln -sf $(GNU_TARGET_NAME)-ld.gold $(GNU_TARGET_NAME)-ld)
  193. else
  194. (cd $(TOOLCHAIN_DIR)/usr/bin && \
  195. ln -sf $(GNU_TARGET_NAME)-ld.bfd $(GNU_TARGET_NAME)-ld)
  196. endif
  197. cd $(STAGING_TARGET_DIR)/lib && \
  198. ln -sf libstdc++.so.6.0.18 libstdc++.so && \
  199. ln -sf libstdc++.so.6.0.18 libstdc++.so.6
  200. # cleanup unneeded docs
  201. rm -rf $(TOOLCHAIN_DIR)/usr/share
  202. touch $@
  203. include ${TOPDIR}/mk/toolchain.mk