prereq.sh 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. #!/bin/sh
  2. # This file is part of the OpenADK project. OpenADK is copyrighted
  3. # material, please see the LICENCE file in the top-level directory.
  4. # resolve prerequisites for OpenADK build
  5. topdir=$(pwd)
  6. target="$@"
  7. flags="$MAKEFLAGS"
  8. out=0
  9. mirror=http://distfiles.openadk.org
  10. makever=4.1
  11. bashver=4.3.30
  12. # detect operating system
  13. os=$(env uname)
  14. osver=$(env uname -r)
  15. printf " ---> $os $osver for build detected.\n"
  16. # check if the filesystem is case sensitive
  17. rm -f foo
  18. echo >FOO
  19. if [ -e foo ]; then
  20. printf "ERROR: OpenADK cannot be built in a case-insensitive file system."
  21. case $os in
  22. CYG*)
  23. printf "Building OpenADK on $os needs a small registry change."
  24. printf "http://cygwin.com/cygwin-ug-net/using-specialnames.html"
  25. ;;
  26. Darwin*)
  27. printf "Building OpenADK on $os needs a case-sensitive disk partition."
  28. printf "For Snow Leopard and above you can use diskutil to resize your existing disk."
  29. printf "Example: sudo diskutil resizeVolume disk0s2 90G 1 jhfsx adk 30G"
  30. printf "For older versions you might consider to use a disk image:"
  31. printf "hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 30g ~/openadk.dmg"
  32. ;;
  33. esac
  34. rm -f FOO
  35. exit 1
  36. fi
  37. rm -f FOO
  38. # do we have a download tool?
  39. tools="curl wget"
  40. for tool in $tools; do
  41. printf " ---> checking if $tool is installed.. "
  42. if which $tool >/dev/null; then
  43. printf "found\n"
  44. case $tool in
  45. curl)
  46. FETCHCMD="$(which $tool) -k -f -s -o "
  47. ;;
  48. wget)
  49. FETCHCMD="$(which $tool) --no-check-certificate -q -O "
  50. ;;
  51. esac
  52. break
  53. else
  54. printf "not found\n"
  55. continue
  56. fi
  57. done
  58. if [ -z "$FETCHCMD" ]; then
  59. printf "ERROR: no download tool found. Fatal error.\n"
  60. exit 1
  61. fi
  62. # do we have a checksum tool?
  63. tools="sha256sum sha256 cksum shasum"
  64. for tool in $tools; do
  65. printf " ---> checking if $tool is installed.. "
  66. if which $tool >/dev/null 2>/dev/null; then
  67. printf "found\n"
  68. # check if cksum is usable
  69. case $tool in
  70. sha256sum)
  71. SHA256=$(which $tool)
  72. ;;
  73. sha256)
  74. SHA256="$(which $tool) -q"
  75. ;;
  76. cksum)
  77. if cksum -q >/dev/null 2>/dev/null; then
  78. SHA256="$(which $tool) -q -a sha256"
  79. else
  80. continue
  81. fi
  82. ;;
  83. shasum)
  84. SHA256="$(which $tool) -a 256"
  85. ;;
  86. esac
  87. break
  88. else
  89. printf "not found\n"
  90. continue
  91. fi
  92. done
  93. if [ -z "$SHA256" ]; then
  94. printf "ERROR: no checksum tool found. Fatal error.\n"
  95. exit 1
  96. fi
  97. # create download dir
  98. if [ ! -d $topdir/dl ]; then
  99. mkdir -p $topdir/dl
  100. fi
  101. # check for c compiler
  102. compilerbins="cc gcc clang"
  103. for compilerbin in $compilerbins; do
  104. printf " ---> checking if $compilerbin is installed.. "
  105. if which $compilerbin >/dev/null; then
  106. printf "found\n"
  107. CC=$compilerbin
  108. break
  109. fi
  110. done
  111. # check for c++ compiler
  112. compilerbins="c++ g++ clang++"
  113. for compilerbin in $compilerbins; do
  114. printf " ---> checking if $compilerbin is installed.. "
  115. if which $compilerbin >/dev/null; then
  116. printf "found\n"
  117. CXX=$compilerbin
  118. break
  119. fi
  120. done
  121. gnu_host_name=$(${CC} -dumpmachine)
  122. # relocation of topdir?
  123. olddir=$(grep "^ADK_TOPDIR" prereq.mk 2>/dev/null |cut -d '=' -f 2)
  124. newdir=$(pwd)
  125. if [ ! -z "$olddir" ]; then
  126. if [ "$olddir" != "$newdir" ]; then
  127. printf " ---> adk directory was relocated, fixing .."
  128. sed -i -e "s#$olddir#$newdir#g" $(find target_* -name \*.pc|xargs) 2>/dev/null
  129. sed -i -e "s#$olddir#$newdir#g" $(find host_${gnu_host_name} -type f|xargs) 2>/dev/null
  130. sed -i -e "s#$olddir#$newdir#g" $(find target_*/scripts -type f|xargs) 2>/dev/null
  131. sed -i -e "s#$olddir#$newdir#" target_*/etc/ipkg.conf 2>/dev/null
  132. sleep 2
  133. printf "done\n"
  134. fi
  135. fi
  136. case :$PATH: in
  137. (*:$topdir/host_${gnu_host_name}/bin:*) ;;
  138. (*) export PATH=$topdir/host_${gnu_host_name}/bin:$PATH ;;
  139. esac
  140. # check for GNU make
  141. makebins="gmake make"
  142. for makebin in $makebins; do
  143. printf " ---> checking if $makebin is installed.. "
  144. if which $makebin >/dev/null 2>/dev/null; then
  145. printf "found\n"
  146. printf " ---> checking if it is GNU make.. "
  147. $makebin --version 2>/dev/null| grep GNU >/dev/null
  148. if [ $? -eq 0 ]; then
  149. printf "yes\n"
  150. MAKE=$(which $makebin)
  151. break
  152. else
  153. # we need to build GNU make
  154. printf "no\n"
  155. printf " ---> compiling missing GNU make.. "
  156. cd dl
  157. $FETCHCMD make-${makever}.tar.gz $mirror/make-${makever}.tar.gz
  158. if [ $? -ne 0 ]; then
  159. printf "ERROR: failed to download make from $mirror\n"
  160. exit 1
  161. fi
  162. cd ..
  163. mkdir tmp
  164. cd tmp
  165. tar xzf ../dl/make-${makever}.tar.gz
  166. cd make-$makever
  167. ./configure --prefix=$topdir/host_$gnu_host_name/
  168. make
  169. make install
  170. cd ..
  171. cd ..
  172. rm -rf tmp
  173. MAKE=$topdir/host_$gnu_host_name/bin/make
  174. makebin=$topdir/host_$gnu_host_name/bin/make
  175. printf " done\n"
  176. fi
  177. else
  178. printf "not found\n"
  179. continue
  180. fi
  181. done
  182. # check for bash
  183. printf " ---> checking if bash is installed.. "
  184. if which bash >/dev/null; then
  185. printf "found\n"
  186. else
  187. # we need to build GNU bash
  188. printf "not found\n"
  189. printf " ---> compiling missing GNU bash.. "
  190. cd dl
  191. $FETCHCMD bash-${bashver}.tar.gz $mirror/bash-${bashver}.tar.gz
  192. if [ $? -ne 0 ]; then
  193. printf "ERROR: failed to download make from $mirror\n"
  194. exit 1
  195. fi
  196. cd ..
  197. mkdir tmp
  198. cd tmp
  199. tar xzf ../dl/bash-${bashver}.tar.gz
  200. cd bash-${bashver}
  201. ./configure --prefix=$topdir/host_$gnu_host_name/
  202. make
  203. make install
  204. cd ..
  205. cd ..
  206. rm -rf tmp
  207. printf " done\n"
  208. fi
  209. # skip the script if distclean / cleandir
  210. if [ "$target" = "distclean" -o "$target" = "cleandir" ]; then
  211. touch prereq.mk
  212. $makebin ADK_TOPDIR=$topdir -s -f Makefile.adk $flags $target
  213. exit 0
  214. fi
  215. printf " ---> checking if perl is installed.. "
  216. if ! which perl >/dev/null 2>&1; then
  217. echo You must install perl to continue.
  218. echo
  219. out=1
  220. printf "not found\n"
  221. fi
  222. printf "found\n"
  223. # creating prereq.mk
  224. echo "ADK_TOPDIR:=$(readlink -nf . 2>/dev/null || pwd -P)" > $topdir/prereq.mk
  225. echo "BASH:=$(which bash)" >> $topdir/prereq.mk
  226. echo "SHELL:=$(which bash)" >> $topdir/prereq.mk
  227. echo "GMAKE:=$MAKE" >> $topdir/prereq.mk
  228. echo "MAKE:=$MAKE" >> $topdir/prereq.mk
  229. echo "FETCHCMD:=$FETCHCMD" >> $topdir/prereq.mk
  230. echo "SHA256:=$SHA256" >> $topdir/prereq.mk
  231. echo "GNU_HOST_NAME:=${gnu_host_name}" >> $topdir/prereq.mk
  232. echo "OS_FOR_BUILD:=${os}" >> $topdir/prereq.mk
  233. echo "ARCH_FOR_BUILD:=$(${CC} -dumpmachine | sed \
  234. -e 's/x86_64-linux-gnux32/x32/' \
  235. -e s'/-.*//' \
  236. -e 's/sparc.*/sparc/' \
  237. -e 's/armeb.*/armeb/g' \
  238. -e 's/arm.*/arm/g' \
  239. -e 's/m68k.*/m68k/' \
  240. -e 's/sh[234]/sh/' \
  241. -e 's/mips-.*/mips/' \
  242. -e 's/mipsel-.*/mipsel/' \
  243. -e 's/i[3-9]86/x86/' \
  244. )" >>prereq.mk
  245. if [ "$CC" = "clang" ]; then
  246. echo "HOST_CC:=${CC} -fbracket-depth=1024" >> $topdir/prereq.mk
  247. else
  248. echo "HOST_CC:=${CC}" >> $topdir/prereq.mk
  249. fi
  250. if [ "$CXX" = "clang++" ]; then
  251. echo "HOST_CXX:=${CXX} -fbracket-depth=1024" >> $topdir/prereq.mk
  252. else
  253. echo "HOST_CXX:=${CXX}" >> $topdir/prereq.mk
  254. fi
  255. echo 'LANGUAGE:=C' >> $topdir/prereq.mk
  256. echo 'LC_ALL:=C' >> $topdir/prereq.mk
  257. echo "_PATH:=$PATH" >> $topdir/prereq.mk
  258. echo "PATH:=${topdir}/scripts:/usr/sbin:$PATH" >> $topdir/prereq.mk
  259. echo "GIT:=$(which git 2>/dev/null)" >> $topdir/prereq.mk
  260. echo "export ADK_TOPDIR GIT SHA256 BASH SHELL" >> $topdir/prereq.mk
  261. # check if compiler works
  262. cat >Makefile.tmp <<'EOF'
  263. include ${ADK_TOPDIR}/prereq.mk
  264. all: test
  265. test: test.c
  266. @${HOST_CC} ${HOST_CFLAGS} -o $@ $^ ${LDADD}
  267. EOF
  268. cat >test.c <<-'EOF'
  269. #include <stdio.h>
  270. int
  271. main()
  272. {
  273. printf("YES");
  274. return (0);
  275. }
  276. EOF
  277. $MAKE --no-print-directory ADK_TOPDIR=$topdir -f Makefile.tmp 2>&1
  278. X=$(./test)
  279. if [ $X != YES ]; then
  280. echo "$X" | sed 's/^/| /'
  281. echo Cannot compile a simple test programme.
  282. echo You must install a host make and C compiler.
  283. echo
  284. out=1
  285. fi
  286. rm test.c test Makefile.tmp 2>/dev/null
  287. # error out on any required prerequisite
  288. if [ $out -ne 0 ]; then
  289. exit $out
  290. fi
  291. host_build_bc=0
  292. if which bc >/dev/null 2>&1; then
  293. if ! echo quit|bc -q 2>/dev/null >/dev/null; then
  294. host_build_bc=1
  295. else
  296. if bc -v 2>&1| grep -q BSD >/dev/null 2>&1; then
  297. host_build_bc=1
  298. fi
  299. fi
  300. else
  301. host_build_bc=1
  302. fi
  303. host_build_bison=0
  304. if ! which bison >/dev/null 2>&1; then
  305. host_build_bison=1
  306. fi
  307. host_build_bzip2=0
  308. if ! which bzip2 >/dev/null 2>&1; then
  309. host_build_bzip2=1
  310. fi
  311. host_build_file=0
  312. if ! which file >/dev/null 2>&1; then
  313. host_build_file=1
  314. fi
  315. host_build_flex=0
  316. if ! which flex >/dev/null 2>&1; then
  317. host_build_flex=1
  318. fi
  319. host_build_m4=0
  320. if ! which m4 >/dev/null 2>&1; then
  321. host_build_m4=1
  322. fi
  323. host_build_mksh=0
  324. if ! which mksh >/dev/null 2>&1; then
  325. host_build_mksh=1
  326. fi
  327. host_build_patch=0
  328. if ! which patch >/dev/null 2>&1; then
  329. host_build_patch=1
  330. fi
  331. host_build_pkgconf=0
  332. if ! which pkgconf >/dev/null 2>&1; then
  333. host_build_pkgconf=1
  334. fi
  335. host_build_tar=0
  336. if which tar >/dev/null 2>&1; then
  337. if ! tar --version 2>/dev/null|grep GNU >/dev/null;then
  338. host_build_tar=1
  339. fi
  340. else
  341. host_build_tar=1
  342. fi
  343. host_build_findutils=0
  344. if which xargs >/dev/null 2>&1; then
  345. if ! xargs --version 2>/dev/null|grep GNU >/dev/null;then
  346. host_build_findutils=1
  347. fi
  348. fi
  349. if which find >/dev/null 2>&1; then
  350. if ! find --version 2>/dev/null|grep GNU >/dev/null;then
  351. host_build_findutils=1
  352. fi
  353. fi
  354. host_build_grep=0
  355. if which grep >/dev/null 2>&1; then
  356. if ! grep --version 2>/dev/null|grep GNU >/dev/null;then
  357. host_build_grep=1
  358. fi
  359. fi
  360. host_build_gawk=0
  361. if ! which gawk >/dev/null 2>&1; then
  362. host_build_gawk=1
  363. fi
  364. host_build_sed=0
  365. if which sed >/dev/null 2>&1; then
  366. if ! sed --version 2>/dev/null|grep GNU >/dev/null;then
  367. host_build_sed=1
  368. fi
  369. fi
  370. host_build_xz=0
  371. if ! which xz >/dev/null 2>&1; then
  372. host_build_xz=1
  373. fi
  374. # optional
  375. host_build_cdrtools=0
  376. if ! which mkisofs >/dev/null 2>&1; then
  377. host_build_cdrtools=1
  378. fi
  379. host_build_ccache=0
  380. if ! which ccache >/dev/null 2>&1; then
  381. host_build_ccache=1
  382. fi
  383. host_build_genext2fs=0
  384. if ! which genext2fs >/dev/null 2>&1; then
  385. host_build_genext2fs=1
  386. fi
  387. host_build_lzma=0
  388. if ! which lzma >/dev/null 2>&1; then
  389. host_build_lzma=1
  390. fi
  391. host_build_lz4=0
  392. if ! which lz4c >/dev/null 2>&1; then
  393. host_build_lz4=1
  394. fi
  395. host_build_lzop=0
  396. if ! which lzop >/dev/null 2>&1; then
  397. host_build_lzop=1
  398. fi
  399. host_build_qemu=0
  400. if ! which qemu-img >/dev/null 2>&1; then
  401. host_build_qemu=1
  402. fi
  403. echo "config ADK_HOST_BUILD_TOOLS" > $topdir/target/config/Config.in.prereq
  404. printf "\t%s\n" "bool" >> $topdir/target/config/Config.in.prereq
  405. printf "\t%s\n" "default y" >> $topdir/target/config/Config.in.prereq
  406. # always required
  407. if [ $host_build_bc -eq 1 ]; then
  408. printf "\t%s\n" "select ADK_HOST_BUILD_BC" >> $topdir/target/config/Config.in.prereq
  409. fi
  410. if [ $host_build_bison -eq 1 ]; then
  411. printf "\t%s\n" "select ADK_HOST_BUILD_BISON" >> $topdir/target/config/Config.in.prereq
  412. fi
  413. if [ $host_build_bzip2 -eq 1 ]; then
  414. printf "\t%s\n" "select ADK_HOST_BUILD_BZIP2" >> $topdir/target/config/Config.in.prereq
  415. fi
  416. if [ $host_build_file -eq 1 ]; then
  417. printf "\t%s\n" "select ADK_HOST_BUILD_FILE" >> $topdir/target/config/Config.in.prereq
  418. fi
  419. if [ $host_build_flex -eq 1 ]; then
  420. printf "\t%s\n" "select ADK_HOST_BUILD_FLEX" >> $topdir/target/config/Config.in.prereq
  421. fi
  422. if [ $host_build_gawk -eq 1 ]; then
  423. printf "\t%s\n" "select ADK_HOST_BUILD_GAWK" >> $topdir/target/config/Config.in.prereq
  424. fi
  425. if [ $host_build_grep -eq 1 ]; then
  426. printf "\t%s\n" "select ADK_HOST_BUILD_GREP" >> $topdir/target/config/Config.in.prereq
  427. fi
  428. if [ $host_build_m4 -eq 1 ]; then
  429. printf "\t%s\n" "select ADK_HOST_BUILD_M4" >> $topdir/target/config/Config.in.prereq
  430. fi
  431. if [ $host_build_mksh -eq 1 ]; then
  432. printf "\t%s\n" "select ADK_HOST_BUILD_MKSH" >> $topdir/target/config/Config.in.prereq
  433. fi
  434. if [ $host_build_patch -eq 1 ]; then
  435. printf "\t%s\n" "select ADK_HOST_BUILD_PATCH" >> $topdir/target/config/Config.in.prereq
  436. fi
  437. if [ $host_build_pkgconf -eq 1 ]; then
  438. printf "\t%s\n" "select ADK_HOST_BUILD_PKGCONF" >> $topdir/target/config/Config.in.prereq
  439. fi
  440. if [ $host_build_findutils -eq 1 ]; then
  441. printf "\t%s\n" "select ADK_HOST_BUILD_FINDUTILS" >> $topdir/target/config/Config.in.prereq
  442. fi
  443. if [ $host_build_sed -eq 1 ]; then
  444. printf "\t%s\n" "select ADK_HOST_BUILD_SED" >> $topdir/target/config/Config.in.prereq
  445. fi
  446. if [ $host_build_tar -eq 1 ]; then
  447. printf "\t%s\n" "select ADK_HOST_BUILD_TAR" >> $topdir/target/config/Config.in.prereq
  448. fi
  449. if [ $host_build_xz -eq 1 ]; then
  450. printf "\t%s\n" "select ADK_HOST_BUILD_XZ" >> $topdir/target/config/Config.in.prereq
  451. fi
  452. # optional
  453. if [ $host_build_ccache -eq 1 ]; then
  454. printf "\t%s\n" "select ADK_HOST_BUILD_CCACHE if ADK_HOST_NEED_CCACHE" >> $topdir/target/config/Config.in.prereq
  455. fi
  456. if [ $host_build_cdrtools -eq 1 ]; then
  457. printf "\t%s\n" "select ADK_HOST_BUILD_CDRTOOLS if ADK_HOST_NEED_CDRTOOLS" >> $topdir/target/config/Config.in.prereq
  458. fi
  459. if [ $host_build_genext2fs -eq 1 ]; then
  460. printf "\t%s\n" "select ADK_HOST_BUILD_GENEXT2FS if ADK_HOST_NEED_GENEXT2FS" >> $topdir/target/config/Config.in.prereq
  461. fi
  462. if [ $host_build_lzma -eq 1 ]; then
  463. printf "\t%s\n" "select ADK_HOST_BUILD_LZMA if ADK_HOST_NEED_LZMA" >> $topdir/target/config/Config.in.prereq
  464. fi
  465. if [ $host_build_lz4 -eq 1 ]; then
  466. printf "\t%s\n" "select ADK_HOST_BUILD_LZ4 if ADK_HOST_NEED_LZ4" >> $topdir/target/config/Config.in.prereq
  467. fi
  468. if [ $host_build_lzop -eq 1 ]; then
  469. printf "\t%s\n" "select ADK_HOST_BUILD_LZOP if ADK_HOST_NEED_LZOP" >> $topdir/target/config/Config.in.prereq
  470. fi
  471. if [ $host_build_qemu -eq 1 ]; then
  472. printf "\t%s\n" "select ADK_HOST_BUILD_QEMU if ADK_HOST_NEED_QEMU" >> $topdir/target/config/Config.in.prereq
  473. fi
  474. # create Host OS symbols
  475. case $os in
  476. Linux)
  477. printf "\nconfig ADK_HOST_LINUX\n" >> $topdir/target/config/Config.in.prereq
  478. printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
  479. printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
  480. ;;
  481. Darwin)
  482. printf "\nconfig ADK_HOST_DARWIN\n" >> $topdir/target/config/Config.in.prereq
  483. printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
  484. printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
  485. ;;
  486. OpenBSD)
  487. printf "\nconfig ADK_HOST_OPENBSD\n" >> $topdir/target/config/Config.in.prereq
  488. printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
  489. printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
  490. ;;
  491. FreeBSD)
  492. printf "\nconfig ADK_HOST_FREEBSD\n" >> $topdir/target/config/Config.in.prereq
  493. printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
  494. printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
  495. ;;
  496. NetBSD)
  497. printf "\nconfig ADK_HOST_NETBSD\n" >> $topdir/target/config/Config.in.prereq
  498. printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
  499. printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
  500. ;;
  501. MirBSD)
  502. printf "\nconfig ADK_HOST_MIRBSD\n" >> $topdir/target/config/Config.in.prereq
  503. printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
  504. printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
  505. ;;
  506. Cygwin*)
  507. printf "\nconfig ADK_HOST_CYGWIN\n" >> $topdir/target/config/Config.in.prereq
  508. printf "\tbool\n" >> $topdir/target/config/Config.in.prereq
  509. printf "\tdefault y\n" >> $topdir/target/config/Config.in.prereq
  510. ;;
  511. esac
  512. if [ ! -f $topdir/.config ]; then
  513. # create a config if no exist
  514. touch .firstrun
  515. $makebin ADK_TOPDIR=$topdir --no-print-directory -f Makefile.adk menuconfig
  516. else
  517. # scan host-tool prerequisites of certain packages before building.
  518. . $topdir/.config
  519. if [ -n "$ADK_PACKAGE_KODI" ]; then
  520. NEED_JAVA="$NEED_JAVA kodi"
  521. fi
  522. if [ -n "$ADK_PACKAGE_ICU4C" ]; then
  523. NEED_STATIC_LIBSTDCXX="$NEED_STATIC_LIBSTDCXX icu4c"
  524. fi
  525. if [ -n "$ADK_PACKAGE_XKEYBOARD_CONFIG" ]; then
  526. NEED_XKBCOMP="$NEED_XKBCOMP xkeyboard-config"
  527. fi
  528. if [ -n "$ADK_PACKAGE_FONT_BITSTREAM_100DPI" ]; then
  529. NEED_MKFONTDIR="$NEED_MKFONTDIR font-bitstream-100dpi"
  530. fi
  531. if [ -n "$ADK_PACKAGE_FONT_BITSTREAM_75DPI" ]; then
  532. NEED_MKFONTDIR="$NEED_MKFONTDIR font-bitstream-75dpi"
  533. fi
  534. if [ -n "$ADK_PACKAGE_FONT_ADOBE_100DPI" ]; then
  535. NEED_MKFONTDIR="$NEED_MKFONTDIR font-adobe-100dpi"
  536. fi
  537. if [ -n "$ADK_PACKAGE_FONT_ADOBE_75DPI" ]; then
  538. NEED_MKFONTDIR="$NEED_MKFONTDIR font-adobe-75dpi"
  539. fi
  540. if [ -n "$NEED_MKFONTDIR" ]; then
  541. if ! which mkfontdir >/dev/null 2>&1; then
  542. printf "You need mkfontdir to build $NEED_MKFONTDIR"
  543. out=1
  544. fi
  545. fi
  546. if [ -n "$NEED_XKBCOMP" ]; then
  547. if ! which xkbcomp >/dev/null 2>&1; then
  548. printf "You need xkbcomp to build $NEED_XKBCOMP"
  549. out=1
  550. fi
  551. fi
  552. if [ -n "$NEED_JAVA" ]; then
  553. if ! which java >/dev/null 2>&1; then
  554. printf "You need java to build $NEED_JAVA"
  555. out=1
  556. fi
  557. fi
  558. if [ -n "$NEED_STATIC_LIBSTDCXX" ]; then
  559. cat >test.c <<-'EOF'
  560. #include <stdio.h>
  561. int
  562. main()
  563. {
  564. return (0);
  565. }
  566. EOF
  567. if ! $CXX -static-libstdc++ -o test test.c 2>/dev/null ; then
  568. printf "You need static version of libstdc++ installed to build $NEED_STATIC_LIBSTDCXX"
  569. out=1
  570. rm test test.c 2>/dev/null
  571. fi
  572. fi
  573. # error out
  574. if [ $out -ne 0 ]; then
  575. exit $out
  576. fi
  577. # start build
  578. $makebin ADK_TOPDIR=$topdir --no-print-directory -f Makefile.adk $flags $target
  579. fi