-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathget-libmame.sh
executable file
·63 lines (53 loc) · 1.55 KB
/
get-libmame.sh
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
#!/bin/sh
##
## get-libmame.sh [target] [clean | source]
##
## get version of libmame from MAME project, or the web
##
## target is one of the following
## ios get libmame-ios.a for iOS
## tvos get libmame-tvos.a for tvOS
## mac get libmame-mac.a for Catalyst
## all get all
##
## source is path to MAME project or blank for default (../MAME)
##
if [ "$1" == "" ] || [ "$1" == "clean" ]; then
$0 ios $1
exit
fi
if [ "$1" == "all" ]; then
$0 ios $2
$0 tvos $2
$0 mac $2
exit
fi
if [ "$1" != "ios" ] && [ "$1" != "tvos" ] && [ "$1" != "mac" ] && [ "$1" != "ios-simulator" ] && [ "$1" != "tvos-simulator" ]; then
echo "USAGE: $0 [ios | tvos | mac | all] [path to MAME]"
exit
fi
LIBMAME="libmame-$1.a"
LIBMAME_URL="https://github.com/ToddLa/mame/releases/latest/download/$LIBMAME.gz"
## only do a clean and get out
if [ "$2" == "clean" ]; then
echo CLEAN $LIBMAME
rm -f $LIBMAME
exit
fi
## copy from local custom build
if [ -f "$2/$LIBMAME" ]; then
echo COPY "$2/$LIBMAME"
cp "$2/$LIBMAME" .
exit
fi
## copy from local custom build
if [ -f "../MAME/$LIBMAME" ]; then
echo COPY "../MAME/$LIBMAME"
cp "../MAME/$LIBMAME" .
exit
fi
## download from GitHub if no local version, *or* version on GitHub is newer
if [ ! -f "$LIBMAME" ] || [ 200 == `curl --silent --head --output /dev/null --write-out "%{http_code}" -z $LIBMAME -L $LIBMAME_URL` ]; then
echo DOWNLOAD $LIBMAME
curl -L $LIBMAME_URL | gunzip > $LIBMAME || (rm -r $LIBMAME; echo "DOWNLOAD $LIBMAME ** FAILED")
fi