From ef14ee964ac098888a662b0a98fd88869d255d86 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Mon, 16 Oct 2023 00:13:24 +0200 Subject: Install .pc file --- CMakeLists.txt | 6 ++++++ Makefile | 9 ++++++++- dynstr.pc | 11 +++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 dynstr.pc diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b21447..91609ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,3 +17,9 @@ add_library(${PROJECT_NAME} STATIC "dynstr.c") target_include_directories(${PROJECT_NAME} PUBLIC "include") install(TARGETS ${PROJECT_NAME}) install(DIRECTORY include/ TYPE INCLUDE) +file(READ ${CMAKE_CURRENT_LIST_DIR}/dynstr.pc dynstr_pc) +string(REPLACE /usr/local ${CMAKE_INSTALL_PREFIX} dynstr_repl_pc ${dynstr_pc}) +file(WRITE ${CMAKE_BINARY_DIR}/dynstr.pc ${dynstr_repl_pc}) +include(GNUInstallDirs) +install(FILES ${CMAKE_BINARY_DIR}/dynstr.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/Makefile b/Makefile index 784e171..f032535 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,8 @@ .POSIX: PREFIX = /usr/local +DST = $(PREFIX)/lib +PC_DST = $(DST)/pkgconfig PROJECT = libdynstr.a CFLAGS = -Iinclude DEPS = \ @@ -22,7 +24,7 @@ DEPS = \ all: $(PROJECT) -install: $(PROJECT) +install: $(PROJECT) $(PC_DST)/dynstr.pc mkdir -p $(PREFIX)/include cp include/dynstr.h $(PREFIX)/include chmod 0644 $(PREFIX)/include/dynstr.h @@ -35,3 +37,8 @@ clean: $(PROJECT): $(DEPS) $(AR) $(ARFLAGS) $@ $(DEPS) + +$(PC_DST)/dynstr.pc: dynstr.pc + mkdir -p $(PC_DST) + sed -e 's,/usr/local,$(PREFIX),' $< > $@ + chmod 0644 $@ diff --git a/dynstr.pc b/dynstr.pc new file mode 100644 index 0000000..0f6f48a --- /dev/null +++ b/dynstr.pc @@ -0,0 +1,11 @@ +prefix=/usr/local +exec_prefix=${prefix} +includedir=${prefix}/include +libdir=${exec_prefix}/lib + +Name: dynstr +Url: https://gitea.privatedns.org/xavi/dynstr +Description: Minimal library that provides dynamic strings using plain C99. +Version: 0.1.0 +Cflags: -I${includedir} +Libs: -L${libdir} -ldynstr -- cgit v1.2.3