summaryrefslogtreecommitdiff
path: root/build/generator/gen_make.py
diff options
context:
space:
mode:
Diffstat (limited to 'build/generator/gen_make.py')
-rw-r--r--build/generator/gen_make.py92
1 files changed, 87 insertions, 5 deletions
diff --git a/build/generator/gen_make.py b/build/generator/gen_make.py
index 5c2db16..b2a7787 100644
--- a/build/generator/gen_make.py
+++ b/build/generator/gen_make.py
@@ -53,6 +53,12 @@ from gen_base import build_path_join, build_path_strip, build_path_splitfile, \
build_path_basename, build_path_dirname, build_path_retreat, unique
+def _normstr(x):
+ if os.sep == '/':
+ return os.path.normpath(str(x))
+ else:
+ return os.path.normpath(str(x).replace('/', os.sep)).replace(os.sep, '/')
+
class Generator(gen_base.GeneratorBase):
_extension_map = {
@@ -62,6 +68,8 @@ class Generator(gen_base.GeneratorBase):
('lib', 'object'): '.lo',
('pyd', 'target'): '.la',
('pyd', 'object'): '.lo',
+ ('so', 'target'): '.la',
+ ('so', 'object'): '.lo',
}
def __init__(self, fname, verfname, options=None):
@@ -230,12 +238,14 @@ class Generator(gen_base.GeneratorBase):
# get the source items (.o and .la) for the link unit
objects = [ ]
+ objdeps = [ ]
object_srcs = [ ]
headers = [ ]
header_classes = [ ]
header_class_filenames = [ ]
deps = [ ]
libs = [ ]
+ add_deps = target_ob.add_deps.split()
for link_dep in self.graph.get_sources(gen_base.DT_LINK, target_ob.name):
if isinstance(link_dep, gen_base.TargetJava):
@@ -260,6 +270,7 @@ class Generator(gen_base.GeneratorBase):
elif isinstance(link_dep, gen_base.ObjectFile):
# link in the object file
objects.append(link_dep.filename)
+ objdeps.append(_normstr(link_dep.filename))
for dep in self.graph.get_sources(gen_base.DT_OBJECT, link_dep, gen_base.SourceFile):
object_srcs.append(
build_path_join('$(abs_srcdir)', dep.filename))
@@ -286,8 +297,9 @@ class Generator(gen_base.GeneratorBase):
varname=targ_varname,
path=path,
install=None,
- add_deps=target_ob.add_deps,
+ add_deps=add_deps,
objects=objects,
+ objdeps=objdeps,
deps=deps,
when=target_ob.when,
)
@@ -379,7 +391,10 @@ class Generator(gen_base.GeneratorBase):
dirname, fname = build_path_splitfile(file.filename)
return _eztdata(mode=None,
dirname=dirname, fullname=file.filename,
- filename=fname, when=file.when)
+ filename=fname, when=file.when,
+ pc_fullname=None,
+ pc_installdir=None,
+ pc_install_fname=None,)
def apache_file_to_eztdata(file):
# cd to dirname before install to work around libtool 1.4.2 bug.
@@ -412,6 +427,15 @@ class Generator(gen_base.GeneratorBase):
else:
ezt_file.install_fname = build_path_join('$(%sdir)' % area_var,
ezt_file.filename)
+
+ # Install pkg-config files
+ if (isinstance(file.target, gen_base.TargetLib) and
+ ezt_file.fullname.startswith('subversion/libsvn_')):
+ ezt_file.pc_fullname = ezt_file.fullname.replace('-1.la', '.pc')
+ ezt_file.pc_installdir = '$(pkgconfig_dir)'
+ pc_install_fname = ezt_file.filename.replace('-1.la', '.pc')
+ ezt_file.pc_install_fname = build_path_join(ezt_file.pc_installdir,
+ pc_install_fname)
ezt_area.files.append(ezt_file)
# certain areas require hooks for extra install rules defined
@@ -452,11 +476,11 @@ class Generator(gen_base.GeneratorBase):
key=lambda t: t[0].filename)
for objname, sources in obj_deps:
- dep = _eztdata(name=str(objname),
+ dep = _eztdata(name=_normstr(objname),
when=objname.when,
- deps=list(map(str, sources)),
+ deps=list(map(_normstr, sources)),
cmd=objname.compile_cmd,
- source=str(sources[0]))
+ source=_normstr(sources[0]))
data.deps.append(dep)
dep.generated = ezt.boolean(getattr(objname, 'source_generated', 0))
@@ -469,6 +493,8 @@ class Generator(gen_base.GeneratorBase):
self.write_transform_libtool_scripts(install_sources)
+ self.write_pkg_config_dot_in_files(install_sources)
+
def write_standalone(self):
"""Write autogen-standalone.mk"""
@@ -580,6 +606,62 @@ DIR=`pwd`
libdep_cache[target_name] = sorted(libs)
return libdep_cache[target_name]
+ def write_pkg_config_dot_in_files(self, install_sources):
+ """Write pkg-config .pc.in files for Subversion libraries."""
+ for target_ob in install_sources:
+ if not (isinstance(target_ob, gen_base.TargetLib) and
+ target_ob.path.startswith('subversion/libsvn_')):
+ continue
+
+ lib_name = target_ob.name
+ lib_path = self.sections[lib_name].options.get('path')
+ lib_deps = self.sections[lib_name].options.get('libs')
+ lib_desc = self.sections[lib_name].options.get('description')
+ output_path = build_path_join(lib_path, lib_name + '.pc.in')
+ template = ezt.Template(os.path.join('build', 'generator', 'templates',
+ 'pkg-config.in.ezt'),
+ compress_whitespace=False)
+ class _eztdata(object):
+ def __init__(self, **kw):
+ vars(self).update(kw)
+
+ data = _eztdata(
+ lib_name=lib_name,
+ lib_desc=lib_desc,
+ lib_deps=[],
+ lib_required=[],
+ lib_required_private=[],
+ )
+ # libsvn_foo -> -lsvn_foo
+ data.lib_deps.append('-l%s' % lib_name.replace('lib', '', 1))
+ for lib_dep in lib_deps.split():
+ if lib_dep == 'apriconv':
+ # apriconv is part of apr-util, skip it
+ continue
+ external_lib = self.sections[lib_dep].options.get('external-lib')
+ if external_lib:
+ ### Some of Subversion's internal libraries can appear as external
+ ### libs to handle conditional compilation. Skip these for now.
+ if external_lib in ['$(SVN_RA_LIB_LINK)', '$(SVN_FS_LIB_LINK)']:
+ continue
+ # If the external library is known to support pkg-config,
+ # add it to the Required: or Required.private: section.
+ # Otherwise, add the external library to linker flags.
+ pkg_config = self.sections[lib_dep].options.get('pkg-config')
+ if pkg_config:
+ private = self.sections[lib_dep].options.get('pkg-config-private')
+ if private:
+ data.lib_required_private.append(pkg_config)
+ else:
+ data.lib_required.append(pkg_config)
+ else:
+ # $(EXTERNAL_LIB) -> @EXTERNAL_LIB@
+ data.lib_deps.append('@%s@' % external_lib[2:-1])
+ else:
+ data.lib_required_private.append(lib_dep)
+
+ template.generate(open(output_path, 'w'), data)
+
class UnknownDependency(Exception):
"We don't know how to deal with the dependent to link it in."
pass