Makefile 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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_TARGET_WITH_MULTILIB),y)
  31. ifeq ($(ADK_LINUX_X86_64),y)
  32. GCC_CONFOPTS+= --with-multilib-list=$(ADK_MULTILIB_TARGET)
  33. endif
  34. GCC_CONFOPTS+= --enable-multilib
  35. else
  36. GCC_CONFOPTS+= --disable-biarch \
  37. --disable-multilib
  38. endif
  39. ifeq ($(ADK_TOOLCHAIN_GCC_SSP),y)
  40. GCC_CONFOPTS+= --enable-libssp
  41. else
  42. GCC_CONFOPTS+= --disable-libssp
  43. endif
  44. ifeq ($(ADK_TOOLCHAIN_GCC_LTO),y)
  45. GCC_CONFOPTS+= --enable-lto
  46. else
  47. GCC_CONFOPTS+= --disable-lto
  48. endif
  49. ifeq ($(ARCH),cris)
  50. GCC_CONFOPTS+= --disable-tls
  51. else
  52. GCC_CONFOPTS+= --enable-tls
  53. endif
  54. ifeq ($(ARCH),powerpc)
  55. GCC_CONFOPTS+= --disable-target-optspace
  56. else
  57. GCC_CONFOPTS+= --enable-target-optspace
  58. endif
  59. ifeq ($(ARCH),mips)
  60. ifeq ($(ADK_TARGET_NO_FPU),y)
  61. GCC_CONFOPTS+= --with-float=soft
  62. else
  63. GCC_CONFOPTS+= --with-float=hard
  64. endif
  65. endif
  66. ifeq ($(ADK_TARGET_SYSTEM_RASPBERRY_PI),y)
  67. GCC_CONFOPTS+= --with-arch=armv6 --with-fpu=vfp --with-float=hard
  68. endif
  69. ifneq ($(ADK_TARGET_ABI),)
  70. GCC_CONFOPTS+= --with-abi=${ADK_TARGET_ABI}
  71. endif
  72. ifeq (${ADK_MAKE_PARALLEL},y)
  73. GCC_MAKEOPTS+= -j${ADK_MAKE_JOBS}
  74. endif
  75. LANGUAGES:=c
  76. ifeq ($(ADK_TOOLCHAIN_GCC_CXX),y)
  77. LANGUAGES:=${LANGUAGES},c++
  78. endif
  79. ifeq ($(ADK_TOOLCHAIN_GCC_JAVA),y)
  80. LANGUAGES:=${LANGUAGES},java
  81. GCC_CONFOPTS+= --enable-java-home
  82. endif
  83. ifeq ($(ADK_TOOLCHAIN_GCC_ADA),y)
  84. LANGUAGES:=${LANGUAGES},ada
  85. endif
  86. include ${TOPDIR}/mk/buildhlp.mk
  87. GCC_BUILD_DIR_MINIMAL:= $(WRKBUILD)-minimal
  88. GCC_BUILD_DIR_INITIAL:= $(WRKBUILD)-initial
  89. GCC_BUILD_DIR_FINAL:= $(WRKBUILD)-final
  90. $(GCC_BUILD_DIR_MINIMAL)/.configured:
  91. mkdir -p $(GCC_BUILD_DIR_MINIMAL)
  92. # these symlinks are very important, do not remove
  93. rm -rf $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  94. ln -sf ${STAGING_TARGET_DIR}/include $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
  95. rm -rf ${STAGING_HOST_DIR}/$(REAL_GNU_TARGET_NAME)/lib
  96. ln -sf ${STAGING_TARGET_DIR}/lib $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/lib
  97. sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' $(WRKBUILD)/gcc/configure
  98. cd $(GCC_BUILD_DIR_MINIMAL); PATH='$(TARGET_PATH)' \
  99. $(WRKBUILD)/configure \
  100. ${GCC_CONFOPTS} \
  101. --enable-languages=c \
  102. --disable-shared \
  103. --with-newlib \
  104. --without-headers
  105. touch $@
  106. $(GCC_BUILD_DIR_MINIMAL)/.compiled: $(GCC_BUILD_DIR_MINIMAL)/.configured
  107. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_MINIMAL) all-gcc
  108. touch $@
  109. $(WRKBUILD)/.headers: $(GCC_BUILD_DIR_MINIMAL)/.compiled
  110. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_MINIMAL) install-gcc
  111. touch $@
  112. $(GCC_BUILD_DIR_INITIAL)/.configured:
  113. mkdir -p $(GCC_BUILD_DIR_INITIAL)
  114. cd $(GCC_BUILD_DIR_INITIAL); PATH='$(TARGET_PATH)' \
  115. $(WRKBUILD)/configure \
  116. ${GCC_CONFOPTS} \
  117. --enable-languages=c \
  118. --disable-shared \
  119. --disable-threads \
  120. --with-newlib \
  121. --with-sysroot=$(STAGING_TARGET_DIR)
  122. touch $@
  123. $(GCC_BUILD_DIR_INITIAL)/.compiled: $(GCC_BUILD_DIR_INITIAL)/.configured
  124. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_INITIAL) all-gcc all-target-libgcc
  125. touch $@
  126. $(WRKBUILD)/.configured: $(GCC_BUILD_DIR_INITIAL)/.compiled
  127. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_INITIAL) install-gcc install-target-libgcc
  128. # -lgcc_eh workaround
  129. (cd $(STAGING_HOST_DIR)/lib/gcc/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION) && ln -sf libgcc.a libgcc_eh.a)
  130. touch $@
  131. $(GCC_BUILD_DIR_FINAL)/.configured:
  132. mkdir -p $(GCC_BUILD_DIR_FINAL)
  133. cd $(GCC_BUILD_DIR_FINAL); PATH='$(TARGET_PATH)' \
  134. $(WRKBUILD)/configure \
  135. ${GCC_CONFOPTS} \
  136. --enable-languages=$(LANGUAGES) \
  137. --with-sysroot='$${prefix}/${STAGING_HOST2TARGET}' \
  138. --enable-shared
  139. touch $@
  140. $(WRKBUILD)/.compiled: $(GCC_BUILD_DIR_FINAL)/.configured
  141. PATH='$(TARGET_PATH)' $(MAKE) ${GCC_MAKEOPTS} -C $(GCC_BUILD_DIR_FINAL) all
  142. touch $@
  143. $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
  144. PATH='$(TARGET_PATH)' $(MAKE) -C $(GCC_BUILD_DIR_FINAL) install
  145. # workaround if you cross-compile binutils
  146. @-rm $(STAGING_TARGET_DIR)/lib/libiberty.a $(STAGING_TARGET_DIR)/usr/lib/libiberty.a
  147. # Set up the symlinks to enable lying about target name.
  148. set -e; \
  149. cd $(STAGING_HOST_DIR); \
  150. ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
  151. cd bin; \
  152. for app in $(REAL_GNU_TARGET_NAME)-* ; do \
  153. ln -sf $${app} \
  154. $(GNU_TARGET_NAME)$${app##$(REAL_GNU_TARGET_NAME)}; \
  155. done;
  156. # workaround for openjdk
  157. cd $(STAGING_HOST_DIR)/$(REAL_GNU_TARGET_NAME)/bin ; cp * ..
  158. touch $@
  159. include ${TOPDIR}/mk/toolchain.mk