@@ -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
@@ -114,6 +148,16 @@ export QT_RCC_TEST=1
114
148
export QT_RCC_SOURCE_DATE_OVERRIDE=1
115
149
export TAR_OPTIONS=" --owner=0 --group=0 --numeric-owner --mtime='@${SOURCE_DATE_EPOCH} ' --sort=name"
116
150
export TZ=" UTC"
151
+ case " $HOST " in
152
+ * darwin* )
153
+ # cctools AR, unlike GNU binutils AR, does not have a deterministic mode
154
+ # or a configure flag to enable determinism by default, it only
155
+ # understands if this env-var is set or not. See:
156
+ #
157
+ # https://github.com/tpoechtrager/cctools-port/blob/55562e4073dea0fbfd0b20e0bf69ffe6390c7f97/cctools/ar/archive.c#L334
158
+ export ZERO_AR_DATE=yes
159
+ ;;
160
+ esac
117
161
118
162
# ###################
119
163
# Depends Building #
@@ -135,7 +179,8 @@ make -C depends --jobs="$MAX_JOBS" HOST="$HOST" \
135
179
x86_64_linux_RANLIB=x86_64-linux-gnu-ranlib \
136
180
x86_64_linux_NM=x86_64-linux-gnu-nm \
137
181
x86_64_linux_STRIP=x86_64-linux-gnu-strip \
138
- qt_config_opts_i686_linux=' -platform linux-g++ -xplatform bitcoin-linux-g++'
182
+ qt_config_opts_i686_linux=' -platform linux-g++ -xplatform bitcoin-linux-g++' \
183
+ FORCE_USE_SYSTEM_CLANG=1
139
184
140
185
141
186
# ##########################
@@ -169,6 +214,7 @@ HOST_CFLAGS="-O2 -g"
169
214
case " $HOST " in
170
215
* linux* ) HOST_CFLAGS+=" -ffile-prefix-map=${PWD} =." ;;
171
216
* mingw* ) HOST_CFLAGS+=" -fno-ident" ;;
217
+ * darwin* ) unset HOST_CFLAGS ;;
172
218
esac
173
219
174
220
# CXXFLAGS
@@ -199,8 +245,8 @@ mkdir -p "$DISTSRC"
199
245
--disable-maintainer-mode \
200
246
--disable-dependency-tracking \
201
247
${CONFIGFLAGS} \
202
- CFLAGS=" ${HOST_CFLAGS} " \
203
- CXXFLAGS=" ${HOST_CXXFLAGS} " \
248
+ ${HOST_CFLAGS : + CFLAGS=" ${HOST_CFLAGS} " } \
249
+ ${HOST_CXXFLAGS : + CXXFLAGS=" ${HOST_CXXFLAGS} " } \
204
250
${HOST_LDFLAGS: +LDFLAGS=" ${HOST_LDFLAGS} " }
205
251
206
252
sed -i.old ' s/-lstdc++ //g' config.status libtool src/univalue/config.status src/univalue/libtool
@@ -210,14 +256,9 @@ mkdir -p "$DISTSRC"
210
256
211
257
# Perform basic ELF security checks on a series of executables.
212
258
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
259
+ # Check that executables only contain allowed gcc, glibc and libstdc++
260
+ # version symbols for Linux distro back-compatibility.
261
+ make -C src --jobs=1 check-symbols ${V: +V=1}
221
262
222
263
# Make the os-specific installers
223
264
case " $HOST " in
@@ -232,8 +273,39 @@ mkdir -p "$DISTSRC"
232
273
INSTALLPATH=" ${PWD} /installed/${DISTNAME} "
233
274
mkdir -p " ${INSTALLPATH} "
234
275
# Install built Bitcoin Core to $INSTALLPATH
235
- make install DESTDIR=" ${INSTALLPATH} " ${V: +V=1}
276
+ case " $HOST " in
277
+ * darwin* )
278
+ make install-strip DESTDIR=" ${INSTALLPATH} " ${V: +V=1}
279
+ ;;
280
+ * )
281
+ make install DESTDIR=" ${INSTALLPATH} " ${V: +V=1}
282
+ ;;
283
+ esac
236
284
285
+ case " $HOST " in
286
+ * darwin* )
287
+ make osx_volname ${V: +V=1}
288
+ make deploydir ${V: +V=1}
289
+ mkdir -p " unsigned-app-${HOST} "
290
+ cp --target-directory=" unsigned-app-${HOST} " \
291
+ osx_volname \
292
+ contrib/macdeploy/detached-sig-{apply,create}.sh \
293
+ " ${BASEPREFIX} /${HOST} " /native/bin/dmg
294
+ for util in codesign_allocate pagestuff; do
295
+ cp --no-target-directory {" ${BASEPREFIX} /${HOST} /native/bin/${HOST} -" ," unsigned-app-${HOST} /" }" $util "
296
+ done
297
+ mv --target-directory=" unsigned-app-${HOST} " dist
298
+ (
299
+ cd " unsigned-app-${HOST} "
300
+ find . -print0 \
301
+ | sort --zero-terminated \
302
+ | tar --create --no-recursion --mode=' u+rw,go+r-w,a+X' --null --files-from=- \
303
+ | gzip -9n > " ${OUTDIR} /${DISTNAME} -osx-unsigned.tar.gz" \
304
+ || ( rm -f " ${OUTDIR} /${DISTNAME} -osx-unsigned.tar.gz" && exit 1 )
305
+ )
306
+ make deploy ${V: +V=1} OSX_DMG=" ${OUTDIR} /${DISTNAME} -osx-unsigned.dmg"
307
+ ;;
308
+ esac
237
309
(
238
310
cd installed
239
311
@@ -248,13 +320,18 @@ mkdir -p "$DISTSRC"
248
320
find . -name " lib*.a" -delete
249
321
250
322
# Prune pkg-config files
251
- rm -r " ${DISTNAME} /lib/pkgconfig"
323
+ rm -rf " ${DISTNAME} /lib/pkgconfig"
252
324
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
325
+ case " $HOST " in
326
+ * darwin* ) ;;
327
+ * )
328
+ # Split binaries and libraries from their debug symbols
329
+ {
330
+ find " ${DISTNAME} /bin" -type f -executable -print0
331
+ find " ${DISTNAME} /lib" -type f -print0
332
+ } | xargs -0 -n1 -P" $MAX_JOBS " -I{} " ${DISTSRC} /contrib/devtools/split-debug.sh" {} {} {}.dbg
333
+ ;;
334
+ esac
258
335
259
336
case " $HOST " in
260
337
* mingw* )
@@ -294,6 +371,13 @@ mkdir -p "$DISTSRC"
294
371
| gzip -9n > " ${OUTDIR} /${DISTNAME} -${HOST} -debug.tar.gz" \
295
372
|| ( rm -f " ${OUTDIR} /${DISTNAME} -${HOST} -debug.tar.gz" && exit 1 )
296
373
;;
374
+ * darwin* )
375
+ find " ${DISTNAME} " -print0 \
376
+ | sort --zero-terminated \
377
+ | tar --create --no-recursion --mode=' u+rw,go+r-w,a+X' --null --files-from=- \
378
+ | gzip -9n > " ${OUTDIR} /${DISTNAME} -${HOST// x86_64-apple-darwin18/ osx64} .tar.gz" \
379
+ || ( rm -f " ${OUTDIR} /${DISTNAME} -${HOST// x86_64-apple-darwin18/ osx64} .tar.gz" && exit 1 )
380
+ ;;
297
381
esac
298
382
)
299
383
)
0 commit comments