vars.mk 4.4 KB

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