Makefile 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. include Makefile.inc
  6. include Makefile.multilib
  7. include ${TOPDIR}/mk/buildhlp.mk
  8. # eglibc does not compile with Os
  9. TARGET_CFLAGS_LIBC:= $(subst Os,O2,$(TARGET_CFLAGS))
  10. ifneq ($(ADK_DEBUG),)
  11. TARGET_CFLAGS_LIBC+= -O2
  12. endif
  13. # ssp partially supported
  14. TARGET_CFLAGS_LIBC:= $(filter-out -fstack-protector,$(TARGET_CFLAGS_LIBC))
  15. ifeq ($(ADK_TARGET_NO_FPU),y)
  16. EGLIBC_CONFOPTS+= --without-fp
  17. endif
  18. EGLIBC_BUILD_DIR_INITIAL:= ${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION)-headers
  19. EGLIBC_BUILD_DIR_FINAL:= ${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION)-final
  20. ifeq ($(ADK_TARGET_WITH_MULTILIB),y)
  21. $(WRKBUILD)/.headers_configure:
  22. for abi in $(TABI); do \
  23. mkdir -p $(EGLIBC_BUILD_DIR_INITIAL)-$${abi/*:/}; \
  24. $(CP) ${TOPDIR}/toolchain/eglibc/eglibc.config \
  25. $(EGLIBC_BUILD_DIR_INITIAL)-$${abi/*:/}/option-groups.config; \
  26. (cd $(EGLIBC_BUILD_DIR_INITIAL)-$${abi/*:/}; \
  27. ${EGLIBC_ENV} \
  28. CC="${REAL_GNU_TARGET_NAME}-gcc ${TCFLAGS}$${abi/*:/}" \
  29. $(WRKBUILD)/libc/configure \
  30. --prefix=$(STAGING_TARGET_DIR)-$${abi/*:/}/usr \
  31. --with-headers=$(STAGING_TARGET_DIR)-$${abi/*:/}/usr/include \
  32. --host=$${abi/:*/} \
  33. ${EGLIBC_CONFOPTS} \
  34. ); \
  35. done
  36. touch $@
  37. $(WRKBUILD)/.headers: $(WRKBUILD)/.headers_configure
  38. for abi in $(TABI); do \
  39. (cd $(EGLIBC_BUILD_DIR_INITIAL)-$${abi/*:/}; \
  40. ${EGLIBC_ENV} \
  41. CC="${REAL_GNU_TARGET_NAME}-gcc ${TCFLAGS}$${abi/*:/}" \
  42. $(MAKE) install-headers install-bootstrap-headers=yes cross-compiling=yes \
  43. ); \
  44. touch $(STAGING_TARGET_DIR)-$${abi/*:/}/usr/include/gnu/stubs.h; \
  45. touch $(STAGING_TARGET_DIR)-$${abi/*:/}/usr/include/gnu/stubs-{32,x32,64,o32,n32}.h; \
  46. done
  47. touch $@
  48. else
  49. $(WRKBUILD)/.headers_configure:
  50. mkdir -p $(EGLIBC_BUILD_DIR_INITIAL)
  51. $(CP) ${TOPDIR}/toolchain/eglibc/eglibc.config \
  52. $(EGLIBC_BUILD_DIR_INITIAL)/option-groups.config
  53. (cd $(EGLIBC_BUILD_DIR_INITIAL); \
  54. ${EGLIBC_ENV} \
  55. CC="${REAL_GNU_TARGET_NAME}-gcc $(ADK_TARGET_ABI_CFLAGS)" \
  56. $(WRKBUILD)/libc/configure \
  57. --prefix=$(STAGING_TARGET_DIR)/usr \
  58. --with-headers=$(STAGING_TARGET_DIR)/usr/include \
  59. --host=$(REAL_GNU_TARGET_NAME) \
  60. ${EGLIBC_CONFOPTS} \
  61. );
  62. touch $@
  63. $(WRKBUILD)/.headers: $(WRKBUILD)/.headers_configure
  64. (cd $(EGLIBC_BUILD_DIR_INITIAL); \
  65. ${EGLIBC_ENV} \
  66. CC="${REAL_GNU_TARGET_NAME}-gcc $(ADK_TARGET_ABI_CFLAGS)" \
  67. $(MAKE) install-headers install-bootstrap-headers=yes cross-compiling=yes \
  68. );
  69. touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs.h
  70. touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs-{32,x32,64,o32,n32,soft,hard}.h
  71. touch $@
  72. endif
  73. ifeq ($(ADK_TOOLCHAIN_GCC_USE_SSP),y)
  74. EGLIBC_ENV+= libc_cv_ssp=yes
  75. else
  76. EGLIBC_ENV+= libc_cv_ssp=no
  77. endif
  78. ifeq ($(ADK_TARGET_WITH_MULTILIB),y)
  79. $(WRKBUILD)/.configured:
  80. for abi in $(TABI); do \
  81. mkdir -p $(EGLIBC_BUILD_DIR_FINAL)-$${abi/*:/} ;\
  82. $(CP) ${TOPDIR}/toolchain/eglibc/eglibc.config \
  83. $(EGLIBC_BUILD_DIR_FINAL)-$${abi/*:/}/option-groups.config ;\
  84. (cd $(EGLIBC_BUILD_DIR_FINAL)-$${abi/*:/}; \
  85. ${EGLIBC_ENV} \
  86. CC="${REAL_GNU_TARGET_NAME}-gcc ${TCFLAGS}$${abi/*:/}" \
  87. $(WRKBUILD)/libc/configure \
  88. --prefix=/usr \
  89. --enable-shared \
  90. --enable-stackguard-randomization \
  91. --host=$${abi/:*/} \
  92. ${EGLIBC_CONFOPTS} \
  93. ); \
  94. done
  95. touch $@
  96. $(WRKBUILD)/.compiled: $(WRKBUILD)/.configured
  97. for abi in $(TABI); do \
  98. ${EGLIBC_ENV} $(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL)-$${abi/*:/} cross-compiling=yes all ;\
  99. done
  100. touch $@
  101. $(WRKBUILD)/.installed: $(WRKBUILD)/.compiled
  102. for abi in $(TABI); do \
  103. ${EGLIBC_ENV} $(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL)-$${abi/*:/} install_root=$(STAGING_TARGET_DIR)-$${abi/*:/} install ;\
  104. done
  105. # default libgcc searching for 64 bit libraries
  106. ${EGLIBC_ENV} $(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL)-64 install_root=$(STAGING_TARGET_DIR) install
  107. touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs.h
  108. touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs-{32,x32,64,o32,n32}.h
  109. # for libgcc build we need C library files, 64 bit default
  110. mkdir -p $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2 ; \
  111. $(CP) $(STAGING_TARGET_DIR)-64/lib/* $(STAGING_TARGET_DIR)-64/usr/lib/* \
  112. $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/; \
  113. rm $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/libc.so ; \
  114. for abi in $(TABI); do \
  115. mkdir -p $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/$${abi/*:/} ; \
  116. $(CP) $(STAGING_TARGET_DIR)-$${abi/*:/}/lib/* $(STAGING_TARGET_DIR)-$${abi/*:/}/usr/lib/* \
  117. $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/$${abi/*:/} ; \
  118. rm $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/$${abi/*:/}/libc.so ; \
  119. done
  120. ${INSTALL_DIR} ${STAGING_TARGET_DIR}/etc
  121. ${INSTALL_DATA} ${WRKBUILD}/libc/posix/gai.conf ${STAGING_TARGET_DIR}/etc/
  122. ${INSTALL_DATA} ${WRKBUILD}/libc/nscd/nscd.conf ${STAGING_TARGET_DIR}/etc/
  123. ${INSTALL_DATA} ${WRKBUILD}/libc/nss/nsswitch.conf ${STAGING_TARGET_DIR}/etc/
  124. touch $@
  125. else
  126. $(WRKBUILD)/.configured:
  127. mkdir -p $(EGLIBC_BUILD_DIR_FINAL)
  128. $(CP) ${TOPDIR}/toolchain/eglibc/eglibc.config \
  129. $(EGLIBC_BUILD_DIR_FINAL)/option-groups.config
  130. (cd $(EGLIBC_BUILD_DIR_FINAL); \
  131. ${EGLIBC_ENV} \
  132. CC="${REAL_GNU_TARGET_NAME}-gcc $(ADK_TARGET_ABI_CFLAGS)" \
  133. $(WRKBUILD)/libc/configure \
  134. --prefix=/usr \
  135. --enable-shared \
  136. --enable-stackguard-randomization \
  137. --host=$(REAL_GNU_TARGET_NAME) \
  138. ${EGLIBC_CONFOPTS} \
  139. );
  140. touch $@
  141. $(EGLIBC_BUILD_DIR_FINAL)/libc.so:
  142. $(WRKBUILD)/.compiled: $(WRKBUILD)/.configured
  143. ${EGLIBC_ENV} \
  144. CC="${REAL_GNU_TARGET_NAME}-gcc $(ADK_TARGET_ABI_CFLAGS)" \
  145. $(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL) cross-compiling=yes all
  146. touch $@
  147. $(WRKBUILD)/.installed: $(EGLIBC_BUILD_DIR_FINAL)/libc.so
  148. ${EGLIBC_ENV} \
  149. CC="${REAL_GNU_TARGET_NAME}-gcc $(ADK_TARGET_ABI_CFLAGS)" \
  150. $(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL) install_root=$(STAGING_TARGET_DIR) install
  151. ${INSTALL_DIR} ${STAGING_TARGET_DIR}/etc
  152. ${INSTALL_DATA} ${WRKBUILD}/libc/posix/gai.conf ${STAGING_TARGET_DIR}/etc/
  153. ${INSTALL_DATA} ${WRKBUILD}/libc/nscd/nscd.conf ${STAGING_TARGET_DIR}/etc/
  154. ${INSTALL_DATA} ${WRKBUILD}/libc/nss/nsswitch.conf ${STAGING_TARGET_DIR}/etc/
  155. touch $@
  156. endif
  157. $(WRKBUILD)/.fixup:
  158. ifeq ($(ADK_TARGET_WITH_MULTILIB),y)
  159. ifeq ($(ADK_TARGET_ABI_64),y)
  160. ${CP} $(STAGING_TARGET_DIR)-64/lib/* $(STAGING_TARGET_DIR)/lib
  161. ${CP} $(STAGING_TARGET_DIR)-64/usr/lib/* $(STAGING_TARGET_DIR)/usr/lib
  162. endif
  163. ifeq ($(ADK_TARGET_ABI_32),y)
  164. ${CP} $(STAGING_TARGET_DIR)-32/lib/* $(STAGING_TARGET_DIR)/lib
  165. ${CP} $(STAGING_TARGET_DIR)-32/usr/lib/* $(STAGING_TARGET_DIR)/usr/lib
  166. endif
  167. ifeq ($(ADK_TARGET_ABI_X32),y)
  168. ${CP} $(STAGING_TARGET_DIR)-x32/lib/* $(STAGING_TARGET_DIR)/lib
  169. ${CP} $(STAGING_TARGET_DIR)-x32/usr/lib/* $(STAGING_TARGET_DIR)/usr/lib
  170. endif
  171. endif
  172. touch $@
  173. include ${TOPDIR}/mk/toolchain.mk