about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Makefile.lib28
-rw-r--r--src/libmain/Makefile.new2
-rw-r--r--src/libutil/Makefile.new4
-rw-r--r--src/nix-store/Makefile.new2
4 files changed, 23 insertions, 13 deletions
diff --git a/Makefile.lib b/Makefile.lib
index b045534dcca8..3ebb8df7c98b 100644
--- a/Makefile.lib
+++ b/Makefile.lib
@@ -25,15 +25,15 @@ QUIET = @
 
 # Pass -fPIC if we're building dynamic libraries.
 ifeq ($(BUILD_SHARED_LIBS), 1)
-GLOBAL_CFLAGS += -fPIC
-GLOBAL_CXXFLAGS += -fPIC
+  GLOBAL_CFLAGS += -fPIC
+  GLOBAL_CXXFLAGS += -fPIC
 endif
 
 
 # Pass -g if we want debug info.
 ifeq ($(BUILD_DEBUG), 1)
-GLOBAL_CFLAGS += -g
-GLOBAL_CXXFLAGS += -g
+  GLOBAL_CFLAGS += -g
+  GLOBAL_CXXFLAGS += -g
 endif
 
 
@@ -53,11 +53,19 @@ define LIBS_template =
   _d := $$($(1)_DIR)
   _srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)/$$(src))
   _objs := $$(addsuffix .o, $$(basename $$(_srcs)))
-  _libs := $$(foreach lib, $$($(1)_LIBS), $$(lib).a)
-  _lib := $$(_d)/$(1).a
 
-  $$(_lib): $$(_objs)
+  ifeq ($(BUILD_SHARED_LIBS), 1)
+    _lib := $$(_d)/$(1).so
+    $$(_lib): $$(_objs)
+	$(QUIET) $(CC) -o $$@ -shared $$^ $$($(1)_LDFLAGS)
+  else
+    _lib := $$(_d)/$(1).a
+    $$(_lib): $$(_objs)
 	$(QUIET) ar crs $$@ $$?
+    $(1)_LDFLAGS_PROPAGATED += $$($(1)_LDFLAGS)
+  endif
+
+  $(1)_NAME := $$(_lib)
 
   # Propagate CXXFLAGS to the individual object files.
   $$(foreach obj, $$(_objs), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS)))
@@ -65,7 +73,7 @@ define LIBS_template =
   include $$(wildcard $$(_d)/*.dep)
 
   libs_list += $$(_lib)
-  clean_list += $$(_d)/*.a $$(_d)/*.o $$(_d)/*.dep
+  clean_list += $$(_d)/*.a $$(_d)/*.so $$(_d)/*.o $$(_d)/*.dep
   dist_files += $$(_srcs)
 endef
 
@@ -79,11 +87,11 @@ define PROGRAMS_template =
   _d := $$($(1)_DIR)
   _srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)/$$(src))
   _objs := $$(addsuffix .o, $$(basename $$(_srcs)))
-  _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_DIR)/$$(lib).a)
+  _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_NAME))
   _prog := $$(_d)/$(1)
 
   $$(_prog): $$(_objs) $$(_libs)
-	$(QUIET) g++ -o $$@ $$^ $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS))
+	$(QUIET) $(CXX) -o $$@ -Wl,--no-copy-dt-needed-entries $$^ $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_PROPAGATED))
 
   # Propagate CXXFLAGS to the individual object files.
   $$(foreach obj, $$(_objs), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS)))
diff --git a/src/libmain/Makefile.new b/src/libmain/Makefile.new
index 9e26aa8b9e53..eed7e84afe18 100644
--- a/src/libmain/Makefile.new
+++ b/src/libmain/Makefile.new
@@ -4,4 +4,4 @@ libmain_DIR := $(d)
 
 libmain_SOURCES = shared.cc stack.cc
 
-libmain_LDFLAGS = $(BDW_GC_LIBS)
+libmain_LDFLAGS_PROPAGATED = $(BDW_GC_LIBS)
diff --git a/src/libutil/Makefile.new b/src/libutil/Makefile.new
index 7871a4ddb8c8..b7dbf7d1d21e 100644
--- a/src/libutil/Makefile.new
+++ b/src/libutil/Makefile.new
@@ -5,9 +5,9 @@ libutil_DIR := $(d)
 libutil_SOURCES = util.cc hash.cc serialise.cc archive.cc xml-writer.cc affinity.cc
 
 ifeq ($(HAVE_OPENSSL), 1)
-libutil_LDFLAGS = $(OPENSSL_LIBS)
+  libutil_LDFLAGS = $(OPENSSL_LIBS)
 else
-libutil_SOURCES += md5.c sha1.c sha256.c
+  libutil_SOURCES += md5.c sha1.c sha256.c
 endif
 
 libutil_LIBS = src/boost/format/libformat
diff --git a/src/nix-store/Makefile.new b/src/nix-store/Makefile.new
index 0b31f3a36735..105513872e81 100644
--- a/src/nix-store/Makefile.new
+++ b/src/nix-store/Makefile.new
@@ -5,3 +5,5 @@ nix-store_DIR := $(d)
 nix-store_SOURCES = nix-store.cc dotgraph.cc xmlgraph.cc
 
 nix-store_LIBS = libmain libstore libutil libformat
+
+nix-store_LDFLAGS = -lbz2