-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathMakefile.in
181 lines (139 loc) · 5.93 KB
/
Makefile.in
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
PROJECT := umu-launcher
# Define the interpreters to use to prevent shebang complaints
PYTHON_INTERPRETER = /usr/bin/python3
SHELL_INTERPRETER = /usr/bin/sh
# If this is changed to umu (uppercase), `uninstall` target will also remove the SLR directory
INSTALLDIR ?= umu
OBJDIR := builddir
PREFIX ?= /usr
BINDIR := $(PREFIX)/bin
LIBDIR := $(PREFIX)/lib
DATADIR := $(PREFIX)/share
MANDIR := $(DATADIR)/man
PYTHONDIR := $(shell $(PYTHON_INTERPRETER) -c "import site; print(site.getsitepackages()[0])")
DESTDIR ?=
USERINSTALL ?= xfalse
FLATPAK ?= xfalse
.PHONY: all
ifeq ($(FLATPAK), xtrue)
all: version umu umu-launcher
else
all: version umu umu-docs umu-launcher
endif
.PHONY: install
ifeq ($(USERINSTALL), xtrue)
install: umu-install umu-launcher-install user-install fix_shebangs
else
install: umu-install umu-launcher-install fix_shebangs
endif
fix_shebangs:
$(info :: Fixing shebangs in $(DESTDIR)... )
find $(DESTDIR) -type f -name "*.py" -exec sed -i '1s|^#!/usr/bin/python\b|#!$(PYTHON_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "*.py" -exec sed -i '1s|^#!/usr/bin/env python\b|#!/usr/bin/env $(PYTHON_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "*.sh" -exec sed -i '1s|^#!/usr/bin/python\b|#!$(PYTHON_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "*.sh" -exec sed -i '1s|^#!/usr/bin/env python\b|#!/usr/bin/env $(PYTHON_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "umu-run" -exec sed -i '1s|^#!/usr/bin/python\b|#!$(PYTHON_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "umu-run" -exec sed -i '1s|^#!/usr/bin/env python\b|#!/usr/bin/env $(PYTHON_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "*.sh" -exec sed -i '1s|^#!/usr/bin/env sh|#!$(SHELL_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "umu-run" -exec sed -i '1s|^#!/usr/bin/env sh|#!$(SHELL_INTERPRETER)|' {} \;
# Special case, do this inside the source directory for release distribution
umu/umu_version.json: umu/umu_version.json.in
$(info :: Updating $(@) )
cp $(<) $(<).tmp
sed 's|##UMU_VERSION##|$(shell git describe --always --long --tags)|g' -i $(<).tmp
mv $(<).tmp $(@)
.PHONY: version
version: umu/umu_version.json
version-install: version
$(info :: Installing umu_version.json )
install -d $(DESTDIR)$(PYTHONDIR)/$(INSTALLDIR)
install -Dm 644 umu/umu_version.json -t $(DESTDIR)$(PYTHONDIR)/$(INSTALLDIR)
$(OBJDIR)/.build-umu-docs: | $(OBJDIR)
$(info :: Building umu man pages )
scdoc < docs/umu.1.scd > $(OBJDIR)/umu.1
scdoc < docs/umu.5.scd > $(OBJDIR)/umu.5
touch $(@)
.PHONY: umu-docs
umu-docs: $(OBJDIR)/.build-umu-docs
umu-docs-install: umu-docs
$(info :: Installing umu man pages )
install -d $(DESTDIR)$(MANDIR)/man1
install -d $(DESTDIR)$(MANDIR)/man5
install -m644 $(OBJDIR)/umu.1 $(DESTDIR)$(MANDIR)/man1/umu.1
install -m644 $(OBJDIR)/umu.5 $(DESTDIR)$(MANDIR)/man5/umu.5
$(OBJDIR)/.build-umu-dist: | $(OBJDIR)
$(info :: Building umu )
$(PYTHON_INTERPRETER) -m build --wheel --skip-dependency-check --no-isolation --outdir=$(OBJDIR)
touch $(@)
.PHONY: umu-dist
umu-dist: $(OBJDIR)/.build-umu-dist
umu-dist-install: umu-dist
$(info :: Installing umu )
install -d $(DESTDIR)$(PYTHONDIR)/$(INSTALLDIR)
$(PYTHON_INTERPRETER) -m installer --destdir=$(DESTDIR) $(OBJDIR)/*.whl
ifeq ($(FLATPAK), xtrue)
umu-install: version-install umu-dist-install
else
umu-install: version-install umu-dist-install umu-docs-install
endif
ifeq ($(FLATPAK), xtrue)
UMU_LAUNCHER_COMMAND = org.openwinecomponents.umu.umu-launcher
else
UMU_LAUNCHER_COMMAND = $(PYTHONDIR)/umu/umu_run.py
endif
# umu-launcher is separate to allow control over installing the bin target
$(OBJDIR)/.build-umu-launcher: | $(OBJDIR)
$(info :: Building umu-launcher )
sed 's|##INSTALL_PATH##|$(UMU_LAUNCHER_COMMAND)|g' umu/umu-launcher/umu-run.in > $(OBJDIR)/umu-launcher-run
touch $(@)
.PHONY: umu-launcher
umu-launcher: $(OBJDIR)/.build-umu-launcher
umu-launcher-bin-install: umu-launcher
install -d $(DESTDIR)$(DATADIR)/steam/compatibilitytools.d/umu-launcher
install -Dm 755 $(OBJDIR)/$(<)-run $(DESTDIR)$(DATADIR)/steam/compatibilitytools.d/umu-launcher/umu-run
umu-launcher-dist-install:
$(info :: Installing umu-launcher )
install -d $(DESTDIR)$(DATADIR)/steam/compatibilitytools.d/umu-launcher
install -Dm 644 umu/umu-launcher/compatibilitytool.vdf -t $(DESTDIR)$(DATADIR)/steam/compatibilitytools.d/umu-launcher
install -Dm 644 umu/umu-launcher/toolmanifest.vdf -t $(DESTDIR)$(DATADIR)/steam/compatibilitytools.d/umu-launcher
umu-launcher-install: umu-launcher-dist-install umu-launcher-bin-install
$(OBJDIR)/.build-umu-subprojects: | $(OBJDIR)
$(info :: Building subprojects )
pip install -r requirements.in -t $(OBJDIR)
.PHONY: umu-subprojects
umu-subprojects: $(OBJDIR)/.build-umu-subprojects
umu-subprojects-install:
$(info :: Installing subprojects )
install -d $(DESTDIR)$(PYTHONDIR)
cp -r $(OBJDIR)/*-info $(DESTDIR)$(PYTHONDIR)
cp -r $(OBJDIR)/Xlib $(DESTDIR)$(PYTHONDIR)
cp $(OBJDIR)/six.py $(DESTDIR)$(PYTHONDIR)
$(OBJDIR):
@mkdir -p $(@)
.PHONY: clean
clean:
$(info :: Cleaning source directory )
@rm -rf -v $(OBJDIR) umu/umu_version.json ./$(RELEASEDIR) $(RELEASEDIR).tar.gz
RELEASEDIR := $(PROJECT)-$(shell git describe --abbrev=0)
$(RELEASEDIR):
mkdir -p $(@)
.PHONY: release
release: $(RELEASEDIR) | version
$(info :: Creating source distribution for release )
mkdir -p $(<)
rm -rf umu/__pycache__
cp -r umu packaging Makefile.in configure.sh README.md LICENSE $(<)
tar -cvzf $(<).tar.gz $(<)
.PHONY: uninstall
# NEVER use a wildcard here
uninstall:
$(info :: Removing $(INSTALLDIR) files in $(DESTDIR)$(BINDIR) )
@rm -rf -v --preserve-root=all $(DESTDIR)$(BINDIR)/umu-run
$(info :: Removing $(INSTALLDIR) directory in $(DESTDIR)$(DATADIR) )
@rm -rf -v --preserve-root=all $(DESTDIR)$(DATADIR)/$(INSTALLDIR)
.PHONY: user-install
user-install:
$(info :: --- )
$(info :: Installed under user-only location "$(DATADIR)/$(INSTALLDIR)" )
$(info :: To run you need to make sure "$(BINDIR)" is in your PATH )
# vim: ft=make