-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
120 lines (109 loc) · 3.64 KB
/
configure.ac
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
# Initialize Autoconf
AC_INIT([cobrar], [0.1.1], [[email protected]])
# Initialize variables
LIBSBML_LIBS=""
GLPK_LIBS=""
GMP_LIBS=""
LIBSBML_CFLAGS=""
GLPK_CFLAGS=""
GMP_CFLAGS=""
# Check for pkg-config
PKG_CHECK_EXISTS([pkg-config], [HAVE_PKG_CONFIG=yes], [HAVE_PKG_CONFIG=no])
# Check for user-provided libsbml path
AC_ARG_WITH([libsbml],
AS_HELP_STRING([--with-libsbml=PATH], [Specify libsbml installation path]),
[
if test -d "$withval"; then
LIBSBML_LIBS="-L$withval/lib -lsbml"
LIBSBML_CFLAGS="-I$withval/include"
else
AC_MSG_ERROR([Directory $withval does not exist])
fi
],
[
# Check for libsbml
if test "$HAVE_PKG_CONFIG" = "yes"; then
# Check for libsbml using pkg-config
PKG_CHECK_MODULES([LIBSBML], [libsbml], , AC_MSG_NOTICE([libsbml not found using pkg-config]))
fi
# Last try (no user input, no pkg-config result)
if test "$LIBSBML_LIBS" == ""; then
AC_CHECK_LIB([sbml], [main], [
LIBSBML_LIBS="-lsbml"
], [
AC_MSG_ERROR([libsbml not found])
])
fi
]
)
# Check for user-provided glpk path
AC_ARG_WITH([glpk],
AS_HELP_STRING([--with-glpk=PATH], [Specify glpk installation path]),
[
if test -d "$withval"; then
GLPK_LIBS="-L$withval/lib -lglpk"
GLPK_CFLAGS="$withval/include"
else
AC_MSG_ERROR([Directory $withval does not exist])
fi
],
[
# Check for glpk in default and Homebrew paths as before
AC_CHECK_LIB([glpk], [glp_version], [
GLPK_LIBS="-lglpk"
], [
if test "$(uname)" = "Darwin"; then
if test -n "$(command -v brew)"; then
BREW_PREFIX=$(brew --prefix)
GLPK_LIBS="-L$(find $BREW_PREFIX/Cellar/glpk -name lib) -lglpk"
GLPK_CFLAGS="-I$(dirname `find $BREW_PREFIX/Cellar/GLPK -name glpk.h`)"
else
AC_MSG_ERROR([glpk not found. Consider installing it with homebrew via 'brew install glpk'.])
fi
fi
])
]
)
# Check for user-provided gmp path
AC_ARG_WITH([gmp],
AS_HELP_STRING([--with-gmp=PATH], [Specify gmp (GNU multiple precision arithmetic library) installation path]),
[
if test -d "$withval"; then
GMP_LIBS="-L$withval/lib -lgmp"
GMP_CFLAGS="$withval/include"
else
AC_MSG_ERROR([Directory $withval does not exist])
fi
],
[
# Check for gmp in default and Homebrew paths as before
AC_CHECK_LIB([gmp], [__gmpz_init], [
GMP_LIBS="-lgmp"
], [
if test "$(uname)" = "Darwin"; then
if test -n "$(command -v brew)"; then
BREW_PREFIX=$(brew --prefix)
GMP_LIBS="-L$(find $BREW_PREFIX/Cellar/gmp -name lib) -lgmp"
GMP_CFLAGS="-I$(dirname `find $BREW_PREFIX/Cellar/GMP -name gmp.h`)"
else
AC_MSG_RESULT([gmp (optional) not found. Consider installing it with homebrew via 'brew install gmp'.])
fi
fi
])
]
)
# Output variables
AC_SUBST([LIBSBML_LIBS])
AC_SUBST([GLPK_LIBS])
AC_SUBST([GMP_LIBS])
AC_SUBST([LIBSBML_CFLAGS])
AC_SUBST([GLPK_CFLAGS])
AC_SUBST([GMP_CFLAGS])
# output Makevars
AC_CONFIG_FILES([src/Makevars])
# Output summary
AC_MSG_RESULT([libsbml found: $LIBSBML_CFLAGS $LIBSBML_LIBS])
AC_MSG_RESULT([glpk found: $GLPK_CFLAGS $GLPK_LIBS])
AC_MSG_RESULT([gmp found: $GMP_CFLAGS $GMP_LIBS])
# Output messages
AC_OUTPUT