~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to config/pandora-plugin

  • Committer: Brian Aker
  • Date: 2009-11-25 07:05:58 UTC
  • mfrom: (1192.3.39 pandora-build)
  • Revision ID: brian@gaz-20091125070558-mzf1m5etiwb841jb
Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
          pass
71
71
 
72
72
 
 
73
def write_external_configure(plugin, plugin_file):
 
74
  """Write the initial bits of the configure.ac file"""
 
75
  if not os.path.exists('m4'):
 
76
    os.mkdir('m4')
 
77
  plugin_file.write("""
 
78
AC_PREREQ(2.59)dnl              Minimum Autoconf version required.
 
79
AC_INIT([%(name)s],[%(version)s],[%(url)s])
 
80
AC_CONFIG_SRCDIR([%(main_source)s])
 
81
AC_CONFIG_AUX_DIR(config)
 
82
AC_CONFIG_HEADERS([config.h])
 
83
AC_CONFIG_MACRO_DIR([m4])
 
84
 
 
85
PANDORA_CANONICAL_TARGET(less-warnings, warnings-always-on, require-cxx, force-gcc42)
 
86
 
 
87
PANDORA_REQUIRE_LIBPROTOBUF
 
88
PANDORA_PROTOBUF_REQUIRE_VERSION([2.1.0])
 
89
PANDORA_REQUIRE_PROTOC
 
90
 
 
91
AC_LANG_PUSH(C++)
 
92
PANDORA_REQUIRE_PTHREAD
 
93
PANDORA_REQUIRE_LIBDL
 
94
AC_LANG_POP
 
95
 
 
96
PANDORA_USE_BETTER_MALLOC
 
97
 
 
98
PANDORA_DRIZZLE_BUILD
 
99
""" % plugin)
 
100
 
 
101
  write_plugin_ac(plugin, plugin_file)
 
102
 
 
103
  plugin_file.write("""
 
104
AC_CONFIG_FILES(Makefile)
 
105
 
 
106
AC_OUTPUT
 
107
 
 
108
echo "---"
 
109
echo "Configuration summary for $PACKAGE_NAME version $VERSION $PANDORA_RELEASE_COMMENT"
 
110
echo ""
 
111
echo "   * Installation prefix:       $prefix"
 
112
echo "   * System type:               $host_vendor-$host_os"
 
113
echo "   * Host CPU:                  $host_cpu"
 
114
echo "   * C Compiler:                $CC_VERSION"
 
115
echo "   * C++ Compiler:              $CXX_VERSION"
 
116
echo "   * Debug enabled:             $with_debug"
 
117
echo "   * Warnings as failure:       $ac_cv_warnings_as_errors"
 
118
echo "   * C++ cstdint location:      $ac_cv_cxx_cstdint"
 
119
echo "   * C++ hash_map location:     $ac_cv_cxx_hash_map"
 
120
echo "   * C++ hash namespace:        $ac_cv_cxx_hash_namespace"
 
121
echo "   * C++ shared_ptr namespace:  $ac_cv_shared_ptr_namespace"
 
122
echo ""
 
123
echo "---"
 
124
 
 
125
  """ % plugin)
 
126
 
 
127
def write_external_makefile(plugin, plugin_file):
 
128
 
 
129
  plugin_file.write("""
 
130
ACLOCAL_AMFLAGS = -I m4 --force
 
131
VERSION=$(PANDORA_RELEASE_VERSION)
 
132
 
 
133
pkgplugindir=$(libdir)/drizzle/plugin
 
134
EXTRA_DIST = %(rel_path)s/plugin.ini
 
135
  """ % plugin)
 
136
  if plugin['headers'] != "":
 
137
    plugin_file.write("noinst_HEADERS = %(headers)s\n" % plugin)
 
138
  if plugin['testsuite']:
 
139
    if plugin.has_key('testsuitedir') and plugin['testsuitedir'] != "":
 
140
      plugin_file.write("EXTRA_DIST += %(rel_path)s/%(testsuitedir)s\n" % plugin)
 
141
  plugin_file.write("""
 
142
pkgplugin_LTLIBRARIES=lib%(name)s_plugin.la
 
143
lib%(name)s_plugin_la_LDFLAGS=-module -avoid-version -rpath $(pkgplugindir) $(AM_LDFLAGS) %(ldflags)s
 
144
lib%(name)s_plugin_la_LIBADD=%(libs)s
 
145
lib%(name)s_plugin_la_DEPENDENCIES=%(libs)s
 
146
lib%(name)s_plugin_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN -DPANDORA_MODULE_NAME=%(name)s %(cppflags)s
 
147
lib%(name)s_plugin_la_CXXFLAGS=$(AM_CXXFLAGS) %(cxxflags)s
 
148
lib%(name)s_plugin_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
 
149
 
 
150
lib%(name)s_plugin_la_SOURCES=%(sources)s
 
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
 
73
156
def write_external_plugin():
74
157
  """Return True if the plugin had changed."""
75
158
  plugin = read_plugin_ini('.')
76
159
  expand_plugin_ini(plugin, '.')
77
 
  plugin_file = ChangeProtectedFile('pandora-plugin.ac')
78
 
  write_plugin_ac(plugin, plugin_file)
 
160
  plugin_file = ChangeProtectedFile('configure.ac')
 
161
  write_external_configure(plugin, plugin_file)
79
162
  result = plugin_file.close()
80
 
  plugin_file = ChangeProtectedFile('pandora-plugin.am')
81
 
  write_plugin_am(plugin, plugin_file)
 
163
  plugin_file = ChangeProtectedFile('Makefile.am')
 
164
  write_external_makefile(plugin, plugin_file)
82
165
  # Write some stub configure.ac and Makefile.am files that include the above
83
166
  result = plugin_file.close() or result
84
167
  return result
132
215
      [with_%(name)s_plugin=no])
133
216
  """ % plugin)
134
217
  plugin['plugin_dep_libs']=" ".join(["\${top_builddir}/%s" % f for f in plugin['libs'].split()])
135
 
  plugin_ac.write("""
 
218
  if not plugin['unconditional']:
 
219
    plugin_ac.write("""
136
220
AM_CONDITIONAL([%(build_conditional_tag)s],
137
221
               [test %(build_conditional)s])
 
222
    """ % plugin)
 
223
  plugin_ac.write("""
138
224
AS_IF([test "x$with_%(name)s_plugin" = "xyes"],
139
225
      [
140
226
  """ % plugin)
158
244
 
159
245
 
160
246
def expand_plugin_ini(plugin, plugin_dir):
 
247
    if plugin_dir == ".":
 
248
      plugin['unconditional']=True
 
249
    else:
 
250
      plugin['unconditional']=False
161
251
    plugin['rel_path']= plugin_dir[len(top_srcdir)+len(os.path.sep):]
162
252
    # TODO: determine path to plugin dir relative to top_srcdir... append it to
163
253
    # source files if they don't already have it
168
258
      if not src.startswith(plugin['rel_path']):
169
259
        src= os.path.join(plugin['rel_path'], src)
170
260
        new_sources= "%s %s" % (new_sources, src)
171
 
    plugin['sources']= new_sources
 
261
    if new_sources != "":
 
262
      plugin['sources']= new_sources
 
263
    plugin['main_source']= plugin['sources'].split()[0]
172
264
    
173
265
    new_headers=""
174
266
    for header in plugin['headers'].split():
205
297
    parser=ConfigParser.ConfigParser(defaults=dict(sources="",headers="", cflags="",cppflags="",cxxflags="", libs="", ldflags=""))
206
298
    parser.read(plugin_file)
207
299
    plugin=dict(parser.items('plugin'))
208
 
    plugin['name']= os.path.basename(plugin_dir)
 
300
    if not plugin.has_key('name'):
 
301
      plugin['name']= os.path.basename(plugin_dir)
 
302
    if plugin_dir == '.':
 
303
      if not plugin.has_key('url'):
 
304
        print "External Plugins are required to specifiy a url"
 
305
        plugin['url']= 'http://launchpad.net/%(name)s' % plugin
 
306
        sys.exit(1)
 
307
      if plugin_dir == '.' and not plugin.has_key('version'):
 
308
        print "External Plugins are required to specifiy a version"
 
309
        sys.exit(1)
 
310
   
209
311
    if plugin.has_key('load_by_default'):
210
312
      plugin['load_by_default']=parser.getboolean('plugin','load_by_default')
211
313
    else:
314
416
# plugin.list: datestamp preserved list
315
417
${srcdir}/config/plugin.list: .plugin.scan
316
418
.plugin.scan:
317
 
        @cd ${top_srcdir} && python config/register_plugins.py plugin-list
 
419
        @cd ${top_srcdir} && python config/pandora-plugin plugin-list
318
420
 
319
421
# Plugins affect configure; so to prevent configure running twice in a tarball
320
422
# build (once up front, once with the right list of plugins, we ship the
323
425
EXTRA_DIST += \
324
426
        config/pandora-plugin.am \
325
427
        config/pandora-plugin.ac \
326
 
        config/register_plugins.py
 
428
        config/pandora-plugin
327
429
 
328
430
 
329
431
# Seed the list of plugin LDADDS which plugins may extend.
350
452
  plugin_list_file.close()
351
453
 
352
454
if not os.path.exists("config/pandora-plugin.am") or 'write' in actions:
353
 
  plugin_am_file.write("\nconfig/pandora-plugin.am: ${top_srcdir}/config/plugin.list ${top_srcdir}/config/register_plugins.py ")
 
455
  plugin_am_file.write("\nconfig/pandora-plugin.am: ${top_srcdir}/config/plugin.list ${top_srcdir}/config/pandora-plugin ")
354
456
  for plugin_dir in plugin_list:
355
457
    plugin_am_file.write("\\\n\t%s/plugin.ini " % plugin_dir)
356
 
  plugin_am_file.write("\n\tcd ${top_srcdir} && python config/register_plugins.py write\n")
 
458
  plugin_am_file.write("\n\tcd ${top_srcdir} && python config/pandora-plugin write\n")
357
459
  for plugin_dir in plugin_list:
358
460
    write_plugin(plugin_dir)
359
461