From: Andrew Waterman Date: Mon, 27 Jan 2014 00:26:25 +0000 (-0800) Subject: Link subproject dynamic libraries correctly X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=afa56de3d56a00998ce8e7a0f8a73a3996bd1f25;p=riscv-isa-sim.git Link subproject dynamic libraries correctly --- diff --git a/Makefile.in b/Makefile.in index 9cd36d1..f54864f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -195,19 +195,23 @@ $$($(2)_c_objs) : %.o : %.c $$($(2)_gen_hdrs) $(2)_junk += $$($(2)_objs) $$($(2)_c_objs) $$($(2)_deps) $$($(2)_c_deps) $$($(2)_gen_hdrs) -# Build a library for this subproject - -lib$(1).so : $$($(2)_objs) $$($(2)_c_objs) - $(CXX) -shared -o $$@ $$^ - -$(2)_junk += lib$(1).so - # Reverse the dependency list so that a given subproject only depends on # subprojects listed to its right. This is the correct order for linking # the list of subproject libraries. $(2)_reverse_deps := $$(call reverse_list,$$($(2)_subproject_deps)) +# Build a library for this subproject + +$(2)_lib_libs := $$($(2)_reverse_deps) +$(2)_lib_libnames := $$(patsubst %, lib%.so, $$($(2)_lib_libs)) +$(2)_lib_libarg := -L. $$(patsubst %, -l%, $$($(2)_lib_libs)) + +lib$(1).so : $$($(2)_objs) $$($(2)_c_objs) $$($(2)_lib_libnames) + $(LINK) -shared -o $$@ $(if $(filter Darwin,$(shell uname -s)),-install_name $(install_libs_dir)/$$@) $$^ $$($(2)_lib_libarg) $(LIBS) + +$(2)_junk += lib$(1).so + # Build unit tests $(2)_test_objs := $$(patsubst %.cc, %.o, $$($(2)_test_srcs))