27
27
autogen_header="This file is generated, re-run %s to rebuild\n" % sys.argv[0]
29
class ChangeProtectedFile(object):
31
def __init__(self, fname):
32
self.real_fname= fname
33
self.new_fname= "%s.new" % fname
34
self.new_file= open(self.new_fname,'w')
36
def write(self, text):
37
self.new_file.write(text)
39
# We've written all of this out into .new files, now we only copy them
40
# over the old ones if they are different, so that we don't cause
41
# unnecessary recompiles
44
if os.system('diff %s %s >/dev/null 2>&1' % (self.new_fname,self.real_fname)):
46
os.unlink(self.real_fname)
49
os.rename(self.new_fname, self.real_fname)
51
os.unlink(self.new_fname)
55
29
if len(sys.argv)>1:
56
30
top_srcdir=sys.argv[1]
57
31
top_builddir=top_srcdir
58
32
if len(sys.argv)>2:
59
33
top_builddir=sys.argv[2]
61
plugin_ac=ChangeProtectedFile(os.path.join(top_builddir,'config','plugin.ac'))
62
plugin_am=ChangeProtectedFile(os.path.join(top_srcdir,'config','plugin.am'))
35
plugin_ac=open(os.path.join(top_builddir,'config','plugin.ac.new'),'w')
36
plugin_am=open(os.path.join(top_srcdir,'config','plugin.am.new'),'w')
64
37
plugin_ac.write("dnl %s" % autogen_header)
65
38
plugin_am.write("# %s" % autogen_header)
66
plugin_am.write("PANDORA_DYNAMIC_LDADDS=\n")
68
40
def accumulate_plugins(arg, dirname, fnames):
69
41
if plugin_ini_fname in fnames:
76
48
for plugin_dir in plugin_list:
77
49
plugin_file= os.path.join(plugin_dir,plugin_ini_fname)
78
parser=ConfigParser.ConfigParser(defaults=dict(sources="",headers="", cflags="",cppflags="",cxxflags="", libs="", ldflags="", testsuite=""))
50
parser=ConfigParser.ConfigParser(defaults=dict(sources="",headers="", cflags="",cppflags="",cxxflags="", libs="", ldflags=""))
79
51
parser.read(plugin_file)
80
52
plugin=dict(parser.items('plugin'))
81
53
plugin['rel_path']= plugin_dir[len(top_srcdir)+len(os.path.sep):]
96
68
header= os.path.join(plugin['rel_path'], header)
97
69
new_headers= "%s %s" % (new_headers, header)
98
70
plugin['headers']= new_headers
100
72
if plugin.has_key('load_by_default'):
101
73
plugin['load_by_default']=parser.getboolean('plugin','load_by_default')
125
97
plugin['has_build_conditional']=False
126
98
plugin['build_conditional']='"x${with_%(name)s_plugin}" = "xyes"' %plugin
128
# Turn this on later plugin_lib%(name)s_plugin_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN %(cppflags)s
100
# Turn this on later plugin_lib%(name)s_plugin_la_CPPFLAGS=$(AM_CPPFLAGS) -DDRIZZLE_DYNAMIC_PLUGIN %(cppflags)s
131
103
# Write plugin build instructions into plugin.am file.
145
117
plugin_lib%(name)s_plugin_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
147
119
plugin_lib%(name)s_plugin_la_SOURCES=%(sources)s
148
PANDORA_DYNAMIC_LDADDS+=${top_builddir}/plugin/lib%(name)s_plugin.la
151
122
# Add this once we're actually doing dlopen (and remove -avoid-version if
152
123
# we move to ltdl
153
124
#pkgplugin_LTLIBRARIES+=plugin/lib%(name)s_plugin.la
154
125
#plugin_lib%(name)s_plugin_la_LDFLAGS=-module -avoid-version -rpath $(pkgplugindir) %(libs)s
126
#drizzled_drizzled_LDADD+=${top_builddir}/plugin/lib%(name)s_plugin.la
157
128
if os.path.exists(plugin_am_file):
158
plugin_am.write('include %s\n' % plugin_am_file)
129
plugin_am.write('include %s\n' % plugin_am_file)
161
132
# Write plugin config instructions into plugin.am file.
163
134
plugin_ac.write("\n\ndnl Config for %(title)s\n" % plugin)
164
135
for m4_file in plugin_m4_files:
165
plugin_ac.write('m4_sinclude([%s])\n' % m4_file)
136
plugin_ac.write('m4_sinclude([%s])\n' % m4_file)
167
138
plugin_ac.write("""
168
139
AC_ARG_WITH([%(name_with_dashes)s-plugin],[
194
165
[test %(build_conditional)s])
195
166
AS_IF([test "x$with_%(name)s_plugin" = "xyes"],
198
if plugin['testsuite'] != "":
200
pandora_plugin_test_list="%(testsuite)s,${pandora_plugin_test_list}"
204
pandora_default_plugin_list="%(name)s,${pandora_default_plugin_list}"
205
pandora_builtin_list="builtin_%(name)s_plugin,${pandora_builtin_list}"
206
pandora_plugin_libs="${pandora_plugin_libs} \${top_builddir}/plugin/lib%(name)s_plugin.la"
207
PANDORA_PLUGIN_DEP_LIBS="${PANDORA_PLUGIN_DEP_LIBS} %(plugin_dep_libs)s"
168
drizzled_default_plugin_list="%(name)s,${drizzled_default_plugin_list}"
169
drizzled_builtin_list="builtin_%(name)s_plugin,${drizzled_builtin_list}"
170
drizzled_plugin_libs="${drizzled_plugin_libs} \${top_builddir}/plugin/lib%(name)s_plugin.la"
171
DRIZZLED_PLUGIN_DEP_LIBS="${DRIZZLED_PLUGIN_DEP_LIBS} %(plugin_dep_libs)s"
211
175
plugin_ac.close()
212
176
plugin_am.close()
178
# We've written all of this out into .new files, now we only copy them
179
# over the old ones if they are different, so that we don't cause
180
# unnecessary recompiles
181
for f in ('plugin.ac','plugin.am'):
182
fname= os.path.join(top_builddir,'config',f)
183
if os.system('diff %s.new %s >/dev/null 2>&1' % (fname,fname)):
188
os.rename('%s.new' % fname, fname)
190
os.unlink("%s.new" % fname)