Makefile 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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_GCC_SSP),y)
  60. GCC_FINAL_CONFOPTS+= --enable-libssp
  61. else
  62. GCC_FINAL_CONFOPTS+= --disable-libssp
  63. endif
  64. ifeq ($(ADK_TOOLCHAIN_GCC_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
  103. ifeq ($(ADK_TOOLCHAIN_GCC_CXX),y)
  104. LANGUAGES:=${LANGUAGES},c++
  105. endif
  106. include ${TOPDIR}/mk/buildhlp.mk
  107. GCC_BUILD_DIR_MINIMAL:= $(WRKBUILD)-minimal
  108. GCC_BUILD_DIR_INITIAL:= $(WRKBUILD)-initial
  109. GCC_BUILD_DIR_FINAL:= $(WRKBUILD)-final
  110. $(GCC_BUILD_DIR_MINIMAL)/.configured:
  111. mkdir -p $(GCC_BUILD_DIR_MINIMAL)
  112. # these symlinks are very important, do not remove
  113. rm -rf $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)/sys-include
  114. mkdir -p $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)
  115. (cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME); \
  116. ln -s ../$(STAGING_HOST2TARGET)/usr/include sys-include)
  117. rm -rf ${TOOLCHAIN_DIR}/usr/$(GNU_TARGET_NAME)/lib
  118. (cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME); \
  119. ln -s ../$(STAGING_HOST2TARGET)/lib lib)
  120. ifeq ($(ADK_LINUX_SH),y)
  121. (cd ${STAGING_TARGET_DIR}/ && ln -sf . m4 && ln -sf . m4-nofpu)
  122. endif
  123. $(SED) '/k prot/agcc_cv_libc_provides_ssp=yes' $(WRKBUILD)/gcc/configure
  124. cd $(GCC_BUILD_DIR_MINIMAL); \
  125. PATH='$(TARGET_PATH)' \
  126. CFLAGS="-O0 -g0" \
  127. CXXFLAGS="-O0 -g0" \
  128. $(WRKBUILD)/configure \
  129. ${GCC_CONFOPTS} \
  130. --enable-languages=c \
  131. --disable-multilib \
  132. --disable-lto \
  133. --disable-libssp \
  134. --disable-shared \
  135. --without-headers
  136. touch $@
  137. $(GCC_BUILD_DIR_MINIMAL)/.compiled: $(GCC_BUILD_DIR_MINIMAL)/.configured
  138. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_MINIMAL) all-gcc
  139. touch $@
  140. $(WRKBUILD)/.headers: $(GCC_BUILD_DIR_MINIMAL)/.compiled
  141. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_MINIMAL) install-gcc
  142. touch $@
  143. $(GCC_BUILD_DIR_INITIAL)/.configured:
  144. mkdir -p $(GCC_BUILD_DIR_INITIAL)
  145. cd $(GCC_BUILD_DIR_INITIAL); \
  146. PATH='$(TARGET_PATH)' \
  147. CFLAGS="-O0 -g0" \
  148. CXXFLAGS="-O0 -g0" \
  149. $(WRKBUILD)/configure \
  150. ${GCC_CONFOPTS} \
  151. ${GCC_FINAL_CONFOPTS} \
  152. --enable-languages=c \
  153. --disable-shared \
  154. --disable-threads \
  155. --with-sysroot=$(STAGING_TARGET_DIR)
  156. touch $@
  157. $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
  158. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc all-target-libgcc
  159. touch $@
  160. $(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
  161. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
  162. touch $@
  163. $(GCC_BUILD_DIR_FINAL)/.configured:
  164. mkdir -p $(GCC_BUILD_DIR_FINAL)
  165. cd $(GCC_BUILD_DIR_FINAL); \
  166. PATH='$(TARGET_PATH)' \
  167. $(WRKBUILD)/configure \
  168. ${GCC_CONFOPTS} \
  169. ${GCC_FINAL_CONFOPTS} \
  170. --enable-languages=$(LANGUAGES) \
  171. --with-build-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  172. --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  173. --enable-shared
  174. touch $@
  175. $(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured
  176. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_FINAL) all
  177. touch $@
  178. $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
  179. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_FINAL) install
  180. # remove duplicate tools, convert hardlinks to symlinks
  181. set -e; \
  182. cd $(TOOLCHAIN_DIR)/usr/$(GNU_TARGET_NAME)/bin; \
  183. for app in ar as c++ g++ gcc ld ld.gold ld.bfd nm objcopy objdump ranlib strip; do \
  184. ln -sf ../../bin/$(GNU_TARGET_NAME)-$${app} $${app}; \
  185. done;
  186. (cd $(TOOLCHAIN_DIR)/usr/bin && \
  187. ln -sf $(GNU_TARGET_NAME)-gcc $(GNU_TARGET_NAME)-gcc-${PKG_VERSION})
  188. ifeq ($(ADK_TOOLCHAIN_USE_GOLD),y)
  189. (cd $(TOOLCHAIN_DIR)/usr/bin && \
  190. ln -sf $(GNU_TARGET_NAME)-ld.gold $(GNU_TARGET_NAME)-ld)
  191. else
  192. (cd $(TOOLCHAIN_DIR)/usr/bin && \
  193. ln -sf $(GNU_TARGET_NAME)-ld.bfd $(GNU_TARGET_NAME)-ld)
  194. endif
  195. cd $(STAGING_TARGET_DIR)/lib && \
  196. ln -sf libstdc++.so.6.0.18 libstdc++.so && \
  197. ln -sf libstdc++.so.6.0.18 libstdc++.so.6
  198. # cleanup unneeded docs
  199. rm -rf $(TOOLCHAIN_DIR)/usr/share
  200. touch $@
  201. include ${TOPDIR}/mk/toolchain.mk