curly/Makefile

71 lines
1.4 KiB
Makefile
Raw Normal View History

2023-02-09 17:04:18 +01:00
include premake.make
2020-11-08 13:26:54 +01:00
2020-09-01 16:12:41 +02:00
BIN := $(shell basename $$(pwd))
2023-02-09 17:04:18 +01:00
MANSECTION ?= 1
2020-09-01 16:12:41 +02:00
MANPAGE := $(BIN).$(MANSECTION)
2020-11-08 13:26:54 +01:00
SRCS := $(notdir $(wildcard src/*.cpp))
OBJS := $(SRCS:.cpp=.o)
2023-03-23 14:43:03 +01:00
DEPS := $(SRCS:.cpp=.d)
2020-09-01 16:12:41 +02:00
2020-11-08 13:26:54 +01:00
BUILDDIR := build/intermediates/
2020-09-01 16:12:41 +02:00
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
2023-02-09 17:04:18 +01:00
MANDIR ?= $(PREFIX)/man/man
2020-09-01 16:12:41 +02:00
CONFIGDIR ?= $(PREFIX)/etc
DATADIR ?= $(PREFIX)/share
DOCDIR ?= $(DATADIR)/$(BIN)/doc
2020-11-08 13:26:54 +01:00
CXX ?= g++
RM := /bin/rm -rf
2020-09-01 16:12:41 +02:00
INSTALL := /usr/bin/install -c
CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -g -std=c++17
2020-09-01 16:12:41 +02:00
ifeq ($(DEBUG),1)
CXXFLAGS += -D DEBUG -O0
CONFIG := debug
2020-09-01 16:12:41 +02:00
else
CXXFLAGS += -D NDEBUG -O3
CONFIG := release
2020-09-01 16:12:41 +02:00
endif
OUTDIR := build/$(CONFIG)/
2020-11-08 13:26:54 +01:00
vpath %.cpp src
vpath %.d $(BUILDDIR)
vpath %.o $(BUILDDIR)
2023-02-09 17:04:18 +01:00
.PHONY: all clean install prebuild test dist-clean
2020-09-01 16:12:41 +02:00
all: prebuild $(OUTDIR)$(BIN)
2020-09-01 16:12:41 +02:00
prebuild:
@mkdir -p $(BUILDDIR) $(OUTDIR)
2020-09-01 16:12:41 +02:00
2023-02-09 17:04:18 +01:00
$(OUTDIR)$(BIN): $(OBJS)
2024-03-28 15:25:08 +01:00
$(CXX) -o $(OUTDIR)$(BIN) $(LDFLAGS) $(addprefix $(BUILDDIR),$(OBJS)) $(LDLIBS)
@ln -sf $(OUTDIR)$(BIN) $(BIN)
2020-09-01 16:12:41 +02:00
2023-02-09 17:04:18 +01:00
%.o %.d: %.cpp
2020-11-08 13:26:54 +01:00
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
@mv $@ $*.d $(BUILDDIR)
2020-09-01 16:12:41 +02:00
2023-03-23 14:43:03 +01:00
-include $(addprefix $(BUILDDIR), $(DEPS))
2020-09-01 16:12:41 +02:00
2023-02-09 17:04:18 +01:00
test:
$(MAKE) -C tests && tests/tests
2020-09-01 16:12:41 +02:00
clean:
2023-02-09 17:04:18 +01:00
$(RM) $(BUILDDIR)
$(MAKE) -C tests clean
dist-clean:
$(RM) build $(BIN)
2023-02-09 17:04:18 +01:00
$(MAKE) -C tests clean
2020-09-01 16:12:41 +02:00
2023-02-09 17:04:18 +01:00
install:
2020-09-01 16:12:41 +02:00
$(INSTALL) -d $(BINDIR)
$(INSTALL) $(OUTDIR)$(BIN) $(BINDIR)
2020-09-01 16:12:41 +02:00
$(INSTALL) -d $(MANDIR)$(MANSECTION)
2023-02-09 17:04:18 +01:00
$(INSTALL) -m 0644 $(MANPAGE) $(MANDIR)$(MANSECTION)