Makefile 5.2 KB

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