support older 32 bit macs running 10.7, fix build

Make mac builder use -m32 in CFLAGS etc. to produce a 32 bit binary
targetting 10.7 (Lion.) This provides the greatest backward
compatibility for older macs, and also allows for asm filters.

Fix an issue with m4 on 10.13 using a patch from macports.

Support `-pX` patch level args in DIST_PATCHES in builder.

Fix an issue with bison on 10.13 by bumping the version to 3.0.5.

Build libxslt `--without-crypto` so that it doesn't try to link the brew
libgcrypt.

Invoke cmake for dists with -DCMAKE_C_COMPILER_LAUNCHER=ccache and
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache to use ccache, and set
CMAKE_C_COMPILER and CMAKE_CXX_COMPILER to the actual compilers not
prefixed by ccache.

When checking for ccache in vbam cmake code, check that
CMAKE_CXX_COMPILER_LAUNCHER and CMAKE_C_COMPILER_LAUNCHER were not
already defined (generally on the command line.)

Remove align attributes from sections in 2xSaImmx.asm, macho format on
mac does not support this and the filter works fine without them.

In the Quartz2D renderer, pass the NSRect view.bounds through
NSRectToCGRect when calling CGContextDrawImage(), this is necessary for
the 32 bit API.

Bump openssl to 1.0.2o.

Bump libxml2 to 2.9.8.

Update URL for urw fonts, and improve the dist downloading/unpacking
code to handle URLs that do not contain the filename (for .tar.gz and
.zip as identified by `file`.)

Change post-build for harfbuzz from `rebuild_dist freetype;` to
`rebuild_dist freetype --with-harfbuzz=yes;` as it was supposed to have
been.

Build cmake itself with --parallel and --enable-ccache.

Silence errors from killed jobs due to tmp directory being gone.

Write a couple of string functions, rtrim() and gsub().

Make path_exists() handle globs with spaces in them, by escaping the
space.

Use --host and --build args to autoconf configure to "cross-compile" for
32 bits, this is necessary for some dists, and does not work for others,
remove it for dists where it does not work.

Add COMMAND_MODE=unix2003 to the build environment, this is necessary to
fix some build errors, why I have no clue, found it on stackoverflow.

Pass -Wl,-no_compact_unwind in LDFLAGS to openssl, this is necessary for
32 bits.

Force sfml to compile as 32 bit, it normally does not allow this.

Remove shared-mime-info from this build, it's not necessary for anything
and there are issues XML::Parser linked to our expat and brew perl that
need to be resolved.
This commit is contained in:
Rafael Kitover 2018-06-30 03:38:22 -07:00
parent 6b4862581e
commit 498019a39b
5 changed files with 143 additions and 28 deletions

View File

@ -38,12 +38,14 @@ endif()
set(ASM_DEFAULT OFF)
# use ccache if available
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)
# use ccache if available, and not already enabled on the command line
if(NOT CMAKE_CXX_COMPILER_LAUNCHER AND NOT CMAKE_C_COMPILER_LAUNCHER)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)
endif()
if(NOT CMAKE_SYSTEM_PROCESSOR)
if(NOT CMAKE_TOOLCHAIN_FILE AND CMAKE_HOST_SYSTEM_PROCESSOR)

View File

@ -44,7 +44,7 @@ GLOBAL _2xSaILine
GLOBAL _2xSaISuperEagleLine
GLOBAL _2xSaISuper2xSaILine
GLOBAL Init_2xSaIMMX
SECTION .text ALIGN = 32
SECTION .text
%ifdef FAR_POINTER
;EXTERN_C void _2xSaILine (uint8 *srcPtr, uint32 srcPitch, uint32 width,
@ -2068,7 +2068,7 @@ end3:
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------
SECTION .data ALIGN = 32
SECTION .data
;Some constants
colorMask dd 0xF7DEF7DE,0xF7DEF7DE
lowPixelMask dd 0x08210821,0x08210821
@ -2085,7 +2085,7 @@ TRUE dd 0xffffffff,0xffffffff
ONE dd 0x00010001,0x00010001
SECTION .bss ALIGN = 32
SECTION .bss
ACPixel resb 8
Mask1 resb 8
Mask2 resb 8

View File

@ -80,7 +80,7 @@ void Quartz2DDrawingPanel::DrawImage(wxWindowDC& dc, wxImage* im)
CGContextTranslateCTM(context, 0, view.bounds.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextDrawImage(context, view.bounds, image);
CGContextDrawImage(context, NSRectToCGRect(view.bounds), image);
CGContextRestoreGState(context);

View File

@ -24,6 +24,14 @@ case "\$CC" in
;;
*)
if command -v ccache >/dev/null; then
case "\$REQUIRED_CMAKE_ARGS" in
*ccache*)
:
;;
*)
REQUIRED_CMAKE_ARGS="\$REQUIRED_CMAKE_ARGS -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER=\$CC -DCMAKE_CXX_COMPILER=\$CXX"
;;
esac
export CC="ccache \$CC"
export CXX="ccache \$CXX"
fi
@ -101,7 +109,7 @@ DISTS=$DISTS'
xz https://tukaani.org/xz/xz-5.2.3.tar.gz lib/liblzma.a
unzip https://downloads.sourceforge.net/project/infozip/UnZip%206.x%20%28latest%29/UnZip%206.0/unzip60.tar.gz bin/unzip
zip https://downloads.sourceforge.net/project/infozip/Zip%203.x%20%28latest%29/3.0/zip30.tar.gz bin/zip
openssl https://www.openssl.org/source/openssl-1.0.2l.tar.gz lib/libssl.a
openssl https://www.openssl.org/source/openssl-1.0.2o.tar.gz lib/libssl.a
cmake https://cmake.org/files/v3.10/cmake-3.10.0-rc3.tar.gz bin/cmake
zlib https://zlib.net/zlib-1.2.11.tar.gz lib/libz.a
m4 http://ftp.gnu.org/gnu/m4/m4-1.4.18.tar.xz bin/m4
@ -115,7 +123,7 @@ DISTS=$DISTS'
gettext http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.1.tar.xz lib/libintl.a
getopt http://frodo.looijaard.name/system/files/software/getopt/getopt-1.1.6.tar.gz bin/getopt
gsed http://ftp.gnu.org/gnu/sed/sed-4.4.tar.xz bin/sed
bison https://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.xz bin/bison
bison https://ftp.gnu.org/gnu/bison/bison-3.0.5.tar.xz bin/bison
texinfo http://ftp.gnu.org/gnu/texinfo/texinfo-6.5.tar.xz bin/makeinfo
flex-2.6.3 https://github.com/westes/flex/releases/download/v2.6.3/flex-2.6.3.tar.gz bin/flex
flex https://github.com/westes/flex/archive/e7d45afc6aeb49745f17d21ddba4848e0c0118fc.tar.gz bin/flex
@ -127,7 +135,7 @@ DISTS=$DISTS'
pcre https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.bz2 lib/libpcre.a
libffi ftp://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz lib/libffi.a
c2man http://www.ciselant.de/c2man/c2man-2.0@42.tar.gz bin/c2man
libxml2 ftp://xmlsoft.org/libxml2/libxml2-2.9.7.tar.gz lib/libxml2.a
libxml2 ftp://xmlsoft.org/libxml2/libxml2-2.9.8.tar.gz lib/libxml2.a
libxslt https://github.com/GNOME/libxslt/archive/v1.1.33-rc1.tar.gz lib/libxslt.a
XML-NamespaceSupport https://cpan.metacpan.org/authors/id/P/PE/PERIGRIN/XML-NamespaceSupport-1.12.tar.gz perl5/lib/perl5/XML/NamespaceSupport.pm
XML-SAX-Base https://cpan.metacpan.org/authors/id/G/GR/GRANTM/XML-SAX-Base-1.09.tar.gz perl5/lib/perl5/XML/SAX/Base.pm
@ -137,12 +145,13 @@ DISTS=$DISTS'
libpng https://download.sourceforge.net/libpng/libpng-1.6.32.tar.xz lib/libpng.a
libjpeg-turbo https://github.com/libjpeg-turbo/libjpeg-turbo/archive/1.5.2.tar.gz lib/libjpeg.a
libtiff http://download.osgeo.org/libtiff/tiff-4.0.9.tar.gz lib/libtiff.a
# libcroco http://ftp.gnome.org/pub/gnome/sources/libcroco/0.6/libcroco-0.6.12.tar.xz lib/libcroco-0.6.a
freetype http://download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.bz2 lib/libfreetype.a
fontconfig https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.6.tar.bz2 lib/libfontconfig.a
libgd https://github.com/libgd/libgd/releases/download/gd-2.2.4/libgd-2.2.4.tar.xz lib/libgd.a
dejavu https://downloads.sourceforge.net/project/dejavu/dejavu/2.37/dejavu-fonts-ttf-2.37.tar.bz2 share/fonts/dejavu/DejaVuSansMono.ttf
liberation https://releases.pagure.org/liberation-fonts/liberation-fonts-ttf-2.00.1.tar.gz share/fonts/liberation/LiberationMono-Regular.ttf
urw http://git.ghostscript.com/?p=urw-core35-fonts.git;a=snapshot;h=91edd6ece36e84a1c6d63a1cf63a1a6d84bd443a;sf=tgz share/fonts/urw/a010013l.pfm
urw http://git.ghostscript.com/?p=urw-core35-fonts.git;a=snapshot;h=91edd6ece36e84a1c6d63a1cf63a1a6d84bd443a;sf=tgz share/fonts/urw/URWBookman-Light.ttf
graphviz https://gitlab.com/graphviz/graphviz/repository/archive.tar.bz2?ref=bd97cff688f7a7b85b6f1262e14eb1cac0862fcd bin/dot_static
docbook4.2 http://www.docbook.org/xml/4.2/docbook-xml-4.2.zip share/xml/docbook/schema/dtd/4.2/catalog.xml
docbook4.1.2 http://www.docbook.org/xml/4.1.2/docbkx412.zip share/xml/docbook/schema/dtd/4.1.2/catalog.xml
@ -285,7 +294,7 @@ DIST_PRE_BUILD="$DIST_PRE_BUILD
"
DIST_POST_BUILD="$DIST_POST_BUILD
harfbuzz rebuild_dist freetype;
harfbuzz rebuild_dist freetype --with-harfbuzz=yes;
flex-2.6.3 build_dist flex || :;
glib rebuild_dist gettext --without-included-glib --without-included-libxml;
graphviz (cd '$BUILD_ROOT/root/bin'; path_exists dot_static && ! path_exists dot && ln -sf '$BUILD_ROOT/root/bin/dot_static' ./dot || :)
@ -303,7 +312,7 @@ DIST_POST_CONFIGURE="$DIST_POST_CONFIGURE
DIST_CONFIGURE_OVERRIDES="$DIST_CONFIGURE_OVERRIDES
openssl ./config no-shared --prefix=/usr --openssldir=/etc/ssl
cmake ./configure --prefix=/usr --no-qt-gui
cmake ./configure --prefix=/usr --no-qt-gui --parallel=\$NUM_CPUS --\"\$(set -- \$CC; if [ \"\$1\" = ccache ]; then echo enable; else echo disable; fi)\"-ccache
zlib ./configure --static --prefix=/usr
XML-SAX echo no | PERL_MM_USE_DEFAULT=0 perl Makefile.PL
wxwidgets ./configure $REQUIRED_CONFIGURE_ARGS --disable-shared --prefix=/usr --enable-stl --disable-precomp-headers --enable-cxx11 --enable-permissive --with-opengl --with-libpng
@ -337,7 +346,7 @@ DIST_ARGS="$DIST_ARGS
gettext --with-included-gettext --with-included-glib --with-included-libcroco --with-included-libunistring --with-included-libxml --disable-curses CPPFLAGS=\"\$CPPFLAGS -DLIBXML_STATIC\"
pkgconfig --with-internal-glib --with-libiconv=gnu
pcre --enable-utf8 --enable-pcre8 --enable-pcre16 --enable-pcre32 --enable-unicode-properties --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-jit
libxslt --without-python
libxslt --without-python --without-crypto
libgd --without-xpm
fontconfig --with-baseconfigdir=/etc/fonts
graphviz --disable-ltdl --without-x CFLAGS=\"-include \$PWD/declspec.h $CFLAGS\"
@ -348,6 +357,7 @@ DIST_ARGS="$DIST_ARGS
XML-Parser EXPATINCPATH='$BUILD_ROOT/root/include' EXPATLIBPATH='$BUILD_ROOT/root/lib'
doxygen -DICONV_ACCEPTS_NONCONST_INPUT:BOOL=FALSE -DICONV_ACCEPTS_CONST_INPUT:BOOL=TRUE
sfml -DSFML_USE_SYSTEM_DEPS=TRUE
libcroco --disable-Bsymbolic
freetype --with-harfbuzz=no
harfbuzz --with-cairo=no --with-icu=no
flac --disable-ogg
@ -924,7 +934,10 @@ dist_file() {
# remove query string stuff
dist_file=${dist_file%\?*}
putsln "$BUILD_ROOT/downloads/$current_dist-$dist_file"
# set full path
dist_file="$BUILD_ROOT/downloads/$current_dist-$dist_file"
puts "$(resolve_link "$dist_file")"
}
dist_dir() {
@ -956,9 +969,41 @@ download_dist() {
if [ ! -f "$dist_file" ]; then
puts "${NL}Fetching $current_dist: $dist_url${NL}${NL}"
$CURL -SsL "$dist_url" -o "$dist_file"
case "$dist_file" in
*.*)
;;
*)
# no extension, try to figure out if zip or .tar.gz
new_dist_file=$(echo "$dist_file" | sed 's/-* *$//') # remove trailing dash and spaces
case "$(file "$dist_file")" in
*gzip*)
mv "$dist_file" "$new_dist_file.tar.gz"
ln -sf "$new_dist_file.tar.gz" "$dist_file"
;;
*Zip\ archive*)
mv "$dist_file" "$new_dist_file.zip"
ln -sf "$new_dist_file.zip" "$dist_file"
;;
esac
;;
esac
fi
}
rtrim() {
str=$1
while [ "$str" != "${str% }" ]; do
str="${str% }"
done
puts "$str"
}
download_failed() {
job_pid=$1
@ -977,7 +1022,7 @@ unpack_dist() {
dist_dir="$DISTS_DIR/$current_dist"
if [ ! -f "$dist_file" ]; then
error "unpack_dist: missing dist file fir dist '$current_dist': '$dist_file'"
error "unpack_dist: missing dist file for dist '$current_dist': '$dist_file'"
fi
puts "${NL}Unpacking $current_dist${NL}${NL}"
@ -1055,12 +1100,12 @@ start_job() {
write_job_exit_status() {
_exit_status=$?
putsln "job_exited='$_exit_status'" >> "$TMP_DIR/job_status/$current_job_pid"
putsln "job_exited='$_exit_status'" >> "$TMP_DIR/job_status/$current_job_pid" 2>/dev/null
}
write_job_info() {
[ -n "$1" ] || die 'write_job_info: key name required'
putsln "${1}='${2}'" >> "$TMP_DIR/job_status/$current_job_pid"
putsln "${1}='${2}'" >> "$TMP_DIR/job_status/$current_job_pid" 2>/dev/null
}
write_job_output() {
@ -2052,7 +2097,16 @@ dist_patch() {
current_dist=$1
[ -n "$current_dist" ] || die 'dist_patch: dist name required'
_patch_level=-p1
for _patch_url in $(table_line DIST_PATCHES $current_dist); do
case "$_patch_url" in
-p*)
_patch_level=$_patch_url
continue
;;
esac
_patch_file=${_patch_url##*/}
_patch_file=${_patch_file%%\?*}
@ -2060,7 +2114,10 @@ dist_patch() {
puts "${NL}Applying patch $_patch_url to $current_dist${NL}${NL}"
$CURL -SsL "$_patch_url" -o "$_patch_file"
patch -l -p1 < "$_patch_file"
patch -l $_patch_level < "$_patch_file"
# reset patch level to 1 which is default
_patch_level=-p1
fi
done_msg
@ -2536,8 +2593,39 @@ putsln() {
path_exists() {
[ -z "$1" ] && return 1
if [ -e "$1" ] || [ -L "$1" ] || [ -d "$1" ]; then
return 0
fi
# check unquoted versions in case of globs
[ -e "$1" ] || [ -L "$1" ] || [ -d "$1" ] || [ -e $1 ] || [ -L $1 ] || [ -d $1 ]
# but must escape spaces first
escaped=$(gsub ' ' '\ ' "$1")
[ -e $escaped ] || [ -L $escaped ] || [ -d $escaped ]
}
gsub() {
match=$1
repl=$2
shift; shift;
res=
str="$@"
while [ -n "$str" ]; do
case "$str" in
*$match*)
res="$res${str%%$match*}$repl"
str="${str#*$match}"
;;
*)
res="$res$str"
break
;;
esac
done
printf '%s' "$res"
}
# on msys2 `ln -sf` to an existing link silently fails

View File

@ -17,24 +17,49 @@ BUILD_ROOT=$HOME/vbam-build-mac
BUILD_ENV=$(cat <<'EOF'
export MACOSX_DEPLOYMENT_TARGET=10.7
export COMMAND_MODE=unix2003
export CC=clang
export CXX=clang++
export CPPFLAGS="-DICONV_CONST="
export CFLAGS="-framework Carbon -framework Foundation -framework CoreServices -arch x86_64 -Wno-unused-command-line-argument -DICONV_CONST="
export CXXFLAGS="-stdlib=libc++ -framework Carbon -framework Foundation -framework CoreServices -arch x86_64 -Wno-unused-command-line-argument -DICONV_CONST="
export OBJCXXFLAGS="-stdlib=libc++ -framework Carbon -framework Foundation -framework CoreServices -arch x86_64 -Wno-unused-command-line-argument -DICONV_CONST="
export LDFLAGS="-framework Carbon -framework Foundation -framework CoreServices -arch x86_64 -Wno-unused-command-line-argument"
export CFLAGS="-m32 -framework Carbon -framework Foundation -framework CoreServices -Wno-unused-command-line-argument -DICONV_CONST= -Wl,-no_compact_unwind"
export CXXFLAGS="-m32 -stdlib=libc++ -framework Carbon -framework Foundation -framework CoreServices -Wno-unused-command-line-argument -DICONV_CONST= -Wl,-no_compact_unwind"
export OBJCXXFLAGS="-m32 -stdlib=libc++ -framework Carbon -framework Foundation -framework CoreServices -Wno-unused-command-line-argument -DICONV_CONST= -Wl,-no_compact_unwind"
export LDFLAGS="-m32 -framework Carbon -framework Foundation -framework CoreServices -Wno-unused-command-line-argument -Wl,-no_compact_unwind"
EOF
)
TAR=tar
REQUIRED_CONFIGURE_ARGS='--host=i386-apple-darwin --build=x86_64-apple-darwin'
. "$(dirname "$0")/../builder/core.sh"
table_line_remove DISTS flex
table_line_remove DISTS libsecret
table_line_replace DIST_CONFIGURE_OVERRIDES openssl './Configure darwin64-x86_64-cc no-shared --prefix=/usr --openssldir=/etc/ssl'
# issues with perl modules linked to our libs and brew perl
table_line_remove DISTS shared-mime-info
table_line_replace DIST_CONFIGURE_OVERRIDES openssl './Configure darwin-i386-cc no-shared --prefix=/usr --openssldir=/etc/ssl'
table_line_append DIST_MAKE_ARGS openssl "LDFLAGS=\"\$LDFLAGS\""
# m4 crashes on 10.13
table_line_append DIST_PATCHES m4 '-p0 https://raw.githubusercontent.com/macports/macports-ports/edf0ee1e2cf/devel/m4/files/secure_snprintf.patch'
# some dists will not cross compile without a CONFIG_SITE
table_line_append DIST_ARGS glib '--host= --build='
table_line_append DIST_ARGS pkgconfig '--host= --build='
table_line_append DIST_ARGS docbook2x '--host= --build='
# python does not support cross-compiling to 32bits
table_line_append DIST_ARGS python2 '--host= --build='
table_line_append DIST_ARGS python3 '--host= --build='
table_line_append DIST_ARGS sfml '-DCMAKE_OSX_ARCHITECTURES=i386'
table_line_append DIST_PRE_BUILD sfml " \
sed -i.bak '/FATAL_ERROR \"Only 64-bit architecture is supported/d' CMakeLists.txt; \
"
table_line_replace DIST_CONFIGURE_TYPES libmodplug autoreconf
table_line_append DIST_PRE_BUILD libmodplug " \