From 9285f0aa2b44427afef7c50f0efae8f74307a7a5 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 25 Nov 2013 16:38:33 +0000 Subject: [PATCH] Add a Makefile for the Perl stuff --- Makefile | 1 + Makefile.config.in | 3 +++ mk/lib.mk | 2 +- mk/libraries.mk | 17 +++++++++++----- perl/Makefile | 41 +++++++++++++++++++++++++++++++++++++++ perl/lib/Nix/Config.pm.in | 2 +- 6 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 perl/Makefile diff --git a/Makefile b/Makefile index 652085a78..6abce9372 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ SUBS = \ src/nix-daemon/Makefile \ src/nix-log2xml/Makefile \ src/bsdiff-4.3/Makefile \ + perl/Makefile \ scripts/Makefile \ corepkgs/Makefile diff --git a/Makefile.config.in b/Makefile.config.in index b9d9bd1c4..65080c88f 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -16,6 +16,9 @@ exec_prefix = @exec_prefix@ libdir = @libdir@ libexecdir = @libexecdir@ localstatedir = @localstatedir@ +perl = @perl@ +perlbindings = @perlbindings@ +perllibdir = @perllibdir@ pkglibdir = $(libdir)/$(PACKAGE_NAME) prefix = @prefix@ storedir = @storedir@ diff --git a/mk/lib.mk b/mk/lib.mk index a1634bc00..107a5af3f 100644 --- a/mk/lib.mk +++ b/mk/lib.mk @@ -58,4 +58,4 @@ $(foreach script, $(noinst_SCRIPTS), $(eval programs_list += $(script))) $(foreach template, $(template_files), $(eval $(call instantiate-template,$(template)))) -all: $(programs_list) +all: $(programs_list) $(libs_list) diff --git a/mk/libraries.mk b/mk/libraries.mk index 633bfdba8..58c67063b 100644 --- a/mk/libraries.mk +++ b/mk/libraries.mk @@ -22,11 +22,14 @@ libs_list := # - $(1)_LDFLAGS_PROPAGATED: additional linker flags, also propagated # to the linking of programs/libraries that use this library. # +# - $(1)_FORCE_INSTALL: if defined, the library will be installed even +# if it's not needed (i.e. dynamically linked) by a program. +# +# - $(1)_INSTALL_DIR: the directory where the library will be +# installed. Defaults to $(libdir). +# # - BUILD_SHARED_LIBS: if equal to ‘1’, a dynamic library will be # built, otherwise a static library. -# -# - libdir: the directory where the library will be installed (if -# required). define build-library = $(1)_NAME ?= $(1) _d := $$(strip $$($(1)_DIR)) @@ -34,6 +37,8 @@ define build-library = $(1)_OBJS := $$(addsuffix .o, $$(basename $$(_srcs))) _libs := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_PATH)) + $(1)_INSTALL_DIR ?= $$(libdir) + $(1)_LDFLAGS_USE := $(1)_LDFLAGS_USE_INSTALLED := @@ -50,8 +55,6 @@ define build-library = $(1)_LDFLAGS_USE += -L$$(_d) -Wl,-rpath,$$(abspath $$(_d)) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME))) - $(1)_INSTALL_DIR := $$(libdir) - $(1)_INSTALL_PATH := $$($(1)_INSTALL_DIR)/$$($(1)_NAME).so _libs_final := $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_INSTALL_PATH)) @@ -63,6 +66,10 @@ define build-library = $(1)_LDFLAGS_USE_INSTALLED += -L$$($(1)_INSTALL_DIR) -Wl,-rpath,$$($(1)_INSTALL_DIR) -l$$(patsubst lib%,%,$$(strip $$($(1)_NAME))) + ifdef $(1)_FORCE_INSTALL + install: $$($(1)_INSTALL_PATH) + endif + else $(1)_PATH := $$(_d)/$$($(1)_NAME).a diff --git a/perl/Makefile b/perl/Makefile new file mode 100644 index 000000000..a0788e2a2 --- /dev/null +++ b/perl/Makefile @@ -0,0 +1,41 @@ +nix_perl_sources := \ + $(d)/lib/Nix/Store.pm \ + $(d)/lib/Nix/Manifest.pm \ + $(d)/lib/Nix/GeneratePatches.pm \ + $(d)/lib/Nix/SSH.pm \ + $(d)/lib/Nix/CopyClosure.pm \ + $(d)/lib/Nix/Config.pm.in \ + $(d)/lib/Nix/Utils.pm + +nix_perl_modules := $(nix_perl_sources:.in=) + +$(foreach x, $(nix_perl_modules), $(eval $(call install-data-in, $(x), $(perllibdir)/Nix))) + +ifeq ($(perlbindings), yes) + + $(d)/lib/Nix/Store.cc: $(d)/lib/Nix/Store.xs + xsubpp $^ -output $@ + + LIBS += Store + + Store_DIR := $(d)/lib/Nix + + Store_SOURCES = Store.cc + + Store_LIBS = libstore + + Store_CXXFLAGS = \ + -I$(shell $(perl) -e 'use Config; print $$Config{archlibexp};')/CORE \ + -D_FILE_OFFSET_BITS=64 + + Store_ALLOW_UNDEFINED = 1 + + Store_FORCE_INSTALL = 1 + + Store_INSTALL_DIR = $(perllibdir)/auto/Nix/Store + +endif + +clean_files += $(d)/lib/Nix/Config.pm $(d)/lib/Nix/Store.cc + +dist_files += $(nix_perl_sources) diff --git a/perl/lib/Nix/Config.pm.in b/perl/lib/Nix/Config.pm.in index 8c902ab6e..ee9d865ca 100644 --- a/perl/lib/Nix/Config.pm.in +++ b/perl/lib/Nix/Config.pm.in @@ -1,6 +1,6 @@ package Nix::Config; -$version = "@version@"; +$version = "@PACKAGE_VERSION@"; $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; $libexecDir = $ENV{"NIX_LIBEXEC_DIR"} || "@libexecdir@";