69 lines
1.4 KiB
Makefile
69 lines
1.4 KiB
Makefile
include premake.make
|
|
|
|
BIN := $(shell basename $$(pwd))
|
|
|
|
MANSECTION := 1
|
|
MANPAGE := $(BIN).$(MANSECTION)
|
|
|
|
SRCS := $(notdir $(wildcard src/*.cpp))
|
|
OBJS := $(SRCS:.cpp=.o)
|
|
DEPS := $(SRCS:.cpp=.d)
|
|
|
|
BUILDDIR := build/intermediates/
|
|
PREFIX ?= /usr/local
|
|
BINDIR ?= $(PREFIX)/bin
|
|
CONFIGDIR ?= $(PREFIX)/etc
|
|
DATADIR ?= $(PREFIX)/share
|
|
MANDIR ?= $(DATADIR)/man/man
|
|
DOCDIR ?= $(DATADIR)/$(BIN)/doc
|
|
|
|
CXX ?= g++
|
|
RM := /bin/rm -rf
|
|
INSTALL := /usr/bin/install -c
|
|
|
|
CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -g -std=c++17
|
|
ifeq ($(DEBUG),1)
|
|
CXXFLAGS += -D DEBUG -O0
|
|
CONFIG := debug
|
|
else
|
|
CXXFLAGS += -D NDEBUG -O3
|
|
CONFIG := release
|
|
endif
|
|
OUTDIR := build/$(CONFIG)/
|
|
|
|
vpath %.cpp src
|
|
vpath %.d $(BUILDDIR)
|
|
vpath %.o $(BUILDDIR)
|
|
|
|
.PHONY: all clean install prebuild test
|
|
|
|
all: prebuild $(OUTDIR)$(BIN)
|
|
|
|
prebuild:
|
|
@mkdir -p $(BUILDDIR) $(OUTDIR)
|
|
|
|
$(OUTDIR)$(BIN): $(OBJS)
|
|
$(CXX) $(addprefix $(BUILDDIR),$(OBJS)) $(LDFLAGS) $(LDLIBS) -o $(OUTDIR)$(BIN)
|
|
@ln -sf $(OUTDIR)$(BIN) $(BIN)
|
|
|
|
%.o %.d: %.cpp
|
|
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
|
|
@mv $@ $*.d $(BUILDDIR)
|
|
|
|
-include $(BUILDDIR)$(DEPS)
|
|
|
|
test:
|
|
$(MAKE) -C tests && tests/tests
|
|
|
|
clean:
|
|
$(RM) build $(BIN)
|
|
$(MAKE) -C tests clean
|
|
|
|
install: $(OUTDIR)$(BIN)
|
|
$(INSTALL) -d $(BINDIR)
|
|
$(INSTALL) $(OUTDIR)$(BIN) $(BINDIR)
|
|
$(INSTALL) -d $(MANDIR)$(MANSECTION)
|
|
$(INSTALL) -m 0644 $(MANPAGE) $(MANDIR)$(MANSECTION)
|
|
$(INSTALL) -d $(DATADIR)/$(BIN)
|
|
$(INSTALL) -m 0644 numerals.db $(DATADIR)/$(BIN)
|