summaryrefslogtreecommitdiff
blob: f5c6e7a6bd4586f664d8ba077e6c431fe969ea28 (plain)
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
## Parameters ##################################################################
#### Where to find the solutions.
SOL_DIR ?=

#### Where to find the model's data
MODEL_DIR ?=

#### Where to find the properties' pretty-print files
TEMPLATE_DIR ?=

NICE_MESSAGE_FILE ?=

#### Binaries
###### JRE binary
JAVA ?= java

###### JDK binary
JAVAC ?= javac

## Parameters Sanity Check #####################################################
ifeq ($(strip $(SOL_DIR)),)
$(error No SOL_DIR defined as parameter.)
endif

ifeq ($(strip $(MODEL_DIR)),)
$(error No MODEL_DIR defined as parameter.)
endif

ifeq ($(strip $(TEMPLATE_DIR)),)
$(error No TEMPLATE_DIR 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

################################################################################
CLASSPATH = "./src/"

## Makefile Magic ##############################################################
SOURCES = $(wildcard src/*.java)
CLASSES = $(SOURCES:.java=.class)

SOLUTION_FILES = $(wildcard $(SOL_DIR)/*.sol)
PROPERTY_PP_FILES = $(wildcard $(TEMPLATE_DIR)/*.pp)
SOLUTION_PP_PAIRS = \
	$(foreach sf,$(SOLUTION_FILES),$(sf) $(filter %$(basename $(notdir $(sf))).pp,$(PROPERTY_PP_FILES)))

## Makefile Rules ##############################################################
compile: $(CLASSES)

model:

ifeq ($(strip $(NICE_MESSAGE)),)
solutions: $(SOLUTION_PP_PAIRS) $(MODEL_DIR)/structural.mod $(MODEL_DIR)/string_to_instr.map $(CLASSES)
	$(JAVA) -cp $(CLASSPATH) Main $(MODEL_DIR)/structural.mod $(MODEL_DIR)/string_to_instr.map $(SOLUTION_PP_PAIRS)
else
solutions: $(SOLUTION_PP_PAIRS) $(MODEL_DIR)/structural.mod $(MODEL_DIR)/string_to_instr.map $(CLASSES)
	$(JAVA) -cp $(CLASSPATH) Main $(MODEL_DIR)/structural.mod $(MODEL_DIR)/string_to_instr.map $(SOLUTION_PP_PAIRS) > $(NICE_MESSAGE)
endif

clean:
	rm -f $(CLASSES)
	rm -f $(SOL_DIR)/*.sol

clean_model:

clean_solutions:
	rm -f $(SOL_DIR)/*.sol

########
%.class: %.java
	$(JAVAC) -cp $(CLASSPATH) $<