File: configure

package info (click to toggle)
camlp5 8.04.00-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,968 kB
  • sloc: ml: 137,918; makefile: 2,055; perl: 1,729; sh: 1,653; python: 38
file content (297 lines) | stat: -rwxr-xr-x 7,193 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
#!/bin/bash
# configure,v

prefix=''
bindir=''
libdir=''
mandir=''
mode=S
camlp5n=camlp5
ocamln=ocaml
noopt=0
oversion=''

if [ -f myconfig ]; then
  . ./myconfig
fi

# a local which command for sh
which () {
IFS=":" # set words separator in PATH to be ':' (it allows spaces in dirnames)
for i in $PATH; do
  if test -z "$i"; then $i=.; fi
  if [ -f "$i/$1" ] ; then
	IFS=" "
        echo $i/$1
	break
  fi
done
}

# 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;;
    -mandir|--mandir)
        mandir=$2; shift;;
    -no-opt|--no-opt)
        noopt=1;;
    -oversion|--oversion)
        oversion=$2; shift;;
    -transitional|--transitional)
        mode=T;;
    -strict|--strict)
        mode=S;;
    -oname|--oname)
        ocamln=$2; shift;;
    -name|--name)
        camlp5n=$2; shift;;
    -help|--help)
        echo "Usage: configure [options]"
        echo "Options:"
        echo "  -bindir <dir>, --bindir <dir>"
        echo "        Directory where the binaries will be installed"
        echo "        Default: same than command ocamlc"
        echo "  -libdir <dir>, --libdir <dir>"
        echo "        Directory where the camlp5 directory will be installed"
        echo "        Default: same than 'ocamlc -where'"
        echo "  -mandir <dir>, --mandir <dir>"
        echo "        Directory where the manual pages will be installed"
        echo "        Default: <bindir>/../man"
        echo "  -prefix <dir>, --prefix <dir>"
        echo "        Set bindir, libdir and mandir respectively to"
        echo "        <dir>/bin, <dir>/lib/ocaml, <dir>/man."
        echo "  -no-opt, --no-opt"
        echo "        do not use .opt versions of ocaml compilers"
        echo "  -oversion <name>"
        echo "        specify an OCaml version on ocaml_stuff directory"
        echo "  -transitional, --transitional"
        echo "        compile in transitional mode"
        echo "  -strict, --strict"
        echo "        compile in strict mode"
        echo "  -oname <name>, --oname <name>"
        echo "        OCaml name (default: ocaml)"
        echo "  -name <name>, --name <name>"
        echo "        Camlp5 name (default: camlp5)"
        echo "  -help, --help"
        echo "        this message"
       exit 0;;
    *) echo "Unknown option \"$1\"." 1>&2; exit 2;;
  esac
  shift
done

if [ "$mode" = "T" -o "$mode" = "S" ]; then
  :
else
  echo 1>&2
  echo "Launch \"configure\" with the mode you want:" 1>&2
  echo "   --transitional" 1>&2
  echo "   --strict" 1>&2
  echo 1>&2
  exit 2
fi

echo "mode=$mode" > myconfig

x="$(echo 'Sys.os_type;;' | ocaml | egrep 'Win32|Cygwin')"
if test "$x" = ""; then win=false; else win=true; fi
x="$(echo 'Sys.os_type;;' | ocaml | grep 'Win32')"
if test "$x" = ""; then win32=false; else win32=true; fi

# Sanity checks

if test "$win32" = "false"; then
case "$prefix" in
  /*) ;;
  "") ;;
   *) echo "The -prefix directory must be absolute." 1>&2; exit 2;;
esac
case "$bindir" in
  /*) ;;
  "") ;;
   *) echo "The -bindir directory must be absolute." 1>&2; exit 2;;
esac
case "$libdir" in
  /*) ;;
  "") ;;
   *) echo "The -libdir directory must be absolute." 1>&2; exit 2;;
esac
case "$mandir" in
  /*) ;;
  "") ;;
   *) echo "The -mandir directory must be absolute." 1>&2; exit 2;;
esac
case "$camlp5n" in
  /*) ;;
  "") echo "Camlp5 name must not be empty." 1>&2; exit 2;;
   *) ;;
esac
fi

# Check Ocaml

ocamlc=${ocamln}c
ocamlopt=${ocamln}opt
ocamlrun=${ocamln}run

if ${ocamln}c -v >/dev/null 2>&1; then :
else
    echo "You need the command" ${ocamln}c "accessible in the path!"
    echo "Configuration script failed!"
    exit 1
fi

# Check versions

if [ "$oversion" = "" ]; then
  oversion=$(${ocamln}c -v | head -1 | sed 's/^.*version //; s/ .*$//')
fi
OVERSION=$(echo "$oversion" | sed -e 's/[ +].*$//')
STUFFVERSION=$(./config/find_stuffversion.pl $OVERSION)

if [ -d "ocaml_stuff/$STUFFVERSION" -a \
     -f "ocaml_src/lib/versdep/$STUFFVERSION.ml" ]
then :
else
  echo
  echo "Sorry: the compatibility with ocaml version \"$oversion\""
  echo "is not yet implemented. Please report."
  echo
  if [ -d "ocaml_stuff/$STUFFVERSION" ]; then
    echo "Information: file ocaml_src/lib/versdep/$STUFFVERSION.ml is missing."
  else
    echo "Information: directory ocaml_stuff/$STUFFVERSION is missing."
  fi
  echo
  echo "Configuration failed."
  # to give the ability to do "make steal":
  echo "OVERSION=$OVERSION" > config/Makefile
  echo "OCAMLN=$ocamln" >> config/Makefile
  exit 2
fi

# Evaluate installation directories

ocamlc_where=$($ocamlc -where 2>/dev/null)
if [ "$?" != "0" ]; then
  ocamlc_where=$($ocamlc -v | tail -1 | sed -e 's/^.*: //')
fi

x=$ocamlc_where
y=$(echo $x | sed -e 's|\\\\|/|g')
OLIBDIR="$y"
if [ "$OVERSION" "<" "4.14" ]; then
  C5PACKAGES="compiler-libs,rresult,bos,re,pcre2"
else
  C5PACKAGES="compiler-libs,camlp-streams,rresult,bos,re,pcre2"
fi

EXE=$($ocamlc -config-var ext_exe)
EXT_OBJ=$($ocamlc -config-var ext_obj)
EXT_LIB=$($ocamlc -config-var ext_lib)

if test "$bindir" != ""; then
    BINDIR=$bindir
elif test "$prefix" != ""; then
    BINDIR='$(PREFIX)/bin'
else
    BINDIR=$(dirname "$(which $ocamlc)")
fi
if test "$libdir" != ""; then
    LIBDIR=$libdir
elif test "$prefix" != ""; then
    LIBDIR='$(PREFIX)/lib/ocaml'
else
    LIBDIR=$ocamlc_where
fi
if test "$mandir" != ""; then
    MANDIR=$mandir
elif test "$prefix" != ""; then
    MANDIR='$(PREFIX)/man'
else
    MANDIR=$(dirname "$BINDIR")/man
fi

OPT=
if [ "$noopt" = "0" ] && $ocamlc.opt > /dev/null 2>&1 &&
   $ocamlopt.opt > /dev/null 2>&1
then
    oversion_opt=$($ocamlopt.opt -v | head -1 | sed 's/^.*version //; s/ .*$//')
    if [ "$oversion" = "$oversion_opt" ]; then
      OPT=.opt
    fi
fi

if [ "$(ocamlc -w y 2>&1)" = "" ]; then
  OCAMLC_W_Y="-w y"
else
  OCAMLC_W_Y=""
fi

if [ "$($ocamlc -warn-error +A-11 2>&1)" = "" ]; then
  WARNERR="-warn-error +A-11"
else
  WARNERR=""
fi

if make -f config/Makefile.check --no-print-directory >/dev/null 2>&1; then
  NO_PR_DIR=--no-print-directory
else
  NO_PR_DIR=
fi

VERSION="$(grep "value version =" main/pcaml.ml | sed -e 's/^[^"]*"\([^"]*\).*$/\1/')"

(
echo MODE=$mode
echo EXE=$EXE
echo OPT=$OPT
echo EXT_OBJ=$EXT_OBJ
echo EXT_LIB=$EXT_LIB
echo OVERSION=$STUFFVERSION
echo VERSION=$VERSION
echo OCAMLC_W_Y=\"$OCAMLC_W_Y\"
echo WARNERR=$WARNERR
echo NO_PR_DIR=$NO_PR_DIR
echo OLIBDIR=$OLIBDIR
echo export C5PACKAGES=$C5PACKAGES
if test "$prefix" != ""; then
  echo PREFIX=$prefix
fi
echo "OTOPU=\$(TOP)/ocaml_stuff/$STUFFVERSION/utils"
echo BINDIR=$BINDIR
echo LIBDIR=$LIBDIR
echo MANDIR=$MANDIR
echo OCAMLN=$ocamln
echo CAMLP5N=$camlp5n
) > config/Makefile.cnf

rm -f config/Makefile
cat config/Makefile.tpl > config/Makefile
echo >> config/Makefile
cat config/Makefile.cnf >> config/Makefile

cd ocaml_src/lib
cp "versdep/$STUFFVERSION.ml" versdep.ml
cd ../..

echo
echo "Resulting configuration file (config/Makefile.cnf):"
echo
cat config/Makefile.cnf

echo
if [ "$mode" = "T" ]; then
  echo "=== transitional mode ==="
else
  echo "=== strict mode ==="
fi
echo