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
|
||||
MANPAGE := $(BIN).$(MANSECTION)
|
||||
|
||||
BUILDDIR := build/intermediates/
|
||||
|
||||
SRCS := $(wildcard *.cpp)
|
||||
OBJS := $(subst .cpp,.o,$(SRCS))
|
||||
DEPS := $(subst .cpp,.d,$(SRCS))
|
||||
CODE := $(wildcard code/*.txt)
|
||||
OBJS := $(addprefix $(BUILDDIR),$(SRCS:.cpp=.o))
|
||||
DEPS := $(addprefix $(BUILDDIR),$(SRCS:.cpp=.d))
|
||||
|
||||
CXX ?= g++
|
||||
PKG_CONFIG ?= pkg-config
|
||||
@ -18,44 +19,45 @@ DATADIR ?= $(PREFIX)/share
|
||||
MANDIR ?= $(DATADIR)/man/man
|
||||
DOCDIR ?= $(DATADIR)/$(BIN)/doc
|
||||
|
||||
RM := /bin/rm -f
|
||||
RM := /bin/rm -rf
|
||||
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
|
||||
CONFIG := debug
|
||||
else
|
||||
CXXFLAGS += -D NDEBUG -O3
|
||||
CONFIG := release
|
||||
endif
|
||||
|
||||
LDLIBS := -lm -lpthread -lcurl -lsclogging
|
||||
|
||||
.PHONY: all sync clean install
|
||||
OUTDIR := build/$(CONFIG)/
|
||||
|
||||
all: $(BIN) sync
|
||||
.PHONY: all clean install prebuild
|
||||
|
||||
$(BIN): $(OBJS) $(DEPS)
|
||||
$(CXX) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $(BIN)
|
||||
all: prebuild $(OUTDIR)$(BIN)
|
||||
|
||||
%.o: %.cpp %.d Makefile
|
||||
$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
|
||||
prebuild:
|
||||
@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
|
||||
rsync -av code/ pi@www.swiftcoder.nl:/var/www/html/cpp1/
|
||||
@for f in $(CODE) code/index.html ;\
|
||||
do \
|
||||
curl -nT $$f ftp://student.aii.avans.nl/doc/rpbpolis1/ ;\
|
||||
done
|
||||
-include $(BUILDDIR)*.d
|
||||
|
||||
$(BUILDDIR)%.d: ;
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJS) $(DEPS) $(BIN)
|
||||
$(RM) build $(BIN)
|
||||
|
||||
install: $(BIN)
|
||||
install: $(OUTDIR)$(BIN)
|
||||
$(INSTALL) -d $(BINDIR)
|
||||
$(INSTALL) $(BIN) $(BINDIR)
|
||||
$(INSTALL) $(OUTDIR)$(BIN) $(BINDIR)
|
||||
$(INSTALL) -d $(MANDIR)$(MANSECTION)
|
||||
$(INSTALL) $(MANPAGE) $(MANDIR)$(MANSECTION)
|
||||
|
Loading…
x
Reference in New Issue
Block a user