bootstrap 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. #! /bin/sh
  2. # Copyright (C) 2003-2011 the VideoLAN team
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  17. #
  18. # Command line handling
  19. #
  20. usage()
  21. {
  22. echo "Usage: $0 [--build=BUILD] [--host=HOST] [--prefix=PREFIX]"
  23. echo " --build=BUILD configure for building on BUILD"
  24. echo " --host=HOST cross-compile to build to run on HOST"
  25. echo " --prefix=PREFIX install files in PREFIX"
  26. echo " --no-checksums don't verify checksums (allows to replace tarballs)"
  27. echo " --disable-downloads don't download packages from the internet"
  28. echo " --disable-FOO configure to not build package FOO"
  29. echo " --enable-FOO configure to build package FOO"
  30. }
  31. BUILD=
  32. HOST=
  33. PREFIX=
  34. PKGS_ENABLE=
  35. PKGS_DISABLE=
  36. if test ! -f "../../contrib/src/main.mak"
  37. then
  38. echo "$0 must be run from a subdirectory"
  39. exit 1
  40. fi
  41. while test -n "$1"
  42. do
  43. case "$1" in
  44. --build=*)
  45. BUILD="${1#--build=}"
  46. ;;
  47. --help|-h)
  48. usage
  49. exit 0
  50. ;;
  51. --no-checksums)
  52. DISABLE_CONTRIB_CHECKSUMS="TRUE"
  53. ;;
  54. --disable-downloads)
  55. DISABLE_CONTRIB_DOWNLOADS="TRUE"
  56. ;;
  57. --host=*)
  58. HOST="${1#--host=}"
  59. ;;
  60. --prefix=*)
  61. PREFIX="${1#--prefix=}"
  62. ;;
  63. --disable-*)
  64. PKGS_DISABLE="${PKGS_DISABLE} ${1#--disable-}"
  65. ;;
  66. --enable-*)
  67. PKGS_ENABLE="${PKGS_ENABLE} ${1#--enable-}"
  68. ;;
  69. *)
  70. echo "Unrecognized options $1"
  71. usage
  72. exit 1
  73. ;;
  74. esac
  75. shift
  76. done
  77. if test -z "$BUILD"
  78. then
  79. echo -n "Guessing build system... "
  80. BUILD="`${CC:-cc} -dumpmachine`"
  81. if test -z "$BUILD"; then
  82. echo "FAIL!"
  83. exit 1
  84. fi
  85. echo "$BUILD"
  86. fi
  87. if test -z "$HOST"
  88. then
  89. echo -n "Guessing host system... "
  90. HOST="$BUILD"
  91. echo "$HOST"
  92. fi
  93. if test "$PREFIX"
  94. then
  95. # strip trailing slash
  96. PREFIX="${PREFIX%/}"
  97. fi
  98. #
  99. # Prepare files
  100. #
  101. echo "Creating configuration file... config.mak"
  102. exec 3>config.mak || exit $?
  103. cat >&3 << EOF
  104. # This file was automatically generated.
  105. # Any change will be overwritten if ../bootstrap is run again.
  106. BUILD := $BUILD
  107. HOST := $HOST
  108. CROSS_COMPILE ?= $HOST-
  109. PKGS_DISABLE := $PKGS_DISABLE
  110. PKGS_ENABLE := $PKGS_ENABLE
  111. DISABLE_CONTRIB_DOWNLOADS := $DISABLE_CONTRIB_DOWNLOADS
  112. DISABLE_CONTRIB_CHECKSUMS := $DISABLE_CONTRIB_CHECKSUMS
  113. EOF
  114. add_make()
  115. {
  116. while test -n "$1"
  117. do
  118. echo "$1" >&3
  119. shift
  120. done
  121. }
  122. add_make_enabled()
  123. {
  124. while test -n "$1"
  125. do
  126. add_make "$1 := 1"
  127. shift
  128. done
  129. }
  130. check_ios_sdk()
  131. {
  132. if test -z "$SDKROOT"
  133. then
  134. SDKROOT=`xcode-select -print-path`/Platforms/${IOS_TARGET_PLATFORM}.platform/Developer/SDKs/${IOS_TARGET_PLATFORM}${SDK_VERSION}.sdk
  135. echo "SDKROOT not specified, assuming $SDKROOT"
  136. else
  137. SDKROOT="$SDKROOT"
  138. fi
  139. if [ ! -d "${SDKROOT}" ]
  140. then
  141. echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
  142. exit 1
  143. fi
  144. add_make "IOS_SDK=${SDKROOT}"
  145. add_make "IOS_TARGET_PLATFORM=${IOS_TARGET_PLATFORM}"
  146. }
  147. check_macosx_sdk()
  148. {
  149. if [ -z "${OSX_VERSION}" ]
  150. then
  151. OSX_VERSION=`xcrun --show-sdk-version`
  152. echo "OSX_VERSION not specified, assuming $OSX_VERSION"
  153. fi
  154. if test -z "$SDKROOT"
  155. then
  156. SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
  157. echo "SDKROOT not specified, assuming $SDKROOT"
  158. fi
  159. if [ ! -d "${SDKROOT}" ]
  160. then
  161. SDKROOT_NOT_FOUND=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
  162. SDKROOT=`xcode-select -print-path`/SDKs/MacOSX$OSX_VERSION.sdk
  163. echo "SDKROOT not found at $SDKROOT_NOT_FOUND, trying $SDKROOT"
  164. fi
  165. if [ ! -d "${SDKROOT}" ]
  166. then
  167. SDKROOT_NOT_FOUND="$SDKROOT"
  168. SDKROOT=`xcrun --show-sdk-path`
  169. echo "SDKROOT not found at $SDKROOT_NOT_FOUND, trying $SDKROOT"
  170. fi
  171. if [ ! -d "${SDKROOT}" ]
  172. then
  173. echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
  174. exit 1
  175. fi
  176. add_make "MACOSX_SDK=${SDKROOT}"
  177. add_make "OSX_VERSION ?= ${OSX_VERSION}"
  178. }
  179. check_android_sdk()
  180. {
  181. [ -z "${ANDROID_NDK}" ] && echo "You must set ANDROID_NDK environment variable" && exit 1
  182. add_make "ANDROID_NDK := ${ANDROID_NDK}"
  183. [ -z "${ANDROID_ABI}" ] && echo "You must set ANDROID_ABI environment variable" && exit 1
  184. add_make "ANDROID_ABI := ${ANDROID_ABI}"
  185. [ -z "${ANDROID_API}" ] && echo "You should set ANDROID_API environment variable (using default android-9)" && ANDROID_API := android-9
  186. add_make "ANDROID_API := ${ANDROID_API}"
  187. [ ${ANDROID_ABI} = "armeabi-v7a" ] && add_make_enabled "HAVE_NEON"
  188. [ ${ANDROID_ABI} = "armeabi-v7a" ] && add_make_enabled "HAVE_ARMV7A"
  189. [ ${ANDROID_ABI} = "armeabi" -a -z "${NO_ARMV6}" ] && add_make_enabled "HAVE_ARMV6"
  190. }
  191. test -z "$PREFIX" || add_make "PREFIX := $PREFIX"
  192. #
  193. # Checks
  194. #
  195. OS="${HOST#*-}" # strip architecture
  196. case "${OS}" in
  197. apple-darwin*)
  198. if test -z "$BUILDFORIOS"
  199. then
  200. check_macosx_sdk
  201. add_make_enabled "HAVE_MACOSX" "HAVE_DARWIN_OS" "HAVE_BSD"
  202. else
  203. check_ios_sdk
  204. add_make_enabled "HAVE_IOS" "HAVE_DARWIN_OS" "HAVE_BSD" "HAVE_NEON" "HAVE_ARMV7A"
  205. fi
  206. ;;
  207. *bsd*)
  208. add_make_enabled "HAVE_BSD"
  209. ;;
  210. *android*)
  211. check_android_sdk
  212. add_make_enabled "HAVE_LINUX" "HAVE_ANDROID"
  213. case "${HOST}" in
  214. *arm*)
  215. add_make "PLATFORM_SHORT_ARCH := arm"
  216. ;;
  217. *i686*)
  218. add_make "PLATFORM_SHORT_ARCH := x86"
  219. ;;
  220. *mipsel*)
  221. add_make "PLATFORM_SHORT_ARCH := mips"
  222. ;;
  223. esac
  224. ;;
  225. *linux*)
  226. add_make_enabled "HAVE_LINUX"
  227. ;;
  228. *wince*)
  229. add_make_enabled "HAVE_WINCE"
  230. ;;
  231. *mingw*)
  232. add_make_enabled "HAVE_WIN32"
  233. ;;
  234. *solaris*)
  235. add_make_enabled "HAVE_SOLARIS"
  236. ;;
  237. esac
  238. #
  239. # Results output
  240. #
  241. test -e Makefile && unlink Makefile
  242. ln -sf ../../contrib/src/main.mak Makefile || exit $?
  243. cat << EOF
  244. Bootstrap completed.
  245. Run "make" to start compilation.
  246. Other targets:
  247. * make install same as "make"
  248. * make prebuilt fetch and install prebuilt binaries
  249. * make list list packages
  250. * make fetch fetch required source tarballs
  251. * make fetch-all fetch all source tarballs
  252. * make distclean clean everything and undo bootstrap
  253. * make mostlyclean clean everything except source tarballs
  254. * make clean clean everything
  255. * make package prepare prebuilt packages
  256. EOF
  257. mkdir -p ../../contrib/tarballs || exit $?