~drizzle-trunk/drizzle/development

992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
1
#!/usr/bin/python
2
992.1.25 by Monty Taylor
Moved myisam to new plugin system.
3
#  Copyright (C) 2009 Sun Microsystems
4
#
5
#  This program is free software; you can redistribute it and/or modify
6
#  it under the terms of the GNU General Public License as published by
7
#  the Free Software Foundation; version 2 of the License.
8
#
9
#  This program is distributed in the hope that it will be useful,
10
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
#  GNU General Public License for more details.
13
#
14
#  You should have received a copy of the GNU General Public License
15
#  along with this program; if not, write to the Free Software
16
#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
18
pandora_plugin_file = 'config/pandora-plugin.ini'
992.1.25 by Monty Taylor
Moved myisam to new plugin system.
19
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
20
# Find plugins in the tree and add them to the build system
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
21
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
22
import ConfigParser, os, sys
1241.10.1 by Monty Taylor
Added ability to specify all of the meta information in the plugin.ini file. This allows us to have a streamlined out-of-tree build.
23
import datetime, time
1377.3.6 by Monty Taylor
Set the default plugin version for plugins not specifying a version to be
24
import subprocess
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
25
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
26
plugin_am_file=None
27
plugin_ac_file=None
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
28
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
29
class ChangeProtectedFile(object):
30
31
  def __init__(self, fname):
1192.3.11 by Monty Taylor
Fixed a few distcheck issues.
32
    self.bogus_file= False
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
33
    self.real_fname= fname
34
    self.new_fname= "%s.new" % fname
1192.3.11 by Monty Taylor
Fixed a few distcheck issues.
35
    try:
36
      self.new_file= open(self.new_fname,'w+')
37
    except IOError:
38
      self.bogus_file= True
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
39
40
  def write(self, text):
1192.3.11 by Monty Taylor
Fixed a few distcheck issues.
41
    if not self.bogus_file:
42
      self.new_file.write(text)
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
43
44
  # We've written all of this out into .new files, now we only copy them
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
45
  # over the old ones if they are different, so that we don't cause
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
46
  # unnecessary recompiles
47
  def close(self):
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
48
    """Return True if the file had changed."""
1192.3.11 by Monty Taylor
Fixed a few distcheck issues.
49
    if self.bogus_file:
50
      return
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
51
    self.new_file.seek(0)
52
    new_content = self.new_file.read()
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
53
    self.new_file.close()
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
54
    try:
55
        old_file = file(self.real_fname, 'r')
56
        old_content = old_file.read()
57
        old_file.close()
58
    except IOError:
59
        old_content = None
60
    if new_content != old_content:
61
      if old_content != None:
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
62
        os.unlink(self.real_fname)
63
      os.rename(self.new_fname, self.real_fname)
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
64
      return True
65
    else:
66
        try:
67
          os.unlink(self.new_fname)
68
        except:
69
          pass
70
71
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
72
def write_external_configure(plugin, plugin_file):
73
  """Write the initial bits of the configure.ac file"""
74
  if not os.path.exists('m4'):
75
    os.mkdir('m4')
76
  plugin_file.write("""
77
AC_PREREQ(2.59)dnl		Minimum Autoconf version required.
78
AC_INIT([%(name)s],[%(version)s],[%(url)s])
79
AC_CONFIG_SRCDIR([%(main_source)s])
80
AC_CONFIG_AUX_DIR(config)
81
1241.9.5 by Monty Taylor
Fixed the plugin script to not bork plugin visibility.
82
PANDORA_CANONICAL_TARGET(less-warnings, warnings-always-on, require-cxx, force-gcc42,skip-visibility)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
83
84
PANDORA_REQUIRE_LIBPROTOBUF
85
PANDORA_PROTOBUF_REQUIRE_VERSION([2.1.0])
86
PANDORA_REQUIRE_PROTOC
87
88
AC_LANG_PUSH(C++)
89
PANDORA_REQUIRE_PTHREAD
90
PANDORA_REQUIRE_LIBDL
91
AC_LANG_POP
92
93
PANDORA_USE_BETTER_MALLOC
94
95
PANDORA_DRIZZLE_BUILD
96
""" % plugin)
97
98
  write_plugin_ac(plugin, plugin_file)
99
100
  plugin_file.write("""
101
AC_CONFIG_FILES(Makefile)
102
103
AC_OUTPUT
104
105
echo "---"
106
echo "Configuration summary for $PACKAGE_NAME version $VERSION $PANDORA_RELEASE_COMMENT"
107
echo ""
108
echo "   * Installation prefix:       $prefix"
109
echo "   * System type:               $host_vendor-$host_os"
110
echo "   * Host CPU:                  $host_cpu"
111
echo "   * C Compiler:                $CC_VERSION"
112
echo "   * C++ Compiler:              $CXX_VERSION"
113
echo "   * Debug enabled:             $with_debug"
114
echo "   * Warnings as failure:       $ac_cv_warnings_as_errors"
115
echo "   * C++ cstdint location:      $ac_cv_cxx_cstdint"
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
116
echo "   * C++ hash_map location:     $ac_cv_cxx_hash_map"
117
echo "   * C++ hash namespace:        $ac_cv_cxx_hash_namespace"
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
118
echo "   * C++ shared_ptr namespace:  $ac_cv_shared_ptr_namespace"
119
echo ""
120
echo "---"
121
122
  """ % plugin)
123
124
def write_external_makefile(plugin, plugin_file):
125
126
  plugin_file.write("""
127
ACLOCAL_AMFLAGS = -I m4 --force
128
VERSION=$(PANDORA_RELEASE_VERSION)
129
1273.23.1 by Monty Taylor
Merged in latest pandora-build changes. Install plugins in pkglibdir now
130
pkgplugindir=%(pkgplugindir)s
1241.9.3 by Monty Taylor
Fixed the out-of-tree plugin file generation.
131
EXTRA_DIST = plugin.ini
1192.3.53 by Robert Collins
Build fixes from Robert.
132
133
""" % plugin)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
134
  if plugin['headers'] != "":
135
    plugin_file.write("noinst_HEADERS = %(headers)s\n" % plugin)
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
136
  if plugin['install_headers'] != "":
137
    plugin_file.write("nobase_include_HEADERS += %(install_headers)s\n" % plugin)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
138
  if plugin['testsuite']:
139
    if plugin.has_key('testsuitedir') and plugin['testsuitedir'] != "":
1241.9.3 by Monty Taylor
Fixed the out-of-tree plugin file generation.
140
      plugin_file.write("EXTRA_DIST += %(testsuitedir)s\n" % plugin)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
141
  plugin_file.write("""
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
142
pkgplugin_LTLIBRARIES=%(libname)s.la
143
%(libname)s_la_LDFLAGS=-avoid-version -rpath $(pkgplugindir) $(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS)
144
%(libname)s_la_LIBADD=%(libs)s
145
%(libname)s_la_DEPENDENCIES=%(libs)s
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
146
%(libname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN -DPANDORA_MODULE_NAME=%(module_name)s -DPANDORA_MODULE_AUTHOR='"%(author)s"' -DPANDORA_MODULE_TITLE='"%(title)s"' -DPANDORA_MODULE_VERSION='"%(version)s"' -DPANDORA_MODULE_LICENSE=%(license)s %(cppflags)s
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
147
%(libname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s
148
%(libname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
149
%(libname)s_la_SOURCES=%(sources)s
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
150
check_PROGRAMS += %(tests)s
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
151
""" % plugin)
152
  plugin_am_file=os.path.join(plugin['rel_path'],'plugin.am')
153
  if os.path.exists(plugin_am_file):
154
    plugin_file.write('include %s\n' % plugin_am_file)
155
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
156
def write_external_plugin():
157
  """Return True if the plugin had changed."""
158
  plugin = read_plugin_ini('.')
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
159
  expand_plugin_ini(plugin)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
160
  plugin_file = ChangeProtectedFile('configure.ac')
161
  write_external_configure(plugin, plugin_file)
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
162
  result = plugin_file.close()
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
163
  plugin_file = ChangeProtectedFile('Makefile.am')
164
  write_external_makefile(plugin, plugin_file)
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
165
  # Write some stub configure.ac and Makefile.am files that include the above
166
  result = plugin_file.close() or result
167
  return result
168
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
169
def write_plugin(plugin, plugin_ini_list):
170
  # Since this function is recursive, make sure we're not already in it.
171
  if plugin.has_key('writing_status'):
172
    if plugin['writing_status'] == 'done':
173
      return
174
    else:
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
175
      print "Dependency loop detected with %s" % plugin['name']
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
176
      exit(1)
177
178
  plugin['writing_status'] = 'dependencies'
179
180
  # Write all dependencies first to get around annoying automake bug
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
181
  for dependency in plugin['dependency_list']:
182
    found = False
183
    for find_plugin in plugin_ini_list:
184
      if find_plugin['module_name'] == dependency:
185
        found = True
186
        write_plugin(find_plugin, plugin_ini_list)
187
        break
188
    if found is False:
189
      print "Could not find dependency %s: %s" % (plugin['name'], dependency)
190
      exit(1)
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
191
1192.3.25 by Monty Taylor
It seems to work.
192
  write_plugin_ac(plugin, plugin_ac_file)
193
  write_plugin_am(plugin, plugin_am_file)
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
194
  plugin['writing_status'] = 'done'
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
195
196
def write_plugin_ac(plugin, plugin_ac):
197
  #
198
  # Write plugin config instructions into plugin.ac file.
199
  #
992.1.23 by Monty Taylor
New system now runs in parallel to old system.
200
  plugin_ac_file=os.path.join(plugin['rel_path'],'plugin.ac')
201
  plugin_m4_dir=os.path.join(plugin['rel_path'],'m4')
202
  plugin_m4_files=[]
203
  if os.path.exists(plugin_m4_dir) and os.path.isdir(plugin_m4_dir):
204
    for m4_file in os.listdir(plugin_m4_dir):
205
      if os.path.splitext(m4_file)[-1] == '.m4':
206
        plugin_m4_files.append(os.path.join(plugin['rel_path'], m4_file))
1192.3.25 by Monty Taylor
It seems to work.
207
  plugin_ac.write("""
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
208
dnl Config for %(title)s
992.1.23 by Monty Taylor
New system now runs in parallel to old system.
209
""" % plugin)
210
  for m4_file in plugin_m4_files:
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
211
    plugin_ac.write('m4_sinclude([%s])\n' % m4_file)
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
212
  plugin['plugin_dep_libs']=" ".join(["\${top_builddir}/%s" % f for f in plugin['libs'].split()])
213
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
214
  plugin_ac.write("""
1022.2.4 by Monty Taylor
Fixed turning off plugins.
215
AC_ARG_WITH([%(name_with_dashes)s-plugin],[
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
216
dnl indented wierd to make the help output correct
1273.12.6 by Monty Taylor
Added support for disabling plugins
217
AS_HELP_STRING([--with-%(name_with_dashes)s-plugin],[Build %(title)s. @<:@default=%(enabled)s@:>@])
1022.2.4 by Monty Taylor
Fixed turning off plugins.
218
AS_HELP_STRING([--without-%(name_with_dashes)s-plugin],[Disable building %(title)s])
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
219
  ],[
220
    with_%(name)s_plugin="$withval"
1273.23.6 by Monty Taylor
Need to be able to actually disable plugins in the build.
221
    AS_IF([test "x$with_%(name)s_plugin" = "xyes"],[
222
      requested_%(name)s_plugin="yes"
223
    ],[
224
      requested_%(name)s_plugin="no"
225
    ])
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
226
  ],[
1273.12.6 by Monty Taylor
Added support for disabling plugins
227
    with_%(name)s_plugin="%(enabled)s"
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
228
    requested_%(name)s_plugin="no"
229
  ])
230
AC_ARG_ENABLE([%(name_with_dashes)s-plugin],[
231
dnl indented wierd to make the help output correct
232
AS_HELP_STRING([--enable-%(name_with_dashes)s-plugin],[Build %(title)s. @<:@default=%(default_yesno)s@:>@])
233
AS_HELP_STRING([--disable-%(name_with_dashes)s-plugin],[Disable building %(title)s])
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
234
  ],
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
235
  [enable_%(name)s_plugin="$enableval"],
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
236
  [enable_%(name)s_plugin=%(default_yesno)s])
237
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
238
""" % plugin)
239
  if os.path.exists(plugin_ac_file):
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
240
    plugin_ac.write('m4_sinclude([%s])\n' % plugin_ac_file)
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
241
  # The plugin author has specified some check to make to determine
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
242
  # if the plugin can be built. If the plugin is turned on and this
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
243
  # check fails, then configure should error out. If the plugin is not
244
  # turned on, then the normal conditional build stuff should just let
245
  # it silently not build
246
  if plugin['has_build_conditional']:
247
    plugin_ac.write("""
997.2.5 by Monty Taylor
Merged up with trunk properly.
248
AS_IF([test %(build_conditional)s],
1166.1.1 by Monty Taylor
Fixed an accidental logic error that caused any plugin which was availble to be built to be automatically enabled/builtin.
249
      [], dnl build_conditional can only negate
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
250
      [
251
        AS_IF([test "x${requested_%(name)s_plugin}" = "xyes"],
252
              [AC_MSG_ERROR([Plugin %(name)s was explicitly requested, yet failed build dependency checks. Aborting!])])
253
        with_%(name)s_plugin=no
254
      ])
1192.3.53 by Robert Collins
Build fixes from Robert.
255
256
""" % plugin)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
257
  if not plugin['unconditional']:
258
    plugin_ac.write("""
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
259
AM_CONDITIONAL([%(build_conditional_tag)s],
260
               [test %(build_conditional)s])
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
261
    """ % plugin)
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
262
263
  plugin_ac.write("""
992.1.21 by Monty Taylor
First pass at replacing plugin.m4.
264
AS_IF([test "x$with_%(name)s_plugin" = "xyes"],
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
265
    [
1192.3.53 by Robert Collins
Build fixes from Robert.
266
""" % plugin)
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
267
  if plugin['testsuite']:
268
    plugin_ac.write("""
269
      pandora_plugin_test_list="%(name)s,${pandora_plugin_test_list}"
270
    """ % plugin)
271
  if plugin['static']:
272
    plugin_ac.write("""
273
        AS_IF([test "x$enable_%(name)s_plugin" = "xyes"],[
1530.2.3 by Monty Taylor
Changed the builtin plugin code path to work exactly the same as dynamic.
274
          pandora_builtin_list="%(module_name)s,${pandora_builtin_list}"
275
          pandora_builtin_symbols_list="_drizzled_%(module_name)s_plugin_,${pandora_builtin_symbols_list}"
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
276
          pandora_plugin_libs="${pandora_plugin_libs} \${top_builddir}/%(root_plugin_dir)s/%(libname)s.la"
277
          PANDORA_PLUGIN_DEP_LIBS="${PANDORA_PLUGIN_DEP_LIBS} %(plugin_dep_libs)s"
278
        ])
279
    """ % plugin)
1099.1.16 by Monty Taylor
Added support for conditionally building plugin's test suite if the plugin is built.
280
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
281
  else:
1259.7.5 by Monty Taylor
Removed the apparent ability to disable builtin plugins. We don't actually support it
282
    plugin_ac.write("""
283
        AS_IF([test "x$enable_%(name)s_plugin" = "xyes"],[
284
          pandora_default_plugin_list="%(name)s,${pandora_default_plugin_list}"
285
        ])
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
286
    """ % plugin)
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
287
  plugin_ac.write("      ])\n")
1093.9.13 by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build
288
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
289
def fix_file_paths(plugin, files):
290
  # TODO: determine path to plugin dir relative to top_srcdir... append it to
291
  # source files if they don't already have it
292
  new_files=""
293
  if plugin['plugin_dir'] != ".":
294
    for file in files.split():
295
      if not file.startswith(plugin['rel_path']):
296
        file= os.path.join(plugin['rel_path'], file)
297
        new_files= "%s %s" % (new_files, file)
298
  else:
299
    new_files= " ".join(plugin['sources'].split())
300
  if new_files != "":
301
    return new_files
302
  return files
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
303
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
304
def expand_plugin_ini(plugin):
1273.23.15 by Monty Taylor
Put in error check for out of tree plugin builds.
305
    if plugin['name'] == "**OUT-OF-TREE**":
306
      print "Out of tree plugins require the name field to be specified in plugin.ini"
307
      sys.exit(1)
308
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
309
    if plugin['plugin_dir'] == ".":
310
      plugin['rel_path']= plugin['plugin_dir']
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
311
      plugin['unconditional']=True
312
    else:
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
313
      plugin['rel_path']= plugin['plugin_dir'][len(config['top_srcdir'])+len(os.path.sep):]
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
314
      plugin['unconditional']=False
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
315
316
    plugin['sources']= fix_file_paths(plugin, plugin['sources'])
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
317
    plugin['main_source']= plugin['sources'].split()[0]
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
318
    plugin['headers']= fix_file_paths(plugin, plugin['headers'])
319
    plugin['install_headers']= fix_file_paths(plugin, plugin['install_headers'])
320
    plugin['tests']= fix_file_paths(plugin, plugin['tests'])
321
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
322
    # Make a yes/no version for autoconf help messages
1497.3.18 by Monty Taylor
Enables the disabling of a static plugin at compile time. Incidentally,
323
    if plugin['load_by_default'] or plugin['static']:
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
324
      plugin['default_yesno']="yes"
325
    else:
326
      plugin['default_yesno']="no"
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
327
1716.1.1 by Monty Taylor
Added files to the tarball that should be there. Removed some that shouldn't
328
    if plugin.has_key('extra_dist'):
329
      plugin['extra_dist']=" ".join([os.path.join(plugin['rel_path'],f) for f in plugin['extra_dist'].split()])
330
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
331
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
332
    plugin['build_conditional_tag']= "BUILD_%s_PLUGIN" % plugin['name'].upper()
333
    plugin['name_with_dashes']= plugin['name'].replace('_','-')
334
    if plugin.has_key('build_conditional'):
335
      plugin['has_build_conditional']=True
1273.12.6 by Monty Taylor
Added support for disabling plugins
336
      plugin['build_conditional']='"x${with_%(name)s_plugin}" = "xyes" -a %(build_conditional)s' % plugin
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
337
    else:
338
      plugin['has_build_conditional']=False
339
      plugin['build_conditional']='"x${with_%(name)s_plugin}" = "xyes"' %plugin
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
340
1273.23.9 by Monty Taylor
Merged in noinst fix for plugins.
341
    if plugin['install']:
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
342
      plugin['library_type']= 'pkgplugin'
1273.23.9 by Monty Taylor
Merged in noinst fix for plugins.
343
    else:
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
344
      plugin['library_type']= 'noinst'
1273.23.9 by Monty Taylor
Merged in noinst fix for plugins.
345
1192.3.20 by Monty Taylor
Added the testsuite location finding code to support in-plugin-dir test suites.
346
def find_testsuite(plugin_dir):
347
  for testdir in ['drizzle-tests','tests']:
348
    if os.path.isdir(os.path.join(plugin_dir,testdir)):
349
      return testdir
350
  if os.path.isdir(os.path.join('tests','suite',os.path.basename(plugin_dir))):
351
    return ""
352
  return None
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
353
354
def read_plugin_ini(plugin_dir):
1273.23.15 by Monty Taylor
Put in error check for out of tree plugin builds.
355
    if plugin_dir == ".":
356
      plugin_name="**OUT-OF-TREE**"
357
    else:
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
358
      short_name=os.path.basename(plugin_dir)
359
      plugin_name = plugin_dir[plugin_dir.index(config['root_plugin_dir']) + len(config['root_plugin_dir']) + 1:]
360
      module_name = plugin_name.replace("/", config['module_name_separator']).replace("\\", config['module_name_separator'])
361
      plugin_name = plugin_name.replace("/", config['plugin_name_separator']).replace("\\", config['plugin_name_separator'])
362
363
364
    plugin_file= os.path.join(plugin_dir,config['plugin_ini_fname'])
365
    plugin_defaults= dict(sources="%s.cc" % short_name,
1241.10.1 by Monty Taylor
Added ability to specify all of the meta information in the plugin.ini file. This allows us to have a streamlined out-of-tree build.
366
                          headers="",
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
367
                          install_headers="",
1241.10.1 by Monty Taylor
Added ability to specify all of the meta information in the plugin.ini file. This allows us to have a streamlined out-of-tree build.
368
                          cflags="",
369
                          cppflags="",
370
                          cxxflags="",
371
                          libs="",
372
                          ldflags="",
373
                          author="",
374
                          title="",
375
                          description="",
376
                          license="PLUGIN_LICENSE_GPL",
1273.23.15 by Monty Taylor
Put in error check for out of tree plugin builds.
377
                          name=plugin_name,
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
378
                          module_name=module_name,
379
                          load_by_default=config['default_load_by_default'],
1273.12.6 by Monty Taylor
Added support for disabling plugins
380
                          disabled="False",
1273.23.9 by Monty Taylor
Merged in noinst fix for plugins.
381
                          static="False",
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
382
                          dependencies="",
383
                          dependency_aliases="",
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
384
                          tests="",
385
                          install=config['default_install'])
1241.10.1 by Monty Taylor
Added ability to specify all of the meta information in the plugin.ini file. This allows us to have a streamlined out-of-tree build.
386
    parser=ConfigParser.ConfigParser(defaults= plugin_defaults)
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
387
    parser.read(plugin_file)
388
    plugin=dict(parser.items('plugin'))
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
389
    plugin['plugin_dir'] = plugin_dir
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
390
    if plugin_dir == '.':
391
      if not plugin.has_key('url'):
392
        print "External Plugins are required to specifiy a url"
393
        plugin['url']= 'http://launchpad.net/%(name)s' % plugin
394
        sys.exit(1)
395
      if plugin_dir == '.' and not plugin.has_key('version'):
396
        print "External Plugins are required to specifiy a version"
397
        sys.exit(1)
1241.10.1 by Monty Taylor
Added ability to specify all of the meta information in the plugin.ini file. This allows us to have a streamlined out-of-tree build.
398
    if not plugin.has_key('version'):
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
399
      plugin['version'] = config['default_plugin_version']
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
400
    if plugin.has_key('load_by_default'):
401
      plugin['load_by_default']=parser.getboolean('plugin','load_by_default')
1273.12.6 by Monty Taylor
Added support for disabling plugins
402
    if plugin.has_key('disabled'):
403
      plugin['disabled']=parser.getboolean('plugin','disabled')
404
    if plugin['disabled']:
405
      plugin['enabled']="no"
406
    else:
407
      plugin['enabled']="yes"
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
408
    if plugin.has_key('static'):
409
      plugin['static']= parser.getboolean('plugin','static')
1273.23.9 by Monty Taylor
Merged in noinst fix for plugins.
410
    if plugin.has_key('install'):
411
      plugin['install']= parser.getboolean('plugin','install')
1192.3.20 by Monty Taylor
Added the testsuite location finding code to support in-plugin-dir test suites.
412
    if plugin.has_key('testsuite'):
413
      if plugin['testsuite'] == 'disable':
414
        plugin['testsuite']= False
1716.1.1 by Monty Taylor
Added files to the tarball that should be there. Removed some that shouldn't
415
        plugin['dist_testsuite']= find_testsuite(plugin_dir)
1192.3.20 by Monty Taylor
Added the testsuite location finding code to support in-plugin-dir test suites.
416
    else:
417
      plugin_testsuite= find_testsuite(plugin_dir)
418
      plugin['testsuitedir']=plugin_testsuite
419
      if plugin_testsuite is not None:
420
        plugin['testsuite']=True
421
      else:
422
        plugin['testsuite']=False
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
423
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
424
    plugin['cflags']+= ' ' + config['extra_cflags']
425
    plugin['cppflags']+= ' ' + config['extra_cppflags']
426
    plugin['cxxflags']+= ' ' + config['extra_cxxflags']
1273.23.1 by Monty Taylor
Merged in latest pandora-build changes. Install plugins in pkglibdir now
427
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
428
    plugin['libname']= "lib%s%s%s" % (config['plugin_prefix'],
429
                                      plugin['name'],
430
                                      config['plugin_suffix'])
431
    if config['force_lowercase_libname']:
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
432
      plugin['libname']= plugin['libname'].lower()
433
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
434
    plugin['root_plugin_dir']= config['root_plugin_dir']
435
    plugin['plugin_prefix']= config['plugin_prefix']
436
    plugin['plugin_suffix']= config['plugin_suffix']
437
    plugin['pkgplugindir']= config['pkgplugindir']
1273.23.1 by Monty Taylor
Merged in latest pandora-build changes. Install plugins in pkglibdir now
438
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
439
    # Dependencies must have a module but dependency aliases are simply added
440
    # to the variable passed during compile.
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
441
    plugin['dependency_list'] = plugin['dependencies'].split()
442
    dependency_aliases = plugin['dependency_aliases'].split()
443
    plugin['dependencies'] = ','.join(plugin['dependency_list'] +
444
                                      plugin['dependency_aliases'].split())
445
    dependency_libs = ["%s/lib%s%s.la" % (config['root_plugin_dir'],
446
                                          dependency.lower().replace('::', '_'),
447
                                          config['plugin_suffix'])
448
                       for dependency in plugin['dependency_list']]
449
    plugin['libs'] = " ".join(plugin['libs'].split() + dependency_libs);
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
450
451
# Libtool is going to expand:
452
#      -DPANDORA_MODULE_AUTHOR='"Padraig O'"'"'Sullivan"'
453
# to:
454
# "-DPANDORA_MODULE_AUTHOR=\"Padraig O'Sullivan\""
455
# So we have to replace internal ''s to '"'"'
456
    for key in ('author','title','description','version'):
457
      plugin[key]=plugin[key].replace('"','\\"')
458
      plugin[key]=plugin[key].replace("'","'\"'\"'")
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
459
    return plugin
460
461
462
def write_plugin_am(plugin, plugin_am):
463
  """Write an automake fragment for this plugin.
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
464
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
465
  :param plugin: The plugin dict.
466
  :param plugin_am: The file to write to.
467
  """
468
  # The .plugin.ini.stamp avoids changing the datestamp on plugin.ini which can
469
  # confuse VCS systems.
1192.3.25 by Monty Taylor
It seems to work.
470
  plugin_am.write("""
471
EXTRA_DIST += %(rel_path)s/plugin.ini
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
472
473
# Prevent errors when a plugin dir is removed
474
%(rel_path)s/plugin.ini:
1192.3.53 by Robert Collins
Build fixes from Robert.
475
476
""" % plugin)
1716.1.1 by Monty Taylor
Added files to the tarball that should be there. Removed some that shouldn't
477
  if plugin.has_key('extra_dist') and plugin['extra_dist'] != "":
478
    plugin_am.write("EXTRA_DIST += %(extra_dist)s\n" % plugin)
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
479
  if plugin['headers'] != "":
480
    plugin_am.write("noinst_HEADERS += %(headers)s\n" % plugin)
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
481
  if plugin['install_headers'] != "":
482
    plugin_am.write("nobase_include_HEADERS += %(install_headers)s\n" % plugin)
1192.3.20 by Monty Taylor
Added the testsuite location finding code to support in-plugin-dir test suites.
483
  if plugin['testsuite']:
484
    if plugin.has_key('testsuitedir') and plugin['testsuitedir'] != "":
485
      plugin_am.write("EXTRA_DIST += %(rel_path)s/%(testsuitedir)s\n" % plugin)
1716.1.1 by Monty Taylor
Added files to the tarball that should be there. Removed some that shouldn't
486
  if plugin.has_key('dist_testsuite') and plugin['dist_testsuite'] != "":
487
    plugin_am.write("EXTRA_DIST += %(rel_path)s/%(dist_testsuite)s\n" % plugin)
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
488
  if plugin['static']:
489
    plugin_am.write("""
1273.23.1 by Monty Taylor
Merged in latest pandora-build changes. Install plugins in pkglibdir now
490
%(root_plugin_dir)s_%(plugin_prefix)s%(name)s_dir=${top_srcdir}/%(rel_path)s
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
491
EXTRA_DIST += %(rel_path)s/plugin.ini
492
if %(build_conditional_tag)s
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
493
  noinst_LTLIBRARIES+=%(root_plugin_dir)s/%(libname)s.la
494
  %(root_plugin_dir)s_%(libname)s_la_LIBADD=%(libs)s
495
  %(root_plugin_dir)s_%(libname)s_la_DEPENDENCIES=%(libs)s
496
  %(root_plugin_dir)s_%(libname)s_la_LDFLAGS=$(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS)
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
497
  %(root_plugin_dir)s_%(libname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_MODULE_NAME=%(module_name)s -DPANDORA_MODULE_AUTHOR='"%(author)s"' -DPANDORA_MODULE_TITLE='"%(title)s"' -DPANDORA_MODULE_VERSION='"%(version)s"' -DPANDORA_MODULE_LICENSE=%(license)s -DPANDORA_MODULE_DEPENDENCIES='"%(dependencies)s"' %(cppflags)s
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
498
  %(root_plugin_dir)s_%(libname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s
499
  %(root_plugin_dir)s_%(libname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
500
  %(root_plugin_dir)s_%(libname)s_la_SOURCES=%(sources)s
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
501
  check_PROGRAMS += %(tests)s
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
502
  PANDORA_DYNAMIC_LDADDS+=${top_builddir}/%(root_plugin_dir)s/%(libname)s.la
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
503
endif
504
""" % plugin)
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
505
  else:
506
    plugin_am.write("""
1273.23.1 by Monty Taylor
Merged in latest pandora-build changes. Install plugins in pkglibdir now
507
%(root_plugin_dir)s_%(plugin_prefix)s%(name)s_dir=${top_srcdir}/%(rel_path)s
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
508
EXTRA_DIST += %(rel_path)s/plugin.ini
509
if %(build_conditional_tag)s
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
510
  %(library_type)s_LTLIBRARIES+=%(root_plugin_dir)s/%(libname)s.la
511
  %(root_plugin_dir)s_%(libname)s_la_LDFLAGS=-avoid-version -rpath $(pkgplugindir) $(AM_LDFLAGS) %(ldflags)s $(GCOV_LIBS)
512
  %(root_plugin_dir)s_%(libname)s_la_LIBADD=%(libs)s
513
  %(root_plugin_dir)s_%(libname)s_la_DEPENDENCIES=%(libs)s
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
514
  %(root_plugin_dir)s_%(libname)s_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN -DPANDORA_MODULE_NAME=%(module_name)s -DPANDORA_MODULE_AUTHOR='"%(author)s"' -DPANDORA_MODULE_TITLE='"%(title)s"' -DPANDORA_MODULE_VERSION='"%(version)s"' -DPANDORA_MODULE_LICENSE=%(license)s -DPANDORA_MODULE_DEPENDENCIES='"%(dependencies)s"' %(cppflags)s
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
515
  %(root_plugin_dir)s_%(libname)s_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s
516
  %(root_plugin_dir)s_%(libname)s_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
517
  %(root_plugin_dir)s_%(libname)s_la_SOURCES=%(sources)s
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
518
  check_PROGRAMS += %(tests)s
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
519
endif
520
""" % plugin)
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
521
  plugin_am_file=os.path.join(plugin['rel_path'],'plugin.am')
522
  if os.path.exists(plugin_am_file):
523
    plugin_am.write('include %s\n' % plugin_am_file)
524
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
525
#
526
# MAIN STARTS HERE:
527
#
528
529
# Parse the pandora-plugin config file
530
531
config_defaults= dict(
532
  top_srcdir='.',
533
  top_builddir='.',
534
  plugin_ini_fname='plugin.ini',
535
  plugin_prefix='',
536
  plugin_suffix='',
537
  extra_cflags='',
538
  extra_cppflags='',
539
  extra_cxxflags='',
540
  root_plugin_dir='',
541
  pkgplugindir='',
542
  default_install='True',
543
  default_plugin_version='',
544
  default_load_by_default='False',
545
  force_lowercase_libname='True',
546
  plugin_name_separator='_',
547
  module_name_separator='::'
548
)
549
550
config_parser = ConfigParser.ConfigParser(defaults=config_defaults)
551
config_parser.read(pandora_plugin_file)
552
config = dict(config_parser.items('pandora-plugin'))
553
config['force_lowercase_libname']=config_parser.getboolean('pandora-plugin','force_lowercase_libname')
1192.3.25 by Monty Taylor
It seems to work.
554
1377.3.8 by Monty Taylor
Let's not hardcode bzr.
555
# I'm 3 seconds away from writing a comprehensive build solution
1377.3.7 by Monty Taylor
Read out the vcinfo file if it's there.
556
if not os.path.exists('config/pandora_vc_revinfo'):
1377.3.8 by Monty Taylor
Let's not hardcode bzr.
557
  if os.path.exists('.bzr'):
558
    bzr_revno= subprocess.Popen(["bzr", "revno"], stdout=subprocess.PIPE).communicate()[0].strip()
559
    rev_date= datetime.date.fromtimestamp(time.time())
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
560
    config['default_plugin_version'] = "%d.%02d.%s" % (rev_date.year, rev_date.month, bzr_revno)
1377.3.8 by Monty Taylor
Let's not hardcode bzr.
561
  else:
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
562
    config['default_plugin_version']=datetime.date.fromtimestamp(time.time()).isoformat()
1377.3.6 by Monty Taylor
Set the default plugin version for plugins not specifying a version to be
563
else:
564
  # need to read config/pandora_vc_revno
1377.3.7 by Monty Taylor
Read out the vcinfo file if it's there.
565
  pandora_vc_revno=open('config/pandora_vc_revinfo','r').read().split()
566
  rev_date=""
567
  bzr_revno=""
568
  for revno_line in pandora_vc_revno:
569
    (revno_key,revno_val)= revno_line.split("=")
570
    if revno_key == 'PANDORA_VC_REVNO':
571
      bzr_revno=revno_val.strip()
572
    elif revno_key == 'PANDORA_RELEASE_DATE':
573
      rev_date=revno_val.strip()
574
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
575
  config['default_plugin_version'] = "%s.%s" % (rev_date, bzr_revno)
1377.3.7 by Monty Taylor
Read out the vcinfo file if it's there.
576
1192.3.25 by Monty Taylor
It seems to work.
577
actions=[]
578
for arg in sys.argv:
579
  if arg.startswith('--top_srcdir='):
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
580
    config['top_srcdir']=arg[12:]
1192.3.25 by Monty Taylor
It seems to work.
581
  elif arg.startswith('--top_builddir='):
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
582
    config['top_builddir']=arg[14:]
1192.3.25 by Monty Taylor
It seems to work.
583
  elif arg == "--force-all":
584
    actions=['plugin-list','pandora-plugin.am','write']
585
    break
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
586
  else:
1192.3.25 by Monty Taylor
It seems to work.
587
    actions.append(arg)
588
if len(actions) == 0:
589
  actions.append('write')
590
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
591
plugin_list=[]
592
1192.3.25 by Monty Taylor
It seems to work.
593
def accumulate_plugins(arg, dirname, fnames):
594
  # plugin_ini_fname is a name in dirname indicating dirname is a plugin.
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
595
  if config['plugin_ini_fname'] in fnames:
1192.3.25 by Monty Taylor
It seems to work.
596
    arg.append(dirname)
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
597
598
os.path.walk(os.path.join(config['top_srcdir'],
599
                          config['root_plugin_dir']),
600
             accumulate_plugins,
601
             plugin_list)
1192.3.25 by Monty Taylor
It seems to work.
602
603
604
if not os.path.exists("config/pandora-plugin.am") or "write" in actions:
605
  plugin_am_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.am'))
606
  plugin_am_file.write("""
607
# always the current list, generated every build so keep this lean.
1192.3.74 by Robert Collins
Finish the renaming of plugin.list -> pandora-plugin.list that mtaylor started.
608
# pandora-plugin.list: datestamp preserved list
609
${srcdir}/config/pandora-plugin.list: .plugin.scan
1192.3.25 by Monty Taylor
It seems to work.
610
.plugin.scan:
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
611
	@cd ${top_srcdir} && python config/pandora-plugin plugin-list
1192.3.25 by Monty Taylor
It seems to work.
612
613
# Plugins affect configure; so to prevent configure running twice in a tarball
614
# build (once up front, once with the right list of plugins, we ship the
615
# generated list of plugins and the housekeeping material for that list so it
616
# is likewise not updated.
617
EXTRA_DIST += \
618
	config/pandora-plugin.am \
619
	config/pandora-plugin.ac \
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
620
	config/pandora-plugin \
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
621
	config/pandora-plugin.ini
1192.3.25 by Monty Taylor
It seems to work.
622
623
624
# Seed the list of plugin LDADDS which plugins may extend.
625
PANDORA_DYNAMIC_LDADDS=
626
627
# plugin.stamp: graph dominator for creating all per pandora-plugin.ac/am
628
# files. This is invoked when the code to generate such files has altered.""")
629
630
if not os.path.exists("config/pandora-plugin.ac") or "write" in actions:
631
  plugin_ac_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.ac'))
632
  plugin_ac_file.write("dnl Generated file, run make to rebuild\n")
633
1192.4.1 by Robert Collins
Merged buildsystem change from lifeless.
634
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
635
if os.path.exists('plugin.ini'):
636
  # Are we in a plugin dir which wants to have a self-sufficient build system?
1192.3.25 by Monty Taylor
It seems to work.
637
  plugin_list=['.']
1241.9.3 by Monty Taylor
Fixed the out-of-tree plugin file generation.
638
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
639
  write_external_plugin()
640
else:
1192.3.25 by Monty Taylor
It seems to work.
641
  plugin_list_file = ChangeProtectedFile(os.path.join('config', 'pandora-plugin.list'))
642
  for p in plugin_list:
643
    plugin_list_file.write(p)
644
    plugin_list_file.write("\n")
1192.3.7 by Monty Taylor
Added code necessary for building plugins dynamically.
645
  plugin_list.sort()
1192.3.25 by Monty Taylor
It seems to work.
646
  plugin_list_file.close()
647
648
if not os.path.exists("config/pandora-plugin.am") or 'write' in actions:
1192.3.74 by Robert Collins
Finish the renaming of plugin.list -> pandora-plugin.list that mtaylor started.
649
  plugin_am_file.write("\n${top_srcdir}/config/pandora-plugin.am: ${top_srcdir}/config/pandora-plugin.list ${top_srcdir}/config/pandora-plugin ")
1192.3.25 by Monty Taylor
It seems to work.
650
  for plugin_dir in plugin_list:
651
    plugin_am_file.write("\\\n\t%s/plugin.ini " % plugin_dir)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
652
  plugin_am_file.write("\n\tcd ${top_srcdir} && python config/pandora-plugin write\n")
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
653
  plugin_ini_list=[]
654
655
  # Load all plugin.ini files first so we can do dependency tracking.
1192.3.25 by Monty Taylor
It seems to work.
656
  for plugin_dir in plugin_list:
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
657
    plugin = read_plugin_ini(plugin_dir)
658
    expand_plugin_ini(plugin)
659
    plugin_ini_list.append(plugin)
660
1497.3.15 by Monty Taylor
Merged in some stuff from pandora-build.
661
  # Check for duplicates
662
  plugin_name_list = [plugin['libname'] for plugin in plugin_ini_list]
663
  for plugin in plugin_ini_list:
664
    if plugin_name_list.count(plugin['libname']) != 1:
665
      print "Duplicate module name %s" % plugin['libname']
666
      exit(1)
667
1471.3.1 by Monty Taylor
Latest pandora-build. Moves the lint check to only run distcheck.
668
  for plugin in plugin_ini_list:
669
    write_plugin(plugin, plugin_ini_list)
1192.3.25 by Monty Taylor
It seems to work.
670
671
if plugin_am_file is not None:
672
  plugin_am_file.close()
673
if plugin_ac_file is not None:
674
  plugin_ac_file.close()