SHELL := $(shell which bash) .ONESHELL: ATT = $(EXE:=.att) BST = $(basename $(shell grep -l fiber.hpp $(SRC))) DEP = $(foreach i,$(EXE:=.d),.$i) EXE = $(basename $(SRC)) GBM = $(basename $(shell grep -l benchmark.h $(SRC))) SRC = $(sort $(wildcard *.cc)) TBB = $(basename $(shell grep -l tbb.h $(SRC))) CXXFLAGS = -flto -g -I../include -march=native -O3 -pthread -std=c++23 -Wall $(BST): LDLIBS += -lboost_fiber -lboost_context -lboost_system $(GBM): LDLIBS += $(shell pkg-config --libs benchmark) $(TBB): LDLIBS += $(shell pkg-config --libs tbb) all: $(ATT) auto: @while true; do make --no-print-directory run printf '\e[1;31m' ! inotifywait -e close_write . -q && break done printf '\e[0m' clean: -rm -fv $(ATT) $(DEP) $(EXE) {,vg}core{,.*} *~ leak: $(EXE) -@for i in $^; do make $$i.leak &> /dev/null if [ "$$?" == "0" ]; then echo -e "$$i: \e[1;32mwithout leaks\e[0m" else echo -e "$$i: \e[1;31mLEAKS!!!\e[0m" fi done run: $(EXE) @for i in $^; do printf "\e[1;34m%64s\n #$${i}\n%64s\n\e[0m" | tr ' #' '# ' ./$$i done coroify: ../tools/coro_source_rewriter.py common.h -o common.coro.h test: $(filter-out $(GBM),$(EXE)) @for i in $^; do ./$$i 1> /tmp/$$i.tmp 2> /dev/null ret=$$? if [[ "$$ret" != "0" ]]; then printf '\e[1;31m' fi printf '%16s --> %i : ' $$i $$ret cat /tmp/$$i.tmp rm -f /tmp/$$i.tmp printf '\e[0m' done %: %.cc $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MMD -MP -MF .$*.d $< $(LDFLAGS) $(LOADLIBES) $(LDLIBS) -o $@ %.att: % objdump -Cd $< > $@ %.leak: % valgrind --error-exitcode=1 --leak-check=full -s -- ./$< -include $(DEP) .PHONY: all auto clean leak run test coroify .PRECIOUS: $(DEP)