@@ -66,7 +66,7 @@ configure_options()
66
66
display_message " configure options:"
67
67
for OPTION in " $@ " ; do
68
68
if [[ $OPTION ]]; then
69
- display_message $OPTION
69
+ display_message " $OPTION "
70
70
fi
71
71
done
72
72
@@ -83,19 +83,17 @@ create_directory()
83
83
84
84
display_heading_message ()
85
85
{
86
- echo
87
- echo " ********************** $@ **********************"
88
- echo
86
+ printf " \n********************** %s **********************\n" " $@ "
89
87
}
90
88
91
89
display_message ()
92
90
{
93
- echo " $@ "
91
+ printf " %s\n " " $@ "
94
92
}
95
93
96
94
display_error ()
97
95
{
98
- >&2 echo " $@ "
96
+ >&2 printf " %s\n " " $@ "
99
97
}
100
98
101
99
initialize_git ()
@@ -115,7 +113,7 @@ make_current_directory()
115
113
116
114
./autogen.sh
117
115
configure_options " $@ "
118
- make_jobs $JOBS
116
+ make_jobs " $JOBS "
119
117
make install
120
118
configure_links
121
119
}
@@ -128,7 +126,7 @@ make_jobs()
128
126
129
127
# Avoid setting -j1 (causes problems on Travis).
130
128
if [[ $JOBS > $SEQUENTIAL ]]; then
131
- make -j$JOBS " $@ "
129
+ make -j" $JOBS " " $@ "
132
130
else
133
131
make " $@ "
134
132
fi
@@ -144,7 +142,7 @@ make_tests()
144
142
145
143
# Build and run unit tests relative to the primary directory.
146
144
# VERBOSE=1 ensures test runner output sent to console (gcc).
147
- make_jobs $JOBS check " VERBOSE=1"
145
+ make_jobs " $JOBS " check " VERBOSE=1"
148
146
local RESULT=$?
149
147
150
148
# Test runners emit to the test.log file.
@@ -225,13 +223,13 @@ done
225
223
# Configure build parallelism.
226
224
# ------------------------------------------------------------------------------
227
225
SEQUENTIAL=1
228
- OS=` uname -s`
226
+ OS=$( uname -s)
229
227
if [[ $PARALLEL ]]; then
230
228
display_message " Using shell-defined PARALLEL value."
231
229
elif [[ $OS == Linux ]]; then
232
- PARALLEL=` nproc`
230
+ PARALLEL=$( nproc)
233
231
elif [[ ($OS == Darwin) || ($OS == OpenBSD) ]]; then
234
- PARALLEL=` sysctl -n hw.ncpu`
232
+ PARALLEL=$( sysctl -n hw.ncpu)
235
233
else
236
234
display_error " Unsupported system: $OS "
237
235
display_error " Explicit shell-definition of PARALLEL will avoid system detection."
@@ -279,7 +277,7 @@ CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--build-*/}")
279
277
280
278
# Always set a prefix (required on OSX and for lib detection).
281
279
# ------------------------------------------------------------------------------
282
- if [[ ! ($PREFIX ) ]]; then
280
+ if [[ ! ($PREFIX ) ]]; then
283
281
PREFIX=" /usr/local"
284
282
CONFIGURE_OPTIONS=( " ${CONFIGURE_OPTIONS[@]} " " --prefix=$PREFIX " )
285
283
else
@@ -426,23 +424,23 @@ build_from_tarball()
426
424
shift 7
427
425
428
426
# For some platforms we need to set ICU pkg-config path.
429
- if [[ ! ($BUILD ) ]]; then
430
- if [[ $ARCHIVE == $ICU_ARCHIVE ]]; then
427
+ if [[ ! ($BUILD ) ]]; then
428
+ if [[ $ARCHIVE == " $ICU_ARCHIVE " ]]; then
431
429
initialize_icu_packages
432
430
fi
433
431
return
434
432
fi
435
433
436
434
# Because libpng doesn't actually use pkg-config to locate zlib.
437
435
# Because ICU tools don't know how to locate internal dependencies.
438
- if [[ ($ARCHIVE == $ICU_ARCHIVE ) || ($ARCHIVE == $PNG_ARCHIVE ) ]]; then
439
- local SAVE_LDFLAGS=$LDFLAGS
436
+ if [[ ($ARCHIVE == " $ICU_ARCHIVE " ) || ($ARCHIVE == " $PNG_ARCHIVE " ) ]]; then
437
+ local SAVE_LDFLAGS=" $LDFLAGS "
440
438
export LDFLAGS=" -L$PREFIX /lib $LDFLAGS "
441
439
fi
442
440
443
441
# Because libpng doesn't actually use pkg-config to locate zlib.h.
444
- if [[ ($ARCHIVE == $PNG_ARCHIVE ) ]]; then
445
- local SAVE_CPPFLAGS=$CPPFLAGS
442
+ if [[ ($ARCHIVE == " $PNG_ARCHIVE " ) ]]; then
443
+ local SAVE_CPPFLAGS=" $CPPFLAGS "
446
444
export CPPFLAGS=" -I$PREFIX /include $CPPFLAGS "
447
445
fi
448
446
@@ -455,31 +453,31 @@ build_from_tarball()
455
453
push_directory " $EXTRACT "
456
454
457
455
# Extract the source locally.
458
- wget --output-document $ARCHIVE $URL
459
- tar --extract --file $ARCHIVE --$COMPRESSION --strip-components=1
456
+ wget --output-document " $ARCHIVE " " $URL "
457
+ tar --extract --file " $ARCHIVE " " --$COMPRESSION " --strip-components=1
460
458
push_directory " $PUSH_DIR "
461
459
462
460
# Enable static only zlib build.
463
- if [[ $ARCHIVE == $ZLIB_ARCHIVE ]]; then
461
+ if [[ $ARCHIVE == " $ZLIB_ARCHIVE " ]]; then
464
462
patch_zlib_configuration
465
463
fi
466
464
467
465
# Join generated and command line options.
468
466
local CONFIGURATION=(" ${OPTIONS[@]} " " $@ " )
469
467
470
- if [[ $ARCHIVE == $MBEDTLS_ARCHIVE ]]; then
471
- make -j $JOBS lib
468
+ if [[ $ARCHIVE == " $MBEDTLS_ARCHIVE " ]]; then
469
+ make -j " $JOBS " lib
472
470
make DESTDIR=$PREFIX install
473
471
else
474
472
configure_options " ${CONFIGURATION[@]} "
475
- make_jobs $JOBS --silent
473
+ make_jobs " $JOBS " --silent
476
474
make install
477
475
fi
478
476
479
477
configure_links
480
478
481
479
# Enable shared only zlib build.
482
- if [[ $ARCHIVE == $ZLIB_ARCHIVE ]]; then
480
+ if [[ $ARCHIVE == " $ZLIB_ARCHIVE " ]]; then
483
481
clean_zlib_build
484
482
fi
485
483
@@ -488,7 +486,7 @@ build_from_tarball()
488
486
489
487
# Restore flags to prevent side effects.
490
488
export LDFLAGS=$SAVE_LDFLAGS
491
- export CPPFLAGS=$SAVE_LCPPFLAGS
489
+ export CPPFLAGS=$SAVE_CPPFLAGS
492
490
493
491
pop_directory
494
492
}
@@ -504,8 +502,8 @@ circumvent_boost_icu_detection()
504
502
local REGEX_TEST=" libs/regex/build/has_icu_test.cpp"
505
503
local LOCALE_TEST=" libs/locale/build/has_icu_test.cpp"
506
504
507
- echo $SUCCESS > $REGEX_TEST
508
- echo $SUCCESS > $LOCALE_TEST
505
+ printf " %s " " $SUCCESS " > $REGEX_TEST
506
+ printf " %s " " $SUCCESS " > $LOCALE_TEST
509
507
510
508
# display_message "Hack: ICU detection modified, will always indicate found."
511
509
}
@@ -546,20 +544,23 @@ initialize_boost_icu_configuration()
546
544
BOOST_ICU_POSIX=" off"
547
545
548
546
# Extract ICU libs from package config variables and augment with -ldl.
549
- ICU_LIBS=" ` pkg-config icu-i18n --libs` -ldl"
547
+ ICU_LIBS=" $( pkg-config icu-i18n --libs) -ldl"
550
548
551
549
# This is a hack for boost m4 scripts that fail with ICU dependency.
552
550
# See custom edits in ax-boost-locale.m4 and ax_boost_regex.m4.
553
- export BOOST_ICU_LIBS=" ${ICU_LIBS[@]} "
551
+ export BOOST_ICU_LIBS=( " ${ICU_LIBS[@]} " )
554
552
555
553
# Extract ICU prefix directory from package config variable.
556
- ICU_PREFIX=` pkg-config icu-i18n --variable=prefix`
554
+ ICU_PREFIX=$( pkg-config icu-i18n --variable=prefix)
557
555
fi
558
556
}
559
557
560
558
# Because boost doesn't use autoconfig.
561
559
build_from_tarball_boost ()
562
560
{
561
+ local SAVE_IFS=" $IFS "
562
+ IFS=' '
563
+
563
564
local URL=$1
564
565
local ARCHIVE=$2
565
566
local COMPRESSION=$3
@@ -568,7 +569,7 @@ build_from_tarball_boost()
568
569
local BUILD=$6
569
570
shift 6
570
571
571
- if [[ ! ($BUILD ) ]]; then
572
+ if [[ ! ($BUILD ) ]]; then
572
573
return
573
574
fi
574
575
@@ -581,8 +582,8 @@ build_from_tarball_boost()
581
582
push_directory " $EXTRACT "
582
583
583
584
# Extract the source locally.
584
- wget --output-document $ARCHIVE $URL
585
- tar --extract --file $ARCHIVE --$COMPRESSION --strip-components=1
585
+ wget --output-document " $ARCHIVE " " $URL "
586
+ tar --extract --file " $ARCHIVE " " --$COMPRESSION " --strip-components=1
586
587
587
588
initialize_boost_configuration
588
589
initialize_boost_icu_configuration
@@ -599,15 +600,15 @@ build_from_tarball_boost()
599
600
display_message " boost.locale.posix : $BOOST_ICU_POSIX "
600
601
display_message " -sNO_BZIP2 : 1"
601
602
display_message " -sICU_PATH : $ICU_PREFIX "
602
- display_message " -sICU_LINK : ${ICU_LIBS[@ ]} "
603
+ display_message " -sICU_LINK : " " ${ICU_LIBS[* ]} "
603
604
display_message " -sZLIB_LIBPATH : $PREFIX /lib"
604
605
display_message " -sZLIB_INCLUDE : $PREFIX /include"
605
606
display_message " -j : $JOBS "
606
607
display_message " -d0 : [supress informational messages]"
607
608
display_message " -q : [stop at the first error]"
608
609
display_message " --reconfigure : [ignore cached configuration]"
609
610
display_message " --prefix : $PREFIX "
610
- display_message " BOOST_OPTIONS : $@ "
611
+ display_message " BOOST_OPTIONS : $* "
611
612
display_message " --------------------------------------------------------------------"
612
613
613
614
# boost_iostreams
@@ -631,7 +632,7 @@ build_from_tarball_boost()
631
632
" boost.locale.posix=$BOOST_ICU_POSIX " \
632
633
" -sNO_BZIP2=1" \
633
634
" -sICU_PATH=$ICU_PREFIX " \
634
- " -sICU_LINK=${ICU_LIBS[@ ]} " \
635
+ " -sICU_LINK=${ICU_LIBS[* ]} " \
635
636
" -sZLIB_LIBPATH=$PREFIX /lib" \
636
637
" -sZLIB_INCLUDE=$PREFIX /include" \
637
638
" -j $JOBS " \
@@ -643,6 +644,8 @@ build_from_tarball_boost()
643
644
644
645
pop_directory
645
646
pop_directory
647
+
648
+ IFS=" $SAVE_IFS "
646
649
}
647
650
648
651
# Standard build from github.
@@ -661,14 +664,14 @@ build_from_github()
661
664
display_heading_message " Download $FORK /$BRANCH "
662
665
663
666
# Clone the repository locally.
664
- git clone --depth 1 --branch $BRANCH --single-branch " https://github.com/$FORK "
667
+ git clone --depth 1 --branch " $BRANCH " --single-branch " https://github.com/$FORK "
665
668
666
669
# Join generated and command line options.
667
670
local CONFIGURATION=(" ${OPTIONS[@]} " " $@ " )
668
671
669
672
# Build the local repository clone.
670
673
push_directory " $REPO "
671
- make_current_directory $JOBS " ${CONFIGURATION[@]} "
674
+ make_current_directory " $JOBS " " ${CONFIGURATION[@]} "
672
675
pop_directory
673
676
pop_directory
674
677
}
@@ -687,7 +690,7 @@ build_from_local()
687
690
local CONFIGURATION=(" ${OPTIONS[@]} " " $@ " )
688
691
689
692
# Build the current directory.
690
- make_current_directory $JOBS " ${CONFIGURATION[@]} "
693
+ make_current_directory " $JOBS " " ${CONFIGURATION[@]} "
691
694
}
692
695
693
696
# Because Travis alread has downloaded the primary repo.
@@ -702,13 +705,13 @@ build_from_travis()
702
705
703
706
# The primary build is not downloaded if we are running in Travis.
704
707
if [[ $TRAVIS == true ]]; then
705
- build_from_local " Local $TRAVIS_REPO_SLUG " $JOBS " ${OPTIONS[@]} " " $@ "
706
- make_tests $JOBS
708
+ build_from_local " Local $TRAVIS_REPO_SLUG " " $JOBS " " ${OPTIONS[@]} " " $@ "
709
+ make_tests " $JOBS "
707
710
else
708
- build_from_github $ACCOUNT $REPO $BRANCH $JOBS " ${OPTIONS[@]} " " $@ "
711
+ build_from_github " $ACCOUNT " " $REPO " " $BRANCH " " $JOBS " " ${OPTIONS[@]} " " $@ "
709
712
push_directory " $BUILD_DIR "
710
713
push_directory " $REPO "
711
- make_tests $JOBS
714
+ make_tests " $JOBS "
712
715
pop_directory
713
716
pop_directory
714
717
fi
@@ -719,12 +722,12 @@ build_from_travis()
719
722
# ==============================================================================
720
723
build_all ()
721
724
{
722
- build_from_tarball_boost $BOOST_URL $BOOST_ARCHIVE bzip2 . $PARALLEL " $BUILD_BOOST " " ${BOOST_OPTIONS[@]} "
723
- build_from_tarball $ZMQ_URL $ZMQ_ARCHIVE gzip . $PARALLEL " $BUILD_ZMQ " " ${ZMQ_OPTIONS[@]} " " $@ "
724
- build_from_tarball $MBEDTLS_URL $MBEDTLS_ARCHIVE gzip . $PARALLEL " $BUILD_MBEDTLS " " ${MBEDTLS_OPTIONS[@]} " " $@ "
725
- build_from_github libbitcoin secp256k1 version5 $PARALLEL ${SECP256K1_OPTIONS[@]} " $@ "
726
- build_from_github libbitcoin libbitcoin-system master $PARALLEL ${BITCOIN_SYSTEM_OPTIONS[@]} " $@ "
727
- build_from_travis libbitcoin libbitcoin-protocol master $PARALLEL ${BITCOIN_PROTOCOL_OPTIONS[@]} " $@ "
725
+ build_from_tarball_boost " $BOOST_URL " " $BOOST_ARCHIVE " bzip2 . " $PARALLEL " " $BUILD_BOOST " " ${BOOST_OPTIONS[@]} "
726
+ build_from_tarball " $ZMQ_URL " " $ZMQ_ARCHIVE " gzip . " $PARALLEL " " $BUILD_ZMQ " " ${ZMQ_OPTIONS[@]} " " $@ "
727
+ build_from_tarball " $MBEDTLS_URL " " $MBEDTLS_ARCHIVE " gzip . " $PARALLEL " " $BUILD_MBEDTLS " " ${MBEDTLS_OPTIONS[@]} " " $@ "
728
+ build_from_github libbitcoin secp256k1 version5 " $PARALLEL " " ${SECP256K1_OPTIONS[@]} " " $@ "
729
+ build_from_github libbitcoin libbitcoin-system master " $PARALLEL " " ${BITCOIN_SYSTEM_OPTIONS[@]} " " $@ "
730
+ build_from_travis libbitcoin libbitcoin-protocol master " $PARALLEL " " ${BITCOIN_PROTOCOL_OPTIONS[@]} " " $@ "
728
731
}
729
732
730
733
0 commit comments