-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
127 lines (93 loc) · 2.9 KB
/
Makefile
File metadata and controls
127 lines (93 loc) · 2.9 KB
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
# Configuration
APPNAME = $(strip $(shell make -s app-name))
VERSION = $(strip $(shell make -s app-version))
NAME = $(strip $(shell make -s dune-public_name))
MAIN = main
NONDEPS = unix audio_file [a-zA-Z0-9_]*[.][a-zA-Z0-9_.]*
DEPS = dune $(strip $(shell make -s dune-libraries $(NONDEPS:%=| sed 's/ %//g')))
ifeq ($(OS),Windows_NT)
SYSTEM = win
else
ifeq ($(shell uname -s),Darwin)
SYSTEM = mac
endif
ifeq ($(shell uname -s),Linux)
SYSTEM = linux
endif
endif
ASSETS = $(wildcard assets/*)
SYSASSETS = $(wildcard platform/$(SYSTEM)/* platform/$(SYSTEM)/*/* platform/$(SYSTEM)/*/*/*)
WIN_DLLS = libwinpthread-1 libffi-6
# Main Targets
default:
make $(SYSTEM)
vars:
@echo 'NAME = $(NAME)'
@echo 'MAIN = $(MAIN)'
@echo 'APPNAME = $(APPNAME)'
@echo 'VERSION = $(VERSION)'
@echo 'SYSTEM = $(SYSTEM)'
@echo 'DEPS = $(DEPS)'
@echo 'ASSETS = $(ASSETS)'
@echo 'SYSASSETS = $(SYSASSETS)'
deps:
opam install --yes --deps-only $(DEPS) # Temporary workaround for Opam Windows bug
opam install --yes $(DEPS)
upgrade:
opam update
opam upgrade --yes
exe:
cd src && opam exec -- dune build $(MAIN).exe
ln -f _build/default/src/$(MAIN).exe $(NAME).exe
# Packaging
prerequisites: deps exe $(ASSETS) $(SYSASSETS)
dir: prerequisites
mkdir -p $(APPNAME)
cp -f $(NAME).exe $(APPNAME)/$(APPNAME).exe
cp -rf assets $(APPNAME)
win: dir
@if [ "$(WIN_DLLS)" != '' ]; then cp $(WIN_DLLS:%=`opam exec -- which %.dll`) $(APPNAME); fi
linux: dir
mac: prerequisites
osacompile -o _build/run.app platform/mac/run.scpt
mkdir -p $(APPNAME).app/Contents/MacOS
mkdir -p $(APPNAME).app/Contents/Resources
cp -rf platform/mac/Contents $(APPNAME).app
cp -rf $(NAME).exe $(APPNAME).app/Contents/$(APPNAME)
cp -rf assets $(APPNAME).app/Contents
cp -rf _build/run.app/Contents/MacOS/droplet $(APPNAME).app/Contents/MacOS/$(APPNAME)Launcher
cp -rf _build/run.app/Contents/Resources/Scripts $(APPNAME).app/Contents/Resources
cp $(APPNAME).app/Contents/Info.plist Info.plist.0
sed "s/[$$]APPNAME/$(APPNAME)/g" Info.plist.0 >Info.plist.1
sed "s/[$$]VERSION/$(VERSION)/g" Info.plist.1 >Info.plist.2
sed "s/[$$]NAME/$(NAME)/g" Info.plist.2 >Info.plist.3
mv -f Info.plist.3 $(APPNAME).app/Contents/Info.plist
rm Info.plist.*
mac-debug: mac
codesign -s - -v -f --entitlements platform/mac-debug/debug.plist $(NAME).exe
mac-install: mac
cp -rf $(APPNAME).app /Applications
# Zips
zip-mac: mac
zip -r $(APPNAME)-$(VERSION)-mac.zip $(APPNAME).app
zip-win: win
zip -r $(APPNAME)-$(VERSION)-win.zip $(APPNAME)
rm -rf $(NAME)
zip-linux: linux
zip -r $(APPNAME)-$(VERSION)-linux.zip $(APPNAME)
rm -rf $(NAME)
zip:
make zip-$(SYSTEM)
# Clean-up
clean:
dune clean
rm -rf $(NAME)
rm -rf Info.plist.*
distclean: clean
rm -rf _build
rm -rf *.exe *.zip *.app
# Dune file access
app-%:
grep "let $* =" src/app.ml | sed 's/[^"]*"//' | sed 's/"//'
dune-%:
grep "[(]$*" src/dune src/*/dune | sed 's/.*$*//' | sed 's/[^a-zA-Z0-9_. -]//g'