diff --git a/Makefile b/Makefile index a3c016f..f7026f1 100644 --- a/Makefile +++ b/Makefile @@ -21,24 +21,23 @@ STATICLIB := $(LIBNAME).a BUILDDIR := build/intermediates/ PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin +MANDIR ?= $(PREFIX)/man CONFIGDIR ?= $(PREFIX)/etc - CONFIG := debug INCLUDEDIR ?= $(PREFIX)/include LIBDIR ?= $(PREFIX)/lib DATADIR ?= $(PREFIX)/share -MANDIR ?= $(DATADIR)/man DOCDIR ?= $(DATADIR)/$(LIBNAME)/doc SRCS := $(notdir $(wildcard src/*.cpp)) OBJS := $(SRCS:.cpp=.o) -DEPS := $(SRCS:.cpp=.d) -HDRS := $(wildcard src/*.hpp) +HDRS ?= $(wildcard src/*.hpp) CXX ?= g++ CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -g -std=c++17 -fPIC ifeq ($(DEBUG),1) CXXFLAGS += -D DEBUG -O0 + CONFIG := debug else CXXFLAGS += -D NDEBUG -O3 CONFIG := release @@ -74,18 +73,23 @@ endif $(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $< @mv $@ $*.d $(BUILDDIR) --include $(BUILDDIR)$(DEPS) +-include $(BUILDDIR)$(SRCS:.cpp=.d) $(OUTDIR)$(STATICLIB): $(OBJS) ar r $(OUTDIR)$(STATICLIB) $(addprefix $(BUILDDIR),$(OBJS)) +ifeq ($(GENERATELIBHEADER),1) $(LIBNAME).hpp: $(HDRS) @echo updating build/$(LIBNAME).hpp @cp /dev/null build/$(LIBNAME).hpp @for h in $(HDRS); \ do \ - cat $$h >> build/$(LIBNAME).hpp; \ + sed '/@exclude/d' $$h >> build/$(LIBNAME).hpp; \ done +HEADERSRCDIR := build +else +HEADERSRCDIR := src +endif test: $(MAKE) -C tests && tests/tests @@ -94,11 +98,15 @@ clean: $(RM) build $(MAKE) -C tests clean -install: $(OUTDIR)$(REALNAME) $(LIBNAME).hpp +ifeq ($(GENERATELIBHEADER),1) +install: $(LIBNAME).hpp +else +install: +endif $(INSTALL) -d $(LIBDIR) $(INSTALL) -m 644 $(OUTDIR)$(REALNAME) $(LIBDIR) - $(INSTALL) -d $(INCLUDEDIR) - $(INSTALL) -m 644 build/$(LIBNAME).hpp $(INCLUDEDIR) + $(INSTALL) -d $(INCLUDEDIR)/$(LIBNAME) + $(INSTALL) -m 644 $(HEADERSRCDIR)/$(LIBNAME).hpp $(INCLUDEDIR) ifeq ($(UNAME_S),Darwin) cd $(LIBDIR) && ln -sf $(REALNAME) $(SONAME) endif