-
Notifications
You must be signed in to change notification settings - Fork 24
/
bootstrap
executable file
·136 lines (118 loc) · 3.13 KB
/
bootstrap
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
#!/bin/sh
#
# bootstrap script to get the tools needed to build the specs within a UNIX shell
export LC_ALL=
FOUND=
NEEDED=
MMARK_VERSION=2.2.30
XML2RFC_VERSION=2.46.0
BOOTSTRAP_MAKE=bootstrap.mak
RUNTIMES_MAKE=runtimes.mak
check_version() {
gotver=$2
gotmajor=`echo $gotver|cut -d. -f1`
gotminor=`echo $gotver|cut -d. -f2|cut -d+ -f1`
gotmicro=`echo $gotver|cut -d. -f3|cut -d+ -f1`
[ -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" \
-o "$needmajor" -eq "$gotmajor" -a "$needminor" -gt "$gotminor" \
-o "$needmajor" -eq "$gotmajor" -a "$needminor" -eq "$gotminor" -a "$needmicro" -gt "$gotmicro" ]
then
echo "$1 too old (got $gotver, needed $3)"
NEEDED="$NEEDED $1"
else
FOUND="$FOUND $(command -v $1)"
echo "found $1 version $2 (needed $3)"
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 $(command -v $1)"
echo "found $1"
else
gotver=`$1 --version | head -1 | sed s/'.* '//`
check_version $1 $gotver $2
fi
fi
}
# check make
check mmark $MMARK_VERSION
check xml2rfc $XML2RFC_VERSION
cat > $BOOTSTRAP_MAKE << EOF
# Generated from boostrap
PREFIX=\$(abspath ./build)
EOF
echo > $RUNTIMES_MAKE << EOF
# Generated from boostrap
# calls the local or installed tool
EOF
for t in $FOUND; do
echo ".$t:" >> $BOOTSTRAP_MAKE
VAR_NAME=$(echo "$(basename $t)" | awk '{ tool = sprintf("%s_CALL", toupper($0)); print tool }')
echo "$VAR_NAME := $t" >> $RUNTIMES_MAKE
done
for t in $NEEDED; do
echo .$t: .build$t >> $BOOTSTRAP_MAKE
PACKAGES="$PACKAGES $t"
TARGETS="$TARGETS .build$t"
if [ $t = "xml2rfc" ]; then
# installed in the Python local user dir
PYTHON_USER_PATH=$(python3 -m site --user-base)
echo PYTHON_USER_PATH=$PYTHON_USER_PATH >> $RUNTIMES_MAKE
echo "$t" | awk '{ tool = sprintf("%s_CALL := $(PYTHON_USER_PATH)/bin/%s", toupper($0), $0); print tool }' >> $RUNTIMES_MAKE
else
echo "$t" | awk '{ tool = sprintf("%s_CALL := ./%s", toupper($0), $0); print tool }' >> $RUNTIMES_MAKE
fi
done
[ -n "$PACKAGES" ] && echo "Out of date packages: $PACKAGES"
case `uname` in
Linux)
MMARK_OS=linux
;;
Darwin)
MMARK_OS=darwin
;;
MINGW32*|MINGW64*|*MSYS*)
MMARK_OS=windows
;;
*)
echo Unsupported build OS `uname`
exit 1
;;
esac
case `uname -m` in
x86_64)
MMARK_MACHINE=amd64
;;
arm64)
MMARK_MACHINE=arm64
;;
arm)
MMARK_MACHINE=arm
;;
*)
echo Unsupported build CPU `uname -m`
exit 1
;;
esac
cat >> $BOOTSTRAP_MAKE << EOF
all: $TARGETS
@echo "You are ready to build EBML specifications"
MMARK_VERSION=$MMARK_VERSION
MMARK_OS=$MMARK_OS
MMARK_MACHINE=$MMARK_MACHINE
XML2RFC_VERSION=$XML2RFC_VERSION
include tools.mak
EOF
echo Getting necessary tools
make -f $BOOTSTRAP_MAKE