vars.mk 14 KB

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