Makefile 6.6 KB

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