Makefile 6.8 KB

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