refactoring variable into Makefile

This commit is contained in:
Antoine 2020-04-27 00:07:17 +02:00
parent e4509061fb
commit 34bc39b252
12 changed files with 51 additions and 29 deletions

View File

@ -1,40 +1,57 @@
EXEC=bin/crypto.ex
BIN_PATH=./bin
LIB_PATH=./lib
OBJ_PATH=./obj
EXEC=$(BIN_PATH)/cryptomain.ex
SRC=main.cpp
JSON_CPP=$(OBJ_PATH)/jsoncpp.o
main: main.cpp jsoncpp.o
# merge crypt and decrypt binary into cryptomain
cryptomain.ex:
$(EXEC): $(SRC) $(JSON_CPP)
@echo "compilation de aes"
@g++ -Wall -Wextra -ggdb -o $(EXEC) $(SRC) obj/jsoncpp.o -lcrypto --std=c++14
@g++ -Wall -Wextra -ggdb -o $(EXEC) $(SRC) $(JSON_CPP) -lcrypto --std=c++14
obj/jsoncpp.o: jsoncpp.cpp json/json.h json/json-forwards.h
$(JSON_CPP): $(LIB_PATH)/jsoncpp.cpp $(LIB_PATH)/json/json.h $(LIB_PATH)/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
@g++ -I ../lib/jsoncpp-master/include/ -Wall -Wextra -std=c++11 -c -ggdb $(LIB_PATH)/jsoncpp.cpp -o $(JSON_CPP)
run2:
@./bin/crypt.ex data/file && ./bin/decrypt.ex data/file.enc data/aesKey.key
run: $(EXEC)
@./$(EXEC) data/cryptomain/file
run:
@./$(EXEC) file
# separate crypt and decrypt binary
EXEC_DECRYPT=$(BIN_PATH)/decrypt.ex
EXEC_CRYPT=$(BIN_PATH)/crypt.ex
SRC_CRYPT=mainCrypt.cpp
SRC_DECRYPT=mainDecrypt.cpp
decrypt.ex: mainDecrypt.cpp obj/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
crypt.ex:
$(EXEC_CRYPT): $(SRC_CRYPT) $(JSON_CPP) aes.hpp
@echo "compilation de crypt.ex"
@g++ -Wall -Wextra -ggdb -o bin/crypt.ex mainCrypt.cpp obj/jsoncpp.o -lcrypto --std=c++14
@g++ -Wall -Wextra -ggdb -o $(EXEC_CRYPT) $(SRC_CRYPT) $(JSON_CPP) -lcrypto --std=c++14
decrypt.ex:
$(EXEC_DECRYPT): $(SRC_DECRYPT) $(JSON_CPP) aes.hpp
@echo "compilation de decrypt.ex"
@g++ -Wall -Wextra -ggdb -o $(EXEC_DECRYPT) $(SRC_DECRYPT) $(JSON_CPP) -lcrypto --std=c++14
run2: $(EXEC_CRYPT) $(EXEC_DECRYPT)
@./$(EXEC_CRYPT) data/crypt_decrypt/file && ./$(EXEC_DECRYPT) data/crypt_decrypt/file.enc data/crypt_decrypt/file.key
# debug target
valgrind:
@valgrind --leak-check=full --track-origins=yes ./$(EXEC) file
# clean target
clean: cleanO cleanB
cleanO:
@rm -rf obj/*.o
@rm -rf $(OBJ_PATH)/*.o
cleanB:
@rm -rf bin/*.ex
@rm -rf $(BIN_PATH)/*.ex
cleanD:
@/bin/rm -f data/*.enc
@/bin/rm -f data/*.dec
@/bin/rm -f data/*.key
@rm -f data/*.enc
@rm -f data/*.dec
@rm -f data/*.key

View File

@ -1,4 +0,0 @@
{
"IV" : "<22>e‡£|<7C>-}“õ:šåº¿‹@¼3†Ægñ¼\u0002Ï\u0006/ÒU",
"key" : "|\u0006[QGµåÿu°¤aJnóf®'gØ\u0011/nÝ`\u0015ûþdd»/"
}

2
data/crypt_decrypt/file Normal file
View File

@ -0,0 +1,2 @@
toto
test crypt_decrypt

View File

@ -0,0 +1,2 @@
toto
test crypt_decrypt

View File

@ -0,0 +1 @@
HN▄ВэьЁt│А╡ц ц]плU╗и-*лЭ╣УeО

View File

@ -0,0 +1,4 @@
{
"IV" : "\u0018FîM,Ó®5\u0006‡\u0005\u0014ÁŁŽuŠÁ\u000Eĺ/÷ë\u0004<30>N4ň—s(C",
"key" : "\u0018˙Šc¸qo\fd2ĄŢ¶Ąë7ż¸BiĽŠf‰¸ěw\u000Eóü\u001Fµ"
}

1
data/cryptomain/file.enc Normal file
View File

@ -0,0 +1 @@
оџАy»Ы¤јЯAµ“]€В

4
data/cryptomain/file.key Normal file
View File

@ -0,0 +1,4 @@
{
"IV" : "ř<>:=¸\u001AäÚ N“K$¦ď¨zzĎ1\u001Fţt\u0016\u0011Pů\tEOś\u0016",
"key" : "ţZí%źŕňíͱúăÔ{\u0013\u0019îQĽc\u0004đÄ”|󔕨Żčn"
}

View File

@ -1 +0,0 @@
eЫЦ—Џ0?О­вЬmaО

View File

@ -1,4 +0,0 @@
{
"IV" : "ж9╞╞И╜■\u0016FCгчА6\u0001и\"СQX4Q╞Б╨йъkАUР╨",
"key" : "│\u0002\u0014\u0005╩\u0019=н\u0006ТСоУ├⌠┌╦xCIe\u0018┐нLcЛzsz"
}