-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
473 lines (358 loc) · 11.6 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
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
# This file is part of the software similarity tester SIM.
# Written by Dick Grune, Vrije Universiteit, Amsterdam.
# $Id: Makefile,v 2.115 2017-12-15 17:23:23 dick Exp $
#
#VERSION="-DVERSION=\"3.0.2 of 2017-12-16\"" # uncomment for public version
# E N T R Y P O I N T S
help:
@echo 'Entry points:'
@echo 'test: compile sim_c and run a simple test'
@echo ''
@echo 'binaries: create all binaries'
@echo 'exes: create executables in MSDOS'
@echo 'install: install all binaries'
@echo ''
@echo 'view_man: view sim.pdf'
@echo 'lint: lint sim sources'
@echo 'simsim: run sim_c on the sim sources'
@echo 'view_SPC: view the percentage computation document'
@echo 'chklat: do a LaTeX check on the .tex documents'
@echo ''
@echo 'fresh: remove created files'
#
# When you modify any of the following macros, do 'make clean'
#
# System dependencies
# =============== including ../lib/sysidf.mk here
# This file is part of the auxiliary libraries.
# Written by Dick Grune, dick@dickgrune.com
# $Id: sysidf.mk,v 1.19 2017-12-08 18:07:17 dick Exp $
#
################################################################
# For UNIX-like systems
SYSTEM = UNIX
SUBSYSTEM = SOLARIS
# Locations
DIR = /home/dick
BINDIR = /usr/bin
MAN1DIR = /usr/share/man/man1
# Commands
COPY = cp -p
EXE = #
LEX = flex
LN = ln
ZIP = zip -o
# File names
NULLFILE = /dev/null
################################################################
## For MSDOS + MinGW
## SYSTEM = MSDOS
# SUBSYSTEM = MinGW
## Locations
# DIR = C:/BIN
# BINDIR = C:/BIN
# MAN1DIR = C:/BIN
## File names
# NULLFILE = nul
## Commands (cp required, since xcopy cannot handle forward slashes)
# COPY = cp -p
# EXE = .exe
# LEX = flex
# LN = ln
# ZIP = zip -o
################################################################
# General, C compilation:
CC = gcc -D$(SYSTEM) -D$(SUBSYSTEM)
LINT = lint -ansi -D$(SYSTEM) -D$(SUBSYSTEM)
LINTFLAGS = -xh
# General, text:
LATEX = pdflatex
SHOW_PDF = pdfview
GROFF = groff -man
GROFF = man2pdf
.SUFFIXES: .1 .3 .pdf
.1.pdf:
$(GROFF) $<
.3.pdf:
$(GROFF) $<
# =============== end of ../lib/sysidf.mk
# Compiling
MEMORY = -DMEMCHECK -DMEMCLOBBER
CFLAGS = $(VERSION) $(MEMORY) -O4 # -Dlint -DLIB # for all db active
LIBFLAGS = #
LINTFLAGS = -Dlint_test $(MEMORY) -h# -X
LOADFLAGS = -s# # strip symbol table
LOADER = $(CC) $(LOADFLAGS)
# Debugging
CFLAGS += -DDEBUG
# T E S T P A R A M E T E R S
# Rumen Stevanov test
TEST_LANG = text
TEST_OPT = -pPae -r4 -O -t4
TEST_INP = Contributors/Rumen_Stefanov/new/*.txt
# slash test
TEST_LANG = text
TEST_OPT = -r24 -M clang.l pasclang.l "|" textlang.l
TEST_INP =
# -i option test
TEST_LANG = c
TEST_OPT = -f -r 20 -R -i <option-i.inp
TEST_INP = #
# overlap test, foo^100 vs. foo^150
TEST_LANG = text
TEST_OPT = -r50 -p
TEST_OPT = -r50
TEST_INP = Test_percentages/foo_100
TEST_INP = Test_percentages/foo_100 Test_percentages/foo_150
# single file test
TEST_LANG = c
TEST_OPT = -r24 -M
TEST_INP = pass3.c pass3.c # compares 1st to 2nd, then 2nd to 2nd
# tight match test, foo_100 has exactly 100 tokens
TEST_LANG = text
TEST_OPT = -r50
TEST_INP = Test_percentages/foo_100
# percentage test
TEST_LANG = c
TEST_OPT = -puae
TEST_INP = *.l
# spaced word test
TEST_LANG = text
TEST_OPT = -r 5
TEST_INP = Testfiles/test_seplet
# larger test
TEST_LANG = text
TEST_OPT = -r24 -M -puae
TEST_INP = clang.c textlang.c
TEST_INP = textlang.c clang.c javalang.c
# test UTF-8 file names
TEST_LANG = text
TEST_OPT = Kor_test/한국어 Kor_test/한국어# 'make' cannot see these files
TEST_INP = #
# test UTF-8 recursive file name test
TEST_LANG = text
TEST_OPT = -R Kor_test
TEST_INP = #
# test bad UTF-8 text
TEST_LANG = text
TEST_OPT = -r12 -MO -w80
TEST_INP = Testfiles/Korean1_bad.txt Testfiles/Korean1_bad2.txt
# test UTF-8 text
TEST_LANG = text
TEST_OPT = -r12 -MO -w80
TEST_INP = Testfiles/Korean1.txt Testfiles/Korean2.txt
# test
TEST_LANG = c
TEST_OPT = -r10 -MO -
TEST_INP = pass2.c pass1.c
# M A I N M O D U L E S
# Each module (set of programs that together perform some function)
# has the following sets of files defined for it:
# _SRC the C-files from which the object files derive
# _OBJ object files
# _HDR header files and other include files
# _GRB garbage files produced by the module
#
# (This is a feeble attempt at software-engineering a Makefile.)
#
test: sim.res stream.res percentages.res version.res
./sim_$(TEST_LANG)$(EXE) -v
# B I N A R I E S
BINARIES = sim_c$(EXE) sim_c++$(EXE) sim_java$(EXE) sim_pasc$(EXE) \
sim_m2$(EXE) sim_lisp$(EXE) sim_mira$(EXE) sim_text$(EXE) \
sim_8086$(EXE)
binaries: $(BINARIES)# # for *N?X
exes: binaries# # for MSDOS
test_exes: binaries# # for packCVS
# A U X I L I A R Y M O D U L E S
# Common modules:
COM_SRC = token.c lex.c stream.c text.c tokenarray.c debug.c \
utf8.c ForEachFile.c fname.c Malloc.c any_int.c
COM_OBJ = token.o lex.o stream.o text.o tokenarray.o debug.o \
utf8.o ForEachFile.o fname.o Malloc.o any_int.o
COM_HDR = token.h lex.h stream.h text.h tokenarray.h debug.h \
utf8.h ForEachFile.h fname.h Malloc.h any_int.h \
lang.h \
sortlist.spc sortlist.bdy system.par
# C files for the abstract modules:
ABS_SRC = lang.c
# The idf module:
IDF_SRC = idf.c
IDF_OBJ = idf.o
IDF_HDR = idf.h
# The runs package:
RUNS_SRC = runs.c percentages.c
RUNS_OBJ = runs.o percentages.o
RUNS_HDR = runs.h percentages.h
# The main program:
MAIN_SRC = sim.c options.c newargs.c hash.c compare.c add_run.c \
pass1.c pass2.c pass3.c
MAIN_OBJ = sim.o options.o newargs.o hash.o compare.o add_run.o \
pass1.o pass2.o pass3.o
MAIN_HDR = sim.h options.h newargs.h hash.h compare.h add_run.h \
pass1.h pass2.h pass3.h \
debug.par settings.par
sim.o: Makefile # because of $(VERSION)
# The similarity tester without the language part:
SIM_SRC = $(COM_SRC) $(IDF_SRC) $(RUNS_SRC) $(MAIN_SRC)
SIM_OBJ = $(COM_OBJ) $(IDF_OBJ) $(RUNS_OBJ) $(MAIN_OBJ)
SIM_HDR = $(COM_HDR) $(IDF_HDR) $(RUNS_HDR) $(MAIN_HDR)
# L A N G U A G E S
# The properties module:
PROP_SRC = properties.c
PROP_OBJ = properties.o
PROP_HDR = properties.h
# The Generic Language module
# variable: GEN_LANG
# entry point: sim_gen$(EXE)
# makes: sim_$(GEN_LANG)$(EXE)
sim_gen.c: $(GEN_LANG)lang.l
$(LEX) -t $(GEN_LANG)lang.l >sim_gen.c
SIM_GEN_SRC = $(SIM_SRC) $(PROP_SRC) sim_gen.c
SIM_GEN_OBJ = $(SIM_OBJ) $(PROP_OBJ) sim_gen.o
sim_gen$(EXE): $(SIM_GEN_OBJ)
$(LOADER) $(SIM_GEN_OBJ) -o $@
mv sim_gen$(EXE) sim_$(GEN_LANG)$(EXE)
rm -f sim_gen.[co]
# The executables: # using recursive make
LEX_HDR: options.h token.h properties.h idf.h lex.h lang.h
sim_c$(EXE): $(SIM_SRC) $(PROP_SRC) clang.l $(LEX_HDR)
make GEN_LANG=c sim_gen$(EXE)
sim_text$(EXE): $(SIM_SRC) $(PROP_SRC) textlang.l $(LEX_HDR)
make GEN_LANG=text sim_gen$(EXE)
sim_c++$(EXE): $(SIM_SRC) $(PROP_SRC) c++lang.l $(LEX_HDR)
make GEN_LANG=c++ sim_gen$(EXE)
sim_java$(EXE): $(SIM_SRC) $(PROP_SRC) javalang.l $(LEX_HDR)
make GEN_LANG=java sim_gen$(EXE)
sim_pasc$(EXE): $(SIM_SRC) $(PROP_SRC) pasclang.l $(LEX_HDR)
make GEN_LANG=pasc sim_gen$(EXE)
sim_m2$(EXE): $(SIM_SRC) $(PROP_SRC) m2lang.l $(LEX_HDR)
make GEN_LANG=m2 sim_gen$(EXE)
sim_lisp$(EXE): $(SIM_SRC) $(PROP_SRC) lisplang.l $(LEX_HDR)
make GEN_LANG=lisp sim_gen$(EXE)
sim_mira$(EXE): $(SIM_SRC) $(PROP_SRC) miralang.l $(LEX_HDR)
make GEN_LANG=mira sim_gen$(EXE)
sim_8086$(EXE): $(SIM_SRC) $(PROP_SRC) 8086lang.l $(LEX_HDR)
make GEN_LANG=8086 sim_gen$(EXE)
# T E S T S
# Some simple tests:
.PHONY: sim.res percentages.res
sim.res: sim_$(TEST_LANG)$(EXE) $(TEST_INP)
./sim_$(TEST_LANG)$(EXE) $(TEST_OPT) $(TEST_INP)
stream.res: sim_$(TEST_LANG)$(EXE)
./sim_$(TEST_LANG)$(EXE) -- $(TEST_OPT) $(TEST_INP) >$@
wc $@ $(TEST_INP)
GARBAGE = stream.res
PERC_TEST_EXE = sim_text$(EXE)
PERC_TEST_FILES = Test_percentages/foo_100 Test_percentages/foo_150
PERC_TEST_EXE = sim_c$(EXE)
PERC_TEST_FILES = pasclang.l clang.l javalang.l
percentages.res:$(PERC_TEST_EXE) $(PERC_TEST_FILES)
@echo ''
./$(PERC_TEST_EXE) -T -p $(PERC_TEST_FILES)
@echo ''
./$(PERC_TEST_EXE) -T -pa $(PERC_TEST_FILES)
@echo ''
./$(PERC_TEST_EXE) -T -pae $(PERC_TEST_FILES)
version.res: sim_$(TEST_LANG)$(EXE)
./sim_$(TEST_LANG)$(EXE) -v
# More simple tests, using the C version only:
simsim: sim_c$(EXE) $(SIM_SRC) $(PROP_SRC)
./sim_c$(EXE) -fr 20 $(SIM_SRC) $(PROP_SRC)
# Lint
lint: $(SIM_SRC) $(PROP_SRC) $(ABS_SRC) \
$(SIM_HDR) $(PROP_HDR) $(ABS_HDR)
$(LINT) $(LINTFLAGS) $(SIM_SRC) $(PROP_SRC) $(ABS_SRC)
# O T H E R E N T R I E S
# Documentation
view_man: sim.pdf
$(SHOW_PDF) sim.pdf
%.pdf: %.tex
$(LATEX) $< || log2errmsg <$*.log
$(LATEX) $<
$(LATEX) $<
SPC = Similarity_Percentage_Computation
view_SPC: $(SPC).pdf
$(SHOW_PDF) $(SPC).pdf
DOCS += $(SPC).pdf
# LaTeX checker
chklat:
chklat *.tex
# Installation
install_all: install # just a synonym
install: $(MAN1DIR)/sim.1 \
$(BINDIR)/sim_c$(EXE) \
$(BINDIR)/sim_text$(EXE) \
$(BINDIR)/sim_c++$(EXE) \
$(BINDIR)/sim_java$(EXE) \
$(BINDIR)/sim_pasc$(EXE) \
$(BINDIR)/sim_m2$(EXE) \
$(BINDIR)/sim_lisp$(EXE) \
$(BINDIR)/sim_mira$(EXE) \
$(BINDIR)/sim_8086$(EXE)
$(MAN1DIR)/sim.1: sim.1
$(COPY) sim.1 $@
$(BINDIR)/sim_c$(EXE): sim_c$(EXE)
$(COPY) sim_c$(EXE) $@
$(BINDIR)/sim_text$(EXE): sim_text$(EXE)
$(COPY) sim_text$(EXE) $@
$(BINDIR)/sim_c++$(EXE): sim_c++$(EXE)
$(COPY) sim_c++$(EXE) $@
$(BINDIR)/sim_java$(EXE): sim_java$(EXE)
$(COPY) sim_java$(EXE) $@
$(BINDIR)/sim_pasc$(EXE): sim_pasc$(EXE)
$(COPY) sim_pasc$(EXE) $@
$(BINDIR)/sim_m2$(EXE): sim_m2$(EXE)
$(COPY) sim_m2$(EXE) $@
$(BINDIR)/sim_lisp$(EXE): sim_lisp$(EXE)
$(COPY) sim_lisp$(EXE) $@
$(BINDIR)/sim_mira$(EXE): sim_mira$(EXE)
$(COPY) sim_mira$(EXE) $@
$(BINDIR)/sim_8086$(EXE): sim_8086$(EXE)
$(COPY) sim_8086$(EXE) $@
# Clean-up
.PHONY: clean fresh
clean:
-rm -f *.o
-rm -f $(GARBAGE)
-rm -f *.aux *.log *.out
-rm -f a.out a.exe sim.txt core mon.out
fresh: clean
-rm -f *.exe
# D E P E N D E N C I E S
# DO NOT DELETE THIS LINE -- make depend depends on it.
ForEachFile.o: ForEachFile.c ForEachFile.h fname.h
Malloc.o: Malloc.c any_int.h Malloc.h
add_run.o: add_run.c sim.h text.h runs.h percentages.h options.h \
add_run.h
any_int.o: any_int.c any_int.h
compare.o: compare.c sim.h text.h token.h tokenarray.h hash.h \
properties.h options.h add_run.h compare.h debug.par
count_sim_dup.o: count_sim_dup.c
debug.o: debug.c debug.h
fname.o: fname.c fname.h
hash.o: hash.c system.par debug.par sim.h text.h Malloc.h any_int.h \
token.h properties.h tokenarray.h options.h hash.h
idf.o: idf.c system.par token.h idf.h
lang.o: lang.c token.h properties.h idf.h lex.h lang.h
lex.o: lex.c lex.h
newargs.o: newargs.c sim.h ForEachFile.h fname.h Malloc.h newargs.h
options.o: options.c sim.h token.h lang.h options.h
pass1.o: pass1.c debug.par sim.h text.h token.h tokenarray.h lang.h \
options.h pass1.h
pass2.o: pass2.c debug.par sim.h token.h text.h lang.h pass2.h \
sortlist.bdy
pass3.o: pass3.c system.par debug.par sim.h options.h fname.h text.h \
token.h runs.h percentages.h pass3.h
percentages.o: percentages.c debug.par sim.h text.h options.h Malloc.h \
percentages.h sortlist.bdy
properties.o: properties.c sim.h options.h token.h properties.h
runs.o: runs.c sim.h text.h runs.h Malloc.h debug.par sortlist.bdy
sim.o: sim.c system.par settings.par sim.h options.h newargs.h token.h \
tokenarray.h text.h runs.h hash.h compare.h pass1.h pass2.h pass3.h \
percentages.h stream.h lang.h Malloc.h any_int.h
stream.o: stream.c system.par sim.h token.h lang.h fname.h stream.h
t.o: t.c
text.o: text.c stream.h Malloc.h text.h
token.o: token.c token.h
tokenarray.o: tokenarray.c sim.h Malloc.h token.h lang.h tokenarray.h