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
|
## Parameters ##################################################################
#### Where to find the level files
ifndef LEVEL_FILES
LEVEL_FILES =
endif
#### Where to find the properties to verify
ifndef PROPERTY_FILES
PROPERTY_FILES =
endif
#### Where to find the model
ifndef MODEL_DIR
MODEL_DIR =
endif
#### Where to store & find the PATH models
ifndef PATH_MODEL_DIR
PATH_MODEL_DIR = $(MODEL_DIR)/path/
endif
#### Where to output the solutions.
ifndef SOL_DIR
SOL_DIR =
endif
#### Where to get the missing Jar files.
ifndef JAR_SOURCE
JAR_SOURCE = "https://noot-noot.org/tabellion/jar/"
endif
#### Binaries
###### JRE binary
ifndef JAVA
JAVA = java
endif
###### JDK binary
ifndef JAVAC
JAVAC = javac
endif
##### Downloader
ifndef DOWNLOADER
DOWNLOADER = wget
endif
## Parameters Sanity Check #####################################################
ifeq ($(strip $(LEVEL_FILES)),)
$(error No LEVEL_FILES defined as parameter.)
endif
ifeq ($(strip $(PROPERTY_FILES)),)
$(error No PROPERTY_FILES defined as parameter.)
endif
ifeq ($(strip $(MODEL_DIR)),)
$(error No MODEL_DIR defined as parameter.)
endif
ifeq ($(strip $(PATH_MODEL_DIR)),)
$(error No PATH_MODEL_DIR defined as parameter.)
endif
ifeq ($(strip $(SOL_DIR)),)
$(error No SOL_DIR defined as parameter.)
endif
ifeq ($(strip $(JAR_SOURCE)),)
$(error No JAR_SOURCE defined as parameter.)
endif
ifeq ($(strip $(JAVA)),)
$(error No Java executable defined as parameter.)
endif
ifeq ($(strip $(JAVAC)),)
$(error No Java compiler defined as parameter.)
endif
ifeq ($(strip $(DOWNLOADER)),)
$(error No Java executable defined as parameter.)
endif
################################################################################
CLASSPATH = "kodkod.jar:./src/:./parser/:org.sat4j.core.jar:antlr-4.7-complete.jar"
REQUIRED_JARS = kodkod.jar org.sat4j.core.jar antlr-4.7-complete.jar
ANTLR_JAR = ${CURDIR}/antlr-4.7-complete.jar
## Makefile Magic ##############################################################
SOURCES = $(wildcard src/*.java)
CLASSES = $(SOURCES:.java=.class)
SOLUTION_FILES = $(addprefix $(SOL_DIR)/,$(notdir $(PROPERTY_FILES:.pro=.sol)))
MODEL_FILES = \
$(MODEL_DIR)/structural.mod \
$(MODEL_DIR)/depths.mod \
$(MODEL_DIR)/string_to_instr.map \
$(filter-out %structural.mod,$(wildcard $(MODEL_DIR)/cfg_*.mod))
PARSER_SOURCES = $(wildcard parser/*.g4)
PARSER_CLASSES = $(PARSER_SOURCES:.g4=.class)
export
## Makefile Rules ##############################################################
run: cfg-generator $(PARSER_CLASSES) $(CLASSES) $(SOLUTION_FILES)
build: $(PARSER_CLASSES) $(CLASSES)
$(MAKE) -C cfg-to-paths build
cfg-generator:
$(MAKE) -C cfg-to-paths
$(PARSER_CLASSES): antlr-4.7-complete.jar kodkod.jar $(PARSER_SOURCES)
$(MAKE) -C parser
clean:
$(MAKE) -C parser clean
$(MAKE) -C cfg-to-paths clean
rm -f $(CLASSES)
rm -f $(SOL_DIR)/*.sol
$(SOL_DIR)/%.sol: $(PROPERTY_FILES) $(MODEL_FILES) $(LEVEL_FILES)
touch $@
$(JAVA) -cp $(CLASSPATH) Main $@ \
$(filter %$(basename $(notdir $@)).pro,$(PROPERTY_FILES)) \
$(LEVEL_FILES) \
$(MODEL_FILES) \
$(wildcard $(PATH_MODEL_DIR)/*.mod)
src/%.class: src/%.java $(PARSER_CLASSES) $(REQUIRED_JARS)
$(JAVAC) -cp $(CLASSPATH) $<
%.jar:
echo "Attempting to download missing jar '$@'..."
$(DOWNLOADER) "$(JAR_SOURCE)/$@"
|