playlist demuxer: remove tabs
[vlc.git] / extras / tools / bootstrap
blobfd399315fe1a2ffa81e790ab9aad9ba6c6d1ca7b
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 if [ -z "$1" ];then
98 FOUND="$FOUND nasm"
99 else
100 gotver=`nasm -v | cut -d ' ' -f 3`
101 check_version nasm $gotver $1
106 check() {
107 if ! $1 --version >/dev/null 2>&1 && ! $1 -version >/dev/null 2>&1
108 then
109 echo "$1 not found"
110 NEEDED="$NEEDED $1"
111 else
112 # found, need to check version ?
113 if [ -z "$2" ];then
114 FOUND="$FOUND $1"
115 else
116 gotver=`$1 --version | head -1 | sed s/'.* '//`
117 check_version $1 $gotver $2
122 check_majmin() {
123 if ! $1 --version >/dev/null 2>&1 && ! $1 -version >/dev/null 2>&1 && ! $1 --version 2>/dev/null
124 then
125 echo "$1 not found"
126 NEEDED="$NEEDED $1"
127 else
128 # found, need to check version ?
129 if [ -z "$2" ];then
130 FOUND="$FOUND $1"
131 else
132 gotver=`$1 --version | head -1 | sed s/'.* '//`
133 check_version_majmin $1 $gotver $2
138 check autoconf 2.69
139 check automake 1.15
140 check m4 1.4.16
141 check libtool 2.4
142 check pkg-config
143 check cmake 3.8.2
144 check yasm
145 check_tar
146 check ragel
147 check_sed
148 check_majmin protoc 3.1.0
149 check ant
150 check xz
151 check bison 3.0.0
152 check flex
153 check_nasm 2.13.01
154 check gettext
155 check help2man
156 check meson 0.48.1
157 check ninja
159 DEPS_ONLY="help2man"
161 CPUS=
162 case `uname` in
163 Linux|MINGW32*|MINGW64*)
164 CPUS=`getconf _NPROCESSORS_ONLN 2>&1`
166 Darwin|FreeBSD|NetBSD)
167 CPUS=`getconf NPROCESSORS_ONLN 2>&1`
169 OpenBSD)
170 CPUS=`sysctl -n hw.ncpu 2>&1`
172 SunOS)
173 CPUS=`psrinfo | wc -l 2>&1`
176 CPUS=1 # default
178 esac
180 cat > Makefile << EOF
181 MAKEFLAGS += -j$CPUS
182 CMAKEFLAGS += --parallel=$CPUS
183 PREFIX=\$(abspath ./build)
186 for t in $FOUND; do
187 echo ".$t:" >> Makefile
188 done
190 for t in $NEEDED; do
191 echo .$t: .build$t >> Makefile
192 case "$t" in
193 *$DEPS_ONLY*)
194 ;; # Dependency only, not build by default
196 PACKAGES="$PACKAGES $t"
197 TARGETS="$TARGETS .build$t"
199 esac
200 done
202 [ -n "$PACKAGES" ] && mkdir -p build/bin && echo "To-be-built packages: $PACKAGES"
204 cat >> Makefile << EOF
205 all: $TARGETS
206 @echo "You are ready to build VLC and its contribs"
208 include tools.mak