File: configure

package info (click to toggle)
ghdl 5.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 86,000 kB
  • sloc: ada: 309,826; vhdl: 209,727; ansic: 31,072; python: 19,213; sh: 14,214; cpp: 2,345; makefile: 1,542; pascal: 585; asm: 45; exp: 40; fortran: 33
file content (478 lines) | stat: -rwxr-xr-x 15,217 bytes parent folder | download
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/sh
#
# Configure script for GHDL (C) 2014-2018 Tristan Gingold
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <gnu.org/licenses>.


# Current version.  This is the only place where the version is written.
# Any code that needs version should read it directly or indirectly from this
# place.
# Note the absence of spaces and the quotes.
# Suffix "-dev" is used during development.
ghdl_version="5.0.1"

backend=mcode
backend_version="none"
CC=${CC:-gcc}
CXX=${CXX:-clang++}
AR=${AR:-ar}
CFLAGS=${CFLAGS:--g}
CXXFLAGS=${CXXFLAGS:--g}
GNATMAKE=${GNATMAKE:-gnatmake}
ADA_FLAGS=${ADA_FLAGS:-}
MAKE=${MAKE:-make}
LDFLAGS=${LDFLAGS:-}
LLVM_LDFLAGS=${LLVM_LDFLAGS:-'`$(LLVM_CONFIG) --ldflags --libs --system-libs`'}
prefix=/usr/local
libdirsuffix=lib
libghdldirsuffix=lib/ghdl
libnativedirsuffix=lib
incdirsuffix=include
gcc_src_dir=
llvm_config=llvm-config
backtrace_lib=
llvm_be=llvm6
build=
build_mode=
enable_werror=false
enable_checks=true
enable_gplcompat=unknown
enable_libghdl=true
enable_synth=true
with_readline=None
with_sundials=false
sundials_incflags=
sundials_ldflags=
default_pic=false
EXEEXT=
SOEXT=.so
PIC_FLAGS=-fPIC

show_help=no
progname=$0

subst_vars="CC CXX AR GNATMAKE ADA_FLAGS MAKE CFLAGS CXXFLAGS LDFLAGS build
srcdir abs_srcdir prefix backend backend_version libdirsuffix libghdldirsuffix
incdirsuffix gcc_src_dir llvm_config llvm_be backtrace_lib
build_mode EXEEXT SOEXT PIC_FLAGS default_pic enable_werror enable_checks
enable_gplcompat enable_libghdl libghdl_version ghdl_version
with_sundials sundials_incflags sundials_ldflags
COMPILER_GCC COMPILER_DEBUG COMPILER_MCODE COMPILER_LLVM POST_PROCESSOR
INSTALL_PREFIX LIBDIR_SUFFIX LIBGHDLDIR_SUFFIX INCDIR_SUFFIX LIBNATIVEDIR_SUFFIX
GCC_DEFAULT_OPTIONS
LLVM_LDFLAGS
"

# Find srcdir
srcdir=`dirname $progname`
if test x$srcdir = x; then
  srcdir=.
fi

# Check echo -n / echo \c
if test x`echo -n` = x"-n" ; then
  echon=
  echoc="\c"
else
  echon="-n"
  echoc=
fi

# Check $1 is a prefix of $2
check_version()
{
  exp_ver=`echo $1 | sed 's/\./v/g'`
  tool_ver=`echo $2 | sed 's/\./v/g'`
  if echo $tool_ver | grep -q "^$exp_ver"; then
    return 0
  else
    return 1
  fi
}

# Decode options
for opt do
  optarg=`expr x"$opt" : 'x[^=]*=\(.*\)'`
  case "$opt" in
    CC=*|CFLAGS=*|GNATMAKE=*|LDFLAGS=*|CXX=*|LLVM_LDFLAGS=*)
      optvar=`expr x"$opt" : 'x\([^=]*\)=.*'`
      eval $optvar=\"$optarg\"
      ;;
    --prefix=*)             prefix="$optarg";;
    --srcdir=*)             srcdir="$optarg";;
    --libdir=*)             libdirsuffix="$optarg";;
    --libghdldir=*)         libghdldirsuffix="$optarg";;
    --libnativedir=*)       libnativedirsuffix="$optarg";;
    --incdir=*)             incdirsuffix="$optarg";;
    --with-gcc=*)           gcc_src_dir="$optarg";     backend=gcc;;
    --with-llvm=*)
      echo "--with-llvm is deprecated, use --with-llvm-config"
      llvm_config="$optarg/bin/llvm-config";           backend=llvm;;
    --with-llvm-config)     llvm_config="llvm-config"; backend=llvm;;
    --with-llvm-config=*)   llvm_config="$optarg";     backend=llvm;;
    --with-llvm-jit)        backend=llvm_jit;;
    --with-backtrace-lib=*) backtrace_lib="$optarg";;
    --with-readline)        with_readline="Gnu";;
    --with-sundials=*)      with_sundials=true;
			    sundials_incflags="-I$optarg/include";
			    sundials_ldflags="-L$optarg/lib -lsundials_ida";;
    --with-sundials)        with_sundials=true;;
    --enable-werror)        enable_werror=true;;
    --disable-werror)       enable_werror=false;;
    --enable-checks)        enable_checks=true;;
    --disable-checks)       enable_checks=false;;
    --enable-gplcompat)     enable_gplcompat=true;;
    --disable-gplcompat)    enable_gplcompat=false;;
    --enable-libghdl)       enable_libghdl=true;;
    --disable-libghdl)      enable_libghdl=false;;
    --enable-synth)         enable_synth=true;;
    --disable-synth)        enable_synth=false;;
    --default-pic)          default_pic=true;;
    --enable-coverage)      build_mode="coverage";;
    -h|-help|--help)        show_help=yes;;
    *)
      echo "$0: unknown option $opt; try $0 --help"
      exit 1
      ;;
  esac
done

# Help
if test $show_help != no; then
  cat <<EOF
Usage: configure [options]

Options [defaults in brackets]:
  --prefix=PREFIX             install in PREFIX [$prefix]
  --srcdir=SRCDIR             source code path [$srcdir]
  --libdir=LIBDIR             lib dir path relative to PREFIX [$libdirsuffix]
  --libghdldir=LIBGHDLDIR     ghdl lib dir path relative to PREFIX [$libdirsuffix]
  --libnativedir=DIR          libghdl dir relative to PREFIX [$libnativedir]
  --incdir=INCDIR             C include dir path relative to PREFIX [$incdirsuffix]
  --with-gcc=DIR              use gcc backend from DIR
  --with-llvm-config[=LLVM-CONFIG]  use llvm backend [llvm-config]
  --with-llvm-jit             use llvm-jit backend
  --with-backtrace-lib=LIB.a  link with libbacktrace LIB.a to display a
                              backtrace on errors (only for llvm).
  --disable-werror            warnings don't stop build
  --disable-checks            disable internal checks
  --disable-libghdl           do not build libghdl shared library
  --enable-gplcompat          use GPL-compatible sources for ieee library
  --enable-libghdl            also build the libghdl shared library
  --disable-synth             do not build with synthesis feature

Binaries are installed in PREFIX/bin
VPI shared libraries are installed in PREFIX/LIBDIRSUFFIX
Native shared libraries (libghdl) are installed in PREFIX/LIBNATIVEDIR
C header files are installed in PREFIX/INCDIR
GHDL libraries are installed in PREFIX/LIBGHDLDIR
EOF
  exit 0
fi

# Set abs_srcdir (absolute srcdir)
case $srcdir in
  /*) abs_srcdir=$srcdir;;
  *)
    # Use a Windows path on windows.
    case "$OS" in
      Windows_NT) curdir=`pwd -W 2>/dev/null || pwd` ;;
      *) curdir=`pwd` ;;
    esac
    abs_srcdir=$curdir/$srcdir
    ;;
esac

# Sanity checks
# Check srcdir
pat="2019802090ed76fc5c54cec58f22a2c1"
if ! grep $pat $srcdir/configure > /dev/null 2>&1; then
  echo "Incorrect srcdir; try with --srcdir=xx"
  echo "srcdir=$srcdir"
  exit 1
fi

if ! `cmp /dev/null /dev/null > /dev/null 2>&1`; then
  echo "Sorry, you need 'cmp' to configure GHDL.";
  exit 1
fi

if ! cmp $srcdir/configure $abs_srcdir/configure > /dev/null 2>&1; then
  echo "Cannot compute absolute source dir (or incorrect srcdir)"
  echo "srcdir=$srcdir"
  echo "abs_srcdir=$abs_srcdir"
  exit 1
fi
# Check that gnatmake exists
if ! $GNATMAKE --version >/dev/null 2>&1; then
  echo "Sorry, you need GNAT to build GHDL.  See the README"
  echo "(gnatmake executable is: $GNATMAKE)"
  exit 1
fi

# Check that compiler exists
if ! $CC --version 2> /dev/null; then
  echo "Sorry, you need a C compiler to build GHDL.  See the README"
  exit 1
fi

# Check the version of libghdl is correct.
if [ "$enable_libghdl" = true ]; then
    libghdl_version="$srcdir/pyGHDL/__init__.py"
    # Extract content between double quotes in __init__.py, to avoid false positives due to LF/CRLF mismatch.
    if [ "$ghdl_version" != `sed -n 's/^__version__.*"\(.*\)".*/\1/gp' $libghdl_version` ]; then
      echo "Sorry, the version of $libghdl_version is not correct"
      echo "update the version to: $ghdl_version"
      echo "or use --disable-libghdl"
      exit 1
    fi
fi

# Default for enable_gplcompat
if [ "$enable_gplcompat" = "unknown" ]; then
  if test -d $srcdir/libraries/vital95 && test -d $srcdir/libraries/vital2000; then
    enable_gplcompat=false
    echo "Use full IEEE library"
  else
    enable_gplcompat=true
    echo "Use GPL-compatible source files for IEEE library (but partial)"
  fi
elif [ "$enable_gplcompat" = false ]; then
  if ! test -d $srcdir/libraries/vital95 || ! test -d $srcdir/libraries/vital2000; then
    echo "Sorry, full IEEE library source files not present"
    echo "consider --enable-gplcompat"
    exit 1
  fi
fi

# Compute build machine
if test x$build = x; then
  build=`$CC $CFLAGS -dumpmachine`
fi
echo "Build machine is: $build"

# For mcode, check that gcc emits i386
if test $backend = mcode; then
  case "$build" in
    i[3-6]86*) mcode64="" ;;
    x86_64*) mcode64="64" ;;
    amd64*)  mcode64="64" ;;
    *)
      mcode64=""
      echo "WARNING: GHDL for mcode is supported only on x86"
      echo "continuing, but build failure expected (See the README)"
      ;;
  esac
  if test "x$backtrace_lib" != x ; then
    echo "WARNING: --with-backtrace-lib= ignored with mcode"
    backtrace_lib=
  fi
  backend_version="none"
fi

# For gcc backend, check existing version
if test $backend = gcc; then
  if ! test -f $gcc_src_dir/gcc/BASE-VER; then
    echo "cannot find gcc/BASE-VER in $gcc_src_dir"
    exit 1
  fi
  backend_version=`cat $gcc_src_dir/gcc/BASE-VER`
  if test "x$backtrace_lib" = x ; then
    # Automatically use libbacktrace from gcc.
    backtrace_lib="$prefix/$libghdldirsuffix/libbacktrace.a"
  fi
fi

# For llvm backend, check llvm-config
if test $backend = llvm -o $backend = llvm_jit; then
  # No quotes for llvm_config, so that options (like --link-static) can be
  # added.  As a consequence, spaces in --with-llvm-config= are not allowed
  # for the path.
  llvm_version=`$llvm_config --version 2>/dev/null`
  if [ $? != 0 ]; then
    echo "cannot run $llvm_config"
    exit 1
  fi
  if   check_version  3.5 $llvm_version ||
       check_version  3.6 $llvm_version ||
       check_version  3.7 $llvm_version ||
       check_version  3.8 $llvm_version ||
       check_version  3.9 $llvm_version ||
       check_version  4.0 $llvm_version ||
       check_version  5.0 $llvm_version ||
       false; then
    echo "Debugging not enabled with llvm $llvm_version"
  elif check_version  6.0 $llvm_version ||
       check_version  7.0 $llvm_version ||
       check_version  8.0 $llvm_version ||
       check_version  9.0 $llvm_version ||
       check_version 10.0 $llvm_version ||
       check_version 11.0 $llvm_version ||
       check_version 11.1 $llvm_version ||
       check_version 12.0 $llvm_version ||
       check_version 13.0 $llvm_version ||
       check_version 14.0 $llvm_version ||
       check_version 15.0 $llvm_version ||
       check_version 16.0 $llvm_version ||
       check_version 17.0 $llvm_version ||
       check_version 18.1 $llvm_version ||
       check_version 19. $llvm_version ||
       false; then
    echo "Debugging is enabled with llvm $llvm_version"
  else
    echo "Unhandled version llvm $llvm_version"
    exit 1
  fi
  # For llvm, the c++ compiler is used for linking so that the standard c++
  # library is included.  However, the linker needs the no_compact_unwind
  # flag because code generated by gcc is not compatible with compact unwind.
  case "$build" in
    *darwin*) LDFLAGS="$LDFLAGS -Wl,-no_compact_unwind" ;;
  esac
  backend_version="$llvm_version"
fi

# Define default file extensions for Windows or Linux-like systems and
# use -fPIC or not.
case "$build" in
  *mingw* | *cygwin* | *windows-gnu*) SOEXT=".dll";   EXEEXT=".exe"; PIC_FLAGS="";;
  *darwin*)           SOEXT=".dylib"; EXEEXT="";     PIC_FLAGS="";;
  *)                  SOEXT=".so";    EXEEXT="";     PIC_FLAGS="-fPIC";;
esac

# Define libghdl_version
libghdl_version=`echo $ghdl_version | sed -e 's/[-.]/_/g'`

# Check if gcc was configured with --enable-default-pie.  In that case -fPIC
# should be added.
if gcc -v 2>&1 | grep -q enable-default-pie; then
  default_pic="true"
fi

# Create subdirectories
if [ ! -d pic ]; then
  echo "create pic/ subdirectory"
  if ! mkdir pic; then
    echo "failed to create pic/"
    exit 1;
  fi
fi

# Define variables derrived from configuration
#
# Note most of these are used to generate default_paths.ads, you should
# also update scripts/windows/mcode/default_paths.ads if you change them.
COMPILER_GCC=ghdl1-gcc$EXEEXT
COMPILER_DEBUG=ghdl1-debug$EXEEXT
COMPILER_MCODE=ghdl1-mcode$EXEEXT
COMPILER_LLVM=lib/ghdl/llvm/ghdl1-llvm$EXEEXT
POST_PROCESSOR=oread-$backend
INSTALL_PREFIX=$prefix
LIBDIR_SUFFIX=$libdirsuffix
LIBGHDLDIR_SUFFIX=$libghdldirsuffix
LIBNATIVEDIR_SUFFIX=$libnativedirsuffix
INCDIR_SUFFIX=$incdirsuffix

# Generate config.status
rm -f config.status
{
  echo "#! /bin/sh"
  echo "# Generated by configure."
  echo "# Run this file to recreate the current configuration."
  echo
  echo 'if [ x"$1" = x"--reconfigure" ]; then'
  #  Do not use exec as bash 3.2 pass the absolute path in argv[0]
  echo $echon "   $progname"$echoc
  for opt do
    echo $echon \ \"$opt\"$echoc
  done
  echo
  echo "  exit"
  echo 'fi'
  echo
  echo subst_vars=\"$subst_vars\"
  for v in $subst_vars; do
    eval vval=\$$v
    echo $v=\'$vval\'
  done
  subst_files="Makefile default_paths.ads ghdl.gpr scripts/gcc/Make-lang.in"
  echo "for f in $subst_files; do"
  echo '  echo "Creating $f"'
  echo '  mkdir -p "$(dirname "$f")"'
  echo "  sed \\"
  for v in $subst_vars; do
      echo "    -e \"s%@$v@%\$$v%g\" \\"
  done
  echo '  < $srcdir/${f}.in > $f'
  echo "done"
} > config.status || \
{
  echo "$progname: cannot create config.status"
  exit 1
}

chmod +x ./config.status

# Run config.status to generate files
if ! sh ./config.status; then
  echo "$progname: cannot execute config.status"
  exit 1
fi

# Create dirs
if ! $MAKE create-dirs; then
    echo "$progname: cannot execute $MAKE create-dirs"
    exit 1
fi

# Generate ortho_code-x86-flags
if test $backend = mcode; then
  case "$build" in
    *darwin*)  ortho_flags="Flags_Macosx${mcode64}" ;;
    *mingw32*) ortho_flags="Flags_Windows${mcode64}" ;;
    *linux*)   ortho_flags="Flags_Linux${mcode64}" ;;
    *-gnu)     ortho_flags="Flags_Linux${mcode64}" ;;
    *openbsd*) ortho_flags="Flags_Macosx${mcode64}" ;;
    *netbsd*)  ortho_flags="Flags_Macosx${mcode64}" ;;
    *) echo "Unsupported $build build for mcode"; exit 1;;
  esac
  echo "Generate ortho_code-x86-flags.ads"
  {
    echo "with Ortho_Code.X86.$ortho_flags;"
    echo "package Ortho_Code.X86.Flags renames Ortho_Code.X86.$ortho_flags;"
  } > ortho_code-x86-flags.ads
  echo "Generate elf_arch.ads"
  {
    echo "with Elf_Arch${mcode64:-32};"
    echo "package Elf_Arch renames Elf_Arch${mcode64:-32};"
  } > elf_arch.ads
fi

# Generate ghdlsynth_maybe.ads
echo "Generate ghdlsynth_maybe.ads"
if [ "$enable_synth" = "true" ]; then
    pkg_synth=Ghdlsynth
else
    pkg_synth=Ghdlnull
fi
echo "with $pkg_synth;" > ghdlsynth_maybe.ads
echo "package Ghdlsynth_Maybe renames $pkg_synth;" >> ghdlsynth_maybe.ads

# Generate grt-readline.ads
echo "Generate grt-readline.ads"
echo "with Grt.Readline_${with_readline};" > grt-readline.ads
echo "package Grt.Readline renames Grt.Readline_${with_readline};" >> grt-readline.ads

exit 0