demux: mkv: ProcessNavAction: negate if to prevent nesting
[vlc.git] / extras / tools / bootstrap
blobd9455be29ad42948d055d006170bee98c4b02ef9
1 #!/bin/sh
2 # Copyright © 2011 Rafaël Carré
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.
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.
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.
18 export LC_ALL=
19 NEEDED=
20 FOUND=
22 if [ ! -f tools.mak ]
23 then
24 echo "You must run me in ./extras/tools !"
25 exit 1
28 check_version() {
29 gotver=$2
30 gotmajor=`echo $gotver|cut -d. -f1`
31 gotminor=`echo $gotver|cut -d. -f2`
32 gotmicro=`echo $gotver|cut -d. -f3`
33 [ -z "$gotmicro" ] && gotmicro=0
34 needmajor=`echo $3|cut -d. -f1`
35 needminor=`echo $3|cut -d. -f2`
36 needmicro=`echo $3|cut -d. -f3`
37 [ -z "$needmicro" ] && needmicro=0
38 if [ "$needmajor" -ne "$gotmajor" \
39 -o "$needmajor" -eq "$gotmajor" -a "$needminor" -gt "$gotminor" \
40 -o "$needmajor" -eq "$gotmajor" -a "$needminor" -eq "$gotminor" -a "$needmicro" -gt "$gotmicro" ]
41 then
42 echo "$1 too old"
43 NEEDED="$NEEDED $1"
44 else
45 FOUND="$FOUND $1"
50 check_version_majmin() {
51 gotver=$2
52 gotmajor=`echo $gotver|cut -d. -f1`
53 gotminor=`echo $gotver|cut -d. -f2`
54 needmajor=`echo $3|cut -d. -f1`
55 needminor=`echo $3|cut -d. -f2`
56 if [ "$needmajor" -ne "$gotmajor" \
57 -o "$needminor" -ne "$gotminor" ]
58 then
59 echo "$1 not compatible"
60 NEEDED="$NEEDED $1"
61 else
62 FOUND="$FOUND $1"
67 check_tar() {
68 if ! tar PcJ /dev/null >/dev/null 2>&1 && ! tar PcJf /dev/null /dev/null 2>&1
69 then
70 echo "tar doesn't support xz (J option)"
71 NEEDED="$NEEDED tar xz"
72 else
73 FOUND="$FOUND tar xz"
77 check_sed() {
78 tmp="`pwd`/check_sed"
79 trap "rm \"$tmp\" \"$tmp-e\" 2>/dev/null" EXIT
80 echo "test file for GNU sed" > $tmp
81 if ! sed -i -e 's/sed//' $tmp >/dev/null 2>&1
82 then
83 echo "sed doesn't do in-place editing (-i option)"
84 NEEDED="$NEEDED sed"
85 else
86 FOUND="$FOUND sed"
90 check_nasm() {
91 if ! nasm -v >/dev/null 2>&1
92 then
93 echo "nasm not found"
94 NEEDED="$NEEDED nasm"
95 else
96 # found, need to check version ?
97 [ -z "$1" ] && return # no
98 gotver=`nasm -v | cut -d ' ' -f 3`
99 check_version nasm $gotver $1
103 check() {
104 if ! $1 --version >/dev/null 2>&1 && ! $1 -version >/dev/null 2>&1
105 then
106 echo "$1 not found"
107 NEEDED="$NEEDED $1"
108 else
109 # found, need to check version ?
110 [ -z "$2" ] && return # no
111 gotver=`$1 --version | head -1 | sed s/'.* '//`
112 check_version $1 $gotver $2
116 check_majmin() {
117 if ! $1 --version >/dev/null 2>&1 && ! $1 -version >/dev/null 2>&1 && ! $1 --version 2>/dev/null
118 then
119 echo "$1 not found"
120 NEEDED="$NEEDED $1"
121 else
122 # found, need to check version ?
123 [ -z "$2" ] && return # no
124 gotver=`$1 --version | head -1 | sed s/'.* '//`
125 check_version_majmin $1 $gotver $2
129 check autoconf 2.69
130 check automake 1.15
131 check m4 1.4.16
132 check libtool 2.4
133 check pkg-config
134 check cmake 3.8.2
135 check yasm
136 check_tar
137 check ragel
138 check_sed
139 check_majmin protoc 3.1.0
140 check ant
141 check xz
142 check bison 3.0.0
143 check flex
144 check_nasm 2.13.01
145 check gettext
146 check help2man
148 DEPS_ONLY="help2man"
150 CPUS=
151 case `uname` in
152 Linux|MINGW32*|MINGW64*)
153 CPUS=`getconf _NPROCESSORS_ONLN 2>&1`
155 Darwin|FreeBSD|NetBSD)
156 CPUS=`getconf NPROCESSORS_ONLN 2>&1`
158 OpenBSD)
159 CPUS=`sysctl -n hw.ncpu 2>&1`
161 SunOS)
162 CPUS=`psrinfo | wc -l 2>&1`
165 CPUS=1 # default
167 esac
170 cat > Makefile << EOF
171 MAKEFLAGS += -j$CPUS
172 CMAKEFLAGS += --parallel=$CPUS
173 PREFIX=\$(abspath ./build)
176 for t in $FOUND; do
177 echo ".$t:" >> Makefile
178 done
180 for t in $NEEDED; do
181 echo .$t: .build$t >> Makefile
182 case "$t" in
183 *$DEPS_ONLY*)
184 ;; # Dependency only, not build by default
186 PACKAGES="$PACKAGES $t"
187 TARGETS="$TARGETS .build$t"
189 esac
190 done
192 [ -n "$PACKAGES" ] && mkdir -p build/ && echo "To-be-built packages: $PACKAGES"
194 cat >> Makefile << EOF
195 all: $TARGETS
196 @echo "You are ready to build VLC and its contribs"
198 include tools.mak