replaced Makefile with new one that makes build dir
This commit is contained in:
parent
34aaee7509
commit
9ef1ffc1c9
44
Makefile
44
Makefile
@ -3,10 +3,11 @@ BIN := $(shell basename $$(pwd))
|
|||||||
MANSECTION := 1
|
MANSECTION := 1
|
||||||
MANPAGE := $(BIN).$(MANSECTION)
|
MANPAGE := $(BIN).$(MANSECTION)
|
||||||
|
|
||||||
|
BUILDDIR := build/intermediates/
|
||||||
|
|
||||||
SRCS := $(wildcard *.cpp)
|
SRCS := $(wildcard *.cpp)
|
||||||
OBJS := $(subst .cpp,.o,$(SRCS))
|
OBJS := $(addprefix $(BUILDDIR),$(SRCS:.cpp=.o))
|
||||||
DEPS := $(subst .cpp,.d,$(SRCS))
|
DEPS := $(addprefix $(BUILDDIR),$(SRCS:.cpp=.d))
|
||||||
CODE := $(wildcard code/*.txt)
|
|
||||||
|
|
||||||
CXX ?= g++
|
CXX ?= g++
|
||||||
PKG_CONFIG ?= pkg-config
|
PKG_CONFIG ?= pkg-config
|
||||||
@ -18,44 +19,45 @@ DATADIR ?= $(PREFIX)/share
|
|||||||
MANDIR ?= $(DATADIR)/man/man
|
MANDIR ?= $(DATADIR)/man/man
|
||||||
DOCDIR ?= $(DATADIR)/$(BIN)/doc
|
DOCDIR ?= $(DATADIR)/$(BIN)/doc
|
||||||
|
|
||||||
RM := /bin/rm -f
|
RM := /bin/rm -rf
|
||||||
INSTALL := /usr/bin/install -c
|
INSTALL := /usr/bin/install -c
|
||||||
|
|
||||||
CXXFLAGS := $(CXXFLAGS) -Wshadow -Wall -Wpedantic -Wextra -g -fno-strict-aliasing -std=c++17 -pthread
|
CXXFLAGS := $(CXXFLAGS) -Wshadow -Wall -Wpedantic -Wextra -g -fno-strict-aliasing -std=c++17 -pthread
|
||||||
ifeq ($(DEBUG),1)
|
ifeq ($(DEBUG),1)
|
||||||
CXXFLAGS += -D DEBUG -O0
|
CXXFLAGS += -D DEBUG -O0
|
||||||
|
CONFIG := debug
|
||||||
else
|
else
|
||||||
CXXFLAGS += -D NDEBUG -O3
|
CXXFLAGS += -D NDEBUG -O3
|
||||||
|
CONFIG := release
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LDLIBS := -lm -lpthread -lcurl -lsclogging
|
LDLIBS := -lm -lpthread -lcurl -lsclogging
|
||||||
|
|
||||||
.PHONY: all sync clean install
|
OUTDIR := build/$(CONFIG)/
|
||||||
|
|
||||||
all: $(BIN) sync
|
.PHONY: all clean install prebuild
|
||||||
|
|
||||||
$(BIN): $(OBJS) $(DEPS)
|
all: prebuild $(OUTDIR)$(BIN)
|
||||||
$(CXX) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $(BIN)
|
|
||||||
|
|
||||||
%.o: %.cpp %.d Makefile
|
prebuild:
|
||||||
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
|
@mkdir -p $(BUILDDIR) $(OUTDIR)
|
||||||
|
|
||||||
-include *.d
|
$(OUTDIR)$(BIN): $(OBJS) $(DEPS)
|
||||||
|
$(CXX) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $(OUTDIR)$(BIN)
|
||||||
|
@ln -sf $(OUTDIR)$(BIN) $(BIN)
|
||||||
|
|
||||||
%.d: ;
|
$(BUILDDIR)%.o: %.cpp $(BUILDDIR)%.d Makefile
|
||||||
|
cd $(BUILDDIR) && $(CXX) $(CXXFLAGS) -MMD -MP -MT $(notdir $@) -MF $*.d -c ../../$< && cd ../..
|
||||||
|
|
||||||
sync: $(CODE) code/index.html
|
-include $(BUILDDIR)*.d
|
||||||
rsync -av code/ pi@www.swiftcoder.nl:/var/www/html/cpp1/
|
|
||||||
@for f in $(CODE) code/index.html ;\
|
$(BUILDDIR)%.d: ;
|
||||||
do \
|
|
||||||
curl -nT $$f ftp://student.aii.avans.nl/doc/rpbpolis1/ ;\
|
|
||||||
done
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(OBJS) $(DEPS) $(BIN)
|
$(RM) build $(BIN)
|
||||||
|
|
||||||
install: $(BIN)
|
install: $(OUTDIR)$(BIN)
|
||||||
$(INSTALL) -d $(BINDIR)
|
$(INSTALL) -d $(BINDIR)
|
||||||
$(INSTALL) $(BIN) $(BINDIR)
|
$(INSTALL) $(OUTDIR)$(BIN) $(BINDIR)
|
||||||
$(INSTALL) -d $(MANDIR)$(MANSECTION)
|
$(INSTALL) -d $(MANDIR)$(MANSECTION)
|
||||||
$(INSTALL) $(MANPAGE) $(MANDIR)$(MANSECTION)
|
$(INSTALL) $(MANPAGE) $(MANDIR)$(MANSECTION)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user