1
0

Makefile 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. --build=$(GNU_HOST_NAME) \
  9. --host=$(GNU_HOST_NAME) \
  10. --target=$(REAL_GNU_TARGET_NAME) \
  11. --with-gmp=$(STAGING_HOST_DIR) \
  12. --with-mpfr=$(STAGING_HOST_DIR) \
  13. --with-libelf=$(STAGING_HOST_DIR) \
  14. --disable-__cxa_atexit \
  15. --with-gnu-ld \
  16. --disable-libmudflap \
  17. --disable-libgomp \
  18. --disable-decimal-float \
  19. --disable-libstdcxx-pch \
  20. --disable-ppl-version-check \
  21. --disable-cloog-version-check \
  22. --without-ppl \
  23. --without-cloog \
  24. --disable-nls
  25. ifeq ($(ADK_TOOLCHAIN_GCC_SJLJ),y)
  26. GCC_CONFOPTS+= --enable-sjlj-exceptions
  27. else
  28. GCC_CONFOPTS+= --disable-sjlj-exceptions
  29. endif
  30. ifeq ($(ADK_LINUX_SH)$(ADK_LINUX_X86_64),)
  31. GCC_CONFOPTS+= --disable-biarch --disable-multilib
  32. endif
  33. ifeq ($(ADK_LINUX_SH),y)
  34. GCC_CONFOPTS+= --with-multilib-list=m4,m4-nofpu
  35. endif
  36. ifeq ($(ADK_LINUX_X86_64),y)
  37. ifeq ($(ADK_x32),y)
  38. GCC_CONFOPTS+= --with-multilib-list=mx32
  39. else
  40. GCC_CONFOPTS+= --disable-biarch --disable-multilib
  41. endif
  42. endif
  43. ifeq ($(ADK_TOOLCHAIN_GCC_SSP),y)
  44. GCC_CONFOPTS+= --enable-libssp
  45. else
  46. GCC_CONFOPTS+= --disable-libssp
  47. endif
  48. ifeq ($(ADK_TOOLCHAIN_GCC_LTO),y)
  49. GCC_CONFOPTS+= --enable-lto
  50. else
  51. GCC_CONFOPTS+= --disable-lto
  52. endif
  53. ifeq ($(ARCH),m68k)
  54. GCC_CONFOPTS+= --disable-tls
  55. else
  56. GCC_CONFOPTS+= --enable-tls
  57. endif
  58. ifeq ($(ARCH),powerpc)
  59. GCC_CONFOPTS+= --disable-target-optspace --with-long-double-64 --enable-secureplt
  60. else
  61. GCC_CONFOPTS+= --enable-target-optspace
  62. endif
  63. ifeq ($(ARCH),mips)
  64. ifeq ($(ADK_TARGET_NO_FPU),y)
  65. GCC_CONFOPTS+= --with-float=soft
  66. else
  67. GCC_CONFOPTS+= --with-float=hard
  68. endif
  69. endif
  70. ifeq ($(ADK_TARGET_SYSTEM_RASPBERRY_PI),y)
  71. GCC_CONFOPTS+= --with-arch=armv6 --with-fpu=vfp --with-float=hard
  72. endif
  73. ifneq ($(ADK_TARGET_ABI),)
  74. GCC_CONFOPTS+= --with-abi=${ADK_TARGET_ABI}
  75. endif
  76. ifeq (${ADK_MAKE_PARALLEL},y)
  77. GCC_MAKEOPTS+= -j${ADK_MAKE_JOBS}
  78. endif
  79. LANGUAGES:=c
  80. ifeq ($(ADK_TOOLCHAIN_GCC_CXX),y)
  81. LANGUAGES:=${LANGUAGES},c++
  82. endif
  83. ifeq ($(ADK_TOOLCHAIN_GCC_JAVA),y)
  84. LANGUAGES:=${LANGUAGES},java
  85. GCC_CONFOPTS+= --enable-java-home
  86. endif
  87. ifeq ($(ADK_TOOLCHAIN_GCC_ADA),y)
  88. LANGUAGES:=${LANGUAGES},ada
  89. endif
  90. include ${TOPDIR}/mk/buildhlp.mk
  91. GCC_BUILD_DIR_MINIMAL:= $(WRKBUILD)-minimal
  92. GCC_BUILD_DIR_INITIAL:= $(WRKBUILD)-initial
  93. GCC_BUILD_DIR_FINAL:= $(WRKBUILD)-final
  94. $(GCC_BUILD_DIR_MINIMAL)/.configured:
  95. mkdir -p $(GCC_BUILD_DIR_MINIMAL)
  96. # these symlinks are very important, do not remove
  97. rm -rf $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  98. ln -sf ${STAGING_TARGET_DIR}/include $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  99. rm -rf ${STAGING_HOST_DIR}/$(REAL_GNU_TARGET_NAME)/lib
  100. ln -sf ${STAGING_TARGET_DIR}/lib $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  101. ifeq ($(ADK_LINUX_SH),y)
  102. (cd ${STAGING_TARGET_DIR}/ && ln -sf . m4 && ln -sf . m4-nofpu)
  103. endif
  104. sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' $(WRKBUILD)/gcc/configure
  105. cd $(GCC_BUILD_DIR_MINIMAL); PATH='$(TARGET_PATH)' \
  106. $(WRKBUILD)/configure \
  107. ${GCC_CONFOPTS} \
  108. --enable-languages=c \
  109. --disable-shared \
  110. --with-newlib \
  111. --without-headers
  112. touch $@
  113. $(GCC_BUILD_DIR_MINIMAL)/.compiled: $(GCC_BUILD_DIR_MINIMAL)/.configured
  114. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_MINIMAL) all-gcc
  115. touch $@
  116. $(WRKBUILD)/.headers: $(GCC_BUILD_DIR_MINIMAL)/.compiled
  117. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_MINIMAL) install-gcc
  118. touch $@
  119. $(GCC_BUILD_DIR_INITIAL)/.configured:
  120. mkdir -p $(GCC_BUILD_DIR_INITIAL)
  121. cd $(GCC_BUILD_DIR_INITIAL); PATH='$(TARGET_PATH)' \
  122. $(WRKBUILD)/configure \
  123. ${GCC_CONFOPTS} \
  124. --enable-languages=c \
  125. --disable-shared \
  126. --disable-threads \
  127. --with-newlib \
  128. --with-sysroot=$(STAGING_TARGET_DIR)
  129. touch $@
  130. $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
  131. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc all-target-libgcc
  132. touch $@
  133. $(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
  134. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
  135. touch $@
  136. $(GCC_BUILD_DIR_FINAL)/.configured:
  137. mkdir -p $(GCC_BUILD_DIR_FINAL)
  138. cd $(GCC_BUILD_DIR_FINAL); PATH='$(TARGET_PATH)' \
  139. $(WRKBUILD)/configure \
  140. ${GCC_CONFOPTS} \
  141. --enable-languages=$(LANGUAGES) \
  142. --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  143. --enable-shared
  144. touch $@
  145. $(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured
  146. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_FINAL) all
  147. touch $@
  148. $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
  149. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_FINAL) install
  150. # workaround if you cross-compile binutils
  151. @-rm $(STAGING_TARGET_DIR)/lib/libiberty.a $(STAGING_TARGET_DIR)/usr/lib/libiberty.a
  152. # Set up the symlinks to enable lying about target name.
  153. set -e; \
  154. cd $(STAGING_HOST_DIR); \
  155. ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
  156. cd bin; \
  157. for app in $(REAL_GNU_TARGET_NAME)-* ; do \
  158. ln -sf $${app} \
  159. $(GNU_TARGET_NAME)$${app##$(REAL_GNU_TARGET_NAME)}; \
  160. done;
  161. # workaround for openjdk
  162. cd $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/bin ; cp * ..
  163. # fix linking g++ apps with libtool
  164. @-test -d $(STAGING_TARGET_DIR)/lib32 && \
  165. cd $(STAGING_TARGET_DIR)/lib32 && \
  166. ln -sf libstdc++.so.6.0.17 libstdc++.so
  167. @-test -d $(STAGING_TARGET_DIR)/lib64 && \
  168. cd $(STAGING_TARGET_DIR)/lib64 && \
  169. ln -sf libstdc++.so.6.0.17 libstdc++.so
  170. touch $@
  171. include ${TOPDIR}/mk/toolchain.mk