From 3d7c9baf3dff3c959d7ed8d8717ae7e9f805de95 Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Tue, 21 Dec 2021 10:58:31 +0100 Subject: [PATCH] Moved versioning to premake; added OpenBSD support --- Makefile | 28 +++++++++++++++++++--------- premake.make | 4 ++++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 4d81130..22f5397 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,22 @@ include premake.make LIBNAME := $(shell basename $$(pwd)) -MAJOR := 1 -MINOR := 0.0 - UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) LINKERNAME := $(LIBNAME).dylib SONAME := $(LIBNAME).$(MAJOR).dylib REALNAME := $(LINKERNAME) -else +endif +ifeq ($(UNAME_S),OpenBSD) + REALNAME := $(LIBNAME).so.$(MAJOR).$(MINOR) +endif +ifeq ($(UNAME_S),Linux) LINKERNAME := $(LIBNAME).so SONAME := $(LINKERNAME).$(MAJOR) - REALNAME := $(SONAME).$(MINOR) + REALNAME := $(SONAME).$(MINOR).$(PATCH) endif +STATICLIB := $(LIBNAME).a BUILDDIR := build/intermediates/ PREFIX ?= /usr/local @@ -33,7 +35,7 @@ HDRS := $(wildcard src/*.hpp) CXX ?= g++ -CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -g -std=c++17 -fPIC +CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -g -fno-strict-aliasing -std=c++17 -fPIC ifeq ($(DEBUG),1) CXXFLAGS += -D DEBUG -O0 CONFIG := debug @@ -52,7 +54,7 @@ vpath %.o $(BUILDDIR) .PHONY: all clean install prebuild test -all: prebuild $(OUTDIR)$(REALNAME) +all: prebuild $(OUTDIR)$(REALNAME) $(OUTDIR)$(STATICLIB) prebuild: @mkdir -p $(BUILDDIR) $(OUTDIR) @@ -60,7 +62,11 @@ prebuild: $(OUTDIR)$(REALNAME): $(OBJS) $(DEPS) ifeq ($(UNAME_S),Darwin) $(CXX) -dynamiclib -o $(OUTDIR)$(REALNAME) -current_version $(MAJOR) -compatibility_version $(MINOR) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS)) -else +endif +ifeq ($(UNAME_S),OpenBSD) + $(CXX) -g -shared -Wl,-soname,$(REALNAME) -o $(OUTDIR)$(REALNAME) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS)) +endif +ifeq ($(UNAME_S),Linux) $(CXX) -g -shared -Wl,-soname,$(SONAME) -o $(OUTDIR)$(REALNAME) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS)) endif @@ -72,6 +78,9 @@ endif %.d: ; +$(OUTDIR)$(STATICLIB): $(OBJS) + ar r $(OUTDIR)$(STATICLIB) $(addprefix $(BUILDDIR),$(OBJS)) + $(LIBNAME).hpp: $(HDRS) @echo updating build/$(LIBNAME).hpp @cp /dev/null build/$(LIBNAME).hpp @@ -94,7 +103,8 @@ install: $(OUTDIR)$(REALNAME) $(LIBNAME).hpp $(INSTALL) -m 644 build/$(LIBNAME).hpp $(INCLUDEDIR) ifeq ($(UNAME_S),Darwin) cd $(LIBDIR) && ln -sf $(REALNAME) $(SONAME) -else +endif +ifeq ($(UNAME_S),Linux) ldconfig cd $(LIBDIR) && ln -sf $(SONAME) $(LINKERNAME) endif diff --git a/premake.make b/premake.make index ba34652..1c9e144 100644 --- a/premake.make +++ b/premake.make @@ -1 +1,5 @@ LDLIBS := -lcairo -lscnumerics + +MAJOR := 1 +MINOR := 0 +PATCH := 0