~jaypipes/drizzle/split-xa-resource-manager

« back to all changes in this revision

Viewing changes to m4/pandora_have_libmysqlclient.m4

  • Committer: Jay Pipes
  • Date: 2010-02-14 20:26:43 UTC
  • mfrom: (1273.1.27 staging)
  • Revision ID: jpipes@serialcoder-20100214202643-ahuqvc8rhn8u7y33
Merge trunk and resolve conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl -*- mode: m4; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
dnl vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
dnl
 
4
dnl  Copyright (C) 2010 Monty Taylor
 
5
dnl  This file is free software; Sun Microsystems
 
6
dnl  gives unlimited permission to copy and/or distribute it,
 
7
dnl  with or without modifications, as long as this notice is preserved.
 
8
dnl
 
9
 
 
10
AC_DEFUN([PANDORA_WITH_MYSQL],[
 
11
  AC_ARG_WITH([mysql],
 
12
    [AS_HELP_STRING([--with-mysql=PATH],
 
13
        [path to mysql_config binary or mysql prefix dir])], 
 
14
      [with_mysql=$withval],
 
15
      [with_mysql=":"])
 
16
 
 
17
  dnl There are three possibilities:
 
18
  dnl   1) nothing is given: we will search for mysql_config in PATH
 
19
  dnl   2) the location of mysql_config is given: we'll use that to determine
 
20
  dnl   3) a directory argument is given: that will be mysql_base
 
21
 
 
22
     
 
23
  dnl option 1: nothing, we need to insert something into MYSQL_CONFIG
 
24
  AS_IF([test "x$with_mysql" = "x:"],[
 
25
    AC_CHECK_PROGS(MYSQL_CONFIG,[mysql_config])
 
26
  ],[
 
27
    MYSQL_CONFIG="${with_mysql}"
 
28
  ])
 
29
 
 
30
  AC_CACHE_CHECK([for MySQL Base Location],[pandora_cv_mysql_base],[
 
31
 
 
32
    dnl option 2: something in MYSQL_CONFIG now, use that to get a base dir
 
33
    AS_IF([test -f "${MYSQL_CONFIG}" -a -x "${MYSQL_CONFIG}"],[
 
34
      pandora_cv_mysql_base=$(dirname $(MYSQL_CONFIG --include | sed 's/-I//'))
 
35
    ],[
 
36
      dnl option 1: a directory
 
37
      AS_IF([test -d $with_mysql],[pandora_cv_mysql_base=$with_mysql],[
 
38
        pandora_cv_mysql_base="not found"
 
39
      ])
 
40
    ])
 
41
  ])
 
42
])
 
43
 
 
44
AC_DEFUN([_PANDORA_SEARCH_LIBMYSQLCLIENT],[
 
45
  AC_REQUIRE([AC_LIB_PREFIX])
 
46
 
 
47
  AC_ARG_ENABLE([libmysqlclient],
 
48
    [AS_HELP_STRING([--disable-libmysqlclient],
 
49
      [Build with libmysqlclient support @<:@default=on@:>@])],
 
50
    [ac_enable_libmysqlclient="$enableval"],
 
51
    [ac_enable_libmysqlclient="yes"])
 
52
 
 
53
  AS_IF([test "x$ac_enable_libmysqlclient" = "xyes"],[
 
54
    AC_LIB_HAVE_LINKFLAGS(mysqlclient_r,,[
 
55
#include <mysql/mysql.h>
 
56
    ],[
 
57
MYSQL mysql;
 
58
  ])],[
 
59
    ac_cv_libmysqlclient_r="no"
 
60
  ])
 
61
 
 
62
  AM_CONDITIONAL(HAVE_LIBMYSQLCLIENT, [test "x${ac_cv_libmysqlclient_r}" = "xyes"])
 
63
  
 
64
AC_DEFUN([PANDORA_HAVE_LIBMYSQLCLIENT],[
 
65
  AC_REQUIRE([_PANDORA_SEARCH_LIBMYSQLCLIENT])
 
66
])
 
67
 
 
68
AC_DEFUN([PANDORA_REQUIRE_LIBMYSQLCLIENT],[
 
69
  AC_REQUIRE([PANDORA_HAVE_LIBMYSQLCLIENT])
 
70
  AS_IF([test "x${ac_cv_libmysqlclient_r}" = "xno"],
 
71
      AC_MSG_ERROR([libmysqlclient_r is required for ${PACKAGE}]))
 
72
])
 
73
 
 
74
  AS_IF([test "x$MYSQL_CONFIG" = "xISDIR"],[
 
75
    IBASE="-I${with_mysql}"
 
76
    MYSQL_CONFIG="${with_mysql}/scripts/mysql_config"
 
77
    ADDIFLAGS="$IBASE/include "
 
78
    ADDIFLAGS="$ADDIFLAGS $IBASE/storage/ndb/include/ndbapi "
 
79
    ADDIFLAGS="$ADDIFLAGS $IBASE/storage/ndb/include/mgmapi "
 
80
    ADDIFLAGS="$ADDIFLAGS $IBASE/storage/ndb/include "
 
81
    LDFLAGS="-L${with_mysql}/storage/ndb/src/.libs -L${with_mysql}/libmysql_r/.libs/ -L${with_mysql}/mysys/.libs -L${with_mysql}/mysys -L${with_mysql}/strings/.libs -L${with_mysql}/strings "
 
82
  ],[
 
83
    IBASE=`$MYSQL_CONFIG --include`
 
84
    ADDIFLAGS=""
 
85
    # add regular MySQL C flags
 
86
    ADDCFLAGS=`$MYSQL_CONFIG --cflags` 
 
87
    # add NdbAPI specific C flags
 
88
    LDFLAGS="$LDFLAGS "`$MYSQL_CONFIG --libs_r | sed 's/-lmysqlclient_r//'`
 
89
    ])
 
90
 
 
91
 
 
92
    ADDIFLAGS="$ADDIFLAGS $IBASE/storage/ndb"
 
93
    ADDIFLAGS="$ADDIFLAGS $IBASE/storage/ndb/ndbapi"
 
94
    ADDIFLAGS="$ADDIFLAGS $IBASE/storage/ndb/mgmapi"
 
95
    ADDIFLAGS="$ADDIFLAGS $IBASE/ndb"
 
96
    ADDIFLAGS="$ADDIFLAGS $IBASE/ndb/ndbapi"
 
97
    ADDIFLAGS="$ADDIFLAGS $IBASE/ndb/mgmapi"
 
98
    ADDIFLAGS="$ADDIFLAGS $IBASE"
 
99
 
 
100
    CFLAGS="$CFLAGS $ADDCFLAGS $ADDIFLAGS"    
 
101
    CXXFLAGS="$CXXFLAGS $ADDCFLAGS $ADDIFLAGS" 
 
102
    MYSQL_INCLUDES="$IBASE $ADDIFLAGS"   
 
103
 
 
104
    
 
105
    dnl AC_CHECK_LIB([mysqlclient_r],[safe_mutex_init],,[AC_MSG_ERROR([Can't link against libmysqlclient_r])])
 
106
    dnl First test to see if we can run with only ndbclient
 
107
    AC_CHECK_LIB([ndbclient],[decimal_bin_size],,[dnl else
 
108
      LDFLAGS="$LDFLAGS -lmysys -ldbug"
 
109
      AC_CHECK_LIB([mysqlclient_r],[safe_mutex_init],,)
 
110
      AC_CHECK_LIB([ndbclient],[ndb_init],,[
 
111
        AC_MSG_ERROR([Can't link against libndbclient])])
 
112
      AC_CHECK_LIB([mystrings],[decimal_bin_size],,[
 
113
          AC_MSG_ERROR([Can't find decimal_bin_size])])])
 
114
    AC_MSG_CHECKING(for NdbApi headers)
 
115
     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <NdbApi.hpp>]], [[int attr=NdbTransaction::Commit; ]])],[ndbapi_found="yes"],[])
 
116
    AS_IF([test "$ndbapi_found" = "yes"], 
 
117
       [AC_MSG_RESULT(found)],
 
118
       [AC_MSG_ERROR([Couldn't find NdbApi.hpp!])])
 
119
    AC_MSG_CHECKING(for NDB_LE_ThreadConfigLoop)
 
120
      AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mgmapi.h>]], [[int attr=NDB_LE_ThreadConfigLoop; ]])],[have_cge63="yes"],[])
 
121
      AS_IF([test "$have_cge63" = "yes"],
 
122
        [AC_MSG_RESULT(found)
 
123
         HAVE_CGE63="-DCGE63"
 
124
         AC_SUBST(HAVE_CGE63)],
 
125
        [AC_MSG_RESULT(missing)])
 
126
 
 
127
    LDFLAGS="$LDFLAGS $LIBS"
 
128
  
 
129
 
 
130
    MYSQL_MAJOR_VERSION=`$MYSQL_CONFIG --version | sed -e 's/\.//g' -e 's/-//g' -e 's/[A-Za-z]//g' | cut -c1-2`
 
131
 
 
132
    case "$MYSQL_MAJOR_VERSION" in 
 
133
      50) AC_DEFINE(MYSQL_50, [1], [mysql5.0])
 
134
        ;;
 
135
      51) AC_DEFINE(MYSQL_51, [1], [mysql5.1])
 
136
        ;;
 
137
      *) echo "Unsupported version of MySQL Detected!"
 
138
        ;;
 
139
     esac
 
140
    
 
141
    AC_SUBST(MYSQL_MAJOR_VERSION)
 
142
    AC_SUBST(MYSQL_CONFIG)
 
143
    
 
144
  
 
145
])
 
146