2011-06-28 00:15:00 +08:00
|
|
|
#! /bin/sh
|
|
|
|
# Copyright (C) 2003-2011 the VideoLAN team
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
|
|
|
|
|
|
|
#
|
|
|
|
# Command line handling
|
|
|
|
#
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
echo "Usage: $0 [--build=BUILD] [--host=HOST] [--prefix=PREFIX]"
|
|
|
|
echo " --build=BUILD configure for building on BUILD"
|
|
|
|
echo " --host=HOST cross-compile to build to run on HOST"
|
|
|
|
echo " --prefix=PREFIX install files in PREFIX"
|
2011-06-27 21:37:59 +08:00
|
|
|
echo " --disable-FOO configure to not build package FOO"
|
|
|
|
echo " --enable-FOO configure to build package FOO"
|
2011-07-02 05:20:08 +08:00
|
|
|
echo " --disable-disc configure to not build optical discs packages"
|
|
|
|
echo " --disable-sout configure to not build stream output packages"
|
2012-02-09 07:07:16 +08:00
|
|
|
echo " --enable-small optimize libraries for size with slight speed decrease [DANGEROUS]"
|
2012-12-19 13:08:59 +08:00
|
|
|
echo " --disable-gpl configure to not build viral GPL code"
|
2011-06-28 00:15:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
BUILD=
|
|
|
|
HOST=
|
|
|
|
PREFIX=
|
2011-06-27 21:37:59 +08:00
|
|
|
PKGS_ENABLE=
|
|
|
|
PKGS_DISABLE=
|
2011-07-02 05:20:08 +08:00
|
|
|
BUILD_ENCODERS="1"
|
|
|
|
BUILD_DISCS="1"
|
2012-12-19 13:08:59 +08:00
|
|
|
GPL="1"
|
2011-06-28 00:15:00 +08:00
|
|
|
|
2011-07-06 17:33:31 +08:00
|
|
|
if test ! -f "../../contrib/src/main.mak"
|
2011-06-28 00:15:00 +08:00
|
|
|
then
|
|
|
|
echo "$0 must be run from a subdirectory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
while test -n "$1"
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
--build=*)
|
|
|
|
BUILD="${1#--build=}"
|
|
|
|
;;
|
|
|
|
--help|-h)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
--host=*)
|
|
|
|
HOST="${1#--host=}"
|
|
|
|
;;
|
|
|
|
--prefix=*)
|
|
|
|
PREFIX="${1#--prefix=}"
|
|
|
|
;;
|
2011-07-02 05:20:08 +08:00
|
|
|
--disable-disc)
|
|
|
|
BUILD_DISCS=
|
|
|
|
;;
|
|
|
|
--disable-sout)
|
|
|
|
BUILD_ENCODERS=
|
|
|
|
;;
|
2012-02-09 07:07:16 +08:00
|
|
|
--enable-small)
|
|
|
|
ENABLE_SMALL=1
|
|
|
|
;;
|
2012-12-19 13:08:59 +08:00
|
|
|
--disable-gpl)
|
|
|
|
GPL=
|
|
|
|
;;
|
2011-06-27 21:37:59 +08:00
|
|
|
--disable-*)
|
|
|
|
PKGS_DISABLE="${PKGS_DISABLE} ${1#--disable-}"
|
|
|
|
;;
|
|
|
|
--enable-*)
|
|
|
|
PKGS_ENABLE="${PKGS_ENABLE} ${1#--enable-}"
|
|
|
|
;;
|
2011-06-28 00:15:00 +08:00
|
|
|
*)
|
|
|
|
echo "Unrecognized options $1"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if test -z "$BUILD"
|
|
|
|
then
|
|
|
|
echo -n "Guessing build system... "
|
|
|
|
BUILD="`cc -dumpmachine`"
|
|
|
|
if test -z "$BUILD"; then
|
|
|
|
echo "FAIL!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "$BUILD"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -z "$HOST"
|
|
|
|
then
|
|
|
|
echo -n "Guessing host system... "
|
|
|
|
HOST="$BUILD"
|
|
|
|
echo "$HOST"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "$PREFIX"
|
|
|
|
then
|
|
|
|
# strip trailing slash
|
|
|
|
PREFIX="${PREFIX%/}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Prepare files
|
|
|
|
#
|
|
|
|
echo "Creating configuration file... config.mak"
|
2013-03-22 03:06:07 +08:00
|
|
|
exec 3>config.mak || exit $?
|
2011-06-28 00:15:00 +08:00
|
|
|
cat >&3 << EOF
|
|
|
|
# This file was automatically generated.
|
|
|
|
# Any change will be overwritten if ../bootstrap is run again.
|
|
|
|
BUILD := $BUILD
|
|
|
|
HOST := $HOST
|
2011-06-27 21:37:59 +08:00
|
|
|
PKGS_DISABLE := $PKGS_DISABLE
|
|
|
|
PKGS_ENABLE := $PKGS_ENABLE
|
2011-06-28 00:15:00 +08:00
|
|
|
EOF
|
|
|
|
|
|
|
|
add_make()
|
|
|
|
{
|
|
|
|
while test -n "$1"
|
|
|
|
do
|
|
|
|
echo "$1" >&3
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
add_make_enabled()
|
|
|
|
{
|
|
|
|
while test -n "$1"
|
|
|
|
do
|
|
|
|
add_make "$1 := 1"
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2011-11-27 02:38:16 +08:00
|
|
|
check_macosx_sdk()
|
|
|
|
{
|
2012-08-17 20:40:40 +08:00
|
|
|
[ -z "${OSX_VERSION}" ] && echo "OSX_VERSION not specified, assuming 10.7" && OSX_VERSION=10.7
|
2012-05-17 19:59:27 +08:00
|
|
|
if test -z "$SDKROOT"
|
2011-11-27 02:38:16 +08:00
|
|
|
then
|
2012-05-17 19:59:27 +08:00
|
|
|
SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
|
|
|
|
echo "SDKROOT not specified, assuming $SDKROOT"
|
2011-11-27 02:38:16 +08:00
|
|
|
fi
|
2012-05-17 19:59:27 +08:00
|
|
|
|
2012-06-07 07:44:03 +08:00
|
|
|
if [ ! -d "${SDKROOT}" ]
|
|
|
|
then
|
|
|
|
SDKROOT_NOT_FOUND=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
|
|
|
|
SDKROOT=`xcode-select -print-path`/SDKs/MacOSX$OSX_VERSION.sdk
|
|
|
|
echo "SDKROOT not found at $SDKROOT_NOT_FOUND, trying $SDKROOT"
|
|
|
|
fi
|
|
|
|
|
2012-05-17 19:59:27 +08:00
|
|
|
if [ ! -d "${SDKROOT}" ]
|
|
|
|
then
|
|
|
|
echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-08-17 20:39:56 +08:00
|
|
|
add_make "MACOSX_SDK=${SDKROOT}"
|
2011-11-27 02:38:16 +08:00
|
|
|
add_make "OSX_VERSION ?= ${OSX_VERSION}"
|
|
|
|
}
|
|
|
|
|
2012-03-21 01:59:23 +08:00
|
|
|
check_ios_sdk()
|
|
|
|
{
|
|
|
|
if test -z "$SDKROOT"
|
|
|
|
then
|
|
|
|
SDKROOT=`xcode-select -print-path`/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/iPhone${PLATFORM}${SDK_VERSION}.sdk
|
|
|
|
echo "SDKROOT not specified, assuming $SDKROOT"
|
|
|
|
else
|
|
|
|
SDKROOT="$SDKROOT"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "${SDKROOT}" ]
|
|
|
|
then
|
|
|
|
echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
add_make "SDKROOT=${SDKROOT}"
|
|
|
|
}
|
|
|
|
|
2011-11-27 16:56:20 +08:00
|
|
|
check_android_sdk()
|
|
|
|
{
|
|
|
|
[ -z "${ANDROID_NDK}" ] && echo "You must set ANDROID_NDK environment variable" && exit 1
|
|
|
|
add_make "ANDROID_NDK := ${ANDROID_NDK}"
|
2012-06-22 23:26:43 +08:00
|
|
|
[ -z "${ANDROID_ABI}" ] && echo "You must set ANDROID_ABI environment variable" && exit 1
|
|
|
|
add_make "ANDROID_ABI := ${ANDROID_ABI}"
|
2012-11-22 07:11:25 +08:00
|
|
|
[ ${ANDROID_ABI} = "armeabi-v7a" ] && add_make_enabled "HAVE_NEON"
|
2012-10-05 23:04:10 +08:00
|
|
|
[ ${ANDROID_ABI} = "armeabi-v7a" ] && add_make_enabled "HAVE_ARMV7A"
|
2013-05-11 02:47:13 +08:00
|
|
|
[ ${ANDROID_ABI} = "armeabi" -a -z "${NO_ARMV6}" ] && add_make_enabled "HAVE_ARMV6"
|
2011-11-27 16:56:20 +08:00
|
|
|
}
|
|
|
|
|
2011-07-06 17:18:06 +08:00
|
|
|
test -z "$PREFIX" || add_make "PREFIX := $PREFIX"
|
2011-07-02 05:20:08 +08:00
|
|
|
test -z "$BUILD_DISCS" || add_make_enabled "BUILD_DISCS"
|
|
|
|
test -z "$BUILD_ENCODERS" || add_make_enabled "BUILD_ENCODERS"
|
2012-02-09 07:07:16 +08:00
|
|
|
test -z "$ENABLE_SMALL" || add_make_enabled "ENABLE_SMALL"
|
2012-12-19 13:08:59 +08:00
|
|
|
test -z "$GPL" || add_make_enabled "GPL"
|
2011-07-02 05:20:08 +08:00
|
|
|
|
2011-06-28 00:15:00 +08:00
|
|
|
#
|
|
|
|
# Checks
|
|
|
|
#
|
2012-03-21 02:09:17 +08:00
|
|
|
OS="${HOST#*-}" # strip architecture
|
|
|
|
case "${OS}" in
|
2012-03-25 17:55:19 +08:00
|
|
|
apple-darwin*)
|
|
|
|
if test -z "$BUILDFORIOS"
|
|
|
|
then
|
|
|
|
check_macosx_sdk
|
|
|
|
add_make_enabled "HAVE_MACOSX" "HAVE_DARWIN_OS" "HAVE_BSD"
|
|
|
|
else
|
|
|
|
check_ios_sdk
|
2012-10-05 23:04:10 +08:00
|
|
|
add_make_enabled "HAVE_IOS" "HAVE_DARWIN_OS" "HAVE_BSD" "HAVE_NEON" "HAVE_ARMV7A"
|
2012-03-25 17:55:19 +08:00
|
|
|
fi
|
2011-06-28 00:15:00 +08:00
|
|
|
;;
|
|
|
|
*bsd*)
|
|
|
|
add_make_enabled "HAVE_BSD"
|
|
|
|
;;
|
2012-07-25 10:51:40 +08:00
|
|
|
*android*)
|
2011-11-27 16:56:20 +08:00
|
|
|
check_android_sdk
|
|
|
|
add_make_enabled "HAVE_LINUX" "HAVE_ANDROID"
|
2012-07-25 10:51:40 +08:00
|
|
|
case "${HOST}" in
|
|
|
|
*arm*)
|
|
|
|
add_make "PLATFORM_SHORT_ARCH := arm"
|
|
|
|
;;
|
|
|
|
*i686*)
|
|
|
|
add_make "PLATFORM_SHORT_ARCH := x86"
|
|
|
|
;;
|
|
|
|
*mipsel*)
|
|
|
|
add_make "PLATFORM_SHORT_ARCH := mips"
|
|
|
|
;;
|
|
|
|
esac
|
2011-11-27 16:56:20 +08:00
|
|
|
;;
|
2011-06-28 00:15:00 +08:00
|
|
|
*linux*)
|
|
|
|
add_make_enabled "HAVE_LINUX"
|
|
|
|
;;
|
|
|
|
*wince*)
|
|
|
|
add_make_enabled "HAVE_WINCE"
|
|
|
|
;;
|
2011-07-04 20:45:52 +08:00
|
|
|
*mingw*)
|
|
|
|
add_make_enabled "HAVE_WIN32"
|
|
|
|
;;
|
2011-06-28 00:15:00 +08:00
|
|
|
esac
|
|
|
|
|
|
|
|
#
|
|
|
|
# Results output
|
|
|
|
#
|
|
|
|
test -e Makefile && unlink Makefile
|
2013-03-22 03:06:07 +08:00
|
|
|
ln -sf ../../contrib/src/main.mak Makefile || exit $?
|
2011-06-28 00:15:00 +08:00
|
|
|
cat << EOF
|
|
|
|
Bootstrap completed.
|
|
|
|
|
|
|
|
Run "make" to start compilation.
|
|
|
|
|
|
|
|
Other targets:
|
|
|
|
* make install same as "make"
|
2011-11-30 08:38:55 +08:00
|
|
|
* make prebuilt fetch and install prebuilt binaries
|
|
|
|
* make list list packages
|
2011-06-28 00:15:00 +08:00
|
|
|
* make fetch fetch required source tarballs
|
|
|
|
* make fetch-all fetch all source tarballs
|
|
|
|
* make distclean clean everything and undo bootstrap
|
|
|
|
* make mostlyclean clean everything except source tarballs
|
2011-07-04 16:37:09 +08:00
|
|
|
* make clean clean everything
|
2011-11-30 08:38:55 +08:00
|
|
|
* make package prepare prebuilt packages
|
2011-06-28 00:15:00 +08:00
|
|
|
EOF
|
2011-07-19 01:54:44 +08:00
|
|
|
|
2013-03-22 03:06:07 +08:00
|
|
|
mkdir -p ../../contrib/tarballs || exit $?
|