mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 15:26:17 +02:00
Allow (dynamic) libraries to depend on other libraries
This commit is contained in:
parent
14772783e6
commit
90dfb37f14
5 changed files with 17 additions and 8 deletions
17
Makefile.lib
17
Makefile.lib
|
@ -52,7 +52,8 @@ libs_list :=
|
|||
define LIBS_template =
|
||||
_d := $$(strip $$($(1)_DIR))
|
||||
_srcs := $$(foreach src, $$($(1)_SOURCES), $$(_d)/$$(src))
|
||||
_objs := $$(addsuffix .o, $$(basename $$(_srcs)))
|
||||
$(1)_OBJS := $$(addsuffix .o, $$(basename $$(_srcs)))
|
||||
_libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_NAME))
|
||||
|
||||
$(1)_LDFLAGS_USE :=
|
||||
$(1)_LDFLAGS_USE_INSTALLED :=
|
||||
|
@ -60,8 +61,8 @@ define LIBS_template =
|
|||
ifeq ($(BUILD_SHARED_LIBS), 1)
|
||||
|
||||
_lib := $$(_d)/$(1).so
|
||||
$$(_lib): $$(_objs)
|
||||
$(QUIET) $(CC) -o $$@ -shared $$^ $$($(1)_LDFLAGS)
|
||||
$$(_lib): $$($(1)_OBJS) $$(_libs)
|
||||
$(QUIET) $(CC) -o $$@ -shared -Wl,--no-copy-dt-needed-entries $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
|
||||
|
||||
$(1)_LDFLAGS_USE += -L$$(_d) -Wl,-rpath,$$(abspath $$(_d)) -l$$(patsubst lib%,%,$$(strip $(1)))
|
||||
|
||||
|
@ -69,16 +70,18 @@ define LIBS_template =
|
|||
|
||||
$(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$(1).so
|
||||
|
||||
$$($(1)_INSTALL_PATH): $$(_objs)
|
||||
_libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH))
|
||||
|
||||
$$($(1)_INSTALL_PATH): $$($(1)_OBJS) $$(_libs_final)
|
||||
install -d $$($(1)_INSTALL_DIR)
|
||||
$(QUIET) $(CC) -o $$@ -shared $$^ $$($(1)_LDFLAGS)
|
||||
$(QUIET) $(CC) -o $$@ -shared -Wl,--no-copy-dt-needed-entries $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE_INSTALLED))
|
||||
|
||||
$(1)_LDFLAGS_USE_INSTALLED += -L$$($(1)_INSTALL_DIR) -Wl,-rpath,$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $(1)))
|
||||
|
||||
else
|
||||
|
||||
_lib := $$(_d)/$(1).a
|
||||
$$(_lib): $$(_objs)
|
||||
$$(_lib): $$($(1)_OBJS)
|
||||
$(QUIET) ar crs $$@ $$?
|
||||
|
||||
$(1)_LDFLAGS_USE += $$(_lib) $$($(1)_LDFLAGS)
|
||||
|
@ -92,7 +95,7 @@ define LIBS_template =
|
|||
$(1)_NAME := $$(_lib)
|
||||
|
||||
# Propagate CXXFLAGS to the individual object files.
|
||||
$$(foreach obj, $$(_objs), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS)))
|
||||
$$(foreach obj, $$($(1)_OBJS), $$(eval $$(obj)_CXXFLAGS=$$($(1)_CXXFLAGS)))
|
||||
|
||||
include $$(wildcard $$(_d)/*.dep)
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ libexpr_SOURCES = \
|
|||
get-drvs.cc attr-path.cc value-to-xml.cc value-to-json.cc \
|
||||
common-opts.cc names.cc
|
||||
|
||||
libexpr_LIBS = libutil libstore libformat
|
||||
|
||||
$(d)/parser-tab.cc $(d)/parser-tab.hh: $(d)/parser.y
|
||||
bison -v -o $(libexpr_DIR)/parser-tab.cc $< -d
|
||||
|
||||
|
|
|
@ -4,4 +4,6 @@ libmain_DIR := $(d)
|
|||
|
||||
libmain_SOURCES = shared.cc stack.cc
|
||||
|
||||
libmain_LIBS = libstore libutil libformat
|
||||
|
||||
libmain_LDFLAGS_PROPAGATED = $(BDW_GC_LIBS)
|
||||
|
|
|
@ -6,6 +6,8 @@ libstore_SOURCES = \
|
|||
store-api.cc local-store.cc remote-store.cc derivations.cc build.cc misc.cc \
|
||||
globals.cc references.cc pathlocks.cc gc.cc optimise-store.cc
|
||||
|
||||
libstore_LIBS = libutil libformat
|
||||
|
||||
libstore_LDFLAGS = -lsqlite3 -lbz2
|
||||
|
||||
libstore_CXXFLAGS = \
|
||||
|
|
|
@ -10,4 +10,4 @@ else
|
|||
libutil_SOURCES += md5.c sha1.c sha256.c
|
||||
endif
|
||||
|
||||
libutil_LIBS = src/boost/format/libformat
|
||||
libutil_LIBS = libformat
|
||||
|
|
Loading…
Reference in a new issue