forked from gittiver/litesql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
232 lines (215 loc) · 6.32 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
AC_PREREQ(2.53)
AC_INIT([LiteSQL], [0.3.17], [[email protected]], [litesql])
AC_CONFIG_SRCDIR([src/library/database.cpp])
AM_INIT_AUTOMAKE([litesql], [0.3.17])
AM_CONFIG_HEADER(config.h)
if [[ ! -d m4 ]]; then
mkdir m4;
fi
AC_CONFIG_MACRO_DIR([m4])
# Program Checks
AC_PROG_CC
AC_PROG_CXX
AX_CXX_COMPILE_STDCXX_11()
AC_PROG_INSTALL
AC_CHECK_PROG([DOXYGEN], [doxygen], [doxygen], [not found])
# Doxygen
DOXYGEN_OUTPUT_DIR=.
AC_SUBST(DOXYGEN_OUTPUT_DIR)
AM_CONDITIONAL(HAVE_DOXYGEN, [test "x$DOXYGEN" = "xdoxygen"])
DOXYGEN_OUTPUT_SUBDIRS=""
if test "x$DOXYGEN" = "xdoxygen"
then
for d in html
do
DOXYGEN_OUTPUT_SUBDIRS="${DOXYGEN_OUTPUT_SUBDIRS} ${DOXYGEN_OUTPUT_DIR}/$d"
done
fi
AC_SUBST(DOXYGEN_OUTPUT_SUBDIRS)
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([inttypes.h stdlib.h string.h sys/time.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([gettimeofday memset strchr strdup strrchr strstr strtol strtof strtoll atof localtime_r mktime])
pkg_config_reqs_tv=""
# Check for expat
find_expat="yes"
expat_master_dir=/usr
EXPAT_CXXFLAGS=""
EXPAT_LDFLAGS=""
AC_ARG_WITH([expat], AS_HELP_STRING([--with-expat@<:@=PATH@:>@],
[compile with expat support @<:@default=yes@:>@]),[
case "$withval" in
yes) ;;
no) find_expat="no" ;;
*) expat_master_dir=$withval ;;
esac])
if test "x${find_expat}" = "xyes"
then
AC_MSG_CHECKING([for expat header file])
expat_header="${expat_master_dir}/include/expat.h"
if test -r "${expat_header}"
then
if test "x/usr" != "x${expat_master_dir}"
then
EXPAT_CXXFLAGS="-I${expat_master_dir}/include"
EXPAT_LDFLAGS="-L${expat_master_dir}/lib"
fi
else
expat_header="not found"
fi
AC_MSG_RESULT([${expat_header}])
if test "${expat_header}" != "not found"
then
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS ${EXPAT_LDFLAGS}"
AC_CHECK_LIB([expat], [XML_ParserCreate])
LDFLAGS="${saved_LDFLAGS}"
if test "x${ac_cv_lib_expat_XML_ParserCreate}" = "xyes"
then
if test "x" = "x${pkg_config_reqs_tv}"
then
pkg_config_reqs_tv="Requires: expat"
else
pkg_config_reqs_tv="${pkg_config_reqs_tv}, expat"
fi
fi
fi
fi
AC_SUBST(EXPAT_CXXFLAGS)
AC_SUBST(EXPAT_LDFLAGS)
# Check for SQLite3.
find_sqlite3="yes"
sqlite3_master_dir=/usr
SQLITE3_CXXFLAGS=""
SQLITE3_LDFLAGS=""
AC_ARG_WITH([sqlite3], AS_HELP_STRING([--with-sqlite3@<:@=PATH@:>@],
[compile with SQLite3 support @<:@default=yes@:>@]),[
case "$withval" in
yes) ;;
no) find_sqlite3="no" ;;
*) sqlite3_master_dir=$withval ;;
esac])
if test "x${find_sqlite3}" = "xyes"
then
AC_MSG_CHECKING([for SQLite3 header file])
sqlite3_header="${sqlite3_master_dir}/include/sqlite3.h"
if test -r "${sqlite3_header}"
then
if test "x/usr" != "x${sqlite3_master_dir}"
then
SQLITE3_CXXFLAGS="-I${sqlite3_master_dir}/include"
SQLITE3_LDFLAGS="-L${sqlite3_master_dir}/lib"
fi
else
sqlite3_header="not found"
fi
AC_MSG_RESULT([${sqlite3_header}])
if test "${sqlite3_header}" != "not found"
then
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS ${SQLITE3_LDFLAGS}"
AC_CHECK_LIB([sqlite3], [sqlite3_open])
LDFLAGS="${saved_LDFLAGS}"
if test "x${ac_cv_lib_sqlite3_sqlite3_open}" = "xyes"
then
if test "x" = "x${pkg_config_reqs_tv}"
then
pkg_config_reqs_tv="Requires: sqlite3"
else
pkg_config_reqs_tv="${pkg_config_reqs_tv}, sqlite3"
fi
fi
fi
fi
AC_SUBST(SQLITE3_CXXFLAGS)
AC_SUBST(SQLITE3_LDFLAGS)
# Check for MySQL client lib.
AH_TEMPLATE(HAVE_LIBMYSQLCLIENT, [Define to 1 if you have the 'mysqlclient' library (-lmysqlclient).])
find_mysql="yes"
mysql_config_path="/usr"
AC_ARG_VAR([MYSQL_CONFIG], [location of mysql_config])
MYSQL_CXXFLAGS=""
MYSQL_LIBS=""
AC_ARG_WITH([mysql], AS_HELP_STRING([--with-mysql@<:@=PATH@:>@],
[compile with MySQL support @<:@default=yes@:>@]),[
case "$withval" in
yes) ;;
no) find_mysql="no" ;;
*) mysql_config_path=$withval ;;
esac])
if test -d "${mysql_config_path}"
then
mysql_config_path="${mysql_config_path}/bin"
fi
if test "x${find_mysql}" = "xyes"
then
AC_CHECK_PROG([MYSQL_CONFIG], [mysql_config], [${mysql_config_path}/mysql_config],
[not found], [${mysql_config_path}])
if test "x${MYSQL_CONFIG}" != "xnot found"
then
MYSQL_CXXFLAGS=`${MYSQL_CONFIG} --include`
MYSQL_LIBS=`${MYSQL_CONFIG} --libs`
AC_DEFINE([HAVE_LIBMYSQLCLIENT])
fi
fi
AC_SUBST(MYSQL_CXXFLAGS)
AC_SUBST(MYSQL_LIBS)
# Check for PostgreSQL client lib.
find_pgsql="yes"
pgsql_config_path="/usr"
AC_ARG_VAR([PGSQL_CONFIG], [location of pg_config])
PGSQL_CXXFLAGS=""
PGSQL_LDFLAGS=""
PGSQL_LIBS=""
AC_ARG_WITH([pgsql], AS_HELP_STRING([--with-pgsql@<:@=PATH@:>@],
[compile with PostgreSQL support @<:@default=yes@:>@]),[
case "$withval" in
yes) ;;
no) find_pgsql="no" ;;
*) pgsql_config_path=$withval ;;
esac])
if test -d "${pgsql_config_path}"
then
pgsql_config_path="${pgsql_config_path}/bin"
fi
if test "x${find_pgsql}" = "xyes"
then
AC_CHECK_PROG([PGSQL_CONFIG], [pg_config], [${pgsql_config_path}/pg_config],
[not found], [${pgsql_config_path}])
if test "x${PGSQL_CONFIG}" != "xnot found"
then
PGSQL_CXXFLAGS="-I`${PGSQL_CONFIG} --includedir`"
PGSQL_LDFLAGS="-L`${PGSQL_CONFIG} --libdir`"
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS ${PGSQL_LDFLAGS}"
AC_CHECK_LIB([pq], [PQconnectdb])
if test "x${ac_cv_lib_pq_PQconnectdb}" = "xyes"
then
PGSQL_LIBS="-lpq"
fi
LDFLAGS="${saved_LDFLAGS}"
fi
fi
AC_SUBST(PGSQL_CXXFLAGS)
AC_SUBST(PGSQL_LDFLAGS)
AC_SUBST(PGSQL_LIBS)
# "Requires" tag and values for 'litesql.pc'
AC_SUBST(pkg_config_reqs_tv)
# For now, combine various DB backend flags into master flags.
# Later, it might be useful to only compile and link with the flags when necessary.
CXXFLAGS="$CXXFLAGS ${EXPAT_CFLAGS} ${SQLITE3_CXXFLAGS} ${MYSQL_CXXFLAGS} ${PGSQL_CXXFLAGS}"
LDFLAGS="$LDFLAGS ${EXPAT_LDFLAGS} ${SQLITE3_LDFLAGS} ${PGSQL_LDFLAGS}"
LIBS="$LIBS ${MYSQL_LIBS} ${EXPAT_LIBS}"
AC_PROG_LIBTOOL
AC_OUTPUT(Makefile include/Makefile include/litesql/Makefile src/Makefile
src/library/Makefile src/generator/Makefile src/tests/Makefile src/examples/Makefile
docs/Makefile docs/doxygen/Makefile rpm/Makefile pkg/Makefile
docs/doxygen/doxygen.conf rpm/litesql.spec pkg/litesql-config pkg/litesql.pc)