-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfigure.ac
111 lines (101 loc) · 3.49 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
# Configure Script for ToxicR
# Modified 4/27/2022
AC_INIT([ToxicR], 1.0.1) dnl Package version
CXX=`"${R_HOME}/bin/R" CMD config CXX`
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
AC_LANG(C++)
AC_PROG_CPP
# Determine the OS
AC_MSG_CHECKING([Is OPENMP available?])
OS_FLAG="$(uname)"
if test x"${OS_FLAG}" == x"Darwin"; then
AC_MSG_RESULT([no])
OPENMP="-DNO_OMP"
OSFLAG="-D__APPLE__"
elif test x"${OS_FLAG}" == x"Linux"; then
AC_MSG_RESULT([yes])
OPENMP="\$(SHLIB_OPENMP_CXXFLAGS)"
OSFLAG=""
else
AC_MSG_RESULT([yes])
OPENMP="\$(SHLIB_OPENMP_CXXFLAGS)"
OSFLAG="-D__WIN32"
fi
AC_PATH_PROG([GSL_CONFIG], [gsl-config])
## If gsl-config was found, let's use it
if test "${GSL_CONFIG}" != ""; then
AC_MSG_RESULT([yes])
# Use gsl-config for header and linker arguments
gsl_include=$(gsl-config --cflags)
gsl_libs=$(gsl-config --libs)
else
AC_MSG_ERROR([gsl-config not found, is GSL installed?
To install GSL in Ubuntu Type:
sudo apt install gsl
To install GSL in Fedora Type:
sudo yum -y install gsl
To install GSL on macOS using homebrew type:
brew install gsl
])
fi
## Can we use pkg-config?
AC_PATH_PROG(have_pkg_config, pkg-config, no)
AC_MSG_CHECKING([Is pkg-config available?])
if test x"${have_pkg_config}" != x"no"; then
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([if pkg-config knows NLopt])
if pkg-config --exists nlopt; then
AC_MSG_RESULT([yes])
## Since nlopt has been found, test for minimal version requirement
AC_MSG_CHECKING([for pkg-config checking NLopt version])
if pkg-config --atleast-version=2.6.0 nlopt; then
AC_MSG_RESULT([>= 2.6.0])
nlopt_include=$(pkg-config --cflags nlopt)
nlopt_libs=$(pkg-config --libs nlopt)
AC_SUBST([NLOPT_INCLUDE], "${nlopt_include}")
AC_SUBST([NLOPT_LIBS], "${nlopt_libs}")
else
AC_MSG_RESULT([no])
need_to_build="yes"
fi
else
AC_MSG_RESULT([no])
need_to_build="yes"
fi
else
AC_MSG_RESULT([no])
need_to_build="yes"
fi
## So do we need to build
if test x"${need_to_build}" != x"no"; then
AC_PATH_PROG(have_cmake, cmake, no)
if test x"${have_cmake}" == x"no"; then
if test x"${OS_FLAG}" == x"Linux"; then
. src/scripts/cmake_install.sh
if test -z "${CMAKE_BIN}"; then
## also error to end configure here
AC_MSG_ERROR([Could not find 'cmake'.])
fi
fi
fi
## 'uname -m' on M1 give x86_64 which is ... not helping
machine=`"${R_HOME}/bin/Rscript" -e 'cat(Sys.info()[["machine"]])'`
AC_MSG_RESULT([using NLopt via local cmake build on ${machine} ])
tools/cmake_call.sh
## cmake_call.sh installs into nlopt/lib, headers are copied
nlopt_include="-I./nlopt/include"
nlopt_libs="-L./nlopt/lib -lnlopt"
fi
SUBDIR_SOURCES="$(cd src/ && ls {code_base,polyK}/*.cpp | tr '\n' ' ')"
SRC_SOURCES="$( cd src/ && ls *.cpp | tr '\n' ' ')"
AC_SUBST(OPENMP)
AC_SUBST(OSFLAG)
AC_SUBST(SRC_SOURCES)
AC_SUBST(SUBDIR_SOURCES)
AC_SUBST([NLOPT_CPPFLAGS],["${nlopt_include}"])
AC_SUBST([NLOPT_LIBS],["${nlopt_libs}"])
AC_SUBST([GSL_CPPFLAGS],["${gsl_include}"])
AC_SUBST([GSL_LIBS],["${gsl_libs}"])
AC_CONFIG_FILES([src/Makevars])
AC_OUTPUT