forked from mellotanica/uARM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile
executable file
·155 lines (141 loc) · 3.1 KB
/
compile
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
#!/bin/bash
function usage(){
PNAME=$(basename $0)
echo -e "Usage\t$PNAME [-h] [-nc] [-ca] [-u] [target] -- [make options]"
echo
echo -e "\t$PNAME\t compiles all binaries"
echo -e "\t$PNAME -h\t shows this help"
echo -e "\t$PNAME target\t compiles desired target"
echo -e "\t$PNAME -nc\t avoid ./configure execution before compilation"
echo -e "\t$PNAME -ca\t run \`make cleanall\` before compiling each target (sometimes needed to fix compilation errors)"
echo -e "\t$PNAME -u\t compile universal binaries"
echo
echo -e "\tmake options are used by make when compiling each target"
echo
echo -e "\tPossible targets are:"
echo -e "\t\tmkdev"
echo -e "\t\tuarm"
}
function compile(){
echo "Compiling $1...."
echo
XN="$1"
BD="$1"-build
MD=`pwd`
shift
mkdir -p "$BD"
pushd "$BD" > /dev/null
$QMCOMP "$MD/$1"
shift
if $CLEANALL; then
echo "cleaning target $XN.."
make clean > /dev/null 2>&1
make cleanall > /dev/null 2>&1
fi
make $*
popd > /dev/null
cp -R "$BD/$XN" .
}
SET=""
CONFIGURE=true
CLEANALL=false
UNIVERSAL=false
if test $# -gt 0; then
SCAN=false
while test -n "$1"; do
case "$1" in
"uarm")
SET="u:$SET"
;;
"mkdev")
SET="m:$SET"
;;
"-h")
usage
exit 0
;;
"--")
SCAN=true
;;
"-nc")
CONFIGURE=false
;;
"-ca")
CLEANALL=true
;;
"-u")
UNIVERSAL=true
;;
*)
echo "unknown target: $1"
usage
exit 1
;;
esac
shift
if $SCAN; then
break
fi
done
fi
if test -z "$SET"; then
SET="u:m:e"
fi
QMCOMP="qmake"
PLATFORM=`uname -s`
if [[ "$PLATFORM" == "Linux" ]]; then
qtchooser >> /dev/null 2> /dev/null
QMAKERET=`echo $?`
if [ $QMAKERET -ne 127 ]; then
VERSION=0
for v in `qtchooser -list-versions`; do
if [[ $v == 5* ]]; then
VERSION=`echo $v`
break
fi
done
if [ "$VERSION" == 0 ]; then
echo "!!!!!!!! it seems you don't have qt5 installed, aborting compilation !!!!!!!!"
exit 1
fi
QMCOMP="qtchooser -run-tool=qmake -qt=$VERSION"
else
if test -n "$(which qmake-qt5)"; then
QMCOMP="qmake-qt5"
else
echo "!!!!!!!! it seems you don't have qt5 installed, aborting compilation !!!!!!!!"
exit 1
fi
fi
elif [[ "$PLATFORM" == "Darwin" ]]; then
which -s brew
if [[ $? != 0 ]] ; then
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
for pkg in qt5 libelf boost; do
if brew list -1 | grep -q "^${pkg}\$"; then
echo "Package '$pkg' is installed"
else
brew install "$pkg"
fi
done
QMCOMP="$(brew --prefix qt5)/bin/qmake"
if ! $UNIVERSAL; then
QMCOMP="$QMCOMP QMAKE_MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | awk -F '.' '{print $1 "." $2}')"
fi
fi
echo "Compiler command: \"$QMCOMP $*\""
echo
if $CONFIGURE; then
./configure
fi
if [[ "$SET" = *"u"* ]]; then
uarm="uarm"
if [[ "$PLATFORM" == "Darwin" ]]; then
uarm="uarm.app"
fi
compile $uarm "qarm.pro" $*
fi
if [[ "$SET" = *"m"* ]]; then
compile "uarm-mkdev" "mkdev.pro" $*
fi