-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathMakefile
55 lines (49 loc) · 1.42 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
.PHONY: all
all: desktop binary
BINNAME ?= Play_2048
APP_PREFIX ?= mgrojo/2048
.PHONY: binary
binary: $(BINNAME)
$(BINNAME):
echo "#!/usr/bin/env bash" > $(BINNAME)
echo "unset LD_LIBRARY_PATH" >> $(BINNAME)
echo "cd /$(PREFIX)/lib/$(APP_PREFIX) && ./AppRun $$@" >> $(BINNAME)
DESKTOP_FILE ?= play_2048.desktop
.PHONY: desktop
desktop: extract $(DESKTOP_FILE)
$(DESKTOP_FILE): squashfs-root/$(DESKTOP_FILE)
cp squashfs-root/$(DESKTOP_FILE) .
sed -i \
"s/Exec=.*/Exec=\/$(subst /,\/,$(PREFIX))\/bin\/$(BINNAME)/" \
$(DESKTOP_FILE)
APPIMAGE ?= Play_2048-v0.9.10-x86_64.AppImage
.PHONY: extract
extract: squashfs-root
squashfs-root: $(APPIMAGE)
chmod +x $(APPIMAGE)
./$(APPIMAGE) --appimage-extract
APPIMAGE_URL ?= https://github.com/mgrojo/play_2048/releases/download/v0.9.10/Play_2048-v0.9.10-x86_64.AppImage
$(APPIMAGE):
wget $(APPIMAGE_URL) -O $(APPIMAGE)
PREFIX ?= opt/$(APP_PREFIX)
DESTDIR ?=
.PHONY: install
install: binary desktop
( \
cd squashfs-root && \
find -type f -exec \
install -D "{}" "$(DESTDIR)/$(PREFIX)/lib/$(APP_PREFIX)/{}" \; && \
find -type l -exec bash -c " \
ln -s \$$(readlink {}) \
\"$(DESTDIR)/$(PREFIX)/lib/$(APP_PREFIX)/{}\" \
" \; \
)
install -D $(BINNAME) \
$(DESTDIR)/$(PREFIX)/bin/$(BINNAME)
install -D $(DESKTOP_FILE) \
$(DESTDIR)/$(PREFIX)/share/applications/$(DESKTOP_FILE)
.PHONY: clean
clean:
rm -r squashfs-root || true
rm $(DESKTOP_FILE) || true
rm $(BINNAME) || true