-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
102 lines (77 loc) · 3.11 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
GPGKEY ="8038DEBE14AD09A4"
MFFILE = build/manifest.mf
LICENCEFILE = build/LICENCE.txt
MACFILE = build/HTGT-Debug-macOS_$(version)
MACSTART = build/Start-HTGT-macOS_$(version)
SHFILE = build/HTGT-Debug-Linux_$(version).sh
SHSTART = build/Start-HTGT-Linux_$(version).sh
BATFILE = build/HTGT-Debug-Windows_$(version).bat
BATSTART = build/Start-HTGT-Windows_$(version).bat
SIGFILE = build/HTGT_$(version).sha512.sig
CSUMFILE = build/HTGT_$(version).sha512
JARFILE = build/HTGT_$(version).jar
ZIPFILE = build/HTGT_$(version).zip
VFILE = htgt-version.txt
TARGET = 9
XLINT = -Xlint:all -Xlint:-options
JFLAGS = -source $(TARGET) -target $(TARGET) -g -sourcepath ./src -classpath ./classes -d ./classes $(XLINT)
VMFLAGS = -classpath ./classes
JC = javac
JAVA = java
JAR = jar
sources = $(wildcard src/*.java)
classes = $(sources:.java=.class)
lbundles = $(wildcard src/LangBundle_*.properties)
rbundles = $(lbundles:src/LangBundle_%=src/RealLangBundle_%)
version = $(strip $(shell $(JAVA) $(VMFLAGS) HTGT -v))
commit = $(shell git rev-parse --short HEAD)
all: clean compile jar zip simpleclean
i18n: $(rbundles)
RealLangBundle_%.properties: LangBundle_%.properties
cp -af $< $@
sed -i -r 's/^#.*$$//g;/^$$/d' $@
compile: $(classes) i18n
echo Original version: $(version)
@echo git-$(commit) > $(VFILE)
cp -af ./src/RealLangBundle_*.properties ./classes/
%.class: %.java
$(JC) $(JFLAGS) $<
jar: compile
@echo Packaging version $(version)
@echo "Manifest-Version: 1.0" > $(MFFILE)
@echo "Class-Path: ." >> $(MFFILE)
@echo "Main-Class: HTGT" >> $(MFFILE)
@echo "Permissions: all-permissions" >> $(MFFILE)
cd ./classes && \
$(JAR) -cmf ../$(MFFILE) ../$(JARFILE) ./*.class ./RealLangBundle_*.properties ../$(VFILE) && \
chmod +x ../$(JARFILE) && $(RM) ../$(MFFILE)
zip: jar
@echo Zipping version $(version)
cp -af scr/HTGT-Debug-Linux.sh $(SHFILE)
sed -i "s/HTGT.jar/HTGT_$(version).jar/" $(SHFILE)
cp -af scr/Start-HTGT-Linux.sh $(SHSTART)
sed -i "s/HTGT.jar/HTGT_$(version).jar/" $(SHSTART)
cp -af scr/HTGT-Debug-macOS $(MACFILE)
sed -i "s/HTGT.jar/HTGT_$(version).jar/" $(MACFILE)
cp -af scr/Start-HTGT-macOS $(MACSTART)
sed -i "s/HTGT.jar/HTGT_$(version).jar/" $(MACSTART)
cp -af scr/HTGT-Debug-Windows.bat $(BATFILE)
sed -i "s/HTGT.jar/HTGT_$(version).jar/" $(BATFILE)
cp -af scr/Start-HTGT-Windows.bat $(BATSTART)
sed -i "s/HTGT.jar/HTGT_$(version).jar/" $(BATSTART)
cp -af LICENCE $(LICENCEFILE)
unix2dos $(LICENCEFILE)
zip -j $(ZIPFILE) $(LICENCEFILE) $(JARFILE) $(SHFILE) $(SHSTART) $(MACFILE) $(MACSTART) $(BATFILE) $(BATSTART)
$(RM) $(LICENCEFILE) $(SHFILE) $(SHSTART) $(MACFILE) $(MACSTART) $(BATFILE) $(BATSTART)
sig: zip
@echo Signing version $(version)
sha512sum $(JARFILE) $(ZIPFILE) > $(CSUMFILE)
sed -i 's#build/##' $(CSUMFILE) && $(RM) $(SIGFILE)
gpg -u $(GPGKEY) --armor --output $(SIGFILE) --detach-sig $(CSUMFILE)
clean: simpleclean
$(RM) build/HTGT_*.*
simpleclean:
$(RM) $(MFFILE) $(VFILE) $(LICENCEFILE)
$(RM) classes/*.class classes/*.properties src/*.class src/RealLangBundle_*.properties
fullclean: clean
$(RM) HTGT-Debug.log