-
Notifications
You must be signed in to change notification settings - Fork 70
/
_build
361 lines (348 loc) · 12.9 KB
/
_build
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
#!/bin/bash
# +-------------------------------------------------------------------+
# ! !
# ! Name: _build !
# ! !
# ! Desc: build Hercules with various options !
# ! !
# ! Usage: !
# ! !
# ! >>- build -+------------------------+-+---------------------+-> !
# ! ! ! ! ! !
# ! +- -c --+- i586 -------+-+ +- -t -+-- fthread -+-+ !
# ! ! ! ! ! !
# ! +- i686 -------+ +-- f -------+ !
# ! ! ! ! ! !
# ! +- pentium ----+ +-- pthread -+ !
# ! ! ! ! ! !
# ! +- athlon -----+ +-- p -------+ !
# ! ! ! !
# ! +- pentiumpro -+ !
# ! ! ! !
# ! +- p4 ---------+ !
# ! ! ! !
# ! +- pentium4 ---+ !
# ! !
# ! >---------+-------+------------------------------------------> !
# ! ! ! !
# ! +- -f --+ force rebuilding of configure !
# ! !
# ! !
# ! >---------+-------------------------------------+------------>< !
# ! ! ! !
# ! +- -p -- number_of_processors (<=8) --+ !
# ! !
# ! !
# ! Defaults: build -c `uname -m` -t f -p 2 !
# ! !
# +-------------------------------------------------------------------+
# !
# ! Change Log: '$Log$
# ! Change Log: 'Revision 1.20 2003/10/12 06:48:13 vbandke
# ! Change Log: 'remove extraneous CR from _build scripts
# ! Change Log: '
# ! Change Log: 'Revision 1.19 2003/10/06 19:51:24 vbandke
# ! Change Log: 'Add support for Linux build. Add support for -p flag (number of processors)
# ! Change Log: '
# ! Change Log: 'Revision 1.18 2003/08/26 11:53:08 vbandke
# ! Change Log: 'remove reference to ABOUT-NLS. Add option -f to forece generation of ./configure
# ! Change Log: '
# ! Change Log: 'Revision 1.17 2003/08/15 13:56:14 vbandke
# ! Change Log: 'fixed minor details
# ! Change Log: '
# ! Change Log: 'Revision 1.16 2002/12/16 16:19:17 vbandke
# ! Change Log: 'remove --prefix=`pwd` from ./configure invocation
# ! Change Log: '
# ! Change Log: 'Revision 1.15 2002/12/15 21:56:03 vbandke
# ! Change Log: 'Complete rework. Include support for P4 processor
# ! Change Log: '
function pause() {
echo -e -n "${MSG}Press the ${MSGHI}ENTER${MSG} key to continue"
read dummy
}
function log() {
if [ $# != 0 ] ; then
THE_TIME=`date +%H:%M:%S`
echo -e "${MSG}${THE_TIME}${DEFAULT} - ${MSGHI}${1}${DEFAULT}"
echo -e "${THE_TIME} - ${1}" >>${LOGFILE} 2>&1
fi
return
}
function logn() {
if [ $# != 0 ] ; then
echo -e " ${MSGHI}${1}${DEFAULT}"
echo -e " ${1}" >>${LOGFILE} 2>&1
fi
return
}
function loga() {
if [ $# != 0 ] ; then
THE_TIME=`date +%H:%M:%S`
echo -e "${MSG}${THE_TIME}${DEFAULT} - ${ERRHI}\a${1}${DEFAULT}"
echo -e "${THE_TIME} - ${1}" >>${LOGFILE} 2>&1
fi
return
}
function lower() {
if [ "${1}X" = "X" ] ; then
echo ""
else
echo -E "${1}" | tr [:upper:] [:lower:]
fi
}
function upper() {
if [ "${1}X" = "X" ] ; then
echo ""
else
echo -E "${1}" | tr [:lower:] [:upper:]
fi
}
function abort() {
loga "*******************************************************************"
loga "* *"
loga "* A B O R T *"
loga "* ========= *"
loga "* *"
loga "*******************************************************************"
logn " "
logn "${1}"
logn " "
logn "Check error messages in logfile ${LOGFILE}"
logn " "
pause
exit
}
clear
. set_color_vars
if [ ${OSTYPE} = cygwin ] ; then
THIS_CYGWIN=`cygcheck -s | grep -i dll\ version:`
THIS_CYGWIN=${THIS_CYGWIN##*: }
DEFTHREAD=fthreads
else
THIS_CYGWIN=n/a
DEFTHREAD=posix
fi
MYCMD=`basename ${0}`
LOGFILE=`pwd`/${MYCMD}.log
cat >${LOGFILE}<<!EOF!
*************************************************************************
*
* Name: ${LOGFILE}
*
* Date: `date`
*
* Command line: ${0} ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9}
*
*************************************************************************
!EOF!
log "Building Hercules Binaries from Local Source"
THREAD_SET=false
CPU_SET=false
NUMCPU_SET=false
NUMCPU=2
AUTO_SET=false
ANSI_SET=true
CPU_TYPE=auto
THREAD_TYPE=fthread
while getopts :c:fn:p:t: THE_OPT ; do
THE_OPT=`lower ${THE_OPT}`
case ${THE_OPT} in
c) CPU_TYPE=${OPTARG}
CPU_SET=true
;;
f) rm -f ./configure
;;
n) ANSI_SET=false
;;
p) NUMCPU_SET=true
NUMCPU=${OPTARG}
;;
t) THREAD_TYPE=${OPTARG}
THREAD_SET=true
;;
:) abort "Required information is missing"
;;
\?) loga "Invalid command switch ${OPTARG}\n"
logn "Syntax is\n"
logn "_build [-c <cputype>] [-t <threadmodel>] [-n] [-f] [-p number_of_CPUs]"
logn " ! ! ! ! !"
logn " ! ! ! ! +--- Number of emulated"
logn " ! ! ! ! Hercules processors"
logn " ! ! ! +-------- force rebuild of configure"
logn " ! ! +------------- no-ansi, do not"
logn " ! ! use fancy colours"
logn " ! +-------------------------------- thread model to use"
logn " ! f or fthread or fish"
logn " ! p or pthread or posix"
logn " +----------------------------------------------- target cpu type "
logn " i586 for Pentium "
logn " i686 for Pentium Pro "
logn " p4 for Pentium 4 "
logn " "
logn " The default is ${MYCMD} -c `uname -m` -t ${DEFTHREAD} -p 2"
logn " "
pause
exit
;;
esac
done
if ! ${CPU_SET} ; then
CPU_TYPE=`uname -m`
HOST_OPT=
fi
if ! ${NUMCPU_SET} ; then
NUMCPU=2
fi
case ${OSTYPE} in
cygwin) OSTEXT=cygwin
;;
linux*) OSTEXT=linux-gnu
;;
*) abort "This script does not work for OSTYPE=${OSTYPE}"
;;
esac
CPU_TYPE=`lower ${CPU_TYPE}`
log "CPU type ................................ ${CPU_TYPE}"
case ${CPU_TYPE} in
i586 | pentium | athlon)
HOST_OPT=--host=i586-pc-${OSTEXT}
TARG_CPU=i586
;;
i686 | pentiumpro)
HOST_OPT=--host=i686-pc-${OSTEXT}
TARG_CPU=i686
;;
p4 | pentium4)
# HOST_OPT=--host=p4-pc-${OSTEXT}
TARG_CPU=p4
OPTOPT="-fomit-frame-pointer -O3 -march=pentium4 -mcpu=pentium4"
OPTOPT=${OPTOPT}" -mmmx -msse -msse2 -minline-all-stringops -mfpmath=sse"
OPTOPT=${OPTOPT}" -maccumulate-outgoing-args"
;;
*) abort "Invalid CPU type ${CPU_TYPE}"
;;
esac
log "Number of host processors supported ..... ${NUMCPU}"
if ! ${THREAD_SET} ; then
if [ ${OSTYPE} = cygwin ] ; then
THREAD_TYPE=fthread
else
THREAD_TYPE=pthread
fi
fi
THREAD_TYPE=`lower ${THREAD_TYPE}`
log "Threading model being used .............. ${THREAD_TYPE}"
case ${THREAD_TYPE} in
f | fthread* | fish ) FTHREAD=yes
THREAD_TYPE="optimzed thread (Fish)"
;;
p | pthread* | posix) FTHREAD=no
THREAD_TYPE="standard thread (posix)"
;;
*) abort "Invalid thread model \"${THREAD_TYPE}\""
;;
esac
if test -f Makefile ; then
log "Cleaning up previous installation"
log "make uninstall"
cat >>${LOGFILE} <<!EOF!
+------------------------------------------------------------------------
!
! make uninstall
! ==============
!
+------------------------------------------------------------------------
!EOF!
make uninstall >>${LOGFILE} 2>&1
log "make distclean"
cat >>${LOGFILE} <<!EOF!
+------------------------------------------------------------------------
!
! make distclean
! ==============
!
+------------------------------------------------------------------------
!EOF!
make distclean >>${LOGFILE} 2>&1
fi
if ! test -f ./configure ; then
log "Running autogen.sh"
cat >>${LOGFILE} <<!EOF!
+------------------------------------------------------------------------
!
! bash autogen.sh
! ===============
!
+------------------------------------------------------------------------
!EOF!
bash autogen.sh >>${LOGFILE} 2>&1 || abort "autogen processing failed"
log "autogen completed successfully"
fi
logn "./configure ${HOST_OPT}"
logn " --enable-fthreads=${FTHREAD}"
logn " --enable-custom=\"compiled for ${TARG_CPU}\""
if [ "${OPTOPT}X" != "X" ] ; then
logn " --enable-optimization=\"${OPTOPT:0:27}\"... "
fi
logn " --enable-multi-cpu=${NUMCPU} "
cat >>${LOGFILE} <<!EOF!
+------------------------------------------------------------------------
!
! ./configure
! ===========
!
+------------------------------------------------------------------------
!EOF!
while ! test -f Makefile ; do
if [ "${OPTOPT}X" != "X" ] ; then
./configure ${HOST_OPT} \
--enable-fthreads=${FTHREAD} \
--enable-custom="compiled for ${TARG_CPU}" \
--enable-optimization="${OPTOPT}" \
--enable-cckd-bzip2 \
--enable-het-bzip2 \
--enable-multi-cpu=${NUMCPU} >>${LOGFILE} 2>&1
else
./configure ${HOST_OPT} \
--enable-fthreads=${FTHREAD} \
--enable-custom="compiled for ${TARG_CPU}" \
--enable-cckd-bzip2 \
--enable-het-bzip2 \
--enable-multi-cpu=${NUMCPU} >>${LOGFILE} 2>&1
fi
done
RC=$?
if [ ${RC} != 0 ] ; then
abort "./configure script failed"
fi
rm -f version.o 2>/dev/null
log "make"
cat >>${LOGFILE} <<!EOF!
+------------------------------------------------------------------------
!
! make
! ====
!
+------------------------------------------------------------------------
!EOF!
make >>${LOGFILE} 2>&1 || abort "make failed"
log "make install-strip"
cat >>${LOGFILE} <<!EOF!
+------------------------------------------------------------------------
!
! make install-strip
! ==================
!
+------------------------------------------------------------------------
!EOF!
make install-strip >>${LOGFILE} 2>&1 || abort "make install-strip failed"
cat >>${LOGFILE} <<!EOF!
+------------------------------------------------------------------------
!
! Time: `date +%H:%M:%S`
!
! F I N I T O ! ! !
! ===================
!
+------------------------------------------------------------------------
!EOF!