forked from camlp4/camlp4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·102 lines (87 loc) · 2.29 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
#! /bin/sh
# Try to turn internationalization off
unset LANG
unset LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
set -e
PINNED=0
for i in "$@"; do
case $i in
--bindir=*)
BINDIR=${i##*=}
;;
--libdir=*)
LIBDIR=${i##*=}
;;
--pkgdir=*)
PKGDIR=${i##*=}
;;
--pinned*)
PINNED=1
;;
*)
echo "usage: ./configure [--bindir=<dir>] [--libdir=<dir>] [--pkgdir=<dir>]" 1>&2
exit 2
;;
esac
done
# OCaml is already installed, this means we should have everything we
# need. Just dump its configuration.
ocaml_version=`ocamlc -version`
major=`echo $ocaml_version | cut -d. -f1`
minor=`echo $ocaml_version | cut -d. -f2`
if [ $major -lt 4 -o \( $major -eq 4 -a $minor -lt 2 \) ]; then
echo "The standalone Camlp4 requires OCaml >= 4.02."
echo "For previous versions of OCaml use the Camlp4 distributed with OCaml."
exit 2
elif [ $major -ne 4 -o $minor -ne 7 ]; then
echo "This version of Camlp4 is for OCaml 4.07 but you are using OCaml $ocaml_version."
if [ -d .git ] ; then
if [ $PINNED -eq 1 ] ; then
echo "You've used the wrong opam pin URL for this switch.">&2
echo "Try https://github.com/ocaml/camlp4.git#$major.$minor instead">&2
else
echo "You appear to be building Camlp4 from git, so try the $major.$minor branch."
fi
fi
exit 2
fi
ocamlc -config | tr -d '\015' | sed 's/: /="/;s/$/"/' > config.sh
ocamlc -config | tr -d '\015' | sed 's/^/let /;s/: / = "/;s/$/"/' > myocamlbuild_config.ml
# Add a few things to config.sh
. ./config.sh
if [ "$os_type" = Win32 ]; then
ext_exe=".exe"
else
ext_exe=""
fi
OCAMLC="`command -v ocamlc`"
LIBDIR="${LIBDIR:-$standard_library}"
BINDIR="${BINDIR:-`dirname $OCAMLC`}"
PKGDIR="${PKGDIR:-$standard_library}"
if [ -x "`command -v ocamlopt`" ]; then
OB_FLAGS=""
else
OB_FLAGS="-byte-plugin"
fi
COMPLIBS="`ocamlc -where`/compiler-libs"
if [ -f "$COMPLIBS/opttoploop.cmi" ]; then
OCAMLNAT=true
else
OCAMLNAT=false
fi
cat >> config.sh <<EOF
A="$ext_lib"
O="$ext_obj"
EXE="$ext_exe"
LIBDIR="$LIBDIR"
BINDIR="$BINDIR"
PKGDIR="$PKGDIR"
OB_FLAGS=$OB_FLAGS
OCAMLNAT=$OCAMLNAT
EOF
cat >> myocamlbuild_config.ml <<EOF
let libdir="$LIBDIR"
let bindir="$BINDIR"
let pkgdir="$PKGDIR"
let ocamlnat=$OCAMLNAT
EOF