File indexing completed on 2024-04-21 04:52:59
0001 #!/bin/bash 0002 0003 thisdir=$(cd $(dirname $0); pwd) 0004 0005 # sudo aptitude install libxml2-dev llvm clang 0006 0007 set -e 0008 0009 # Build xar 0010 test -d xar || git clone https://github.com/mackyle/xar 0011 if ! test -f xar-1.6.1.tgz; then 0012 cd xar 0013 wget https://patch-diff.githubusercontent.com/raw/mackyle/xar/pull/23.patch 0014 patch -p1 -i 23.patch 0015 cd xar 0016 ./autogen.sh 0017 ./configure --prefix=/opt/osxcross/target 0018 make 0019 make install DESTDIR=$(pwd)/inst 0020 cd inst 0021 tar czf ../../../xar-1.6.1.tgz opt 0022 cd ../../.. 0023 fi 0024 0025 # libdmg-hfsplus 0026 test -d libdmg-hfsplus || git clone https://github.com/vitamin-caig/libdmg-hfsplus 0027 if ! test -f libdmg-hfsplus-20190605.tgz; then 0028 cd libdmg-hfsplus 0029 cmake -DCMAKE_INSTALL_PREFIX=/opt/osxcross/target . 0030 make 0031 make install DESTDIR=$(pwd)/inst 0032 cd inst 0033 tar czf ../../libdmg-hfsplus-20190605.tgz opt 0034 cd ../.. 0035 fi 0036 0037 # build osxcross 0038 test -d osxcross || git clone https://github.com/tpoechtrager/osxcross 0039 cd osxcross 0040 test -d apple-libtapi || git clone https://github.com/tpoechtrager/apple-libtapi.git 0041 test -d cctools-port || git clone https://github.com/tpoechtrager/cctools-port.git 0042 cd .. 0043 if ! test -d /opt/osxcross; then 0044 sudo cp -a osxcross /opt/ 0045 sudo tar xzf xar-1.6.1.tgz -C / 0046 sudo tar xzf libdmg-hfsplus-20190605.tgz -C / 0047 sudo chown -R $USER:$USER /opt/osxcross 0048 fi 0049 0050 # Extract MacOSX11.1.sdk.tar.xz, add a symlink to it from /opt/osxcross/tarballs/ 0051 test -f $thisdir/MacOSX11.1.sdk.tar.xz || wget https://github.com/joseluisq/macosx-sdks/releases/download/11.1/MacOSX11.1.sdk.tar.xz -O $thisdir/MacOSX11.1.sdk.tar.xz 0052 cd /opt/osxcross/tarballs 0053 ln -sf $thisdir/MacOSX11.1.sdk.tar.xz 0054 cd .. 0055 0056 export PATH=/opt/osxcross/target/bin:$PATH 0057 0058 if ! test -f /opt/osxcross/target/bin/x86_64-apple-darwin20.2-machocheck; then 0059 UNATTENDED=1 ./build.sh 0060 fi 0061 0062 if ! test -f /opt/osxcross/target/include/tapi/Defines.h; then 0063 cd apple-libtapi 0064 INSTALLPREFIX=/opt/osxcross/target ./build.sh && ./install.sh 0065 cd .. 0066 fi 0067 0068 if ! test -f /opt/osxcross/target/bin/x86_64-apple-darwin20.2-inout; then 0069 cd cctools-port/cctools/ 0070 ./configure --prefix=/opt/osxcross/target --target=x86_64-apple-darwin20.2 --with-libtapi=/opt/osxcross/target 0071 make && make install 0072 cd ../.. 0073 fi 0074 0075 if ! test -f /opt/osxcross/target/bin/osxcross-llvm-dsymutil; then 0076 ./build_llvm_dsymutil.sh 0077 fi 0078 0079 if ! test -f /opt/osxcross/build/compiler-rt/build/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib; then 0080 ./build_compiler_rt.sh 0081 LLVM_VERSION=$(llvm-config --version) # Debian 11: 11.0.1 0082 0083 mkdir -p /opt/osxcross/target/lib/clang/${LLVM_VERSION}/lib/darwin 0084 cp -rv /opt/osxcross/build/compiler-rt/compiler-rt/include/sanitizer /opt/osxcross/target/lib/clang/${LLVM_VERSION}/include 0085 cp -v /opt/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/*.a /opt/osxcross/target/lib/clang/${LLVM_VERSION}/lib/darwin 0086 cp -v /opt/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/*.dylib /opt/osxcross/target/lib/clang/${LLVM_VERSION}/lib/darwin 0087 fi 0088 0089 if ! test -f /opt/osxcross/target/bin/otool; then 0090 ln -s x86_64-apple-darwin20.2-otool target/bin/otool 0091 ln -s x86_64-apple-darwin20.2-install_name_tool target/bin/install_name_tool 0092 fi 0093 0094 if ! test -d /opt/osxcross/target/lib/ccache/bin; then 0095 mkdir -p /opt/osxcross/target/lib/ccache/bin/ 0096 for arch in i386 x86_64 x86_64h; do 0097 for cmd in clang clang++; do 0098 ln -s /usr/bin/ccache /opt/osxcross/target/lib/ccache/bin/$arch-apple-darwin20.2-$cmd 0099 done 0100 done 0101 fi 0102 0103 if test -d /opt/osxcross/build; then 0104 # Move everything except target out of /opt/osxcross/ 0105 test -d $thisdir/osxcross.trash && rm -rf $thisdir/osxcross.trash 0106 mv $thisdir/osxcross $thisdir/osxcross.trash 0107 mkdir $thisdir/osxcross 0108 for f in *; do test "$f" = "target" || mv "$f" $thisdir/osxcross/; done 0109 test -d .git && mv .git $thisdir/osxcross/ 0110 mv .gitignore $thisdir/osxcross/ 0111 sudo chown -R root:root /opt/osxcross 0112 fi