Skip to content

Commit 0815493

Browse files
Makefile: make out-of-source building possible.
It is now possible to use the BUILD variable to point make in the location to use for building the binary dependencies. When installing the DIST env variable can point make where to install protonfixes Example usage in proton's makefile: ``` PROTONFIXES_OBJ = ./obj-protonfixes PROTONFIXES_TARGET := $(addprefix $(DST_BASE)/,protonfixes) $(PROTONFIXES_TARGET): $(addprefix $(SRCDIR)/,protonfixes) $(OBJ)/.build-protonfixes: cd $(SRCDIR)/protonfixes && \ env BUILD=$(PROTONFIXES_OBJ) make touch $(@) $(PROTONFIXES_TARGET): $(OBJ)/.build-protonfixes cd $(SRCDIR)/protonfixes && \ env BUILD=$(PROTONFIXES_OBJ) DIST=$(PROTONFIXES_TARGET) make install ```
1 parent 1c264cc commit 0815493

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

Makefile

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
OBJDIR := builddir
2-
PREFIX ?= /files
3-
LIBDIR = $(PREFIX)/lib/x86_64-linux-gnu
4-
DESTDIR ?=
5-
INSTALL_DIR ?= $(shell pwd)/dist/protonfixes
1+
BUILD ?= build
2+
DIST ?= dist
3+
4+
OBJDIR := $(shell realpath $(BUILD))
5+
DSTDIR := $(shell realpath $(DIST))
6+
TARGET_DIR := $(DSTDIR)/protonfixes
7+
8+
BASEDIR := /files
9+
i386_LIBDIR = $(BASEDIR)/lib/i386-linux-gnu
10+
x86_64_LIBDIR = $(BASEDIR)/lib/x86_64-linux-gnu
611

712
.PHONY: all
813

@@ -21,14 +26,14 @@ install: protonfixes-install cabextract-install libmspack-install unzip-install
2126

2227
protonfixes-install: protonfixes
2328
$(info :: Installing protonfixes )
24-
install -d $(INSTALL_DIR)
25-
cp -r gamefixes-* $(INSTALL_DIR)
26-
cp -r verbs $(INSTALL_DIR)
27-
cp *.py $(INSTALL_DIR)
28-
mkdir -p $(INSTALL_DIR)/files/bin
29-
cp winetricks $(INSTALL_DIR)/files/bin
30-
cp umu-database.csv $(INSTALL_DIR)
31-
rm $(INSTALL_DIR)/protonfixes_test.py
29+
install -d $(TARGET_DIR)
30+
cp -r gamefixes-* $(TARGET_DIR)
31+
cp -r verbs $(TARGET_DIR)
32+
cp *.py $(TARGET_DIR)
33+
mkdir -p $(TARGET_DIR)$(BASEDIR)/bin
34+
cp winetricks $(TARGET_DIR)$(BASEDIR)/bin
35+
cp umu-database.csv $(TARGET_DIR)
36+
rm $(TARGET_DIR)/protonfixes_test.py
3237

3338
#
3439
# libmspack and cabextract
@@ -45,7 +50,7 @@ $(OBJDIR)/.build-cabextract-dist: | $(OBJDIR)/libmspack
4550
$(info :: Building cabextract )
4651
cd $(OBJDIR)/libmspack/cabextract && \
4752
autoreconf -fiv -I /usr/share/gettext/m4/ && \
48-
./configure --prefix=$(PREFIX) --libdir=$(LIBDIR) && \
53+
./configure --prefix=$(BASEDIR) --libdir=$(x86_64_LIBDIR) && \
4954
make
5055
touch $(@)
5156

@@ -56,8 +61,8 @@ cabextract-dist: $(OBJDIR)/.build-cabextract-dist
5661
cabextract-install: cabextract-dist
5762
$(info :: Installing cabextract )
5863
cd $(OBJDIR)/libmspack/cabextract && \
59-
make DESTDIR=$(INSTALL_DIR) install
60-
rm -r $(INSTALL_DIR)/files/share
64+
make DESTDIR=$(TARGET_DIR) install
65+
rm -r $(TARGET_DIR)$(BASEDIR)/share
6166

6267
#
6368
# libmspack
@@ -67,7 +72,7 @@ $(OBJDIR)/.build-libmspack-dist: | $(OBJDIR)/libmspack
6772
$(info :: Building libmspack )
6873
cd $(OBJDIR)/libmspack/libmspack && \
6974
autoreconf -vfi && \
70-
./configure --prefix=/files --libdir=/files/lib/x86_64-linux-gnu --disable-static && \
75+
./configure --prefix=$(BASEDIR) --libdir=$(x86_64_LIBDIR) --disable-static && \
7176
sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool && \
7277
make
7378
touch $(@)
@@ -79,10 +84,10 @@ libmspack-dist: $(OBJDIR)/.build-libmspack-dist
7984
libmspack-install: libmspack-dist
8085
$(info :: Installing libmspack )
8186
cd $(OBJDIR)/libmspack/libmspack && \
82-
make DESTDIR=$(INSTALL_DIR) install
83-
rm -r $(INSTALL_DIR)/files/include
84-
rm -r $(INSTALL_DIR)/files/lib/x86_64-linux-gnu/pkgconfig
85-
rm $(INSTALL_DIR)/files/lib/x86_64-linux-gnu/libmspack.la
87+
make DESTDIR=$(TARGET_DIR) install
88+
rm -r $(TARGET_DIR)$(BASEDIR)/include
89+
rm -r $(TARGET_DIR)$(BASEDIR)/lib/x86_64-linux-gnu/pkgconfig
90+
rm $(TARGET_DIR)$(BASEDIR)/lib/x86_64-linux-gnu/libmspack.la
8691

8792
#
8893
# unzip
@@ -102,7 +107,7 @@ $(OBJDIR)/.build-unzip-dist: | $(OBJDIR)
102107
rsync -arx --delete subprojects/unzip $(OBJDIR)
103108
cd $(OBJDIR)/unzip && \
104109
$(foreach pch, $(UNZIP_PATCHES),patch -Np1 -i debian/patches/$(pch) &&) \
105-
make -f unix/Makefile D_USE_BZ2=-DUSE_BZIP2 L_BZ2=-lbz2 LF2="$(LDFLAGS)" CF="$(CFLAGS) -I. $(DEFINES)" unzips
110+
make -f unix/Makefile prefix=$(BASEDIR) D_USE_BZ2=-DUSE_BZIP2 L_BZ2=-lbz2 LF2="$(LDFLAGS)" CF="$(CFLAGS) -I. $(DEFINES)" unzips
106111
touch $(@)
107112

108113
.PHONY: unzip-dist
@@ -112,9 +117,9 @@ unzip-dist: $(OBJDIR)/.build-unzip-dist
112117
unzip-install: unzip-dist
113118
$(info :: Installing unzip )
114119
cd $(OBJDIR)/unzip && \
115-
make -f unix/Makefile prefix=$(INSTALL_DIR)/files install
120+
make -f unix/Makefile prefix=$(TARGET_DIR)$(BASEDIR) install
116121
# Post install
117-
rm -r $(INSTALL_DIR)/files/man
122+
rm -r $(TARGET_DIR)$(BASEDIR)/man
118123

119124
#
120125
# python-xlib
@@ -133,10 +138,10 @@ python-xlib-dist: $(OBJDIR)/.build-python-xlib-dist
133138

134139
python-xlib-install: python-xlib-dist
135140
$(info :: Installing python-xlib )
136-
mkdir $(INSTALL_DIR)/_vendor
141+
mkdir $(TARGET_DIR)/_vendor
137142
cd $(OBJDIR)/python-xlib && mkdir dist && \
138143
python setup.py install --root=dist --optimize=1 --skip-build && \
139-
find dist -type d -name Xlib | xargs -I {} mv {} $(INSTALL_DIR)/_vendor; \
144+
find dist -type d -name Xlib | xargs -I {} mv {} $(TARGET_DIR)/_vendor;
140145

141146
$(OBJDIR):
142147
@mkdir -p $(@)

0 commit comments

Comments
 (0)