CLI
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.7 KiB

11 months ago
# Author Yannis Gerlach
# HochSchule Osnabrück
# 29.04.2020
# `make clean all` nicht mit -j verwenden! -> race condition im make file
# statdessen: `make clean; make all -j` verwenden
NAME = app
NAMETEST = test
CFLAGS = -std=c++2a -O2 -g3 -pipe -Wall -rdynamic
CXX = g++
SRCF = src/
INCF = inc/
BUILDDIR = build/
TESTF = tests/
DEPF = $(BUILDDIR)deps/
INCLUDES = -I$(INCF)
LDFLAGS = -lpthread -lcrypto
SRCFILES = $(shell find $(SRCF) -name "*.cpp")
OBJFILES = $(patsubst $(SRCF)%, $(BUILDDIR)%, $(patsubst %.cpp, %.o, $(SRCFILES)))
DEPFILES = $(wildcard $(DEPF)*.d)
SOURCEDIRS = $(shell find $(SRCF) -type d -printf "%p/\n")
BUILDDIRS = $(patsubst $(SRCF)%, $(BUILDDIR)%, $(SOURCEDIRS))
OBJFILESTEST = $(filter-out $(BUILDDIR)main.o, $(OBJFILES))
INCLUDES += $(addprefix -I, $(SOURCEDIRS))
all: $(NAME) runtest
$(NAME): $(BUILDDIRS) $(DEPF) $(OBJFILES)
@echo "Linking $@"
@$(CXX) $(CFLAGS) -o $@ $(filter %.o, $^) $(LDFLAGS)
$(BUILDDIR)%.o: $(SRCF)%.cpp
@echo "Compiling: $@"
@$(CXX) $(CFLAGS) $(INCLUDES) $< -MM -MT $@ > $(DEPF)$(subst /,_,$*).d
@$(CXX) -c -o $@ $(CFLAGS) $(INCLUDES) $<
$(NAME)_strip: $(NAME)
@echo "Strip $<"
@strip -o $@ $<
%/:
mkdir -p $@
clean-depends:
$(RM) -r $(DEPF)
clean:
$(RM) -r $(NAME) $(BUILDDIR) $(NAMETEST)
$(NAMETEST): $(BUILDDIRS) $(DEPF) $(TESTF)*.cpp $(OBJFILESTEST)
@echo "Compiling tests"
@$(CXX) -o $@ $(filter %.o, $^) $(filter %.cpp, $^) $(CFLAGS) -I$(SRCF) $(INCLUDES) $(LDFLAGS)
runtest: $(NAMETEST)
@echo "Running tests"
./$<
# fix assets :
# find assets/ -name '*.*' -exec sh -c 'a=$(echo "$0" | sed -r "s/([^.]*)\$/\L\1/"); [ "$a" != "$0" ] && mv "$0" "$a" ' {} \;
.PHONY: clean all $(NAMETEST) clean-depends runtest
include $(DEPFILES)