Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
executable file 136 lines (118 sloc) 3.13 KB
#!/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.8
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