vars.mk 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. CP= cp -fpR
  4. INSTALL_DIR= install -d -m0755
  5. INSTALL_DATA= install -m0644
  6. INSTALL_BIN= install -m0755
  7. INSTALL_SCRIPT= install -m0755
  8. MAKEFLAGS= $(EXTRA_MAKEFLAGS)
  9. BUILD_USER= $(shell id -un)
  10. BUILD_GROUP= $(shell id -gn)
  11. # target compiler settings
  12. TARGET_CPPFLAGS+= -I${STAGING_TARGET_DIR}/usr/include
  13. TARGET_LDFLAGS+= -Wl,-O2
  14. ifneq ($(ADK_DEBUG),)
  15. TARGET_DEBUGGING:= -g3 -fno-omit-frame-pointer
  16. else
  17. TARGET_DEBUGGING:= $(TARGET_OPTIMIZATION) -fomit-frame-pointer
  18. endif
  19. TARGET_CFLAGS:= $(TARGET_CFLAGS_ARCH) $(TARGET_DEBUGGING) -fwrapv
  20. ifneq ($(ADK_TOOLCHAIN_GCC_USE_SSP),)
  21. TARGET_CFLAGS+= -fstack-protector
  22. TARGET_LDFLAGS+= -fstack-protector
  23. endif
  24. ifneq ($(ADK_TOOLCHAIN_GCC_USE_LTO),)
  25. TARGET_CFLAGS+= -flto
  26. TARGET_LDFLAGS+= -flto
  27. endif
  28. BASE_DIR:= $(TOPDIR)
  29. DISTDIR?= ${BASE_DIR}/dl
  30. BUILD_DIR:= ${BASE_DIR}/build_${ADK_TARGET_SYSTEM}_${CPU_ARCH}_${ADK_TARGET_LIBC}
  31. BUILD_DIR_PFX:= $(BASE_DIR)/build_*
  32. STAGING_PKG_DIR:= ${BASE_DIR}/pkg_${ADK_TARGET_SYSTEM}_${ADK_TARGET_LIBC}
  33. STAGING_PKG_DIR_PFX:= ${BASE_DIR}/pkg_*
  34. STAGING_HOST_DIR:= ${BASE_DIR}/host_${CPU_ARCH}_${ADK_TARGET_LIBC}
  35. STAGING_HOST_DIR_PFX:= ${BASE_DIR}/host_*
  36. STAGING_TARGET_DIR:= ${BASE_DIR}/target_${CPU_ARCH}_${ADK_TARGET_LIBC}
  37. STAGING_TARGET_DIR_PFX:=${BASE_DIR}/target_*
  38. # relation from STAGING_HOST_DIR to STAGING_TARGET_DIR (for gcc to find
  39. # its sysroot while staying relocatable)
  40. STAGING_HOST2TARGET:= ../target_${CPU_ARCH}_${ADK_TARGET_LIBC}
  41. TOOLCHAIN_BUILD_DIR= $(BASE_DIR)/toolchain_build_${CPU_ARCH}_${ADK_TARGET_LIBC}
  42. TOOLCHAIN_BUILD_DIR_PFX=$(BASE_DIR)/toolchain_build_*
  43. TOOLS_BUILD_DIR= $(BASE_DIR)/tools_build
  44. TOOLS_DIR:= $(BASE_DIR)/bin/tools
  45. SCRIPT_DIR:= $(BASE_DIR)/scripts
  46. BIN_DIR:= $(BASE_DIR)/bin/${ADK_TARGET_SYSTEM}_${CPU_ARCH}_${ADK_TARGET_LIBC}
  47. BIN_DIR_PFX:= $(BASE_DIR)/bin
  48. PACKAGE_DIR:= $(BIN_DIR)/packages
  49. TARGET_DIR:= $(BASE_DIR)/root_${ADK_TARGET_SYSTEM}_${CPU_ARCH}_${ADK_TARGET_LIBC}
  50. TARGET_DIR_PFX:= $(BASE_DIR)/root_*
  51. TARGET_PATH= ${SCRIPT_DIR}:${TOOLS_DIR}:${STAGING_HOST_DIR}/bin:${STAGING_TARGET_DIR}/scripts:${_PATH}
  52. REAL_GNU_TARGET_NAME= $(CPU_ARCH)-$(ADK_VENDOR)-linux-$(ADK_TARGET_SUFFIX)
  53. GNU_TARGET_NAME= $(CPU_ARCH)-$(ADK_VENDOR)-linux
  54. TOOLCHAIN_SYSROOT:= $(TOOLCHAIN_BUILD_DIR)/libc_dev
  55. ifeq ($(ADK_NATIVE),y)
  56. TARGET_CROSS:=
  57. TARGET_COMPILER_PREFIX?=
  58. else
  59. TARGET_CROSS:= $(STAGING_HOST_DIR)/bin/$(REAL_GNU_TARGET_NAME)-
  60. TARGET_COMPILER_PREFIX?=${TARGET_CROSS}
  61. endif
  62. TARGET_CC:= ${TARGET_COMPILER_PREFIX}gcc
  63. TARGET_CXX:= ${TARGET_COMPILER_PREFIX}g++
  64. TARGET_LD:= ${TARGET_COMPILER_PREFIX}ld
  65. PATCH= ${BASH} $(SCRIPT_DIR)/patch.sh
  66. SED:= sed -i -e
  67. LINUX_DIR:= $(BUILD_DIR)/linux
  68. LINUX_HEADER_DIR:= $(STAGING_TARGET_DIR)/linux-header
  69. TARGET_CONFIGURE_OPTS= PATH='${TARGET_PATH}' \
  70. AR=$(TARGET_CROSS)ar \
  71. AS=$(TARGET_CROSS)as \
  72. LD=$(TARGET_CROSS)ld \
  73. NM=$(TARGET_CROSS)nm \
  74. RANLIB=$(TARGET_CROSS)ranlib \
  75. CC='$(TARGET_CC)' \
  76. GCC='$(TARGET_CC)' \
  77. CXX='$(TARGET_CXX)' \
  78. CROSS='$(TARGET_CROSS)'
  79. HOST_CONFIGURE_OPTS= CC_FOR_BUILD='${HOSTCC}' \
  80. BUILD_CC='${HOSTCC}' \
  81. CFLAGS_FOR_BUILD='${HOSTCFLAGS}' \
  82. CPPFLAGS_FOR_BUILD='${HOSTCPPFLAGS}' \
  83. LDFLAGS_FOR_BUILD='${HOSTLDFLAGS}'
  84. PKG_SUFFIX:= $(strip $(subst ",, $(ADK_PACKAGE_SUFFIX)))
  85. ifeq ($(ADK_TARGET_PACKAGE_IPKG),y)
  86. PKG_BUILD:= PATH='${TARGET_PATH}' \
  87. ${BASH} ${SCRIPT_DIR}/ipkg-build
  88. PKG_INSTALL:= IPKG_TMP=$(BUILD_DIR)/tmp \
  89. IPKG_INSTROOT=$(TARGET_DIR) \
  90. IPKG_CONF_DIR=$(STAGING_TARGET_DIR)/etc \
  91. IPKG_OFFLINE_ROOT=$(TARGET_DIR) \
  92. ${BASH} ${SCRIPT_DIR}/ipkg \
  93. -force-defaults -force-depends install
  94. PKG_STATE_DIR:= $(TARGET_DIR)/usr/lib/ipkg
  95. else
  96. PKG_BUILD:= ${BASH} ${SCRIPT_DIR}/tarpkg build
  97. PKG_INSTALL:= PKG_INSTROOT=$(TARGET_DIR) \
  98. ${BASH} ${SCRIPT_DIR}/tarpkg install
  99. PKG_STATE_DIR:= $(TARGET_DIR)/usr/lib/pkg
  100. endif
  101. ifeq ($(ADK_NATIVE),y)
  102. RSTRIP:= prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh
  103. else
  104. RSTRIP:= prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh
  105. endif
  106. EXTRACT_CMD= mkdir -p ${WRKDIR}; \
  107. cd ${WRKDIR} && \
  108. for file in ${FULLDISTFILES}; do case $$file in \
  109. *.cpio) \
  110. cat $$file | $(TOOLS_DIR)/cpio -i -d ;; \
  111. *.tar) \
  112. tar -xf $$file ;; \
  113. *.cpio.Z | *.cpio.gz | *.cgz | *.mcz) \
  114. gzip -dc $$file | $(TOOLS_DIR)/cpio -i -d ;; \
  115. *.tar.Z | *.tar.gz | *.taz | *.tgz) \
  116. gzip -dc $$file | tar -xf - ;; \
  117. *.cpio.bz2 | *.cbz) \
  118. bzip2 -dc $$file | $(TOOLS_DIR)/cpio -i -d ;; \
  119. *.tar.bz2 | *.tbz | *.tbz2) \
  120. bzip2 -dc $$file | tar -xf - ;; \
  121. *.zip) \
  122. cat $$file | $(TOOLS_DIR)/cpio -ivd -H zip ;; \
  123. *.arm) \
  124. cp $$file ${WRKDIR} ;; \
  125. *) \
  126. echo "Cannot extract '$$file'" >&2; \
  127. false ;; \
  128. esac; done
  129. ifeq ($(VERBOSE),1)
  130. QUIET:=
  131. else
  132. QUIET:= --quiet
  133. endif
  134. FETCH_CMD?= wget --timeout=30 $(QUIET)
  135. include $(TOPDIR)/mk/mirrors.mk