From 96dba49bf1614d1467e3bcc7fef65c194fae2c9f Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Thu, 9 Feb 2023 17:04:18 +0100 Subject: [PATCH] Fixed Makfile --- Makefile | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index ea76715..1feb37f 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,19 @@ -LDLIBS := -lm -lpthread -lcurl -lsclogging +include premake.make BIN := $(shell basename $$(pwd)) -MANSECTION := 1 +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 +MANDIR ?= $(PREFIX)/man/man CONFIGDIR ?= $(PREFIX)/etc DATADIR ?= $(PREFIX)/share -MANDIR ?= $(DATADIR)/man/man DOCDIR ?= $(DATADIR)/$(BIN)/doc CXX ?= g++ @@ -35,30 +34,36 @@ vpath %.cpp src vpath %.d $(BUILDDIR) vpath %.o $(BUILDDIR) -.PHONY: all clean install prebuild +.PHONY: all clean install prebuild test dist-clean all: prebuild $(OUTDIR)$(BIN) prebuild: @mkdir -p $(BUILDDIR) $(OUTDIR) -$(OUTDIR)$(BIN): $(OBJS) $(DEPS) - $(CXX) $(addprefix $(BUILDDIR),$(OBJS)) $(LDFLAGS) $(LDLIBS) -o $(OUTDIR)$(BIN) +$(OUTDIR)$(BIN): $(OBJS) + $(CXX) -o $(OUTDIR)$(BIN) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS)) @ln -sf $(OUTDIR)$(BIN) $(BIN) -%.o: %.cpp %.d +%.o %.d: %.cpp $(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $< @mv $@ $*.d $(BUILDDIR) --include $(BUILDDIR)*.d +-include $(BUILDDIR)$(SRCS:.cpp=.d) -%.d: ; +test: + $(MAKE) -C tests && tests/tests clean: - $(RM) build $(BIN) + $(RM) $(BUILDDIR) + $(MAKE) -C tests clean -install: $(OUTDIR)$(BIN) +dist-clean: + $(RM) build $(BIN) + $(MAKE) -C tests clean + +install: $(INSTALL) -d $(BINDIR) $(INSTALL) $(OUTDIR)$(BIN) $(BINDIR) $(INSTALL) -d $(MANDIR)$(MANSECTION) - $(INSTALL) $(MANPAGE) $(MANDIR)$(MANSECTION) + $(INSTALL) -m 0644 $(MANPAGE) $(MANDIR)$(MANSECTION)