~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to m4/plugins.m4

  • Committer: Jay Pipes
  • Date: 2008-12-21 18:10:35 UTC
  • mto: This revision was merged to the branch mainline in revision 729.
  • Revision ID: jpipes@serialcoder-20081221181035-4sgqwwkfigzutp8z
Fixes mysql.test.  Commented out executable commands which reference the test database, since we don't have one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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: DRIZZLE_PLUGIN
 
11
dnl
 
12
dnl SYNOPSIS
 
13
dnl   DRIZZLE_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 ---------------------------------------------------------------------------
 
22
 
 
23
AC_DEFUN([DRIZZLE_PLUGIN],[
 
24
 _DRIZZLE_PLUGIN(
 
25
  [$1],
 
26
  [__DRIZZLE_PLUGIN_]AS_TR_CPP([$1])[__],
 
27
  m4_default([$2], [$1 plugin]),
 
28
  m4_default([$3], [plugin for $1]),
 
29
  m4_default([$4], []),
 
30
 )
 
31
])
 
32
 
 
33
AC_DEFUN([_DRIZZLE_PLUGIN],[
 
34
 m4_ifdef([$2], [
 
35
  AC_FATAL([Duplicate DRIZZLE_PLUGIN declaration for $3])
 
36
 ],[
 
37
  m4_define([$2], [$1])
 
38
  _DRIZZLE_PLUGAPPEND([__mysql_plugin_list__],[$1])
 
39
  m4_define([DRIZZLE_PLUGIN_NAME_]AS_TR_CPP([$1]), [$3])
 
40
  m4_define([DRIZZLE_PLUGIN_DESC_]AS_TR_CPP([$1]), [$4])
 
41
  _DRIZZLE_PLUGAPPEND_META([$1], $5)
 
42
  ifelse(m4_bregexp(__mysql_include__,[/plug\.in$]),-1,[],[
 
43
     DRIZZLE_PLUGIN_DIRECTORY([$1],
 
44
         m4_bregexp(__mysql_include__,[^\(.*\)/plug\.in$],[\1]))
 
45
  ])
 
46
 ])
 
47
])
 
48
 
 
49
 
 
50
dnl ---------------------------------------------------------------------------
 
51
dnl Macro: DRIZZLE_STORAGE_ENGINE
 
52
dnl
 
53
dnl SYNOPSIS
 
54
dnl   DRIZZLE_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 ---------------------------------------------------------------------------
 
61
 
 
62
AC_DEFUN([DRIZZLE_STORAGE_ENGINE],[
 
63
 DRIZZLE_PLUGIN([$1], [$3], [$4], [[$5]])
 
64
 DRIZZLE_PLUGIN_DEFINE([$1], [WITH_]AS_TR_CPP([$1])[_STORAGE_ENGINE])
 
65
 ifelse([$2],[no],[],[
 
66
  _DRIZZLE_LEGACY_STORAGE_ENGINE(
 
67
      m4_bpatsubst([$1], -, _),
 
68
      m4_bpatsubst(m4_default([$2], [$1-storage-engine]), -, _))
 
69
 ])
 
70
])
 
71
 
 
72
AC_DEFUN([_DRIZZLE_LEGACY_STORAGE_ENGINE],[
 
73
if test "[${with_]$2[+set}]" = set; then
 
74
  [with_plugin_]$1="[$with_]$2"
 
75
fi
 
76
])
 
77
 
 
78
 
 
79
dnl ---------------------------------------------------------------------------
 
80
dnl Macro: DRIZZLE_PLUGIN_DEFINE
 
81
dnl
 
82
dnl SYNOPSIS
 
83
dnl   DRIZZLE_PLUGIN_DEFINE([name],[DRIZZLE_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 ---------------------------------------------------------------------------
 
89
 
 
90
AC_DEFUN([DRIZZLE_PLUGIN_DEFINE],[
 
91
 DRIZZLE_REQUIRE_PLUGIN([$1])
 
92
 m4_define([DRIZZLE_PLUGIN_DEFINE_]AS_TR_CPP([$1]), [$2])
 
93
])
 
94
 
 
95
 
 
96
dnl ---------------------------------------------------------------------------
 
97
dnl Macro: DRIZZLE_PLUGIN_DIRECTORY
 
98
dnl
 
99
dnl SYNOPSIS
 
100
dnl   DRIZZLE_PLUGIN_DIRECTORY([name],[plugin/dir])
 
101
dnl
 
102
dnl DESCRIPTION
 
103
dnl   Adds a directory to the build process
 
104
dnl   if it contains 'configure' it will be picked up automatically
 
105
dnl
 
106
dnl ---------------------------------------------------------------------------
 
107
 
 
108
AC_DEFUN([DRIZZLE_PLUGIN_DIRECTORY],[
 
109
 DRIZZLE_REQUIRE_PLUGIN([$1])
 
110
 m4_define([DRIZZLE_PLUGIN_DIRECTORY_]AS_TR_CPP([$1]), [$2])
 
111
])
 
112
 
 
113
 
 
114
dnl ---------------------------------------------------------------------------
 
115
dnl Macro: DRIZZLE_PLUGIN_STATIC
 
116
dnl
 
117
dnl SYNOPSIS
 
118
dnl   DRIZZLE_PLUGIN_STATIC([name],[libmyplugin.a])
 
119
dnl
 
120
dnl DESCRIPTION
 
121
dnl   Declare the name for the static library 
 
122
dnl
 
123
dnl ---------------------------------------------------------------------------
 
124
 
 
125
AC_DEFUN([DRIZZLE_PLUGIN_STATIC],[
 
126
 DRIZZLE_REQUIRE_PLUGIN([$1])
 
127
 m4_define([DRIZZLE_PLUGIN_STATIC_]AS_TR_CPP([$1]), [$2])
 
128
])
 
129
 
 
130
 
 
131
dnl ---------------------------------------------------------------------------
 
132
dnl Macro: DRIZZLE_PLUGIN_DYNAMIC
 
133
dnl
 
134
dnl SYNOPSIS
 
135
dnl  DRIZZLE_PLUGIN_DYNAMIC([name],[myplugin.la])
 
136
dnl
 
137
dnl DESCRIPTION
 
138
dnl   Declare the name for the shared library
 
139
dnl
 
140
dnl ---------------------------------------------------------------------------
 
141
 
 
142
AC_DEFUN([DRIZZLE_PLUGIN_DYNAMIC],[
 
143
 DRIZZLE_REQUIRE_PLUGIN([$1])
 
144
 m4_define([DRIZZLE_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]), [$2])
 
145
])
 
146
 
 
147
 
 
148
dnl ---------------------------------------------------------------------------
 
149
dnl Macro: DRIZZLE_PLUGIN_MANDATORY
 
150
dnl
 
151
dnl SYNOPSIS
 
152
dnl   DRIZZLE_PLUGIN_MANDATORY([name])
 
153
dnl
 
154
dnl DESCRIPTION
 
155
dnl   Marks the specified plugin as a mandatory plugin
 
156
dnl
 
157
dnl ---------------------------------------------------------------------------
 
158
 
 
159
AC_DEFUN([DRIZZLE_PLUGIN_MANDATORY],[
 
160
 DRIZZLE_REQUIRE_PLUGIN([$1])
 
161
 _DRIZZLE_PLUGIN_MANDATORY([$1],
 
162
  [DRIZZLE_PLUGIN_MANDATORY_]AS_TR_CPP([$1]),
 
163
  [DRIZZLE_PLUGIN_DISABLED_]AS_TR_CPP([$1])
 
164
 )
 
165
])
 
166
 
 
167
AC_DEFUN([_DRIZZLE_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
 ])
 
173
])
 
174
 
 
175
 
 
176
dnl ---------------------------------------------------------------------------
 
177
dnl Macro: DRIZZLE_PLUGIN_DISABLED
 
178
dnl
 
179
dnl SYNOPSIS
 
180
dnl   DRIZZLE_PLUGIN_DISABLED([name])
 
181
dnl
 
182
dnl DESCRIPTION
 
183
dnl   Marks the specified plugin as a disabled plugin
 
184
dnl
 
185
dnl ---------------------------------------------------------------------------
 
186
 
 
187
AC_DEFUN([DRIZZLE_PLUGIN_DISABLED],[
 
188
 DRIZZLE_REQUIRE_PLUGIN([$1])
 
189
 _DRIZZLE_PLUGIN_DISABLED([$1], 
 
190
  [DRIZZLE_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
 
191
  [DRIZZLE_PLUGIN_MANDATORY_]AS_TR_CPP([$1])
 
192
 )
 
193
])
 
194
 
 
195
AC_DEFUN([_DRIZZLE_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
 ])
 
201
])
 
202
 
 
203
 
 
204
dnl ---------------------------------------------------------------------------
 
205
dnl Macro: DRIZZLE_PLUGIN_DEPENDS
 
206
dnl
 
207
dnl SYNOPSIS
 
208
dnl   DRIZZLE_PLUGIN_DEPENDS([name],[prereq,prereq...])
 
209
dnl
 
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!
 
215
dnl
 
216
dnl ---------------------------------------------------------------------------
 
217
 
 
218
AC_DEFUN([DRIZZLE_PLUGIN_DEPENDS],[
 
219
 DRIZZLE_REQUIRE_PLUGIN([$1])
 
220
 ifelse($#, 2, [
 
221
  _DRIZZLE_PLUGIN_DEPEND([$1], $2)
 
222
 ], [
 
223
  AC_FATAL([bad number of arguments])
 
224
 ])
 
225
])
 
226
 
 
227
AC_DEFUN([_DRIZZLE_PLUGIN_DEPEND],[
 
228
 ifelse($#, 1, [], [$#:$2], [2:], [], [
 
229
  DRIZZLE_REQUIRE_PLUGIN([$2])
 
230
  _DRIZZLE_PLUGAPPEND([__mysql_plugdepends_$1__],[$2])
 
231
  _DRIZZLE_PLUGIN_DEPEND([$1], m4_shift(m4_shift($@)))
 
232
 ])
 
233
])
 
234
 
 
235
 
 
236
dnl ---------------------------------------------------------------------------
 
237
dnl Macro: DRIZZLE_PLUGIN_ACTIONS
 
238
dnl
 
239
dnl SYNOPSIS
 
240
dnl   DRIZZLE_PLUGIN_ACTIONS([name],[PLUGIN_CONFIGURE_STUFF])
 
241
dnl
 
242
dnl DESCRIPTION
 
243
dnl   Declares additional autoconf actions required to configure the plugin
 
244
dnl
 
245
dnl ---------------------------------------------------------------------------
 
246
 
 
247
AC_DEFUN([DRIZZLE_PLUGIN_ACTIONS],[
 
248
 DRIZZLE_REQUIRE_PLUGIN([$1])
 
249
 m4_ifdef([$2],[
 
250
   m4_define([DRIZZLE_PLUGIN_ACTIONS_]AS_TR_CPP([$1]),m4_defn([$2]))
 
251
 ],[
 
252
   m4_define([DRIZZLE_PLUGIN_ACTIONS_]AS_TR_CPP([$1]), [$2])
 
253
 ])
 
254
])
 
255
 
 
256
dnl ---------------------------------------------------------------------------
 
257
dnl Macro: DRIZZLE_PLUGIN_DEPENDS_ON_DRIZZLE_INTERNALS
 
258
dnl
 
259
dnl SYNOPSIS
 
260
dnl   DRIZZLE_PLUGIN_DEPENDS_ON_DRIZZLE_INTERNALS([name],[file name])
 
261
dnl
 
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)
 
271
dnl
 
272
dnl ---------------------------------------------------------------------------
 
273
 
 
274
AC_DEFUN([DRIZZLE_PLUGIN_DEPENDS_ON_DRIZZLE_INTERNALS],[
 
275
 DRIZZLE_REQUIRE_PLUGIN([$1])
 
276
 m4_define([DRIZZLE_PLUGIN_DEPENDS_ON_DRIZZLE_INTERNALS_]AS_TR_CPP([$1]), [$2])
 
277
])
 
278
 
 
279
dnl ---------------------------------------------------------------------------
 
280
dnl Macro: DRIZZLE_CONFIGURE_PLUGINS
 
281
dnl
 
282
dnl SYNOPSIS
 
283
dnl   DRIZZLE_PLUGIN_DEPENDS([name,name...])
 
284
dnl
 
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
 
288
dnl
 
289
dnl ---------------------------------------------------------------------------
 
290
 
 
291
AC_DEFUN([DRIZZLE_CONFIGURE_PLUGINS],[
 
292
 m4_ifdef([__mysql_plugin_configured__],[
 
293
   AC_FATAL([cannot use [DRIZZLE_CONFIGURE_PLUGINS] multiple times])
 
294
 ],[
 
295
   m4_define([__mysql_plugin_configured__],[done])
 
296
   _DRIZZLE_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
    _DRIZZLE_CHECK_PLUGIN_ARGS([$1])
 
302
    _DRIZZLE_CONFIGURE_PLUGINS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
 
303
    _DRIZZLE_EMIT_PLUGIN_ACTIONS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
 
304
    AC_SUBST([drizzle_plugin_files])
 
305
    AC_SUBST([mysql_se_dirs])
 
306
    AC_SUBST([mysql_pg_dirs])
 
307
    AC_SUBST([mysql_se_unittest_dirs])
 
308
    AC_SUBST([mysql_pg_unittest_dirs])
 
309
    AC_SUBST([condition_dependent_plugin_modules])
 
310
    AC_SUBST([condition_dependent_plugin_objects])
 
311
    AC_SUBST([condition_dependent_plugin_links])
 
312
    AC_SUBST([condition_dependent_plugin_includes])
 
313
   ])
 
314
 ])
 
315
])
 
316
 
 
317
AC_DEFUN([_DRIZZLE_CONFIGURE_PLUGINS],[
 
318
 ifelse($#, 0, [], $#, 1, [
 
319
  _DRIZZLE_EMIT_CHECK_PLUGIN([$1])
 
320
 ],[
 
321
  _DRIZZLE_EMIT_CHECK_PLUGIN([$1])
 
322
  _DRIZZLE_CONFIGURE_PLUGINS(m4_shift($@))
 
323
 ])
 
324
])
 
325
 
 
326
AC_DEFUN([_DRIZZLE_EMIT_CHECK_PLUGIN],[
 
327
 __DRIZZLE_EMIT_CHECK_PLUGIN(
 
328
  [$1],
 
329
  m4_bpatsubst([$1], -, _),
 
330
  [DRIZZLE_PLUGIN_NAME_]AS_TR_CPP([$1]),
 
331
  [DRIZZLE_PLUGIN_DESC_]AS_TR_CPP([$1]),
 
332
  [DRIZZLE_PLUGIN_DEFINE_]AS_TR_CPP([$1]),
 
333
  [DRIZZLE_PLUGIN_DIRECTORY_]AS_TR_CPP([$1]),
 
334
  [DRIZZLE_PLUGIN_STATIC_]AS_TR_CPP([$1]),
 
335
  [DRIZZLE_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]),
 
336
  [DRIZZLE_PLUGIN_MANDATORY_]AS_TR_CPP([$1]),
 
337
  [DRIZZLE_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
 
338
  [DRIZZLE_PLUGIN_DEPENDS_ON_DRIZZLE_INTERNALS_]AS_TR_CPP([$1]),
 
339
  [DRIZZLE_PLUGIN_ACTIONS_]AS_TR_CPP([$1])
 
340
 )
 
341
])
 
342
 
 
343
AC_DEFUN([__DRIZZLE_EMIT_CHECK_PLUGIN],[
 
344
 m4_ifdef([$5],[
 
345
  AH_TEMPLATE($5, [Include ]$4[ into mysqld])
 
346
 ])
 
347
 AC_MSG_CHECKING([whether to use ]$3)
 
348
 mysql_use_plugin_dir=""
 
349
 m4_ifdef([$10],[
 
350
  if test "X[$mysql_plugin_]$2" = Xyes -a \
 
351
          "X[$with_plugin_]$2" != Xno -o \
 
352
          "X[$with_plugin_]$2" = Xyes; then
 
353
    AC_MSG_RESULT([error])
 
354
    AC_MSG_ERROR([disabled])
 
355
  fi
 
356
  AC_MSG_RESULT([no])
 
357
 ],[
 
358
  m4_ifdef([$9],[
 
359
   if test "X[$with_plugin_]$2" = Xno; then
 
360
     AC_MSG_RESULT([error])
 
361
     AC_MSG_ERROR([cannot disable mandatory plugin])
 
362
   fi
 
363
   [mysql_plugin_]$2=yes
 
364
  ],[
 
365
   case "$with_mysqld_ldflags " in
 
366
     *"-all-static "*)
 
367
       # No need to build shared plugins when mysqld is linked with
 
368
       # -all-static as it won't be able to load them.
 
369
       if test "X[$mysql_plugin_]$2" != Xyes -a \
 
370
               "X[$with_plugin_]$2" != Xyes; then
 
371
             [with_plugin_]$2=no
 
372
           fi
 
373
     ;;
 
374
   esac
 
375
  ])
 
376
  if test "X[$with_plugin_]$2" = Xno; then
 
377
    AC_MSG_RESULT([no])
 
378
  else
 
379
    m4_ifdef([$8],m4_ifdef([$7],[],[[with_plugin_]$2='']))
 
380
    if test "X[$mysql_plugin_]$2" != Xyes -a \
 
381
            "X[$with_plugin_]$2" != Xyes; then
 
382
      m4_ifdef([$8],[
 
383
       m4_ifdef([$6],[
 
384
         if test -d "$srcdir/$6" ; then
 
385
           mysql_use_plugin_dir="$6"
 
386
       ])
 
387
       AC_SUBST([plugin_]$2[_shared_target], "$8")
 
388
       AC_SUBST([plugin_]$2[_static_target], [""])
 
389
       [with_plugin_]$2=yes
 
390
       AC_MSG_RESULT([plugin])
 
391
       m4_ifdef([$6],[
 
392
         else
 
393
           [mysql_plugin_]$2=no
 
394
           AC_MSG_RESULT([no])
 
395
         fi
 
396
       ])
 
397
      ],[
 
398
       [with_plugin_]$2=no
 
399
       AC_MSG_RESULT([no])
 
400
      ])
 
401
    else
 
402
      m4_ifdef([$7],[
 
403
       ifelse(m4_bregexp($7, [^lib[^.]+\.a$]), -2, [
 
404
dnl change above "-2" to "0" to enable this section
 
405
dnl Although this is "pretty", it breaks libmysqld build
 
406
        m4_ifdef([$6],[
 
407
         mysql_use_plugin_dir="$6"
 
408
         mysql_plugin_libs="$mysql_plugin_libs -L[\$(top_builddir)]/$6"
 
409
        ])
 
410
        mysql_plugin_libs="$mysql_plugin_libs dnl
 
411
[-l]m4_bregexp($7, [^lib\([^.]+\)], [\1])"
 
412
       ], m4_bregexp($7, [^\\\$]), 0, [
 
413
        m4_ifdef([$6],[
 
414
         mysql_use_plugin_dir="$6"
 
415
        ])
 
416
        mysql_plugin_libs="$mysql_plugin_libs $7"
 
417
       ], [
 
418
        m4_ifdef([$6],[
 
419
         mysql_use_plugin_dir="$6"
 
420
         mysql_plugin_libs="$mysql_plugin_libs \$(top_builddir)/$6/$7"
 
421
        ],[
 
422
         mysql_plugin_libs="$mysql_plugin_libs $7"
 
423
        ])
 
424
       ])
 
425
       m4_ifdef([$5],[
 
426
        AC_DEFINE($5)
 
427
       ])
 
428
       AC_SUBST([plugin_]$2[_static_target], "$7")
 
429
       AC_SUBST([plugin_]$2[_shared_target], [""])
 
430
      ],[
 
431
       m4_ifdef([$6],[
 
432
        AC_MSG_RESULT([error])
 
433
        AC_MSG_ERROR([Plugin $1 does not support static linking])
 
434
       ],[
 
435
        m4_ifdef([$5],[
 
436
         AC_DEFINE($5)
 
437
         AC_SUBST([plugin_]$2[_static_target], ["yes"])
 
438
         AC_SUBST([plugin_]$2[_shared_target], [""])
 
439
        ])
 
440
       ])
 
441
      ])
 
442
      mysql_plugin_defs="$mysql_plugin_defs, [builtin_]$2[_plugin]"
 
443
      [with_plugin_]$2=yes
 
444
      AC_MSG_RESULT([yes])
 
445
      m4_ifdef([$11],[
 
446
       condition_dependent_plugin_modules="$condition_dependent_plugin_modules m4_bregexp($11, [[^/]+$], [\&])"
 
447
       condition_dependent_plugin_objects="$condition_dependent_plugin_objects m4_bregexp($11, [[^/]+\.], [\&o])"
 
448
       condition_dependent_plugin_links="$condition_dependent_plugin_links $6/$11"
 
449
       condition_dependent_plugin_includes="$condition_dependent_plugin_includes -I[\$(top_srcdir)]/$6/m4_bregexp($11, [^.+[/$]], [\&])"
 
450
      ])
 
451
    fi
 
452
    m4_ifdef([$6],[
 
453
      if test -n "$mysql_use_plugin_dir" ; then
 
454
        mysql_plugin_dirs="$mysql_plugin_dirs $6"
 
455
        m4_syscmd(test -f "$6/configure")
 
456
        ifelse(m4_sysval, 0,
 
457
          [AC_CONFIG_SUBDIRS($6)],
 
458
          [AC_CONFIG_FILES($6/Makefile)]
 
459
        )
 
460
        ifelse(m4_substr($6, 0, 8), [storage/],
 
461
          [
 
462
            [mysql_se_dirs="$mysql_se_dirs ]m4_substr($6, 8)"
 
463
             mysql_se_unittest_dirs="$mysql_se_unittest_dirs ../$6"
 
464
          ],
 
465
          m4_substr($6, 0, 7), [plugin/],
 
466
          [
 
467
            [mysql_pg_dirs="$mysql_pg_dirs ]m4_substr($6, 7)"
 
468
             mysql_pg_unittest_dirs="$mysql_pg_unittest_dirs ../$6"
 
469
          ],
 
470
          [AC_FATAL([don't know how to handle plugin dir ]$6)])
 
471
      fi
 
472
    ])
 
473
  fi
 
474
 ])
 
475
])
 
476
 
 
477
AC_DEFUN([_DRIZZLE_EMIT_PLUGIN_ACTIONS],[
 
478
 ifelse($#, 0, [], $#, 1, [
 
479
  _DRIZZLE_EMIT_PLUGIN_ACTION([$1])
 
480
 ],[
 
481
  _DRIZZLE_EMIT_PLUGIN_ACTION([$1])
 
482
  _DRIZZLE_EMIT_PLUGIN_ACTIONS(m4_shift($@))
 
483
 ])
 
484
])
 
485
 
 
486
AC_DEFUN([_DRIZZLE_EMIT_PLUGIN_ACTION],[
 
487
 __DRIZZLE_EMIT_PLUGIN_ACTION(
 
488
  [$1],
 
489
  m4_bpatsubst([$1], -, _),
 
490
  [DRIZZLE_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
 
491
  [DRIZZLE_PLUGIN_ACTIONS_]AS_TR_CPP([$1])
 
492
 )
 
493
])
 
494
 
 
495
 
 
496
AC_DEFUN([__DRIZZLE_EMIT_PLUGIN_ACTION],[
 
497
 m4_ifdef([$3], [], [
 
498
  if test "X[$with_plugin_]$2" = Xyes; then
 
499
    if test "X[$plugin_]$2[_static_target]" = X -a \
 
500
            "X[$plugin_]$2[_shared_target]" = X; then
 
501
      AC_MSG_ERROR([that's strange, $1 failed sanity check])
 
502
    fi
 
503
    $4
 
504
  fi
 
505
 ])
 
506
])
 
507
 
 
508
 
 
509
 
 
510
dnl ===========================================================================
 
511
dnl  Private helper macros
 
512
dnl ===========================================================================
 
513
 
 
514
 
 
515
dnl SYNOPSIS
 
516
dnl   DRIZZLE_REQUIRE_PLUGIN([name])
 
517
dnl
 
518
dnl DESCRIPTION
 
519
dnl   Checks that the specified plugin does exist
 
520
 
 
521
AC_DEFUN([DRIZZLE_REQUIRE_PLUGIN],[
 
522
 _DRIZZLE_REQUIRE_PLUGIN([$1], [__DRIZZLE_PLUGIN_]AS_TR_CPP([$1])[__])
 
523
])
 
524
 
 
525
define([_DRIZZLE_REQUIRE_PLUGIN],[
 
526
 ifdef([$2],[
 
527
  ifelse($2, [$1], [], [
 
528
   AC_FATAL([Misspelt DRIZZLE_PLUGIN declaration for $1])
 
529
  ])
 
530
 ],[
 
531
  AC_FATAL([Missing DRIZZLE_PLUGIN declaration for $1])
 
532
 ])
 
533
])
 
534
 
 
535
 
 
536
dnl ---------------------------------------------------------------------------
 
537
 
 
538
 
 
539
dnl SYNOPSIS
 
540
dnl   _DRIZZLE_EMIT_METAPLUGINS([name,name...])
 
541
dnl
 
542
dnl DESCRIPTION
 
543
dnl   Emits shell code for metaplugins
 
544
 
 
545
AC_DEFUN([_DRIZZLE_EMIT_METAPLUGINS], [ifelse($#, 0, [], $#, 1,
 
546
[_DRIZZLE_EMIT_METAPLUGIN([$1], [__mysql_]m4_bpatsubst($1, -, _)[_plugins__])
 
547
],
 
548
[_DRIZZLE_EMIT_METAPLUGIN([$1], [__mysql_]m4_bpatsubst($1, -, _)[_plugins__])
 
549
_DRIZZLE_EMIT_METAPLUGINS(m4_shift($@))])
 
550
])
 
551
 
 
552
AC_DEFUN([_DRIZZLE_EMIT_METAPLUGIN], [
 
553
  [$1] )
 
554
m4_ifdef([$2], [
 
555
    mysql_plugins='m4_bpatsubst($2, :, [ ])'
 
556
],[
 
557
    mysql_plugins=''
 
558
])
 
559
    ;;
 
560
])
 
561
 
 
562
 
 
563
dnl ---------------------------------------------------------------------------
 
564
 
 
565
 
 
566
dnl SYNOPSIS
 
567
dnl   _DRIZZLE_PLUGAPPEND([name],[to-append])
 
568
dnl
 
569
dnl DESCRIPTION
 
570
dnl   Helper macro for appending to colon-delimited lists
 
571
dnl   Optinal 3rd argument is for actions only required when defining
 
572
dnl   macro named for the first time.
 
573
 
 
574
AC_DEFUN([_DRIZZLE_PLUGAPPEND],[
 
575
 m4_ifdef([$1],[
 
576
  m4_define([__plugin_append_tmp__], m4_defn([$1]))
 
577
  m4_undefine([$1])
 
578
  m4_define([$1], __plugin_append_tmp__[:$2])
 
579
  m4_undefine([__plugin_append_tmp__])
 
580
 ],[
 
581
  m4_define([$1], [$2])
 
582
  $3
 
583
 ])
 
584
])
 
585
 
 
586
 
 
587
dnl SYNOPSIS
 
588
dnl   _DRIZZLE_PLUGAPPEND_META([name],[meta,meta...])
 
589
dnl
 
590
dnl DESCRIPTION
 
591
dnl   Helper macro for adding plugins to meta plugins
 
592
 
 
593
AC_DEFUN([_DRIZZLE_PLUGAPPEND_META],[
 
594
 ifelse($#, 1, [], [$#:$2], [2:], [], [$2], [all], [
 
595
  AC_FATAL([protected plugin group: all])
 
596
 ], [$2], [none], [
 
597
  AC_FATAL([protected plugin group: none])
 
598
 ],[
 
599
  _DRIZZLE_PLUGAPPEND([__mysql_$1_configs__],[$2])
 
600
  _DRIZZLE_PLUGAPPEND([__mysql_]m4_bpatsubst($2, -, _)[_plugins__],[$1], [
 
601
   _DRIZZLE_PLUGAPPEND([__mysql_metaplugin_list__],[$2])
 
602
  ])
 
603
  _DRIZZLE_PLUGAPPEND_META([$1], m4_shift(m4_shift($@)))
 
604
 ])
 
605
])
 
606
 
 
607
 
 
608
dnl ---------------------------------------------------------------------------
 
609
 
 
610
 
 
611
dnl SYNOPSIS
 
612
dnl   DRIZZLE_LIST_PLUGINS
 
613
dnl
 
614
dnl DESCRIPTION
 
615
dnl   Emits formatted list of declared plugins
 
616
 
 
617
AC_DEFUN([DRIZZLE_LIST_PLUGINS],[dnl
 
618
 m4_ifdef([__mysql_plugin_list__],[dnl
 
619
  _DRIZZLE_LIST_PLUGINS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))dnl
 
620
 ])dnl
 
621
])
 
622
 
 
623
AC_DEFUN([_DRIZZLE_LIST_PLUGINS],[dnl
 
624
 ifelse($#, 0, [], $#, 1, [dnl
 
625
  DRIZZLE_SHOW_PLUGIN([$1])dnl
 
626
 ],[dnl
 
627
  DRIZZLE_SHOW_PLUGIN([$1])dnl
 
628
  _DRIZZLE_LIST_PLUGINS(m4_shift($@))dnl
 
629
 ])dnl
 
630
])
 
631
 
 
632
AC_DEFUN([DRIZZLE_SHOW_PLUGIN],[
 
633
 _DRIZZLE_SHOW_PLUGIN(
 
634
  [$1],
 
635
  [$1-plugin],
 
636
  [DRIZZLE_PLUGIN_NAME_]AS_TR_CPP([$1]),
 
637
  [DRIZZLE_PLUGIN_DESC_]AS_TR_CPP([$1]),
 
638
  [DRIZZLE_PLUGIN_DEFINE_]AS_TR_CPP([$1]),
 
639
  [DRIZZLE_PLUGIN_DIRECTORY_]AS_TR_CPP([$1]),
 
640
  [DRIZZLE_PLUGIN_STATIC_]AS_TR_CPP([$1]),
 
641
  [DRIZZLE_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]),
 
642
  [DRIZZLE_PLUGIN_MANDATORY_]AS_TR_CPP([$1]),
 
643
  [DRIZZLE_PLUGIN_DISABLED_]AS_TR_CPP([$1]),
 
644
  [DRIZZLE_PLUGIN_ACTIONS_]AS_TR_CPP([$1]),
 
645
  __mysql_[$1]_configs__,
 
646
 )
 
647
])
 
648
 
 
649
AC_DEFUN([_DRIZZLE_SHOW_PLUGIN],[dnl
 
650
  === $3 ===
 
651
  Plugin Name:      [$1]
 
652
  Description:      $4
 
653
  Supports build:   _PLUGIN_BUILD_TYPE([$7],[$8])[]dnl
 
654
m4_ifdef([$12],[
 
655
  Configurations:   m4_bpatsubst($12, :, [, ])])[]dnl
 
656
m4_ifdef([$10],[
 
657
  Status:           disabled])[]dnl
 
658
m4_ifdef([$9],[
 
659
  Status:           mandatory])[]dnl
 
660
])
 
661
 
 
662
AC_DEFUN([_PLUGIN_BUILD_TYPE],
 
663
[m4_ifdef([$1],[static ]m4_ifdef([$2],[and dnl
 
664
]))[]m4_ifdef([$2],[dynamic],[m4_ifdef([$1],[],[static])])])
 
665
 
 
666
 
 
667
dnl ---------------------------------------------------------------------------
 
668
 
 
669
 
 
670
AC_DEFUN([_DRIZZLE_EMIT_PLUGINS],[
 
671
 ifelse($#, 0, [], [$#:$1], [1:], [], [
 
672
  m4_ifdef([DRIZZLE_PLUGIN_ACTIONS_]AS_TR_CPP([$1]), [], [
 
673
   m4_define([DRIZZLE_PLUGIN_ACTIONS_]AS_TR_CPP([$1]),[ ])
 
674
  ])
 
675
    [$1] )
 
676
  m4_ifdef([DRIZZLE_PLUGIN_DISABLED_]AS_TR_CPP([$1]),[
 
677
      AC_MSG_ERROR([plugin $1 is disabled])
 
678
  ],[
 
679
    _DRIZZLE_EMIT_PLUGIN_ENABLE([$1], m4_bpatsubst([$1], -, _),
 
680
      [DRIZZLE_PLUGIN_NAME_]AS_TR_CPP([$1]),
 
681
      [DRIZZLE_PLUGIN_STATIC_]AS_TR_CPP([$1]),
 
682
      [DRIZZLE_PLUGIN_DYNAMIC_]AS_TR_CPP([$1]))
 
683
  ])
 
684
      ;;
 
685
  _DRIZZLE_EMIT_PLUGINS(m4_shift($@))
 
686
 ])
 
687
])
 
688
 
 
689
AC_DEFUN([_DRIZZLE_EMIT_PLUGIN_ENABLE],[
 
690
    m4_ifdef([$5],m4_ifdef([$4],[
 
691
      [mysql_plugin_]$2=yes
 
692
    ],[
 
693
      AC_MSG_WARN([$3 can only be built as a plugin])
 
694
    ]),[
 
695
      [mysql_plugin_]$2=yes
 
696
    ])      
 
697
])
 
698
 
 
699
AC_DEFUN([_DRIZZLE_EMIT_PLUGIN_DEPENDS], [
 
700
 ifelse($#, 0, [], [$#:$1], [1:], [], [
 
701
  _DRIZZLE_EMIT_CHECK_DEPENDS(m4_bpatsubst([$1], -, _), 
 
702
                            [__mysql_plugdepends_$1__])
 
703
  _DRIZZLE_EMIT_PLUGIN_DEPENDS(m4_shift($@))
 
704
 ])
 
705
])
 
706
 
 
707
AC_DEFUN([_DRIZZLE_EMIT_CHECK_DEPENDS], [
 
708
 m4_ifdef([$2], [
 
709
   if test "X[$mysql_plugin_]$1" = Xyes -a \
 
710
           "X[$with_plugin_]$1" != Xno -o \
 
711
           "X[$with_plugin_]$1" = Xyes; then
 
712
     _DRIZZLE_EMIT_PLUGIN_DEPENDENCIES(m4_bpatsubst($2, :, [,]))
 
713
   fi
 
714
 ])
 
715
])
 
716
 
 
717
AC_DEFUN([_DRIZZLE_EMIT_PLUGIN_DEPENDENCIES], [
 
718
 ifelse([$1], [], [], [
 
719
  m4_ifdef([DRIZZLE_PLUGIN_DISABLED_]AS_TR_CPP([$1]),[
 
720
       AC_MSG_ERROR([depends upon disabled plugin $1])
 
721
  ],[
 
722
       [mysql_plugin_]m4_bpatsubst([$1], -, _)=yes
 
723
       if test "X[$with_plugin_]m4_bpatsubst([$1], -, _)" = Xno; then
 
724
         AC_MSG_ERROR([depends upon disabled plugin $1])
 
725
       fi
 
726
  ])
 
727
  _DRIZZLE_EMIT_PLUGIN_DEPENDENCIES(m4_shift($@))
 
728
 ])
 
729
])
 
730
 
 
731
dnl SYNOPSIS
 
732
dnl   _DRIZZLE_CHECK_PLUGIN_ARGS([plugin],[plugin]...)
 
733
dnl
 
734
dnl DESCRIPTION
 
735
dnl   Emits shell script for checking configure arguments
 
736
dnl   Arguments to this macro is default value for selected plugins
 
737
 
 
738
AC_DEFUN([_DRIZZLE_CHECK_PLUGIN_ARGS],[
 
739
 __DRIZZLE_CHECK_PLUGIN_ARGS(m4_default([$1], [none]))
 
740
])
 
741
 
 
742
AC_DEFUN([__DRIZZLE_CHECK_PLUGIN_ARGS],[
 
743
 AC_ARG_WITH([plugins],
 
744
AS_HELP_STRING([--with-plugins=PLUGIN[[[[[,PLUGIN..]]]]]],
 
745
               [Plugins to include in mysqld. (default is: $1) Must be a
 
746
                configuration name or a comma separated list of plugins.])
 
747
AS_HELP_STRING([],
 
748
               [Available configurations are:] dnl
 
749
m4_bpatsubst([none:]m4_ifdef([__mysql_metaplugin_list__],
 
750
             __mysql_metaplugin_list__:)[all], :, [ ])[.])
 
751
AS_HELP_STRING([],
 
752
               [Available plugins are:] dnl
 
753
m4_bpatsubst(__mysql_plugin_list__, :, [ ])[.])
 
754
AS_HELP_STRING([--without-plugin-PLUGIN],
 
755
               [Disable the named plugin from being built. Otherwise, for
 
756
                plugins which are not selected for inclusion in mysqld will be
 
757
                built dynamically (if supported)])
 
758
AS_HELP_STRING([--with-plugin-PLUGIN],
 
759
               [Forces the named plugin to be linked into mysqld statically.]),
 
760
 [mysql_plugins="`echo $withval | tr ',.:;*[]' '       '`"],
 
761
 [mysql_plugins=['$1']])
 
762
 
 
763
m4_divert_once([HELP_VAR_END],[
 
764
Description of plugins:
 
765
DRIZZLE_LIST_PLUGINS])
 
766
 
 
767
  case "$mysql_plugins" in
 
768
  all )
 
769
    mysql_plugins='m4_bpatsubst(__mysql_plugin_list__, :, [ ])'
 
770
    ;;
 
771
  none )
 
772
    mysql_plugins=''
 
773
    ;;
 
774
m4_ifdef([__mysql_metaplugin_list__],[
 
775
_DRIZZLE_EMIT_METAPLUGINS(m4_bpatsubst(__mysql_metaplugin_list__, :, [,]))
 
776
])
 
777
  esac
 
778
 
 
779
  for plugin in $mysql_plugins; do
 
780
    case "$plugin" in
 
781
    all | none )
 
782
      AC_MSG_ERROR([bad plugin name: $plugin])
 
783
      ;;
 
784
_DRIZZLE_EMIT_PLUGINS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
 
785
    * )
 
786
      AC_MSG_ERROR([unknown plugin: $plugin])
 
787
      ;;
 
788
    esac
 
789
  done
 
790
 
 
791
  _DRIZZLE_EMIT_PLUGIN_DEPENDS(m4_bpatsubst(__mysql_plugin_list__, :, [,]))
 
792
])
 
793
 
 
794
dnl ---------------------------------------------------------------------------
 
795
dnl Macro: _DRIZZLE_INCLUDE_LIST
 
796
dnl
 
797
dnl SYNOPSIS
 
798
dnl   _DRIZZLE_INCLUDE_LIST([filename,filename...])
 
799
dnl
 
800
dnl DESCRIPTION
 
801
dnl   includes all files from the list
 
802
dnl
 
803
dnl ---------------------------------------------------------------------------
 
804
AC_DEFUN([_DRIZZLE_INCLUDE_LIST],[
 
805
 ifelse([$1], [], [], [
 
806
  m4_define([__mysql_include__],[$1])
 
807
  sinclude($1)
 
808
  m4_undefine([__mysql_include__])
 
809
  _DRIZZLE_INCLUDE_LIST(m4_shift($@))
 
810
  drizzle_plugin_files="\${top_srcdir}/$1 ${drizzle_plugin_files}"
 
811
 ])
 
812
])
 
813
 
 
814
dnl ===========================================================================