2 AC_INIT([xbmc-depends], [2.00], [http://trac.xbmc.org])
4 AC_CONFIG_AUX_DIR([build-aux])
5 AC_CONFIG_FILES([target/config.site native/config.site.native Makefile.include target/Toolchain.cmake])
7 m4_include([../../m4/xbmc_arch.m4])
9 AC_ARG_WITH([toolchain],
10 [AS_HELP_STRING([--with-toolchain],
11 [specify path to toolchain. Required for android. Defaults to xcode root for darwin, /usr for linux])],
12 [use_toolchain=$withval])
14 AC_ARG_WITH([tarballs],
15 [AS_HELP_STRING([--with-tarballs],
16 [path where tarballs will be saved [prefix/xbmc-tarballs]])],
17 [use_tarballs=$withval])
20 [AS_HELP_STRING([--with-cpu],
21 [optional. specify target cpu. guessed if not specified])],
22 [use_cpu=$withval],use_cpu=auto)
25 [AS_HELP_STRING([--with-ndk],
26 [specify path to ndk (required for android only)])],
29 AC_ARG_WITH([sdk-path],
30 [AS_HELP_STRING([--with-sdk-path],
31 [specify path to sdk (required for android only)])],
32 [use_sdk_path=$withval])
35 [AS_HELP_STRING([--with-sdk],
36 [spcify sdk platform version (optional for android). default is android-14])],
39 AC_ARG_ENABLE([gplv3],
40 [AS_HELP_STRING([--enable-gplv3],
41 [enable gplv3 components. default off for android, on everywhere else])],
42 [use_gplv3=1], [use_gplv3=auto])
45 AC_CHECK_PROG(HAVE_UNZIP,unzip,"yes","no",)
46 if test "x$HAVE_UNZIP" = "xno" ; then
47 AC_MSG_ERROR("Missing program: unzip")
50 AC_CHECK_PROG(HAVE_ZIP,zip,"yes","no",)
51 if test "x$HAVE_ZIP" = "xno" ; then
52 AC_MSG_ERROR("Missing program: zip")
55 AC_PATH_PROG(CURL,curl,"no")
56 if test "x$CURL" = "xno" ; then
57 AC_MSG_ERROR("Missing program: curl")
60 AC_PATH_PROG(TAR,tar,"no")
61 if test "x$TAR" = "xno" ; then
62 AC_MSG_ERROR("Missing program: tar")
67 if test "x$host" = "x$build"; then
68 use_host=$build_cpu-$build_os
72 tool_dir=$build_cpu-$build_os-native
75 if test "x$host" = "x$build"; then
79 passed_cflags="$CFLAGS"
80 passed_ldflags="$LDFLAGS"
81 passed_cxxflags="$CXXFLAGS"
86 if test "x$use_cpu" = "xauto"; then
89 use_sdk="${use_sdk:-android-14}"
90 deps_dir="$use_host-$use_sdk"
91 platform_cflags="-DANDROID -Os -fexceptions"
92 if test "x$use_cpu" = "xarmeabi-v7a"; then
93 platform_cflags+=" -march=armv7-a -mtune=cortex-a9 -mfloat-abi=softfp -mfpu=neon"
95 platform_ldflags="-L$prefix/$deps_dir/lib/$use_sdk"
96 platform_cxxflags="$platform_cflags -frtti"
97 platform_includes="-I$prefix/$deps_dir/include/$use_sdk"
99 if test "x$use_gplv3" = "xauto"; then
102 #android builds are always cross
103 cross_compiling="yes"
105 i*86*-linux-android*)
106 if test "x$use_cpu" = "xauto"; then
109 use_sdk="${use_sdk:-android-14}"
110 deps_dir="$use_host-$use_sdk"
111 platform_cflags="-DANDROID -Os -fexceptions"
112 platform_ldflags="-L$prefix/$deps_dir/lib/$use_sdk"
113 platform_cxxflags="$platform_cflags -frtti"
114 platform_includes="-I$prefix/$deps_dir/include/$use_sdk"
115 platform_os="android"
116 if test "x$use_gplv3" = "xauto"; then
119 #android builds are always cross
120 cross_compiling="yes"
123 if test "x$use_cpu" = "xauto"; then
126 use_toolchain="${use_toolchain:-/usr}"
127 platform_cflags="-Os -fPIC -DPIC"
128 platform_ldflags="-Wl,-rpath-link=$prefix/$deps_dir/lib"
129 platform_cxxflags="$platform_cflags"
134 use_toolchain="${use_toolchain:-/usr}"
139 use_toolchain="${use_toolchain:-/usr}"
140 platform_cflags="-fPIC -DPIC"
141 platform_cxxflags="$platform_cflags"
145 if test "x$prefix" = "xNONE"; then
146 prefix=/Users/Shared/xbmc-depends
148 use_tarballs="${use_tarballs:-$prefix/tarballs}"
149 use_xcodepath=`xcode-select -print-path`
150 use_xcodebuild=$use_xcodepath/usr/bin/xcodebuild
151 use_xcode=[`$use_xcodebuild -version | grep Xcode | awk '{ print $2}'`]
152 AC_MSG_RESULT(found xcodebuild at $use_xcodebuild)
153 use_build_toolchain=$use_xcodepath
155 #darwin builds are always cross
156 cross_compiling="yes"
158 platform_cflags="-std=gnu99 -no_compact_linkedit -no-cpp-precomp"
159 platform_ldflags="-Wl,-search_paths_first -no_compact_linkedit"
160 platform_cxxflags="-no_compact_linkedit -no-cpp-precomp"
168 platform_cc=llvm-gcc-4.2
169 platform_cxx=llvm-g++-4.2
174 platform_cflags="-fheinous-gnu-extensions -no-cpp-precomp -no-integrated-as"
175 platform_ldflags="-Wl,-search_paths_first"
176 platform_cxxflags="-no-cpp-precomp"
181 found_sdk_version=[`$use_xcodebuild -showsdks | grep macosx | sort | tail -n 1 | grep -oE 'macosx[0-9.0-9]+' | cut -c 7-$NF`]
184 use_toolchain="${use_xcodepath}/Toolchains/XcodeDefault.xctoolchain"
187 use_toolchain="${use_toolchain:-$use_xcodepath}"
190 use_sdk="${use_sdk:-$found_sdk_version}"
191 if test "$use_cpu" = "armv7"; then
192 AC_MSG_ERROR(error in configure of --with-arch=$use_cpu)
201 AC_MSG_ERROR(error in configure of --with-sdk=$use_sdk)
203 sdk_name=macosx$use_sdk
204 use_sdk_path=[`$use_xcodebuild -version -sdk $sdk_name Path`]
207 x86_64-apple-darwin*)
208 if test "x$use_cpu" = "xauto"; then
213 if test "x$use_cpu" = "xauto"; then
218 AC_MSG_ERROR(error in configure of --with-arch=$use_cpu)
221 platform_min_version=macosx-version-min=10.6
225 if test "x$use_cpu" = "xauto"; then
228 if test "$use_cpu" != "armv7"; then
229 AC_MSG_ERROR(error in configure of --with-arch=$use_cpu)
231 platform_min_version="iphoneos-version-min=4.2"
232 found_sdk_version=[`$use_xcodebuild -showsdks | grep iphoneos | sort | tail -n 1 | awk '{ print $2}'`]
233 use_sdk="${use_sdk:-$found_sdk_version}"
234 sdk_name=iphoneos$use_sdk
237 use_toolchain="${use_xcodepath}/Toolchains/XcodeDefault.xctoolchain"
240 use_toolchain="${use_toolchain:-`$use_xcodebuild -version -sdk $sdk_name PlatformPath`/Developer}"
250 AC_MSG_ERROR(error in configure of --with-sdk=$use_sdk)
253 use_sdk_path=[`$use_xcodebuild -version -sdk $sdk_name | grep ^Path | awk '{ print $2}'`]
255 tmp_flags="-mcpu=cortex-a8 -mfpu=neon -ftree-vectorize -mfloat-abi=softfp -pipe -Wno-trigraphs -fpascal-strings -O3 -Wreturn-type -Wunused-variable -fmessage-length=0 -gdwarf-2"
256 platform_cflags+=" $tmp_flags"
257 platform_ldflags+=" -L$use_sdk_path/usr/lib/system"
258 platform_cxxflags+=" $tmp_flags"
261 platform_cflags+=" -arch $use_cpu -m$platform_min_version"
262 platform_ldflags+=" -arch $use_cpu -m$platform_min_version -isysroot $use_sdk_path"
263 platform_cxxflags+=" -arch $use_cpu -m$platform_min_version"
264 platform_includes="-isysroot $use_sdk_path"
265 deps_dir=$sdk_name"_"$use_cpu-target
266 tool_dir=buildtools-native;
269 AC_MSG_ERROR(unsupported host ($use_host))
272 XBMC_SETUP_ARCH_DEFINES()
274 platform_cflags+=" $passed_cflags"
275 platform_ldflags+=" $passed_ldflags $LIBS"
276 platform_cxxflags+=" $passed_cxxflags"
278 if test -n $use_build_toolchain; then
279 PATH_FOR_HOST=$use_toolchain:$use_toolchain/usr/bin:$use_toolchain/bin:$PATH
283 if test -n $use_build_toolchain; then
284 PATH_FOR_BUILD=$use_build_toolchain:$use_build_toolchain/usr/bin:$use_toolchain/bin:$PATH
289 AC_PATH_TOOL([RANLIB], [ranlib],, $PATH_FOR_HOST)
290 AC_PATH_TOOL([LD], [ld],, $PATH_FOR_HOST)
291 AC_PATH_TOOL([AR], [ar],, $PATH_FOR_HOST)
292 AC_PATH_TOOL([READELF], [readelf],, $PATH_FOR_HOST)
293 AC_PATH_TOOL([STRIP], [strip],, $PATH_FOR_HOST)
294 AC_PATH_TOOL([AS], [as],, $PATH_FOR_HOST)
295 AC_PATH_TOOL([NM], [nm],, $PATH_FOR_HOST)
296 AC_PATH_TOOL([OBJDUMP], [objdump],, $PATH_FOR_HOST)
297 AC_PATH_TOOL([CC],[$platform_cc],,$PATH_FOR_HOST)
298 AC_PATH_TOOL([CXX],[$platform_cxx],,$PATH_FOR_HOST)
301 AC_PATH_PROG([RANLIB_FOR_BUILD], [ranlib], ranlib, $PATH_FOR_BUILD)
302 AC_PATH_PROG([LD_FOR_BUILD], [ld], ld, $PATH_FOR_BUILD)
303 AC_PATH_PROG([AR_FOR_BUILD], [ar], ar, $PATH_FOR_BUILD)
304 AC_PATH_PROG([READELF_FOR_BUILD], [readelf], readelf, $PATH_FOR_BUILD)
305 AC_PATH_PROG([STRIP_FOR_BUILD], [strip], strip, $PATH_FOR_BUILD)
306 AC_PATH_PROG([AS_FOR_BUILD], [as], as, $PATH_FOR_BUILD)
307 AC_PATH_PROG([NM_FOR_BUILD], [nm], nm, $PATH_FOR_BUILD)
308 AC_PATH_PROG([OBJDUMP_FOR_BUILD], [objdump], objdump, $PATH_FOR_BUILD)
309 AC_PATH_PROG([CC_FOR_BUILD],[gcc llvm-gcc $platform_cc], gcc, $PATH_FOR_BUILD)
310 AC_PATH_PROG([CXX_FOR_BUILD],[g++ llvm-g++ $platform_cxx], g++, $PATH_FOR_BUILD)
312 AC_CHECK_LIB([z], [main], has_zlib=1, AC_MSG_WARN("No zlib support in toolchain. Will build libz."); has_zlib=0)
313 AC_SEARCH_LIBS([iconv_open],iconv, link_iconv=$ac_cv_search_iconv_open, link_iconv=-liconv; AC_MSG_WARN("No iconv support in toolchain. Will build libiconv."); need_libiconv=1)
314 AC_TRY_LINK([#include <locale.h>],[struct lconv* test=localeconv();], has_localeconv=yes, AC_MSG_WARN("No localeconv support in toolchain. Using replacement."); has_localeconv=no)
315 AC_CHECK_LIB([crystax], [main], has_libcrystax=1, has_libcrystax=0)
317 if test "x$use_gplv3" = "xauto"; then
321 if test "$link_iconv" = "none required"; then
325 if test "x$prefix" = "xNONE"; then
326 AC_MSG_ERROR([No prefix path defined. Use for ex: --prefix=/opt/xbmc-depends]);
329 if test -z $use_tarballs; then
330 use_tarballs=$prefix/xbmc-tarballs
333 if test "$platform_os" == "android"; then
334 if test -z $use_ndk; then
335 AC_MSG_ERROR("NDK path is required for android")
338 if test -z $use_sdk_path; then
339 AC_MSG_ERROR("SDK path is required for android")
342 if [ ! test -f $use_sdk_path/tools/zipalign ]; then
343 AC_MSG_ERROR(verify sdk path)
346 if [ ! test -f $use_ndk/sources/android/native_app_glue/android_native_app_glue.h ]; then
347 AC_MSG_ERROR(verify ndk path)
351 # Some dumb checks to see if paths might be correct.
352 if [ ! `mkdir -p $prefix/$deps_dir/include` ]; then
353 AC_MSG_ERROR(unable to create $prefix/$deps_dir/include. verify that the path and permissions are correct.)
356 if [ ! `mkdir -p $prefix/$deps_dir/lib` ]; then
357 AC_MSG_ERROR(unable to create $prefix/$deps_dir/lib. verify that the path and permissions are correct.)
360 if [ ! `mkdir -p $prefix/$deps_dir/share` ]; then
361 AC_MSG_ERROR(unable to create $prefix/$deps_dir/share. verify that the path and permissions are correct.)
364 if [ ! `mkdir -p $prefix/$tool_dir/include` ]; then
365 AC_MSG_ERROR(unable to create $prefix/$tool_dir/include. verify that the path and permissions are correct.)
368 if [ ! `mkdir -p $prefix/$tool_dir/lib` ]; then
369 AC_MSG_ERROR(unable to create $prefix/$tool_dir/lib. verify that the path and permissions are correct.)
372 if [ ! `mkdir -p $prefix/$tool_dir/share` ]; then
373 AC_MSG_ERROR(unable to create $prefix/$tool_dir/share. verify that the path and permissions are correct.)
376 if [ ! `mkdir -p $prefix/$tool_dir/bin` ]; then
377 AC_MSG_ERROR(unable to create $prefix/$tool_dir/share. verify that the path and permissions are correct.)
380 if [ ! `mkdir -p $use_tarballs` ]; then
381 AC_MSG_ERROR(unable to create tarballs dir. verify that the path and permissions are correct.)
384 if test "$platform_os" == "android"; then
387 if [ ! `mkdir -p $prefix/$deps_dir/include/$use_sdk` ]; then
388 AC_MSG_ERROR(unable to create $prefix/$deps_dir/include/$use_sdk. verify that the path and permissions are correct.)
391 if [ ! `mkdir -p $prefix/$deps_dir/lib/$use_sdk` ]; then
392 AC_MSG_ERROR(unable to create $prefix/$deps_dir/lib/$use_sdk. verify that the path and permissions are correct.)
396 if test "$platform_os" == "android"; then
398 AC_SUBST(use_sdk_path)
407 AC_SUBST(use_toolchain)
408 AC_SUBST(use_build_toolchain)
409 AC_SUBST(use_tarballs)
410 AC_SUBST(cross_compiling)
411 AC_SUBST(platform_cflags)
412 AC_SUBST(platform_cxxflags)
413 AC_SUBST(platform_ldflags)
414 AC_SUBST(platform_includes)
415 AC_SUBST(platform_os)
418 AC_SUBST(need_libiconv)
420 AC_SUBST(has_libcrystax)
424 echo -e "toolchain:\t $use_toolchain"
425 echo -e "cpu:\t\t $use_cpu"
426 echo -e "host:\t\t $use_host"
427 if test "$platform_os" == "android"; then
428 echo -e "sdk-platform:\t $use_sdk"
431 if test "$platform_os" == "ios"; then
432 simulator_sdk_path=[`$use_xcodebuild -version -sdk iphonesimulator$use_sdk | grep ^Path | awk '{ print $2}'`]
433 cp -vf $simulator_sdk_path/usr/include/crt_externs.h $prefix/$deps_dir/include
436 if test "x$has_localeconv" == "xno" && test "$platform_os" == "android"; then
437 cp -vf target/android-libc-replacements/locale.h $prefix/$deps_dir/include/
440 cp -vf target/config.site $prefix/$deps_dir/share
441 cp -vf target/Toolchain.cmake $prefix/$deps_dir/share
442 cp -vf native/config.site.native $prefix/$tool_dir/share/config.site