-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRUNME
executable file
·203 lines (174 loc) · 5.59 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/sh
#
# Copyright (C) 2013 Neil McGill
#
# See the LICENSE file for license.
#
ESC=""
DULL=0
BRIGHT=1
FG_BLACK=30
FG_RED=31
FG_GREEN=32
FG_YELLOW=33
FG_BLUE=34
FG_MAGENTA=35
FG_CYAN=36
FG_WHITE=37
FG_NULL=00
BG_BLACK=40
BG_RED=41
BG_GREEN=42
BG_YELLOW=43
BG_BLUE=44
BG_MAGENTA=45
BG_CYAN=46
BG_WHITE=47
BG_NULL=00
ESC="["
NORMAL="${ESC}m"
RESET="${ESC}${DULL};${FG_WHITE};${BG_NULL}m"
# DULL TEXT
BLACK="${ESC}${DULL};${FG_BLACK}m"
RED="${ESC}${DULL};${FG_RED}m"
GREEN="${ESC}${DULL};${FG_GREEN}m"
YELLOW="${ESC}${DULL};${FG_YELLOW}m"
BLUE="${ESC}${DULL};${FG_BLUE}m"
MAGENTA="${ESC}${DULL};${FG_MAGENTA}m"
CYAN="${ESC}${DULL};${FG_CYAN}m"
WHITE="${ESC}${DULL};${FG_WHITE}m"
ON_BLACK="${ESC}${DULL};${BG_BLACK}m"
ON_RED="${ESC}${DULL};${BG_RED}m"
ON_GREEN="${ESC}${DULL};${BG_GREEN}m"
ON_YELLOW="${ESC}${DULL};${BG_YELLOW}m"
ON_BLUE="${ESC}${DULL};${BG_BLUE}m"
ON_MAGENTA="${ESC}${DULL};${BG_MAGENTA}m"
ON_CYAN="${ESC}${DULL};${BG_CYAN}m"
ON_WHITE="${ESC}${DULL};${BG_WHITE}m"
# BRIGHT TEXT
BRIGHT_BLACK="${ESC}${BRIGHT};${FG_BLACK}m"
BRIGHT_RED="${ESC}${BRIGHT};${FG_RED}m"
BRIGHT_GREEN="${ESC}${BRIGHT};${FG_GREEN}m"
BRIGHT_YELLOW="${ESC}${BRIGHT};${FG_YELLOW}m"
BRIGHT_BLUE="${ESC}${BRIGHT};${FG_BLUE}m"
BRIGHT_MAGENTA="${ESC}${BRIGHT};${FG_MAGENTA}m"
BRIGHT_CYAN="${ESC}${BRIGHT};${FG_CYAN}m"
BRIGHT_WHITE="${ESC}${BRIGHT};${FG_WHITE}m"
setenv() {
eval "$1='$2'"; export $1;
}
log() {
echo "${MAGENTA}$*${RESET}"
}
log_info() {
echo "fatdisk: ${GREEN}$*${RESET}"
}
log_echo() {
echo "fatdisk: $*"
}
log_err() {
echo "fatdisk: ${RED}ERROR: $*${RESET}"
}
log_warn() {
echo "fatdisk: ${CYAN}WARN: $*${RESET}"
}
log_die() {
echo "fatdisk: ${RED}FATAL ERROR: $*${RESET}"
echo "Mail [email protected] for help"
exit 1
}
run() {
echo " $*"
$*
}
ARCH=`arch`
cat Makefile.base | sed '/DO NOT DELETE/,$d' | sed "s/^TARGET_FATDISK=.*/TARGET_FATDISK=fatdisk.$ARCH/g" > Makefile.tmp
mv Makefile.tmp Makefile
makedepend *.c -p .o/ 2>/dev/null
if [ $? -ne 0 ]
then
log_warn "Is makedepend installed? If not:"
log_warn " For ubuntu do: sudo apt-get install xutils-dev"
log_warn " For MAC do: sudo port install makedepend"
log_warn " For MingW do: not supported AFAIK"
fi
echo "COMPILER_FLAGS=-Werror -g -O0 $SDL_FLAGS # AUTOGEN" >> .Makefile
echo "COMPILER_FLAGS=-g -O2 $SDL_FLAGS # AUTOGEN" > .Makefile
echo " " >> .Makefile
echo "CLANG_COMPILER_WARNINGS=-fmessage-length=0 -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-sign-conversion # AUTOGEN" >> .Makefile
echo "GCC_COMPILER_WARNINGS=-fmessage-length=0 -Wno-trigraphs -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value # AUTOGEN" >> .Makefile
echo "GXX_COMPILER_WARNINGS=-fmessage-length=0 -Wno-trigraphs -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value # AUTOGEN" >> .Makefile
`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 "CC=clang # AUTOGEN" >> .Makefile
echo "# CC=gcc # AUTOGEN" >> .Makefile
echo "# CC=cc # AUTOGEN" >> .Makefile
echo "# CC=g++ # 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 "# CC=clang # AUTOGEN" >> .Makefile
echo "CC=gcc # AUTOGEN" >> .Makefile
echo "# CC=cc # AUTOGEN" >> .Makefile
echo "# CC=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 "# CC=clang # AUTOGEN" >> .Makefile
echo "# CC=gcc # AUTOGEN" >> .Makefile
echo "# CC=cc # AUTOGEN" >> .Makefile
echo "CC=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 "# CC=clang # AUTOGEN" >> .Makefile
echo "# CC=gcc # AUTOGEN" >> .Makefile
echo "# CC=cc # AUTOGEN" >> .Makefile
echo "CC=g++ # AUTOGEN" >> .Makefile
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 clean | sed 's/^/ /g'
log_info "Compiling"
make $CORES $* all
if [ $? -eq 0 ]
then
echo
log_info "Run fatdisk -h for more info. Or run ./TESTME"
rm -f Makefile.bak
else
cd ..
log_die "Build failed"
fi
cd ..