This repository has been archived by the owner on Apr 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
118 lines (88 loc) · 2.59 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#====================== PARAMETRES ======================#
# Nom du fichier principal (sans le .c)
MAIN=huffman_exec
LIB=libhuffman
#====================== NE PAS TOUCHER ======================#
# Compilateur
CC=gcc
# FLAGS : paramètres de compilation
CFLAGS=-I include -O2 -march=native -Wall -Wextra -pedantic -ggdb
# FLAGS : Librairies + Version utilisée
LIBS=-std=c99 -lm
SRCS=$(wildcard src/*.c)
OBJS=$(SRCS:src/%.c=obj/%.o)
OBJSPIC=$(SRCS:src/%.c=obj/%.pic.o)
# bin/$(MAIN)
bin/$(MAIN): $(OBJS)
@mkdir -p bin
$(CC) -o $@ $^ $(LIBS)
@cp bin/$(MAIN) app/.resources/huffman_exec
@chmod +x app/.resources/huffman_exec
obj/$(MAIN).o: src/$(MAIN).c
@mkdir -p obj
$(CC) -c -o $@ $< $(CFLAGS)
obj/%.o: src/%.c include/%.h
@mkdir -p obj
$(CC) -c -o $@ $< $(CFLAGS)
#lib/$(LIB).a
lib/$(LIB).a: $(OBJS)
@mkdir -p lib
@rm -f obj/$(MAIN).o obj/*.pic.o
$(AR) -cr $@ obj/*.o
#lib/$(LIB).so
lib/$(LIB).so: $(OBJSPIC)
@mkdir -p lib
@rm -f obj/$(MAIN).pic.o
$(CC) --shared -o $@ obj/*.pic.o
obj/$(MAIN).pic.o: src/$(MAIN).c
$(CC) -fPIC -c -o $@ $< -I include
obj/%.pic.o: src/%.c include/%.h
$(CC) -fPIC -c -o $@ $< -I include
.PHONY: bin lib clean cleanO cleantests clean+ cleandir run memory_run run_interface memory_run_interface archive
bin: bin/$(MAIN)
lib: lib/$(LIB).a lib/$(LIB).so
clean:
ifneq ("$(wildcard bin/$(MAIN))","")
@rm bin/$(MAIN)
@echo "Executable removed"
else
@echo "Executable already removed"
endif
cleanO:
ifneq ("$(wildcard obj/*.o)","")
@rm $(wildcard obj/*.o)
@echo "Files .o deleted"
else
@echo "No file .o to delete"
endif
cleantests:
ifneq ("$(wildcard tests/*.hfm)","")
@rm $(wildcard tests/*.hfm)
endif
ifneq ("$(wildcard tests/*.hfm.key)","")
@rm $(wildcard tests/*.hfm.key)
endif
ifneq ("$(wildcard tests/*.hfm.txt)","")
@rm $(wildcard tests/*.hfm.txt)
endif
@echo "Tests repository cleaned"
clean+: clean cleanO cleantests
cleandir: cleantests
@rm -rf bin obj lib
@echo "'bin/', 'obj/' and 'lib/' folders have been deleted"
run: bin/$(MAIN)
@./bin/$(MAIN)
memory_run: bin/$(MAIN)
@valgrind ./bin/$(MAIN)
run_interface: bin/$(MAIN)
@./bin/$(MAIN) interface
memory_run_interface: bin/$(MAIN)
@valgrind ./bin/$(MAIN) interface
archive: $(wildcard src/*) $(wildcard include/*) $(wildcard doc/*) $(wildcard app/.resources/*) app/HuffmanCoding.jar $(wildcard tests/*) Makefile README.html commands.html
@tar jcvf $@-$(MAIN).tar.bz2 $^ > /dev/null
ifneq ("$@-$(MAIN).tar.bz2","")
@echo "The archive \"$@-$(MAIN).tar.bz2\" was successfully generated"
else
@echo "The archive could not be generated"
endif
#====================== FIN NE PAS TOUCHER ======================#