NAME          = Sully
SRCS          = Sully.c

CLONES_D      = clones
# extract value of i inside Sully.c :
CLONES_i      = $(shell grep -oP 'int i = \K\d+' $(SRCS))
# seq -s ' ' -w 5 -1 0 : output -> "5 4 3 2 1 0"
CLONES_SEQ    = $(shell seq -s ' ' -w $(CLONES_i) -1 0)
# create liste of executables files : Sully_5 Sully_4 ...
CLONES_X      = $(addprefix $(NAME)_,$(CLONES_SEQ))
CLONES        = $(CLONES_C)
# create liste of files : Sully_5.c Sully_4.c ...
CLONES_C      = $(addsuffix .c,$(CLONES_X))

CREATE_CLONE  = ./$(NAME)
RM_MORE       = rm -rf
RM_MORE      += $(CLONES_X)
RM_MORE      += ./$(CLONES_D)

include ../MakefileCommon

sully:
	$(MAKE) re
	rm -rf ./$(CLONES_D)
	mkdir -p ./$(CLONES_D)
	cd ./$(CLONES_D) ;\
		clang -Wall -Wextra -Werror ../Sully.c -o Sully ; ./Sully ;\
		ls -al | grep Sully | wc -l

.PHONY : sully

