Makefile 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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=$(STAGING_HOST_DIR) \
  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) \
  13. --with-mpfr=$(STAGING_HOST_DIR) \
  14. --with-libelf=$(STAGING_HOST_DIR) \
  15. --disable-__cxa_atexit \
  16. --with-gnu-ld \
  17. --with-gnu-as \
  18. --disable-libsanitizer \
  19. --disable-libitm \
  20. --disable-libmudflap \
  21. --disable-libgomp \
  22. --disable-decimal-float \
  23. --disable-libstdcxx-pch \
  24. --disable-ppl-version-check \
  25. --disable-cloog-version-check \
  26. --without-ppl \
  27. --without-cloog \
  28. --without-isl \
  29. --disable-nls
  30. ifeq ($(ADK_TOOLCHAIN_GCC_SJLJ),y)
  31. GCC_CONFOPTS+= --enable-sjlj-exceptions
  32. else
  33. GCC_CONFOPTS+= --disable-sjlj-exceptions
  34. endif
  35. ifeq ($(ADK_LINUX_SH)$(ADK_LINUX_X86_64),)
  36. GCC_CONFOPTS+= --disable-biarch --disable-multilib
  37. endif
  38. ifeq ($(ADK_LINUX_SH),y)
  39. GCC_CONFOPTS+= --with-multilib-list=m4,m4-nofpu
  40. endif
  41. ifeq ($(ADK_LINUX_X86_64),y)
  42. ifeq ($(ADK_x32),y)
  43. GCC_CONFOPTS+= --with-multilib-list=mx32
  44. else
  45. GCC_CONFOPTS+= --disable-biarch --disable-multilib
  46. endif
  47. endif
  48. ifeq ($(ADK_TOOLCHAIN_GCC_SSP),y)
  49. GCC_CONFOPTS+= --enable-libssp
  50. else
  51. GCC_CONFOPTS+= --disable-libssp
  52. endif
  53. ifeq ($(ADK_TOOLCHAIN_GCC_LTO),y)
  54. GCC_CONFOPTS+= --enable-lto
  55. else
  56. GCC_CONFOPTS+= --disable-lto
  57. endif
  58. ifeq ($(ARCH),m68k)
  59. ifeq ($(ADK_TARGET_LIBC),uclibc)
  60. GCC_CONFOPTS+= --disable-tls
  61. else
  62. GCC_CONFOPTS+= --enable-tls
  63. endif
  64. else
  65. GCC_CONFOPTS+= --enable-tls
  66. endif
  67. ifeq ($(ADK_LINUX_PPC),y)
  68. ifeq ($(ADK_TARGET_LIBC),uclibc)
  69. GCC_CONFOPTS+= --disable-target-optspace --with-long-double-128 --enable-secureplt
  70. else
  71. GCC_CONFOPTS+= --disable-target-optspace --with-long-double-64 --enable-secureplt
  72. endif
  73. else
  74. GCC_CONFOPTS+= --enable-target-optspace
  75. endif
  76. ifeq ($(ARCH),arm)
  77. GCC_CONFOPTS+= --with-float=$(ADK_TARGET_FLOAT)
  78. GCC_CONFOPTS+= --with-mode=$(ADK_TARGET_ARM_MODE)
  79. endif
  80. ifeq ($(ADK_CPU_ARM926EJ_S),y)
  81. GCC_CONFOPTS+= --with-arch=armv5te --with-tune=arm1176jzf-s
  82. endif
  83. ifeq ($(ADK_CPU_ARM1176JZF_S),y)
  84. GCC_CONFOPTS+= --with-arch=armv6 --with-tune=arm1176jzf-s --with-fpu=vfp
  85. endif
  86. ifeq ($(ADK_CPU_CORTEX_A9),y)
  87. GCC_CONFOPTS+= --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=neon
  88. endif
  89. ifeq ($(ADK_CPU_SPARC_V9),y)
  90. GCC_CONFOPTS+= --with-cpu=ultrasparc
  91. endif
  92. ifneq ($(ADK_TARGET_MIPS_ABI),)
  93. GCC_CONFOPTS+= --with-abi=${ADK_TARGET_MIPS_ABI}
  94. endif
  95. ifeq (${ADK_MAKE_PARALLEL},y)
  96. GCC_MAKEOPTS+= -j${ADK_MAKE_JOBS}
  97. endif
  98. LANGUAGES:=c
  99. ifeq ($(ADK_TOOLCHAIN_GCC_CXX),y)
  100. LANGUAGES:=${LANGUAGES},c++
  101. endif
  102. include ${TOPDIR}/mk/buildhlp.mk
  103. GCC_BUILD_DIR_MINIMAL:= $(WRKBUILD)-minimal
  104. GCC_BUILD_DIR_INITIAL:= $(WRKBUILD)-initial
  105. GCC_BUILD_DIR_FINAL:= $(WRKBUILD)-final
  106. $(GCC_BUILD_DIR_MINIMAL)/.configured:
  107. mkdir -p $(GCC_BUILD_DIR_MINIMAL)
  108. # these symlinks are very important, do not remove
  109. rm -rf $(STAGING_HOST_DIR)/$(GNU_TARGET_NAME)/sys-include
  110. ln -sf ${STAGING_TARGET_DIR}/usr/include $(STAGING_HOST_DIR)/$(GNU_TARGET_NAME)/sys-include
  111. rm -rf ${STAGING_HOST_DIR}/$(GNU_TARGET_NAME)/lib
  112. ln -sf ${STAGING_TARGET_DIR}/lib $(STAGING_HOST_DIR)/$(GNU_TARGET_NAME)/lib
  113. ifeq ($(ADK_LINUX_SH),y)
  114. (cd ${STAGING_TARGET_DIR}/ && ln -sf . m4 && ln -sf . m4-nofpu)
  115. endif
  116. sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' $(WRKBUILD)/gcc/configure
  117. cd $(GCC_BUILD_DIR_MINIMAL); PATH='$(TARGET_PATH)' \
  118. CFLAGS="-O0 -g0" \
  119. CXXFLAGS="-O0 -g0" \
  120. $(WRKBUILD)/configure \
  121. ${GCC_CONFOPTS} \
  122. --enable-languages=c \
  123. --disable-shared \
  124. --without-headers
  125. touch $@
  126. $(GCC_BUILD_DIR_MINIMAL)/.compiled: $(GCC_BUILD_DIR_MINIMAL)/.configured
  127. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_MINIMAL) all-gcc
  128. touch $@
  129. $(WRKBUILD)/.headers: $(GCC_BUILD_DIR_MINIMAL)/.compiled
  130. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_MINIMAL) install-gcc
  131. touch $@
  132. $(GCC_BUILD_DIR_INITIAL)/.configured:
  133. mkdir -p $(GCC_BUILD_DIR_INITIAL)
  134. cd $(GCC_BUILD_DIR_INITIAL); PATH='$(TARGET_PATH)' \
  135. CFLAGS="-O0 -g0" \
  136. CXXFLAGS="-O0 -g0" \
  137. $(WRKBUILD)/configure \
  138. ${GCC_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); PATH='$(TARGET_PATH)' \
  153. $(WRKBUILD)/configure \
  154. ${GCC_CONFOPTS} \
  155. --enable-languages=$(LANGUAGES) \
  156. --with-build-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  157. --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  158. --enable-shared
  159. touch $@
  160. $(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured
  161. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_FINAL) all
  162. touch $@
  163. $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
  164. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_FINAL) install
  165. # remove duplicate tools, convert hardlinks to symlinks
  166. set -e; \
  167. cd $(STAGING_HOST_DIR)/$(GNU_TARGET_NAME)/bin; \
  168. for app in ar as c++ g++ gcc ld ld.bfd nm objcopy objdump ranlib strip; do \
  169. ln -sf ../../bin/$(GNU_TARGET_NAME)-$${app} $${app}; \
  170. done;
  171. (cd $(STAGING_HOST_DIR)/bin && \
  172. ln -sf $(GNU_TARGET_NAME)-gcc $(GNU_TARGET_NAME)-gcc-${PKG_VERSION})
  173. # setup symlink, so that gcc/g++ find cc1plus
  174. (cd $(STAGING_HOST_DIR)/$(GNU_TARGET_NAME)/ && \
  175. ln -sf ../libexec .)
  176. # setup symlink, so that gcc/g++ find stddef.h
  177. (cd $(STAGING_HOST_DIR)/$(GNU_TARGET_NAME)/lib/ && \
  178. ln -sf ../../host_${CPU_ARCH}_${ADK_TARGET_LIBC}_${ADK_TARGET_SUFFIX}/lib/gcc .)
  179. # fix linking g++ apps with libtool
  180. @-test -d $(STAGING_TARGET_DIR)/lib32 && \
  181. cd $(STAGING_TARGET_DIR)/lib32 && \
  182. ln -sf libstdc++.so.6.0.18 libstdc++.so && \
  183. ln -sf libstdc++.so.6.0.18 libstdc++.so.6
  184. @-test -d $(STAGING_TARGET_DIR)/libx32 && \
  185. cd $(STAGING_TARGET_DIR)/libx32 && \
  186. ln -sf libstdc++.so.6.0.18 libstdc++.so && \
  187. ln -sf libstdc++.so.6.0.18 libstdc++.so.6
  188. @-test -d $(STAGING_TARGET_DIR)/lib64 && \
  189. cd $(STAGING_TARGET_DIR)/lib64 && \
  190. ln -sf libstdc++.so.6.0.18 libstdc++.so && \
  191. ln -sf libstdc++.so.6.0.18 libstdc++.so.6
  192. # cleanup unneeded docs
  193. rm -rf $(STAGING_HOST_DIR)/share
  194. touch $@
  195. include ${TOPDIR}/mk/toolchain.mk