Compare commits

...

6 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
3 changed files with 37 additions and 19 deletions

2
.gitignore vendored
View File

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

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.0)
project(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})

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,31 +14,47 @@
.POSIX:
PREFIX = /usr/local
DST = $(PREFIX)/lib
PC_DST = $(DST)/pkgconfig
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) $(PC_DST)/dynstr.pc
mkdir -p $(PREFIX)/include
cp include/dynstr.h $(PREFIX)/include
chmod 0644 $(PREFIX)/include/dynstr.h
mkdir -p $(DST)
cp $(PROJECT) $(DST)
chmod 0755 $(DST)/$(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)
$(PC_DST)/dynstr.pc: dynstr.pc
mkdir -p $(PC_DST)
sed -e 's,/usr/local,$(PREFIX),' $< > $@
$(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 $@