decoder: fix data race
[vlc.git] / extras / tools / bootstrap
blob8e3e0351239669f95f8419f9628f43b026a7ef9b
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 FOUND=
21 check_version() {
22 gotver=$2
23 gotmajor=`echo $gotver|cut -d. -f1`
24 gotminor=`echo $gotver|cut -d. -f2`
25 gotmicro=`echo $gotver|cut -d. -f3`
26 [ -z "$gotmicro" ] && gotmicro=0
27 needmajor=`echo $3|cut -d. -f1`
28 needminor=`echo $3|cut -d. -f2`
29 needmicro=`echo $3|cut -d. -f3`
30 [ -z "$needmicro" ] && needmicro=0
31 if [ "$needmajor" -ne "$gotmajor" \
32 -o "$needmajor" -eq "$gotmajor" -a "$needminor" -gt "$gotminor" \
33 -o "$needmajor" -eq "$gotmajor" -a "$needminor" -eq "$gotminor" -a "$needmicro" -gt "$gotmicro" ]
34 then
35 echo "$1 too old"
36 NEEDED="$NEEDED $1"
37 else
38 FOUND="$FOUND $1"
43 check_version_majmin() {
44 gotver=$2
45 gotmajor=`echo $gotver|cut -d. -f1`
46 gotminor=`echo $gotver|cut -d. -f2`
47 needmajor=`echo $3|cut -d. -f1`
48 needminor=`echo $3|cut -d. -f2`
49 if [ "$needmajor" -ne "$gotmajor" \
50 -o "$needminor" -ne "$gotminor" ]
51 then
52 echo "$1 not compatible"
53 NEEDED="$NEEDED $1"
54 else
55 FOUND="$FOUND $1"
60 check_tar() {
61 if ! tar PcJ /dev/null >/dev/null 2>&1 && ! tar PcJf /dev/null /dev/null 2>&1
62 then
63 echo "tar doesn't support xz (J option)"
64 NEEDED="$NEEDED tar xz"
65 else
66 FOUND="$FOUND tar xz"
70 check_sed() {
71 tmp="`pwd`/check_sed"
72 trap "rm \"$tmp\" \"$tmp-e\" 2>/dev/null" EXIT
73 echo "test file for GNU sed" > $tmp
74 if ! sed -i -e 's/sed//' $tmp >/dev/null 2>&1
75 then
76 echo "sed doesn't do in-place editing (-i option)"
77 NEEDED="$NEEDED sed"
78 else
79 FOUND="$FOUND sed"
83 check_nasm() {
84 if ! nasm -v >/dev/null 2>&1
85 then
86 echo "nasm not found"
87 NEEDED="$NEEDED nasm"
88 else
89 # found, need to check version ?
90 if [ -z "$1" ];then
91 FOUND="$FOUND nasm"
92 else
93 gotver=`nasm -v | cut -d ' ' -f 3`
94 check_version nasm $gotver $1
99 check() {
100 if ! $1 --version >/dev/null 2>&1 && ! $1 -version >/dev/null 2>&1
101 then
102 echo "$1 not found"
103 NEEDED="$NEEDED $1"
104 else
105 # found, need to check version ?
106 if [ -z "$2" ];then
107 FOUND="$FOUND $1"
108 else
109 gotver=`$1 --version | head -1 | sed s/'.* '//`
110 check_version $1 $gotver $2
115 check_majmin() {
116 if ! $1 --version >/dev/null 2>&1 && ! $1 -version >/dev/null 2>&1 && ! $1 --version 2>/dev/null
117 then
118 echo "$1 not found"
119 NEEDED="$NEEDED $1"
120 else
121 # found, need to check version ?
122 if [ -z "$2" ];then
123 FOUND="$FOUND $1"
124 else
125 gotver=`$1 --version | head -1 | sed s/'.* '//`
126 check_version_majmin $1 $gotver $2
131 check autoconf 2.69
132 check automake 1.15
133 check m4 1.4.16
134 check libtool 2.4
135 check pkg-config
136 check cmake 3.17.0
137 check yasm
138 check_tar
139 check ragel
140 check_sed
141 check_majmin protoc 3.1.0
142 check ant
143 check xz
144 check bison 3.0.0
145 check flex
146 check_nasm 2.14
147 check gettext
148 check help2man
149 check meson 0.54.2
150 check ninja
152 DEPS_ONLY="help2man"
154 CPUS=
155 case `uname` in
156 Linux|MINGW32*|MINGW64*|*MSYS*)
157 CPUS=`getconf _NPROCESSORS_ONLN 2>&1`
159 Darwin|FreeBSD|NetBSD)
160 CPUS=`getconf NPROCESSORS_ONLN 2>&1`
162 OpenBSD)
163 CPUS=`sysctl -n hw.ncpu 2>&1`
165 SunOS)
166 CPUS=`psrinfo | wc -l 2>&1`
169 CPUS=1 # default
171 esac
173 BOOTSTRAP_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
175 cat > Makefile << EOF
176 TOOLS = $BOOTSTRAP_PATH
177 MAKEFLAGS += -j$CPUS
178 CMAKEFLAGS += --parallel=$CPUS
179 PREFIX=\$(abspath ./build)
180 PATH=\${PREFIX}/bin:$PATH
183 for t in $FOUND; do
184 echo ".$t:" >> Makefile
185 done
187 for t in $NEEDED; do
188 echo .$t: .build$t >> Makefile
189 case "$t" in
190 *$DEPS_ONLY*)
191 ;; # Dependency only, not build by default
193 PACKAGES="$PACKAGES $t"
194 TARGETS="$TARGETS .build$t"
196 esac
197 done
199 [ -n "$PACKAGES" ] && mkdir -p build/bin && echo "To-be-built packages: $PACKAGES"
201 cat >> Makefile << EOF
202 all: $TARGETS
203 @echo "You are ready to build VLC and its contribs"
205 include \$(TOOLS)/tools.mak