Moved versioning to premake; added OpenBSD support

This commit is contained in:
Bob Polis 2021-12-21 10:54:39 +01:00
parent bebb6e4393
commit c2e8f440b4
2 changed files with 23 additions and 9 deletions

View File

@ -1,20 +1,22 @@
include premake.make include premake.make
LIBNAME := $(shell basename $$(pwd)) LIBNAME := $(shell basename $$(pwd))
MAJOR := 1
MINOR := 0.0
UNAME_S := $(shell uname -s) UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin) ifeq ($(UNAME_S),Darwin)
LINKERNAME := $(LIBNAME).dylib LINKERNAME := $(LIBNAME).dylib
SONAME := $(LIBNAME).$(MAJOR).dylib SONAME := $(LIBNAME).$(MAJOR).dylib
REALNAME := $(LINKERNAME) REALNAME := $(LINKERNAME)
else endif
ifeq ($(UNAME_S),OpenBSD)
REALNAME := $(LIBNAME).so.$(MAJOR).$(MINOR)
endif
ifeq ($(UNAME_S),Linux)
LINKERNAME := $(LIBNAME).so LINKERNAME := $(LIBNAME).so
SONAME := $(LINKERNAME).$(MAJOR) SONAME := $(LINKERNAME).$(MAJOR)
REALNAME := $(SONAME).$(MINOR) REALNAME := $(SONAME).$(MINOR).$(PATCH)
endif endif
STATICLIB := $(LIBNAME).a
BUILDDIR := build/intermediates/ BUILDDIR := build/intermediates/
PREFIX ?= /usr/local PREFIX ?= /usr/local
@ -33,7 +35,7 @@ HDRS := $(wildcard src/*.hpp)
CXX ?= g++ 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) ifeq ($(DEBUG),1)
CXXFLAGS += -D DEBUG -O0 CXXFLAGS += -D DEBUG -O0
CONFIG := debug CONFIG := debug
@ -52,7 +54,7 @@ vpath %.o $(BUILDDIR)
.PHONY: all clean install prebuild test .PHONY: all clean install prebuild test
all: prebuild $(OUTDIR)$(REALNAME) all: prebuild $(OUTDIR)$(REALNAME) $(OUTDIR)$(STATICLIB)
prebuild: prebuild:
@mkdir -p $(BUILDDIR) $(OUTDIR) @mkdir -p $(BUILDDIR) $(OUTDIR)
@ -60,7 +62,11 @@ prebuild:
$(OUTDIR)$(REALNAME): $(OBJS) $(DEPS) $(OUTDIR)$(REALNAME): $(OBJS) $(DEPS)
ifeq ($(UNAME_S),Darwin) ifeq ($(UNAME_S),Darwin)
$(CXX) -dynamiclib -o $(OUTDIR)$(REALNAME) -current_version $(MAJOR) -compatibility_version $(MINOR) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS)) $(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)) $(CXX) -g -shared -Wl,-soname,$(SONAME) -o $(OUTDIR)$(REALNAME) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS))
endif endif
@ -72,6 +78,9 @@ endif
%.d: ; %.d: ;
$(OUTDIR)$(STATICLIB): $(OBJS)
ar r $(OUTDIR)$(STATICLIB) $(addprefix $(BUILDDIR),$(OBJS))
$(LIBNAME).hpp: $(HDRS) $(LIBNAME).hpp: $(HDRS)
@echo updating build/$(LIBNAME).hpp @echo updating build/$(LIBNAME).hpp
@cp /dev/null 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) $(INSTALL) -m 644 build/$(LIBNAME).hpp $(INCLUDEDIR)
ifeq ($(UNAME_S),Darwin) ifeq ($(UNAME_S),Darwin)
cd $(LIBDIR) && ln -sf $(REALNAME) $(SONAME) cd $(LIBDIR) && ln -sf $(REALNAME) $(SONAME)
else endif
ifeq ($(UNAME_S),Linux)
ldconfig ldconfig
cd $(LIBDIR) && ln -sf $(SONAME) $(LINKERNAME) cd $(LIBDIR) && ln -sf $(SONAME) $(LINKERNAME)
endif endif

View File

@ -1 +1,5 @@
LDLIBS := -lSDL2 -lSDL2_image LDLIBS := -lSDL2 -lSDL2_image
MAJOR := 1
MINOR := 0
PATCH := 0