summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d09fde903cd4b3430b1ef47f8c9b06da25a30fe5 (plain)
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
# Maintainer: emersion <contact@emersion.fr>
# Maintainer: swyter <swyterzone+aur@gmail.com>
pkgname=osxcross-git
_pkgname=${pkgname%-git}
_sdkname=MacOSX10.11.sdk # swy: choose your SDK version here
pkgver=0.16
pkgrel=1
pkgdesc="macOS cross-compiling toolchain for Linux, FreeBSD and NetBSD"
arch=('x86_64')
url="https://github.com/tpoechtrager/osxcross"
license=('MIT')
depends=('clang>=3.2')
makedepends=('patch' 'libxml2' 'bash')
optdepends=(
	'llvm: for Link Time Optimization support and ld64 -bitcode_bundle support'
	'uuid: for ld64 -random_uuid support'
	'xar: for ld64 -bitcode_bundle support'
)
provides=("$_pkgname" xar)
conflicts=("$_pkgname" xar apple-darwin-osxcross)
source=(
	'git+https://github.com/tpoechtrager/osxcross.git'
	"https://s3.dockerproject.org/darwin/v2/${_sdkname}.tar.xz"

	# swy: this repository by an anonymous individual seems to have pre-bundled versions of the other SDKs,
	#      in case you want to change $_sdkname and use a newer version, comment the URL above and uncomment this one
	#      or pack your own if you don't trust the unofficial source, which I can understand.
	#"https://github.com/phracker/MacOSX-SDKs/releases/latest/download/${_sdkname}.tar.xz"
)
md5sums=('SKIP' 'b0d81b95746c7e698c39c7df1e15ca7d')
noextract=("${_sdkname}.tar.xz")
options=('!strip')
install="$pkgname.install"

# https://github.com/tpoechtrager/cctools-port/issues/108
CXXFLAGS="$CXXFLAGS -U_GLIBCXX_ASSERTIONS -Wp,-U_GLIBCXX_ASSERTIONS"

prepare() {
	cd "$srcdir/$_pkgname"
	mv "../${_sdkname}.tar.xz" tarballs/
}

build() {
	cd "$srcdir/$_pkgname"

	# swy: put all the generated files in there
	export OSXCROSS_TARGET_DIR="$srcdir/usr/local/osx-ndk-x86"; mkdir -p "$OSXCROSS_TARGET_DIR"
	sed -i -s "s|export TARGET_DIR\=|export TARGET_DIR\='${OSXCROSS_TARGET_DIR}' #|" "./tools/tools.sh"

	# swy: use almost all available processor cores, for compiling speed. Leave a spare one.
	JOBS=$(( `nproc` - 1 )) UNATTENDED=yes OSX_VERSION_MIN=10.6  ./build.sh # OCDEBUG=1
}

package() {
	cd "$srcdir/$_pkgname"

	# swy: copy them over, as we can't seemingly use $pkgdir in build()
	mv "$srcdir/usr/" "$pkgdir/usr/"

	# swy: as this package conflicts with «xar», make that un/packing tool widely available with a symlink
	mkdir -p "$pkgdir/usr/bin"; ln -s "$pkgdir/usr/local/osx-ndk-x86/bin/xar" "$pkgdir/usr/bin/xar"

	# swy: make sure the cross-compiled binaries can locate the .so dependencies stored aside in every
	#      case without having to set funky environment variables or patching every .elf's RUNPATH
	mkdir -p "$pkgdir/etc/ld.so.conf.d/"
	echo '/usr/local/osx-ndk-x86/lib' > "$pkgdir/etc/ld.so.conf.d/osxcross.conf"
}