vars.mk 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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. BASE_DIR:= $(TOPDIR)
  12. DISTDIR?= ${BASE_DIR}/dl
  13. BUILD_DIR:= ${BASE_DIR}/build_${ADK_TARGET_SYSTEM}_${CPU_ARCH}_${ADK_TARGET_LIBC}
  14. BUILD_DIR_PFX:= $(BASE_DIR)/build_*
  15. STAGING_PKG_DIR:= ${BASE_DIR}/pkg_${ADK_TARGET_SYSTEM}_${CPU_ARCH}_${ADK_TARGET_LIBC}
  16. STAGING_PKG_DIR_PFX:= ${BASE_DIR}/pkg_*
  17. STAGING_HOST_DIR:= ${BASE_DIR}/host_${CPU_ARCH}_${ADK_TARGET_SUFFIX}_${ADK_TARGET_LIBC}
  18. STAGING_HOST_DIR_PFX:= ${BASE_DIR}/host_*
  19. STAGING_JAVA_HOST_DIR:= ${BASE_DIR}/jhost
  20. # use headers and foo-config from system
  21. ifeq ($(ADK_NATIVE),y)
  22. STAGING_TARGET_DIR:=
  23. SCRIPT_TARGET_DIR:= /usr/bin
  24. else
  25. STAGING_TARGET_DIR:= ${BASE_DIR}/target_${CPU_ARCH}_${ADK_TARGET_SUFFIX}_${ADK_TARGET_LIBC}
  26. SCRIPT_TARGET_DIR:= ${STAGING_TARGET_DIR}/scripts
  27. endif
  28. STAGING_DIR:= ${BASE_DIR}/target_${CPU_ARCH}_${ADK_TARGET_SUFFIX}_${ADK_TARGET_LIBC}
  29. STAGING_TARGET_DIR_PFX:=${BASE_DIR}/target_*
  30. # relation from STAGING_HOST_DIR to STAGING_TARGET_DIR (for gcc to find
  31. # its sysroot while staying relocatable)
  32. STAGING_HOST2TARGET:= ../target_${CPU_ARCH}_${ADK_TARGET_SUFFIX}_${ADK_TARGET_LIBC}
  33. TOOLCHAIN_BUILD_DIR= $(BASE_DIR)/toolchain_build_${CPU_ARCH}_${ADK_TARGET_SUFFIX}_${ADK_TARGET_LIBC}
  34. TOOLCHAIN_BUILD_DIR_PFX=$(BASE_DIR)/toolchain_build_*
  35. TOOLS_BUILD_DIR= $(BASE_DIR)/tools_build
  36. JTOOLS_BUILD_DIR= $(BASE_DIR)/jtools_build
  37. TOOLS_DIR:= $(BASE_DIR)/bin/tools
  38. SCRIPT_DIR:= $(BASE_DIR)/scripts
  39. BIN_DIR:= $(BASE_DIR)/bin/${ADK_TARGET_SYSTEM}_${CPU_ARCH}_${ADK_TARGET_LIBC}
  40. BIN_DIR_PFX:= $(BASE_DIR)/bin
  41. PACKAGE_DIR:= $(BIN_DIR)/packages
  42. TARGET_DIR:= $(BASE_DIR)/root_${ADK_TARGET_SYSTEM}_${CPU_ARCH}_${ADK_TARGET_LIBC}
  43. TARGET_DIR_PFX:= $(BASE_DIR)/root_*
  44. TARGET_PATH= ${SCRIPT_DIR}:${TOOLS_DIR}:${STAGING_HOST_DIR}/bin:${STAGING_HOST_DIR}/usr/bin:${STAGING_TARGET_DIR}/scripts:${_PATH}
  45. AUTOTOOL_PATH= ${TOOLS_DIR}:${STAGING_HOST_DIR}/bin:${STAGING_HOST_DIR}/usr/bin:${STAGING_TARGET_DIR}/scripts:${_PATH}
  46. REAL_GNU_TARGET_NAME= $(CPU_ARCH)-$(ADK_VENDOR)-linux-$(ADK_TARGET_SUFFIX)
  47. GNU_TARGET_NAME= $(CPU_ARCH)-$(ADK_VENDOR)-linux
  48. ifeq ($(ADK_DISABLE_HONOUR_CFLAGS),)
  49. GCC_CHECK:= GCC_HONOUR_COPTS=2
  50. else
  51. GCC_CHECK:=
  52. endif
  53. ifeq ($(CPU_ARCH),arm)
  54. QEMU:= qemu-arm
  55. endif
  56. ifeq ($(CPU_ARCH),mipsel)
  57. QEMU:= qemu-mipsel
  58. endif
  59. ifeq ($(CPU_ARCH),mips64el)
  60. QEMU:= qemu-mipsel
  61. endif
  62. ifeq ($(CPU_ARCH),mips)
  63. QEMU:= qemu-mips
  64. endif
  65. ifeq ($(CPU_ARCH),i486)
  66. QEMU:= qemu-i386
  67. endif
  68. ifeq ($(CPU_ARCH),i586)
  69. QEMU:= qemu-i386
  70. endif
  71. ifeq ($(CPU_ARCH),i686)
  72. QEMU:= qemu-i386
  73. endif
  74. ifeq ($(CPU_ARCH),x86_64)
  75. QEMU:= qemu-x86_64
  76. endif
  77. ifeq ($(ADK_NATIVE),y)
  78. TARGET_CROSS:=
  79. TARGET_COMPILER_PREFIX?=
  80. CONFIGURE_TRIPLE:=
  81. else
  82. TARGET_CROSS:= $(STAGING_HOST_DIR)/bin/$(REAL_GNU_TARGET_NAME)-
  83. TARGET_COMPILER_PREFIX?=${TARGET_CROSS}
  84. CONFIGURE_TRIPLE:= --build=${GNU_HOST_NAME} --host=${GNU_TARGET_NAME} --target=${GNU_TARGET_NAME}
  85. endif
  86. ifneq ($(strip ${ADK_USE_CCACHE}),)
  87. TARGET_COMPILER_PREFIX=ccache ${TARGET_CROSS}
  88. endif
  89. # target compiler flags
  90. TARGET_CC:= ${TARGET_COMPILER_PREFIX}gcc
  91. TARGET_CXX:= ${TARGET_COMPILER_PREFIX}g++
  92. TARGET_LD:= ${TARGET_COMPILER_PREFIX}ld
  93. TARGET_CPPFLAGS:=
  94. TARGET_CFLAGS:= $(TARGET_CFLAGS_ARCH) -fwrapv -fno-ident -fhonour-copts $(ADK_TARGET_ABI_CFLAGS)
  95. TARGET_CFLAGS_LIBC:= $(TARGET_CFLAGS_ARCH) -fwrapv -fno-ident -fhonour-copts $(TARGET_OPTIMIZATION)
  96. TARGET_CXXFLAGS:= $(TARGET_CFLAGS_ARCH) -fwrapv -fno-ident
  97. TARGET_LDFLAGS:= -L$(STAGING_TARGET_DIR)/lib -L$(STAGING_TARGET_DIR)/usr/lib \
  98. -Wl,-O2 -Wl,-rpath -Wl,/usr/lib \
  99. -Wl,-rpath-link -Wl,${STAGING_TARGET_DIR}/usr/lib \
  100. $(ADK_TARGET_ABI_LDFLAGS)
  101. ifneq ($(ADK_NATIVE),)
  102. TARGET_CPPFLAGS:=
  103. TARGET_CFLAGS:= $(TARGET_CFLAGS_ARCH) -fwrapv -fno-ident -fhonour-copts
  104. TARGET_LDFLAGS:=
  105. endif
  106. ifneq ($(ADK_TOOLCHAIN_GCC_USE_SSP),)
  107. TARGET_CFLAGS+= -fstack-protector
  108. TARGET_CXXFLAGS+= -fstack-protector
  109. TARGET_LDFLAGS+= -fstack-protector
  110. endif
  111. ifneq ($(ADK_TOOLCHAIN_GCC_USE_LTO),)
  112. TARGET_CFLAGS+= -flto
  113. TARGET_CXXFLAGS+= -flto
  114. TARGET_LDFLAGS+= -flto
  115. endif
  116. ifneq ($(ADK_DEBUG),)
  117. TARGET_CFLAGS+= -g3 -fno-omit-frame-pointer
  118. else
  119. TARGET_CPPFLAGS+= -DNDEBUG
  120. TARGET_CFLAGS+= -fomit-frame-pointer $(TARGET_OPTIMIZATION)
  121. # stop generating eh_frame stuff
  122. TARGET_CFLAGS+= -fno-unwind-tables -fno-asynchronous-unwind-tables
  123. # always add debug information
  124. TARGET_CFLAGS+= -g3
  125. endif
  126. # A nifty macro to make testing gcc features easier (from uClibc project)
  127. check_gcc=$(shell \
  128. if $(CC_FOR_BUILD) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
  129. then echo "$(1)"; else echo "$(2)"; fi)
  130. CF_FOR_BUILD=$(call check_gcc,-fhonour-copts,)
  131. # host compiler flags
  132. CXX_FOR_BUILD?= g++
  133. CPPFLAGS_FOR_BUILD?= -I$(STAGING_HOST_DIR)/usr/include
  134. CFLAGS_FOR_BUILD= -O2 -Wall $(CF_FOR_BUILD)
  135. CXXFLAGS_FOR_BUILD?= -O2 -Wall
  136. LDFLAGS_FOR_BUILD?= -L$(STAGING_HOST_DIR)/usr/lib
  137. FLAGS_FOR_BUILD= ${CPPFLAGS_FOR_BUILD} ${CFLAGS_FOR_BUILD} ${LDFLAGS_FOR_BUILD}
  138. PATCH= ${BASH} $(SCRIPT_DIR)/patch.sh
  139. SED:= sed -i -e
  140. LINUX_DIR:= $(BUILD_DIR)/linux
  141. LINUX_HEADER_DIR:= $(STAGING_DIR)/linux-header
  142. KERNEL_MODULE_FLAGS:= ARCH=${ARCH} KERNELVERSION="2.6" \
  143. KERNEL_PATH=${LINUX_DIR} KERNELDIR=${LINUX_DIR} KERNEL_DIR=${LINUX_DIR} \
  144. PREFIX=/usr CROSS_COMPILE="${TARGET_CROSS}" \
  145. LDFLAGS="$(ADK_TARGET_KERNEL_LDFLAGS)" CFLAGS_MODULE="-fhonour-copts" V=1
  146. TARGET_CONFIGURE_OPTS= PATH='${TARGET_PATH}' \
  147. AR='$(TARGET_CROSS)ar' \
  148. AS='$(TARGET_CROSS)as' \
  149. LD='$(TARGET_CROSS)ld' \
  150. NM='$(TARGET_CROSS)nm' \
  151. RANLIB='$(TARGET_CROSS)ranlib' \
  152. STRIP='${TARGET_CROSS}strip' \
  153. OBJCOPY='${TARGET_CROSS}objcopy' \
  154. CC='$(TARGET_CC)' \
  155. GCC='$(TARGET_CC)' \
  156. CXX='$(TARGET_CXX)' \
  157. CROSS='$(TARGET_CROSS)' \
  158. ARCH=${ARCH}
  159. HOST_CONFIGURE_OPTS= CC_FOR_BUILD='${CC_FOR_BUILD}' \
  160. CPPFLAGS_FOR_BUILD='${CPPFLAGS_FOR_BUILD}' \
  161. CXX_FOR_BUILD='${CXX_FOR_BUILD}' \
  162. CFLAGS_FOR_BUILD='${CFLAGS_FOR_BUILD}' \
  163. LDFLAGS_FOR_BUILD='${LDFLAGS_FOR_BUILD}' \
  164. QEMU='$(QEMU)'
  165. PKG_SUFFIX:= $(strip $(subst ",, $(ADK_PACKAGE_SUFFIX)))
  166. ifeq ($(ADK_TARGET_PACKAGE_IPKG),y)
  167. PKG_BUILD:= PATH='${TARGET_PATH}' \
  168. ${BASH} ${SCRIPT_DIR}/ipkg-build
  169. PKG_INSTALL:= IPKG_TMP=$(BUILD_DIR)/tmp \
  170. IPKG_INSTROOT=$(TARGET_DIR) \
  171. IPKG_CONF_DIR=$(STAGING_TARGET_DIR)/etc \
  172. IPKG_OFFLINE_ROOT=$(TARGET_DIR) \
  173. TOOLS_DIR=$(TOOLS_DIR) \
  174. ${BASH} ${SCRIPT_DIR}/ipkg \
  175. -force-defaults -force-depends install
  176. PKG_STATE_DIR:= $(TARGET_DIR)/usr/lib/ipkg
  177. else
  178. PKG_BUILD:= ${BASH} ${SCRIPT_DIR}/tarpkg build
  179. PKG_INSTALL:= PKG_INSTROOT=$(TARGET_DIR) \
  180. ${BASH} ${SCRIPT_DIR}/tarpkg install
  181. PKG_STATE_DIR:= $(TARGET_DIR)/usr/lib/pkg
  182. endif
  183. ifeq ($(ADK_NATIVE),y)
  184. RSTRIP:= prefix=' ' ${BASH} ${SCRIPT_DIR}/rstrip.sh
  185. else
  186. RSTRIP:= PATH="$(TARGET_PATH)" prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh
  187. endif
  188. STATCMD:=$(shell if stat -qs .>/dev/null 2>&1; then echo 'stat -f %z';else echo 'stat -c %s';fi)
  189. EXTRACT_CMD= mkdir -p ${WRKDIR}; \
  190. cd ${WRKDIR} && \
  191. for file in ${FULLDISTFILES}; do case $$file in \
  192. *.cpio) \
  193. cat $$file | $(TOOLS_DIR)/cpio -i -d ;; \
  194. *.tar) \
  195. tar -xf $$file ;; \
  196. *.cpio.Z | *.cpio.gz | *.cgz | *.mcz) \
  197. gzip -dc $$file | $(TOOLS_DIR)/cpio -i -d ;; \
  198. *.tar.xz | *.txz) \
  199. xz -dc $$file | tar -xf - ;; \
  200. *.tar.Z | *.tar.gz | *.taz | *.tgz) \
  201. gzip -dc $$file | tar -xf - ;; \
  202. *.cpio.bz2 | *.cbz) \
  203. bzip2 -dc $$file | $(TOOLS_DIR)/cpio -i -d ;; \
  204. *.tar.bz2 | *.tbz | *.tbz2) \
  205. bzip2 -dc $$file | tar -xf - ;; \
  206. *.zip) \
  207. cat $$file | $(TOOLS_DIR)/cpio -ivd -H zip ;; \
  208. *.arm) \
  209. cp $$file ${WRKDIR} ;; \
  210. *) \
  211. echo "Cannot extract '$$file'" >&2; \
  212. false ;; \
  213. esac; done
  214. ifeq ($(VERBOSE),1)
  215. QUIET:=
  216. else
  217. QUIET:= --quiet
  218. endif
  219. FETCH_CMD?= wget --timeout=5 -t 3 $(QUIET)
  220. ifeq ($(ADK_HOST_CYGWIN),y)
  221. EXEEXT:= .exe
  222. endif
  223. include $(TOPDIR)/mk/mirrors.mk