1 | #-######################################################################
|
---|
2 | # mysql++.m4 - Example autoconf macro showing how to find MySQL++
|
---|
3 | # library and header files.
|
---|
4 | #
|
---|
5 | # Copyright (c) 2004-2009 by Educational Technology Resources, Inc.
|
---|
6 | #
|
---|
7 | # This file is free software; you can redistribute it and/or modify it
|
---|
8 | # under the terms of the GNU Lesser General Public License as published
|
---|
9 | # by the Free Software Foundation; either version 2.1 of the License, or
|
---|
10 | # (at your option) any later version.
|
---|
11 | #
|
---|
12 | # This program is distributed in the hope that it will be useful, but
|
---|
13 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
15 | # Lesser General Public License for more details.
|
---|
16 | #
|
---|
17 | # You should have received a copy of the GNU Lesser General Public
|
---|
18 | # License along with MySQL++; if not, write to the Free Software
|
---|
19 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
|
---|
20 | # USA
|
---|
21 | #-######################################################################
|
---|
22 |
|
---|
23 | dnl @synopsis MYSQLPP_DEVEL
|
---|
24 | dnl
|
---|
25 | dnl This macro tries to find the MySQL++ library and header files.
|
---|
26 | dnl
|
---|
27 | dnl We define the following configure script flags:
|
---|
28 | dnl
|
---|
29 | dnl --with-mysqlpp: Give prefix for both library and headers, and try
|
---|
30 | dnl to guess subdirectory names for each. (e.g. tack /lib and
|
---|
31 | dnl /include onto given dir name, and other common schemes.)
|
---|
32 | dnl --with-mysqlpp-lib: Similar to --with-mysqlpp, but for library only.
|
---|
33 | dnl --with-mysqlpp-include: Similar to --with-mysqlpp, but for headers
|
---|
34 | dnl only.
|
---|
35 | dnl
|
---|
36 | dnl This macro depends on having the default compiler and linker flags
|
---|
37 | dnl set up for building programs against the MySQL C API. The mysql.m4
|
---|
38 | dnl macro in this directory fits this bill; run it first.
|
---|
39 | dnl
|
---|
40 | dnl @version 1.3, 2009/11/22
|
---|
41 | dnl @author Warren Young <mysqlpp@etr-usa.com>
|
---|
42 |
|
---|
43 | AC_DEFUN([MYSQLPP_DEVEL],
|
---|
44 | [
|
---|
45 | dnl
|
---|
46 | dnl Set up configure script macros
|
---|
47 | dnl
|
---|
48 | AC_ARG_WITH(mysqlpp,
|
---|
49 | [ --with-mysqlpp=<path> path containing MySQL++ header and library subdirs],
|
---|
50 | [MYSQLPP_lib_check="$with_mysqlpp/lib64 $with_mysqlpp/lib $with_mysqlpp/lib64/mysql++ $with_mysqlpp/lib/mysql++"
|
---|
51 | MYSQLPP_inc_check="$with_mysqlpp/include $with_mysqlpp/include/mysql++"],
|
---|
52 | [MYSQLPP_lib_check="/usr/local/mysql++/lib64 /usr/local/mysql++/lib /usr/local/lib64/mysql++ /usr/local/lib/mysql++ /opt/mysql++/lib64 /opt/mysql++/lib /usr/lib64/mysql++ /usr/lib/mysql++ /usr/local/lib64 /usr/local/lib /usr/lib64 /usr/lib"
|
---|
53 | MYSQLPP_inc_check="/usr/local/mysql++/include /usr/local/include/mysql++ /opt/mysql++/include /usr/local/include/mysql++ /usr/local/include /usr/include/mysql++ /usr/include"])
|
---|
54 | AC_ARG_WITH(mysqlpp-lib,
|
---|
55 | [ --with-mysqlpp-lib=<path> directory path of MySQL++ library],
|
---|
56 | [MYSQLPP_lib_check="$with_mysqlpp_lib $with_mysqlpp_lib/lib64 $with_mysqlpp_lib/lib $with_mysqlpp_lib/lib64/mysql $with_mysqlpp_lib/lib/mysql"])
|
---|
57 | AC_ARG_WITH(mysqlpp-include,
|
---|
58 | [ --with-mysqlpp-include=<path> directory path of MySQL++ headers],
|
---|
59 | [MYSQLPP_inc_check="$with_mysqlpp_include $with_mysqlpp_include/include $with_mysqlpp_include/include/mysql"])
|
---|
60 |
|
---|
61 | dnl
|
---|
62 | dnl Look for MySQL++ library
|
---|
63 | dnl
|
---|
64 | AC_CACHE_CHECK([for MySQL++ library location], [ac_cv_mysqlpp_lib],
|
---|
65 | [
|
---|
66 | for dir in $MYSQLPP_lib_check
|
---|
67 | do
|
---|
68 | if test -d "$dir" && \
|
---|
69 | ( test -f "$dir/libmysqlpp.so" ||
|
---|
70 | test -f "$dir/libmysqlpp.a" )
|
---|
71 | then
|
---|
72 | ac_cv_mysqlpp_lib=$dir
|
---|
73 | break
|
---|
74 | fi
|
---|
75 | done
|
---|
76 |
|
---|
77 | if test -z "$ac_cv_mysqlpp_lib"
|
---|
78 | then
|
---|
79 | AC_MSG_ERROR([Didn't find the MySQL++ library dir in '$MYSQLPP_lib_check'])
|
---|
80 | fi
|
---|
81 |
|
---|
82 | case "$ac_cv_mysqlpp_lib" in
|
---|
83 | /* ) ;;
|
---|
84 | * ) AC_MSG_ERROR([The MySQL++ library directory ($ac_cv_mysqlpp_lib) must be an absolute path.]) ;;
|
---|
85 | esac
|
---|
86 | ])
|
---|
87 | AC_SUBST([MYSQLPP_LIB_DIR],[$ac_cv_mysqlpp_lib])
|
---|
88 |
|
---|
89 | dnl
|
---|
90 | dnl Look for MySQL++ header file directory
|
---|
91 | dnl
|
---|
92 | AC_CACHE_CHECK([for MySQL++ include path], [ac_cv_mysqlpp_inc],
|
---|
93 | [
|
---|
94 | for dir in $MYSQLPP_inc_check
|
---|
95 | do
|
---|
96 | if test -d "$dir" && test -f "$dir/mysql++.h"
|
---|
97 | then
|
---|
98 | ac_cv_mysqlpp_inc=$dir
|
---|
99 | break
|
---|
100 | fi
|
---|
101 | done
|
---|
102 |
|
---|
103 | if test -z "$ac_cv_mysqlpp_inc"
|
---|
104 | then
|
---|
105 | AC_MSG_ERROR([Didn't find the MySQL++ header dir in '$MYSQLPP_inc_check'])
|
---|
106 | fi
|
---|
107 |
|
---|
108 | case "$ac_cv_mysqlpp_inc" in
|
---|
109 | /* ) ;;
|
---|
110 | * ) AC_MSG_ERROR([The MySQL++ header directory ($ac_cv_mysqlpp_inc) must be an absolute path.]) ;;
|
---|
111 | esac
|
---|
112 | ])
|
---|
113 | AC_SUBST([MYSQLPP_INC_DIR],[$ac_cv_mysqlpp_inc])
|
---|
114 |
|
---|
115 | dnl
|
---|
116 | dnl Now check that the above checks resulted in -I and -L flags that
|
---|
117 | dnl let us build actual programs against MySQL++.
|
---|
118 | dnl
|
---|
119 | case "$ac_cv_mysqlpp_lib" in
|
---|
120 | /usr/lib) ;;
|
---|
121 | *) LDFLAGS="$LDFLAGS -L${ac_cv_mysqlpp_lib}" ;;
|
---|
122 | esac
|
---|
123 | CPPFLAGS="$CPPFLAGS -I${ac_cv_mysqlpp_inc} -I${MYSQL_C_INC_DIR}"
|
---|
124 | AC_MSG_CHECKING([that we can build MySQL++ programs])
|
---|
125 | AC_COMPILE_IFELSE(
|
---|
126 | [AC_LANG_PROGRAM([#include <mysql++.h>],
|
---|
127 | [mysqlpp::Connection c(false)])],
|
---|
128 | AC_MSG_RESULT([yes]),
|
---|
129 | AC_MSG_ERROR([no]))
|
---|
130 | ]) dnl End MYSQLPP_DEVEL
|
---|
131 |
|
---|