Debian Codegraph @

configure

raw
1 #! /bin/sh
2
3 # Try to turn internationalization off
4 unset LANG
5 unset LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
6
7 set -e
8
9 PINNED=0
10 SKIP_VERSION_CHECK=0
11 for i in "$@"; do
12 case $i in
13 --bindir=*)
14 BINDIR=${i##*=}
15 ;;
16 --libdir=*)
17 LIBDIR=${i##*=}
18 ;;
19 --pkgdir=*)
20 PKGDIR=${i##*=}
21 ;;
22 --pinned*)
23 PINNED=1
24 ;;
25 --skip-version-check)
26 SKIP_VERSION_CHECK=1
27 ;;
28 *)
29 echo "usage: ./configure [--bindir=<dir>] [--libdir=<dir>] [--pkgdir=<dir>]" 1>&2
30 exit 2
31 ;;
32 esac
33 done
34
35 # OCaml is already installed, this means we should have everything we
36 # need. Just dump its configuration.
37
38 ocaml_version=`ocamlc -version`
39 major=`echo $ocaml_version | cut -d. -f1`
40 minor=`echo $ocaml_version | cut -d. -f2`
41
42 camlp4_version=5.4
43 camlp4_major=`echo $camlp4_version | cut -d. -f1`
44 camlp4_minor=`echo $camlp4_version | cut -d. -f2`
45
46 if [ $major -lt 4 -o \( $major -eq 4 -a $minor -lt 2 \) ]; then
47 echo "The standalone Camlp4 requires OCaml >= 4.02."
48 echo "For previous versions of OCaml use the Camlp4 distributed with OCaml."
49 exit 2
50 elif [ $SKIP_VERSION_CHECK -eq 1 ]; then
51 echo "Skipping OCaml version check"
52 elif [ $major -ne $camlp4_major -o $minor -ne $camlp4_minor ]; then
53 echo "This version of Camlp4 is for OCaml $camlp4_version but you are using OCaml $ocaml_version."
54 if [ -d .git ] ; then
55 if [ $PINNED -eq 1 ] ; then
56 echo "You've used the wrong opam pin URL for this switch.">&2
57 echo "Try https://github.com/ocaml/camlp4.git#$major.$minor instead">&2
58 else
59 echo "You appear to be building Camlp4 from git, so try the $major.$minor branch."
60 fi
61 fi
62 exit 2
63 fi
64
65 ocamlc -config | tr -d '\015' | sed 's/: /="/;s/$/"/' > config.sh
66 ocamlc -config | tr -d '\015' | sed 's/^/let /;s/: / = "/;s/$/"/' > myocamlbuild_config.ml
67
68 # Add a few things to config.sh
69
70 . ./config.sh
71
72 if [ "$os_type" = Win32 ]; then
73 ext_exe=".exe"
74 else
75 ext_exe=""
76 fi
77
78 OCAMLC="`command -v ocamlc`"
79 LIBDIR="${LIBDIR:-$standard_library}"
80 BINDIR="${BINDIR:-`dirname $OCAMLC`}"
81 PKGDIR="${PKGDIR:-$standard_library}"
82
83 if [ -x "`command -v ocamlopt`" ]; then
84 OB_FLAGS=""
85 else
86 OB_FLAGS="-byte-plugin"
87 fi
88
89 COMPLIBS="`ocamlc -where`/compiler-libs"
90 if [ -f "$COMPLIBS/opttoploop.cmi" ]; then
91 OCAMLNAT=true
92 else
93 OCAMLNAT=false
94 fi
95
96 cat >> config.sh <<EOF
97 A="$ext_lib"
98 O="$ext_obj"
99 EXE="$ext_exe"
100 LIBDIR="$LIBDIR"
101 BINDIR="$BINDIR"
102 PKGDIR="$PKGDIR"
103 OB_FLAGS=$OB_FLAGS
104 OCAMLNAT=$OCAMLNAT
105 EOF
106
107 cat >> myocamlbuild_config.ml <<EOF
108 let libdir="$LIBDIR"
109 let bindir="$BINDIR"
110 let pkgdir="$PKGDIR"
111 let ocamlnat=$OCAMLNAT
112 EOF