CFLAGS= -g -Wall -pedantic -std=c99
LDFLAGS= -g
LDLIBS= -lpthread -lm
MAK=make -B --no-print-directory

all:
	less README.txt

test-porciento.o porciento.o: porciento.h
test-porciento: test-porciento.o porciento.o
test-porciento-g:
	@$(MAK) test-porciento
	./test-porciento

test-porciento-O:
	@$(MAK) CFLAGS="-O -Wall -pedantic -std=c99" LDFLAGS= test-porciento
	chmod +x porciento-prof
	./test-porciento `./porciento-prof 0`

test-porciento-vg:
	@$(MAK) CFLAGS="$(CFLAGS) -DVALGRIND=1" test-porciento
	valgrind --leak-check=full --track-origins=yes ./test-porciento

test-porciento-vg-ddd:
	@$(MAK) test-porciento
	valgrind --leak-check=full --track-origins=yes --vgdb=yes --vgdb-error=0 ./test-porciento

test-arboles.o arboles.o: arboles.h
test-arboles: test-arboles.o arboles.o
test-arboles-g:
	@$(MAK) test-arboles
	./test-arboles

test-arboles-O:
	@$(MAK) CFLAGS="-O -Wall -pedantic -std=c99" LDFLAGS= test-arboles
	./test-arboles

test-arboles-vg:
	@$(MAK) CFLAGS="$(CFLAGS) -DVALGRIND=1" test-arboles
	valgrind --leak-check=full --track-origins=yes ./test-arboles

test-arboles-vg-ddd:
	@$(MAK) CFLAGS="$(CFLAGS) -DVALGRIND=1" test-arboles
	valgrind --leak-check=full --track-origins=yes --vgdb=yes --vgdb-error=0 ./test-arboles

test-rifa.o rifa.o: rifa.h
test-rifa: test-rifa.o rifa.o
test-rifa-g:
	@$(MAK) test-rifa
	./test-rifa

test-rifa-O:
	@$(MAK) CFLAGS="-O -Wall -pedantic -std=c99" LDFLAGS= test-rifa
	./test-rifa

test-rifa-vg:
	@$(MAK) CFLAGS="$(CFLAGS) -DVALGRIND=1" test-rifa
	valgrind --leak-check=full --track-origins=yes ./test-rifa

test-rifa-vg-ddd:
	@$(MAK) CFLAGS="$(CFLAGS) -DVALGRIND=1" test-rifa 
	valgrind --leak-check=full --track-origins=yes --vgdb=yes --vgdb-error=0 ./test-rifa

test-rifa-san:
	@$(MAK) "CFLAGS=-fsanitize=thread $(CFLAGS)" "LDFLAGS=-fsanitize=thread" test-rifa
	./test-rifa

test-menores.o menores.o: menores.h
test-menores: test-menores.o menores.o
test-menores-g:
	@$(MAK) test-menores
	./test-menores

test-menores-O:
	@$(MAK) "CFLAGS=-O -std=c99 -Wall -pedantic" LDFLAGS= test-menores
	./test-menores

test-menores-vg:
	@$(MAK) "CFLAGS=${CFLAGS} -DVALGRIND" test-menores
	valgrind --child-silent-after-fork=yes --leak-check=full --track-origins=yes ./test-menores

test-menores-vg-ddd:
	@$(MAK) "CFLAGS=${CFLAGS} -DVALGRIND" test-menores
	valgrind --child-silent-after-fork=yes --leak-check=full --track-origins=yes --vgdb=yes --vgdb-error=0 ./test-menores

clean:
	rm -f *.o test-arboles test-menores test-rifa test-porciento
