aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-10-16 00:13:24 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-10-16 00:38:06 +0200
commitef14ee964ac098888a662b0a98fd88869d255d86 (patch)
tree0080fe7b5549180ecb5b229d2015fe25c401a7ae
parentd0d843b7046ced76336604450f8eb78b4decfa09 (diff)
downloaddynstr-ef14ee964ac098888a662b0a98fd88869d255d86.tar.gz
Install .pc file
-rw-r--r--CMakeLists.txt6
-rw-r--r--Makefile9
-rw-r--r--dynstr.pc11
3 files changed, 25 insertions, 1 deletions
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