aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@eecs.berkeley.edu>2014-01-26 16:26:25 -0800
committerAndrew Waterman <waterman@eecs.berkeley.edu>2014-01-26 16:26:25 -0800
commitafa56de3d56a00998ce8e7a0f8a73a3996bd1f25 (patch)
tree85ea79239ef67ccb741a600f78a2f49b199626dd
parent017f62ac55a9514d12d47cf608f7f5ca6c1d4973 (diff)
downloadriscv-isa-sim-afa56de3d56a00998ce8e7a0f8a73a3996bd1f25.zip
riscv-isa-sim-afa56de3d56a00998ce8e7a0f8a73a3996bd1f25.tar.gz
riscv-isa-sim-afa56de3d56a00998ce8e7a0f8a73a3996bd1f25.tar.bz2
Link subproject dynamic libraries correctly
-rw-r--r--Makefile.in18
1 files changed, 11 insertions, 7 deletions
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))