-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile.in
332 lines (261 loc) · 11 KB
/
Makefile.in
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# @configure_input@
# TODO :
# * make doc generate some warning (since the merge of music). Why ? Fix the issue
# * the targets dist and doc are not *generic*.
#variable from configure
package = @PACKAGE_NAME@
version = @PACKAGE_VERSION@
tarname = @PACKAGE_TARNAME@
distdir = $(tarname)-$(version)
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
resourcesdir = @datadir@
#VPATH variable
#VPATH allow to build the project in other tree than were
#are located the original sources files
#not supported by ocamlbuild because ocamlbuild
#do not support relative path, WTF ?!?
#srcdir = @srcdir@
#VPATH = @srcdir@
#where are located files
src_root=src
resources_dir=resources
documentation_dir=doc
engine_dir=$(src_root)/engine
common_dir=$(src_root)/common
utils_dir=$(src_root)/common/utils
config_dir=$(src_root)/common/config
interface_dir=$(src_root)/interface
gui_dir=$(interface_dir)/gui
amaze_dir=$(interface_dir)/amaze
network_dir=$(src_root)/network
music_dir=$(src_root)/music
script_dir=$(src_root)/script
foo=${datarootdir}
test_dir=test
log_dir=log
# $(network_dir) removed for now
dirs = $(network_dir) $(engine_dir) $(common_dir) $(utils_dir) $(config_dir) $(interface_dir) $(gui_dir) $(amaze_dir) $(music_dir) $(script_dir)
#for each target, the directories concerned for ocamlbuild
engine_src=$(network_dir),$(engine_dir),$(common_dir),$(utils_dir),$(config_dir),$(script_dir)
interface_src=$(engine_dir),$(common_dir),$(utils_dir),$(config_dir),$(interface_dir),$(gui_dir),$(amaze_dir),$(music_dir),$(network_dir),$(script_dir)
network_src=$(network_dir),$(common_dir),$(utils_dir),$(config_dir)
script_src=$(common_dir),$(utils_dir),$(script_dir),$(config_dir)
test_src=test,$(engine_src),$(interface_src)
#dependencies required for each target
common_dependencies = atdgen,dolog,unix
engine_dependencies = $(common_dependencies),threads
music_dependencies = num,ocsfml.audio,mm,pulseaudio
script_dependencies = $(common_dependencies)
network_dependencies = dolog
#music dependencies must be before ocsfml.graphics otherwise ocamlbuild fail.
interface_dependencies = bigarray,threads,$(music_dependencies),ocsfml.graphics,$(common_dependencies)
network_libraries = unix
test_dependencies=$(engine_dependencies),$(interface_dependencies),oUnit
#tags needed for each target
interface_tags = thread
engine_tags = thread
#compiler flags
cflags = -w,-3,-g
#name of the target for ocamlbuild
output_interface = main.native
output_profile = main.p.native
output_script = script.native
output_engine = dummy_serv.native
output_client = dummy_client.native
output_network = dealer.native
output_gprof = profile
menhir_command = -use-menhir -yaccflag --explain
command = ocamlbuild -use-ocamlfind -cflags $(cflags)
interface_command = $(command) $(menhir_command) -Is $(interface_src) -package $(interface_dependencies) $(output_interface) -tag $(interface_tags)
profile_command = $(command) $(menhir_command) -Is $(interface_src) -package $(interface_dependencies) $(output_profile) -tag $(interface_tags)
gprof_command = gprof $(output_profile) gmon.out >> $(output_gprof)
script_command = $(command) $(menhir_command) -Is $(script_src) -package $(script_dependencies) $(output_script)
engine_command = $(command) $(menhir_command) -Is $(engine_src) -package $(engine_dependencies) $(output_engine) -tag $(engine_tags)
client_command = $(command) $(menhir_command) -Is $(engine_src) -package $(engine_dependencies) $(output_client) -tag $(engine_tags)
network_command = $(command) $(menhir_command) -Is $(network_src) -package $(network_dependencies) $(output_network)
#get every source file of the project
#needed for the target doc
find_ml_files = $(wildcard $(dir)/*.ml)
find_mli_files = $(wildcard $(dir)/*.mli)
files := $(foreach dir,$(dirs),$(find_ml_files) $(find_mli_files))
###########################################
# Generate .ml files from .atd files #
###########################################
# atd files
%_t.ml: %.atd
atdgen -t $<
%_j.ml: %.atd
atdgen -j $<
%_v.ml: %.atd
atdgen -v $<
###########################################
# get all the atd files in the project #
###########################################
#temporary solution : find a way toreplace src/common
find_files_atd = $(wildcard $(dir)/*.atd)
files_atd := $(foreach dir,$(dirs),$(find_files_atd))
files_atd_ml := $(files_atd:.atd=_t.ml) $(files_atd:.atd=_j.ml) $(files_atd:.atd=_v.ml)
files_atd_mli := $(files_atd_ml:.ml=.mli)
find_files_t_ml = $(wildcard $(dir)/*_t.ml)
files_atd_t := $(foreach dir,$(dirs),$(find_files_t_ml))
all_files_atd_ml := $(files_atd_t) $(files_atd_t:_t.ml=_j.ml) $(files_atd_t:_t.ml=_v.ml)
all_files_atd_mli := $(files_atd_ml:.ml=.mli)
#TO DO : log shouldn't be here
all: interface engine client
interface: $(files_atd_ml) log
$(interface_command)
run: interface
./$(output_interface)
engine: $(files_atd_ml) log
$(engine_command)
client: $(files_atd_ml)
$(client_command)
#network:
# $(network_command)
script: $(files_atd_ml) log
$(script_command)
profile: $(files_atd_ml) log
$(profile_command)
./$(output_profile)
$(gprof_command)
#variable DESTDIR is useful for distcheck and more generally if you want to change the directory for installation.
install:
install -d "$(DESTDIR)$(bindir)"
-install -m 0755 $(output_interface) "$(DESTDIR)$(bindir)/ocawai"
#-install -m 0755 $(output_engine) "$(DESTDIR)$(bindir)"
#-install -m 0755 $(output_network) "$(DESTDIR)$(bindir)"
mkdir -p $(DESTDIR)$(resourcesdir)/ocawai/
cp -R ./resources/* $(DESTDIR)$(resourcesdir)/ocawai/
chmod 777 -R $(DESTDIR)$(resourcesdir)/ocawai/
uninstall:
-rm $(DESTDIR)$(bindir)/ocawai
#-rm $(DESTDIR)$(bindir)/$(output_engine)
#-rm $(DESTDIR)$(bindir)/$(output_network)
#-rm $(DESTDIR)$(bindir)/$(output_script)
-rm -Rf -- $(DESTDIR)$(resourcesdir)/ocawai
dist: $(distdir).tar.gz
#option h is for deference symlinks
$(distdir).tar.gz: $(distdir)
tar chf - $(distdir) | gzip -9 -c > $@
rm -rf $(distdir)
#create the archive
$(distdir): FORCE
mkdir -p $(distdir)/src
mkdir $(distdir)/$(common_dir)
mkdir $(distdir)/$(utils_dir)
mkdir $(distdir)/$(config_dir)
mkdir $(distdir)/$(engine_dir)
mkdir $(distdir)/$(interface_dir)
mkdir $(distdir)/$(gui_dir)
mkdir $(distdir)/$(amaze_dir)
mkdir $(distdir)/$(network_dir)
mkdir $(distdir)/$(resources_dir)
mkdir $(distdir)/$(music_dir)
mkdir $(distdir)/$(test_dir)
mkdir $(distdir)/$(script_dir)
cp Makefile.in $(distdir)
cp README.md $(distdir)
cp configure.ac $(distdir)
cp configure $(distdir)
cp install-sh $(distdir)
cp $(common_dir)/*.ml* $(distdir)/$(common_dir)
cp $(common_dir)/*.atd $(distdir)/$(common_dir)
cp $(utils_dir)/*.ml* $(distdir)/$(utils_dir)
cp $(config_dir)/*.ml* $(distdir)/$(config_dir)
cp $(config_dir)/*.atd $(distdir)/$(config_dir)
cp $(engine_dir)/*.ml* $(distdir)/$(engine_dir)
cp $(interface_dir)/*.ml* $(distdir)/$(interface_dir)
cp $(script_dir)/*.ml* $(distdir)/$(script_dir)
cp $(gui_dir)/*.ml* $(distdir)/$(gui_dir)
cp $(amaze_dir)/*.ml* $(distdir)/$(amaze_dir)
cp $(music_dir)/*.ml* $(distdir)/$(music_dir)
cp $(network_dir)/*.ml* $(distdir)/$(network_dir)
cp $(test_dir)/*.ml $(distdir)/$(test_dir)
# Used by script_test.ml
cp $(test_dir)/script_test_assoc.script $(distdir)/$(test_dir)
cp $(test_dir)/typechecker.script $(distdir)/$(test_dir)
cp $(test_dir)/occurs_check.script $(distdir)/$(test_dir)
cp $(test_dir)/occurs_check1.script $(distdir)/$(test_dir)
cp $(test_dir)/unit_unit.script $(distdir)/$(test_dir)
cp -R $(resources_dir)/* $(distdir)/$(resources_dir)
#check that distdir create a correct archive
distcheck: $(distdir).tar.gz
gzip -cd $(distdir).tar.gz | tar xvf -
cd $(distdir) && ./configure
#cd $(distdir) && $(MAKE) network
cd $(distdir) && $(MAKE) engine
cd $(distdir) && $(MAKE) interface
cd $(distdir) && $(MAKE) check
cd $(distdir) && $(MAKE) install DESTDIR="$${PWD}/_inst"
cd $(distdir) && $(MAKE) uninstall DESTDIR="$${PWD}/_inst"
#check if uninstall works
@remaining="`find $${PWD}/$(distdir)/_inst -type f | wc -l`"; \
if test "$${remainning}" -ne 0; then \
echo "*** $${remaining} file(s) remaining in temporary install directory!"; \
exit 1; \
fi
cd $(distdir) && $(MAKE) clean
rm -rf $(distdir)
@echo "*** Package $(distdir).tar.gz is ready for distribution"
#if an old archive is already there. Delete it to make a new one
FORCE:
-rm $(distdir).tar.gz > /dev/null 2>&1
-rm -rf $(distdir) > /dev/null 2>&1
#recompile the Makefile if you change something in Makefile.in
#without start over configure
Makefile: Makefile.in config.status
./config.status $@
config.status: configure
./config.status --recheck
#Generate documentation -I _builld/$(network_dir) removed for now
doc: interface engine client
mkdir -p $(documentation_dir)
ocamlfind ocamldoc -stars -package $(interface_dependencies) -d doc \
-t "Projet_Genie_Logiciel_MPRI_2014" \
-I _build/$(common_dir) -I _build/$(utils_dir) -I _build/$(config_dir) -I _build/$(interface_dir) -I _build/$(gui_dir) \
-I _build/$(amaze_dir) -I _build/$(engine_dir) -I _build/$(music_dir) -I _build/$(script_dir) -I _build/$(network_dir) \
-I -thread -thread -html -colorize-code $(files)
rm -f documentation.html
ln -s doc/index.html documentation.html
clean:
ocamlbuild -clean
rm -f $(all_files_atd_ml) $(all_files_atd_mli)
-rm -f $(documentation_dir)/*.html $(documentation_dir)/*.css
-test \! -e doc || rmdir doc
rm -f documentation.html
rm -f resources/config/settings.json
rm -f resources/config/settings_engine.json
rm -f resources/config/settings_interface.json
rm -f $(output_gprof)
rm -f gmon.out
mrproper: clean
rm -f configure
check_generation: engine
ocamlbuild -use-ocamlfind -cflags $(cflags) -Is $(test_src) -package $(test_dependencies) generation_test.native -tag $(engine_tags)
#ocamlfind ocamlc -o player_test -package oUnit -linkpkg -g test/player_test.ml
./generation_test.native
check_player: engine
ocamlbuild -use-ocamlfind -cflags $(cflags) -Is $(test_src) -package $(test_dependencies) player_test.native -tag $(engine_tags)
#ocamlfind ocamlc -o player_test -package oUnit -linkpkg -g test/player_test.ml
./player_test.native
check_logics: engine
ocamlbuild -use-ocamlfind -cflags $(cflags) -Is $(test_src) -package $(test_dependencies) logics_test.native -tag $(engine_tags)
./logics_test.native
check_fog: interface
ocamlbuild -use-ocamlfind -cflags $(cflags) -Is $(test_src) -package $(test_dependencies) fog_test.native -tag $(interface_tags)
./fog_test.native
check_music: interface
ocamlbuild -use-ocamlfind -cflags $(cflags) -Is $(test_src) -package $(test_dependencies) music_test.native -tag $(interface_tags)
./music_test.native
check_interface: interface
ocamlbuild -use-ocamlfind -cflags $(cflags) -Is $(test_src) -package $(test_dependencies) interface_test.native -tag $(interface_tags)
./interface_test.native
check_script: engine
ocamlbuild -use-ocamlfind $(menhir_command) -cflags $(cflags) -Is $(test_src) -package $(test_dependencies) script_test.native -tag $(engine_tags)
./script_test.native
check: check_player check_generation check_logics check_music check_interface check_script
log:
mkdir -p $(log_dir)
.PHONY: FORCE all clean dist distcheck engine interface network script log