libscio/Makefile

72 lines
1.5 KiB
Makefile
Raw Normal View History

2020-02-14 18:17:17 +01:00
LIBNAME := $(shell basename $$(pwd))
MAJOR := 1
2020-07-11 10:07:37 +02:00
MINOR := 1.0
2020-02-14 18:17:17 +01:00
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
LINKERNAME := $(LIBNAME).dylib
SONAME := $(LIBNAME).$(MAJOR).dylib
REALNAME := $(LINKERNAME)
else
LINKERNAME := $(LIBNAME).so
SONAME := $(LINKERNAME).$(MAJOR)
REALNAME := $(SONAME).$(MINOR)
endif
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
LIBDIR ?= $(PREFIX)/lib
INCLUDEDIR ?= $(PREFIX)/include
DATADIR ?= $(PREFIX)/share
MANDIR ?= $(DATADIR)/man
SRCS := $(wildcard *.cpp)
OBJS := $(subst .cpp,.o,$(SRCS))
DEPS := $(subst .cpp,.d,$(SRCS))
CXX ?= g++
CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -g -std=c++17 -fPIC
2020-02-14 18:17:17 +01:00
ifeq ($(DEBUG),1)
CXXFLAGS += -D DEBUG -O0
else
CXXFLAGS += -D NDEBUG -O3
endif
2020-03-17 17:21:14 +01:00
LDLIBS := -lscerror
2020-02-14 18:17:17 +01:00
RM := /bin/rm -f
INSTALL := /usr/bin/install -c
all: $(REALNAME)
$(REALNAME): $(OBJS) $(DEPS)
ifeq ($(UNAME_S),Darwin)
$(CXX) -dynamiclib -o $(REALNAME) -current_version $(MAJOR) -compatibility_version $(MINOR) $(LDFLAGS) $(LDLIBS) $(OBJS)
else
$(CXX) -g -shared -Wl,-soname,$(SONAME) -o $(REALNAME) $(LDFLAGS) $(LDLIBS) $(OBJS)
endif
%.o: %.cpp %.d Makefile
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
-include *.d
%.d: ;
.PHONY: clean install
clean:
$(RM) $(OBJS) $(DEPS) $(REALNAME)
2020-02-14 18:17:17 +01:00
install: $(REALNAME) $(LIBNAME).hpp
$(INSTALL) -m 644 $(REALNAME) $(LIBDIR)
$(INSTALL) -m 644 $(LIBNAME).hpp $(INCLUDEDIR)
ifeq ($(UNAME_S),Darwin)
cd $(LIBDIR) && ln -sf $(REALNAME) $(SONAME)
else
ldconfig
cd $(LIBDIR) && ln -sf $(SONAME) $(LINKERNAME)
endif