Commit 66980934 authored by Rafael Kitover's avatar Rafael Kitover
Browse files

add multi-platform build system

under `tools/` add some scripts to invoke the build system to build all
deps for vbam and vbam itself:

- `tools/linux/builder`

This builds a mostly static linux binary with a few dynamic deps for
xorg and wayland. Using gtk3. This will run on just about any dist.

- `tools/osx/builder`

Builds a static mac app targetting 10.7.

- `tools/win/linux-cross-builder`

Builds a static windows binary using the mingw-w64 toolchain.

- `tools/win/msys2-builder`

Builds a static windows binary in the MSYS2 environment, this may be
suffering from a few regressions.

Change some cmake code to support the build system, refactor a few
things in it.
parent 3e052c94
This diff is collapsed.
......@@ -130,14 +130,18 @@ Here is the complete list:
| ENABLE_MMX | Enable MMX | ON for 32 bit builds |
| ENABLE_LINK | Enable GBA linking functionality (requires SFML) | ON |
| ENABLE_LIRC | Enable LIRC support | OFF |
| ENABLE_FFMPEG | Enable ffmpeg A/V recording | ON on Linux and MSys2 |
| ENABLE_FFMPEG | Enable ffmpeg A/V recording | OFF |
| ENABLE_LTO | Compile with Link Time Optimization (gcc and clang only) | ON for release build |
| ENABLE_GBA_LOGGING | Enable extended GBA logging | ON |
| ENABLE_DIRECT3D | Direct3D rendering for wxWidgets (Windows, **NOT IMPLEMENTED!!!**) | ON |
| ENABLE_XAUDIO2 | Enable xaudio2 sound output for wxWidgets (Windows only) | ON |
| ENABLE_OPENAL | Enable OpenAL for the wxWidgets port | ON |
| SFML_STATIC_LIBRARIES | Set this to ON if linking static SFML libraries | OFF |
| FFMPEG_STATIC | Set this to ON if linking static ffmpeg librariesl | OFF |
| VBAM_STATIC | Try link all libs statically (the following are set to ON if ON) | OFF |
| SDL2_STATIC | Try to link static SDL2 libraries | OFF |
| SFML_STATIC_LIBRARIES | Try to link static SFML libraries | OFF |
| FFMPEG_STATIC | Try to link static ffmpeg libraries | OFF |
| SSP_STATIC | Try to link static gcc stack protector library (gcc only) | OFF except Win32 |
| OPENAL_STATIC | Try to link static OpenAL libraries | OFF |
Note for distro packagers, we use the CMake module
[GNUInstallDirs](https://cmake.org/cmake/help/v2.8.12/cmake.html#module:GNUInstallDirs)
......
......@@ -52,9 +52,18 @@ IF(NOT (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC))
RETURN()
ENDIF()
GET_FILENAME_COMPONENT(GCC_DIRNAME ${CMAKE_C_COMPILER} DIRECTORY)
foreach(arg ${CMAKE_C_COMPILER_ARG1} ${CMAKE_C_COMPILER_ARG2} ${CMAKE_C_COMPILER_ARG3} ${CMAKE_C_COMPILER_ARG4} ${CMAKE_C_COMPILER_ARG5} ${CMAKE_C_COMPILER_ARG6} ${CMAKE_C_COMPILER_ARG7} ${CMAKE_C_COMPILER_ARG8} ${CMAKE_C_COMPILER_ARG9})
string(STRIP ${arg} arg)
set(gcc_args "${gcc_args};${arg}")
endforeach()
EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} --print-libgcc-file-name OUTPUT_VARIABLE LIBGCC_FILE OUTPUT_STRIP_TRAILING_WHITESPACE)
EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} ${gcc_args} --print-prog-name=gcc OUTPUT_VARIABLE GCC_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND sh -c "command -v ${GCC_EXECUTABLE}" OUTPUT_VARIABLE GCC_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE)
GET_FILENAME_COMPONENT(GCC_DIRNAME ${GCC_EXECUTABLE} DIRECTORY)
EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} ${gcc_args} --print-libgcc-file-name OUTPUT_VARIABLE LIBGCC_FILE OUTPUT_STRIP_TRAILING_WHITESPACE)
GET_FILENAME_COMPONENT(LIBGCC_DIRNAME ${LIBGCC_FILE} DIRECTORY)
......
......@@ -9,6 +9,10 @@ find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-g++)
SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX} /usr/${COMPILER_PREFIX}/sys-root/mingw)
if(CMAKE_PREFIX_PATH)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CMAKE_PREFIX_PATH})
endif()
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment too
......
......@@ -9,6 +9,10 @@ find_program(CMAKE_CXX_COMPILER NAMES ${COMPILER_PREFIX}-g++)
SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX} /usr/${COMPILER_PREFIX}/sys-root/mingw)
if(CMAKE_PREFIX_PATH)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CMAKE_PREFIX_PATH})
endif()
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment too
......
......@@ -159,6 +159,8 @@ linux_installdeps() {
archlinux_installdeps
elif [ -f /etc/solus-release ]; then
solus_installdeps
elif path_exists /etc/os-release && [ "$(. /etc/os-release; puts "$ID_LIKE")" = suse ]; then
suse_installdeps
else
error "Don't know how to install deps on your version of Linux"
fi
......@@ -488,6 +490,16 @@ fedora_installdeps() {
build_instructions
}
suse_installdeps() {
check_cross
installing
check sudo zypper in -y gcc gcc-c++ binutils make cmake nasm ffmpeg2-devel gettext-tools libpng16-devel \
pkg-config libSDL2-devel sfml2-devel wxWidgets-3_0-devel
build_instructions
}
archlinux_require_yaourt() {
if ! command -v yaourt >/dev/null; then
(
......
......@@ -31,7 +31,7 @@ if(ENABLE_OPENAL)
FIND_PACKAGE(OpenAL REQUIRED)
INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
IF(WIN32 AND ((NOT (MINGW AND MSYS)) OR CMAKE_TOOLCHAIN_FILE MATCHES mxe))
IF(OPENAL_STATIC OR (WIN32 AND ((NOT (MINGW AND MSYS)) OR CMAKE_TOOLCHAIN_FILE MATCHES mxe)))
ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC)
ENDIF()
else(ENABLE_OPENAL)
......@@ -42,6 +42,33 @@ IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(wxWidgets_USE_DEBUG ON) # noop if wx is compiled with --disable-debug, like in Mac Homebrew atm
ENDIF()
# on e.g. msys2 add a couple of libraries wx needs
#if(WIN32 AND (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang))
# set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -luuid -lwinspool")
#endif()
# convert msys paths like /c/foo to windows paths like c:/foo
# for variables set by FindWxWidgets
function(normalize_wx_paths)
if(MSYS)
unset(new_paths)
foreach(p ${wxWidgets_LIBRARY_DIRS})
execute_process(COMMAND cygpath -m "${p}" OUTPUT_VARIABLE p_win OUTPUT_STRIP_TRAILING_WHITESPACE)
list(APPEND new_paths "${p_win}")
endforeach()
set(wxWidgets_LIBRARY_DIRS ${new_paths} PARENT_SCOPE)
string(REGEX REPLACE "((^| )[^/]*)/([a-zA-Z])/" "\\1\\3:/" new_libs "${wxWidgets_LIBRARIES}")
set(wxWidgets_LIBRARIES ${new_libs} PARENT_SCOPE)
endif()
endfunction()
if(CMAKE_PREFIX_PATH)
set(wxWidgets_CONFIG_OPTIONS "--prefix=${CMAKE_PREFIX_PATH}")
endif()
SET(wxWidgets_USE_UNICODE ON)
# adv is for wxAboutBox
# xml, html is for xrc
......@@ -51,6 +78,7 @@ SET(wxWidgets_USE_LIBS xrc xml html adv gl net core base gl)
# the gl lib may not be available, and if it looks like it is we still have to
# do a compile test later
FIND_PACKAGE(wxWidgets QUIET)
normalize_wx_paths()
SET(CHECK_WX_OPENGL FALSE)
......@@ -116,6 +144,7 @@ IF(NOT WX_HAS_OPENGL)
ADD_DEFINITIONS(-DNO_OGL)
LIST(REMOVE_ITEM wxWidgets_USE_LIBS gl)
FIND_PACKAGE(wxWidgets REQUIRED)
normalize_wx_paths()
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CROSSCOMPILING)
......@@ -268,8 +297,19 @@ IF(NOT WIN32 AND NOT APPLE)
SET(WX_CONFIG_H "${WX_CONFIG_H}/wx/config.h")
INCLUDE(CheckCXXSymbolExists)
CHECK_CXX_SYMBOL_EXISTS(__WXGTK4__ ${WX_CONFIG_H} WX_USING_GTK4)
CHECK_CXX_SYMBOL_EXISTS(__WXGTK3__ ${WX_CONFIG_H} WX_USING_GTK3)
IF(WX_USING_GTK3)
IF(WX_USING_GTK4)
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK4 REQUIRED gtk+-4.0)
IF(NOT GTK4_INCLUDE_DIRS)
MESSAGE(FATAL_ERROR "Could not find gtk4")
ENDIF()
INCLUDE_DIRECTORIES(${GTK4_INCLUDE_DIRS})
LINK_DIRECTORIES(${GTK4_LIBRARY_DIRS})
ADD_COMPILE_OPTIONS(${GTK4_CFLAGS_OTHER})
SET(GTK_LIBRARIES ${GTK4_LIBRARIES})
ELSEIF(WX_USING_GTK3)
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
IF(NOT GTK3_INCLUDE_DIRS)
......@@ -367,10 +407,17 @@ INCLUDE(HostCompile)
HOST_COMPILE(${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c ${BIN2C})
if(WXRC)
separate_arguments(WXRC UNIX_COMMAND "${WXRC}")
else()
set(WXRC wxrc)
endif()
ADD_CUSTOM_COMMAND(OUTPUT wxvbam.xrs
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND wxrc ${XRC_SOURCES} -o wxvbam.xrs
COMMAND ${WXRC} ${XRC_SOURCES} "--output=wxvbam.xrs"
DEPENDS ${XRC_SOURCES})
ADD_CUSTOM_COMMAND(OUTPUT builtin-xrc.h
COMMAND ${BIN2C} wxvbam.xrs builtin-xrc.h builtin_xrs
DEPENDS wxvbam.xrs)
......@@ -520,12 +567,39 @@ if(ENABLE_FFMPEG)
visualboyadvance-m
PROPERTIES LINK_FLAGS ${FFMPEG_LDFLAGS_STR}
)
endif(ENABLE_FFMPEG)
# Build a console app in debug mode on Windows
IF(WIN32 AND CMAKE_BUILD_TYPE STREQUAL Debug)
SET(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -Wl,--subsystem,console")
ENDIF()
endif()
# link libgcc/libstdc++ statically on mingw
# and adjust link command when making a static binary
if(CMAKE_COMPILER_IS_GNUCXX)
if(WIN32)
# Build a console app in debug mode on Windows
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -Wl,--subsystem,console")
else()
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -Wl,--subsystem,windows")
endif()
endif()
if(VBAM_STATIC)
# some dists don't have a static libpthread
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread ")
if(WIN32)
add_custom_command(
TARGET visualboyadvance-m PRE_LINK
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/msys-link-static.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
else()
add_custom_command(
TARGET visualboyadvance-m PRE_LINK
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/link-static.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endif()
endif()
endif()
IF(WIN32)
INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/visualboyadvance-m${CMAKE_EXECUTABLE_SUFFIX} DESTINATION ${CMAKE_BINARY_DIR})
......
......@@ -2536,8 +2536,8 @@ void MainFrame::MenuOptionIntRadioValue(const char* menuName, int& field, int va
// app-specific volume controls.
#ifdef __WXMSW__
#include <Windows.h>
#include <CommCtrl.h>
#include <windows.h>
#include <commctrl.h>
#include <wx/msw/private.h>
typedef int (WINAPI *func_LoadIconWithScaleDown)(HINSTANCE, LPCWSTR, int, int, HICON*);
#endif
......
file(READ CMakeFiles/visualboyadvance-m.dir/link.txt link_cmd)
string(REGEX REPLACE "-l(z|expat|X[^ ]+|xcb[^ ]*) " "-Wl,--whole-archive -l\\1 -Wl,--no-whole-archive " link_cmd ${link_cmd})
file(WRITE CMakeFiles/visualboyadvance-m.dir/link.txt ${link_cmd})
file(READ CMakeFiles/visualboyadvance-m.dir/linklibs.rsp link_libs)
string(REPLACE "-Wl,-Bdynamic" "" link_libs ${link_libs})
file(WRITE CMakeFiles/visualboyadvance-m.dir/linklibs.rsp ${link_libs})
This diff is collapsed.
#!/bin/sh
set -e
[ -n "$BUILD_ENV" ] && eval "$BUILD_ENV"
BUILD_ENV=$BUILD_ENV$(cat <<EOF
export CFLAGS="$CFLAGS -static-libgcc -static-libstdc++ -static -lpthread"
export CXXFLAGS="$CXXFLAGS -static-libgcc -static-libstdc++ -static -lpthread"
export LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++ -static -lpthread"
EOF
)
. "$(dirname "$0")/../builder/core.sh"
# make separate roots for target and host for cross compiling
if [ ! -L "$BUILD_ROOT/root" ]; then
mv "$BUILD_ROOT/root" "$BUILD_ROOT/target"
mkdir "$BUILD_ROOT/host"
ln -sf "$BUILD_ROOT/target" "$BUILD_ROOT/root"
cp -a "$BUILD_ROOT/target/"* "$BUILD_ROOT/host"
# share these for both roots
for d in perl5 share etc man doc; do
rmdir "$BUILD_ROOT/host/$d"
ln -s "$BUILD_ROOT/target/$d" "$BUILD_ROOT/host/$d"
done
mkdir "$BUILD_ROOT/host/bin" "$BUILD_ROOT/target/bin"
fi
ln -sf "$BUILD_ROOT/target" "$BUILD_ROOT/root"
perl_dists="$perl_dists XML-NamespaceSupport XML-SAX-Base XML-SAX"
host_dists="$host_dists m4 gsed bison flex-2.6.3 flex docbook2x"
both_dists="$both_dists openssl zlib bzip2 libiconv"
set_host_env() {
rm -f "$BUILD_ROOT/root"
ln -sf "$BUILD_ROOT/host" "$BUILD_ROOT/root"
if [ -z "$OCC" ]; then
OCC=$CC
OCXX=$CXX
export CC='ccache gcc'
export CXX='ccache g++'
OCFLAGS=$CFLAGS OCXXFLAGS=$CXXFLAGS OLDFLAGS=$LDFLAGS
CFLAGS=$( puts "$CFLAGS" | sed 's/ -static-libgcc -static-libstdc++ -static -lpthread//g')
CXXFLAGS=$(puts "$CXXFLAGS" | sed 's/ -static-libgcc -static-libstdc++ -static -lpthread//g')
LDFLAGS=$( puts "$LDFLAGS" | sed 's/ -static-libgcc -static-libstdc++ -static -lpthread//g')
OREQUIRED_CONFIGURE_ARGS=$REQUIRED_CONFIGURE_ARGS
OREQUIRED_CMAKE_ARGS=$REQUIRED_CMAKE_ARGS
REQUIRED_CONFIGURE_ARGS=$(puts "$REQUIRED_CONFIGURE_ARGS" | sed 's/--host[^ ]*//g')
REQUIRED_CMAKE_ARGS=$(puts "$REQUIRED_CMAKE_ARGS" | sed 's/-DCMAKE_TOOLCHAIN_FILE=[^ ]*//g')
fi
}
unset_host_env() {
rm -f "$BUILD_ROOT/root"
ln -sf "$BUILD_ROOT/target" "$BUILD_ROOT/root"
if [ -n "$OCC" ]; then
export CC="$OCC"
export CXX="$OCXX"
OCC= OCXX=
export CFLAGS="$OCFLAGS"
export CXXFLAGS="$OCXXFLAGS"
export LDFLAGS="$OLDFLAGS"
OCFLAGS= OCXXFLAGS= OLDFLAGS=
REQUIRED_CONFIGURE_ARGS=$OREQUIRED_CONFIGURE_ARGS
REQUIRED_CMAKE_ARGS=$OREQUIRED_CMAKE_ARGS
OREQUIRED_CONFIGURE_ARGS=
OREQUIRED_CMAKE_ARGS=
fi
# make links to executables in the target as well
IFS=$NL
for exe in $(find "$BUILD_ROOT/host/bin" -maxdepth 1 -type f); do
IFS=$OIFS
basename=${exe##*/}
if ! path_exists "$BUILD_ROOT/target/bin/$basename"; then
ln -s "$exe" "$BUILD_ROOT/target/bin/$basename";
fi
done
IFS=$OIFS
}
# replace install artifact paths with absolute paths into host and target trees
# so that the check for which dists are already built works correctly
pre_build_all() {
new_dists=
IFS=$NL
for dist in $DISTS; do
IFS=$OIFS
set -- $dist
case "$(table_line DIST_PRE_BUILD "$1")" in
*set_host_env*)
path="$BUILD_ROOT/host/$3"
;;
*)
path="$BUILD_ROOT/target/$3"
;;
esac
new_dists="$new_dists $1 $2 $path $NL"
done
IFS=$OIFS
DISTS=$new_dists
}
for dist in $host_dists $perl_dists; do
table_line_append DIST_PRE_BUILD $dist ':; set_host_env;'
table_line_replace DIST_POST_BUILD $dist "unset_host_env; $(table_line DIST_POST_BUILD $dist)"
done
for dist in $both_dists; do
duplicate_dist $dist "${dist}-target"
table_line_append DIST_PRE_BUILD $dist ':; set_host_env;'
table_line_replace DIST_POST_BUILD $dist "unset_host_env; $(table_line DIST_POST_BUILD $dist)"
done
remove_dists='graphviz python2 python3 swig libxml2-python doxygen bakefile setuptools pip meson XML-Parser intltool ninja libsecret shared-mime-info'
for dist in $remove_dists; do
if ! list_contains $dist $do_not_remove_dists; then
table_line_remove DISTS "$dist"
fi
done
table_insert_after DISTS libiconv-target '
catgets https://downloads.sourceforge.net/project/mingw/MinGW/Extension/catgets/mingw-catgets-1.0.1/mingw-catgets-1.0.1-src.tar.gz include/langinfo.h
'
table_line_append DIST_PATCHES catgets "\
https://gist.githubusercontent.com/rkitover/4fe26d4af9e20234ba7821100356b0a6/raw/715b89f23b0e13a5d1859bfeee600f43edd35c07/mingw-catgets-mc_realloc-and-langinfo.patch \
"
table_line_append DIST_POST_BUILD catgets ":; \
rm -f \$BUILD_ROOT/root/lib/libcatgets.dll.a \$BUILD_ROOT/root/bin/libcatgets.dll; \
"
table_line_append DIST_PATCHES libgd 'https://gist.githubusercontent.com/rkitover/c64ea5b83ddea94ace58c40c7de42879/raw/fbaf4885fbefb302116b56626c0e191df514e8c6/libgd-2.2.4-mingw-static.patch'
table_insert_before DISTS sfml '
openal http://kcat.strangesoft.net/openal-releases/openal-soft-1.18.2.tar.bz2 lib/libOpenAL32.a
'
table_line_append DIST_ARGS openal '-DLIBTYPE=STATIC -DALSOFT_UTILS=OFF -DALSOFT_EXAMPLES=OFF -DALSOFT_TESTS=OFF'
table_line_replace DIST_ARGS mp3lame "LDFLAGS='$LDFLAGS $BUILD_ROOT/root/lib/libcatgets.a'"
table_line_append DIST_POST_BUILD zlib-target ":; \
rm -f \$BUILD_ROOT/root/lib/libz.dll.a \$BUILD_ROOT/root/bin/libz.dll; \
"
table_line_replace DIST_CONFIGURE_TYPES zlib-target cmake
table_line_append DIST_ARGS zlib-target -DUNIX=1
table_line_remove DIST_CONFIGURE_OVERRIDES zlib-target
table_line_append DIST_POST_BUILD libgsm ":; \
rm -f \$BUILD_ROOT/root/lib/libgsm.dll.a \$BUILD_ROOT/root/bin/libgsm.dll; \
"
table_line_append DIST_POST_BUILD ffmpeg ":; \
sed -i.bak 's/-lSDL2main//g; s/-lstdc++//g; s/-lgcc_s//g; s/-lgcc//g; s/-lpthread//g' \$BUILD_ROOT/root/lib/pkgconfig/libav*.pc
"
table_line_append DIST_PRE_BUILD xvidcore ":; sed -i.bak 's/STATIC_LIB=\"xvidcore\\./STATIC_LIB=\"libxvidcore./; \
s/SHARED_LIB=\"xvidcore\\./SHARED_LIB=\"libxvidcore./' configure.in; \
"
table_line_replace DIST_CONFIGURE_TYPES xvidcore autoreconf
# this was my attempt to fix the problem with msys paths in the perl configs, but does not help
# so the doc dir is removed from expat
#table_line_append DIST_POST_CONFIGURE docbook2x ":; sed -i.bak 's,q</c/,q<c:/,; /xsltproc-program'\\''/{ s/\([a-z]\)>, *$/\1.exe>,/; }' perl/config.pl;"
table_line_append DIST_ARGS libsoxr '-DWITH_OPENMP=NO'
table_line_append DIST_ARGS ffmpeg "--extra-ldflags='-Wl,-allow-multiple-definition' --extra-libs='-lwsock32 -lws2_32 -liphlpapi -lfreetype'"
table_line_append DIST_ARGS gettext "--enable-threads=windows"
table_line_replace DISTS glib 'https://download.gnome.org/sources/glib/2.54/glib-2.54.1.tar.xz lib/libglib-2.0.a'
table_line_append DIST_PATCHES glib "\
http://src.fedoraproject.org/cgit/rpms/mingw-glib2.git/plain/0001-Use-CreateFile-on-Win32-to-make-sure-g_unlink-always.patch?id=f68d4a3ff32fb12f5d4467f4abfec6d2fb95b9fe \
http://src.fedoraproject.org/cgit/rpms/mingw-glib2.git/plain/0002-GNetworkMonitorBase-don-t-fail-when-IPv6-support-is-.patch?id=f68d4a3ff32fb12f5d4467f4abfec6d2fb95b9fe \
http://src.fedoraproject.org/cgit/rpms/mingw-glib2.git/plain/glib-include-time-h-for-localtime_r.patch?id=f68d4a3ff32fb12f5d4467f4abfec6d2fb95b9fe \
http://src.fedoraproject.org/cgit/rpms/mingw-glib2.git/plain/glib-prefer-constructors-over-DllMain.patch?id=f68d4a3ff32fb12f5d4467f4abfec6d2fb95b9fe \
"
table_line_append DIST_PATCHES graphite2 "\
https://raw.githubusercontent.com/Alexpux/MINGW-packages/master/mingw-w64-graphite2/001-graphite2-1.3.8-win64.patch \
"
table_line_append DIST_PATCHES libgsm "\
https://raw.githubusercontent.com/Alexpux/MINGW-packages/master/mingw-w64-gsm/0001-adapt-makefile-to.mingw.patch \
https://raw.githubusercontent.com/Alexpux/MINGW-packages/master/mingw-w64-gsm/0002-adapt-config-h-to.mingw.patch \
https://raw.githubusercontent.com/Alexpux/MINGW-packages/master/mingw-w64-gsm/0003-fix-ln.mingw.patch \
"
table_line_append DIST_PATCHES libtheora "\
http://src.fedoraproject.org/cgit/rpms/mingw-libtheora.git/plain/mingw-libtheora-1.1.1-rint.patch?id=a35cf93c3068ed4c8a59691a3cf129766d875444 \
"
table_line_append DIST_PRE_BUILD wxwidgets ":; \
if path_exists $BUILD_ROOT/root/include/langinfo.h; then \
mv $BUILD_ROOT/root/include/langinfo.h $BUILD_ROOT/root/include/langinfo.bak; \
fi;
"
table_line_append DIST_POST_BUILD wxwidgets ":; \
if path_exists $BUILD_ROOT/root/include/langinfo.bak; then \
mv $BUILD_ROOT/root/include/langinfo.bak $BUILD_ROOT/root/include/langinfo.h; \
fi;
"
set -e
: ${BUILD_ROOT:=$HOME/vbam-build-unix}
BUILD_ENV=$BUILD_ENV$(cat <<EOF
export LDFLAGS="$LDFLAGS -Wl,--start-group -ldl"
EOF
)
eval "$BUILD_ENV"
. "$(dirname "$0")/../builder/core.sh"
# on mac openal is part of the system, on most unixes we need openal-soft
table_insert_before DISTS sfml '
openal http://kcat.strangesoft.net/openal-releases/openal-soft-1.18.2.tar.bz2 lib/libopenal.a
'
XORG_DISTS="xproto xcb-proto inputproto kbproto xextproto renderproto
randrproto glproto dri2proto dri3proto damageproto fixesproto recordproto
xf86vidmodeproto libpthread-stubs xtrans libXau libxcb libX11 libXext
libXrender libXrandr libXfixes libXdamage libxshmfence libXi libXtst
libXxf86vm"
# have to build a large chunk of X11 on *nix
table_insert_before DISTS sfml '
xproto https://www.x.org/archive/individual/proto/xproto-7.0.31.tar.bz2 include/X11/X.h
xcb-proto https://www.x.org/archive/individual/xcb/xcb-proto-1.12.tar.bz2 lib/pkgconfig/xcb-proto.pc
inputproto https://www.x.org/archive/individual/proto/inputproto-2.3.2.tar.bz2 include/X11/extensions/XI.h
kbproto https://www.x.org/archive/individual/proto/kbproto-1.0.7.tar.bz2 include/X11/extensions/XKBsrv.h
xextproto https://www.x.org/archive/individual/proto/xextproto-7.3.0.tar.bz2 include/X11/extensions/shmproto.h
renderproto https://www.x.org/archive/individual/proto/renderproto-0.11.tar.bz2 lib/pkgconfig/renderproto.pc
randrproto https://www.x.org/archive/individual/proto/randrproto-1.5.0.tar.bz2 lib/pkgconfig/randrproto.pc
glproto https://www.x.org/releases/individual/proto/glproto-1.4.17.tar.bz2 lib/pkgconfig/glproto.pc
dri2proto https://www.x.org/archive/individual/proto/dri2proto-2.8.tar.bz2 lib/pkgconfig/dri2proto.pc
dri3proto https://www.x.org/archive/individual/proto/dri3proto-1.0.tar.bz2 lib/pkgconfig/dri3proto.pc
damageproto https://www.x.org/archive//individual/proto/damageproto-1.2.1.tar.bz2 lib/pkgconfig/damageproto.pc
fixesproto https://www.x.org/archive//individual/proto/fixesproto-5.0.tar.bz2 lib/pkgconfig/fixesproto.pc
recordproto https://www.x.org/archive//individual/proto/recordproto-1.14.2.tar.bz2 lib/pkgconfig/recordproto.pc
xf86vidmodeproto https://www.x.org/archive//individual/proto/xf86vidmodeproto-2.3.1.tar.bz2 lib/pkgconfig/xf86vidmodeproto.pc
libpthread-stubs https://www.x.org/archive/individual/xcb/libpthread-stubs-0.4.tar.bz2 lib/pkgconfig/pthread-stubs.pc
xtrans https://www.x.org/archive/individual/lib/xtrans-1.3.5.tar.bz2 include/X11/Xtrans/Xtrans.h
libXau https://www.x.org/archive/individual/lib/libXau-1.0.8.tar.bz2 lib/libXau.so
libxcb https://www.x.org/archive/individual/xcb/libxcb-1.12.tar.bz2 lib/libxcb.so
libX11 https://www.x.org/archive/individual/lib/libX11-1.6.5.tar.bz2 lib/libX11.so
libXext https://www.x.org/archive/individual/lib/libXext-1.3.3.tar.bz2 lib/libXext.so
libXrender https://www.x.org/archive/individual/lib/libXrender-0.9.10.tar.bz2 lib/libXrender.so
libXrandr https://www.x.org/archive/individual/lib/libXrandr-1.5.1.tar.bz2 lib/libXrandr.so
libXfixes https://www.x.org/archive//individual/lib/libXfixes-5.0.3.tar.bz2 lib/libXfixes.so
libXdamage https://www.x.org/archive//individual/lib/libXdamage-1.1.4.tar.bz2 lib/libXdamage.so
libxshmfence https://www.x.org/archive//individual/lib/libxshmfence-1.2.tar.bz2 lib/libxshmfence.so
libXi https://www.x.org/archive//individual/lib/libXi-1.7.9.tar.bz2 lib/libXi.so
libXtst https://www.x.org/archive//individual/lib/libXtst-1.2.3.tar.bz2 lib/libXtst.so
libXxf86vm https://www.x.org/archive//individual/lib/libXxf86vm-1.1.4.tar.bz2 lib/libXxf86vm.so
'
# we build and link Xorg libs as dynamic because there is no point in making
# them static, since they are required for the resulting binary to run
for dist in $XORG_DISTS; do
table_line_append DIST_ARGS $dist '--enable-shared --disable-static'
done
# and Wayland now that that's a thing
table_insert_before DISTS sfml '
wayland https://wayland.freedesktop.org/releases/wayland-1.14.0.tar.xz lib/libwayland-client.so
wayland-protocols https://wayland.freedesktop.org/releases/wayland-protocols-1.11.tar.xz share/pkgconfig/wayland-protocols.pc
'
# no reason to link wayland core static, since we still depend on wayland-egl from mesa
table_line_append DIST_ARGS wayland --enable-shared --disable-static
# and mesa OpenGL (the Gallium drivers in mesa require llvm)
table_insert_before DISTS sfml '
libpciaccess https://www.x.org/archive//individual/lib/libpciaccess-0.14.tar.bz2 lib/libpciaccess.a
libdrm https://dri.freedesktop.org/libdrm/libdrm-2.4.88.tar.bz2 lib/libdrm.a
# llvm http://releases.llvm.org/5.0.0/llvm-5.0.0.src.tar.xz lib/libLLVMCore.a
libelf http://www.mr511.de/software/libelf-0.8.13.tar.gz lib/libelf.a
mesa https://mesa.freedesktop.org/archive/mesa-17.3.0-rc5.tar.xz lib/libGL.so
glu ftp://ftp.freedesktop.org/pub/mesa/glu/glu-9.0.0.tar.bz2 lib/libGLU.a
freeglut https://downloads.sourceforge.net/project/freeglut/freeglut/3.0.0/freeglut-3.0.0.tar.gz lib/libglut.a
'
# and need GTK with all deps for wx
table_insert_before DISTS wxwidgets '
pixman https://www.cairographics.org/releases/pixman-0.34.0.tar.gz lib/libpixman-1.a
cairo http://cairographics.org/snapshots/cairo-1.15.8.tar.xz lib/libcairo.a
libepoxy https://github.com/anholt/libepoxy/releases/download/1.4.3/libepoxy-1.4.3.tar.xz lib/libepoxy.a
gdk-pixbuf https://download.gnome.org/sources/gdk-pixbuf/2.36/gdk-pixbuf-2.36.11.tar.xz lib/libgdk_pixbuf-2.0.a
pango https://download.gnome.org/sources/pango/1.40/pango-1.40.14.tar.xz lib/libpango-1.0.a
atk https://download.gnome.org/sources/atk/2.27/atk-2.27.1.tar.xz lib/libatk-1.0.a
dbus https://dbus.freedesktop.org/releases/dbus/dbus-1.12.2.tar.gz lib/libdbus-1.a
gtk-doc https://github.com/GNOME/gtk-doc/archive/GTK_DOC_1_26.tar.gz bin/gtkdocize
gobject-introspection https://download.gnome.org/sources/gobject-introspection/1.55/gobject-introspection-1.55.0.tar.xz share/aclocal/introspection.m4
at-spi2-core http://ftp.gnome.org/pub/GNOME/sources/at-spi2-core/2.27/at-spi2-core-2.27.1.tar.xz lib/libatspi.a
at-spi2-atk http://ftp.gnome.org/pub/GNOME/sources/at-spi2-atk/2.26/at-spi2-atk-2.26.1.tar.xz lib/libatk-bridge-2.0.a
libxkbcommon https://xkbcommon.org/download/libxkbcommon-0.7.2.tar.xz lib/libxkbcommon.a
graphene https://github.com/ebassi/graphene/archive/1.6.0.tar.gz lib/libgraphene-1.0.a
gtk+3 https://download.gnome.org/sources/gtk+/3.22/gtk+-3.22.28.tar.xz lib/libgtk-3.a
# gtk+4 https://download.gnome.org/sources/gtk+/3.92/gtk+-3.92.1.tar.xz lib/libgtk-4.a
'
table_line_replace DIST_CONFIGURE_TYPES libepoxy autoconf
table_line_replace DIST_CONFIGURE_TYPES gdk-pixbuf autoconf
table_line_replace DIST_CONFIGURE_TYPES pango autoconf
table_line_replace DIST_CONFIGURE_TYPES atk autoconf
table_line_replace DIST_CONFIGURE_TYPES at-spi2-atk autoconf
table_line_replace DIST_CONFIGURE_TYPES libxkbcommon autoconf
table_line_replace DIST_CONFIGURE_TYPES graphene autoconf
table_line_append DIST_PATCHES freeglut 'https://gist.githubusercontent.com/rkitover/e6d6af234c6a5cea05a7943dba7ab76f/raw/4ba4305d55d56140e90e0761f46e4b73a40e304d/freeglut-3.0.0-static-X11.patch'
table_line_append DIST_ARGS libdrm '--disable-cairo-tests'
table_line_append DIST_ARGS freeglut '-DFREEGLUT_BUILD_SHARED_LIBS=NO -DFREEGLUT_BUILD_STATIC_LIBS=YES'
table_line_append DIST_ARGS gtk-doc "--with-xml-catalog='$BUILD_ROOT/root/etc/xml/catalog.xml'"
table_line_append DIST_POST_BUILD gtk-doc ":; sed -i.bak 's|^prefix=/usr$|prefix=$BUILD_ROOT/root|' $BUILD_ROOT/root/bin/gtkdocize"
table_line_replace DIST_BUILD_OVERRIDES gobject-introspection ':; cp m4/introspection.m4 "$BUILD_ROOT/root/share/aclocal";'
table_line_append DIST_ARGS gdk-pixbuf '--disable-modules --with-included-loaders=yes'
table_line_append DIST_PRE_BUILD gtk+4 ':; sed -i.bak '"\"s/'-Werror[^']*',//g; s/shared_library(/library(/g\""' $(find . -name meson.build)'
table_line_append DIST_ARGS gtk+4 '-Dintrospection=false -Denable-x11-backend=true -Denable-wayland-backend=true -Ddemos=false -Dbuild-tests=false -Dinstall-tests=false -Ddisable-modules=true -Dwith-included-immodules=all'
table_line_append DIST_PATCHES at-spi2-core "\
https://gist.githubusercontent.com/rkitover/c46dc5523aab78b2e5fff6618fb0b943/raw/9dc00863e9c32a67e56738f732a89dd2ff957699/at-spi2-core-2.27.1-static.patch \