Fixed Makfile

This commit is contained in:
Bob Polis 2023-02-09 17:04:18 +01:00
parent b5b369b080
commit 96dba49bf1

View File

@ -1,20 +1,19 @@
LDLIBS := -lm -lpthread -lcurl -lsclogging include premake.make
BIN := $(shell basename $$(pwd)) BIN := $(shell basename $$(pwd))
MANSECTION := 1 MANSECTION ?= 1
MANPAGE := $(BIN).$(MANSECTION) MANPAGE := $(BIN).$(MANSECTION)
SRCS := $(notdir $(wildcard src/*.cpp)) SRCS := $(notdir $(wildcard src/*.cpp))
OBJS := $(SRCS:.cpp=.o) OBJS := $(SRCS:.cpp=.o)
DEPS := $(SRCS:.cpp=.d)
BUILDDIR := build/intermediates/ BUILDDIR := build/intermediates/
PREFIX ?= /usr/local PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/man/man
CONFIGDIR ?= $(PREFIX)/etc CONFIGDIR ?= $(PREFIX)/etc
DATADIR ?= $(PREFIX)/share DATADIR ?= $(PREFIX)/share
MANDIR ?= $(DATADIR)/man/man
DOCDIR ?= $(DATADIR)/$(BIN)/doc DOCDIR ?= $(DATADIR)/$(BIN)/doc
CXX ?= g++ CXX ?= g++
@ -35,30 +34,36 @@ vpath %.cpp src
vpath %.d $(BUILDDIR) vpath %.d $(BUILDDIR)
vpath %.o $(BUILDDIR) vpath %.o $(BUILDDIR)
.PHONY: all clean install prebuild .PHONY: all clean install prebuild test dist-clean
all: prebuild $(OUTDIR)$(BIN) all: prebuild $(OUTDIR)$(BIN)
prebuild: prebuild:
@mkdir -p $(BUILDDIR) $(OUTDIR) @mkdir -p $(BUILDDIR) $(OUTDIR)
$(OUTDIR)$(BIN): $(OBJS) $(DEPS) $(OUTDIR)$(BIN): $(OBJS)
$(CXX) $(addprefix $(BUILDDIR),$(OBJS)) $(LDFLAGS) $(LDLIBS) -o $(OUTDIR)$(BIN) $(CXX) -o $(OUTDIR)$(BIN) $(LDFLAGS) $(LDLIBS) $(addprefix $(BUILDDIR),$(OBJS))
@ln -sf $(OUTDIR)$(BIN) $(BIN) @ln -sf $(OUTDIR)$(BIN) $(BIN)
%.o: %.cpp %.d %.o %.d: %.cpp
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $< $(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
@mv $@ $*.d $(BUILDDIR) @mv $@ $*.d $(BUILDDIR)
-include $(BUILDDIR)*.d -include $(BUILDDIR)$(SRCS:.cpp=.d)
%.d: ; test:
$(MAKE) -C tests && tests/tests
clean: 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) -d $(BINDIR)
$(INSTALL) $(OUTDIR)$(BIN) $(BINDIR) $(INSTALL) $(OUTDIR)$(BIN) $(BINDIR)
$(INSTALL) -d $(MANDIR)$(MANSECTION) $(INSTALL) -d $(MANDIR)$(MANSECTION)
$(INSTALL) $(MANPAGE) $(MANDIR)$(MANSECTION) $(INSTALL) -m 0644 $(MANPAGE) $(MANDIR)$(MANSECTION)