@@ -38,7 +38,28 @@ store_path() {
38
38
--expression=' s|"[[:space:]]*$||'
39
39
}
40
40
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
42
63
# includes/libs for $HOST
43
64
case " $HOST " in
44
65
* mingw* )
@@ -48,14 +69,18 @@ case "$HOST" in
48
69
CROSS_GCC_LIBS=( " ${CROSS_GCC} /lib/gcc/${HOST} " /* ) # This expands to an array of directories...
49
70
CROSS_GCC_LIB=" ${CROSS_GCC_LIBS[0]} " # ...we just want the first one (there should only be one)
50
71
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)
55
76
export CROSS_C_INCLUDE_PATH=" ${CROSS_GCC_LIB} /include:${CROSS_GCC_LIB} /include-fixed:${CROSS_GLIBC} /include"
56
77
export CROSS_CPLUS_INCLUDE_PATH=" ${CROSS_GCC} /include/c++:${CROSS_GCC} /include/c++/${HOST} :${CROSS_GCC} /include/c++/backward:${CROSS_C_INCLUDE_PATH} "
57
78
export CROSS_LIBRARY_PATH=" ${CROSS_GCC} /lib:${CROSS_GCC} /${HOST} /lib:${CROSS_GCC_LIB} :${CROSS_GLIBC} /lib"
58
79
;;
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
+ ;;
59
84
* linux* )
60
85
CROSS_GLIBC=" $( store_path " glibc-cross-${HOST} " ) "
61
86
CROSS_GLIBC_STATIC=" $( store_path " glibc-cross-${HOST} " static) "
@@ -64,9 +89,7 @@ case "$HOST" in
64
89
CROSS_GCC_LIBS=( " ${CROSS_GCC} /lib/gcc/${HOST} " /* ) # This expands to an array of directories...
65
90
CROSS_GCC_LIB=" ${CROSS_GCC_LIBS[0]} " # ...we just want the first one (there should only be one)
66
91
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"
70
93
export CROSS_CPLUS_INCLUDE_PATH=" ${CROSS_GCC} /include/c++:${CROSS_GCC} /include/c++/${HOST} :${CROSS_GCC} /include/c++/backward:${CROSS_C_INCLUDE_PATH} "
71
94
export CROSS_LIBRARY_PATH=" ${CROSS_GCC} /lib:${CROSS_GCC} /${HOST} /lib:${CROSS_GCC_LIB} :${CROSS_GLIBC} /lib:${CROSS_GLIBC_STATIC} /lib"
72
95
;;
@@ -77,14 +100,25 @@ esac
77
100
# Sanity check CROSS_*_PATH directories
78
101
IFS=' :' read -ra PATHS <<< " ${CROSS_C_INCLUDE_PATH}:${CROSS_CPLUS_INCLUDE_PATH}:${CROSS_LIBRARY_PATH}"
79
102
for p in " ${PATHS[@]} " ; do
80
- if [ ! -d " $p " ]; then
103
+ if [ -n " $p " ] && [ ! -d " $p " ]; then
81
104
echo " '$p ' doesn't exist or isn't a directory... Aborting..."
82
105
exit 1
83
106
fi
84
107
done
85
108
86
109
# 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
88
122
89
123
# Make /usr/bin if it doesn't exist
90
124
[ -e /usr/bin ] || mkdir -p /usr/bin
@@ -135,7 +169,8 @@ make -C depends --jobs="$MAX_JOBS" HOST="$HOST" \
135
169
x86_64_linux_RANLIB=x86_64-linux-gnu-ranlib \
136
170
x86_64_linux_NM=x86_64-linux-gnu-nm \
137
171
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
139
174
140
175
141
176
# ##########################
@@ -169,6 +204,7 @@ HOST_CFLAGS="-O2 -g"
169
204
case " $HOST " in
170
205
* linux* ) HOST_CFLAGS+=" -ffile-prefix-map=${PWD} =." ;;
171
206
* mingw* ) HOST_CFLAGS+=" -fno-ident" ;;
207
+ * darwin* ) unset HOST_CFLAGS ;;
172
208
esac
173
209
174
210
# CXXFLAGS
@@ -199,8 +235,8 @@ mkdir -p "$DISTSRC"
199
235
--disable-maintainer-mode \
200
236
--disable-dependency-tracking \
201
237
${CONFIGFLAGS} \
202
- CFLAGS=" ${HOST_CFLAGS} " \
203
- CXXFLAGS=" ${HOST_CXXFLAGS} " \
238
+ ${HOST_CFLAGS : + CFLAGS=" ${HOST_CFLAGS} " } \
239
+ ${HOST_CXXFLAGS : + CXXFLAGS=" ${HOST_CXXFLAGS} " } \
204
240
${HOST_LDFLAGS: +LDFLAGS=" ${HOST_LDFLAGS} " }
205
241
206
242
sed -i.old ' s/-lstdc++ //g' config.status libtool src/univalue/config.status src/univalue/libtool
@@ -210,14 +246,9 @@ mkdir -p "$DISTSRC"
210
246
211
247
# Perform basic ELF security checks on a series of executables.
212
248
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}
221
252
222
253
# Make the os-specific installers
223
254
case " $HOST " in
@@ -232,8 +263,39 @@ mkdir -p "$DISTSRC"
232
263
INSTALLPATH=" ${PWD} /installed/${DISTNAME} "
233
264
mkdir -p " ${INSTALLPATH} "
234
265
# 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
236
274
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
237
299
(
238
300
cd installed
239
301
@@ -248,13 +310,18 @@ mkdir -p "$DISTSRC"
248
310
find . -name " lib*.a" -delete
249
311
250
312
# Prune pkg-config files
251
- rm -r " ${DISTNAME} /lib/pkgconfig"
313
+ rm -rf " ${DISTNAME} /lib/pkgconfig"
252
314
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
258
325
259
326
case " $HOST " in
260
327
* mingw* )
@@ -294,6 +361,13 @@ mkdir -p "$DISTSRC"
294
361
| gzip -9n > " ${OUTDIR} /${DISTNAME} -${HOST} -debug.tar.gz" \
295
362
|| ( rm -f " ${OUTDIR} /${DISTNAME} -${HOST} -debug.tar.gz" && exit 1 )
296
363
;;
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
+ ;;
297
371
esac
298
372
)
299
373
)
0 commit comments