2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#!/usr/bin/env bash
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Your build script should simply source this script, optionally override any build hooks and then invoke `build`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# The build product should be available under `build-<platform>~/out`, under the library path.
							 
						 
					
						
							
								
									
										
										
										
											2018-06-30 20:53:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# Hook lifecycle:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - build
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#     - initialize
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#         - needs
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#     - clean & exit (only if script was ran with "clean" argument)
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#     - check & exit (only if target has already been successfully built)
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#     - prepare
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#         - create
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#         - config
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#     - target
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#         - prepare
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#         - configure
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#         - build
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#     - finalize
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#         - merge
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#         - clean
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# You can override any of these hooks to provide a custom implementation or call their underscore variant to delegate to the default implementation.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# For example:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# target_prepare() { make -s distclean; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# target_configure() { _target_configure "$@" --enable-minimal; }
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								set -e
							 
						 
					
						
							
								
									
										
										
										
											2018-07-26 15:05:58 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								PATH+=:/usr/local/bin
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# needs <binary> ...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Utility for ensuring all tools needed by the script are installed prior to starting.
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								needs() { _needs "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_needs() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    local failed=0
							 
						 
					
						
							
								
									
										
										
										
											2018-08-01 20:13:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    for spec; do
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        IFS=: read pkg tools <<< "$spec"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        IFS=, read -a tools <<< "${tools:-$pkg}"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        for tool in "${tools[@]}"; do
							 
						 
					
						
							
								
									
										
										
										
											2018-08-07 00:07:16 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            hash "$tool" 2>/dev/null && continue 2
							 
						 
					
						
							
								
									
										
										
										
											2018-08-01 20:13:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        done
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        echo >&2 "Missing: $pkg.  Please install this package."
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        (( failed++ ))
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    done
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return $failed
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# initialize <prefix> <platform>
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# The build script invokes this once prior to all other actions.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								initialize() { _initialize "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_initialize() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    initialize_needs "$@"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# initialize_needs <prefix> <platform>
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Check if all tools required to configure and build for the platform are available.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# By default, this will check for:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - Windows: MSBuild
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - Other: `libtool` (for libtoolize), `automake` (for aclocal), `autoconf` (for autoreconf) and make
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								initialize_needs() { _initialize_needs "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_initialize_needs() {
							 
						 
					
						
							
								
									
										
										
										
											2018-06-24 16:20:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if [[ $platform = windows ]]; then
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        needs cmd
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        for dir in "$VSINSTALLDIR" "$(cygpath -F 0x002a)/Microsoft Visual Studio"/*/*/Common7/..; do
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            dir=$( [[ $dir ]] && cd "$dir" && [[ -e "Common7/Tools/VsMSBuildCmd.bat" ]] && cygpath -w "$PWD" ) && \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                export VSINSTALLDIR=$dir && echo "Using MSBuild: $VSINSTALLDIR" && return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        done
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        echo >&2 "Missing: msbuild.  Please install 'Build Tools for Visual Studio'.  See https://visualstudio.microsoft.com/downloads/?q=build+tools"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return 1
							 
						 
					
						
							
								
									
										
										
										
											2018-06-24 16:20:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    else
							 
						 
					
						
							
								
									
										
										
										
											2018-08-01 20:13:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        needs libtool:libtoolize,glibtoolize automake autoconf make
							 
						 
					
						
							
								
									
										
										
										
											2018-06-24 16:20:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    fi
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# clean <prefix> <platform>
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Fully clean up the library code, restoring it to a pristine state.
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# By default, this will:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - Windows: `msbuild /t:Clean`, or
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - Makefile: run `make distclean`, or
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - GIT: `git clean -fdx`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Finally, it will wipe the prefix.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								clean() { _clean "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_clean() {
							 
						 
					
						
							
								
									
										
										
										
											2018-06-24 16:20:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if [[ $platform = windows ]]; then
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        PATH="$(cygpath "$VSINSTALLDIR")/Common7/Tools:$PATH" \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            cmd /v /c 'VsMSBuildCmd && for %s in (*.sln) do msbuild /t:Clean %s'
							 
						 
					
						
							
								
									
										
										
										
											2018-07-01 21:20:56 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    elif [[ -e Makefile ]] && make -s distclean; then :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    elif [[ -e .git ]] && git clean -fdx; then :
							 
						 
					
						
							
								
									
										
										
										
											2018-06-24 16:20:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    fi
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-07-01 21:20:56 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    rm -rf "$prefix"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# prepare <prefix> <platform> [ <arch:host> ... ]
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Initialize the prefix in anticipation for building the <arch>s on this machine.
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# The build script invokes this once prior to building each of its targets.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								prepare() { _prepare "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_prepare() {
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    prepare_create "$@"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    prepare_config "$@"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# prepare_create <prefix> <platform> [ <arch:host> ... ]
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Perform any necessary clean-up of the library code prior to building.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 16:21:28 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# By default, this will wipe the build configuration and re-create the prefix.
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# TODO: Should this differ from clean()?
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								prepare_create() { _prepare_create "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_prepare_create() {
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    local prefix=$1 platform=$2; shift 2
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-05-29 12:49:49 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if [[ $platform = windows ]]; then :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    else
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 16:21:28 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        [[ ! -e Makefile ]] || make -s distclean || git clean -fdx
							 
						 
					
						
							
								
									
										
										
										
											2019-05-29 12:49:49 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    fi
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    rm -rf "$prefix"
							 
						 
					
						
							
								
									
										
										
										
											2018-07-01 21:20:56 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    install -d "$prefix/out"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# prepare_config <prefix> <platform> [ <arch:host> ... ]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Generate build solution for configuring a build on this machine.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# The <prefix> has been newly created.
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# TODO: cmake support?
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# By default, this will:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - Windows: do nothing
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - Other: run `autoreconf`.
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								prepare_config() { _prepare_config "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_prepare_config() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    local prefix=$1 platform=$2; shift 2
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-07-01 21:20:56 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    [[ -e "$prefix/out/.prepared" ]] && return
							 
						 
					
						
							
								
									
										
										
										
											2018-06-24 16:20:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-07-01 21:20:56 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if [[ $platform = windows ]]; then :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    else
							 
						 
					
						
							
								
									
										
										
										
											2019-06-07 18:24:07 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        # autoreconf installs a useless INSTALL documentation stub that can overwrite repo docs.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        [[ -e INSTALL ]] && mv INSTALL{,~}
							 
						 
					
						
							
								
									
										
										
										
											2018-07-04 12:16:37 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        autoreconf --verbose --install --force 2> >(sed 's/^\([^:]*\):[0-9]\{1,\}: /\1: /')
							 
						 
					
						
							
								
									
										
										
										
											2019-06-07 18:24:07 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        [[ -e INSTALL~ ]] && mv INSTALL{~,}
							 
						 
					
						
							
								
									
										
										
										
											2018-07-01 21:20:56 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    fi
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    touch "$prefix/out/.prepared"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# target <prefix> <platform> <arch> <host>
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Build the library to the <arch> binary for the <host> architecture on <platform> into the given <prefix>.
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# The build script invokes this function when it's ready to build the library's code.
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								target() { _target "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_target() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    target_prepare "$@"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    target_configure "$@"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    target_build "$@"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# target_prepare <prefix> <platform> <arch> <host>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Any build-related work to be done in the prefix prior to building.
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# By default, this will:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - Windows: do nothing
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - macOS/iOS: Discover SDKROOT & build flags
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - Android: Prepare an NDK toolchain & build flags
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - Makefile: run `make clean`
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								target_prepare() { _target_prepare "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_target_prepare() {
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    local prefix=$1 platform=$2 arch=$3 host=$4; shift 3
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    case "$platform" in
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        'windows')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        'macos')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            SDKROOT="$(xcrun --show-sdk-path --sdk macosx)"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            export PATH="$(xcrun --show-sdk-platform-path --sdk macosx)/usr/bin:$PATH"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            export CPPFLAGS="-arch $host -flto -O2 -g -isysroot $SDKROOT -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET:-10.8} $CPPFLAGS"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            export LDFLAGS="-arch $host -flto -isysroot $SDKROOT -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET:-10.8} $LDFLAGS"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        'ios')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            case "$arch" in
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                *'arm'*)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    SDKROOT="$(xcrun --show-sdk-path --sdk iphoneos)"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    export PATH="$(xcrun --show-sdk-platform-path --sdk iphoneos)/usr/bin:$PATH"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    export CPPFLAGS="-arch $host -mthumb -fembed-bitcode -flto -O2 -g -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} $CPPFLAGS"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    export LDFLAGS="-arch $host -mthumb -fembed-bitcode -flto -isysroot $SDKROOT -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} $LDFLAGS"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                *)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    SDKROOT="$(xcrun --show-sdk-path --sdk iphonesimulator)"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    export PATH="$(xcrun --show-sdk-platform-path --sdk iphonesimulator)/usr/bin:$PATH"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    export CPPFLAGS="-arch $host -flto -O2 -g -isysroot $SDKROOT -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} $CPPFLAGS"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    export LDFLAGS="-arch $host -flto -isysroot $SDKROOT -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET:-8.0} $LDFLAGS"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            esac
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        'android')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            [[ -x $ANDROID_NDK_HOME/build/ndk-build ]] || { echo >&2 "Android NDK not found.  Please set ANDROID_NDK_HOME."; return 1; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            SDKROOT="$prefix/$arch/ndk"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            # Platform 21 is lowest that supports x86_64
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            "$ANDROID_NDK_HOME/build/tools/make-standalone-toolchain.sh" --force --install-dir="$SDKROOT" --platform='android-21' --arch="$arch"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            export PATH="$SDKROOT/bin:$PATH"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            export CPPFLAGS="-O2 -g $CPPFLAGS"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            export LDFLAGS="-avoid-version $LDFLAGS"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            export CC='clang'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        *)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            case "$arch" in
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                x86)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    export CPPFLAGS="-m32 $CPPFLAGS" LDFLAGS="-m32 $LDFLAGS"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                x86_64)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    export CPPFLAGS="-m64 $CPPFLAGS" LDFLAGS="-m64 $LDFLAGS"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            esac
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    esac
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-07-01 21:20:56 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if [[ $platform = windows ]]; then :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    else
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        [[ ! -e Makefile ]] || make -s clean
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    fi
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# target_configure <prefix> <platform> <arch> <host> [ <args> ... ]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Configure the library for building the target. This generates the compiler configuration.
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# By default, this will:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - Windows: do nothing
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - Other: run `./configure --host=<host> --prefix=<prefix>/<arch> <args>`.
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Some platform-specific configure arguments will be passed in as well.
							 
						 
					
						
							
								
									
										
										
										
											2018-06-30 23:35:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# --enable-pic --disable-pie to ensure the resulting library can be linked again.
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								target_configure() { _target_configure "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_target_configure() {
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    local prefix=$1 platform=$2 arch=$3 host=$4; shift 4
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 10:50:22 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    local build=
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 16:21:28 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    [[ -x config.guess ]] && build=$(./config.guess)
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 10:50:22 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    [[ -x build-aux/config.guess ]] && build=$(build-aux/config.guess)
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    case "$platform" in
							 
						 
					
						
							
								
									
										
										
										
											2018-06-24 16:20:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        'windows')
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 12:45:35 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            # doesn't use ./configure
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            return 0
							 
						 
					
						
							
								
									
										
										
										
											2018-06-24 16:20:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        ;;
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 16:21:28 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        'ios'|'macos')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            host+=-apple
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            set -- --enable-static --disable-shared "$@"
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 16:21:28 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        ;;
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        'android')
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 16:21:28 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            host=( "$SDKROOT/$host"*-android* ) host=${host##*/}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            set -- --disable-static --enable-shared --with-sysroot="$SDKROOT/sysroot" "$@"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        *)
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            set -- --enable-static --disable-shared "$@"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    esac
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 16:21:28 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    ./configure ${build:+--build="$build"} ${host:+--host="$host"} --prefix="$prefix/$arch" --enable-pic --disable-pie "$@"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# target_build <prefix> <platform> <arch> <host>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Build the library code for the target. This runs the compiler per the previous configuration.
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# By default, this will:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - Windows: run `msbuild /t:Rebuild /p:Configuration:Release;Platform=<host>`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# - Other: run `make check install`.
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								target_build() { _target_build "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_target_build() {
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    local prefix=$1 platform=$2 arch=$3 host=$4; shift 4
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-24 16:20:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if [[ $platform = windows ]]; then
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if [[ -e CMakeLists.txt ]]; then
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            ( projdir=$PWD; mkdir -p "$prefix/$arch/"; cd "$prefix/$arch/"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            PATH="$(cygpath "$VSINSTALLDIR")/Common7/Tools:$(cygpath "$VSINSTALLDIR")/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin:$PATH" \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                cmd /v /c "$(printf 'VsMSBuildCmd && cmake -A %s %s && for %%s in (*.sln) do msbuild /m /t:Rebuild /p:Configuration=Release;Platform=%s;OutDir=. %%s' \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                "$host" "$(cygpath -w "$projdir")" "$host")" )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        else
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									    PATH="$(cygpath "$VSINSTALLDIR")/Common7/Tools:$PATH" \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cmd /v /c "$(printf 'VsMSBuildCmd && for %%s in (*.sln) do msbuild /m /t:Rebuild /p:Configuration=Release;Platform=%s;OutDir=%s %%s' \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										"$host" "$(cygpath -w "${prefix##$PWD/}/$arch/")")"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									fi
							 
						 
					
						
							
								
									
										
										
										
											2018-06-24 16:20:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    else
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        local cores=$(getconf NPROCESSORS_ONLN 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null ||:)
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        #make -j"${cores:-3}" check install # TODO: libjson-c breaks on parallel build for check and install
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        #make check install # TODO: libjson-c has a failing test atm
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        make install
							 
						 
					
						
							
								
									
										
										
										
											2018-06-24 16:20:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    fi
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# finalize <prefix> <platform> [ <arch> ... ]
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Prepare the final build product.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# The build script invokes this once after a successful build of all targets.
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								finalize() { _finalize "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_finalize() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    finalize_merge "$@"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    finalize_clean "$@"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# finalize_merge <prefix> <platform> [ <arch> ... ]
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Merge all targets into a product the application can use, available at `<prefix>/out`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# By default, this will copy the headers to `<prefix>/out/include`, install libraries into `<prefix>/out/lib` and mark the output product as successful.
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								finalize_merge() { _finalize_merge "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_finalize_merge() {
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    local prefix=$1 platform=$2; shift 2
							 
						 
					
						
							
								
									
										
										
										
											2018-06-30 23:35:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    local archs=( "$@" )
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 16:21:28 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    [[ -e "$prefix/$archs/include" ]] && cp -a -- "$prefix/$archs/include" "$prefix/out/"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-07-01 21:20:56 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    install -d "$prefix/out/lib"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    case "$platform" in
							 
						 
					
						
							
								
									
										
										
										
											2018-06-30 23:35:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        'linux')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            for arch in "${archs[@]}"; do
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                install -d "$prefix/out/lib/$arch"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                install -p "$prefix/$arch/lib/"*.a "$prefix/out/lib/$arch/"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            done
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ;;
							 
						 
					
						
							
								
									
										
										
										
											2018-06-24 16:20:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        'windows')
							 
						 
					
						
							
								
									
										
										
										
											2018-06-30 23:35:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            for arch in "${archs[@]}"; do
							 
						 
					
						
							
								
									
										
										
										
											2018-06-24 16:20:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                install -d "$prefix/out/lib/$arch"
							 
						 
					
						
							
								
									
										
										
										
											2018-06-25 02:02:51 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                install -p "$prefix/$arch/"*.lib "$prefix/out/lib/$arch/"
							 
						 
					
						
							
								
									
										
										
										
											2018-06-24 16:20:42 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            done
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ;;
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        'macos'|'ios')
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 16:21:28 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            for arch in "${archs[@]}"; do
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                install -d "$prefix/out/lib/$arch"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                install -p "$prefix/$arch/lib/"*.a "$prefix/out/lib/$arch/"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            done
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 16:21:28 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            local libs=( "$prefix/out/lib/"*/* )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            lipo -create "${libs[@]}" -output "$prefix/out/lib/${libs##*/}"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        'android')
							 
						 
					
						
							
								
									
										
										
										
											2018-06-30 23:35:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            for arch in "${archs[@]}"; do
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                local abi=$arch
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                case "$arch" in
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    'arm')      abi='armeabi-v7a' ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    'arm64')    abi='arm64-v8a' ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                esac
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                install -d "$prefix/out/lib/$abi"
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 16:21:28 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                install -p "$prefix/$arch/lib/"*.so "$prefix/out/lib/$abi/"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            done
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    esac
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    touch "$prefix/out/.success"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# finalize_clean <prefix> [ <arch> ... ]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Clean up the library after a successful build (eg. housekeeping of temporary files).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# By default, this will run `make clean`.
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								finalize_clean() { _finalize_clean "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_finalize_clean() {
							 
						 
					
						
							
								
									
										
										
										
											2018-08-27 13:07:38 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if [[ $platform = windows ]]; then :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    else
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        [[ ! -e Makefile ]] || make -s clean
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    fi
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# build <name> [<platform>]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Build the library <name> (found at ../<name>) for platform <platform> (or "host" if unspecified).
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								#
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								build() { _build "$@"; }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								_build() {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    local name=$1 platform=${2:-host}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    local path="../$name"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    [[ $path = /* ]] || path="${BASH_SOURCE%/*}/$path"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    cd "$path"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if [[ $platform = host ]]; then
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        case "$(uname -s)" in
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            'Darwin') platform='macos' archs=( "$(uname -m)" ) ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        esac
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    fi
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if (( ! ${#archs[@]} )); then
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        case "$platform" in
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            'macos') archs=( 'x86_64' ) ;;
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            'ios') archs=( 'x86:i386' 'x86_64' 'armv7' 'armv7s' 'arm64' ) ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            'android') archs=( 'arm' 'arm64:aarch64' 'x86:i686' 'x86_64' ) ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            'windows') archs=( 'x86:Win32' 'x86_64:x64' ) ;;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            *) archs=( 'x86:i686' 'x86_64' ) ;;
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        esac
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    fi
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    local prefix="$PWD/build-$platform~"
							 
						 
					
						
							
								
									
										
										
										
											2019-09-26 16:21:28 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    echo
							 
						 
					
						
							
								
									
										
										
										
											2019-09-25 22:51:12 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    echo " # $name ($platform: ${archs[*]}) into $prefix ..."
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    initialize "$prefix" "$platform"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    # "clean" argument wipes the lib clean and exits. If .success exists in prefix output, skip build.
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    if [[ ${BASH_ARGV[@]:(-1)} = clean ]]; then
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        clean "$prefix" "$platform"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        exit
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    elif [[ -e "$prefix"/out/.success ]]; then
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        echo >&2 "Skipping build for $platform: output product already built successfully."
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        exit
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    fi
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    # Prepare the output location and build configuration.
							 
						 
					
						
							
								
									
										
										
										
											2018-05-21 17:38:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    prepare "$prefix" "$platform" "${archs[@]}"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    # Repeat the build for each individual architecture.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for arch in "${archs[@]}"; do (
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        local host=${arch#*:} arch=${arch%%:*}
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        echo
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        echo " # $name [$platform: $arch ($host)] ..."
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        target "$prefix" "$platform" "$arch" "$host"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    ); done
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-11 14:12:06 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    finalize "$prefix" "$platform" "${archs[@]%%:*}"
							 
						 
					
						
							
								
									
										
										
										
											2018-05-20 14:24:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}