-
Notifications
You must be signed in to change notification settings - Fork 454
/
Makefile
167 lines (138 loc) · 5.25 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
.PHONY: clean contributors validate run maps lint build/hawkthorne.love love love.js
UNAME := $(shell uname)
TILEMAPS := $(patsubst %.tmx,%.lua,$(wildcard src/maps/*.tmx))
LOVE_DOWNLOAD_URL = https://github.com/love2d/love/releases/download
LOVE_VERSION = 11.5
MACOS_APP=build/Journey\ to\ the\ Center\ of\ Hawkthorne.app
ifeq ($(UNAME), Darwin)
TMXTAR = tmx2lua.osx.zip
LOVE = bin/love.app/Contents/MacOS/love
# macOS cannot create a Linux AppImage
BINARIES = build/hawkthorne-macos.zip build/hawkthorne-win32.zip build/hawkthorne-win64.zip
else
TMXTAR = tmx2lua.linux.tar.gz
LOVE = bin/love.AppImage
BINARIES = build/hawkthorne-macos.zip build/hawkthorne-win32.zip build/hawkthorne-win64.zip build/hawkthorne-linux.AppImage
endif
ifeq ($(shell which wget),)
WGET = curl -s -O -L
else
WGET = wget -q --no-check-certificate
endif
maps: $(TILEMAPS)
love: build/hawkthorne.love
love.js: build/hawkthorne.love
mkdir -p build/web
npm install
npx love.js -m 77594624 -c build/hawkthorne.love build/web
build/hawkthorne.love: $(TILEMAPS) src/*
mkdir -p build
rm -f build/hawkthorne.love
cd src && zip --symlinks -q -r ../build/hawkthorne.love . \
-x ".*" \
-x "*.DS_Store" \
-x "psds/*" \
-x "test/*" \
-x "*.tmx" \
-x "maps/test-level.lua" \
-x "*/full_soundtrack.ogg" \
-x "*.bak"
run: $(TILEMAPS) $(LOVE)
$(LOVE) src
src/maps/%.lua: src/maps/%.tmx bin/tmx2lua
bin/tmx2lua $<
# tmx2lua requires golang to be installed.
# If you need to install it on macOS:
# brew update && brew install golang
bin/tmx2lua:
mkdir -p bin
$(WGET) https://github.com/hawkthorne/tmx2lua/releases/download/v1.0.1/$(TMXTAR)
ifeq ($(UNAME), Darwin)
unzip -q $(TMXTAR)
else
tar -xzvf $(TMXTAR)
endif
rm -f $(TMXTAR) ._tmx2lua
mv tmx2lua bin
bin/win32/love.exe:
$(WGET) $(LOVE_DOWNLOAD_URL)/$(LOVE_VERSION)/love-$(LOVE_VERSION)-win32.zip
unzip -q love-$(LOVE_VERSION)-win32.zip
mv love-$(LOVE_VERSION)-win32 bin/win32
rm -f love-$(LOVE_VERSION)-win32.zip
rm bin/win32/changes.txt bin/win32/game.ico bin/win32/love.ico bin/win32/readme.txt
bin/win64/love.exe:
$(WGET) $(LOVE_DOWNLOAD_URL)/$(LOVE_VERSION)/love-$(LOVE_VERSION)-win64.zip
unzip -q love-$(LOVE_VERSION)-win64.zip
mv love-$(LOVE_VERSION)-win64 bin/win64
rm -f love-$(LOVE_VERSION)-win64.zip
rm bin/win64/changes.txt bin/win64/game.ico bin/win64/love.ico bin/win64/readme.txt
bin/love.app/Contents/MacOS/love:
mkdir -p bin
$(WGET) $(LOVE_DOWNLOAD_URL)/$(LOVE_VERSION)/love-$(LOVE_VERSION)-macos.zip
unzip -q love-$(LOVE_VERSION)-macos.zip
rm -f love-$(LOVE_VERSION)-macos.zip
mv love.app bin
bin/love.AppImage:
mkdir -p bin
$(WGET) $(LOVE_DOWNLOAD_URL)/$(LOVE_VERSION)/love-$(LOVE_VERSION)-x86_64.AppImage
mv love-$(LOVE_VERSION)-x86_64.AppImage bin/love.AppImage
chmod a+x bin/love.AppImage
bin/appimagetool.AppImage:
mkdir -p bin
$(WGET) https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage
mv appimagetool-x86_64.AppImage bin/appimagetool.AppImage
chmod a+x bin/appimagetool.AppImage
build/win32/hawkthorne.exe: build/hawkthorne.love bin/win32/love.exe
mkdir -p build/win32
cat bin/win32/love.exe build/hawkthorne.love > build/win32/hawkthorne.exe
build/win64/hawkthorne.exe: build/hawkthorne.love bin/win64/love.exe
mkdir -p build/win64
cat bin/win64/love.exe build/hawkthorne.love > build/win64/hawkthorne.exe
build/hawkthorne-win32.zip: build/win32/hawkthorne.exe
cp -R bin/win32/* build/win32/
zip --symlinks -q -r hawkthorne-win32 build/win32/ -x "*/love*.exe"
mv hawkthorne-win32.zip build
build/hawkthorne-win64.zip: build/win64/hawkthorne.exe
cp -R bin/win64/* build/win64/
zip --symlinks -q -r hawkthorne-win64 build/win64/ -x "*/love*.exe"
mv hawkthorne-win64.zip build
$(MACOS_APP): build/hawkthorne.love bin/love.app/Contents/MacOS/love
cp -R bin/love.app $(MACOS_APP)
cp build/hawkthorne.love $(MACOS_APP)/Contents/Resources/hawkthorne.love
cp templates/macos/Info.plist $(MACOS_APP)/Contents/Info.plist
cp templates/macos/Hawkthorne.icns $(MACOS_APP)/Contents/Resources/GameIcon.icns
build/hawkthorne-macos.zip: $(MACOS_APP)
mkdir -p build
zip --symlinks -q -r hawkthorne-macos $(MACOS_APP)
mv hawkthorne-macos.zip build
build/hawkthorne-linux.AppImage: build/hawkthorne.love bin/love.AppImage bin/appimagetool.AppImage
mkdir -p build/linux
bin/love.AppImage --appimage-extract
mv squashfs-root build/linux/
cat build/linux/squashfs-root/bin/love build/hawkthorne.love > build/linux/squashfs-root/bin/hawkthorne
chmod a+x build/linux/squashfs-root/bin/hawkthorne
cp templates/linux/{AppRun,hawkthorne.png,love.desktop} build/linux/squashfs-root/
rm build/linux/squashfs-root/bin/love build/linux/squashfs-root/love.svg
./bin/appimagetool.AppImage build/linux/squashfs-root build/hawkthorne-linux.AppImage
chmod a+x build/hawkthorne-linux.AppImage
binaries: $(BINARIES)
venv:
python3 -m venv venv
venv/bin/pip install -q -r requirements.txt
contributors: venv
venv/bin/python scripts/credits.py > src/credits.lua
test: $(LOVE) maps
$(LOVE) src --test
validate: venv lint
venv/bin/python scripts/validate.py src
lint:
touch src/maps/init.lua
find src -name "*.lua" | grep -v "src/vendor" | grep -v "src/test" | \
xargs -I {} ./scripts/lualint.lua -r "{}"
clean:
rm -rf bin/
rm -rf build/
rm -rf venv/
rm -rf node_modules/
rm -rf scripts/*.pyc
rm -rf src/maps/*.lua