bootstrap 9.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#! /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"
27 28
	echo "  --disable-FOO    configure to not build package FOO"
	echo "  --enable-FOO     configure to build package FOO"
29
	echo "  --disable-disc   configure to not build optical discs packages"
30
	echo "  --disable-net    configure to not build networking packages"
31
	echo "  --disable-sout   configure to not build stream output packages"
32
	echo "  --enable-small   optimize libraries for size with slight speed decrease [DANGEROUS]"
33
	echo "  --disable-gpl    configure to not build viral GPL code"
34
	echo "  --disable-gnuv3  configure to not build version 3 (L)GPL code"
35 36
	echo "  --enable-ad-clauses configure to build packages with advertising clauses"
	echo "                   (USE AT YOUR OWN LEGAL RISKS)"
37
	echo "  --disable-optim  disable optimization in libraries"
38 39 40 41 42
}

BUILD=
HOST=
PREFIX=
43 44
PKGS_ENABLE=
PKGS_DISABLE=
45
BUILD_ENCODERS="1"
46
BUILD_NETWORK="1"
47
BUILD_DISCS="1"
48
GPL="1"
49
GNUV3="1"
50
AD_CLAUSES=
51
WITH_OPTIMIZATION="1"
52

53
if test ! -f "../../contrib/src/main.mak"
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
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=}"
			;;
75 76 77
		--disable-disc)
			BUILD_DISCS=
			;;
78 79 80
		--disable-net)
			BUILD_NETWORK=
			;;
81 82 83
		--disable-sout)
			BUILD_ENCODERS=
			;;
84 85 86
		--disable-optim)
			WITH_OPTIMIZATION=
			;;
87 88 89
		--enable-small)
			ENABLE_SMALL=1
			;;
90 91 92
		--disable-gpl)
			GPL=
			;;
93 94 95
		--disable-gnuv3)
			GNUV3=
			;;
96 97 98
		--enable-ad-clauses)
			AD_CLAUSES=1
			;;
99 100 101 102 103 104
		--disable-*)
			PKGS_DISABLE="${PKGS_DISABLE} ${1#--disable-}"
			;;
		--enable-*)
			PKGS_ENABLE="${PKGS_ENABLE} ${1#--enable-}"
			;;
105 106 107 108 109 110 111 112 113
		*)
			echo "Unrecognized options $1"
			usage
			exit 1
			;;
	esac
	shift
done

114 115 116 117 118 119
if test -n "$AD_CLAUSES" -a -n "$GPL" -a -z "$GNUV3"
then
	echo "Error: advertising clauses are not compatible with GPLv2!" >&2
	exit 1
fi

120 121 122
if test -z "$BUILD"
then
	echo -n "Guessing build system... "
123
	BUILD="`${CC:-cc} -dumpmachine`"
124 125 126 127 128 129 130 131 132 133 134 135 136 137
	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

138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
echo -n "Packages licensing...    "
if test -n "$GPL"
then
	if test -n "$GNUV3"
	then
		LICENSE="GPL version 3"
	else
		LICENSE="GPL version 2"
	fi
else
	if test -n "$GNUV3"
	then
		LICENSE="Lesser GPL version 3"
	else
		LICENSE="Lesser GPL version 2.1"
	fi
fi
test -z "$AD_CLAUSES" || LICENSE="$LICENSE, with advertisement clauses"
echo "$LICENSE"

158 159 160 161 162 163 164 165 166 167
if test "$PREFIX"
then
	# strip trailing slash
	PREFIX="${PREFIX%/}"
fi

#
# Prepare files
#
echo "Creating configuration file... config.mak"
168
exec 3>config.mak || exit $?
169 170 171 172 173
cat >&3 << EOF
# This file was automatically generated.
# Any change will be overwritten if ../bootstrap is run again.
BUILD := $BUILD
HOST := $HOST
174 175
PKGS_DISABLE := $PKGS_DISABLE
PKGS_ENABLE := $PKGS_ENABLE
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
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
}

196 197
check_ios_sdk()
{
198 199 200 201 202 203 204 205 206 207 208 209
    if test "$VLCSDKROOT"
    then
	    SDKROOT="$VLCSDKROOT"
    else
		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
    fi
210

211 212 213 214 215 216
    if [ ! -d "${SDKROOT}" ]
    then
       echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
       exit 1
    fi
    add_make "IOS_SDK=${SDKROOT}"
217 218
}

219 220
check_macosx_sdk()
{
221 222 223 224 225
   if [ -z "${OSX_VERSION}" ]
   then
      OSX_VERSION=`xcrun --show-sdk-version`
      echo "OSX_VERSION not specified, assuming $OSX_VERSION"
   fi
226
   if test -z "$SDKROOT"
227
   then
228 229
      SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
      echo "SDKROOT not specified, assuming $SDKROOT"
230
   fi
231

232 233 234 235 236 237
   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
238 239 240 241 242 243
   if [ ! -d "${SDKROOT}" ]
   then
      SDKROOT_NOT_FOUND="$SDKROOT"
      SDKROOT=`xcrun --show-sdk-path`
      echo "SDKROOT not found at $SDKROOT_NOT_FOUND, trying $SDKROOT"
   fi
244

245 246 247 248 249 250
   if [ ! -d "${SDKROOT}" ]
   then
      echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
      exit 1
   fi

251
   add_make "MACOSX_SDK=${SDKROOT}"
252 253 254
   add_make "OSX_VERSION ?= ${OSX_VERSION}"
}

255 256 257 258
check_android_sdk()
{
	[ -z "${ANDROID_NDK}" ] && echo "You must set ANDROID_NDK environment variable" && exit 1
	add_make "ANDROID_NDK := ${ANDROID_NDK}"
259 260
	[ -z "${ANDROID_ABI}" ] && echo "You must set ANDROID_ABI environment variable" && exit 1
	add_make "ANDROID_ABI := ${ANDROID_ABI}"
261 262
	[ -z "${ANDROID_API}" ] && echo "You should set ANDROID_API environment variable (using default android-9)" && ANDROID_API := android-9
	add_make "ANDROID_API := ${ANDROID_API}"
263
	[ ${ANDROID_ABI} = "armeabi-v7a" ] && add_make_enabled "HAVE_NEON"
264
	[ ${ANDROID_ABI} = "armeabi-v7a" ] && add_make_enabled "HAVE_ARMV7A"
265 266
	[ ${ANDROID_ABI} = "arm64-v8a" ] && add_make_enabled "HAVE_NEON"
	[ ${ANDROID_ABI} = "arm64-v8a" ] && add_make_enabled "HAVE_ARMV8A"
267
	[ ${ANDROID_ABI} = "armeabi" -a -z "${NO_ARMV6}" ] && add_make_enabled "HAVE_ARMV6"
268 269
}

270 271 272 273 274 275 276 277 278 279
check_tizen_sdk()
{
	[ -z "${TIZEN_SDK}" ] && echo "You must set TIZEN_SDK environment variable" && exit 1
	add_make "TIZEN_SDK := ${TIZEN_SDK}"
	[ -z "${TIZEN_ABI}" ] && echo "You must set TIZEN_ABI environment variable" && exit 1
	add_make "TIZEN_ABI := ${TIZEN_ABI}"
	[ ${TIZEN_ABI} = "armv7l" ] && add_make_enabled "HAVE_NEON"
	[ ${TIZEN_ABI} = "armv7l" ] && add_make_enabled "HAVE_ARMV7A"
}

280
test -z "$PREFIX" || add_make "PREFIX := $PREFIX"
281 282
test -z "$BUILD_DISCS" || add_make_enabled "BUILD_DISCS"
test -z "$BUILD_ENCODERS" || add_make_enabled "BUILD_ENCODERS"
283
test -z "$BUILD_NETWORK" || add_make_enabled "BUILD_NETWORK"
284
test -z "$ENABLE_SMALL" || add_make_enabled "ENABLE_SMALL"
285
test -z "$GPL" || add_make_enabled "GPL"
286
test -z "$GNUV3" || add_make_enabled "GNUV3"
287
test -z "$AD_CLAUSES" || add_make_enabled "AD_CLAUSES"
288
test -z "$WITH_OPTIMIZATION" || add_make_enabled "WITH_OPTIMIZATION"
289
test "`uname -o 2>/dev/null`" != "Msys" || add_make "CMAKE_GENERATOR := -G \"MSYS Makefiles\""
290

291 292 293
#
# Checks
#
294 295
OS="${HOST#*-}" # strip architecture
case "${OS}" in
296
	*-darwin*)
297 298 299 300 301
		if test -z "$BUILDFORIOS"
		then
			check_macosx_sdk
			add_make_enabled "HAVE_MACOSX" "HAVE_DARWIN_OS" "HAVE_BSD"
		else
302
			check_ios_sdk
303
			add_make_enabled "HAVE_IOS" "HAVE_DARWIN_OS" "HAVE_BSD" "HAVE_FPU"
304 305 306 307 308 309

			case "${HOST}" in
				*arm*)
				add_make_enabled "HAVE_NEON" "HAVE_ARMV7A"
				;;
			esac;
310
		fi
311 312 313 314
		if test "$BUILDFORTVOS"
		then
			add_make_enabled "HAVE_TVOS"
		fi
315 316 317 318
		;;
	*bsd*)
		add_make_enabled "HAVE_BSD"
		;;
319
	*android*)
320 321
		check_android_sdk
		add_make_enabled "HAVE_LINUX" "HAVE_ANDROID"
322 323 324
		case "${HOST}" in
			*arm*)
			add_make "PLATFORM_SHORT_ARCH := arm"
325
			;;
326
			*arm64*|*aarch64*)
327
			add_make "PLATFORM_SHORT_ARCH := arm64"
328 329 330 331
			;;
			*i686*)
			add_make "PLATFORM_SHORT_ARCH := x86"
			;;
332 333 334
			*x86_64*)
			add_make "PLATFORM_SHORT_ARCH := x86_64"
			;;
335 336 337 338
			*mipsel*)
			add_make "PLATFORM_SHORT_ARCH := mips"
			;;
		esac
339
		;;
340
	*linux*)
341 342 343 344 345 346 347 348 349 350 351 352 353
		if [ "`${CC} -v 2>&1 | grep tizen`" ]; then
			check_tizen_sdk
			add_make_enabled "HAVE_TIZEN"
			case "${HOST}" in
				*arm*)
				add_make "PLATFORM_SHORT_ARCH := arm"
				;;
				*i386*)
				add_make "PLATFORM_SHORT_ARCH := x86"
				;;
			esac
		fi

354 355
		add_make_enabled "HAVE_LINUX"
		;;
356 357
	*mingw*)
		add_make_enabled "HAVE_WIN32"
358 359 360 361 362 363
		case "${HOST}" in
			*winphone*|*windowsphone*)
			add_make_enabled "HAVE_WINDOWSPHONE"
			;;
		esac
		case "${HOST}" in
364
			*winphone*|*windowsphone*|*winrt*|*uwp*)
365 366 367
			add_make_enabled "HAVE_WINSTORE"
			;;
		esac
368 369 370 371 372
		case "${HOST}" in
			amd64*|x86_64*)
			add_make_enabled "HAVE_WIN64"
			;;
		esac
373 374 375 376 377
        case "${HOST}" in
            armv7*)
                add_make_enabled "HAVE_ARMV7A"
                ;;
        esac
378
		;;
379 380 381
	*solaris*)
		add_make_enabled "HAVE_SOLARIS"
		;;
382 383 384 385 386 387
esac

#
# Results output
#
test -e Makefile && unlink Makefile
388
ln -sf ../../contrib/src/main.mak Makefile || exit $?
389 390
echo "Bootstrap completed."
make help
391
mkdir -p ../../contrib/tarballs || exit $?