-
Notifications
You must be signed in to change notification settings - Fork 8
/
RUNME
executable file
·178 lines (156 loc) · 5.41 KB
/
RUNME
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/bash
#
# Copyright (C) 2014 Neil McGill
#
# This software is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be fun,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this software; if not, write to the Free
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
. ./build/common.sh
help()
{
cat << %%
Build options:
Usage: $0 [options]
[--gcc] Prefer g++ over clang++
[--clang] Prefer clang++
%%
}
OPT_GCC=
OPT_CLANG=
read_opts()
{
while [ "$#" -ne 0 ];
do
local option=$1
case $option in
-*gcc)
OPT_GCC="yes"
export OPT_GCC
shift
;;
-*clang)
OPT_CLANG="yes"
export OPT_CLANG
shift
;;
*)
help
exit 1
;;
esac
done
}
read_opts $*
rm -f Makefile
cat Makefile.base | sed '/DO NOT DELETE/,$d' > Makefile.tmp
mv Makefile.tmp Makefile
makedepend *.cpp -p .o/ 2>/dev/null
echo "COMPILER_FLAGS=-Werror -g -ggdb3 -O3 -fstack-protector-all -I . -I examples # AUTOGEN" > .Makefile
echo " " >> .Makefile
echo "CLANG_COMPILER_WARNINGS=-Wall # AUTOGEN" >> .Makefile
echo "GCC_COMPILER_WARNINGS=-Wall # AUTOGEN" >> .Makefile
echo "GXX_COMPILER_WARNINGS=-Wall # AUTOGEN" >> .Makefile
if [[ $OPT_GCC = "yes" ]]; then
echo "COMPILER_WARNINGS=\$(CLANG_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GXX_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GCC_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "CXX=g++ # AUTOGEN" >> .Makefile
elif [[ $OPT_CLANG = "yes" ]]; then
echo "COMPILER_WARNINGS=\$(CLANG_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GXX_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GCC_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "CXX=clang++ # AUTOGEN" >> .Makefile
else
`clang++ --version >/dev/null 2>/dev/null`
if [ $? -eq 0 ]
then
echo "COMPILER_WARNINGS=\$(GCC_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GXX_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(CLANG_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "CXX=clang++ # AUTOGEN" >> .Makefile
else
`gcc --version >/dev/null 2>/dev/null`
if [ $? -eq 0 ]
then
echo "COMPILER_WARNINGS=\$(CLANG_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GXX_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GCC_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "# CXX=clang++ # AUTOGEN" >> .Makefile
echo "CXX=gcc # AUTOGEN" >> .Makefile
echo "# CXX=cc # AUTOGEN" >> .Makefile
echo "# CXX=g++ # AUTOGEN" >> .Makefile
else
`g++ --version >/dev/null 2>/dev/null`
if [ $? -eq 0 ]
then
echo "COMPILER_WARNINGS=\$(CLANG_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GCC_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GXX_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "# CXX=clang++ # AUTOGEN" >> .Makefile
echo "# CXX=gcc # AUTOGEN" >> .Makefile
echo "# CXX=cc # AUTOGEN" >> .Makefile
echo "CXX=g++ # AUTOGEN" >> .Makefile
else
echo "COMPILER_WARNINGS=\$(CLANG_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GXX_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "COMPILER_WARNINGS=\$(GCC_COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
echo "# CXX=clang++ # AUTOGEN" >> .Makefile
echo "# CXX=gcc # AUTOGEN" >> .Makefile
echo "# CXX=cc # AUTOGEN" >> .Makefile
echo "CXX=g++ # AUTOGEN" >> .Makefile
fi
fi
fi
fi
echo " " >> .Makefile
echo "EXE=$EXE # AUTOGEN" >> .Makefile
echo "LDLIBS=$LDLIBS # AUTOGEN" >> .Makefile
echo "CFLAGS=\$(COMPILER_FLAGS) \$(COMPILER_WARNINGS) # AUTOGEN" >> .Makefile
cat Makefile | grep -v AUTOGEN | grep -v "^ $" >> .Makefile
if [ -s .Makefile ]
then
mv .Makefile Makefile
if [ ! -f Makefile ]
then
log_err "No makefile?!"
exit 1
fi
else
log_err "Makefile create fail?!"
exit 1
fi
log_info "Cleaning"
make clobber | sed 's/^/ /g'
CORES=""
case `uname` in
*Darwin*)
CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep Cores | sed 's/.*: //g'`
;;
*inux*)
CORES=`cat /proc/cpuinfo | grep "cpu cores" | head -1 | awk '{print $4}'`
;;
esac
if [ "$CORES" != "" ]
then
CORES="-j $CORES"
fi
log_info "Compiling"
make $CORES all
if [ $? -eq 0 ]
then
log_info "Run ./c_plus_plus_serializer to start"
rm -f Makefile.bak
else
log_die "Build failed"
fi