CC = cc
CFLAGS = -std=c11 -Wall -Wextra -Wpedantic -g
CPPFLAGS = -Isrc -Itests
METIER = src/rapport.c src/regles.c src/transfert.c src/finalisation.c
COMMUN = $(METIER) src/service.c

.PHONY: all depart observer test test-s1 test-s2 test-s3 test-s4 test-perso integration-s2 integration-s4 arret clean
all: snapguard run_tests tests_perso

snapguard: src/main.c src/fs_posix.c $(COMMUN) src/sg.h
	$(CC) $(CPPFLAGS) $(CFLAGS) src/main.c src/fs_posix.c $(COMMUN) -o $@
run_tests: tests/test_seances.c tests/doublure.c tests/doublure.h $(COMMUN) src/sg.h
	$(CC) $(CPPFLAGS) $(CFLAGS) tests/test_seances.c tests/doublure.c $(COMMUN) -o $@
tests_perso: tests/mes_tests.c tests/doublure.c tests/doublure.h $(COMMUN) src/sg.h
	$(CC) $(CPPFLAGS) $(CFLAGS) tests/mes_tests.c tests/doublure.c $(COMMUN) -o $@

depart: all
	python3 tests/integration.py nominal
observer: run_tests
	./run_tests observer
test-s1 test-s2 test-s3 test-s4: run_tests
	./run_tests $(subst test-s,,$@)
test: test-s1 test-s2 test-s3 test-s4 test-perso
test-perso: tests_perso
	./tests_perso
integration-s2: snapguard
	python3 tests/integration.py s2
integration-s4: snapguard
	python3 tests/integration.py s4
arret: snapguard
	python3 tests/integration.py arret
clean:
	rm -f snapguard run_tests tests_perso
