1dnl ---------------------------------------------------------------------------
2dnl Macro: MYSQL_CHECK_NDBCLUSTER
3dnl ---------------------------------------------------------------------------
4
5# The version of NDB in this version of MySQL is currently fixed
6# and not supposed to be changed unless major changes happen in
7# storage/ndb directory.
8# NOTE! To avoid mixup with MySQL Cluster's version numbers
9# this version of NDB is set to 5.5.7 although it's basically
10# a copy of MySQL Cluster 6.2.18
11NDB_VERSION_MAJOR=5
12NDB_VERSION_MINOR=5
13NDB_VERSION_BUILD=7
14NDB_VERSION_STATUS=""
15TEST_NDBCLUSTER=""
16
17dnl for build ndb docs
18
19AC_PATH_PROG(DOXYGEN, doxygen, no)
20AC_PATH_PROG(PDFLATEX, pdflatex, no)
21AC_PATH_PROG(MAKEINDEX, makeindex, no)
22
23AC_SUBST(DOXYGEN)
24AC_SUBST(PDFLATEX)
25AC_SUBST(MAKEINDEX)
26
27
28AC_DEFUN([MYSQL_CHECK_NDB_OPTIONS], [
29  AC_ARG_WITH([ndb-sci],
30              AC_HELP_STRING([--with-ndb-sci=DIR],
31                             [Provide MySQL with a custom location of
32                             sci library. Given DIR, sci library is
33                             assumed to be in $DIR/lib and header files
34                             in $DIR/include.]),
35              [mysql_sci_dir=${withval}],
36              [mysql_sci_dir=""])
37
38  case "$mysql_sci_dir" in
39    "no" )
40      have_ndb_sci=no
41      AC_MSG_RESULT([-- not including sci transporter])
42      ;;
43    * )
44      if test -f "$mysql_sci_dir/lib/libsisci.a" -a \
45              -f "$mysql_sci_dir/include/sisci_api.h"; then
46        NDB_SCI_INCLUDES="-I$mysql_sci_dir/include"
47        NDB_SCI_LIBS="$mysql_sci_dir/lib/libsisci.a"
48        AC_MSG_RESULT([-- including sci transporter])
49        AC_DEFINE([NDB_SCI_TRANSPORTER], [1],
50                  [Including Ndb Cluster DB sci transporter])
51        AC_SUBST(NDB_SCI_INCLUDES)
52        AC_SUBST(NDB_SCI_LIBS)
53        have_ndb_sci="yes"
54        AC_MSG_RESULT([found sci transporter in $mysql_sci_dir/{include, lib}])
55      else
56        AC_MSG_RESULT([could not find sci transporter in $mysql_sci_dir/{include, lib}])
57      fi
58      ;;
59  esac
60
61  AC_ARG_WITH([ndb-test],
62              [
63  --with-ndb-test       Include the NDB Cluster ndbapi test programs],
64              [ndb_test="$withval"],
65              [ndb_test=no])
66  AC_ARG_WITH([ndb-docs],
67              [
68  --with-ndb-docs       Include the NDB Cluster ndbapi and mgmapi documentation],
69              [ndb_docs="$withval"],
70              [ndb_docs=no])
71  AC_ARG_WITH([ndb-port],
72              [
73  --with-ndb-port       Port for NDB Cluster management server],
74              [ndb_port="$withval"],
75              [ndb_port="default"])
76  AC_ARG_WITH([ndb-port-base],
77              [
78  --with-ndb-port-base  Base port for NDB Cluster transporters],
79              [ndb_port_base="$withval"],
80              [ndb_port_base="default"])
81  AC_ARG_WITH([ndb-debug],
82              [
83  --without-ndb-debug   Disable special ndb debug features],
84              [ndb_debug="$withval"],
85              [ndb_debug="default"])
86  AC_ARG_WITH([ndb-ccflags],
87              AC_HELP_STRING([--with-ndb-ccflags=CFLAGS],
88                           [Extra CFLAGS for ndb compile]),
89              [ndb_ccflags=${withval}],
90              [ndb_ccflags=""])
91  AC_ARG_WITH([ndb-binlog],
92              [
93  --without-ndb-binlog       Disable ndb binlog],
94              [ndb_binlog="$withval"],
95              [ndb_binlog="default"])
96
97  case "$ndb_ccflags" in
98    "yes")
99        AC_MSG_RESULT([The --ndb-ccflags option requires a parameter (passed to CC for ndb compilation)])
100        ;;
101    *)
102        ndb_cxxflags_fix="$ndb_cxxflags_fix $ndb_ccflags"
103    ;;
104  esac
105
106  AC_MSG_CHECKING([for NDB Cluster options])
107  AC_MSG_RESULT([])
108
109  have_ndb_test=no
110  case "$ndb_test" in
111    yes )
112      AC_MSG_RESULT([-- including ndbapi test programs])
113      have_ndb_test="yes"
114      ;;
115    * )
116      AC_MSG_RESULT([-- not including ndbapi test programs])
117      ;;
118  esac
119
120  have_ndb_docs=no
121  case "$ndb_docs" in
122    yes )
123      AC_MSG_RESULT([-- including ndbapi and mgmapi documentation])
124      have_ndb_docs="yes"
125      ;;
126    * )
127      AC_MSG_RESULT([-- not including ndbapi and mgmapi documentation])
128      ;;
129  esac
130
131  case "$ndb_debug" in
132    yes )
133      AC_MSG_RESULT([-- including ndb extra debug options])
134      have_ndb_debug="yes"
135      ;;
136    full )
137      AC_MSG_RESULT([-- including ndb extra extra debug options])
138      have_ndb_debug="full"
139      ;;
140    no )
141      AC_MSG_RESULT([-- not including ndb extra debug options])
142      have_ndb_debug="no"
143      ;;
144    * )
145      have_ndb_debug="default"
146      ;;
147  esac
148
149  AC_MSG_RESULT([done.])
150])
151
152AC_DEFUN([NDBCLUSTER_WORKAROUNDS], [
153
154  #workaround for Sun Forte/x86 see BUG#4681
155  case $SYSTEM_TYPE-$MACHINE_TYPE-$ac_cv_prog_gcc in
156    *solaris*-i?86-no)
157      CFLAGS="$CFLAGS -DBIG_TABLES"
158      CXXFLAGS="$CXXFLAGS -DBIG_TABLES"
159      ;;
160    *)
161      ;;
162  esac
163
164  # workaround for Sun Forte compile problem for ndb
165  case $SYSTEM_TYPE-$ac_cv_prog_gcc in
166    *solaris*-no)
167      ndb_cxxflags_fix="$ndb_cxxflags_fix -instances=static"
168      ;;
169    *)
170      ;;
171  esac
172
173  # ndb fail for whatever strange reason to link Sun Forte/x86
174  # unless using incremental linker
175  case $SYSTEM_TYPE-$MACHINE_TYPE-$ac_cv_prog_gcc-$have_ndbcluster in
176    *solaris*-i?86-no-yes)
177      CXXFLAGS="$CXXFLAGS -xildon"
178      ;;
179    *)
180      ;;
181  esac
182])
183
184AC_DEFUN([MYSQL_SETUP_NDBCLUSTER], [
185
186  AC_MSG_RESULT([Using NDB Cluster])
187  with_partition="yes"
188  ndb_cxxflags_fix=""
189  TEST_NDBCLUSTER="--ndbcluster"
190
191  ndbcluster_includes="-I\$(top_builddir)/storage/ndb/include -I\$(top_srcdir)/storage/ndb/include -I\$(top_srcdir)/storage/ndb/include/ndbapi -I\$(top_srcdir)/storage/ndb/include/mgmapi"
192  ndbcluster_libs="\$(top_builddir)/storage/ndb/src/.libs/libndbclient.a"
193  ndbcluster_system_libs=""
194  ndb_mgmclient_libs="\$(top_builddir)/storage/ndb/src/mgmclient/libndbmgmclient.la"
195
196  MYSQL_CHECK_NDB_OPTIONS
197  NDBCLUSTER_WORKAROUNDS
198
199  MAKE_BINARY_DISTRIBUTION_OPTIONS="$MAKE_BINARY_DISTRIBUTION_OPTIONS --with-ndbcluster"
200
201  if test "$have_ndb_debug" = "default"
202  then
203    have_ndb_debug=$with_debug
204  fi
205
206  if test "$have_ndb_debug" = "yes"
207  then
208    # Medium debug.
209    NDB_DEFS="-DNDB_DEBUG -DVM_TRACE -DERROR_INSERT -DARRAY_GUARD"
210  elif test "$have_ndb_debug" = "full"
211  then
212    NDB_DEFS="-DNDB_DEBUG_FULL -DVM_TRACE -DERROR_INSERT -DARRAY_GUARD"
213  else
214    # no extra ndb debug but still do asserts if debug version
215    if test "$with_debug" = "yes"
216    then
217      NDB_DEFS=""
218    else
219      NDB_DEFS="-DNDEBUG"
220    fi
221  fi
222
223  if test X"$ndb_port" = Xdefault
224  then
225    ndb_port="1186"
226  fi
227
228  have_ndb_binlog="no"
229  if test X"$ndb_binlog" = Xdefault ||
230     test X"$ndb_binlog" = Xyes
231  then
232    have_ndb_binlog="yes"
233  fi
234
235  if test X"$have_ndb_binlog" = Xyes
236  then
237    AC_DEFINE([WITH_NDB_BINLOG], [1],
238              [Including Ndb Cluster Binlog])
239    AC_MSG_RESULT([Including Ndb Cluster Binlog])
240  else
241    AC_MSG_RESULT([Not including Ndb Cluster Binlog])
242  fi
243
244  ndb_transporter_opt_objs=""
245  if test "$ac_cv_func_shmget" = "yes" &&
246     test "$ac_cv_func_shmat" = "yes" &&
247     test "$ac_cv_func_shmdt" = "yes" &&
248     test "$ac_cv_func_shmctl" = "yes" &&
249     test "$ac_cv_func_sigaction" = "yes" &&
250     test "$ac_cv_func_sigemptyset" = "yes" &&
251     test "$ac_cv_func_sigaddset" = "yes" &&
252     test "$ac_cv_func_pthread_sigmask" = "yes"
253  then
254     AC_DEFINE([NDB_SHM_TRANSPORTER], [1],
255               [Including Ndb Cluster DB shared memory transporter])
256     AC_MSG_RESULT([Including ndb shared memory transporter])
257     ndb_transporter_opt_objs="$ndb_transporter_opt_objs SHM_Transporter.lo SHM_Transporter.unix.lo"
258  else
259     AC_MSG_RESULT([Not including ndb shared memory transporter])
260  fi
261
262  if test X"$have_ndb_sci" = Xyes
263  then
264    ndb_transporter_opt_objs="$ndb_transporter_opt_objs SCI_Transporter.lo"
265  fi
266
267  ndb_opt_subdirs=
268  ndb_bin_am_ldflags="-static"
269  if test X"$have_ndb_test" = Xyes
270  then
271    ndb_opt_subdirs="test"
272    ndb_bin_am_ldflags=""
273  fi
274
275  if test X"$have_ndb_docs" = Xyes
276  then
277    ndb_opt_subdirs="$ndb_opt_subdirs docs"
278    ndb_bin_am_ldflags=""
279  fi
280
281  # building dynamic breaks on AIX. (If you want to try it and get unresolved
282  # __vec__delete2 and some such, try linking against libhC.)
283  case "$host_os" in
284    aix3.* | aix4.0.* | aix4.1.*) ;;
285    *) ndb_bin_am_ldflags="-static";;
286  esac
287
288  # libndbclient versioning when linked with GNU ld.
289  if $LD --version 2>/dev/null|grep GNU >/dev/null 2>&1 ; then
290    NDB_LD_VERSION_SCRIPT="-Wl,--version-script=\$(top_builddir)/storage/ndb/src/libndb.ver"
291    AC_CONFIG_FILES(storage/ndb/src/libndb.ver)
292  fi
293  AC_SUBST(NDB_LD_VERSION_SCRIPT)
294
295  AC_SUBST(NDB_SHARED_LIB_MAJOR_VERSION)
296  AC_SUBST(NDB_SHARED_LIB_VERSION)
297
298
299  AC_SUBST(NDB_VERSION_MAJOR)
300  AC_SUBST(NDB_VERSION_MINOR)
301  AC_SUBST(NDB_VERSION_BUILD)
302  AC_SUBST(NDB_VERSION_STATUS)
303  AC_DEFINE_UNQUOTED([NDB_VERSION_MAJOR], [$NDB_VERSION_MAJOR],
304                     [NDB major version])
305  AC_DEFINE_UNQUOTED([NDB_VERSION_MINOR], [$NDB_VERSION_MINOR],
306                     [NDB minor version])
307  AC_DEFINE_UNQUOTED([NDB_VERSION_BUILD], [$NDB_VERSION_BUILD],
308                     [NDB build version])
309  AC_DEFINE_UNQUOTED([NDB_VERSION_STATUS], ["$NDB_VERSION_STATUS"],
310                     [NDB status version])
311
312  AC_SUBST(ndbcluster_includes)
313  AC_SUBST(ndbcluster_libs)
314  AC_SUBST(ndbcluster_system_libs)
315  AC_SUBST(ndb_mgmclient_libs)
316  AC_SUBST(NDB_SCI_LIBS)
317
318  AC_SUBST(ndb_transporter_opt_objs)
319  AC_SUBST(ndb_port)
320  AC_SUBST(ndb_bin_am_ldflags)
321  AC_SUBST(ndb_opt_subdirs)
322
323  AC_SUBST(NDB_DEFS)
324  AC_SUBST(ndb_cxxflags_fix)
325
326  NDB_SIZEOF_CHARP="$ac_cv_sizeof_charp"
327  NDB_SIZEOF_CHAR="$ac_cv_sizeof_char"
328  NDB_SIZEOF_SHORT="$ac_cv_sizeof_short"
329  NDB_SIZEOF_INT="$ac_cv_sizeof_int"
330  NDB_SIZEOF_LONG="$ac_cv_sizeof_long"
331  NDB_SIZEOF_LONG_LONG="$ac_cv_sizeof_long_long"
332  AC_SUBST([NDB_SIZEOF_CHARP])
333  AC_SUBST([NDB_SIZEOF_CHAR])
334  AC_SUBST([NDB_SIZEOF_SHORT])
335  AC_SUBST([NDB_SIZEOF_INT])
336  AC_SUBST([NDB_SIZEOF_LONG])
337  AC_SUBST([NDB_SIZEOF_LONG_LONG])
338
339  AC_CONFIG_FILES([
340   storage/ndb/include/ndb_version.h
341   storage/ndb/include/ndb_global.h
342   storage/ndb/include/ndb_types.h
343  ])
344])
345
346AC_SUBST(TEST_NDBCLUSTER)
347dnl ---------------------------------------------------------------------------
348dnl END OF MYSQL_CHECK_NDBCLUSTER SECTION
349dnl ---------------------------------------------------------------------------
350