Makefile

Download
makefile 51 lines 1.5 KB
 1# Makefile for File Encryption Examples
 2# C Programming Project 7
 3
 4CC = gcc
 5CFLAGS = -Wall -Wextra -std=c11 -O2
 6TARGETS = simple_xor file_encrypt file_encrypt_v2
 7
 8.PHONY: all clean test
 9
10all: $(TARGETS)
11
12# κΈ°λ³Έ XOR 데λͺ¨
13simple_xor: simple_xor.c
14	$(CC) $(CFLAGS) $< -o $@
15
16# 파일 μ•”ν˜Έν™” 도ꡬ (κΈ°λ³Έ)
17file_encrypt: file_encrypt.c
18	$(CC) $(CFLAGS) $< -o $@
19
20# 파일 μ•”ν˜Έν™” 도ꡬ v2 (헀더 + 검증)
21file_encrypt_v2: file_encrypt_v2.c
22	$(CC) $(CFLAGS) $< -o $@
23
24# ν…ŒμŠ€νŠΈ μ‹€ν–‰
25test: all
26	@echo "=== Testing simple_xor ==="
27	./simple_xor
28	@echo ""
29	@echo "=== Testing file_encrypt ==="
30	@echo "Test message for encryption" > test.txt
31	./file_encrypt -e test.txt test.enc mypassword
32	./file_encrypt -d test.enc decrypted.txt mypassword
33	@diff -q test.txt decrypted.txt && echo "βœ“ Basic encryption test passed"
34	@rm -f test.txt test.enc decrypted.txt
35	@echo ""
36	@echo "=== Testing file_encrypt_v2 ==="
37	@echo "Advanced test with header validation" > test2.txt
38	./file_encrypt_v2 encrypt test2.txt test2.enc strongpass
39	./file_encrypt_v2 info test2.enc
40	./file_encrypt_v2 decrypt test2.enc decrypted2.txt strongpass
41	@diff -q test2.txt decrypted2.txt && echo "βœ“ Advanced encryption test passed"
42	@echo ""
43	@echo "Testing wrong password (should fail):"
44	@./file_encrypt_v2 decrypt test2.enc wrong.txt wrongpass || echo "βœ“ Password validation working"
45	@rm -f test2.txt test2.enc decrypted2.txt wrong.txt
46	@echo ""
47	@echo "All tests passed!"
48
49clean:
50	rm -f $(TARGETS) *.o *.enc *.txt *.bin *.dec