File: bootstrap

package info (click to toggle)
vlc 3.0.22-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 208,324 kB
  • sloc: ansic: 443,399; cpp: 111,127; objc: 36,399; sh: 6,737; makefile: 6,623; javascript: 4,902; xml: 1,611; asm: 1,355; yacc: 644; python: 321; lex: 88; perl: 77; sed: 16
file content (205 lines) | stat: -rwxr-xr-x 4,780 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#!/bin/sh
# Copyright © 2011 Rafaël Carré
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.

export LC_ALL=
FOUND=

check_version() {
    gotver=$2
    gotmajor=`echo $gotver|cut -d. -f1`
    gotminor=`echo $gotver|cut -d. -f2`
    gotmicro=`echo $gotver|cut -d. -f3|tr -c -d '[:digit:]'`
    [ -z "$gotmicro" ] && gotmicro=0
    needmajor=`echo $3|cut -d. -f1`
    needminor=`echo $3|cut -d. -f2`
    needmicro=`echo $3|cut -d. -f3`
    [ -z "$needmicro" ] && needmicro=0
    if [ "$needmajor" -ne "$gotmajor" ] ||
       [ "$needmajor" -eq "$gotmajor" -a "$needminor" -gt "$gotminor" ] ||
       [ "$needmajor" -eq "$gotmajor" -a "$needminor" -eq "$gotminor" -a "$needmicro" -gt "$gotmicro" ];
    then
        echo "$1 incompatible version (expected $3, got $2)"
        NEEDED="$NEEDED $1"
    else
        FOUND="$FOUND $1"
    fi

}

check_version_majmin() {
    gotver=$2
    gotmajor=`echo $gotver|cut -d. -f1`
    gotminor=`echo $gotver|cut -d. -f2`
    needmajor=`echo $3|cut -d. -f1`
    needminor=`echo $3|cut -d. -f2`
    if [ "$needmajor" -ne "$gotmajor" \
         -o "$needminor" -ne "$gotminor" ]
    then
        echo "$1 not compatible"
        NEEDED="$NEEDED $1"
    else
        FOUND="$FOUND $1"
    fi

}

check_tar() {
if ! tar PcJ /dev/null >/dev/null 2>&1
then
    echo "tar doesn't support xz (J option)"
    NEEDED="$NEEDED tar xz"
else
    FOUND="$FOUND tar xz"
fi
}

check_sed() {
tmp="`pwd`/check_sed"
trap "rm \"$tmp\" \"$tmp-e\" 2>/dev/null" EXIT
echo "test file for GNU sed" > $tmp
if ! sed -i -e 's/sed//' $tmp >/dev/null 2>&1
then
    echo "sed doesn't do in-place editing (-i option)"
    NEEDED="$NEEDED sed"
else
    FOUND="$FOUND sed"
fi
}

check_nasm() {
if ! nasm -v >/dev/null 2>&1
then
    echo "nasm not found"
    NEEDED="$NEEDED nasm"
else
    # found, need to check version ?
    if [ -z "$1" ];then
        FOUND="$FOUND nasm"
    else
        gotver=`nasm -v | cut -d ' ' -f 3`
        check_version nasm $gotver $1
    fi
fi
}

check() {
if ! $1 --version >/dev/null 2>&1 && ! $1 -version >/dev/null 2>&1
then
    echo "$1 not found"
    NEEDED="$NEEDED $1"
else
    # found, need to check version ?
    if [ -z "$2" ];then
        FOUND="$FOUND $1"
    else
        gotver=`$1 --version | head -1 | grep -o '[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?' | head -1`
        check_version $1 $gotver $2
    fi
fi
}

check_majmin() {
if ! $1 --version >/dev/null 2>&1 && ! $1 -version >/dev/null 2>&1 && ! $1 --version 2>/dev/null
then
    echo "$1 not found"
    NEEDED="$NEEDED $1"
else
    # found, need to check version ?
    if [ -z "$2" ];then
        FOUND="$FOUND $1"
    else
        gotver=`$1 --version | head -1 | sed s/'.* '//`
        check_version_majmin $1 $gotver $2
    fi
fi
}

check autoconf 2.69
check automake 1.15
check m4 1.4.16
check libtool 2.4
check pkg-config
check cmake 3.17.0
check yasm
check_tar
check_sed
check protoc 2.6.0
check ant
check xz
check bison 3.0.0
check flex
check_nasm 2.14
check help2man
check meson 0.60.0
check ninja
check gettext

DEPS_ONLY="help2man"

CPUS=
case `uname` in
    Linux|MINGW32*|MINGW64*)
        CPUS=`getconf _NPROCESSORS_ONLN 2>&1`
     ;;
    Darwin|FreeBSD|NetBSD)
        CPUS=`getconf NPROCESSORS_ONLN 2>&1`
    ;;
    OpenBSD)
        CPUS=`sysctl -n hw.ncpu 2>&1`
    ;;
    SunOS)
        CPUS=`psrinfo | wc -l 2>&1`
    ;;
    *)
        CPUS=1  # default
     ;;
esac

BOOTSTRAP_PATH="$( cd "$(dirname "$0")" ; pwd -P )"

cat > Makefile << EOF
TOOLS = $BOOTSTRAP_PATH
MAKEFLAGS += -j$CPUS
CMAKEFLAGS += --parallel=$CPUS
PREFIX=\$(abspath ./build)
PATH=\${PREFIX}/bin:$PATH
EOF

for t in $FOUND; do
    echo ".$t:" >> Makefile
done

for t in $NEEDED; do
    echo .$t: .build$t >> Makefile
    case "$t" in
        *$DEPS_ONLY*)
            ;; # Dependency only, not build by default
        *)
            PACKAGES="$PACKAGES $t"
            TARGETS="$TARGETS .build$t"
            ;;
    esac
done

[ -n "$PACKAGES" ] && mkdir -p build/bin && echo "To-be-built packages: $PACKAGES"

cat >> Makefile << EOF
all: $TARGETS
	@echo "You are ready to build VLC and its contribs"

include \$(TOOLS)/tools.mak
EOF