-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
126 lines (86 loc) · 2.94 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
119
120
121
122
123
124
125
126
# C
CSRC_DIR = c/
COBJ_DIR = cobj/
CMAIN_NAME = manager client_keyboard scenario_many_clients message_test
CC = gcc
CFLAGS = -g -Wall -pthread
# JAVA
JSRC_DIR = java/
JCLASS_DIR = jclass/
JMAIN_NAME = JavaClient Streamer JavaClientManager
JC = javac
# Pour JCFLAGS ne pas mettre d'option -cp ou -d
JCFLAGS = -Xlint:all
# TAR
TAR_NAME = PR-projet-groupe7.tar
#########################################
# NE PAS MODIFIER CE QUI EST EN DESSOUS #
#########################################
# Compilation des fichiers C et Java
all: c java
# Nettoyage des fichiers de compilation C et Java et Scenarios
clean: cleanc cleanj
# Création du .tar contenant les fichiers .java, .c et Makefile
tar:
tar -cvf $(TAR_NAME) Makefile $(JSRC_DIR) $(CSRC_DIR) README.md doc configs LICENSE
#############################
# COMPILATION DES FICHIER C #
#############################
CMAIN = $(patsubst %,$(CSRC_DIR)%.c,$(CMAIN_NAME))
CSRC = $(wildcard $(CSRC_DIR)*.c)
CSRC := $(filter-out $(CMAIN),$(CSRC))
COBJ = $(notdir $(CSRC:.c=.o))
COBJ := $(addprefix $(COBJ_DIR),$(COBJ))
c: $(CMAIN_NAME)
$(CMAIN_NAME): %: $(COBJ) $(CSRC_DIR)%.c
$(CC) -o $@ $(CFLAGS) $^
$(COBJ_DIR):
@mkdir -p $(COBJ_DIR)
$(COBJ_DIR)%.o: $(CSRC_DIR)%.c $(CSRC_DIR)%.h | $(COBJ_DIR)
$(CC) -c -o $@ $< $(CFLAGS)
# Nettoyage des fichiers de compilation C
cleanc:
rm -rf $(COBJ_DIR) $(CMAIN_NAME)
#################################
# COMPILATION DES FICHIERS JAVA #
#################################
JAR = $(addsuffix .jar,$(JMAIN_NAME))
JSRC = $(wildcard $(JSRC_DIR)*.java)
# Exemple
# java/Message.java -> jclass/Message.class
JCLASS = $(patsubst $(JSRC_DIR)%.java,$(JCLASS_DIR)%.class,$(JSRC))
.SECONDARY: $(JCLASS)
java: $(JAR)
%.jar: $(JCLASS)
jar cfe $@ $* -C $(JCLASS_DIR) .
$(JCLASS_DIR):
@mkdir -p $(JCLASS_DIR)
$(JCLASS_DIR)%.class: $(JSRC_DIR)%.java | $(JCLASS_DIR)
$(JC) -d $(JCLASS_DIR) -cp $(JSRC_DIR) $(JCFLAGS) $<
# Nettoyage des fichiers de compilation Java
cleanj:
rm -rf $(JCLASS_DIR) $(JAR)
#############################
# COMPILATION DES SCENARIOS #
#############################
# SCENARIO = $(wildcard scenario_*)
# SCENARIO_DIR = $(addsuffix /,$(SCENARIO))
# FIND_JSRC = $(wildcard $(dir)*.java)
# SCENARIO_JCLASS := $(foreach dir,$(SCENARIO_DIR),$(FIND_JSRC:.java=.class))
# FIND_CSRC = $(wildcard $(dir)*.c)
# SCENARIO_COBJ := $(foreach dir,$(SCENARIO_DIR),$(FIND_CSRC:.c=.o))
# SCENARIO_EXEC = $(join $(SCENARIO_DIR),$(SCENARIO))
# scenario: c java $(SCENARIO_EXEC) $(SCENARIO_JCLASS)
# $(SCENARIO_EXEC): $(SCENARIO_COBJ)
# $(if $(wildcard $(@D)/*.o),\
# $(CC) -o $@ $(CFLAGS) -I $(CSRC_DIR) $(wildcard $(@D)/*.o))
# $(SCENARIO_COBJ): %.o: %.c
# $(CC) -c -o $@ $< $(CFLAGS) -I $(CSRC_DIR)
# $(SCENARIO_JCLASS): %.class: %.java
# $(JC) -d $(@D) -classpath $(JCLASS_DIR):$(@D)/ $(JCFLAGS) $<
# cleans:
# rm -rf $(SCENARIO_EXEC) $(SCENARIO_JCLASS) $(SCENARIO_COBJ)
# .SECONDEXPANSION:
# $(SCENARIO_EXEC): $$(filter $(dir $$@)/%.o,$(SCENARIO_COBJ))
# $(info $^)
# $(CC) -o $@ $^