Makefile 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. --without-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),)
  34. GCC_FINAL_CONFOPTS+= --disable-biarch --disable-multilib
  35. endif
  36. ifeq ($(ADK_LINUX_SH),y)
  37. GCC_FINAL_CONFOPTS+= --enable-multilib --with-multilib-list=m4,m4-nofpu
  38. endif
  39. ifeq ($(ADK_LINUX_X86_64),y)
  40. ifeq ($(ADK_x32),y)
  41. GCC_FINAL_CONFOPTS+= --enable-multilib --with-multilib-list=mx32
  42. endif
  43. ifeq ($(ADK_32),y)
  44. GCC_FINAL_CONFOPTS+= --enable-multilib --with-multilib-list=m32
  45. endif
  46. ifeq ($(ADK_64),y)
  47. GCC_FINAL_CONFOPTS+= --disable-biarch --disable-multilib
  48. endif
  49. endif
  50. ifeq ($(ADK_TOOLCHAIN_GCC_SSP),y)
  51. GCC_FINAL_CONFOPTS+= --enable-libssp
  52. else
  53. GCC_FINAL_CONFOPTS+= --disable-libssp
  54. endif
  55. ifeq ($(ADK_TOOLCHAIN_GCC_LTO),y)
  56. GCC_FINAL_CONFOPTS+= --enable-lto
  57. else
  58. GCC_FINAL_CONFOPTS+= --disable-lto
  59. endif
  60. ifeq ($(ADK_LINUX_PPC),y)
  61. ifeq ($(ADK_TARGET_LIBC),uclibc)
  62. GCC_CONFOPTS+= --disable-target-optspace --with-long-double-128 --enable-secureplt
  63. else
  64. GCC_CONFOPTS+= --disable-target-optspace --with-long-double-64 --enable-secureplt
  65. endif
  66. else
  67. GCC_CONFOPTS+= --enable-target-optspace
  68. endif
  69. ifeq ($(ARCH),arm)
  70. GCC_CONFOPTS+= --with-float=$(ADK_TARGET_FLOAT)
  71. GCC_CONFOPTS+= --with-mode=$(ADK_TARGET_ARM_MODE)
  72. endif
  73. ifeq ($(ADK_CPU_ARM926EJ_S),y)
  74. GCC_CONFOPTS+= --with-arch=armv5te --with-tune=arm1176jzf-s
  75. endif
  76. ifeq ($(ADK_CPU_ARM1176JZF_S),y)
  77. GCC_CONFOPTS+= --with-arch=armv6 --with-tune=arm1176jzf-s --with-fpu=vfp
  78. endif
  79. ifeq ($(ADK_CPU_CORTEX_A9),y)
  80. GCC_CONFOPTS+= --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=neon
  81. endif
  82. ifeq ($(ADK_CPU_SPARC_V9),y)
  83. GCC_CONFOPTS+= --with-cpu=ultrasparc
  84. endif
  85. ifneq ($(ADK_TARGET_MIPS_ABI),)
  86. GCC_CONFOPTS+= --with-abi=${ADK_TARGET_MIPS_ABI}
  87. endif
  88. ifeq (${ADK_MAKE_PARALLEL},y)
  89. GCC_MAKEOPTS+= -j${ADK_MAKE_JOBS}
  90. endif
  91. LANGUAGES:=c
  92. ifeq ($(ADK_TOOLCHAIN_GCC_CXX),y)
  93. LANGUAGES:=${LANGUAGES},c++
  94. endif
  95. include ${TOPDIR}/mk/buildhlp.mk
  96. GCC_BUILD_DIR_MINIMAL:= $(WRKBUILD)-minimal
  97. GCC_BUILD_DIR_INITIAL:= $(WRKBUILD)-initial
  98. GCC_BUILD_DIR_FINAL:= $(WRKBUILD)-final
  99. $(GCC_BUILD_DIR_MINIMAL)/.configured:
  100. mkdir -p $(GCC_BUILD_DIR_MINIMAL)
  101. # these symlinks are very important, do not remove
  102. rm -rf $(TOOLCHAIN_DIR)/$(GNU_TARGET_NAME)/sys-include
  103. ln -sf ${STAGING_TARGET_DIR}/usr/include \
  104. $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)/sys-include
  105. rm -rf ${TOOLCHAIN_DIR}/usr/$(GNU_TARGET_NAME)/lib
  106. ln -sf ${STAGING_TARGET_DIR}/lib $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)/lib
  107. ifeq ($(ADK_LINUX_SH),y)
  108. (cd ${STAGING_TARGET_DIR}/ && ln -sf . m4 && ln -sf . m4-nofpu)
  109. endif
  110. $(SED) '/k prot/agcc_cv_libc_provides_ssp=yes' $(WRKBUILD)/gcc/configure
  111. cd $(GCC_BUILD_DIR_MINIMAL); \
  112. PATH='$(TARGET_PATH)' \
  113. CFLAGS="-O0 -g0" \
  114. CXXFLAGS="-O0 -g0" \
  115. $(WRKBUILD)/configure \
  116. ${GCC_CONFOPTS} \
  117. --enable-languages=c \
  118. --disable-multilib \
  119. --disable-lto \
  120. --disable-libssp \
  121. --disable-shared \
  122. --without-headers
  123. touch $@
  124. $(GCC_BUILD_DIR_MINIMAL)/.compiled: $(GCC_BUILD_DIR_MINIMAL)/.configured
  125. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_MINIMAL) all-gcc
  126. touch $@
  127. $(WRKBUILD)/.headers: $(GCC_BUILD_DIR_MINIMAL)/.compiled
  128. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_MINIMAL) install-gcc
  129. touch $@
  130. $(GCC_BUILD_DIR_INITIAL)/.configured:
  131. mkdir -p $(GCC_BUILD_DIR_INITIAL)
  132. cd $(GCC_BUILD_DIR_INITIAL); \
  133. PATH='$(TARGET_PATH)' \
  134. CFLAGS="-O0 -g0" \
  135. CXXFLAGS="-O0 -g0" \
  136. $(WRKBUILD)/configure \
  137. ${GCC_CONFOPTS} \
  138. ${GCC_FINAL_CONFOPTS} \
  139. --enable-languages=c \
  140. --disable-shared \
  141. --disable-threads \
  142. --with-sysroot=$(STAGING_TARGET_DIR)
  143. touch $@
  144. $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
  145. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc all-target-libgcc
  146. touch $@
  147. $(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
  148. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
  149. touch $@
  150. $(GCC_BUILD_DIR_FINAL)/.configured:
  151. mkdir -p $(GCC_BUILD_DIR_FINAL)
  152. cd $(GCC_BUILD_DIR_FINAL); \
  153. PATH='$(TARGET_PATH)' \
  154. $(WRKBUILD)/configure \
  155. ${GCC_CONFOPTS} \
  156. ${GCC_FINAL_CONFOPTS} \
  157. --enable-languages=$(LANGUAGES) \
  158. --with-build-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  159. --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  160. --enable-shared
  161. touch $@
  162. $(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured
  163. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_FINAL) all
  164. touch $@
  165. $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
  166. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_FINAL) install
  167. # remove duplicate tools, convert hardlinks to symlinks
  168. set -e; \
  169. cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)/bin; \
  170. for app in ar as c++ g++ gcc ld ld.bfd nm objcopy objdump ranlib strip; do \
  171. ln -sf ../../bin/$(GNU_TARGET_NAME)-$${app} $${app}; \
  172. done;
  173. (cd $(TOOLCHAIN_DIR)/usr/bin && \
  174. ln -sf $(GNU_TARGET_NAME)-gcc $(GNU_TARGET_NAME)-gcc-${PKG_VERSION})
  175. @-test -d $(STAGING_TARGET_DIR)/lib32 && \
  176. cd $(STAGING_TARGET_DIR)/lib32 && \
  177. ln -sf libstdc++.so.6.0.18 libstdc++.so && \
  178. ln -sf libstdc++.so.6.0.18 libstdc++.so.6
  179. @-test -d $(STAGING_TARGET_DIR)/libx32 && \
  180. cd $(STAGING_TARGET_DIR)/libx32 && \
  181. ln -sf libstdc++.so.6.0.18 libstdc++.so && \
  182. ln -sf libstdc++.so.6.0.18 libstdc++.so.6
  183. @-test -d $(STAGING_TARGET_DIR)/lib64 && \
  184. cd $(STAGING_TARGET_DIR)/lib64 && \
  185. ln -sf libstdc++.so.6.0.18 libstdc++.so && \
  186. ln -sf libstdc++.so.6.0.18 libstdc++.so.6
  187. # cleanup unneeded docs
  188. rm -rf $(TOOLCHAIN_DIR)/usr/share
  189. touch $@
  190. include ${TOPDIR}/mk/toolchain.mk