From b6786564552c3059b327d867836814f5eb671a45 Mon Sep 17 00:00:00 2001 From: Christophe de Dinechin Date: Thu, 5 Apr 2018 23:47:28 +0200 Subject: [PATCH] Add support for generating pkg-config files --- config.mk | 11 ++++++++--- rules.mk | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/config.mk b/config.mk index 367400e..0ac7ddf 100644 --- a/config.mk +++ b/config.mk @@ -64,6 +64,10 @@ NOT_PARALLEL?= .NOTPARALLEL # Git revision for the current code GIT_REVISION:= $(shell git rev-parse --short HEAD 2> /dev/null || echo "unknown") +# Package installation directory +PACKAGE_DIR=$(PACKAGE_NAME:%=%/) +PACKAGE_LIBS=$(MIQ_PRODLIB) +PACKAGE_DLLS=$(MIQ_PRODDLL) # Local setup - Location of configuration files, etc (tweaked at install time) -include $(MIQ)config.local-setup.mk @@ -80,10 +84,11 @@ CLANG_FORMAT_SOURCES=$(SOURCES) $(HDR_INSTALL) SYSCONFIG?=$(DESTDIR)/etc/ PREFIX?=$(DESTDIR)/usr/local/ PREFIX_BIN?=$(PREFIX)bin/ -PREFIX_LIB?=$(PREFIX)lib/ +PREFIX_LIB?=$(PREFIX)lib/$(PACKAGE_DIR) PREFIX_DLL?=$(PREFIX_LIB) -PREFIX_HDR?=$(PREFIX)include/ -PREFIX_SHARE?=$(PREFIX)share/ +PREFIX_HDR?=$(PREFIX)include/$(PACKAGE_DIR) +PREFIX_SHARE?=$(PREFIX)share/$(PACKAGE_DIR) +PREFIX_PKGCONFIG=$(PREFIX)share/pkgconfig/ #------------------------------------------------------------------------------ diff --git a/rules.mk b/rules.mk index 0f9714a..93917fc 100644 --- a/rules.mk +++ b/rules.mk @@ -68,6 +68,8 @@ MIQ_LDFLAGS= $(LDFLAGS) \ $(LDFLAGS_VARIANT_$(VARIANT)) \ $(LDFLAGS_$*) +MIQ_PACKAGE= $(PACKAGE_NAME:%=$(MIQ_OBJDIR)%.pc) + MIQ_INSTALL= $(TO_INSTALL:%=%.install) \ $(MIQ_OUTEXE:%=%.install_exe) \ $(MIQ_OUTLIB:%=%.install_lib) \ @@ -75,7 +77,9 @@ MIQ_INSTALL= $(TO_INSTALL:%=%.install) \ $(EXE_INSTALL:%=%.install_exe) \ $(LIB_INSTALL:%=%.install_lib) \ $(DLL_INSTALL:%=%.install_dll) \ - $(HDR_INSTALL:%=%.install_hdr) + $(HDR_INSTALL:%=%.install_hdr) \ + $(SHR_INSTALL:%=%.install_shr) \ + $(MIQ_PACKAGE:%=%.install_pc) MIQ_SOURCES= $(SOURCES) \ $(SOURCES_BUILDENV_$(BUILDENV)) \ @@ -543,6 +547,35 @@ benchmark: $(BENCHMARKS:%=%.benchmark) $(PRINT_INSTALL) $(INSTALL) $* $(PREFIX_DLL) %.install_hdr: $(PREFIX_HDR).mkdir-only $(PRINT_INSTALL) $(INSTALL) $* $(PREFIX_HDR) +%.install_shr: $(PREFIX_SHR).mkdir-only + $(PRINT_INSTALL) $(INSTALL) $* $(PREFIX_SHR) +%.install_pc: $(PREFIX_PKGCONFIG).mkdir-only % + $(PRINT_INSTALL) $(INSTALL) $* $(PREFIX_PKGCONFIG) + + +#------------------------------------------------------------------------------ +# Generation of pkg-config data file +#------------------------------------------------------------------------------ + +MIQ_PACKAGELIBS=$(PACKAGE_LIBS:%.lib=$(LINK_LIB_OPT)%) \ + $(PACKAGE_DLLS:%.dll=$(LINK_DLL_OPT)%) +MIQ_GENPC= \ + (echo 'prefix=$(PREFIX)' ;\ + echo 'exec_prefix=$${prefix}' ;\ + echo 'libdir=$(PREFIX_LIB)' ;\ + echo 'includedir=$(PREFIX_HDR)' ;\ + echo 'Name: $(PACKAGE_NAME)' ;\ + echo 'Description: $(PACKAGE_DESCRIPTION)' ;\ + echo 'Version: $(PACKAGE_VERSION)' ;\ + echo 'URL: $(PACKAGE_URL)' ;\ + echo 'Requires: $(PACKAGE_REQUIRES)' ;\ + echo 'Conflicts: $(PACKAGE_CONFLICTS)' ;\ + echo 'Libs: -L$${libdir} $(MIQ_PACKAGELIBS)' ;\ + echo 'Cflags: -I$${includedir}' ) + +$(MIQ_PACKAGE): $(MIQ_MAKEDEPS) + $(PRINT_BUILD) $(MIQ_GENPC) > $@ + #------------------------------------------------------------------------------ # Clang format