From eca2488ab4d7891e17176d5df028c50abf50b627 Mon Sep 17 00:00:00 2001 From: Zachary Kincaid Date: Sun, 26 Jul 2015 19:59:17 -0400 Subject: [PATCH 1/2] If ocamlfind is installed, add destdir/stublibs to rpath --- scripts/mk_util.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index cff98818f..ee2fefb43 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1478,6 +1478,28 @@ class MLComponent(Component): get_component(Z3_DLL_COMPONENT).dll_name)) out.write(' %s\n' % (os.path.join(sub_dir, 'z3native_stubs$(OBJ_EXT)'))) out.write('\tocamlmklib -o %s -I %s -ldopt \"-L. -lz3\" ' % (os.path.join(sub_dir, 'z3ml'), sub_dir)) + + # Add ocamlfind destdir to rpath + if OCAMLFIND != '': + if is_verbose(): + print ("Finding ocamlfind destdir") + t = TempFile('output') + null = open(os.devnull, 'wb') + try: + subprocess.call([OCAMLFIND, 'printconf', 'destdir'], stdout=t.fname, stderr=null) + t.commit() + except: + raise MKException('Failed to find Ocamlfind destdir') + t = open('output', 'r') + for line in t: + ocamlfind_destdir = line[:-1] + if is_verbose(): + print ('ocamlfind destdir=%s' % ocamlfind_destdir) + t.close() + rmf('output') + out.write("-rpath %s " % os.path.join(ocamlfind_destdir, 'stublibs')) + out.write("-L%s" % os.path.join(ocamlfind_destdir, 'stublibs')) + for m in modules: out.write(' %s' % (os.path.join(sub_dir, m+'.ml'))) out.write(' %s\n' % (os.path.join(sub_dir, 'z3native_stubs$(OBJ_EXT)'))) From 9e34872e8f79c52a6f35ed5fa945bf6a6aa5f755 Mon Sep 17 00:00:00 2001 From: Zachary Kincaid Date: Sun, 4 Oct 2015 10:10:53 -0400 Subject: [PATCH 2/2] For ocamlfind install, set rpath to package directory if stublibs does not exist --- scripts/mk_util.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/mk_util.py b/scripts/mk_util.py index ee2fefb43..33b79bba5 100644 --- a/scripts/mk_util.py +++ b/scripts/mk_util.py @@ -1497,8 +1497,13 @@ class MLComponent(Component): print ('ocamlfind destdir=%s' % ocamlfind_destdir) t.close() rmf('output') - out.write("-rpath %s " % os.path.join(ocamlfind_destdir, 'stublibs')) - out.write("-L%s" % os.path.join(ocamlfind_destdir, 'stublibs')) + # DLLs are installed into stublibs if it exists, Z3 if not + if os.path.exists(os.path.join(ocamlfind_destdir, 'stublibs')): + dll_path = os.path.join(ocamlfind_destdir, 'stublibs') + else: + dll_path = os.path.join(ocamlfind_destdir, 'Z3') + out.write("-rpath %s " % dll_path) + out.write("-L%s" % dll_path) for m in modules: out.write(' %s' % (os.path.join(sub_dir, m+'.ml')))