]> git.sesse.net Git - vlc/blob - extras/tools/bootstrap
Extras: add protoc
[vlc] / extras / tools / bootstrap
1 #!/bin/sh
2 # Copyright © 2011 Rafaël Carré
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
17
18 export LC_ALL=
19 NEEDED=
20
21 if [ ! -f tools.mak ]
22 then
23         echo "You must run me in ./extras/tools !"
24         exit 1
25 fi
26
27 check_tar() {
28 if ! tar PcJ /dev/null >/dev/null 2>&1
29 then
30     echo "tar doesn't support xz (J option)"
31     NEEDED="$NEEDED .tar .xz"
32 fi
33 }
34
35 check_sed() {
36 tmp="`pwd`/check_sed"
37 trap "rm $tmp{,-e} 2>/dev/null" EXIT
38 echo "test file for GNU sed" > $tmp
39 if ! sed -i -e 's/sed//' $tmp >/dev/null 2>&1
40 then
41     echo "sed doesn't do in-place editing (-i option)"
42     NEEDED="$NEEDED .sed"
43 fi
44 }
45
46 check() {
47 if ! $1 --version >/dev/null 2>&1
48 then
49     echo "$1 not found"
50     NEEDED="$NEEDED .$1"
51 else
52     # found, need to check version ?
53     [ -z "$2" ] && return # no
54     gotver=`$1 --version | head -1 | sed s/'.* '//`
55     gotmajor=`echo $gotver|cut -d. -f1`
56     gotminor=`echo $gotver|cut -d. -f2`
57     gotmicro=`echo $gotver|cut -d. -f3`
58     [ -z "$gotmicro" ] && gotmicro=0
59     needmajor=`echo $2|cut -d. -f1`
60     needminor=`echo $2|cut -d. -f2`
61     needmicro=`echo $2|cut -d. -f3`
62     [ -z "$needmicro" ] && needmicro=0
63     if [ "$needmajor" -gt "$gotmajor" \
64          -o "$needmajor" -eq "$gotmajor" -a "$needminor" -gt "$gotminor" \
65          -o "$needmajor" -eq "$gotmajor" -a "$needminor" -eq "$gotminor" -a "$needmicro" -gt "$gotmicro" ]
66     then
67         echo "$1 too old"
68         NEEDED="$NEEDED .$1"
69     fi
70 fi
71 }
72
73 check autoconf 2.69
74 check automake 1.14
75 check m4 1.4.16
76 check libtool 2.4
77 check pkg-config
78 check cmake 2.8.8
79 check yasm
80 check_tar
81 check ragel
82 check_sed
83 check protoc
84
85 [ -n "$NEEDED" ] && mkdir -p build/
86
87 CPUS=
88 CC=
89 CXX=
90 case `uname` in
91     Linux)
92         CPUS=`grep -c ^processor /proc/cpuinfo`
93      ;;
94     Darwin)
95         CPUS=`sysctl hw.ncpu|cut -d: -f2`
96         gcc-4.2 --version >/dev/null 2>&1 && CC=CC=gcc-4.2
97         g++-4.2 --version >/dev/null 2>&1 && CXX=CXX=g++-4.2
98     ;;
99     SunOS)
100         CPUS=`/usr/bin/kstat -p :::state | grep 'on-line$' | wc -l | sed 's/ //g'`
101     ;;
102     *)
103         CPUS=1  # default
104      ;;
105 esac
106
107
108 cat > Makefile << EOF
109 MAKEFLAGS += -j$CPUS
110 $CC
111 $CXX
112 PREFIX=\$(abspath ./build)
113
114 all: $NEEDED
115         @echo "You are ready to build VLC and its contribs"
116
117 include tools.mak
118 EOF