@@ -38,7 +38,28 @@ store_path() {
3838 --expression=' s|"[[:space:]]*$||'
3939}
4040
41- # Set environment variables to point Guix's cross-toolchain to the right
41+
42+ # Set environment variables to point the NATIVE toolchain to the right
43+ # includes/libs
44+ NATIVE_GCC=" $( store_path gcc-toolchain) "
45+ export LIBRARY_PATH=" ${NATIVE_GCC} /lib:${NATIVE_GCC} /lib64"
46+ export CPATH=" ${NATIVE_GCC} /include"
47+ case " $HOST " in
48+ * darwin* )
49+ # When targeting darwin, some native tools built by depends require
50+ # native packages not incorporated in depends
51+ #
52+ # libcap required by native_cdrkit/wodim
53+ # zlib, bzip2 required by native_cdrkit/genisoimage
54+ for native_pkg in libcap zlib bzip2; do
55+ native_pkg_store_path=$( store_path " $native_pkg " )
56+ export LIBRARY_PATH=" ${native_pkg_store_path} /lib:${LIBRARY_PATH} "
57+ export CPATH=" ${native_pkg_store_path} /include:${CPATH} "
58+ done
59+ ;;
60+ esac
61+
62+ # Set environment variables to point the CROSS toolchain to the right
4263# includes/libs for $HOST
4364case " $HOST " in
4465 * mingw* )
@@ -48,14 +69,18 @@ case "$HOST" in
4869 CROSS_GCC_LIBS=( " ${CROSS_GCC} /lib/gcc/${HOST} " /* ) # This expands to an array of directories...
4970 CROSS_GCC_LIB=" ${CROSS_GCC_LIBS[0]} " # ...we just want the first one (there should only be one)
5071
51- NATIVE_GCC= " $( store_path gcc-glibc-2.27-toolchain ) "
52- export LIBRARY_PATH= " ${NATIVE_GCC} /lib: ${NATIVE_GCC} /lib64 "
53- export CPATH= " ${NATIVE_GCC} /include "
54-
72+ # The search path ordering is generally:
73+ # 1. gcc-related search paths
74+ # 2. libc-related search paths
75+ # 2. kernel-header-related search paths (not applicable to mingw-w64 hosts)
5576 export CROSS_C_INCLUDE_PATH=" ${CROSS_GCC_LIB} /include:${CROSS_GCC_LIB} /include-fixed:${CROSS_GLIBC} /include"
5677 export CROSS_CPLUS_INCLUDE_PATH=" ${CROSS_GCC} /include/c++:${CROSS_GCC} /include/c++/${HOST} :${CROSS_GCC} /include/c++/backward:${CROSS_C_INCLUDE_PATH} "
5778 export CROSS_LIBRARY_PATH=" ${CROSS_GCC} /lib:${CROSS_GCC} /${HOST} /lib:${CROSS_GCC_LIB} :${CROSS_GLIBC} /lib"
5879 ;;
80+ * darwin* )
81+ # The CROSS toolchain for darwin uses the SDK and ignores environment variables.
82+ # See depends/hosts/darwin.mk for more details.
83+ ;;
5984 * linux* )
6085 CROSS_GLIBC=" $( store_path " glibc-cross-${HOST} " ) "
6186 CROSS_GLIBC_STATIC=" $( store_path " glibc-cross-${HOST} " static) "
@@ -64,9 +89,7 @@ case "$HOST" in
6489 CROSS_GCC_LIBS=( " ${CROSS_GCC} /lib/gcc/${HOST} " /* ) # This expands to an array of directories...
6590 CROSS_GCC_LIB=" ${CROSS_GCC_LIBS[0]} " # ...we just want the first one (there should only be one)
6691
67- # NOTE: CROSS_C_INCLUDE_PATH is missing ${CROSS_GCC_LIB}/include-fixed, because
68- # the limits.h in it is missing a '#include_next <limits.h>'
69- export CROSS_C_INCLUDE_PATH=" ${CROSS_GCC_LIB} /include:${CROSS_GLIBC} /include:${CROSS_KERNEL} /include"
92+ export CROSS_C_INCLUDE_PATH=" ${CROSS_GCC_LIB} /include:${CROSS_GCC_LIB} /include-fixed:${CROSS_GLIBC} /include:${CROSS_KERNEL} /include"
7093 export CROSS_CPLUS_INCLUDE_PATH=" ${CROSS_GCC} /include/c++:${CROSS_GCC} /include/c++/${HOST} :${CROSS_GCC} /include/c++/backward:${CROSS_C_INCLUDE_PATH} "
7194 export CROSS_LIBRARY_PATH=" ${CROSS_GCC} /lib:${CROSS_GCC} /${HOST} /lib:${CROSS_GCC_LIB} :${CROSS_GLIBC} /lib:${CROSS_GLIBC_STATIC} /lib"
7295 ;;
@@ -77,14 +100,25 @@ esac
77100# Sanity check CROSS_*_PATH directories
78101IFS=' :' read -ra PATHS <<< " ${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}"
79102for p in " ${PATHS[@]} " ; do
80- if [ ! -d " $p " ]; then
103+ if [ -n " $p " ] && [ ! -d " $p " ]; then
81104 echo " '$p ' doesn't exist or isn't a directory... Aborting..."
82105 exit 1
83106 fi
84107done
85108
86109# Disable Guix ld auto-rpath behavior
87- export GUIX_LD_WRAPPER_DISABLE_RPATH=yes
110+ case " $HOST " in
111+ * darwin* )
112+ # The auto-rpath behavior is necessary for darwin builds as some native
113+ # tools built by depends refer to and depend on Guix-built native
114+ # libraries
115+ #
116+ # After the native packages in depends are built, the ld wrapper should
117+ # no longer affect our build, as clang would instead reach for
118+ # x86_64-apple-darwin18-ld from cctools
119+ ;;
120+ * ) export GUIX_LD_WRAPPER_DISABLE_RPATH=yes ;;
121+ esac
88122
89123# Make /usr/bin if it doesn't exist
90124[ -e /usr/bin ] || mkdir -p /usr/bin
@@ -135,7 +169,8 @@ make -C depends --jobs="$MAX_JOBS" HOST="$HOST" \
135169 x86_64_linux_RANLIB=x86_64-linux-gnu-ranlib \
136170 x86_64_linux_NM=x86_64-linux-gnu-nm \
137171 x86_64_linux_STRIP=x86_64-linux-gnu-strip \
138- qt_config_opts_i686_linux=' -platform linux-g++ -xplatform bitcoin-linux-g++'
172+ qt_config_opts_i686_linux=' -platform linux-g++ -xplatform bitcoin-linux-g++' \
173+ FORCE_USE_SYSTEM_CLANG=1
139174
140175
141176# ##########################
@@ -169,6 +204,7 @@ HOST_CFLAGS="-O2 -g"
169204case " $HOST " in
170205 * linux* ) HOST_CFLAGS+=" -ffile-prefix-map=${PWD} =." ;;
171206 * mingw* ) HOST_CFLAGS+=" -fno-ident" ;;
207+ * darwin* ) unset HOST_CFLAGS ;;
172208esac
173209
174210# CXXFLAGS
@@ -199,8 +235,8 @@ mkdir -p "$DISTSRC"
199235 --disable-maintainer-mode \
200236 --disable-dependency-tracking \
201237 ${CONFIGFLAGS} \
202- CFLAGS=" ${HOST_CFLAGS} " \
203- CXXFLAGS=" ${HOST_CXXFLAGS} " \
238+ ${HOST_CFLAGS : + CFLAGS=" ${HOST_CFLAGS} " } \
239+ ${HOST_CXXFLAGS : + CXXFLAGS=" ${HOST_CXXFLAGS} " } \
204240 ${HOST_LDFLAGS: +LDFLAGS=" ${HOST_LDFLAGS} " }
205241
206242 sed -i.old ' s/-lstdc++ //g' config.status libtool src/univalue/config.status src/univalue/libtool
@@ -210,14 +246,9 @@ mkdir -p "$DISTSRC"
210246
211247 # Perform basic ELF security checks on a series of executables.
212248 make -C src --jobs=1 check-security ${V: +V=1}
213-
214- case " $HOST " in
215- * linux* |* mingw* )
216- # Check that executables only contain allowed gcc, glibc and libstdc++
217- # version symbols for Linux distro back-compatibility.
218- make -C src --jobs=1 check-symbols ${V: +V=1}
219- ;;
220- esac
249+ # Check that executables only contain allowed gcc, glibc and libstdc++
250+ # version symbols for Linux distro back-compatibility.
251+ make -C src --jobs=1 check-symbols ${V: +V=1}
221252
222253 # Make the os-specific installers
223254 case " $HOST " in
@@ -232,8 +263,39 @@ mkdir -p "$DISTSRC"
232263 INSTALLPATH=" ${PWD} /installed/${DISTNAME} "
233264 mkdir -p " ${INSTALLPATH} "
234265 # Install built Bitcoin Core to $INSTALLPATH
235- make install DESTDIR=" ${INSTALLPATH} " ${V: +V=1}
266+ case " $HOST " in
267+ * darwin* )
268+ make install-strip DESTDIR=" ${INSTALLPATH} " ${V: +V=1}
269+ ;;
270+ * )
271+ make install DESTDIR=" ${INSTALLPATH} " ${V: +V=1}
272+ ;;
273+ esac
236274
275+ case " $HOST " in
276+ * darwin* )
277+ make osx_volname ${V: +V=1}
278+ make deploydir ${V: +V=1}
279+ mkdir -p " unsigned-app-${HOST} "
280+ cp --target-directory=" unsigned-app-${HOST} " \
281+ osx_volname \
282+ contrib/macdeploy/detached-sig-{apply,create}.sh \
283+ " ${BASEPREFIX} /${HOST} " /native/bin/dmg
284+ for util in codesign_allocate pagestuff; do
285+ cp --no-target-directory {" ${BASEPREFIX} /${HOST} /native/bin/${HOST} -" ," unsigned-app-${HOST} /" }" $util "
286+ done
287+ mv --target-directory=" unsigned-app-${HOST} " dist
288+ (
289+ cd " unsigned-app-${HOST} "
290+ find . -print0 \
291+ | sort --zero-terminated \
292+ | tar --create --no-recursion --mode=' u+rw,go+r-w,a+X' --null --files-from=- \
293+ | gzip -9n > " ${OUTDIR} /${DISTNAME} -osx-unsigned.tar.gz" \
294+ || ( rm -f " ${OUTDIR} /${DISTNAME} -osx-unsigned.tar.gz" && exit 1 )
295+ )
296+ make deploy ${V: +V=1} OSX_DMG=" ${OUTDIR} /${DISTNAME} -osx-unsigned.dmg"
297+ ;;
298+ esac
237299 (
238300 cd installed
239301
@@ -248,13 +310,18 @@ mkdir -p "$DISTSRC"
248310 find . -name " lib*.a" -delete
249311
250312 # Prune pkg-config files
251- rm -r " ${DISTNAME} /lib/pkgconfig"
313+ rm -rf " ${DISTNAME} /lib/pkgconfig"
252314
253- # Split binaries and libraries from their debug symbols
254- {
255- find " ${DISTNAME} /bin" -type f -executable -print0
256- find " ${DISTNAME} /lib" -type f -print0
257- } | xargs -0 -n1 -P" $MAX_JOBS " -I{} " ${DISTSRC} /contrib/devtools/split-debug.sh" {} {} {}.dbg
315+ case " $HOST " in
316+ * darwin* ) ;;
317+ * )
318+ # Split binaries and libraries from their debug symbols
319+ {
320+ find " ${DISTNAME} /bin" -type f -executable -print0
321+ find " ${DISTNAME} /lib" -type f -print0
322+ } | xargs -0 -n1 -P" $MAX_JOBS " -I{} " ${DISTSRC} /contrib/devtools/split-debug.sh" {} {} {}.dbg
323+ ;;
324+ esac
258325
259326 case " $HOST " in
260327 * mingw* )
@@ -294,6 +361,13 @@ mkdir -p "$DISTSRC"
294361 | gzip -9n > " ${OUTDIR} /${DISTNAME} -${HOST} -debug.tar.gz" \
295362 || ( rm -f " ${OUTDIR} /${DISTNAME} -${HOST} -debug.tar.gz" && exit 1 )
296363 ;;
364+ * darwin* )
365+ find " ${DISTNAME} " -print0 \
366+ | sort --zero-terminated \
367+ | tar --create --no-recursion --mode=' u+rw,go+r-w,a+X' --null --files-from=- \
368+ | gzip -9n > " ${OUTDIR} /${DISTNAME} -${HOST// x86_64-apple-darwin18/ osx64} .tar.gz" \
369+ || ( rm -f " ${OUTDIR} /${DISTNAME} -${HOST// x86_64-apple-darwin18/ osx64} .tar.gz" && exit 1 )
370+ ;;
297371 esac
298372 )
299373)
0 commit comments