-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure.ac
189 lines (159 loc) · 6.04 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
AC_INIT([rminizinc],[0.0.8])
# Find the compiler and compiler flags used by R.
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
echo "could not determine R_HOME"
exit 1
fi
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
case "${OS}" in
Windows_NT*)
BUILD_PLATFORM=Windows
;;
*)
uname_str=`uname -s`
case "${uname_str}" in
cygwin*|mingw*)
BUILD_PLATFORM=Windows
;;
*)
BUILD_PLATFORM=MAC_OR_UNIX-LIKE
;;
esac
esac
AC_SUBST([DEFAULT_INCLUDE], "")
AC_SUBST([MZN_INCLUDE], "")
AC_SUBST([MZN_HEADER_PATH], "")
AC_SUBST([MZN_LIBS], "")
AC_SUBST([MZN_LIB_PATH], "")
AC_ARG_WITH(
[mzn],
[AS_HELP_STRING([--with-mzn=PREFIX],[path to where libminizinc is installed])],
[
AS_IF([test "$BUILD_PLATFORM" = "Windows"],
[
AC_MSG_NOTICE([Custom libminizinc path provided!])
MZN_INCLUDE="-I${with_mzn}/include"
MZN_HEADER_PATH="${with_mzn}/include/minizinc"
MZN_LIBS="-L${with_mzn} -lmzn"
MZN_LIB_PATH="${with_mzn}/libmzn.a"
file=${with_mzn}/libmzn.a
if [test -e "$file" ]; then
AC_SUBST([LIB_PATH], "${with_mzn}/libmzn.a")
AC_CHECK_HEADER("${MZN_HEADER_PATH}/ast.hh",
[AC_SUBST([MZN_PATH], 50)], [AC_MSG_NOTICE([header file ast.hh not found at custom path!])])
else
AC_MSG_NOTICE([libmzn.a not found at custom path!])
fi
],
[
AC_MSG_NOTICE([Custom libminizinc path provided!])
MZN_INCLUDE="-I${with_mzn}/include"
MZN_HEADER_PATH="${with_mzn}/include/minizinc"
MZN_LIBS="-L${with_mzn} -lmzn"
MZN_LIB_PATH="${with_mzn}/libmzn.a"
file=${with_mzn}/libmzn.a
if [test -e "$file" ]; then
AC_SUBST([LIB_PATH], "${with_mzn}/libmzn.a")
AC_CHECK_HEADER("${MZN_HEADER_PATH}/ast.hh",
[AC_SUBST([MZN_PATH], 50)], [AC_MSG_NOTICE([header file ast.hh not found at custom path!])])
else
AC_MSG_NOTICE([libmzn.a not found at custom path!])
fi
]
)],
[
AS_IF([test "$BUILD_PLATFORM" = "Windows"],
[
AC_MSG_NOTICE([Custom libminizinc path not provided!])
AC_SUBST([DEFAULT_INCLUDE], "C:/Program Files/libminizinc")
MZN_INCLUDE="-I${DEFAULT_INCLUDE}/include"
MZN_HEADER_PATH="${DEFAULT_INCLUDE}/include/minizinc"
MZN_LIBS="-L${DEFAULT_INCLUDE} -lmzn"
MZN_LIB_PATH="${DEFAULT_INCLUDE}/libmzn.a"
file=${DEFAULT_INCLUDE}/libmzn.a
if [test -e "$file" ]; then
AC_SUBST([LIB_PATH], "${DEFAULT_INCLUDE}/libmzn.a")
AC_CHECK_HEADER("${MZN_HEADER_PATH}/ast.hh",
[AC_SUBST([MZN_PATH], 50)], [AC_MSG_NOTICE([header file ast.hh not found at default path!])])
else
AC_MSG_NOTICE([libmzn.a not found at default path!])
fi
],
[
AC_MSG_NOTICE([Custom libminizinc path not provided!])
AC_SUBST([DEFAULT_INCLUDE], "/usr/local/lib/libminizinc")
MZN_INCLUDE="-I${DEFAULT_INCLUDE}/include"
MZN_HEADER_PATH="${DEFAULT_INCLUDE}/include/minizinc"
MZN_LIBS="-L${DEFAULT_INCLUDE} -lmzn"
MZN_LIB_PATH="${DEFAULT_INCLUDE}/libmzn.a"
file=${DEFAULT_INCLUDE}/libmzn.a
if [test -e "$file" ]; then
AC_SUBST([LIB_PATH], "${DEFAULT_INCLUDE}/libmzn.a")
AC_CHECK_HEADER("${MZN_HEADER_PATH}/ast.hh",
[AC_SUBST([MZN_PATH], 50)], [AC_MSG_NOTICE([header file ast.hh not found at default path!])],
[[#ifdef HAVE_AST_HH
#include <${MZN_HEADER_PATH}/ast.hh>
#endif]])
else
AC_MSG_NOTICE([libmzn.a not found at default path!])
fi
]
)]
)
AC_ARG_WITH(
[bin],
[AS_HELP_STRING([--with-bin=PREFIX],[path to the solver binaries. DON'T USE BACKSLASH AT THE END OF THE PATH])],
[
AC_SUBST([BIN_PATH], ${with_bin})
AS_IF([test "$MZN_PATH" = "50"],
[
AC_SUBST([SLV_BIN], 50)
],
[
AC_MSG_NOTICE([Solver binaries are present but libminizinc is not present or built!])
] )
AC_CONFIG_FILES([inst/minizinc/solvers/gecode.msc])
AC_CONFIG_FILES([inst/minizinc/solvers/chuffed.msc])
AC_CONFIG_FILES([inst/minizinc/solvers/findmus.msc])
AC_CONFIG_FILES([inst/minizinc/solvers/gecode-gist.msc])
AC_CONFIG_FILES([inst/minizinc/solvers/globalizer.msc])
],
[
AC_MSG_NOTICE([Path to the solver binaries is not provided!])
])
AC_SUBST([PROJ_ROOT], "$ac_abs_confdir")
AS_IF([test "${MZN_PATH}" != 50],
[
MZN_HEADER_PATH=""
MZN_INCLUDE=""
MZN_LIBS=""
])
CPP_FLAGS="${CPP_FLAGS} ${MZN_INCLUDE}"
CXX_FLAGS="${CXX_FLAGS} ${MZN_INCLUDE}"
LDFLAGS="${LDFLAGS} ${MZN_LIBS}"
AS_IF([test "$BUILD_PLATFORM" = "Windows"],
[
AC_CONFIG_FILES([src/Makevars.win])
],
[
AC_CONFIG_FILES([src/Makevars])
])
AC_CONFIG_FILES([src/config.h])
AC_OUTPUT
echo "
--------------------------------------------------
Configuration for ${PACKAGE_NAME} ${PACKAGE_VERSION}
cppflags: ${CPPFLAGS} ${PKG_CPPFLAGS} ${MZN_INCLUDE}
ld flags: ${PKG_LIBS} ${MZN_LIBS}
header file folder path: ${MZN_HEADER_PATH}
libmzn path: ${LIB_PATH}
project directory: $ac_abs_confdir
build platform: ${BUILD_PLATFORM}
solver binaries: ${with_bin}
--------------------------------------------------
"