Skip to content

Commit 30b5bdb

Browse files
committed
Update Makefile and README to build x86_64 on M1 Mac
1 parent 4045978 commit 30b5bdb

File tree

6 files changed

+59
-5
lines changed

6 files changed

+59
-5
lines changed

.idea/.gitignore

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/pobfrontend.iml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,36 @@ pob: load_pob luacurl frontend
5252
popd
5353

5454
frontend:
55-
meson -Dbuildtype=release --prefix=${DIR}/PathOfBuilding.app --bindir=Contents/MacOS build
55+
arch=x86_64 meson -Dbuildtype=release --prefix=${DIR}/PathOfBuilding.app --bindir=Contents/MacOS build
5656

5757
load_pob:
5858
git clone https://github.com/PathOfBuildingCommunity/PathOfBuilding.git; \
5959
pushd PathOfBuilding; \
6060
git add . && git fetch && git reset --hard origin/dev; \
6161
popd
6262

63-
# The sed below ensures that we only replace `lua` with `luajit` once
63+
# The seds below ensure that:
64+
#
65+
# - we only replace `lua` with `luajit` once
66+
# - we use pkg-config to find the right path for curl libraries
67+
# - we use gcc-12 from Homebrew instead of clang, to ensure that we build
68+
# the x86_64 library on ARM systems
69+
# - we target only MacOS 10.5 or later; otherwise, we get an error
6470
luacurl:
6571
git clone --depth 1 https://github.com/Lua-cURL/Lua-cURLv3.git; \
6672
pushd Lua-cURLv3; \
6773
sed -i '' 's/\?= lua$$/\?= luajit/' Makefile; \
68-
sed -i '' 's@shell .* --libs libcurl@shell PKG_CONFIG_PATH=\$$\$$(brew --prefix --installed curl)/lib/pkgconfig \$$(PKG_CONFIG) --libs libcurl@' Makefile; \
74+
sed -i '' 's@shell .* --libs libcurl@shell PKG_CONFIG_PATH=\$$\$$(arch --x86_64 brew --prefix --installed curl)/lib/pkgconfig \$$(PKG_CONFIG) --libs libcurl@' Makefile; \
75+
sed -i '' 's@?= \$$(MAC_ENV) gcc$$@ = \$$(MAC_ENV) arch=x86_64 gcc-12@' Makefile; \
76+
sed -i '' "s@MACOSX_DEPLOYMENT_TARGET='10.3'@MACOSX_DEPLOYMENT_TARGET='10.5'@" Makefile; \
6977
make; \
7078
mv lcurl.so ../lcurl.so; \
7179
popd
7280

7381
# curl is used since mesonInstaller.sh copies over the shared library dylib
7482
# dylibbundler is used to copy over dylibs that lcurl.so uses
7583
tools:
76-
brew install qt@5 luajit zlib meson curl dylibbundler
84+
arch --x86_64 brew install qt@5 luajit zlib meson curl dylibbundler gcc
7785

7886
# We don't usually modify the PathOfBuilding directory, so there's rarely a
7987
# need to delete it. We separate it out to a separate task.

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,26 @@ A cross-platform [Path of Building](https://github.com/Openarl/PathOfBuilding) d
66
Building
77
--------
88

9-
### Steps to build
9+
### Steps to build an x86_64 binary on M1 Macs
10+
11+
Before starting, you need to install Homebrew for x86_64.
12+
13+
1. Install Rosetta if you haven't via `softwareupdate --install-rosetta`
14+
2. Run the [Homebrew installation command](https://docs.brew.sh/Installation),
15+
but prepend `arch --x86_64`. The command will be `arch --x86_64 bash -c ...`
16+
3. Create a `~/.intelbrew` file with these contents:
17+
```sh
18+
eval "$(/usr/local/bin/brew shellenv)"
19+
alias brew='arch --x86_64 /usr/local/bin/brew'
20+
```
21+
4. Include it to update your environment variables by running `. ~/.intelbrew`
1022

1123
```sh
1224
# Run this only once after installing Homebrew to install dependencies
1325
make tools
1426

1527
# Build the entire app
28+
export PATH="/usr/local/opt/qt@5/bin:$PATH"
1629
make
1730

1831
# Optionally sign it for distribution

0 commit comments

Comments
 (0)