]> git.sesse.net Git - vlc/blob - extras/tools/bootstrap
920d9f969b7bed8d7dd20caa2e4612216eda0b16
[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() {
28 if ! $1 --version >/dev/null 2>&1
29 then
30     echo "$1 not found"
31     NEEDED="$NEEDED .$1"
32 else
33     # found, need to check version ?
34     [ -z "$2" ] && return # no
35     # we only check GNU tools, their version have the form MAJOR.MINOR
36     gotver=`$1 --version | head -1 | sed s/'.* '//`
37     gotmajor=`echo $gotver|cut -d. -f1`
38     gotminor=`echo $gotver|cut -d. -f2`
39     needmajor=`echo $2|cut -d. -f1`
40     needminor=`echo $2|cut -d. -f2`
41     if [ "$needmajor" -gt "$gotmajor" -o "$needmajor" -eq "$gotmajor" -a "$needminor" -gt "$gotminor" ]
42     then
43         echo "$1 too old"
44         NEEDED="$NEEDED .$1"
45     fi
46 fi
47 }
48
49 check autoconf 2.67
50 check automake 1.11
51 check libtool 2.2
52 check pkg-config
53 check xz
54 check cmake
55 check yasm
56 check tar 1.22
57
58 [ -n "$NEEDED" ] && mkdir -p build/
59
60 CPUS=
61 case `uname` in
62     Linux)
63         CPUS=`grep -c ^processor /proc/cpuinfo`
64      ;;
65     Darwin)
66         CPUS=`sysctl hw.ncpu|cut -d: -f2`
67     ;;
68     *)
69         CPUS=1  # default
70      ;;
71 esac
72
73
74 cat > Makefile << EOF
75 MAKEFLAGS += -j$CPUS
76 PREFIX=\$(abspath ./build)
77
78 all: $NEEDED
79         @echo "You are ready to build VLC and its contribs"
80
81 automake: .autoconf
82
83 include tools.mak
84 EOF