-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathconfigure
executable file
·92 lines (81 loc) · 2.74 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
#! /bin/sh
#########################################################################
# #
# CamlDBM #
# #
# Xavier Leroy, projet Gallium, INRIA Rocquencourt #
# #
# Copyright 2011 Institut National de Recherche en Informatique et #
# en Automatique. All rights reserved. This file is distributed #
# under the terms of the GNU Library General Public License, with #
# the special exception on linking described in file LICENSE. #
# #
#########################################################################
version=`ocamlc -version`
if test $? -ne 0; then
echo "ocamlc not found, aborting."
exit 2
fi
echo "Configuring for OCaml version $version"
echo
stdlib=`ocamlc -where`
hasgot() {
rm -f hasgot.c
(echo "#include <$2>"
echo 'int main() {'
if test $2 = gdbm.h; then
echo ' (void) gdbm_open("foo", 0, 0, 0, NULL);'
else
echo ' (void) dbm_open("foo", 0, 0);'
fi
echo ' return 0;'
echo '}') > hasgot.c
${CC:-cc} $1 -o hasgot.exe hasgot.c $3 2>/dev/null
res=$?
rm -f hasgot.c hasgot.exe
return $res
}
dbm_include="not found"
dbm_link="not found"
dbm_defines=""
for include in \
"" \
"-I/usr/include/db1" \
"-I/usr/include/gdbm" \
"-I/usr/local/include" \
"-I/opt/homebrew/include" ; do
if hasgot "$include" ndbm.h ""; then
dbm_include="$include"
dbm_defines="-DDBM_COMPAT"
dbm_link=""
break
elif hasgot "$include" gdbm.h -lgdbm; then
dbm_include="$include"
dbm_link="-lgdbm"
break
elif hasgot "$include" ndbm.h -lndbm; then
dbm_include="$include"
dbm_defines="-DDBM_COMPAT"
dbm_link="-lndbm"
break
elif hasgot "$include" ndbm.h -ldb1; then
dbm_include="$include"
dbm_defines="-DDBM_COMPAT"
dbm_link="-ldb1"
break
fi
done
if test "$dbm_include" = "not found" || test "$dbm_link" = "not found"; then
echo "NDBM and GDBM not found, the \"camldbm\" library cannot be built."
exit 2
fi
echo "Configuration for the \"camldbm\" library:"
echo " options for compiling .... $dbm_include $dbm_defines"
echo " options for linking ...... $dbm_link"
echo
echo "Configuration successful"
echo
echo "OCAML_STDLIB=$stdlib" > Makefile.config
echo "DBM_INCLUDES=$dbm_include" >> Makefile.config
echo "DBM_LINK=$dbm_link" >> Makefile.config
echo "DBM_DEFINES=$dbm_defines" >> Makefile.config