bootstrap 2.9 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 © 2011 Rafaël Carré
#
# 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.

export LC_ALL=
NEEDED=

if [ ! -f tools.mak ]
then
	echo "You must run me in ./extras/tools !"
	exit 1
fi

27 28 29 30 31 32 33 34
check_tar() {
if ! tar PcJ /dev/null >/dev/null 2>&1
then
    echo "tar doesn't support xz (J option)"
    NEEDED="$NEEDED .tar .xz"
fi
}

Sean McGovern's avatar
Sean McGovern committed
35 36
check_sed() {
tmp="`pwd`/check_sed"
37
trap "rm \"$tmp\" \"$tmp-e\" 2>/dev/null" EXIT
Sean McGovern's avatar
Sean McGovern committed
38 39 40 41 42 43 44 45
echo "test file for GNU sed" > $tmp
if ! sed -i -e 's/sed//' $tmp >/dev/null 2>&1
then
    echo "sed doesn't do in-place editing (-i option)"
    NEEDED="$NEEDED .sed"
fi
}

46
check() {
47
if ! $1 --version >/dev/null 2>&1 && ! $1 -version >/dev/null 2>&1
48 49 50
then
    echo "$1 not found"
    NEEDED="$NEEDED .$1"
51 52 53 54 55 56
else
    # found, need to check version ?
    [ -z "$2" ] && return # no
    gotver=`$1 --version | head -1 | sed s/'.* '//`
    gotmajor=`echo $gotver|cut -d. -f1`
    gotminor=`echo $gotver|cut -d. -f2`
57 58
    gotmicro=`echo $gotver|cut -d. -f3`
    [ -z "$gotmicro" ] && gotmicro=0
59 60
    needmajor=`echo $2|cut -d. -f1`
    needminor=`echo $2|cut -d. -f2`
61 62
    needmicro=`echo $2|cut -d. -f3`
    [ -z "$needmicro" ] && needmicro=0
63
    if [ "$needmajor" -ne "$gotmajor" \
64 65
         -o "$needmajor" -eq "$gotmajor" -a "$needminor" -gt "$gotminor" \
         -o "$needmajor" -eq "$gotmajor" -a "$needminor" -eq "$gotminor" -a "$needmicro" -gt "$gotmicro" ]
66 67 68 69
    then
        echo "$1 too old"
        NEEDED="$NEEDED .$1"
    fi
70 71 72
fi
}

73
check autoconf 2.69
74
check automake 1.15
75
check m4 1.4.16
76
check libtool 2.4
77
check pkg-config
78
check cmake 3.8.2
Rafaël Carré's avatar
Rafaël Carré committed
79
check yasm
80
check_tar
81
check ragel
Sean McGovern's avatar
Sean McGovern committed
82
check_sed
83
check protoc 2.6.0
84
check ant
85
check xz
86
check bison 3.0.0
87
check flex
88

89
[ -n "$NEEDED" ] && mkdir -p build/ && echo "To-be-built packages: `echo $NEEDED | sed 's/\.//g'`"
90 91 92

CPUS=
case `uname` in
93
    Linux|MINGW32*|MINGW64*)
94
        CPUS=`getconf _NPROCESSORS_ONLN 2>&1`
95
     ;;
96 97 98 99 100
    Darwin|FreeBSD|NetBSD)
        CPUS=`getconf NPROCESSORS_ONLN 2>&1`
    ;;
    OpenBSD)
        CPUS=`sysctl -n hw.ncpu 2>&1`
101
    ;;
102
    SunOS)
103
        CPUS=`psrinfo | wc -l 2>&1`
104
    ;;
105 106 107 108 109 110 111 112
    *)
        CPUS=1  # default
     ;;
esac


cat > Makefile << EOF
MAKEFLAGS += -j$CPUS
113
CMAKEFLAGS += --parallel=$CPUS
114 115 116 117 118 119 120
PREFIX=\$(abspath ./build)

all: $NEEDED
	@echo "You are ready to build VLC and its contribs"

include tools.mak
EOF