-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
executable file
·84 lines (65 loc) · 1.88 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
TARGET = Asl
# Directories
ROOT = $(PWD)
SRCDIR = $(ROOT)/src
LIBDIR = $(ROOT)/libs
CLASSDIR = $(ROOT)/classes
MAIN = $(SRCDIR)/$(TARGET)
PARSER = $(SRCDIR)/parser
INTERP = $(SRCDIR)/interp
JAVADOC = $(ROOT)/javadoc
BIN = $(ROOT)/bin
# Executable
EXEC = $(BIN)/$(TARGET)
JARFILE = $(BIN)/$(TARGET).jar
MANIFEST= $(BIN)/$(TARGET)_Manifest.txt
# Libraries and Classpath
LIB_ANTLR = $(LIBDIR)/antlr-3.4-complete.jar
LIB_CLI = $(LIBDIR)/commons-cli-1.2.jar
LIB_MUS = $(LIBDIR)/jfuguecincopuntoocho.jar
CLASSPATH= $(LIB_ANTLR):$(LIB_CLI):$(LIB_MUS)
JARPATH= "$(LIB_ANTLR) $(LIB_CLI) $(LIB_MUS)"
# Distribution (tar) file
DATE= $(shell date +"%d%b%y")
DISTRIB= $(TARGET)_$(DATE).tgz
# Classpath
# Flags
JFLAGS = -classpath $(CLASSPATH) -d $(CLASSDIR)
DOCFLAGS = -classpath $(CLASSPATH) -d $(JAVADOC) -private
# Source files
GRAMMAR = $(PARSER)/$(TARGET).g
MAIN_SRC = $(MAIN)/$(TARGET).java
PARSER_SRC = $(PARSER)/$(TARGET)Lexer.java \
$(PARSER)/$(TARGET)Parser.java
INTERP_SRC = $(INTERP)/Interp.java \
$(INTERP)/Stack.java \
$(INTERP)/Data.java \
$(INTERP)/$(TARGET)Tree.java \
$(INTERP)/AslTreeAdaptor.java
ALL_SRC = $(MAIN_SRC) $(PARSER_SRC) $(INTERP_SRC)
all: compile exec docs
compile:
java -jar $(LIB_ANTLR) -o $(PARSER) $(GRAMMAR)
if [ ! -e $(CLASSDIR) ]; then\
mkdir $(CLASSDIR);\
fi
javac $(JFLAGS) $(ALL_SRC)
docs:
javadoc $(DOCFLAGS) $(ALL_SRC)
exec:
if [ ! -e $(BIN) ]; then\
mkdir $(BIN);\
fi
echo "Main-Class: Asl.Asl" > $(MANIFEST)
echo "Class-Path: $(JARPATH)" >> $(MANIFEST)
cd $(CLASSDIR); jar -cmf $(MANIFEST) $(JARFILE) *
printf "#!/bin/sh\n\n" > $(EXEC)
printf 'exec java -enableassertions -jar $(JARFILE) "$$@"' >> $(EXEC)
chmod a+x $(EXEC)
clean:
rm -rf $(PARSER)/*.java $(PARSER)/*.tokens
rm -rf $(CLASSDIR)
rm -rf $(JAVADOC)
rm -rf $(BIN)
tar: clean
cd ..; tar cvzf $(DISTRIB) $(TARGET); mv $(DISTRIB) $(TARGET); cd $(TARGET)