Replaced with new standard Makefile
This commit is contained in:
parent
9cdbeb283a
commit
24e224dc1d
39
Makefile
39
Makefile
@ -1,8 +1,9 @@
|
|||||||
include premake.make
|
include premake.make
|
||||||
|
|
||||||
LIBNAME := $(shell basename $$(pwd))
|
LIBNAME := $(shell basename $$(pwd))
|
||||||
MAJOR := 1
|
MAJOR ?= 1
|
||||||
MINOR := 0.0
|
MINOR ?= 0
|
||||||
|
PATCH ?= 0
|
||||||
|
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
|
|
||||||
@ -10,11 +11,16 @@ 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 +39,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,20 +58,23 @@ 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)
|
||||||
|
|
||||||
$(OUTDIR)$(REALNAME): $(OBJS) $(DEPS)
|
$(OUTDIR)$(REALNAME): $(OBJS) $(DEPS)
|
||||||
ifeq ($(UNAME_S),Darwin)
|
ifeq ($(UNAME_S),Darwin)
|
||||||
$(CXX) -dynamiclib -o $(OUTDIR)$(REALNAME) -current_version $(MAJOR) \
|
$(CXX) -dynamiclib -o $(OUTDIR)$(REALNAME) -current_version $(MAJOR) -compatibility_version $(MINOR) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS))
|
||||||
-compatibility_version $(MINOR) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS))
|
endif
|
||||||
else
|
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
|
||||||
|
|
||||||
%.o: %.cpp %.d
|
%.o: %.cpp %.d Makefile
|
||||||
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
|
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
|
||||||
@mv $@ $*.d $(BUILDDIR)
|
@mv $@ $*.d $(BUILDDIR)
|
||||||
|
|
||||||
@ -73,7 +82,10 @@ endif
|
|||||||
|
|
||||||
%.d: ;
|
%.d: ;
|
||||||
|
|
||||||
build/$(LIBNAME).hpp: $(HDRS)
|
$(OUTDIR)$(STATICLIB): $(OBJS)
|
||||||
|
ar r $(OUTDIR)$(STATICLIB) $(addprefix $(BUILDDIR),$(OBJS))
|
||||||
|
|
||||||
|
$(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
|
||||||
@for h in $(HDRS); \
|
@for h in $(HDRS); \
|
||||||
@ -88,14 +100,15 @@ clean:
|
|||||||
$(RM) build
|
$(RM) build
|
||||||
$(MAKE) -C tests clean
|
$(MAKE) -C tests clean
|
||||||
|
|
||||||
install: $(OUTDIR)$(REALNAME) build/$(LIBNAME).hpp
|
install: $(OUTDIR)$(REALNAME) $(LIBNAME).hpp
|
||||||
$(INSTALL) -d $(LIBDIR)
|
$(INSTALL) -d $(LIBDIR)
|
||||||
$(INSTALL) -m 644 $(OUTDIR)$(REALNAME) $(LIBDIR)
|
$(INSTALL) -m 644 $(OUTDIR)$(REALNAME) $(LIBDIR)
|
||||||
$(INSTALL) -d $(INCLUDEDIR)
|
$(INSTALL) -d $(INCLUDEDIR)
|
||||||
$(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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user