~ubuntu-branches/ubuntu/hardy/freeradius/hardy-proposed

« back to all changes in this revision

Viewing changes to src/modules/rlm_sql/drivers/rlm_sql_mysql/configure.in

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2006-12-16 20:45:11 UTC
  • mfrom: (3.1.10 feisty)
  • Revision ID: james.westby@ubuntu.com-20061216204511-3pbbsu4s8jtehsor
Tags: 1.1.3-3
Fix POSIX compliance problem in init script.  Closes: #403384. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
AC_INIT(sql_mysql.c)
2
 
AC_REVISION($Revision: 1.9 $)
 
2
AC_REVISION($Revision: 1.9.4.1 $)
3
3
AC_DEFUN(modname,[rlm_sql_mysql])
4
4
AC_CONFIG_HEADER(config.h)
5
5
 
6
 
AC_PROG_CC
7
 
AC_PROG_CPP
8
 
 
9
 
AC_ARG_WITH(mysql-include-dir,
10
 
[  --with-mysql-include-dir=DIR       Directory where the MySQL includes may be found ],
11
 
[ mysql_include_dir="$withval" ]
12
 
)
13
 
 
14
 
AC_ARG_WITH(mysql-lib-dir,
15
 
[  --with-mysql-lib-dir=DIR       Directory where the MySQL libraries may be found ],
16
 
[ mysql_lib_dir="$withval" ]
17
 
)
18
 
 
19
 
AC_ARG_WITH(mysql-dir,
20
 
[  --with-mysql-dir=DIR       Base directory where MySQL is installed ],
21
 
[ mysql_lib_dir="$withval/lib/mysql"
22
 
  mysql_include_dir="$withval/include"
23
 
]
24
 
)
 
6
SMART_LIBS=""
 
7
SMART_CLFAGS=""
 
8
mysql_lib_dir=""
 
9
mysql_include_dir=""
25
10
 
26
11
if test x$with_[]modname != xno; then
27
12
 
28
 
        targetname=modname   # we might change this later.
29
 
 
30
 
        AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, yes, no)
31
 
        if test "x$MYSQL_CONFIG" = "xyes"
32
 
        then
33
 
                sql_mysql_ldflags=`mysql_config --libs`
34
 
                sql_mysql_cflags=`mysql_config --cflags`
35
 
                AC_DEFINE(HAVE_MYSQL_H)
36
 
        else
37
 
                AC_CHECK_LIB(z, compress, LIBS="$LIBS -lz")
38
 
 
39
 
                AC_MSG_CHECKING([for mysql/mysql.h])
40
 
 
41
 
                AC_TRY_COMPILE([#include <mysql/mysql.h>], [int a = 1;],
42
 
                        MYSQL_INCLUDE=" ",
43
 
                        MYSQL_INCLUDE=
44
 
                )
45
 
 
46
 
                if test "x$MYSQL_INCLUDE" = "x"; then
47
 
                        old_CFLAGS="$CFLAGS"
48
 
 
49
 
dnl                     AC_LOCATE_DIR(mysql_include_dir,[mysql/mysql.h])
50
 
 
51
 
                        for try in $mysql_include_dir /usr/local/include /usr/local/mysql/include ; do
52
 
                                CFLAGS="$old_CFLAGS -I$try"
53
 
                                AC_TRY_COMPILE([#include <mysql/mysql.h>], [int a = 1;],
54
 
                                        MYSQL_INCLUDE="-I$try",
55
 
                                        MYSQL_INCLUDE=
56
 
                                )
57
 
                                if test "x$MYSQL_INCLUDE" != "x"; then
58
 
                                        AC_DEFINE(HAVE_MYSQL_MYSQL_H)
59
 
                                        break;
60
 
                                fi
61
 
                        done
62
 
                        CFLAGS="$old_CFLAGS"
63
 
                fi
64
 
 
65
 
                if test "x$MYSQL_INCLUDE" = "x"; then
66
 
                        AC_MSG_RESULT(no)
67
 
                        AC_MSG_WARN([mysql headers not found.  Use --with-mysql-include-dir=<path>.])
68
 
                        targetname=   # disabled module
69
 
                else
70
 
                        sql_mysql_cflags="${sql_mysql_cflags} ${MYSQL_INCLUDE}"
71
 
                        AC_MSG_RESULT(yes)
72
 
                        AC_DEFINE(HAVE_MYSQL_H)
73
 
  
74
 
                        AC_MSG_CHECKING([for mysql_init in -lmysqlclient])
75
 
 
76
 
                        old_LIBS="$LIBS"
77
 
 
78
 
dnl                     AC_LOCATE_DIR(mysql_lib_dir,[libmysqlclient.so])
79
 
dnl                     AC_LOCATE_DIR(mysql_lib_dir,[libmysqlclient.a])
80
 
 
81
 
                        for try in $mysql_lib_dir /usr/lib /usr/lib/mysql /usr/local/lib/mysql /usr/local/mysql/lib/mysql; do
82
 
                                LIBS="$old_LIBS -L$try -lmysqlclient"
83
 
                                AC_TRY_LINK([extern char mysql_init();], [mysql_init()],
84
 
                                        MYSQL_LIBS="-L$try -lmysqlclient $old_LIBS",
85
 
                                        MYSQL_LIBS=
86
 
                                )
87
 
                                if test "x$MYSQL_LIBS" != "x"; then
88
 
                                        break;
89
 
                                fi
90
 
                        done
91
 
                        LIBS="$old_LIBS"
92
 
 
93
 
                        dnl #  If one or the other isn't found, disable them both..
94
 
                        dnl #  If both are found, enable them both.
95
 
                        if test "x$MYSQL_LIBS" = "x"; then
96
 
                                AC_MSG_RESULT(no)
97
 
                                MYSQL_INCLUDE=
98
 
                                AC_MSG_WARN([mysql libraries not found.  Use --with-mysql-lib-dir=<path>.])
99
 
                                targetname=   # disabled module
100
 
                        else
101
 
                                AC_MSG_RESULT(yes) 
102
 
                                sql_mysql_ldflags="$sql_mysql_ldflags $MYSQL_LIBS"
103
 
                        fi
104
 
                fi
105
 
                sql_mysql_ldflags="$sql_mysql_ldflags $LIBS"
106
 
        fi
107
 
 
108
 
        if test "x$targetname" = "x"; then
109
 
                AC_MSG_WARN([sql submodule 'mysql' disabled])
110
 
        fi
111
 
 
 
13
    targetname=modname # we change this if a test fails
 
14
 
 
15
    dnl ############################################################
 
16
    dnl # Check for command line options
 
17
    dnl ############################################################
 
18
 
 
19
    dnl extra argument: --with-mysql-dir=DIR
 
20
    AC_ARG_WITH(mysql-dir,
 
21
    [  --with-mysql-dir=DIR          base directory where MySQL is installed ],
 
22
    [ mysql_lib_dir="$withval/lib/mysql"
 
23
      mysql_include_dir="$withval/include" ]
 
24
    )
 
25
 
 
26
    dnl extra argument: --with-mysql-lib-dir=DIR
 
27
    AC_ARG_WITH(mysql-lib-dir,
 
28
    [  --with-mysql-lib-dir=DIR      directory where the MySQL libraries may be found ],
 
29
    [ mysql_lib_dir="$withval" ]
 
30
    )
 
31
 
 
32
    dnl extra argument: --with-mysql-include-dir=DIR
 
33
    AC_ARG_WITH(mysql-include-dir,
 
34
    [  --with-mysql-include-dir=DIR  directory where the MySQL includes may be found ],
 
35
    [ mysql_include_dir="$withval" ]
 
36
    )
 
37
 
 
38
    dnl extra argument: --with-threads
 
39
    mysql_with_threads=yes
 
40
    AC_ARG_WITH(threads,
 
41
    [  --with-threads                use threads, if available. (default=yes) ],
 
42
    [ case "$withval" in
 
43
        no)
 
44
            mysql_with_threads=no
 
45
            ;;
 
46
        *)
 
47
            ;;
 
48
        esac ]
 
49
    )
 
50
 
 
51
    dnl ############################################################
 
52
    dnl # Check for programs
 
53
    dnl ############################################################
 
54
 
 
55
    AC_PROG_CC
 
56
    AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, yes, no)
 
57
 
 
58
    dnl ############################################################
 
59
    dnl # Check for libraries
 
60
    dnl ############################################################
 
61
 
 
62
    dnl pthread stuff is usually in -lpthread
 
63
    dnl or in -lc_r, on *BSD
 
64
    if test "x$mysql_with_threads" = "xyes"; then
 
65
        AC_CHECK_LIB(pthread, pthread_create,
 
66
                     [ LIBS="-lpthread $LIBS" ],
 
67
                     AC_CHECK_LIB(c_r, pthread_create,
 
68
                                  [ LIBS="-lc_r $LIBS" ],
 
69
                                  [ mysql_with_threads=no ]
 
70
                                  )
 
71
                     )
 
72
    fi
 
73
 
 
74
    if test "x$mysql_with_threads" = "xyes"; then
 
75
        dnl try to link to libmysqlclient_r
 
76
        if test "x$MYSQL_CONFIG" = "xyes"; then
 
77
            mysql_libs="$(mysql_config --libs_r)"
 
78
            old_LIBS="$LIBS"
 
79
            LIBS="$mysql_libs $LIBS"
 
80
            AC_MSG_CHECKING([for mysql_init in -lmysqlclient_r (using mysql_config)])
 
81
            AC_TRY_LINK_FUNC(mysql_init, have_libmysqlclient_r=yes)
 
82
            LIBS="$old_LIBS"
 
83
            if test "x$have_libmysqlclient_r" = "xyes"; then
 
84
                AC_MSG_RESULT(yes)
 
85
                SMART_LIBS="$mysql_libs $SMART_LIBS"
 
86
            else
 
87
                AC_MSG_RESULT(no)
 
88
            fi
 
89
        fi
 
90
        if test "x$have_libmysqlclient_r" != "xyes"; then
 
91
            dnl mysql_config didn't work :(
 
92
            smart_try_dir="$mysql_lib_dir /usr/lib /usr/lib/mysql \
 
93
                /usr/local/lib/mysql /usr/local/mysql/lib/mysql"
 
94
            AC_SMART_CHECK_LIB(mysqlclient_r, mysql_init)
 
95
            if test "x$ac_cv_lib_mysqlclient_r_mysql_init" != "xyes"
 
96
                then
 
97
                dnl nothing worked :(
 
98
                AC_MSG_WARN([mysql libraries not found. Use --with-mysql-lib-dir=<path>.])
 
99
                targetname="" # disable module
 
100
            fi
 
101
        fi
 
102
    else
 
103
        dnl try to link to libmysqlclient (without threads support)
 
104
        if test "x$MYSQL_CONFIG" = "xyes"; then
 
105
            mysql_libs="$(mysql_config --libs)"
 
106
            old_LIBS="$LIBS"
 
107
            LIBS="$mysql_libs $LIBS"
 
108
            AC_MSG_CHECKING([for mysql_init in -lmysqlclient (using mysql_config)])
 
109
            AC_TRY_LINK_FUNC(mysql_init, have_libmysqlclient=yes)
 
110
            LIBS="$old_LIBS"
 
111
            if test "x$have_libmysqlclient" = "xyes"; then
 
112
                AC_MSG_RESULT(yes)
 
113
                SMART_LIBS="$mysql_libs $SMART_LIBS"
 
114
            else
 
115
                AC_MSG_RESULT(no)
 
116
            fi
 
117
        fi
 
118
        if test "x$have_libmysqlclient" != "xyes"; then
 
119
            dnl mysql_config didn't work :(
 
120
            smart_try_dir="$mysql_lib_dir /usr/lib /usr/lib/mysql \
 
121
                /usr/local/lib/mysql /usr/local/mysql/lib/mysql"
 
122
            AC_SMART_CHECK_LIB(mysqlclient, mysql_init)
 
123
            if test "x$ac_cv_lib_mysqlclient_mysql_init" != "xyes"
 
124
                then
 
125
                dnl nothing worked :(
 
126
                AC_MSG_WARN([mysql libraries not found. Use --with-mysql-lib-dir=<path>.])
 
127
                targetname="" # disable module
 
128
            fi
 
129
        fi
 
130
    fi
 
131
 
 
132
    dnl ############################################################
 
133
    dnl # Check for header files
 
134
    dnl ############################################################
 
135
 
 
136
    if test "x$MYSQL_CONFIG" = "xyes"; then
 
137
        mysql_cflags="$(mysql_config --cflags)"
 
138
        old_CFLAGS="$CFLAGS"
 
139
        CFLAGS="$CFLAGS $mysql_cflags"
 
140
        AC_MSG_CHECKING([for mysql.h (using mysql_config)])
 
141
        AC_TRY_COMPILE([#include <mysql.h>], [int a = 1;],
 
142
                       have_mysql_h=yes)
 
143
        if test "x$have_mysql_h" = "xyes"; then
 
144
            AC_MSG_RESULT(yes)
 
145
            AC_DEFINE(HAVE_MYSQL_H, [], [Define if you have <mysql.h>])
 
146
            SMART_CFLAGS="$SMART_CFLAGS $mysql_cflags"
 
147
        else
 
148
            AC_MSG_RESULT(no)
 
149
        fi
 
150
        CFLAGS="$old_CFLAGS"
 
151
    fi
 
152
    if test "x$have_mysql_h" != "xyes"; then
 
153
        dnl mysql_config didn't work :(
 
154
        smart_try_dir="$mysql_include_dir /usr/local/include \
 
155
                /usr/local/mysql/include"
 
156
        AC_SMART_CHECK_INCLUDE(mysql/mysql.h)
 
157
        if test "$ac_cv_header_mysql_mysql_h" = "yes"; then
 
158
            AC_DEFINE(HAVE_MYSQL_MYSQL_H, [],
 
159
                      [Define if you have <mysql/mysql.h>])
 
160
        else
 
161
            dnl nothing worked :(
 
162
            AC_MSG_WARN([mysql headers not found. Use --with-mysql-include-dir=<path>.])
 
163
            targetname="" # disable module
 
164
        fi
 
165
    fi
 
166
 
 
167
    if test "x$targetname" = "x"; then
 
168
        AC_MSG_WARN([sql submodule 'mysql' disabled])
 
169
    fi
112
170
else
113
 
        targetname=
114
 
        echo \*\*\* module modname is disabled.
 
171
    targetname=
 
172
    echo \*\*\* module modname is disabled.
115
173
fi
116
174
 
 
175
sql_mysql_ldflags="$SMART_LIBS"
 
176
sql_mysql_cflags="$SMART_CFLAGS"
117
177
AC_SUBST(sql_mysql_ldflags)
118
178
AC_SUBST(sql_mysql_cflags)
119
179
AC_SUBST(targetname)