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)
29
55
if len(sys.argv)>1:
30
56
top_srcdir=sys.argv[1]
31
57
top_builddir=top_srcdir
32
58
if len(sys.argv)>2:
33
59
top_builddir=sys.argv[2]
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')
61
plugin_ac=ChangeProtectedFile(os.path.join(top_builddir,'config','plugin.ac'))
62
plugin_am=ChangeProtectedFile(os.path.join(top_srcdir,'config','plugin.am'))
37
64
plugin_ac.write("dnl %s" % autogen_header)
38
65
plugin_am.write("# %s" % autogen_header)
66
plugin_am.write("PANDORA_DYNAMIC_LDADDS=\n")
40
68
def accumulate_plugins(arg, dirname, fnames):
41
69
if plugin_ini_fname in fnames:
68
96
header= os.path.join(plugin['rel_path'], header)
69
97
new_headers= "%s %s" % (new_headers, header)
70
98
plugin['headers']= new_headers
72
100
if plugin.has_key('load_by_default'):
73
101
plugin['load_by_default']=parser.getboolean('plugin','load_by_default')
97
125
plugin['has_build_conditional']=False
98
126
plugin['build_conditional']='"x${with_%(name)s_plugin}" = "xyes"' %plugin
100
# Turn this on later plugin_lib%(name)s_plugin_la_CPPFLAGS=$(AM_CPPFLAGS) -DDRIZZLE_DYNAMIC_PLUGIN %(cppflags)s
128
# Turn this on later plugin_lib%(name)s_plugin_la_CPPFLAGS=$(AM_CPPFLAGS) -DPANDORA_DYNAMIC_PLUGIN %(cppflags)s
103
131
# Write plugin build instructions into plugin.am file.
117
145
plugin_lib%(name)s_plugin_la_CFLAGS=$(AM_CFLAGS) %(cflags)s
119
147
plugin_lib%(name)s_plugin_la_SOURCES=%(sources)s
148
PANDORA_DYNAMIC_LDADDS+=${top_builddir}/plugin/lib%(name)s_plugin.la
122
151
# Add this once we're actually doing dlopen (and remove -avoid-version if
123
152
# we move to ltdl
124
153
#pkgplugin_LTLIBRARIES+=plugin/lib%(name)s_plugin.la
125
154
#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
128
157
if os.path.exists(plugin_am_file):
129
plugin_am.write('include %s\n' % plugin_am_file)
158
plugin_am.write('include %s\n' % plugin_am_file)
132
161
# Write plugin config instructions into plugin.am file.
134
163
plugin_ac.write("\n\ndnl Config for %(title)s\n" % plugin)
135
164
for m4_file in plugin_m4_files:
136
plugin_ac.write('m4_sinclude([%s])\n' % m4_file)
165
plugin_ac.write('m4_sinclude([%s])\n' % m4_file)
138
167
plugin_ac.write("""
139
168
AC_ARG_WITH([%(name_with_dashes)s-plugin],[
169
198
if plugin['testsuite'] != "":
170
199
plugin_ac.write("""
171
drizzled_plugin_test_list="%(testsuite)s,${drizzled_plugin_test_list}"
200
pandora_plugin_test_list="%(testsuite)s,${pandora_plugin_test_list}"
174
203
plugin_ac.write("""
175
drizzled_default_plugin_list="%(name)s,${drizzled_default_plugin_list}"
176
drizzled_builtin_list="builtin_%(name)s_plugin,${drizzled_builtin_list}"
177
drizzled_plugin_libs="${drizzled_plugin_libs} \${top_builddir}/plugin/lib%(name)s_plugin.la"
178
DRIZZLED_PLUGIN_DEP_LIBS="${DRIZZLED_PLUGIN_DEP_LIBS} %(plugin_dep_libs)s"
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"
182
211
plugin_ac.close()
183
212
plugin_am.close()
185
# We've written all of this out into .new files, now we only copy them
186
# over the old ones if they are different, so that we don't cause
187
# unnecessary recompiles
188
for f in ('plugin.ac','plugin.am'):
189
fname= os.path.join(top_builddir,'config',f)
190
if os.system('diff %s.new %s >/dev/null 2>&1' % (fname,fname)):
195
os.rename('%s.new' % fname, fname)
197
os.unlink("%s.new" % fname)