BIN := $(shell basename $$(pwd)) MANSECTION := 1 MANPAGE := $(BIN).$(MANSECTION) SRCS := $(wildcard *.cpp) OBJS := $(subst .cpp,.o,$(SRCS)) DEPS := $(subst .cpp,.d,$(SRCS)) CODE := $(wildcard code/*.txt) CXX ?= g++ PKG_CONFIG ?= pkg-config PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin CONFIGDIR ?= $(PREFIX)/etc DATADIR ?= $(PREFIX)/share MANDIR ?= $(DATADIR)/man/man DOCDIR ?= $(DATADIR)/$(BIN)/doc RM := /bin/rm -f INSTALL := /usr/bin/install -c CXXFLAGS := $(CXXFLAGS) -Wshadow -Wall -Wpedantic -Wextra -g -fno-strict-aliasing -std=c++17 -pthread ifeq ($(DEBUG),1) CXXFLAGS += -D DEBUG -O0 else CXXFLAGS += -D NDEBUG -O3 endif LDLIBS := -lm -lpthread -lcurl -lsclogging .PHONY: all sync clean install all: $(BIN) sync $(BIN): $(OBJS) $(DEPS) $(CXX) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $(BIN) %.o: %.cpp %.d Makefile $(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $< -include *.d %.d: ; sync: $(CODE) rsync -av code/ pi@www.swiftcoder.nl:/var/www/html/cpp1/ clean: $(RM) $(OBJS) $(DEPS) $(BIN) install: $(BIN) $(INSTALL) -d $(BINDIR) $(INSTALL) $(BIN) $(BINDIR) $(INSTALL) -d $(MANDIR)$(MANSECTION) $(INSTALL) $(MANPAGE) $(MANDIR)$(MANSECTION)