1
0

Makefile 6.1 KB

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