bootstrap 3.2 KB
Newer Older
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
#! /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"
}

BUILD=
HOST=
PREFIX=

if test ! -f "../src/main.mak"
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=}"
			;;
		*)
			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%/}"
else
	PREFIX="../hosts/$HOST"
fi

#
# Prepare files
#
echo "Creating prefix... $PREFIX"
mkdir -p -- "$PREFIX" || exit $?
mkdir -p -- "$PREFIX/share/aclocal" || exit $?

echo "Creating configuration file... config.mak"
exec 3>config.mak
cat >&3 << EOF
# This file was automatically generated.
# Any change will be overwritten if ../bootstrap is run again.
BUILD := $BUILD
HOST := $HOST
PREFIX := $PREFIX
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
}

#
# Checks
#
OS="${HOST#*-}" # strip architecture
case "${OS}" in
130 131 132
	apple-darwin*)
		add_make_enabled "HAVE_MACOSX" "HAVE_DARWIN_OS" "HAVE_BSD"
		;;
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
	*darwin*)
		add_make_enabled "HAVE_DARWIN_OS" "HAVE_BSD"
		;;
	*bsd*)
		add_make_enabled "HAVE_BSD"
		;;
	*linux*)
		add_make_enabled "HAVE_LINUX"
		;;
	*mingw*)
		add_make_enabled "HAVE_WIN32"
		;;
	*wince*)
		add_make_enabled "HAVE_WINCE"
		;;
esac
149
add_make_enabled "BUILD_ENCODERS"
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171

#
# Results output
#
test -e Makefile && unlink Makefile
ln -sf ../src/main.mak Makefile
cat << EOF
Bootstrap completed.

The following packages were selected:
$PKGS

Run "make" to start compilation.

Other targets:
 * make install      same as "make"
 * make fetch        fetch required source tarballs
 * make fetch-all    fetch all source tarballs
 * make distclean    clean everything and undo bootstrap
 * make clean        clean everything
 * make mostlyclean  clean everything except source tarballs
EOF