vars.mk 7.3 KB

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