vars.mk 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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. ADK_SUFFIX:= ${ADK_TARGET_SYSTEM}
  12. ifneq ($(ADK_TARGET_LIBC),)
  13. ADK_SUFFIX:= $(ADK_SUFFIX)_$(ADK_TARGET_LIBC)
  14. endif
  15. ifneq ($(ADK_TARGET_CPU_TYPE),)
  16. ADK_SUFFIX:= $(ADK_SUFFIX)_$(ADK_TARGET_CPU_TYPE)
  17. endif
  18. ifneq ($(ADK_TARGET_ENDIAN_SUFFIX),)
  19. ADK_SUFFIX:= $(ADK_SUFFIX)$(ADK_TARGET_ENDIAN_SUFFIX)
  20. endif
  21. ifneq ($(ADK_TARGET_FLOAT),)
  22. ADK_SUFFIX:= $(ADK_SUFFIX)_$(ADK_TARGET_FLOAT)
  23. endif
  24. ifneq ($(ADK_TARGET_ABI),)
  25. ADK_SUFFIX:= $(ADK_SUFFIX)_$(ADK_TARGET_ABI)
  26. endif
  27. ifneq ($(ADK_TARGET_BINFMT),)
  28. ADK_SUFFIX:= $(ADK_SUFFIX)_$(ADK_TARGET_BINFMT)
  29. endif
  30. ifeq ($(ADK_TARGET_WITH_MMU),)
  31. ADK_SUFFIX:= $(ADK_SUFFIX)_nommu
  32. endif
  33. # some global dirs
  34. BASE_DIR:= $(ADK_TOPDIR)
  35. ifeq ($(ADK_DL_DIR),)
  36. DL_DIR?= $(BASE_DIR)/dl
  37. else
  38. DL_DIR?= $(ADK_DL_DIR)
  39. endif
  40. SCRIPT_DIR:= $(BASE_DIR)/scripts
  41. STAGING_HOST_DIR:= ${BASE_DIR}/host_${GNU_HOST_NAME}
  42. HOST_BUILD_DIR:= ${BASE_DIR}/host_build_${GNU_HOST_NAME}
  43. TOOLCHAIN_DIR:= ${BASE_DIR}/toolchain_${ADK_SUFFIX}
  44. # dirs for cleandir
  45. FW_DIR_PFX:= $(BASE_DIR)/firmware
  46. BUILD_DIR_PFX:= $(BASE_DIR)/build_*
  47. STAGING_PKG_DIR_PFX:= ${BASE_DIR}/pkg_*
  48. STAGING_TARGET_DIR_PFX:=${BASE_DIR}/target_*
  49. TOOLCHAIN_DIR_PFX= $(BASE_DIR)/toolchain_*
  50. STAGING_HOST_DIR_PFX:= ${BASE_DIR}/host_*
  51. TARGET_DIR_PFX:= $(BASE_DIR)/root_*
  52. TARGET_DIR:= $(BASE_DIR)/root_${ADK_SUFFIX}
  53. FW_DIR:= $(BASE_DIR)/firmware/${ADK_SUFFIX}
  54. BUILD_DIR:= ${BASE_DIR}/build_${ADK_SUFFIX}
  55. STAGING_TARGET_DIR:= ${BASE_DIR}/target_${ADK_SUFFIX}
  56. STAGING_PKG_DIR:= ${BASE_DIR}/pkg_${ADK_SUFFIX}
  57. STAGING_HOST2TARGET:= ../../target_${ADK_SUFFIX}
  58. TOOLCHAIN_BUILD_DIR= $(BASE_DIR)/toolchain_build_${ADK_SUFFIX}
  59. PACKAGE_DIR:= $(FW_DIR)/packages
  60. SCRIPT_TARGET_DIR:= ${STAGING_TARGET_DIR}/scripts
  61. # PATH variables
  62. TARGET_PATH= ${SCRIPT_DIR}:${STAGING_TARGET_DIR}/scripts:${TOOLCHAIN_DIR}/usr/bin:${STAGING_HOST_DIR}/usr/bin:${_PATH}
  63. HOST_PATH= ${SCRIPT_DIR}:${TOOLCHAIN_DIR}/usr/bin:${STAGING_HOST_DIR}/usr/bin:${STAGING_HOST_DIR}/usr/sbin:${_PATH}
  64. AUTOTOOL_PATH= ${TOOLCHAIN_DIR}/usr/bin:${STAGING_HOST_DIR}/usr/bin:${STAGING_TARGET_DIR}/scripts:${_PATH}
  65. ifeq ($(ADK_TARGET_UCLINUX),y)
  66. ADK_TARGET_LINUXTYPE:= uclinux
  67. else
  68. ADK_TARGET_LINUXTYPE:= linux
  69. endif
  70. GNU_TARGET_NAME:= $(ADK_TARGET_CPU_ARCH)-$(ADK_VENDOR)-$(ADK_TARGET_LINUXTYPE)-$(ADK_TARGET_SUFFIX)
  71. ifeq ($(ADK_TARGET_ARCH_C6X),y)
  72. GNU_TARGET_NAME:= $(ADK_TARGET_CPU_ARCH)-$(ADK_TARGET_LINUXTYPE)
  73. endif
  74. ifeq ($(ADK_TARGET_OS_BAREMETAL),y)
  75. GNU_TARGET_NAME:= $(ADK_TARGET_CPU_ARCH)-$(ADK_TARGET_SUFFIX)
  76. endif
  77. ifeq ($(ADK_TARGET_OS_FROSTED),y)
  78. GNU_TARGET_NAME:= $(ADK_TARGET_CPU_ARCH)-$(ADK_TARGET_OS)-$(ADK_TARGET_SUFFIX)
  79. endif
  80. ifeq ($(ADK_TARGET_OS_RTEMS),y)
  81. GNU_TARGET_NAME:= $(ADK_TARGET_CPU_ARCH)-$(ADK_TARGET_OS)
  82. endif
  83. ifeq ($(ADK_TARGET_OS_ZEPHYR),y)
  84. GNU_TARGET_NAME:= $(ADK_TARGET_CPU_ARCH)-$(ADK_TARGET_OS)
  85. endif
  86. TARGET_CROSS:= $(TOOLCHAIN_DIR)/usr/bin/$(GNU_TARGET_NAME)-
  87. TARGET_COMPILER_PREFIX?=${TARGET_CROSS}
  88. CONFIGURE_TRIPLE:= --build=${GNU_HOST_NAME} \
  89. --host=${GNU_TARGET_NAME} \
  90. --target=${GNU_TARGET_NAME}
  91. # target tools
  92. ifeq ($(ADK_BUILD_COMPILER_GCC),y)
  93. TARGET_CC:= ${TARGET_COMPILER_PREFIX}gcc
  94. TARGET_CXX:= ${TARGET_COMPILER_PREFIX}g++
  95. TARGET_CC_NO_CCACHE:= ${TARGET_CC}
  96. TARGET_CXX_NO_CCACHE:= ${TARGET_CXX}
  97. endif
  98. ifeq ($(ADK_BUILD_COMPILER_LLVM),y)
  99. TARGET_CC:= clang --target=${GNU_TARGET_NAME} --sysroot=$(STAGING_TARGET_DIR)
  100. TARGET_CXX:= clang++ --target=${GNU_TARGET_NAME} --sysroot=$(STAGING_TARGET_DIR)
  101. TARGET_LDFLAGS:= -fuse-ld=lld -stdlib=libc++
  102. endif
  103. # gcc specific
  104. ifeq ($(ADK_BUILD_COMPILER_GCC),y)
  105. ifneq ($(strip ${ADK_USE_CCACHE}),)
  106. TARGET_CC:= $(STAGING_HOST_DIR)/usr/bin/ccache ${TARGET_CC_NO_CCACHE}
  107. TARGET_CXX:= $(STAGING_HOST_DIR)/usr/bin/ccache ${TARGET_CXX_NO_CCACHE}
  108. endif
  109. # for x86_64 x32 ABI we need to extend TARGET_CC/TARGET_CXX
  110. ifeq ($(ADK_TARGET_ABI_X32),y)
  111. TARGET_CC+= $(ADK_TARGET_ABI_CFLAGS)
  112. TARGET_CXX+= $(ADK_TARGET_ABI_CFLAGS)
  113. endif
  114. TARGET_LD:= ${TARGET_COMPILER_PREFIX}ld
  115. ifneq ($(ADK_TARGET_USE_LTO),)
  116. TARGET_AR:= ${TARGET_COMPILER_PREFIX}gcc-ar
  117. TARGET_RANLIB:= ${TARGET_COMPILER_PREFIX}gcc-ranlib
  118. else
  119. TARGET_AR:= ${TARGET_COMPILER_PREFIX}ar
  120. TARGET_RANLIB:= ${TARGET_COMPILER_PREFIX}ranlib
  121. endif
  122. TARGET_CPPFLAGS:=
  123. TARGET_CFLAGS:= -fwrapv -fno-ident
  124. TARGET_CXXFLAGS:= -fwrapv -fno-ident
  125. TARGET_LDFLAGS:= -L$(STAGING_TARGET_DIR)/lib -L$(STAGING_TARGET_DIR)/usr/lib \
  126. -Wl,-O1 -Wl,-rpath -Wl,/usr/lib \
  127. -Wl,-rpath-link -Wl,${STAGING_TARGET_DIR}/usr/lib
  128. # for architectures where gcc --with-cpu matches -mcpu=
  129. ifneq ($(ADK_TARGET_GCC_CPU),)
  130. TARGET_CFLAGS+= -mcpu=$(ADK_TARGET_GCC_CPU)
  131. TARGET_CXXFLAGS+= -mcpu=$(ADK_TARGET_GCC_CPU)
  132. endif
  133. # for archiectures where gcc --with-arch matches -march=
  134. ifneq ($(ADK_TARGET_GCC_ARCH),)
  135. TARGET_CFLAGS+= -march=$(ADK_TARGET_GCC_ARCH)
  136. TARGET_CXXFLAGS+= -march=$(ADK_TARGET_GCC_ARCH)
  137. endif
  138. ifneq ($(ADK_TARGET_CPU_FLAGS),)
  139. TARGET_CFLAGS+= $(ADK_TARGET_CPU_FLAGS)
  140. TARGET_CXXFLAGS+= $(ADK_TARGET_CPU_FLAGS)
  141. TARGET_LDFLAGS+= $(ADK_TARGET_CPU_FLAGS)
  142. endif
  143. ifneq ($(ADK_TARGET_FPU),)
  144. TARGET_CFLAGS+= -mfpu=$(ADK_TARGET_FPU)
  145. TARGET_CXXFLAGS+= -mfpu=$(ADK_TARGET_FPU)
  146. endif
  147. ifneq ($(ADK_TARGET_FLOAT),)
  148. ifeq ($(ADK_TARGET_ARCH_ARM),y)
  149. TARGET_CFLAGS+= -mfloat-abi=$(ADK_TARGET_FLOAT)
  150. TARGET_CXXFLAGS+= -mfloat-abi=$(ADK_TARGET_FLOAT)
  151. endif
  152. ifeq ($(ADK_TARGET_ARCH_MIPS),y)
  153. TARGET_CFLAGS+= -m$(ADK_TARGET_FLOAT)-float
  154. TARGET_CXXFLAGS+= -m$(ADK_TARGET_FLOAT)-float
  155. endif
  156. endif
  157. ifeq ($(ADK_TARGET_BINFMT_FLAT)$(ADK_TARGET_OS_FROSTED),y)
  158. TARGET_LDFLAGS+= -Wl,-elf2flt
  159. TARGET_CFLAGS+= -Wl,-elf2flt
  160. TARGET_CXXFLAGS+= -Wl,-elf2flt
  161. endif
  162. ifeq ($(ADK_TARGET_BINFMT_FLAT_SEP_DATA),y)
  163. TARGET_CFLAGS+= -msep-data
  164. TARGET_CXXFLAGS+= -msep-data
  165. endif
  166. ifeq ($(ADK_TARGET_BINFMT_FLAT_SHARED),y)
  167. TARGET_LDFLAGS+= -mid-shared-library
  168. endif
  169. # security optimization, see http://www.akkadia.org/drepper/dsohowto.pdf
  170. ifneq ($(ADK_TARGET_USE_LD_RELRO),)
  171. TARGET_LDFLAGS+= -Wl,-z,relro
  172. endif
  173. ifneq ($(ADK_TARGET_USE_LD_BIND_NOW),)
  174. TARGET_LDFLAGS+= -Wl,-z,now
  175. endif
  176. # needed for musl ppc
  177. ifeq ($(ADK_TARGET_ARCH_PPC),y)
  178. ifeq ($(ADK_TARGET_LIB_MUSL),y)
  179. TARGET_LDFLAGS+= -Wl,--secure-plt
  180. endif
  181. endif
  182. ifeq ($(ADK_TARGET_USE_STATIC_LIBS_ONLY)$(ADK_TARGET_USE_STATIC_AND_SHARED_LIBS),y)
  183. TARGET_CFLAGS+= -static
  184. TARGET_CXXFLAGS+= -static
  185. TARGET_LDFLAGS+= -static
  186. endif
  187. ifneq ($(ADK_TARGET_USE_SSP),)
  188. TARGET_CFLAGS+= -fstack-protector-all --param=ssp-buffer-size=4
  189. TARGET_CXXFLAGS+= -fstack-protector-all --param=ssp-buffer-size=4
  190. TARGET_LDFLAGS+= -fstack-protector-all
  191. endif
  192. ifneq ($(ADK_TARGET_USE_LD_GC),)
  193. TARGET_CFLAGS+= -fdata-sections -ffunction-sections
  194. TARGET_CXXFLAGS+= -fdata-sections -ffunction-sections
  195. TARGET_LDFLAGS+= -Wl,--gc-sections
  196. endif
  197. ifneq ($(ADK_TARGET_USE_LTO),)
  198. TARGET_CFLAGS+= -flto
  199. TARGET_CXXFLAGS+= -flto
  200. TARGET_LDFLAGS+= -flto
  201. endif
  202. # performance optimization, see http://www.akkadia.org/drepper/dsohowto.pdf
  203. ifneq ($(ADK_TARGET_USE_GNU_HASHSTYLE),)
  204. TARGET_LDFLAGS+= -Wl,--hash-style=gnu
  205. endif
  206. # special operating system flags
  207. ifeq ($(ADK_TARGET_OS_FROSTED),y)
  208. TARGET_CFLAGS+= -fPIC -mlong-calls -fno-common -msingle-pic-base -mno-pic-data-is-text-relative
  209. endif
  210. # special architecture optimization flags
  211. ifeq ($(ADK_TARGET_ARCH_XTENSA),y)
  212. ifeq ($(ADK_TARGET_BIG_ENDIAN),)
  213. ifeq ($(ADK_TARGET_LIB_NEWLIB),)
  214. TARGET_CFLAGS+= -mlongcalls -mauto-litpools
  215. TARGET_CXXFLAGS+= -mlongcalls -mauto-litpools
  216. endif
  217. endif
  218. endif
  219. ifeq ($(ADK_TARGET_ARCH_MICROBLAZE),y)
  220. TARGET_CFLAGS+= -mxl-barrel-shift
  221. TARGET_CXXFLAGS+= -mxl-barrel-shift
  222. endif
  223. endif
  224. # end gcc specific
  225. # add configured compiler flags for optimization
  226. TARGET_CFLAGS+= $(ADK_TARGET_CFLAGS_OPT)
  227. TARGET_CXXFLAGS+= $(ADK_TARGET_CFLAGS_OPT)
  228. # add compiler flags for debug information
  229. ifneq ($(ADK_DEBUG),)
  230. TARGET_CFLAGS+= -g3
  231. TARGET_CXXFLAGS+= -g3
  232. endif
  233. ifneq ($(ADK_DEBUG),)
  234. ifeq ($(ADK_TARGET_ARCH_ARM_WITH_THUMB),)
  235. TARGET_CFLAGS+= -fno-omit-frame-pointer
  236. TARGET_CXXFLAGS+= -fno-omit-frame-pointer
  237. endif
  238. TARGET_CFLAGS+= -funwind-tables -fasynchronous-unwind-tables
  239. TARGET_CXXFLAGS+= -funwind-tables -fasynchronous-unwind-tables
  240. else
  241. TARGET_CPPFLAGS+= -DNDEBUG
  242. TARGET_CFLAGS+= -fomit-frame-pointer
  243. TARGET_CXXFLAGS+= -fomit-frame-pointer
  244. # stop generating eh_frame stuff
  245. TARGET_CFLAGS+= -fno-unwind-tables -fno-asynchronous-unwind-tables
  246. TARGET_CXXFLAGS+= -fno-unwind-tables -fno-asynchronous-unwind-tables
  247. ifeq ($(ADK_TARGET_CPU_CF),y)
  248. TARGET_CFLAGS+= -fno-dwarf2-cfi-asm
  249. TARGET_CXXFLAGS+= -fno-dwarf2-cfi-asm
  250. endif
  251. endif
  252. ifeq ($(ADK_TARGET_ARCH_ARM),y)
  253. ifeq ($(ADK_TARGET_ARCH_ARM_WITH_NEON),y)
  254. TARGET_CFLAGS+= -ffast-math -funsafe-math-optimizations
  255. TARGET_CXXFLAGS+= -ffast-math -funsafe-math-optimizations
  256. endif
  257. ifeq ($(ADK_TARGET_ARCH_ARM_WITH_THUMB),y)
  258. TARGET_CFLAGS+= -mthumb -Wa,-mimplicit-it=thumb -mno-thumb-interwork
  259. TARGET_CXXFLAGS+= -mthumb -Wa,-mimplicit-it=thumb -mno-thumb-interwork
  260. else
  261. TARGET_CFLAGS+= -marm
  262. TARGET_CXXFLAGS+= -marm
  263. endif
  264. endif
  265. # host compiler and linker flags
  266. HOST_CPPFLAGS:= -I$(STAGING_HOST_DIR)/usr/include
  267. ifeq ($(OS_FOR_BUILD),Darwin)
  268. HOST_LDFLAGS:= -L$(STAGING_HOST_DIR)/usr/lib
  269. else
  270. HOST_LDFLAGS:= -L$(STAGING_HOST_DIR)/usr/lib -Wl,-rpath -Wl,${STAGING_HOST_DIR}/usr/lib
  271. endif
  272. ifneq (${ADK_UPDATE_PATCHES_GIT},)
  273. PATCH= PATH='${HOST_PATH}' ${BASH} $(SCRIPT_DIR)/patch_git.sh
  274. else
  275. PATCH= PATH='${HOST_PATH}' ${BASH} $(SCRIPT_DIR)/patch.sh
  276. endif
  277. PATCHP0= PATH='${HOST_PATH}' patch -p0
  278. ifeq ($(ADK_STATIC_TOOLCHAIN),y)
  279. HOST_STATIC_CFLAGS:= -static -Wl,-static
  280. HOST_STATIC_CXXFLAGS:= -static -Wl,-static
  281. HOST_STATIC_LDFLAGS:= -Wl,-static
  282. endif
  283. SED:= PATH='${HOST_PATH}' sed -i -e
  284. XZ:= PATH='${HOST_PATH}' xz
  285. CPIO:= PATH='${HOST_PATH}' cpio
  286. LINUX_DIR:= $(BUILD_DIR)/$(ADK_TARGET_OS)
  287. KERNEL_MODULE_FLAGS:= ARCH=${ADK_TARGET_KARCH} \
  288. PREFIX=/usr \
  289. KERNEL_PATH=${LINUX_DIR} \
  290. KERNELDIR=${LINUX_DIR} \
  291. CROSS_COMPILE="${TARGET_CROSS}" \
  292. V=1
  293. COMMON_ENV= CONFIG_SHELL='$(strip ${SHELL})' \
  294. AUTOM4TE='${STAGING_HOST_DIR}/usr/bin/autom4te' \
  295. M4='${STAGING_HOST_DIR}/usr/bin/m4' \
  296. LIBTOOLIZE='${STAGING_HOST_DIR}/usr/bin/libtoolize'
  297. ifneq ($(ADK_TARGET_USE_LTO),)
  298. TOOLS_ENV= AR='$(TARGET_CROSS)gcc-ar' \
  299. RANLIB='$(TARGET_CROSS)gcc-ranlib' \
  300. NM='$(TARGET_CROSS)gcc-nm'
  301. else
  302. TOOLS_ENV= AR='$(TARGET_CROSS)ar' \
  303. RANLIB='$(TARGET_CROSS)ranlib' \
  304. NM='$(TARGET_CROSS)nm'
  305. endif
  306. TARGET_ENV= $(TOOLS_ENV) \
  307. AS='$(TARGET_CROSS)as' \
  308. LD='$(TARGET_CROSS)ld' \
  309. STRIP='$(TARGET_CROSS)strip' \
  310. OBJCOPY='$(TARGET_CROSS)objcopy' \
  311. CC='$(TARGET_CC)' \
  312. GCC='$(TARGET_CC)' \
  313. CXX='$(TARGET_CXX)' \
  314. CROSS='$(TARGET_CROSS)' \
  315. CROSS_COMPILE='$(TARGET_CROSS)' \
  316. CFLAGS='$(TARGET_CFLAGS)' \
  317. CXXFLAGS='$(TARGET_CXXFLAGS)' \
  318. CPPFLAGS='$(TARGET_CPPFLAGS)' \
  319. LDFLAGS='$(TARGET_LDFLAGS)' \
  320. CC_FOR_BUILD='$(HOST_CC)' \
  321. CXX_FOR_BUILD='$(HOST_CXX)' \
  322. CPPFLAGS_FOR_BUILD='$(HOST_CPPFLAGS)' \
  323. CFLAGS_FOR_BUILD='$(HOST_CFLAGS)' \
  324. CXXFLAGS_FOR_BUILD='$(HOST_CXXFLAGS)' \
  325. LDFLAGS_FOR_BUILD='$(HOST_LDFLAGS)' \
  326. LIBS_FOR_BUILD='$(HOST_LIBS)'
  327. HOST_ENV= CC='$(HOST_CC)' \
  328. CXX='$(HOST_CXX)' \
  329. CPPFLAGS='$(HOST_CPPFLAGS)' \
  330. CFLAGS='$(HOST_CFLAGS)' \
  331. CXXFLAGS='$(HOST_CXXFLAGS)' \
  332. LDFLAGS='$(HOST_LDFLAGS)' \
  333. CC_FOR_BUILD='$(HOST_CC)' \
  334. CFLAGS_FOR_BUILD='$(HOST_CFLAGS)'
  335. PKG_SUFFIX:= $(strip $(subst ",, $(ADK_PACKAGE_SUFFIX)))
  336. ifeq ($(ADK_TARGET_PACKAGE_IPKG),y)
  337. PKG_BUILD:= ${BASH} ${SCRIPT_DIR}/ipkg-build
  338. PKG_INSTALL:= PATH='${HOST_PATH}' \
  339. IPKG_TMP=$(BUILD_DIR)/tmp \
  340. IPKG_INSTROOT=$(TARGET_DIR) \
  341. IPKG_CONF_DIR=$(STAGING_TARGET_DIR)/etc \
  342. IPKG_OFFLINE_ROOT=$(TARGET_DIR) \
  343. BIN_DIR=$(STAGING_HOST_DIR)/usr/bin \
  344. ${BASH} ${SCRIPT_DIR}/ipkg \
  345. -force-defaults -force-depends install
  346. PKG_STATE_DIR:= $(TARGET_DIR)/usr/lib/ipkg
  347. endif
  348. ifeq ($(ADK_TARGET_PACKAGE_OPKG),y)
  349. PKG_BUILD:= ${BASH} ${SCRIPT_DIR}/ipkg-build
  350. PKG_INSTALL:= PATH='${HOST_PATH}' \
  351. IPKG_TMP=$(BUILD_DIR)/tmp \
  352. IPKG_INSTROOT=$(TARGET_DIR) \
  353. IPKG_CONF_DIR=$(STAGING_TARGET_DIR)/etc \
  354. IPKG_OFFLINE_ROOT=$(TARGET_DIR) \
  355. BIN_DIR=$(STAGING_HOST_DIR)/usr/bin \
  356. ${BASH} ${SCRIPT_DIR}/ipkg \
  357. -force-defaults -force-depends install
  358. PKG_STATE_DIR:= $(TARGET_DIR)/usr/lib/opkg
  359. endif
  360. ifeq ($(ADK_TARGET_PACKAGE_TXZ),y)
  361. PKG_BUILD:= ${BASH} ${SCRIPT_DIR}/tarpkg build
  362. PKG_INSTALL:= PKG_INSTROOT='$(TARGET_DIR)' \
  363. PATH='${HOST_PATH}' ${BASH} ${SCRIPT_DIR}/tarpkg install
  364. PKG_STATE_DIR:= $(TARGET_DIR)/usr/lib/pkg
  365. endif
  366. RSTRIP:= PATH="$(TARGET_PATH)" prefix='${TARGET_CROSS}' ${BASH} ${SCRIPT_DIR}/rstrip.sh
  367. STATCMD:=$(shell if stat -qs .>/dev/null 2>&1; then echo 'stat -f %z';else echo 'stat -c %s';fi)
  368. EXTRACT_CMD= PATH='${HOST_PATH}'; mkdir -p ${WRKDIR}; \
  369. cd ${WRKDIR} && \
  370. for file in ${FULLDISTFILES}; do case $$file in \
  371. *.cpio) \
  372. cat $$file | cpio -i -d ;; \
  373. *.tar) \
  374. PATH='$(HOST_PATH)' tar -xf $$file ;; \
  375. *.cpio.Z | *.cpio.gz | *.cgz | *.mcz) \
  376. gzip -dc $$file | cpio -i -d ;; \
  377. *.tar.xz | *.txz) \
  378. xz -dc $$file | PATH='$(HOST_PATH)' tar -xf - ;; \
  379. *.tar.Z | *.tar.gz | *.taz | *.tgz) \
  380. gzip -dc $$file | PATH='$(HOST_PATH)' tar -xf - ;; \
  381. *.cpio.bz2 | *.cbz) \
  382. bzip2 -dc $$file | cpio -i -d ;; \
  383. *.tar.bz2 | *.tbz | *.tbz2) \
  384. bzip2 -dc $$file | PATH='$(HOST_PATH)' tar -xf - ;; \
  385. *.tar.lz | *.tlz) \
  386. lzip -dc $$file | PATH='$(HOST_PATH)' tar -xf - ;; \
  387. *.zip) \
  388. unzip -d ${WRKDIR} $$file ;; \
  389. *.arm|*.jar|*.ids.gz) \
  390. mkdir ${WRKBUILD}; cp $$file ${WRKBUILD} ;; \
  391. *.bin) \
  392. sh $$file --force --auto-accept ;; \
  393. *) \
  394. echo "Cannot extract '$$file'" >&2; \
  395. false ;; \
  396. esac; done
  397. ifneq (,$(filter CYGWIN%,${OS_FOR_BUILD}))
  398. EXEEXT:= .exe
  399. endif
  400. include $(ADK_TOPDIR)/mk/mirrors.mk