summaryrefslogtreecommitdiff
path: root/configure
blob: 455f58b8d4ed52ad2972d39a17774d5b91406191 (plain)
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
#!/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-macosx       (PowerPC, MacOS X)
  ppc-linux        (PowerPC, Linux)
  ppc-eabi         (PowerPC, EABI with GNU/Unix tools)
  ppc-eabi-diab    (PowerPC, EABI with Diab tools)
  arm-linux        (ARM, Linux 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 <dir>    Install in <dir>/bin and <dir>/lib/compcert
  -bindir <dir>    Install binaries in <dir>
  -libdir <dir>    Install libraries in <dir>
  -toolprefix <pref>  Prefix names of tools ("gcc", etc) with <pref>
'

# 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

case "$target" in
  powerpc-macosx|ppc-macosx)
    arch="powerpc"
    variant="macosx"
    system="macosx"
    cc="${toolprefix}gcc -arch ppc"
    cprepro="${toolprefix}gcc -arch ppc -U__GNUC__ -U__BLOCKS__ -E"
    casm="${toolprefix}gcc -arch ppc -c"
    clinker="${toolprefix}gcc -arch ppc"
    libmath=""
    need_stdlib_wrapper="true";;
  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"
    clinker="${toolprefix}gcc"
    libmath="-lm"
    need_stdlib_wrapper="false"
    cchecklink=true;;
  powerpc-eabi-diab|ppc-eabi-diab)
    arch="powerpc"
    variant="eabi"
    system="diab"
    cc="${toolprefix}dcc"
    cprepro="${toolprefix}dcc -E"
    casm="${toolprefix}das"
    clinker="${toolprefix}dcc"
    libmath="-lm"
    need_stdlib_wrapper="false"
    cchecklink=true;;
  arm-linux)
    arch="arm"
    variant="linux"
    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"
    need_stdlib_wrapper="false";;
  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"
    need_stdlib_wrapper="false";;
  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"
    need_stdlib_wrapper="false";;
  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"
    clinker="${toolprefix}gcc -arch i386"
    libmath=""
    need_stdlib_wrapper="true";;
  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"
    need_stdlib_wrapper="false";;
  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

# Additional packages needed for cchecklink

if $cchecklink; then
  if ocamlfind query bitstring > /dev/null
  then :
  else 
    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 <<EOF
PREFIX=$prefix
BINDIR=$bindir
LIBDIR=$libdir
EOF

if test "$target" != "manual"; then
cat >> Makefile.config <<EOF
ARCH=$arch
VARIANT=$variant
SYSTEM=$system
CC=$cc
CPREPRO=$cprepro
CASM=$casm
CLINKER=$clinker
LIBMATH=$libmath
NEED_STDLIB_WRAPPER=$need_stdlib_wrapper
CCHECKLINK=$cchecklink
EOF
else
cat >> Makefile.config <<'EOF'

# Target architecture
# ARCH=powerpc
# ARCH=arm
# ARCH=ia32
ARCH=

# Target ABI
# VARIANT=macosx   # for PowerPC / MacOS X
# 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 library files
CC=gcc

# Preprocessor for .c files
CPREPRO=gcc -U__GNUC__ -E

# Assembler for assembling .s files
CASM=gcc -c

# Linker
CLINKER=gcc

# Math library.  Set to empty under MacOS X
LIBMATH=-lm

# Do we need the thin wrapper around standard library and standard includes
# defined in directory runtime/ ?
# NEED_STDLIB_WRAPPER=true  # for MacOS X
# NEED_STDLIB_WRAPPER=false # for other systems
NEED_STDLIB_WRAPPER=
EOF
fi

# Summarize configuration

if test "$target" = "manual"; then
cat <<EOF

Please finish the configuration by editing file ./Makefile.config.

EOF

else

bindirexp=`echo "$bindir" | sed -e "s|\\\$(PREFIX)|$prefix|"`
libdirexp=`echo "$libdir" | sed -e "s|\\\$(PREFIX)|$prefix|"`

cat <<EOF

CompCert configuration:
    Target architecture........... $arch
    Application binary interface.. $variant
    OS and development env........ $system
    C compiler.................... $cc
    C preprocessor................ $cprepro
    Assembler..................... $casm
    Linker........................ $clinker
    Math library.................. $libmath
    Needs wrapper around stdlib... $need_stdlib_wrapper
    Binaries installed in......... $bindirexp
    Library files installed in.... $libdirexp
    cchecklink tool supported..... $cchecklink

If anything above looks wrong, please edit file ./Makefile.config to correct.

EOF

fi