diff --git a/mk/libraries.mk b/mk/libraries.mk index 6541775f329..5118b957608 100644 --- a/mk/libraries.mk +++ b/mk/libraries.mk @@ -130,7 +130,15 @@ define build-library $(1)_LDFLAGS_USE += $$($(1)_PATH) $$($(1)_LDFLAGS) - $(1)_INSTALL_PATH := $$(libdir)/$$($(1)_NAME).a + $(1)_INSTALL_PATH := $(DESTDIR)$$($(1)_INSTALL_DIR)/$$($(1)_NAME).a + + $$(eval $$(call create-dir, $$($(1)_INSTALL_DIR))) + + $$($(1)_INSTALL_PATH): $$($(1)_OBJS) | $(DESTDIR)$$($(1)_INSTALL_DIR)/ + +$$(trace-ld) $(LD) -Ur -o $$(_d)/$$($(1)_NAME).o $$^ + $$(trace-ar) $(AR) crs $$@ $$(_d)/$$($(1)_NAME).o + + install: $$($(1)_INSTALL_PATH) endif diff --git a/src/libstore/local.mk b/src/libstore/local.mk index 8f28bec6c1d..0d41e3c2cac 100644 --- a/src/libstore/local.mk +++ b/src/libstore/local.mk @@ -69,6 +69,13 @@ $(d)/build.cc: clean-files += $(d)/schema.sql.gen.hh $(d)/ca-specific-schema.sql.gen.hh +$(d)/nix-store.pc: $(d)/nix-store.pc.in + $(trace-gen) rm -f $@ && ./config.status --quiet --file=$@ +ifeq ($(BUILD_SHARED_LIBS), 1) + sed -i 's|@LIBS_PRIVATE@||' $@ +else + sed -i 's|@LIBS_PRIVATE@|Libs.private: $(libstore_LDFLAGS) $(libstore_LDFLAGS_PROPAGATED) $(foreach lib, $(libstore_LIBS), $($(lib)_LDFLAGS))|' $@ +endif $(eval $(call install-file-in, $(d)/nix-store.pc, $(libdir)/pkgconfig, 0644)) $(foreach i, $(wildcard src/libstore/builtins/*.hh), \ diff --git a/src/libstore/nix-store.pc.in b/src/libstore/nix-store.pc.in index 6d67b1e0380..738991d307b 100644 --- a/src/libstore/nix-store.pc.in +++ b/src/libstore/nix-store.pc.in @@ -7,3 +7,4 @@ Description: Nix Package Manager Version: @PACKAGE_VERSION@ Libs: -L${libdir} -lnixstore -lnixutil Cflags: -I${includedir}/nix -std=c++2a +@LIBS_PRIVATE@