Compare commits

...

9 Commits

Author SHA1 Message Date
Xavier Del Campo Romero 7be16e6e5c
CMakeLists.txt: Fix missing parameter names
VERSION must be indicated when passing a version string to project().
Also, LANGUAGES must be also be passed when the language name is not the
only argument to project() (apart from the project name itself).
2023-11-10 14:43:39 +01:00
Xavier Del Campo Romero e7b84e0bf6
Makefile: Set -O1 2023-10-25 22:06:23 +02:00
Xavier Del Campo Romero 67bc69c53e
Makefile: Adhere to GNU Make directory variables 2023-10-25 22:06:23 +02:00
Xavier Del Campo Romero 1a303c69cd
Makefile: Build dynstr also as a shared library 2023-10-25 21:47:34 +02:00
Xavier Del Campo Romero b2ded0cd62
Makefile: Update copyright year 2023-10-25 21:47:33 +02:00
Xavier Del Campo Romero de0d0e9fab
CMakeLists.txt: set project VERSION 2023-10-25 14:09:16 +02:00
Xavier Del Campo Romero c4979825b7
CMakeLists.txt: Stop forcing STATIC library
Distribution packagers might prefer dynstr as a shared object.
2023-10-16 01:16:32 +02:00
Xavier Del Campo Romero cc9eae6d01
Makefile: Fix wrong installation directory
Libraries are meant to be placed in $PREFIX/lib, and not $PREFIX/bin.
2023-10-16 00:38:23 +02:00
Xavier Del Campo Romero ef14ee964a
Install .pc file 2023-10-16 00:38:06 +02:00
4 changed files with 57 additions and 15 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
*.o
*.obj
*.a
*.so
*.so.*

View File

@ -12,8 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.0)
project(dynstr C)
add_library(${PROJECT_NAME} STATIC "dynstr.c")
project(dynstr LANGUAGES C VERSION 0.1.0)
add_library(${PROJECT_NAME} "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)

View File

@ -1,4 +1,4 @@
# Copyright 2020 Xavier Del Campo Romero
# Copyright 2020-2023 Xavier Del Campo Romero
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -14,24 +14,47 @@
.POSIX:
PREFIX = /usr/local
PROJECT = libdynstr.a
CFLAGS = -Iinclude
prefix = /usr/local
exec_prefix = $(prefix)
includedir = $(prefix)/include
libdir = $(exec_prefix)/lib
pkgcfgdir = $(libdir)/pkgconfig
PROJECT = libdynstr
MAJOR_VERSION = 0
MINOR_VERSION = 1
PATCH_VERSION = 0
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_VERSION)
PROJECT_A = $(PROJECT).a
PROJECT_SO = $(PROJECT).so.$(VERSION)
PROJECT_SO_FQ = $(PROJECT).so.$(MAJOR_VERSION)
PROJECT_SO_NV = $(PROJECT).so
CFLAGS = -Iinclude -fPIC -O1
LDFLAGS = -shared
DEPS = \
dynstr.o
all: $(PROJECT)
all: $(PROJECT_A) $(PROJECT_SO)
install: $(PROJECT)
mkdir -p $(PREFIX)/include
cp include/dynstr.h $(PREFIX)/include
chmod 0644 $(PREFIX)/include/dynstr.h
mkdir -p $(PREFIX)/bin
cp $(PROJECT) $(PREFIX)/bin
chmod 0755 $(PREFIX)/bin/$(PROJECT)
install: all $(pkgcfgdir)/dynstr.pc
mkdir -p $(DESTDIR)$(includedir)
cp include/dynstr.h $(DESTDIR)$(includedir)
chmod 0644 $(DESTDIR)$(includedir)/dynstr.h
mkdir -p $(DESTDIR)$(libdir)
cp $(PROJECT_A) $(PROJECT_SO) $(DESTDIR)$(libdir)
chmod 0755 $(libdir)/$(PROJECT_A) $(DESTDIR)$(libdir)/$(PROJECT_SO)
ln -fs $(DESTDIR)$(libdir)/$(PROJECT_SO) $(DESTDIR)$(libdir)/$(PROJECT_SO_FQ)
ln -fs $(DESTDIR)$(libdir)/$(PROJECT_SO) $(DESTDIR)$(libdir)/$(PROJECT_SO_NV)
clean:
rm -f $(DEPS)
$(PROJECT): $(DEPS)
$(PROJECT_A): $(DEPS)
$(AR) $(ARFLAGS) $@ $(DEPS)
$(PROJECT_SO): $(DEPS)
$(CC) $(LDFLAGS) $(DEPS) -o $@
$(pkgcfgdir)/dynstr.pc: dynstr.pc
mkdir -p $(DESTDIR)$(pkgcfgdir)
sed -e 's,/usr/local,$(DESTDIR)$(prefix),' $< > $@
chmod 0644 $@

11
dynstr.pc Normal file
View File

@ -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