mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / config / ac-macros / plugins.m4
blob5d15afeda9938af558ea440be27dbea272268f66
1 dnl ===========================================================================
2 dnl Support for mysql server plugins
3 dnl ===========================================================================
4 dnl
5 dnl WorkLog#3201
6 dnl
7 dnl Framework for pluggable static and dynamic plugins for mysql
8 dnl
9 dnl ---------------------------------------------------------------------------
10 dnl Macro: MYSQL_PLUGIN
11 dnl
12 dnl SYNOPSIS
13 dnl   MYSQL_PLUGIN([name],[Plugin name],
14 dnl                [Plugin description],
15 dnl                [group,group...])
16 dnl   
17 dnl DESCRIPTION
18 dnl   First declaration for a plugin (mandatory).
19 dnl   Adds plugin as member to configuration groups (if specified)
20 dnl
21 dnl ---------------------------------------------------------------------------
23 AC_DEFUN([MYSQL_PLUGIN],[
24  _MYSQL_PLUGIN(
25   [$1],
26   [__MYSQL_PLUGIN_]AS_TR_CPP([$1])[__],
27   m4_default([$2], [$1 plugin]),
28   m4_default([$3], [plugin for $1]),
29   m4_default([$4], []),
30  )
33 AC_DEFUN([_MYSQL_PLUGIN],[
34  m4_ifdef([$2], [
35   AC_FATAL([Duplicate MYSQL_PLUGIN declaration for $3])
36  ],[
37   m4_define([$2], [$1])
38   _MYSQL_PLUGAPPEND([__mysql_plugin_list__],[$1])
39   m4_define([MYSQL_PLUGIN_NAME_]AS_TR_CPP([$1]), [$3])
40   m4_define([MYSQL_PLUGIN_DESC_]AS_TR_CPP([$1]), [$4])
41   _MYSQL_PLUGAPPEND_META([$1], $5)
42   ifelse(m4_bregexp(__mysql_include__,[/plug\.in$]),-1,[],[
43      MYSQL_PLUGIN_DIRECTORY([$1],
44          m4_bregexp(__mysql_include__,[^\(.*\)/plug\.in$],[\1]))
45   ])
46  ])
50 dnl ---------------------------------------------------------------------------
51 dnl Macro: MYSQL_STORAGE_ENGINE
52 dnl
53 dnl SYNOPSIS
54 dnl   MYSQL_STORAGE_ENGINE([name],[legacy-option],[Storage engine name],
55 dnl                        [Storage engine description],[group,group...])
56 dnl
57 dnl DESCRIPTION
58 dnl   Short cut for storage engine declarations
59 dnl
60 dnl ---------------------------------------------------------------------------
62 AC_DEFUN([MYSQL_STORAGE_ENGINE],[
63  MYSQL_PLUGIN([$1], [$3], [$4], [[$5]])
64  MYSQL_PLUGIN_DEFINE([$1], [WITH_]AS_TR_CPP([$1])[_STORAGE_ENGINE])
65  ifelse([$2],[no],[],[
66   _MYSQL_LEGACY_STORAGE_ENGINE(
67       m4_bpatsubst([$1], -, _),
68       m4_bpatsubst(m4_default([$2], [$1-storage-engine]), -, _))
69  ])
72 AC_DEFUN([_MYSQL_LEGACY_STORAGE_ENGINE],[
73 if test "[${with_]$2[+set}]" = set; then
74   [with_plugin_]$1="[$with_]$2"
79 dnl ---------------------------------------------------------------------------
80 dnl Macro: MYSQL_PLUGIN_DEFINE
81 dnl
82 dnl SYNOPSIS
83 dnl   MYSQL_PLUGIN_DEFINE([name],[MYSQL_CPP_DEFINE])
84 dnl
85 dnl DESCRIPTION
86 dnl   When a plugin is to be statically linked, define the C macro
87 dnl
88 dnl ---------------------------------------------------------------------------
90 AC_DEFUN([MYSQL_PLUGIN_DEFINE],[
91  MYSQL_REQUIRE_PLUGIN([$1])
92  m4_define([MYSQL_PLUGIN_DEFINE_]AS_TR_CPP([$1]), [$2])
96 dnl ---------------------------------------------------------------------------
97 dnl Macro: MYSQL_PLUGIN_DIRECTORY
98 dnl
99 dnl SYNOPSIS
100 dnl   MYSQL_PLUGIN_DIRECTORY([name],[plugin/dir])
102 dnl DESCRIPTION
103 dnl   Adds a directory to the build process
104 dnl   if it contains 'configure' it will be picked up automatically
106 dnl ---------------------------------------------------------------------------
108 AC_DEFUN([MYSQL_PLUGIN_DIRECTORY],[
109  MYSQL_REQUIRE_PLUGIN([$1])
110  m4_define([MYSQL_PLUGIN_DIRECTORY_]AS_TR_CPP([$1]), [$2])
114 dnl ---------------------------------------------------------------------------
115 dnl Macro: MYSQL_PLUGIN_STATIC
117 dnl SYNOPSIS
118 dnl   MYSQL_PLUGIN_STATIC([name],[libmyplugin.a])
120 dnl DESCRIPTION
121 dnl   Declare the name for the static library 
123 dnl ---------------------------------------------------------------------------
125 AC_DEFUN([MYSQL_PLUGIN_STATIC],[
126  MYSQL_REQUIRE_PLUGIN([$1])
127  m4_define([MYSQL_PLUGIN_STATIC_]AS_TR_CPP([$1]), [$2])
131 dnl ---------------------------------------------------------------------------
132 dnl Macro: MYSQL_PLUGIN_DYNAMIC
134 dnl SYNOPSIS
135 dnl  MYSQL_PLUGIN_DYNAMIC([name],[myplugin.la])
137 dnl DESCRIPTION
138 dnl   Declare the name for the shared library
140 dnl ---------------------------------------------------------------------------
142 AC_DEFUN([MYSQL_PLUGIN_DYNAMIC],[
143  MYSQL_REQUIRE_PLUGIN([$1])
144  m4_define([MYSQL_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]), [$2])
148 dnl ---------------------------------------------------------------------------
149 dnl Macro: MYSQL_PLUGIN_MANDATORY
151 dnl SYNOPSIS
152 dnl   MYSQL_PLUGIN_MANDATORY([name])
154 dnl DESCRIPTION
155 dnl   Marks the specified plugin as a mandatory plugin
157 dnl ---------------------------------------------------------------------------
159 AC_DEFUN([MYSQL_PLUGIN_MANDATORY],[
160  MYSQL_REQUIRE_PLUGIN([$1])
161  _MYSQL_PLUGIN_MANDATORY([$1],
162   [MYSQL_PLUGIN_MANDATORY_]AS_TR_CPP([$1]),
163   [MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1])
167 AC_DEFUN([_MYSQL_PLUGIN_MANDATORY],[
168  m4_define([$2], [yes])
169  m4_ifdef([$3], [
170   AC_FATAL([mandatory plugin $1 has been disabled])
171   m4_undefine([$2])
172  ])
176 dnl ---------------------------------------------------------------------------
177 dnl Macro: MYSQL_PLUGIN_DISABLED
179 dnl SYNOPSIS
180 dnl   MYSQL_PLUGIN_DISABLED([name])
182 dnl DESCRIPTION
183 dnl   Marks the specified plugin as a disabled plugin
185 dnl ---------------------------------------------------------------------------
187 AC_DEFUN([MYSQL_PLUGIN_DISABLED],[
188  MYSQL_REQUIRE_PLUGIN([$1])
189  _MYSQL_PLUGIN_DISABLED([$1], 
190   [MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
191   [MYSQL_PLUGIN_MANDATORY_]AS_TR_CPP([$1])
195 AC_DEFUN([_MYSQL_PLUGIN_DISABLED],[
196  m4_define([$2], [yes])
197  m4_ifdef([$3], [
198   AC_FATAL([attempt to disable mandatory plugin $1])
199   m4_undefine([$2])
200  ])
204 dnl ---------------------------------------------------------------------------
205 dnl Macro: MYSQL_PLUGIN_DEPENDS
207 dnl SYNOPSIS
208 dnl   MYSQL_PLUGIN_DEPENDS([name],[prereq,prereq...])
210 dnl DESCRIPTION
211 dnl   Enables other plugins neccessary for the named plugin
212 dnl   Dependency checking is not recursive so if any 
213 dnl   required plugin requires further plugins, list them
214 dnl   here too!
216 dnl ---------------------------------------------------------------------------
218 AC_DEFUN([MYSQL_PLUGIN_DEPENDS],[
219  MYSQL_REQUIRE_PLUGIN([$1])
220  ifelse($#, 2, [
221   _MYSQL_PLUGIN_DEPEND([$1], $2)
222  ], [
223   AC_FATAL([bad number of arguments])
224  ])
227 AC_DEFUN([_MYSQL_PLUGIN_DEPEND],[
228  ifelse($#, 1, [], [$#:$2], [2:], [], [
229   MYSQL_REQUIRE_PLUGIN([$2])
230   _MYSQL_PLUGAPPEND([__mysql_plugdepends_$1__],[$2])
231   _MYSQL_PLUGIN_DEPEND([$1], m4_shift(m4_shift($@)))
232  ])
236 dnl ---------------------------------------------------------------------------
237 dnl Macro: MYSQL_PLUGIN_ACTIONS
239 dnl SYNOPSIS
240 dnl   MYSQL_PLUGIN_ACTIONS([name],[PLUGIN_CONFIGURE_STUFF])
242 dnl DESCRIPTION
243 dnl   Declares additional autoconf actions required to configure the plugin
245 dnl ---------------------------------------------------------------------------
247 AC_DEFUN([MYSQL_PLUGIN_ACTIONS],[
248  MYSQL_REQUIRE_PLUGIN([$1])
249  m4_ifdef([$2],[
250    m4_define([MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1]),m4_defn([$2]))
251  ],[
252    m4_define([MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1]), [$2])
253  ])
256 dnl ---------------------------------------------------------------------------
257 dnl Macro: MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS
259 dnl SYNOPSIS
260 dnl   MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS([name],[file name])
262 dnl DESCRIPTION
263 dnl   Some modules in plugins keep dependance on structures
264 dnl   declared in sql/ (THD class usually)
265 dnl   That has to be fixed in the future, but until then
266 dnl   we have to recompile these modules when we want to
267 dnl   to compile server parts with the different #defines
268 dnl   Normally it happens when we compile the embedded server
269 dnl   Thus one should mark such files in his handler using this macro
270 dnl    (currently only one such a file per plugin is supported)
272 dnl ---------------------------------------------------------------------------
274 AC_DEFUN([MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS],[
275  MYSQL_REQUIRE_PLUGIN([$1])
276  m4_define([MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS_]AS_TR_CPP([$1]), [$2])
279 dnl ---------------------------------------------------------------------------
280 dnl Macro: MYSQL_CONFIGURE_PLUGINS
282 dnl SYNOPSIS
283 dnl   MYSQL_PLUGIN_DEPENDS([name,name...])
285 dnl DESCRIPTION
286 dnl   Used last, emits all required shell code to configure the plugins
287 dnl   Argument is a list of default plugins or meta-plugin
289 dnl ---------------------------------------------------------------------------
291 AC_DEFUN([MYSQL_CONFIGURE_PLUGINS],[
292  m4_ifdef([__mysql_plugin_configured__],[
293    AC_FATAL([cannot use [MYSQL_CONFIGURE_PLUGINS] multiple times])
294  ],[
295    m4_define([__mysql_plugin_configured__],[done])
296    _MYSQL_INCLUDE_LIST(
297    m4_bpatsubst(m4_esyscmd([ls plugin/*/plug.in storage/*/plug.in 2>/dev/null]),
298 [[ 
299 ]],[,]))
300    m4_ifdef([__mysql_plugin_list__],[
301     _MYSQL_CHECK_PLUGIN_ARGS([$1])
302     _MYSQL_CONFIGURE_PLUGINS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
303     _MYSQL_EMIT_PLUGIN_ACTIONS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
304     AC_SUBST([mysql_se_dirs])
305     AC_SUBST([mysql_se_distdirs])
306     AC_SUBST([mysql_pg_dirs])
307     AC_SUBST([mysql_pg_distdirs])
308     AC_SUBST([mysql_se_unittest_dirs])
309     AC_SUBST([mysql_pg_unittest_dirs])
310     AC_SUBST([condition_dependent_plugin_modules])
311     AC_SUBST([condition_dependent_plugin_objects])
312     AC_SUBST([condition_dependent_plugin_links])
313     AC_SUBST([condition_dependent_plugin_includes])
314    ])
315  ])
318 AC_DEFUN([_MYSQL_CONFIGURE_PLUGINS],[
319  ifelse($#, 0, [], $#, 1, [
320   _MYSQL_EMIT_CHECK_PLUGIN([$1])
321  ],[
322   _MYSQL_EMIT_CHECK_PLUGIN([$1])
323   _MYSQL_CONFIGURE_PLUGINS(m4_shift($@))
324  ])
327 AC_DEFUN([_MYSQL_EMIT_CHECK_PLUGIN],[
328  __MYSQL_EMIT_CHECK_PLUGIN(
329   [$1],
330   m4_bpatsubst([$1], -, _),
331   [MYSQL_PLUGIN_NAME_]AS_TR_CPP([$1]),
332   [MYSQL_PLUGIN_DESC_]AS_TR_CPP([$1]),
333   [MYSQL_PLUGIN_DEFINE_]AS_TR_CPP([$1]),
334   [MYSQL_PLUGIN_DIRECTORY_]AS_TR_CPP([$1]),
335   [MYSQL_PLUGIN_STATIC_]AS_TR_CPP([$1]),
336   [MYSQL_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]),
337   [MYSQL_PLUGIN_MANDATORY_]AS_TR_CPP([$1]),
338   [MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
339   [MYSQL_PLUGIN_DEPENDS_ON_MYSQL_INTERNALS_]AS_TR_CPP([$1]),
340   [MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1])
344 AC_DEFUN([__MYSQL_EMIT_CHECK_PLUGIN],[
345  m4_ifdef([$5],[
346   AH_TEMPLATE($5, [Include ]$4[ into mysqld])
347  ])
348  AC_MSG_CHECKING([whether to use ]$3)
349  mysql_use_plugin_dir=""
350  m4_ifdef([$10],[
351   if test "X[$mysql_plugin_]$2" = Xyes -a \
352           "X[$with_plugin_]$2" != Xno -o \
353           "X[$with_plugin_]$2" = Xyes; then
354     AC_MSG_RESULT([error])
355     AC_MSG_ERROR([disabled])
356   fi
357   AC_MSG_RESULT([no])
358  ],[
360   # Plugin is not disabled, determine if it should be built,
361   # or only distributed
363   m4_ifdef([$6], [
364     if test ! -d "$srcdir/$6"; then
365       # Plugin directory was removed after autoconf was run; treat
366       # this as a disabled plugin
367       if test "X[$with_plugin_]$2" = Xyes; then
368         AC_MSG_RESULT([error])
369         AC_MSG_ERROR([disabled])
370       fi
372       # The result message will be printed below
373       [with_plugin_]$2=no
374     fi
375   ])
377   m4_ifdef([$9],[
378    if test "X[$with_plugin_]$2" = Xno; then
379      AC_MSG_RESULT([error])
380      AC_MSG_ERROR([cannot disable mandatory plugin])
381    fi
382    [mysql_plugin_]$2=yes
383   ],[
384    case "$with_mysqld_ldflags " in
385      *"-all-static "*)
386        # No need to build shared plugins when mysqld is linked with
387        # -all-static as it won't be able to load them.
388        if test "X[$mysql_plugin_]$2" != Xyes -a \
389                "X[$with_plugin_]$2" != Xyes; then
390              [with_plugin_]$2=no
391            fi
392      ;;
393    esac
394   ])
397   if test "X[$with_plugin_]$2" = Xno; then
398     AC_MSG_RESULT([no])
399   else
400     m4_ifdef([$8],m4_ifdef([$7],[],[[with_plugin_]$2='']))
401     if test "X[$mysql_plugin_]$2" != Xyes -a \
402             "X[$with_plugin_]$2" != Xyes; then
403       m4_ifdef([$8],[
404        m4_ifdef([$6],[
405          if test -d "$srcdir/$6" ; then
406            mysql_use_plugin_dir="$6"
407        ])
408        AC_SUBST([plugin_]$2[_shared_target], "$8")
409        AC_SUBST([plugin_]$2[_static_target], [""])
410        [with_plugin_]$2=yes
411        AC_MSG_RESULT([plugin])
412        m4_ifdef([$6],[
413          else
414            [mysql_plugin_]$2=no
415            AC_MSG_RESULT([no])
416          fi
417        ])
418       ],[
419        [with_plugin_]$2=no
420        AC_MSG_RESULT([no])
421       ])
422     else
423       m4_ifdef([$7],[
424        ifelse(m4_bregexp($7, [^lib[^.]+\.a$]), -2, [
425 dnl change above "-2" to "0" to enable this section
426 dnl Although this is "pretty", it breaks libmysqld build
427         m4_ifdef([$6],[
428          mysql_use_plugin_dir="$6"
429          mysql_plugin_libs="$mysql_plugin_libs -L[\$(top_builddir)]/$6"
430         ])
431         mysql_plugin_libs="$mysql_plugin_libs dnl
432 [-l]m4_bregexp($7, [^lib\([^.]+\)], [\1])"
433        ], m4_bregexp($7, [^\\\$]), 0, [
434         m4_ifdef([$6],[
435          mysql_use_plugin_dir="$6"
436         ])
437         mysql_plugin_libs="$mysql_plugin_libs $7"
438        ], [
439         m4_ifdef([$6],[
440          mysql_use_plugin_dir="$6"
441          mysql_plugin_libs="$mysql_plugin_libs \$(top_builddir)/$6/$7"
442         ],[
443          mysql_plugin_libs="$mysql_plugin_libs $7"
444         ])
445        ])
446        m4_ifdef([$5],[
447         AC_DEFINE($5)
448        ])
449        AC_SUBST([plugin_]$2[_static_target], "$7")
450        AC_SUBST([plugin_]$2[_shared_target], [""])
451       ],[
452        m4_ifdef([$6],[
453         AC_MSG_RESULT([error])
454         AC_MSG_ERROR([Plugin $1 does not support static linking])
455        ],[
456         m4_ifdef([$5],[
457          AC_DEFINE($5)
458          AC_SUBST([plugin_]$2[_static_target], ["yes"])
459          AC_SUBST([plugin_]$2[_shared_target], [""])
460         ])
461        ])
462       ])
463       mysql_plugin_defs="$mysql_plugin_defs, [builtin_]$2[_plugin]"
464       [with_plugin_]$2=yes
465       AC_MSG_RESULT([yes])
466       m4_ifdef([$11],[
467        condition_dependent_plugin_modules="$condition_dependent_plugin_modules m4_bregexp($11, [[^/]+$], [\&])"
468        condition_dependent_plugin_objects="$condition_dependent_plugin_objects m4_bregexp($11, [[^/]+\.], [\&o])"
469        condition_dependent_plugin_links="$condition_dependent_plugin_links $6/$11"
470        condition_dependent_plugin_includes="$condition_dependent_plugin_includes -I[\$(top_srcdir)]/$6/m4_bregexp($11, [^.+[/$]], [\&])"
471       ])
472     fi
473   fi
475   m4_ifdef([$6], [
476     if test -d "$srcdir/$6"; then
477       # Even if we don't build a plugin, we bundle its source into the dist
478       # file.  So its Makefile (and Makefiles for any subdirs) must be
479       # generated for 'make dist' to work.
480       m4_syscmd([test -f "]$6[/configure"])
481       ifelse(m4_sysval, 0,
482         [AC_CONFIG_SUBDIRS($6)],
483         [
484           # autoconf doesn't provide an automatic way to configure DIST_SUBDIRS of
485           # a subdir; for our purposes, it's enough to just check for existing
486           # Makefile.am files and add them in here
488 dnl Warning, don't try to quote the m4_esyscmd() macro, it doesn't
489 dnl work.  Quoting here is tricky.
491 dnl The $FIND or $SED variable can be set by the user when calling autoconf itself
492 dnl to if they need to pass a specific path.  This is *NOT* used when calling
493 dnl running configure!
495           AC_CONFIG_FILES(m4_esyscmd([${FIND-find} "]$6[" -name Makefile.am -print | ${SED-sed} 's,\.am$,,']))
496         ]
497       )
499       ifelse(
500         m4_substr($6, 0, 8), [storage/], [
501           mysql_se_distdirs="$mysql_se_distdirs m4_substr($6, 8)"
502           if test -n "$mysql_use_plugin_dir" ; then
503             mysql_se_dirs="$mysql_se_dirs m4_substr($6, 8)"
504             mysql_se_unittest_dirs="$mysql_se_unittest_dirs ../$6"
505           fi],
507         m4_substr($6, 0, 7), [plugin/], [
508           mysql_pg_distdirs="$mysql_pg_distdirs m4_substr($6, 7)"
509           if test -n "$mysql_use_plugin_dir" ; then
510             mysql_pg_dirs="$mysql_pg_dirs m4_substr($6, 7)"
511             mysql_pg_unittest_dirs="$mysql_pg_unittest_dirs ../$6"
512           fi],
513         [AC_FATAL([don't know how to handle plugin dir ]$6)])
514     fi
515   ])
516  ])
519 AC_DEFUN([_MYSQL_EMIT_PLUGIN_ACTIONS],[
520  ifelse($#, 0, [], $#, 1, [
521   _MYSQL_EMIT_PLUGIN_ACTION([$1])
522  ],[
523   _MYSQL_EMIT_PLUGIN_ACTION([$1])
524   _MYSQL_EMIT_PLUGIN_ACTIONS(m4_shift($@))
525  ])
528 AC_DEFUN([_MYSQL_EMIT_PLUGIN_ACTION],[
529  __MYSQL_EMIT_PLUGIN_ACTION(
530   [$1],
531   m4_bpatsubst([$1], -, _),
532   [MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
533   [MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1])
538 AC_DEFUN([__MYSQL_EMIT_PLUGIN_ACTION],[
539  m4_ifdef([$3], [], [
540   if test "X[$with_plugin_]$2" = Xyes; then
541     if test "X[$plugin_]$2[_static_target]" = X -a \
542             "X[$plugin_]$2[_shared_target]" = X; then
543       AC_MSG_ERROR([that's strange, $1 failed sanity check])
544     fi
545     $4
546   fi
547  ])
552 dnl ===========================================================================
553 dnl  Private helper macros
554 dnl ===========================================================================
557 dnl SYNOPSIS
558 dnl   MYSQL_REQUIRE_PLUGIN([name])
560 dnl DESCRIPTION
561 dnl   Checks that the specified plugin does exist
563 AC_DEFUN([MYSQL_REQUIRE_PLUGIN],[
564  _MYSQL_REQUIRE_PLUGIN([$1], [__MYSQL_PLUGIN_]AS_TR_CPP([$1])[__])
567 define([_MYSQL_REQUIRE_PLUGIN],[
568  ifdef([$2],[
569   ifelse($2, [$1], [], [
570    AC_FATAL([Misspelt MYSQL_PLUGIN declaration for $1])
571   ])
572  ],[
573   AC_FATAL([Missing MYSQL_PLUGIN declaration for $1])
574  ])
578 dnl ---------------------------------------------------------------------------
581 dnl SYNOPSIS
582 dnl   _MYSQL_EMIT_METAPLUGINS([name,name...])
584 dnl DESCRIPTION
585 dnl   Emits shell code for metaplugins
587 AC_DEFUN([_MYSQL_EMIT_METAPLUGINS], [ifelse($#, 0, [], $#, 1,
588 [_MYSQL_EMIT_METAPLUGIN([$1], [__mysql_]m4_bpatsubst($1, -, _)[_plugins__])
590 [_MYSQL_EMIT_METAPLUGIN([$1], [__mysql_]m4_bpatsubst($1, -, _)[_plugins__])
591 _MYSQL_EMIT_METAPLUGINS(m4_shift($@))])
594 AC_DEFUN([_MYSQL_EMIT_METAPLUGIN], [
595   [$1] )
596 m4_ifdef([$2], [
597     mysql_plugins='m4_bpatsubst($2, :, [ ])'
599     mysql_plugins=''
601     ;;
605 dnl ---------------------------------------------------------------------------
608 dnl SYNOPSIS
609 dnl   _MYSQL_PLUGAPPEND([name],[to-append])
611 dnl DESCRIPTION
612 dnl   Helper macro for appending to colon-delimited lists
613 dnl   Optinal 3rd argument is for actions only required when defining
614 dnl   macro named for the first time.
616 AC_DEFUN([_MYSQL_PLUGAPPEND],[
617  m4_ifdef([$1],[
618   m4_define([__plugin_append_tmp__], m4_defn([$1]))
619   m4_undefine([$1])
620   m4_define([$1], __plugin_append_tmp__[:$2])
621   m4_undefine([__plugin_append_tmp__])
622  ],[
623   m4_define([$1], [$2])
624   $3
625  ])
629 dnl SYNOPSIS
630 dnl   _MYSQL_PLUGAPPEND_META([name],[meta,meta...])
632 dnl DESCRIPTION
633 dnl   Helper macro for adding plugins to meta plugins
635 AC_DEFUN([_MYSQL_PLUGAPPEND_META],[
636  ifelse($#, 1, [], [$#:$2], [2:], [], [$2], [all], [
637   AC_FATAL([protected plugin group: all])
638  ], [$2], [none], [
639   AC_FATAL([protected plugin group: none])
640  ],[
641   _MYSQL_PLUGAPPEND([__mysql_$1_configs__],[$2])
642   _MYSQL_PLUGAPPEND([__mysql_]m4_bpatsubst($2, -, _)[_plugins__],[$1], [
643    _MYSQL_PLUGAPPEND([__mysql_metaplugin_list__],[$2])
644   ])
645   _MYSQL_PLUGAPPEND_META([$1], m4_shift(m4_shift($@)))
646  ])
650 dnl ---------------------------------------------------------------------------
653 dnl SYNOPSIS
654 dnl   MYSQL_LIST_PLUGINS
656 dnl DESCRIPTION
657 dnl   Emits formatted list of declared plugins
659 AC_DEFUN([MYSQL_LIST_PLUGINS],[dnl
660  m4_ifdef([__mysql_plugin_list__],[dnl
661   _MYSQL_LIST_PLUGINS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))dnl
662  ])dnl
665 AC_DEFUN([_MYSQL_LIST_PLUGINS],[dnl
666  ifelse($#, 0, [], $#, 1, [dnl
667   MYSQL_SHOW_PLUGIN([$1])dnl
668  ],[dnl
669   MYSQL_SHOW_PLUGIN([$1])dnl
670   _MYSQL_LIST_PLUGINS(m4_shift($@))dnl
671  ])dnl
674 AC_DEFUN([MYSQL_SHOW_PLUGIN],[
675  _MYSQL_SHOW_PLUGIN(
676   [$1],
677   [$1-plugin],
678   [MYSQL_PLUGIN_NAME_]AS_TR_CPP([$1]),
679   [MYSQL_PLUGIN_DESC_]AS_TR_CPP([$1]),
680   [MYSQL_PLUGIN_DEFINE_]AS_TR_CPP([$1]),
681   [MYSQL_PLUGIN_DIRECTORY_]AS_TR_CPP([$1]),
682   [MYSQL_PLUGIN_STATIC_]AS_TR_CPP([$1]),
683   [MYSQL_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]),
684   [MYSQL_PLUGIN_MANDATORY_]AS_TR_CPP([$1]),
685   [MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
686   [MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1]),
687   __mysql_[$1]_configs__,
691 AC_DEFUN([_MYSQL_SHOW_PLUGIN],[dnl
692   === $3 ===
693   Plugin Name:      [$1]
694   Description:      $4
695   Supports build:   _PLUGIN_BUILD_TYPE([$7],[$8])[]dnl
696 m4_ifdef([$12],[
697   Configurations:   m4_bpatsubst($12, :, [, ])])[]dnl
698 m4_ifdef([$10],[
699   Status:           disabled])[]dnl
700 m4_ifdef([$9],[
701   Status:           mandatory])[]dnl
704 AC_DEFUN([_PLUGIN_BUILD_TYPE],
705 [m4_ifdef([$1],[static ]m4_ifdef([$2],[and dnl
706 ]))[]m4_ifdef([$2],[dynamic],[m4_ifdef([$1],[],[static])])])
709 dnl ---------------------------------------------------------------------------
712 AC_DEFUN([_MYSQL_EMIT_PLUGINS],[
713  ifelse($#, 0, [], [$#:$1], [1:], [], [
714   m4_ifdef([MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1]), [], [
715    m4_define([MYSQL_PLUGIN_ACTIONS_]AS_TR_CPP([$1]),[ ])
716   ])
717     [$1] )
718   m4_ifdef([MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),[
719       AC_MSG_ERROR([plugin $1 is disabled])
720   ],[
721     _MYSQL_EMIT_PLUGIN_ENABLE([$1], m4_bpatsubst([$1], -, _),
722       [MYSQL_PLUGIN_NAME_]AS_TR_CPP([$1]),
723       [MYSQL_PLUGIN_STATIC_]AS_TR_CPP([$1]),
724       [MYSQL_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]))
725   ])
726       ;;
727   _MYSQL_EMIT_PLUGINS(m4_shift($@))
728  ])
731 AC_DEFUN([_MYSQL_EMIT_PLUGIN_ENABLE],[
732     m4_ifdef([$5],m4_ifdef([$4],[
733       [mysql_plugin_]$2=yes
734     ],[
735       AC_MSG_WARN([$3 can only be built as a plugin])
736     ]),[
737       [mysql_plugin_]$2=yes
738     ])      
741 AC_DEFUN([_MYSQL_EMIT_PLUGIN_DEPENDS], [
742  ifelse($#, 0, [], [$#:$1], [1:], [], [
743   _MYSQL_EMIT_CHECK_DEPENDS(m4_bpatsubst([$1], -, _), 
744                             [__mysql_plugdepends_$1__])
745   _MYSQL_EMIT_PLUGIN_DEPENDS(m4_shift($@))
746  ])
749 AC_DEFUN([_MYSQL_EMIT_CHECK_DEPENDS], [
750  m4_ifdef([$2], [
751    if test "X[$mysql_plugin_]$1" = Xyes -a \
752            "X[$with_plugin_]$1" != Xno -o \
753            "X[$with_plugin_]$1" = Xyes; then
754      _MYSQL_EMIT_PLUGIN_DEPENDENCIES(m4_bpatsubst($2, :, [,]))
755    fi
756  ])
759 AC_DEFUN([_MYSQL_EMIT_PLUGIN_DEPENDENCIES], [
760  ifelse([$1], [], [], [
761   m4_ifdef([MYSQL_PLUGIN_DISABLED_]AS_TR_CPP([$1]),[
762        AC_MSG_ERROR([depends upon disabled plugin $1])
763   ],[
764        [mysql_plugin_]m4_bpatsubst([$1], -, _)=yes
765        if test "X[$with_plugin_]m4_bpatsubst([$1], -, _)" = Xno; then
766          AC_MSG_ERROR([depends upon disabled plugin $1])
767        fi
768   ])
769   _MYSQL_EMIT_PLUGIN_DEPENDENCIES(m4_shift($@))
770  ])
773 dnl SYNOPSIS
774 dnl   _MYSQL_CHECK_PLUGIN_ARGS([plugin],[plugin]...)
776 dnl DESCRIPTION
777 dnl   Emits shell script for checking configure arguments
778 dnl   Arguments to this macro is default value for selected plugins
780 AC_DEFUN([_MYSQL_CHECK_PLUGIN_ARGS],[
781  __MYSQL_CHECK_PLUGIN_ARGS(m4_default([$1], [none]))
784 AC_DEFUN([__MYSQL_CHECK_PLUGIN_ARGS],[
785  AC_ARG_WITH([plugins],
786 AS_HELP_STRING([--with-plugins=PLUGIN[[[[[,PLUGIN..]]]]]],
787                [Plugins to include in mysqld. (default is: $1) Must be a
788                 configuration name or a comma separated list of plugins.])
789 AS_HELP_STRING([],
790                [Available configurations are:] dnl
791 m4_bpatsubst([none:]m4_ifdef([__mysql_metaplugin_list__],
792              __mysql_metaplugin_list__:)[all], :, [ ])[.])
793 AS_HELP_STRING([],
794                [Available plugins are:] dnl
795 m4_bpatsubst(__mysql_plugin_list__, :, [ ])[.])
796 AS_HELP_STRING([--without-plugin-PLUGIN],
797                [Disable the named plugin from being built. Otherwise, for
798                 plugins which are not selected for inclusion in mysqld will be
799                 built dynamically (if supported)])
800 AS_HELP_STRING([--with-plugin-PLUGIN],
801                [Forces the named plugin to be linked into mysqld statically.]),
802  [mysql_plugins="`echo $withval | tr ',.:;*[]' '       '`"],
803  [mysql_plugins=['$1']])
805 m4_divert_once([HELP_VAR_END],[
806 Description of plugins:
807 MYSQL_LIST_PLUGINS])
809   case "$mysql_plugins" in
810   all )
811     mysql_plugins='m4_bpatsubst(__mysql_plugin_list__, :, [ ])'
812     ;;
813   none )
814     mysql_plugins=''
815     ;;
816 m4_ifdef([__mysql_metaplugin_list__],[
817 _MYSQL_EMIT_METAPLUGINS(m4_bpatsubst(__mysql_metaplugin_list__, :, [,]))
819   esac
821   for plugin in $mysql_plugins; do
822     case "$plugin" in
823     all | none )
824       AC_MSG_ERROR([bad plugin name: $plugin])
825       ;;
826 _MYSQL_EMIT_PLUGINS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
827     * )
828       AC_MSG_ERROR([unknown plugin: $plugin])
829       ;;
830     esac
831   done
833   _MYSQL_EMIT_PLUGIN_DEPENDS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
836 dnl ---------------------------------------------------------------------------
837 dnl Macro: _MYSQL_INCLUDE_LIST
839 dnl SYNOPSIS
840 dnl   _MYSQL_INCLUDE_LIST([filename,filename...])
842 dnl DESCRIPTION
843 dnl   includes all files from the list
845 dnl ---------------------------------------------------------------------------
846 AC_DEFUN([_MYSQL_INCLUDE_LIST],[
847  ifelse([$1], [], [], [
848   m4_define([__mysql_include__],[$1])
849   dnl We have to use builtin(), because sinclude would generate an error
850   dnl "file $1 does not exists" in aclocal-1.8 - which is a bug, clearly
851   dnl violating m4 specs, and which is fixed in aclocal-1.9
852   builtin([include],$1)
853   m4_undefine([__mysql_include__])
854   _MYSQL_INCLUDE_LIST(m4_shift($@))
855  ])
858 dnl ===========================================================================