summaryrefslogtreecommitdiffstats
path: root/plugin/handler_socket/configure.ac
blob: 4395fcf1994ccec72cd204ee0f11924e58d9e911 (plain)
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
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

#AC_PREREQ([2.63b])
AC_INIT([handlersocket-plugin], [1.0.6], [https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL/issues])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_CONFIG_SRCDIR([libhsclient/fatal.cpp])
AC_CONFIG_MACRO_DIR([m4])

AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_LIBTOOL

ac_mysql_debug=
AC_ARG_ENABLE(mysql-debug,
  [AS_HELP_STRING([--enable-mysql-debug], [specify whether MySQL is build with DBUG_ON])],[ac_mysql_debug="$enableval"],[ac_mysql_debug=no])
AC_MSG_CHECKING([if --enable-mysql-debug is specified])
AC_MSG_RESULT($ac_mysql_debug)

AC_DEFUN([CONFIG_OPTION_MYSQL],[
  AC_MSG_CHECKING([mysql source])

  MYSQL_SOURCE_VERSION=
  MYSQL_INC=
  ac_mysql_source_dir=
  AC_ARG_WITH([mysql-source],
    [AS_HELP_STRING([--with-mysql-source=PATH], [MySQL source directory PATH])],
    [
      ac_mysql_source_dir=`cd $withval && pwd`
      if test -f "$ac_mysql_source_dir/sql/handler.h" ; then
        MYSQL_INC="-I$ac_mysql_source_dir/sql"
        MYSQL_INC="$MYSQL_INC -I$ac_mysql_source_dir/include"
        MYSQL_INC="$MYSQL_INC -I$ac_mysql_source_dir/regex"
        MYSQL_INC="$MYSQL_INC -I$ac_mysql_source_dir"
        AC_SUBST(MYSQL_INC)
        if test -f "$ac_mysql_source_dir/VERSION"; then
          source "$ac_mysql_source_dir/VERSION"
          MYSQL_SOURCE_VERSION="$MYSQL_VERSION_MAJOR.$MYSQL_VERSION_MINOR.$MYSQL_VERSION_PATCH"
        else
          if test -f "$ac_mysql_source_dir/configure.in"; then
            MYSQL_SOURCE_VERSION=`cat $ac_mysql_source_dir/configure.in | grep "\[[MySQL Server\]]" | sed -e "s|.*\([[0-9]]\+\.[[0-9]]\+\.[[0-9]]\+[[0-9a-zA-Z\_\-]]*\).*|\1|"`
          else
            AC_MSG_ERROR([invalid MySQL source directory: $ac_mysql_source_dir])
          fi
        fi
        AC_MSG_RESULT([yes: Using $ac_mysql_source_dir, version $MYSQL_SOURCE_VERSION])
      else
        AC_MSG_ERROR([invalid MySQL source directory: $ac_mysql_source_dir])
      fi
    ],
    [AC_MSG_ERROR([--with-mysql-source=PATH is required for standalone build])]
  )

  MYSQL_BIN_VERSION=
  ac_mysql_config=
  AC_ARG_WITH([mysql-bindir],
    [AS_HELP_STRING([--with-mysql-bindir=PATH], [MySQL binary directory PATH. This should be the directory where mysql_config is located.])],
    [
      mysql_bin_dir=`cd $withval 2> /dev/null && pwd || echo ""`
      ac_mysql_config="$mysql_bin_dir/mysql_config"
    ],
    [
      AC_PATH_PROG([ac_mysql_config], [mysql_config])
    ]
  )

  AC_MSG_CHECKING([mysql binary])
  if test ! -x "$ac_mysql_config" ; then
    AC_MSG_ERROR([mysql_config not found! You have to specify the directory where mysql_config resides to --with-mysql-bindir=PATH.])
  fi

  MYSQL_CFLAGS_ADD=`"$ac_mysql_config" --cflags`
  MYSQL_CFLAGS="$MYSQL_CFLAGS $MYSQL_CFLAGS_ADD"
  if test "$ac_mysql_debug" = "yes"; then
    MYSQL_CFLAGS="$MYSQL_CFLAGS -DDBUG_ON -DENABLED_DEBUG_SYNC"
  else
    MYSQL_CFLAGS="$MYSQL_CFLAGS -DDBUG_OFF"
  fi
  AC_SUBST(MYSQL_CFLAGS)

  MYSQL_BIN_VERSION=`"$ac_mysql_config" --version`
  AC_MSG_RESULT([yes: Using $ac_mysql_config, version $MYSQL_BIN_VERSION])

  MYSQL_LIB=`"$ac_mysql_config" --libs_r`
  LIB_DIR=`echo $MYSQL_LIB | sed -e "s|.*-L/|/|" | sed -e "s| .*||"`
    # FIXME
  if test a`basename "$LIB_DIR"` = amysql ; then
    MYSQL_LIB="-L`dirname $LIB_DIR` $MYSQL_LIB" 
      # FIXME
  fi
  AC_SUBST(MYSQL_LIB)

  if test a$MYSQL_SOURCE_VERSION != a$MYSQL_BIN_VERSION ; then
    AC_MSG_ERROR([MySQL source version does not match MySQL binary version])
  fi

  AC_MSG_CHECKING([mysql plugin dir])
  ac_mysql_plugin_dir=
  AC_ARG_WITH([mysql-plugindir],
    [AS_HELP_STRING([--with-mysql-plugindir=PATH], [MySQL plugin directory where handlersocket.so to be copied])],
    [
      ac_mysql_plugin_dir=`cd $withval && pwd`
      if test -d "$ac_mysql_plugin_dir/" ; then
        PLUGIN_DIR="$ac_mysql_plugin_dir"
        AC_SUBST(PLUGIN_DIR)
        AC_MSG_RESULT([yes: Using $ac_mysql_plugin_dir])
      else
        AC_MSG_ERROR([invalid MySQL plugin directory : $ac_mysql_plugin_dir])
      fi
    ],
    [
      LIB_DIR_TMP=`"$ac_mysql_config" --plugindir`
      if test ! -d "$LIB_DIR_TMP"; then
        LIB_DIR_TMP=`"$ac_mysql_config" --libs_r | sed -e "s|.*-L/|/|" | sed -e "s| .*||"`/plugin
          # FIXME
      fi
      ac_mysql_plugin_dir=$LIB_DIR_TMP
      PLUGIN_DIR="$ac_mysql_plugin_dir"
      AC_SUBST(PLUGIN_DIR)
      AC_MSG_RESULT([--with-mysql-plugindir was not set. Using $ac_mysql_plugin_dir])
    ]
  )
])

HANDLERSOCKET_SUBDIRS="libhsclient"
AC_ARG_ENABLE(handlersocket_server,
  [  --enable-handlersocket-server    build HandlerSocket plugin (defalut=yes)])
if test "$enable_handlersocket_server" != "no"; then
  CONFIG_OPTION_MYSQL
  HANDLERSOCKET_SUBDIRS="libhsclient handlersocket client"
fi
AC_SUBST(HANDLERSOCKET_SUBDIRS)

CFLAGS="$CFLAGS -Werror"
CXXFLAGS="$CXXFLAGS -Wall -g -fno-rtti -fno-exceptions -fPIC -DPIC"

AC_CONFIG_FILES([Makefile
                 handlersocket/Makefile
                 libhsclient/Makefile
                 client/Makefile])

AC_OUTPUT