#!/bin/sh
#######################################################################
# #
# The Compcert verified compiler #
# #
# Xavier Leroy, INRIA Paris-Rocquencourt #
# #
# Copyright Institut National de Recherche en Informatique et en #
# Automatique. All rights reserved. This file is distributed #
# under the terms of the INRIA Non-Commercial License Agreement. #
# #
#######################################################################
prefix=/usr/local
bindir='$(PREFIX)/bin'
libdir='$(PREFIX)/lib/compcert'
toolprefix=''
target=''
usage='Usage: ./configure [options] target
Supported targets:
ppc-linux (PowerPC, Linux)
ppc-eabi (PowerPC, EABI with GNU/Unix tools)
ppc-eabi-diab (PowerPC, EABI with Diab tools)
arm-linux (ARM, EABI)
arm-eabi (ARM, EABI)
ia32-linux (x86 32 bits, Linux)
ia32-bsd (x86 32 bits, BSD)
ia32-macosx (x86 32 bits, MacOS X)
ia32-cygwin (x86 32 bits, Cygwin environment under Windows)
manual (edit configuration file by hand)
Options:
-prefix
Install in /bin and /lib/compcert
-bindir Install binaries in
-libdir Install libraries in
-toolprefix Prefix names of tools ("gcc", etc) with
'
# Parse command-line arguments
while : ; do
case "$1" in
"") break;;
-prefix|--prefix)
prefix="$2"; shift;;
-bindir|--bindir)
bindir="$2"; shift;;
-libdir|--libdir)
libdir="$2"; shift;;
-toolprefix|--toolprefix)
toolprefix="$2"; shift;;
*)
if test -n "$target"; then echo "$usage" 1>&2; exit 2; fi
target="$1";;
esac
shift
done
# Per-target configuration
cchecklink=false
has_runtime_lib=true
casmruntime=""
asm_supports_cfi=""
case "$target" in
powerpc-linux|ppc-linux|powerpc-eabi|ppc-eabi)
arch="powerpc"
variant="eabi"
system="linux"
cc="${toolprefix}gcc"
cprepro="${toolprefix}gcc -U__GNUC__ -E"
casm="${toolprefix}gcc -c"
casmruntime="${toolprefix}gcc -c -Wa,-mregnames"
clinker="${toolprefix}gcc"
libmath="-lm"
cchecklink=true;;
powerpc-eabi-diab|ppc-eabi-diab)
arch="powerpc"
variant="eabi"
system="diab"
cc="${toolprefix}dcc"
cprepro="${toolprefix}dcc -E"
casm="${toolprefix}das"
asm_supports_cfi=false
clinker="${toolprefix}dcc"
libmath="-lm"
cchecklink=true;;
arm-linux|arm-eabi)
arch="arm"
variant="eabi"
system="linux"
cc="${toolprefix}gcc"
cprepro="${toolprefix}gcc -U__GNUC__ '-D__REDIRECT(name,proto,alias)=name proto' '-D__REDIRECT_NTH(name,proto,alias)=name proto' -E"
casm="${toolprefix}gcc -c"
clinker="${toolprefix}gcc"
libmath="-lm";;
ia32-linux)
arch="ia32"
variant="standard"
system="linux"
cc="${toolprefix}gcc -m32"
cprepro="${toolprefix}gcc -m32 -U__GNUC__ -E"
casm="${toolprefix}gcc -m32 -c"
clinker="${toolprefix}gcc -m32"
libmath="-lm";;
ia32-bsd)
arch="ia32"
variant="standard"
system="bsd"
cc="${toolprefix}gcc -m32"
cprepro="${toolprefix}gcc -m32 -U__GNUC__ -E"
casm="${toolprefix}gcc -m32 -c"
clinker="${toolprefix}gcc -m32"
libmath="-lm";;
ia32-macosx)
arch="ia32"
variant="standard"
system="macosx"
cc="${toolprefix}gcc -arch i386"
cprepro="${toolprefix}gcc -arch i386 -U__GNUC__ -U__BLOCKS__ -E"
casm="${toolprefix}gcc -arch i386 -c"
case `uname -r` in
[1-9].*|10.*|11.*) # up to MacOS 10.7 included
clinker="${toolprefix}gcc -arch i386";;
*) # MacOS 10.8 and up
clinker="${toolprefix}gcc -arch i386 -Wl,-no-pie";;
esac
libmath="";;
ia32-cygwin)
arch="ia32"
variant="standard"
system="cygwin"
cc="${toolprefix}gcc -m32"
cprepro="${toolprefix}gcc -m32 -U__GNUC__ -E"
casm="${toolprefix}gcc -m32 -c"
clinker="${toolprefix}gcc -m32"
libmath="-lm";;
manual)
;;
"")
echo "No target specified." 1>&2
echo "$usage" 1>&2
exit 2;;
*)
echo "Unknown target '$target'." 1>&2
echo "$usage" 1>&2
exit 2;;
esac
if test -z "$casmruntime"; then casmruntime="$casm"; fi
# Test assembler support for CFI directives
if test "$target" != "manual" && test -z "$asm_supports_cfi"; then
echo "Testing assembler support for CFI directives... " | tr -d '\n'
f=/tmp/compcert-configure-$$.s
rm -f $f
cat >> $f </dev/null
then echo "yes"; asm_supports_cfi=true
else echo "no"; asm_supports_cfi=false
fi
rm -f $f
fi
# Additional packages needed for cchecklink
if $cchecklink; then
echo "Testing availability of ocaml-bitstring... " | tr -d '\n'
if ocamlfind query bitstring > /dev/null
then
echo "yes"
else
echo "no"
echo "ocamlfind or ocaml-bitstring missing, cchecklink will not be built"
cchecklink=false
fi
fi
# Generate Makefile.config
rm -f Makefile.config
cat > Makefile.config <> Makefile.config <> Makefile.config <<'EOF'
# Target architecture
# ARCH=powerpc
# ARCH=arm
# ARCH=ia32
ARCH=
# Target ABI
# VARIANT=eabi # for PowerPC / Linux and other SVR4 or EABI platforms
# VARIANT=linux # for ARM
# VARIANT=standard # for IA32
VARIANT=
# Target operating system and development environment
# Possible choices for PowerPC:
# SYSTEM=macosx
# SYSTEM=linux
# SYSTEM=diab
# Possible choices for ARM:
# SYSTEM=linux
# Possible choices for IA32:
# SYSTEM=linux
# SYSTEM=bsd
# SYSTEM=macosx
# SYSTEM=cygwin
SYSTEM=
# C compiler for compiling runtime library files and some tests
CC=gcc
# Preprocessor for .c files
CPREPRO=gcc -U__GNUC__ -E
# Assembler for assembling .s files
CASM=gcc -c
# Assembler for assembling runtime library files
CASMRUNTIME=gcc -c
# Linker
CLINKER=gcc
# Math library. Set to empty under MacOS X
LIBMATH=-lm
# Do not change
HAS_RUNTIME_LIB=true
# Whether the assembler $(CASM) supports .cfi debug directives
ASM_SUPPORTS_CFI=false
#ASM_SUPPORTS_CFI=true
EOF
fi
# Summarize configuration
if test "$target" = "manual"; then
cat <