-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·478 lines (432 loc) · 12.9 KB
/
configure
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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
#!/bin/bash
configure_options="$*"
platform=unix
arch=macosx64
prefix='/usr/local/caph'
bindir=''
libdir=''
mandir=''
docdir=''
exampledir=''
distdir='../dist'
manext=1
target=byte
debug=''
ocp=''
cc=gcc
cpp=/lib/cpp
ar='ar'
cp='cp'
ln='ln -s'
make='make'
qmake='qmake'
qmake_spec='macx-clang'
ocamldot=ocamldot
vhdl_support=yes
vhdl_comp=ghdl
vhdl_fp_support=no
vhdl_fp_lib='/Users/jserot/Dev/vhdl/fp-altera'
cppstd='c++11'
dotviewer='graphviz'
pgmviewer='toyviewer'
build_gui='yes'
build_doc='yes'
# ocamlversion_min=4.06
# Parse command-line arguments
while : ; do
case "$1" in
"") break;;
-platform|--platform)
platform=$2; shift;;
-bindir|--bindir)
bindir=$2; shift;;
-libdir|--libdir)
libdir=$2; shift;;
-mandir|--mandir)
mandir=$2; shift;;
-docdir|--docdir)
docdir=$2; shift;;
-prefix|--prefix)
prefix=$2; shift;;
-target|--target)
target=$2; shift;;
-debug|--debug)
debug='-g';;
-ocp|--ocp)
ocp='ocp-';;
-cpp|--cpp)
cpp=$2; shift;;
-cc|--cc)
cc=$2; shift;;
-make|--make)
make=$2; shift;;
-qmake|--qmake)
qmake=$2; shift;;
-qmake-spec|--qmake-spec)
qmake_spec=$2; shift;;
-ar|--ar)
ar=$2; shift;;
-no-vhdl-support|--no-vhdl-support)
vhdl_support='no';;
-vhdl_fp_support|--vhdl_fp_support)
vhdl_fp_support='no';;
-vhdl-fp-lib|--vhdl-fp-lib)
vhdl_fp_lib=$2; shift;;
-cppstd|--cppstd)
cppstd=$2; shift;;
-dotviewer|--dotviewer)
dotviewer=$2; shift;;
-pgmviewer|--pgmviewer)
pgmviewer=$2; shift;;
-no-gui|--no-gui)
build_gui='no';;
-no-doc|--no-doc)
build_doc='no';;
-help|--help)
cat <<EOF
Usage: configure [options]
Options: [defaults in brackets after descriptions]
--platform NAME target platform (unix, macos or win32) [default: unix]
--prefix PREFIX install distribution in PREFIX [default: /usr/local/caph]
--bindir DIR install executables in DIR [default: PREFIX/bin]
--libdir DIR install libraries in in DIR [default: PREFIX/lib]
--mandir DIR install man documentation in DIR [default: PREFIX/man]
--docdir DIR install documentation in DIR [default: PREFIX/doc]
--target TARGET type of executable for the compiler and tools (byte or native) [default: byte]
--debug compile in debug mode [default: no]
--ocp use ocamlc-ocp,.... instead of ocamlc, ... [default: no]
--cc NAME C compiler [default: gcc]
--ar NAME C archiver [default: ar]
--cpp NAME C pre-processor [default: /lip/cpp]
--cppstd NAME C++ standard used when by g++/gcc [default: c++11]
--make NAME make command [default: make]
--qmake NAME qmake command [default: qmake]
--qmake-spec NAME qmake spec name [default: macx-clang]
--no-vhdl-support do noy build the VHDL support library [default: build it]
--vhdl_comp VHDL compiler [default: ghdl]
--vhdl-fp-support activate float support in the VHDL support library [default: no]
--vhdl-fp-lib location of the float library for VHDL
--dotviewer NAME command name for displaying .dot files [default: graphviz]
--pgmviewer NAME command name for displaying .pgm files [default: toyviewer]
--no-gui do not build the Qt-based GUI [default: build it]
--no-doc do not build the documentation [default: build it]
--help print this message
EOF
exit 0;;
*) echo "Unknown option \"$1\"." 1>&2; exit 2;;
esac
shift
done
# Sanity checks
case "$platform" in
unix|win32|macos) ;;
*) echo "The target platform must be unix, macos or win32." 1>&2; exit 2;;
esac
case "$prefix" in
".") ;;
/*) ;;
*) echo "The -prefix directory must be absolute." 1>&2; exit 2;;
esac
# Generate the config file
rootdir=`dirname $0`
cd $rootdir
rm -f config
touch config
# Write options
echo "# -*- makefile -*-" >> config
echo "# generated by ./configure $configure_options" >> config
echo "" >> config
cat VERSION >> config
echo "PLATFORM=$platform" >> config
echo "BUILD_GUI=$build_gui" >> config
echo "BUILD_DOC=$build_doc" >> config
echo "" >> config
# Where to install
echo "# Where to install" >> config
echo "PREFIX=$prefix" >> config
case "$bindir" in
"") echo 'BINDIR=$(PREFIX)/bin' >> config
bindir="$prefix/bin";;
*) echo "BINDIR=$bindir" >> config;;
esac
case "$libdir" in
"") echo 'LIBDIR=$(PREFIX)/lib' >> config
libdir="$prefix/lib";;
*) echo "LIBDIR=$libdir" >> config;;
esac
if [ $build_doc == "yes" ]; then
case "$mandir" in
"") echo 'MANDIR=$(PREFIX)/man' >> config
mandir="$prefix/man";;
*) echo "MANDIR=$mandir" >> config;;
esac
echo "MANEXT=$manext" >> config
fi
if [ $build_doc == "yes" ]; then
case "$docdir" in
"") echo 'DOCDIR=$(PREFIX)/doc' >> config
docdir="$prefix/doc";;
*) echo "DOCDIR=$docdir" >> config;;
esac
fi
case "$exampledir" in
"") echo 'EXAMPLEDIR=$(PREFIX)/examples' >> config
exampledir="$prefix/examples";;
*) echo "EXAMPLEDIR=$exampledir" >> config;;
esac
case "$prefix" in
".") echo 'CAPH_C_LIB=../../../lib/c' >> config
echo 'CAPH_CAPH_LIB=../../../lib/caph' >> config
echo 'CAPH_ETC_LIB=../../../lib/etc' >> config
echo 'CAPH_SYSC_LIB=../../../lib/systemc' >> config
echo 'CAPH_VHDL_LIB=../../../lib/vhdl' >> config
echo 'CAPHC=../../../compiler/caphc' >> config
echo 'CAPH_TOOLS=../../../tools' >> config;;
*) echo 'CAPH_C_LIB=$(LIBDIR)/c' >> config
echo 'CAPH_CAPH_LIB=$(LIBDIR)/caph' >> config
echo 'CAPH_ETC_LIB=$(LIBDIR)/etc' >> config
echo 'CAPH_SYSC_LIB=$(LIBDIR)/systemc' >> config
echo 'CAPH_VHDL_LIB=$(LIBDIR)/vhdl' >> config
echo 'CAPHC=$(BINDIR)/caphc' >> config
echo 'CAPH_TOOLS=$(BINDIR)' >> config;;
esac
echo 'ETCDIR=$(PREFIX)/etc' >> config
if [ $build_doc == "yes" ]; then
echo "MANEXT=$manext" >> config
echo 'DOCDIR=$(PREFIX)/doc' >> config
fi
echo "" >> config
# Check for install script
set dummy install; cmd_name=$2
/bin/echo -n "checking for $cmd_name... "
if sh ./etc/searchpath $cmd_name; then
echo "$cmd_name"
else
echo "not found"
{ echo "configure: error: cannot find $cmd_name." 1>&2; exit 1; }
fi
install=$cmd_name
# Check for Ocaml compilers
echo "# Program used" >> config
echo >> config
# checking for ocamlc
set dummy ocamlc; compiler_name=${ocp}$2
/bin/echo -n "checking for $compiler_name... "
if sh ./etc/searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
{ echo "configure: error: cannot find $compiler_name." 1>&2; exit 1; }
fi
ocamlc=$compiler
# ocamlversion=`$ocamlc -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
# echo "ocaml version is $ocamlversion"
# bad_version=`expr "$ocamlversion" \< "$ocamlversion_min"`
# if test "$bad_version" = "1"; then
# { echo "configure: error: Ocaml >= $ocamlversion_min needed." 1>&2; exit 1; }
# fi
ocamllib=`$ocamlc -where`
echo "ocaml library path is $ocamllib"
# checking for ocamlopt
set dummy ocamlopt; compiler_name=${ocp}$2
/bin/echo -n "checking for $compiler_name... "
if sh ./etc/searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
fi
ocamlopt=$compiler
ocamlbest=byte
if [ -n "$ocamlopt" ]; then
ocamlbest=opt
fi
if [ -z "$target" ]; then
target=$ocamlbest
fi
echo "TARGET=$target" >> config
echo "" >> config
ocamllib=`$ocamlopt -where`
echo "ocaml library path is $ocamllib"
# checking for ocamldep
set dummy ocamldep; compiler_name=$2
/bin/echo -n "checking for $compiler_name... "
if sh ./etc/searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
{ echo "configure: error: cannot find $compiler_name." 1>&2; exit 1; }
fi
ocamldep=$compiler
# checking for ocamllex
set dummy ocamllex; compiler_name=$2
/bin/echo -n "checking for $compiler_name... "
if sh ./etc/searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
{ echo "configure: error: cannot find $compiler_name." 1>&2; exit 1; }
fi
ocamllex=$compiler
# checking for ocamlyacc
set dummy ocamlyacc; compiler_name=$2
/bin/echo -n "checking for $compiler_name... "
if sh ./etc/searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
{ echo "configure: error: cannot find $compiler_name." 1>&2; exit 1; }
fi
ocamlyacc=$compiler
# checking for ocamlcp
set dummy ocamlcp; compiler_name=$2
/bin/echo -n "checking for $compiler_name... "
if sh ./etc/searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
{ echo "configure: error: cannot find $compiler_name." 1>&2; exit 1; }
fi
ocamlcp=$compiler
# checking for c compiler
set dummy $cc; compiler_name=$2
/bin/echo -n "checking for $compiler_name... "
if sh ./etc/searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
{ echo "configure: error: cannot find $compiler_name." 1>&2; exit 1; }
fi
cc=$compiler
# checking for c archiver
set dummy $ar; compiler_name=$2
/bin/echo -n "checking for $compiler_name... "
if sh ./etc/searchpath $compiler_name; then
echo "$compiler_name"
compiler=$compiler_name
else
echo "not found"
{ echo "configure: error: cannot find $compiler_name." 1>&2; exit 1; }
fi
ar=$compiler
# checking for ocamldot
set dummy $ocamldot; compiler_name=$2
/bin/echo -n "checking for $compiler_name... "
if sh ./etc/searchpath $compiler_name; then
echo "$compiler_name"
ocamldot=$compiler_name
else
echo "not found"
{ echo "** configure: warning: cannot find $compiler_name." 1>&2; }
ocamldot=''
fi
# checking for dot viewer
#set dummy $dotviewer; compiler_name=$2
#/bin/echo -n "checking for program to view .dot files... "
#if test -f "$compiler_name"; then
# echo "$compiler_name"
# dotviewer=$compiler_name
#else
# echo "not found"
# { echo "** configure: warning: cannot find $compiler_name." 1>&2; }
# dotviewer=''
#fi
# checking for pgm viewer
#set dummy $pgmviewer; compiler_name=$2
#/bin/echo -n "checking for program to view .pgm files... "
#if test -f "$compiler_name"; then
# echo "$compiler_name"
# pgmviewer=$compiler_name
#else
# echo "not found"
# { echo "** configure: warning: cannot find $compiler_name." 1>&2; }
# pgmviewer=''
#fi
# Checking whether sed needs -E argument (FreeBSD non standard ext)
echo "" | sed -E -e "s/{}//" > /dev/null 2>&1
if [ $? -eq 0 ]; then
esed="sed -E"
else
esed="sed"
fi
# Finish generated files
echo "INSTALL=$install" >> config
echo "CC=$cc" >> config
echo "CPPSTD=$cppstd" >> config
echo "CPP=$cpp -P" >> config
echo "LN=$ln" >> config
echo "AR=$ar" >> config
echo "CP=cp" >> config
echo "MV=mv" >> config
echo "RM=rm -f" >> config
echo "ESED=$esed" >> config
echo "RMDIR=rm -rf" >> config
echo "MAKE=$make" >> config
echo "QMAKE=$qmake" >> config
echo "QMAKE_SPEC=$qmake_spec" >> config
echo "CAMLC=$ocamlc" >> config
echo "CAMLOPT=$ocamlopt" >> config
echo "CAMLLEX=$ocamllex" >> config
echo "CAMLYACC=$ocamlyacc -v" >> config
if [ -n "$ocamldot" ]; then
echo "CAMLDOT=$ocamldot" >> config
fi
if [ -n "$dotviewer" ]; then
echo "DOTVIEWER=\"$dotviewer\"" >> config
fi
if [ -n "$pgmviewer" ]; then
echo "PGMVIEWER=\"$pgmviewer\"" >> config
fi
echo "CAMLDEP=$ocamldep -pp camlp4o" >> config
echo "CAMLCFLAGS=$debug" >> config
echo "CAMLOPTFLAGS=$debug" >> config
echo "LINKFLAGS=$debug" >> config
echo "CAMLDEPFLAGS=-slash" >> config
if [ $platform == "win32" ]; then
echo "LINKOFLAGS=-cclib -L/C/MinGW/lib" >> config
fi
echo "VHDL_SUPPORT=$vhdl_support" >> config
if [ $vhdl_support == "yes" ]; then
echo "GHDL=$vhdl_comp" >> config
echo "USE_VHDL_FP_LIB=$vhdl_fp_support" >> config
if [ $vhdl_fp_support == "yes" ]; then
echo "VHDL_FP_LIB=$vhdl_fp_lib" >> config
fi
fi
echo
cp ./config ./lib/etc
# Print a summary
echo
echo "** Configuration summary **"
echo
echo "Directories where CAPH will be installed:"
echo " binaries.................. $bindir"
echo " libraries................. $libdir/{c,etc,systemc,vhdl,caph}"
if [ $build_doc == "yes" ]; then
echo " manual pages.............. $mandir (with extension .$manext)"
echo " documentation............. $docdir"
fi
echo " examples.................. $exampledir"
if [ -n "$dotviewer" ]; then
echo "Program for viewing .dot files: \"$dotviewer\""
fi
if [ -n "$pgmviewer" ]; then
echo "Program for viewing .pgm files: \"$pgmviewer\""
fi
echo "Build VHDL support library: $vhdl_support"
if [ $vhdl_support == 'yes' ]; then
echo "Request for VHDL float support : $vhdl_fp_support"
if [ $vhdl_fp_support == 'yes' ]; then
echo "Location of VHDL float library: $vhdl_fp_lib"
fi
fi
echo
echo "** CAPH configuration completed successfully **"
echo "** Wrote files ./config and ./lib/etc/config"
echo