libdwarf: fix linking, fix build on Darwin (#7124)
* libdwarf: fix linker flags * libdwarf: fix header install names * libdwarf: add zlib dependency Prior to this commit, libdwarf was linked to the system zlib. This commit links it to spack-installed zlib. * libdwarf: fix dynamic library suffix for Darwin
This commit is contained in:
parent
bddc1556e1
commit
7959c5ffd2
1 changed files with 31 additions and 3 deletions
|
@ -23,6 +23,7 @@
|
|||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
from spack import *
|
||||
import sys
|
||||
|
||||
# Only build certain parts of dwarf because the other ones break.
|
||||
dwarf_dirs = ['libdwarf', 'dwarfdump2']
|
||||
|
@ -49,6 +50,7 @@ class Libdwarf(Package):
|
|||
version('20130207', '64b42692e947d5180e162e46c689dfbf')
|
||||
version('20130126', 'ded74a5e90edb5a12aac3c29d260c5db')
|
||||
depends_on("elf", type='link')
|
||||
depends_on('zlib', type='link')
|
||||
|
||||
parallel = False
|
||||
|
||||
|
@ -77,23 +79,44 @@ def install(self, spec, prefix):
|
|||
if spec.satisfies('^libelf'):
|
||||
libelf_inc_dir = join_path(spec['libelf'].prefix,
|
||||
'include/libelf')
|
||||
extra_config_args.append('CFLAGS=-I{0}'.format(
|
||||
libelf_inc_dir))
|
||||
extra_config_args.append(
|
||||
'CFLAGS=-I{0} -Wl,-L{1} -Wl,-lelf'.format(
|
||||
libelf_inc_dir, spec['libelf'].prefix.lib))
|
||||
configure("--prefix=" + prefix, "--enable-shared",
|
||||
*extra_config_args)
|
||||
filter_file(r'^dwfzlib\s*=\s*-lz',
|
||||
'dwfzlib=-L{0} -lz'.format(
|
||||
self.spec['zlib'].prefix.lib),
|
||||
'Makefile')
|
||||
make()
|
||||
|
||||
libdwarf_name = 'libdwarf.{0}'.format(dso_suffix)
|
||||
install('libdwarf.a', prefix.lib)
|
||||
install('libdwarf.so', prefix.lib)
|
||||
install('libdwarf.so', join_path(prefix.lib, libdwarf_name))
|
||||
install('libdwarf.h', prefix.include)
|
||||
install('dwarf.h', prefix.include)
|
||||
|
||||
# It seems like fix_darwin_install_name can't be used
|
||||
# here directly; the install name of the library in
|
||||
# the stage directory must be fixed in order for dyld
|
||||
# to locate it on Darwin when spack builds dwarfdump
|
||||
if sys.platform == 'darwin':
|
||||
install_name_tool = which('install_name_tool')
|
||||
install_name_tool('-id',
|
||||
join_path('..', 'libdwarf',
|
||||
'libdwarf.so'),
|
||||
'libdwarf.so')
|
||||
|
||||
if spec.satisfies('@20130126:20130729'):
|
||||
dwarfdump_dir = 'dwarfdump2'
|
||||
else:
|
||||
dwarfdump_dir = 'dwarfdump'
|
||||
with working_dir(dwarfdump_dir):
|
||||
configure("--prefix=" + prefix)
|
||||
filter_file(r'^dwfzlib\s*=\s*-lz',
|
||||
'dwfzlib=-L{0} -lz'.format(
|
||||
self.spec['zlib'].prefix.lib),
|
||||
'Makefile')
|
||||
|
||||
# This makefile has strings of copy commands that
|
||||
# cause a race in parallel
|
||||
|
@ -102,3 +125,8 @@ def install(self, spec, prefix):
|
|||
install('dwarfdump', prefix.bin)
|
||||
install('dwarfdump.conf', prefix.lib)
|
||||
install('dwarfdump.1', prefix.man.man1)
|
||||
|
||||
@run_after('install')
|
||||
def darwin_fix(self):
|
||||
if sys.platform == 'darwin':
|
||||
fix_darwin_install_name(self.prefix.lib)
|
||||
|
|
Loading…
Reference in a new issue