forked from B-Lang-org/bsc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
platform.sh
executable file
·68 lines (56 loc) · 1.36 KB
/
platform.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
63
64
65
66
67
68
#!/bin/sh
usage()
{
echo "Usage: $0 <option>"
echo ""
echo "Display canonical platform information"
echo "Valid options are:"
echo " ostype "
echo " machtype "
echo " c++_shared_flags"
}
if [ $# -ne 1 ] ; then
usage
exit 1;
fi
## =========================
## OSTYPE
if [ -z "${OSTYPE}" ] ; then
OSTYPE=`uname -s`
fi
## Account for values like "linux-gnu" by removing extra fields
OSTYPE=$(echo ${OSTYPE} | cut -d'-' -f1)
## Account for values like "Darwin10.0" by removing the version number
OSTYPE=$(echo ${OSTYPE} | egrep -o "^[A-Za-z]+")
## Account for lowercase values like "linux" when we want "Linux"
OSTYPE=$(echo ${OSTYPE} | cut -c1 | tr a-z A-Z)$(echo $OSTYPE | cut -c2- | tr A-Z a-z)
if [ "$1" = "ostype" ] ; then
echo ${OSTYPE}
exit 0
fi
## =========================
## MACHTYPE
if [ -z "${MACHTYPE}" ] ; then
MACHTYPE=`uname -m`
fi
## Account for values like "x86_64-pc-linux-gnu" when all we want is
## "x86_64", "i386", etc
MACHTYPE=$(echo ${MACHTYPE} | cut -d'-' -f1)
if [ "$1" = "machtype" ] ; then
echo ${MACHTYPE}
exit 0
fi
## =========================
## C++ SHARED FLAGS
if [ "$1" = "c++_shared_flags" ] ; then
if [ "${OSTYPE}" = "Darwin" ]
then
echo "-dynamiclib -Wl,-undefined,dynamic_lookup"
else
echo "-shared"
fi
exit 0
fi
## =========================
usage
exit 1