sources now taken from src directory

This commit is contained in:
Bob Polis 2020-11-08 13:26:54 +01:00
parent 5e9b21de30
commit f8ea704231

View File

@ -1,17 +1,15 @@
LDLIBS := -lm -lpthread -lcurl -lsclogging
BIN := $(shell basename $$(pwd)) BIN := $(shell basename $$(pwd))
MANSECTION := 1 MANSECTION := 1
MANPAGE := $(BIN).$(MANSECTION) MANPAGE := $(BIN).$(MANSECTION)
SRCS := $(notdir $(wildcard src/*.cpp))
OBJS := $(SRCS:.cpp=.o)
DEPS := $(SRCS:.cpp=.d)
BUILDDIR := build/intermediates/ BUILDDIR := build/intermediates/
SRCS := $(wildcard *.cpp)
OBJS := $(addprefix $(BUILDDIR),$(SRCS:.cpp=.o))
DEPS := $(addprefix $(BUILDDIR),$(SRCS:.cpp=.d))
CXX ?= g++
PKG_CONFIG ?= pkg-config
PREFIX ?= /usr/local PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin BINDIR ?= $(PREFIX)/bin
CONFIGDIR ?= $(PREFIX)/etc CONFIGDIR ?= $(PREFIX)/etc
@ -19,6 +17,7 @@ DATADIR ?= $(PREFIX)/share
MANDIR ?= $(DATADIR)/man/man MANDIR ?= $(DATADIR)/man/man
DOCDIR ?= $(DATADIR)/$(BIN)/doc DOCDIR ?= $(DATADIR)/$(BIN)/doc
CXX ?= g++
RM := /bin/rm -rf RM := /bin/rm -rf
INSTALL := /usr/bin/install -c INSTALL := /usr/bin/install -c
@ -30,11 +29,12 @@ else
CXXFLAGS += -D NDEBUG -O3 CXXFLAGS += -D NDEBUG -O3
CONFIG := release CONFIG := release
endif endif
LDLIBS := -lm -lpthread -lcurl -lsclogging
OUTDIR := build/$(CONFIG)/ OUTDIR := build/$(CONFIG)/
vpath %.cpp src
vpath %.d $(BUILDDIR)
vpath %.o $(BUILDDIR)
.PHONY: all clean install prebuild .PHONY: all clean install prebuild
all: prebuild $(OUTDIR)$(BIN) all: prebuild $(OUTDIR)$(BIN)
@ -43,15 +43,16 @@ prebuild:
@mkdir -p $(BUILDDIR) $(OUTDIR) @mkdir -p $(BUILDDIR) $(OUTDIR)
$(OUTDIR)$(BIN): $(OBJS) $(DEPS) $(OUTDIR)$(BIN): $(OBJS) $(DEPS)
$(CXX) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $(OUTDIR)$(BIN) $(CXX) $(addprefix $(BUILDDIR),$(OBJS)) $(LDFLAGS) $(LDLIBS) -o $(OUTDIR)$(BIN)
@ln -sf $(OUTDIR)$(BIN) $(BIN) @ln -sf $(OUTDIR)$(BIN) $(BIN)
$(BUILDDIR)%.o: %.cpp $(BUILDDIR)%.d Makefile %.o: %.cpp %.d
cd $(BUILDDIR) && $(CXX) $(CXXFLAGS) -MMD -MP -MT $(notdir $@) -MF $*.d -c ../../$< && cd ../.. $(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
@mv $@ $*.d $(BUILDDIR)
-include $(BUILDDIR)*.d -include $(BUILDDIR)*.d
$(BUILDDIR)%.d: ; %.d: ;
clean: clean:
$(RM) build $(BIN) $(RM) build $(BIN)