EXEC=bin/crypto.ex
SRC=aes.cpp

main: aes.cpp jsoncpp.o
	@echo "compilation de aes"
	@g++ -Wall -Wextra -ggdb -o $(EXEC) $(SRC) obj/jsoncpp.o -lcrypto --std=c++14

jsoncpp.o: jsoncpp.cpp json/json.h json/json-forwards.h
	@echo "compilation de jsoncpp"
	@g++ -I ../lib/jsoncpp-master/include/ -Wall -Wextra -std=c++11 -c -ggdb jsoncpp.cpp -o obj/jsoncpp.o

run2:
	@./bin/crypt.ex data/file && ./bin/decrypt.ex data/file.enc data/aesKey.key

run:
	@./$(EXEC) file

decrypt.ex: mainDecrypt.cpp jsoncpp.o aes.hpp
	@echo "compilation de decrypt.ex"
	@g++ -Wall -Wextra -ggdb -o bin/decrypt.ex mainDecrypt.cpp obj/jsoncpp.o -lcrypto --std=c++14

crypt.ex: mainCrypt.cpp jsoncpp.o aes.hpp
	@echo "compilation de crypt.ex"
	@g++ -Wall -Wextra -ggdb -o bin/crypt.ex mainCrypt.cpp obj/jsoncpp.o -lcrypto --std=c++14

valgrind:
	@valgrind --leak-check=full --track-origins=yes ./$(EXEC) file

clean: cleanO cleanB

cleanO:
	@rm obj/*.o

cleanB:
	@rm bin/*.ex

cleanD:
	@rm data/*.enc
	@rm data/*.dec
	@rm data/*.key
