forked from oracle/rwloadsim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makemake.sh
401 lines (326 loc) · 11.7 KB
/
makemake.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
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
#!/bin/bash
# Copyright (c) 2023 Oracle Corportaion
# Licensed under the Universal Permissive License v 1.0
# as shown at https://oss.oracle.com/licenses/upl/
# RWP*Load Simulator - generate the top level Makefile
# and the Makefile in src
# History
#
# bengsig 4-jan-2023 - Add db version 23
# bengsig 28-jun-2022 - Generate project
# bengsig 01-jun-2022 - Add cleano target in src/Makefile
# bengsig 18-mar-2022 - Add ctags in flex .l files
# bengsig 29-mar-2021 - Stop using .yi include files for parser
# bengsig 18-feb-2020 - watermark
# bengsig 17-feb-2020 - Add rwlerror utility
# bengsig 23-dec-2020 - Solaris
# bengsig 14-dec-2020 - rwlman is now in bin; no rwlman.sh
# bengsig 02-dec-2020 - Directory structure change
# bengsig 18-nov-2020 - Use INT in stead of SIGINT for portability and exit
# bengsig 08-sep-2020 - Use printf in stead of echo for Solaris portability
# bengsig 03-sep-2020 - Don't allow 11 as primary
# bengsig 01-sep-2020 - Add a "clean" entry to top Makefile, improved tags
# bengsig 28-aug-2020 - Fix use of GCC flags for debug etc
# bengsig 15-aug-2020 - Creation
clean=`mktemp`
trap "rm -f $clean; exit" EXIT INT
fail=2
if test -f Makefile
then
echo Makefile already exists, please remove or rename 1>&2
exit $fail
fi
if test -f src/Makefile
then
echo src/Makefile already exists, please remove or rename 1>&2
exit $fail
fi
printf "Please enter your primary development release [12/18/19/21]: "
read primary
case $primary in
12|18|19|21)
;;
*)
echo Development release must be one of 12, 18, 19, 21
exit $fail
;;
esac
printf "Please enter either ORACLE_HOME or top of instant client for release $primary: "
read phome
fail=1
if test -f $phome/sdk/include/oci.h
then
echo $phome identified as Instant Client
oracle_lib=$phome
oracle_include=$phome/sdk/include
fail=0
fi
if test -f $phome/rdbms/public/oci.h
then
if test x$oracle_lib = x
then
echo $phome identified as ordinary ORACLE_HOME
else
echo Overwriting Instant Client and using $phome as ordinary ORACLE_HOME
fi
oracle_lib=$phome/lib
oracle_include=$phome/rdbms/public
fail=0
fi
if test $fail -gt 0
then
echo Cannot find oci.h as expected in $phome 1>&2
exit $fail
fi
# Check bison version
case `bison --version | sed -r -n '/^bison.*([1-9]+)\.[0-9]+\.[0-9]+.*$/s//\1/ p'` in
0|1|2)
echo 'bison must be at least version 3.0.4' 1>&2
exit 1
;;
3) BISONFLAGS=
;;
4|5) BISONFLAGS=
echo rwloadsim compile was never tested with
bison --version
;;
esac
cat > Makefile <<END
# This Makefile is generated by makemake.sh,
# your changes will be overwritten
#
# Make just the release that is our main building release
# and also increase the patch level by 1
#
only:
(cd src; ./rwlpatch.sh; make MAJOR_VERSION=$primary ORACLE_LIB=$oracle_lib ORACLE_INCLUDE=$oracle_include)
# Make all the other releases, documentation, etc
all: only docs/ERRORLIST.md
END
cat >> $clean <<END
clean:
(cd src; make MAJOR_VERSION=$primary ORACLE_LIB=$oracle_lib ORACLE_INCLUDE=$oracle_include clean)
END
cat > src/Makefile <<END
#
# There are these three fundamental variables
# that are being overwritten when compiling
# for anything but the default version
MAJOR_VERSION=$primary
ORACLE_LIB=$oracle_lib
ORACLE_INCLUDE=$oracle_include
#
# If you need to change this file, please change makemake.sh
# accordingly
#
END
cat >> src/Makefile <<'END'
# List of all object files, rwlpatch.o is generic for
# all versions, the rest are compiled for each client
# version seperately in separate directories
RWLSHROBJECTS = rwlpatch.o \
obj$(MAJOR_VERSION)/rwlparser.tab.o \
obj$(MAJOR_VERSION)/rwldiprs.tab.o \
obj$(MAJOR_VERSION)/lex.rwlz.o \
obj$(MAJOR_VERSION)/lex.rwla.o \
obj$(MAJOR_VERSION)/lex.rwly.o \
obj$(MAJOR_VERSION)/rwlerror.o \
obj$(MAJOR_VERSION)/rwlvariable.o \
obj$(MAJOR_VERSION)/rwlexprcomp.o \
obj$(MAJOR_VERSION)/rwlexpreval.o \
obj$(MAJOR_VERSION)/rwlcodeadd.o \
obj$(MAJOR_VERSION)/rwlcoderun.o \
obj$(MAJOR_VERSION)/rwlrast.o \
obj$(MAJOR_VERSION)/rwldynsql.o \
obj$(MAJOR_VERSION)/rwlsql.o \
obj$(MAJOR_VERSION)/rwlmisc.o
RWLOBJECTS = $(RWLSHROBJECTS) obj$(MAJOR_VERSION)/rwlmain.o
RWLGENOBJECTS = $(RWLSHROBJECTS) obj$(MAJOR_VERSION)/rwlgenexec.o
# List of generated files
GENFILES=rwlparser.tab.c lex.rwly.c rwlparser.tab.h rwldiprs.tab.c rwldiprs.tab.h lex.rwlz.c lex.rwla.c
# List of all source files that are input for ctags
RWLTAGSOURCES = rwl.h \
rwlerror.h \
rwlcodeadd.c \
rwlcoderun.c \
rwlerror.c \
rwlexprcomp.c \
rwlexpreval.c \
rwlscanstring.c \
rwlscansql.c \
rwllexer.l \
rwlmain.c \
rwlrast.c \
rwldynsql.c \
rwlsql.c \
rwlvariable.c \
rwlmisc.c \
rwlparser.y \
rwldiprs.y \
rwldilex.l \
rwlarglex.l \
rwlport.h \
rwlerrornum.h
# List all sources
RWLSOURCES = $(RWLTAGSOURCES) \
rwltypedefs.h rwlmainerror.c
# Change this if you want debugging
GCC_O=-O3
# GCC_O=-O0 -g
# We set all variables and don't use any of those
# already existing in make
GCC=gcc
# Used by all
GCCFLAGSALL=-m64
OCI_LIBS=-L$(ORACLE_LIB) -lclntsh
# Different flags are needed for pure and generated C files
MYGCCFLAGSC = $(GCCALLFLAGS) $(GCC_O) -W -Wall -Wextra -Wconversion
MYGCCFLAGSY = $(GCCALLFLAGS) $(GCC_O) -W -Wall -Wextra
MYGCCFLAGSL = $(GCCALLFLAGS) $(GCC_O) -W -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare
GCCFLAGSC = $(MYGCCFLAGSC) -D RWL_GCCFLAGS='$(MYGCCFLAGSC)'
GCCFLAGSY = $(MYGCCFLAGSY) -D RWL_GCCFLAGS='$(MYGCCFLAGSY)'
GCCFLAGSL = $(MYGCCFLAGSL) -D RWL_GCCFLAGS='$(MYGCCFLAGSL)'
FLEX=flex
BISON=bison
END
echo BISONFLAGS=$BISONFLAGS >> src/Makefile
cat >> src/Makefile <<'END'
only: ../bin/rwloadsim$(MAJOR_VERSION) ../bin/rwloadsim ../bin/rwlerror ../lib/rwlgenmain$(MAJOR_VERSION).o
ctags: $(RWLSOURCES)
rm -f tags cscope.out
ctags --c-kinds=-t $(RWLTAGSOURCES)
sh lextag.sh rwllexer.l
sh lextag.sh rwldilex.l
sh lextag.sh rwlarglex.l
cscope -b -c $(RWLSOURCES)
chmod ugo-w tags cscope.out # prevent inadvertent updates
# The full parser:
obj$(MAJOR_VERSION)/rwlparser.tab.o: rwlparser.tab.c
$(GCC) -c $(GCCFLAGSY) -I$(ORACLE_INCLUDE) rwlparser.tab.c -o obj$(MAJOR_VERSION)/rwlparser.tab.o
rwlparser.tab.h rwlparser.tab.c: rwlparser.y rwl.h rwlerror.h
$(BISON) $(BISONFLAGS) -v -d rwlparser.y
# The parser for $if $then directive
obj$(MAJOR_VERSION)/rwldiprs.tab.o: rwldiprs.tab.c
$(GCC) -c $(GCCFLAGSY) -I$(ORACLE_INCLUDE) rwldiprs.tab.c -o obj$(MAJOR_VERSION)/rwldiprs.tab.o
rwldiprs.tab.h rwldiprs.tab.c: rwldiprs.y rwl.h rwlerror.h
$(BISON) $(BISONFLAGS) -v -d rwldiprs.y
# The ordinary lexer
obj$(MAJOR_VERSION)/lex.rwly.o: lex.rwly.c
$(GCC) -c $(GCCFLAGSL) -I$(ORACLE_INCLUDE) lex.rwly.c -o obj$(MAJOR_VERSION)/lex.rwly.o
lex.rwly.c: rwllexer.l rwl.h rwlerror.h rwlparser.tab.h rwlscanstring.c rwlscansql.c
$(FLEX) --prefix=rwly rwllexer.l
# The lexer for $if $then directive
obj$(MAJOR_VERSION)/lex.rwlz.o: lex.rwlz.c
$(GCC) -c $(GCCFLAGSL) -I$(ORACLE_INCLUDE) lex.rwlz.c -o obj$(MAJOR_VERSION)/lex.rwlz.o
lex.rwlz.c: rwldilex.l rwl.h rwlerror.h rwldiprs.tab.h
$(FLEX) --prefix=rwlz rwldilex.l
# The lexer for scanning first file for option directives
obj$(MAJOR_VERSION)/lex.rwla.o: lex.rwla.c
$(GCC) -c $(GCCFLAGSL) -I$(ORACLE_INCLUDE) lex.rwla.c -o obj$(MAJOR_VERSION)/lex.rwla.o
lex.rwla.c: rwlarglex.l rwl.h rwlerror.h rwldiprs.tab.h rwlscanstring.c rwlscansql.c
$(FLEX) --prefix=rwla rwlarglex.l
# The almost full object for generation
../lib/rwlgenmain$(MAJOR_VERSION).o: obj$(MAJOR_VERSION)/rwlgenexec.o ../bin/rwloadsim$(MAJOR_VERSION) $(RWLGENOBJECTS)
ld -r -o ../lib/rwlgenmain$(MAJOR_VERSION).o $(RWLGENOBJECTS) rwlwatermark.o
# All the normal object files
obj$(MAJOR_VERSION)/rwlgenexec.o: rwlmain.c
$(GCC) -DRWL_GEN_EXEC -c $(GCCFLAGSC) -I$(ORACLE_INCLUDE) -o obj$(MAJOR_VERSION)/rwlgenexec.o rwlmain.c
obj$(MAJOR_VERSION)/rwlmain.o: rwlmain.c
$(GCC) -c $(GCCFLAGSC) -I$(ORACLE_INCLUDE) -o obj$(MAJOR_VERSION)/rwlmain.o rwlmain.c
obj$(MAJOR_VERSION)/rwlcoderun.o: rwlcoderun.c
$(GCC) -c $(GCCFLAGSC) -I$(ORACLE_INCLUDE) -o obj$(MAJOR_VERSION)/rwlcoderun.o rwlcoderun.c
obj$(MAJOR_VERSION)/rwlerror.o: rwlerror.c
$(GCC) -c $(GCCFLAGSC) -I$(ORACLE_INCLUDE) -o obj$(MAJOR_VERSION)/rwlerror.o rwlerror.c
obj$(MAJOR_VERSION)/rwlexprcomp.o: rwlexprcomp.c
$(GCC) -c $(GCCFLAGSC) -I$(ORACLE_INCLUDE) -o obj$(MAJOR_VERSION)/rwlexprcomp.o rwlexprcomp.c
obj$(MAJOR_VERSION)/rwlexpreval.o: rwlexpreval.c
$(GCC) -c $(GCCFLAGSC) -I$(ORACLE_INCLUDE) -o obj$(MAJOR_VERSION)/rwlexpreval.o rwlexpreval.c
obj$(MAJOR_VERSION)/rwlrast.o: rwlrast.c
$(GCC) -c $(GCCFLAGSC) -I$(ORACLE_INCLUDE) -o obj$(MAJOR_VERSION)/rwlrast.o rwlrast.c
obj$(MAJOR_VERSION)/rwldynsql.o: rwldynsql.c
$(GCC) -c $(GCCFLAGSC) -I$(ORACLE_INCLUDE) -o obj$(MAJOR_VERSION)/rwldynsql.o rwldynsql.c
obj$(MAJOR_VERSION)/rwlsql.o: rwlsql.c
$(GCC) -c $(GCCFLAGSC) -I$(ORACLE_INCLUDE) -o obj$(MAJOR_VERSION)/rwlsql.o rwlsql.c
obj$(MAJOR_VERSION)/rwlvariable.o: rwlvariable.c
$(GCC) -c $(GCCFLAGSC) -I$(ORACLE_INCLUDE) -o obj$(MAJOR_VERSION)/rwlvariable.o rwlvariable.c
obj$(MAJOR_VERSION)/rwlmisc.o: rwlmisc.c
$(GCC) -c $(GCCFLAGSC) -I$(ORACLE_INCLUDE) -o obj$(MAJOR_VERSION)/rwlmisc.o rwlmisc.c
obj$(MAJOR_VERSION)/rwlcodeadd.o: rwlcodeadd.c
$(GCC) -c $(GCCFLAGSC) -I$(ORACLE_INCLUDE) -o obj$(MAJOR_VERSION)/rwlcodeadd.o rwlcodeadd.c
rwlpatch.o: rwlpatch.c
$(GCC) -c $(GCCFLAGSC) -I$(ORACLE_INCLUDE) -o rwlpatch.o rwlpatch.c
../bin/rwlerror: rwlmainerror.c rwl.h rwlerror.h
$(GCC) $(GCCFLAGSC) -I $(ORACLE_INCLUDE) -o ../bin/rwlerror rwlmainerror.c
rwlerrornum.h: rwlerror.h
echo '/* This file is generated and is never included */' > rwlerrornum.h
echo '/* It only exists to allow tags/cscope for RWL_ERROR_nnn */' >> rwlerrornum.h
awk '/define RWL_ERROR/ { print "#define RWL_ERROR_" $$3 " " $$2}' rwlerror.h >> rwlerrornum.h
../bin/rwloadsim$(MAJOR_VERSION): $(RWLOBJECTS)
sh rwlwatermark.sh
$(GCC) -c -o rwlwatermark.o rwlwatermark.c
env LD_LIBRARY_PATH=$(ORACLE_LIB) $(GCC) $(GCC_O) -o ../bin/rwloadsim$(MAJOR_VERSION) $(RWLOBJECTS) rwlwatermark.o $(OCI_LIBS) -lm -lrt
clean:
rm -f $(RWLOBJECTS) $(RWLGENOBJECTS) $(GENFILES) ../bin/rwloadsim$(MAJOR_VERSION) ../bin/rwlerror ../lib/rwlgenmain$(MAJOR_VERSION).o
cleano:
rm -f $(RWLOBJECTS)
$(RWLOBJECTS): rwl.h rwlerror.h
.SUFFIXES: .i
.c.i:
$(GCC) -E -I$(ORACLE_INCLUDE) -D RWL_GCCFLAGS='-I -E' $< > $*.i
sources: $(RWLSOURCES)
@echo $(RWLSOURCES)
END
secondary=nothing
until test -z "$secondary"
do
printf "Please enter a secondary development release, return for none/no more : "
read secondary
if test x$secondary = x$primary
then
echo Secondary is the same as the primary
else
case $secondary in
11|12|18|19|21|23)
printf "Please enter either ORACLE_HOME or top of instant client for release $secondary: "
read shome
fail=3
if test -f $shome/sdk/include/oci.h
then
echo $shome identified as Instant Client
oracle_lib=$shome
oracle_include=$shome/sdk/include
fail=0
fi
if test -f $shome/rdbms/public/oci.h
then
echo $shome identified as ordinary ORACLE_HOME
oracle_lib=$shome/lib
oracle_include=$shome/rdbms/public
fail=0
fi
if test $fail -gt 0
then
echo Cannot find oci.h as expected in $shome
else
printf "\t(cd src; make MAJOR_VERSION=$secondary ORACLE_LIB=$oracle_lib ORACLE_INCLUDE=$oracle_include)\n" >> Makefile
printf "\t(cd src; make MAJOR_VERSION=$secondary ORACLE_LIB=$oracle_lib ORACLE_INCLUDE=$oracle_include clean)\n" >> $clean
fi
;;
?*)
echo Secondary release must be one of 11, 12, 18, 19, 21, 23
;;
esac
fi
done
cat $clean >> Makefile
cat >> Makefile <<'END'
docs/ERRORLIST.md: src/rwlerror.h
sh errorlist.sh | sed 's%\\%\\%g' > docs/ERRORLIST.md
# Run the test shell script
test: only
(cd test; sh test.sh -e)
# Prepare the tgz file for shipping
ship: all
sh makeship.sh
END
echo Makefiles have been created, you can type make now