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.
This commit is contained in:
Rafael Kitover 2018-02-24 14:39:29 -05:00
parent 3e052c943d
commit 66980934b2
19 changed files with 3709 additions and 1290 deletions

File diff suppressed because it is too large Load Diff

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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
(

View File

@ -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)
endif()
# 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()
# 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})

View File

@ -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

5
src/wx/link-static.cmake Normal file
View File

@ -0,0 +1,5 @@
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})

View File

@ -0,0 +1,5 @@
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})

2463
tools/builder/core.sh Normal file

File diff suppressed because it is too large Load Diff

230
tools/builder/mingw.sh Normal file
View File

@ -0,0 +1,230 @@
#!/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;
"

170
tools/builder/unix.sh Normal file
View File

@ -0,0 +1,170 @@
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 \
"
table_line_append DIST_EXTRA_LDFLAGS at-spi2-core '-Wl,--allow-multiple-definition -Wl,--as-needed -Wl,--start-group -lmount -lglib-2.0 -lgio-2.0 -lgmodule-2.0 -lgobject-2.0 -lpcre -lz -lffi -lpthread -lresolv -ldl -lintl -liconv -luuid -lblkid -lm -lutil -lbz2'
table_line_append DIST_EXTRA_LDFLAGS gtk+4 '-Wl,--allow-multiple-definition -Wl,--as-needed -Wl,--start-group -latspi -lexpat -lharfbuzz -lpixman-1 -lpng -ldbus-1 -lX11 -lX11-xcb -lxcb -lXau -lXext -lwayland-client -lmount -lglib-2.0 -lgio-2.0 -lgmodule-2.0 -lgobject-2.0 -lpcre -lz -lffi -lpthread -lresolv -ldl -lintl -liconv -luuid -lblkid -lm -lutil -lbz2'
table_line_replace DIST_CONFIGURE_TYPES gtk+3 autoreconf
table_line_append DIST_PRE_BUILD gtk+3 "\
sed -i.bak ' \
s/^\\(SRC_SUBDIRS = gdk gtk libgail-util\\).*/\\1/; \
s/^\\(SUBDIRS = .*\\) docs\\( .*\\)/\\1\\2/ \
' Makefile.am; \
sed -i.bak '/^pkg-config /,/^\$/d' autogen.sh
"
table_line_append DIST_ARGS gtk+3 '--disable-modules --enable-introspection=no --disable-cups'
table_line_append DIST_EXTRA_LDFLAGS gtk+3 '-Wl,--allow-multiple-definition -Wl,--as-needed -Wl,--start-group -latspi -lexpat -lharfbuzz -lpixman-1 -lpng -ldbus-1 -lX11 -lX11-xcb -lxcb -lXau -lXext -lwayland-client -lmount -lglib-2.0 -lgio-2.0 -lgmodule-2.0 -lgobject-2.0 -lpcre -lz -lffi -lpthread -lresolv -ldl -lintl -liconv -luuid -lblkid -lm -lutil -lbz2'
#table_line_append DIST_PRE_BUILD gtk+3 "sed -i.bak 's/^\\(SRC_SUBDIRS = gdk gtk libgail-util\\).*/\\1/; s/^\\(SUBDIRS = .*\\) docs\\( .*\\)/\\1\\2/' Makefile.am; sed -i.bak '/^bin_PROGRAMS =/,/^\$/d' gtk/Makefile.am;"
table_line_append DIST_CONFIGURE_OVERRIDES wxwidgets '--with-gtk=3'
table_line_append DIST_EXTRA_LIBS wxwidgets '-Wl,--allow-multiple-definition -Wl,--as-needed -Wl,--start-group -lfreetype -lfontconfig -lgtk-3 -latk-1.0 -latk-bridge-2.0 -lpangoft2-1.0 -latspi -lexpat -lharfbuzz -lpixman-1 -lpng -ldbus-1 -lX11 -lX11-xcb -lxcb -lXau -lXext -lXfixes -lXdamage -lXrandr -lXrender -lXi -lwayland-client -lwayland-cursor -lepoxy -lwayland-egl -lxkbcommon -lmount -lglib-2.0 -lgio-2.0 -lgmodule-2.0 -lgobject-2.0 -lpcre -lz -lffi -lpthread -lresolv -ldl -lintl -liconv -luuid -lblkid -lm -lutil -lbz2 -llzma -lrt'
#table_line_append DIST_ARGS gobject-introspection '--enable-shared --disable-static'
#table_line_append DIST_EXTRA_LIBS gobject-introspection '-Wl,--as-needed -Wl,--start-group -Wl,-lmount -Wl,-lglib-2.0 -Wl,-lgio-2.0 -Wl,-lgmodule-2.0 -Wl,-lgobject-2.0 -Wl,-lpcre -Wl,-lz -Wl,-lffi -Wl,-lpthread -Wl,-lresolv -Wl,-ldl -Wl,-lintl -Wl,-liconv -Wl,-luuid -Wl,-lblkid -Wl,-lm -Wl,-lutil -Wl,--end-group'
table_line_append DIST_ARGS mesa '--enable-shared --disable-static --with-gallium-drivers=no --with-dri-drivers=no --with-platforms=x11,surfaceless,drm,wayland'
table_line_append DIST_EXTRA_LIBS mesa '-Wl,--as-needed -Wl,--start-group -lexpat -lxcb -lxcb-dri3 -lxcb-dri2 -lxcb-present -lxcb-sync -lxcb-xfixes -lxshmfence -lX11-xcb -ldrm -ldrm_amdgpu -ldrm_intel -ldrm_nouveau -ldrm_radeon -lwayland-client -Wl,--end-group'
table_line_append DIST_EXTRA_LIBS cairo '-Wl,--start-group -lX11 -lXext -lXrender -lxcb -lXau -ldl -Wl,--end-group'
table_line_append DIST_ARGS openal '-DLIBTYPE=STATIC'
table_line_append DIST_MAKE_ARGS libvpx "AS='yasm -DPIC'"
table_line_append DIST_ARGS ffmpeg '--enable-pic'
table_line_append DIST_EXTRA_LDFLAGS ffmpeg '-lgomp'

45
tools/linux/builder Executable file
View File

@ -0,0 +1,45 @@
#!/bin/sh
set -e
: ${BUILD_ROOT:=$HOME/vbam-build-linux}
. "$(dirname "$0")/../builder/unix.sh"
table_line_append DIST_EXTRA_LIBS shared-mime-info '-Wl,--start-group -lmount -lblkid -luuid -Wl,--end-group'
table_line_append DIST_EXTRA_LDFLAGS ffmpeg -lunwind
table_insert_before DISTS autoconf '
libunwind http://download.savannah.nongnu.org/releases/libunwind/libunwind-1.2.tar.gz lib/libunwind.a
'
table_insert_before DISTS glib '
libcap https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.25.tar.xz lib/libcap.a
libudev https://github.com/systemd/systemd/archive/v237.tar.gz lib/libudev.a
util-linux https://www.kernel.org/pub/linux/utils/util-linux/v2.31/util-linux-2.31.tar.xz lib/libmount.a
'
table_line_append DIST_PATCHES libcap 'https://604802.bugs.gentoo.org/attachment.cgi?id=460354'
table_line_append DIST_EXTRA_LDFLAGS util-linux '-lintl -liconv'
table_line_append DIST_PATCHES libudev " \
https://gist.githubusercontent.com/rkitover/b639097f5c0304c5c4c66d19159fb9a2/raw/7c7bb75747c99fda2ed309c3337338279eff1527/systemd-237-static-libudev.patch \
"
table_line_append DIST_EXTRA_LDFLAGS libudev '-Wl,--allow-multiple-definition -Wl,--start-group -lglib-2.0 -lgio-2.0 -lgmodule-2.0 -lgobject-2.0 -lpcre -lz -lffi -lpthread -lresolv -ldl -lintl -liconv -luuid -Wl,--end-group'
table_line_append DIST_ARGS libudev '-Dlink-udev-shared=false'
table_line_append DIST_MAKE_ARGS libudev 'src/udev/libudev.a'
table_line_append DIST_INSTALL_OVERRIDES libudev " \
mkdir -p '$BUILD_ROOT/root/lib/pkgconfig'; \
mkdir -p '$BUILD_ROOT/root/include'; \
cp -a src/udev/libudev.a '$BUILD_ROOT/root/lib'; \
cp -a src/libudev/libudev.pc '$BUILD_ROOT/root/pkgconfig'; \
cp -a ../src/libudev/libudev.h '$BUILD_ROOT/root/include'; \
"
builder "$@"

View File

@ -2,578 +2,51 @@
set -e
BUILD_ROOT=$HOME/vbam-build
build_env() {
cat <<EOF
export MACOSX_DEPLOYMENT_TARGET=10.7
export CFLAGS="-I$BUILD_ROOT/root/include -L$BUILD_ROOT/root/lib -framework Carbon -Wno-unused-command-line-argument -arch x86_64"
export CPPFLAGS="-I$BUILD_ROOT/root/include"
export CXXFLAGS="-I$BUILD_ROOT/root/include -L$BUILD_ROOT/root/lib -std=c++11 -stdlib=libc++ -framework Carbon -Wno-unused-command-line-argument -arch x86_64"
export OBJCXXFLAGS="-I$BUILD_ROOT/root/include -L$BUILD_ROOT/root/lib -std=c++11 -stdlib=libc++ -framework Carbon -Wno-unused-command-line-argument -arch x86_64"
export LDFLAGS="-L$BUILD_ROOT/root/lib -framework Carbon -Wno-unused-command-line-argument -arch x86_64"
export CMAKE_PREFIX_PATH="$BUILD_ROOT/root"
export PKG_CONFIG_PATH="$BUILD_ROOT/root/lib/pkgconfig"
export PERL_MB_OPT='--install_base $BUILD_ROOT/root/perl5'
export PERL_MM_OPT='INSTALL_BASE=$BUILD_ROOT/root/perl5'
export PERL5LIB="$BUILD_ROOT/root/perl5/lib/perl5"
export PERL_LOCAL_LIB_ROOT="$BUILD_ROOT/root/perl5"
export PATH="$BUILD_ROOT/root/bin:$BUILD_ROOT/root/perl5/bin:$PATH"
EOF
}
eval "$(build_env)"
DISTS='
nasm http://www.nasm.us/pub/nasm/releasebuilds/2.13.01/nasm-2.13.01.tar.xz bin/nasm
yasm http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz bin/yasm
zlib https://zlib.net/zlib-1.2.11.tar.gz lib/libz.a
xz https://tukaani.org/xz/xz-5.2.3.tar.xz lib/liblzma.a
bzip2 http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz lib/libbz2.a
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
libiconv https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz lib/libiconv.a
gettext http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.1.tar.xz lib/libintl.a
glib http://mirror.umd.edu/gnome/sources/glib/2.54/glib-2.54.1.tar.xz lib/libglib-2.0.a
openssl https://www.openssl.org/source/openssl-1.0.2l.tar.gz lib/libssl.a
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://dl.maptools.org/dl/libtiff/tiff-3.8.2.tar.gz lib/libtiff.a
sdl2 https://www.libsdl.org/release/SDL2-2.0.6.tar.gz lib/libSDL2.a
sfml https://github.com/SFML/SFML/archive/2.4.2.tar.gz lib/libsfml-system-s.a
wxwidgets https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.3/wxWidgets-3.0.3.tar.bz2 lib/libwx_baseu-3.0.a
xvidcore http://downloads.xvid.org/downloads/xvidcore-1.3.4.tar.bz2 lib/libxvidcore.a
fribidi http://fribidi.org/download/fribidi-0.19.7.tar.bz2 lib/libfribidi.a
libass https://github.com/libass/libass/releases/download/0.13.7/libass-0.13.7.tar.xz lib/libass.a
libgsm http://www.quut.com/gsm/gsm-1.0.17.tar.gz lib/libgsm.a
libmodplug https://github.com/Konstanty/libmodplug/archive/5a39f5913d07ba3e61d8d5afdba00b70165da81d.tar.gz lib/libmodplug.a
libopencore-amrnb https://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.5.tar.gz lib/libopencore-amrnb.a
opus https://archive.mozilla.org/pub/opus/opus-1.2.1.tar.gz lib/libopus.a
snappy https://github.com/google/snappy/archive/1.1.7.tar.gz lib/libsnappy.a
libsoxr https://downloads.sourceforge.net/project/soxr/soxr-0.1.2-Source.tar.xz lib/libsoxr.a
speex http://downloads.us.xiph.org/releases/speex/speex-1.2.0.tar.gz lib/libspeex.a
libvorbis https://github.com/xiph/vorbis/archive/v1.3.5.tar.gz lib/libvorbis.a
libogg http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz lib/libogg.a
libtheora https://github.com/Distrotech/libtheora/archive/17b02c8c564475bb812e540b551219fc42b1f75f.tar.gz lib/libtheora.a
vidstab https://github.com/georgmartius/vid.stab/archive/v1.1.0.tar.gz lib/libvidstab.a
libvo-amrwbenc https://github.com/mstorsjo/vo-amrwbenc/archive/v0.1.3.tar.gz lib/libvo-amrwbenc.a
mp3lame https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz lib/libmp3lame.a
libxml2 ftp://xmlsoft.org/libxml2/libxml2-2.9.6.tar.gz lib/libxml2.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
XML-SAX https://cpan.metacpan.org/authors/id/G/GR/GRANTM/XML-SAX-0.99.tar.gz perl5/lib/perl5/XML/SAX.pm
docbook2x https://downloads.sourceforge.net/project/docbook2x/docbook2x/0.8.8/docbook2X-0.8.8.tar.gz bin/docbook2man
expat https://github.com/libexpat/libexpat/archive/R_2_2_4.tar.gz lib/libexpat.a
graphite2 https://github.com/silnrsi/graphite/releases/download/1.3.10/graphite2-1.3.10.tgz lib/libgraphite2.a
freetype http://download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.bz2 lib/libfreetype.a
harfbuzz https://www.freedesktop.org/software/harfbuzz/release/harfbuzz-1.6.0.tar.bz2 lib/libharfbuzz.a
fontconfig https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.6.tar.bz2 lib/libfontconfig.a
libbluray ftp://ftp.videolan.org/pub/videolan/libbluray/1.0.0/libbluray-1.0.0.tar.bz2 lib/libbluray.a
libvpx http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.6.1.tar.bz2 lib/libvpx.a
libwavpack http://www.wavpack.com/wavpack-5.1.0.tar.bz2 lib/libwavpack.a
libx264 ftp://ftp.videolan.org/pub/videolan/x264/snapshots/last_stable_x264.tar.bz2 lib/libx264.a
libx265 https://bitbucket.org/multicoreware/x265/downloads/x265_2.5.tar.gz lib/libx265.a
libxavs https://github.com/Distrotech/xavs/archive/distrotech-xavs-git.tar.gz lib/libxavs.a
libzmq https://github.com/zeromq/libzmq/releases/download/v4.2.2/zeromq-4.2.2.tar.gz lib/libzmq.a
# libzvbi https://downloads.sourceforge.net/project/zapping/zvbi/0.2.35/zvbi-0.2.35.tar.bz2 lib/libzvbi.a
ffmpeg http://ffmpeg.org/releases/ffmpeg-3.3.4.tar.xz lib/libavformat.a
'
CONFIGURE_ARGS="--disable-shared --enable-static --prefix=$BUILD_ROOT/root"
CMAKE_ARGS="-DBUILD_SHARED_LIBS=NO -DENABLE_SHARED=NO -DCMAKE_PREFIX_PATH=$BUILD_ROOT/root -DCMAKE_INSTALL_PREFIX=$BUILD_ROOT/root -DCMAKE_BUILD_TYPE=Release"
DIST_PATCHES='
docbook2x https://sourceforge.net/p/docbook2x/bugs/_discuss/thread/0cfa4055/f6a5/attachment/docbook2x.patch
graphite2 https://gist.githubusercontent.com/rkitover/418600634d7cf19e2bf1c3708b50c042/raw/b5e9ee6c237a588157a754de6705a56fc315b00a/graphite2-static.patch
'
DIST_PRE_BUILD="
expat cd expat; sed -i .bak 's/cp \\\$</mv \$</' doc/doc.mk
libmodplug sed -i .bak '/-mmacosx-version-min=/d' configure.ac; sed -i .bak 's/-lstdc++/-lc++/g' libmodplug.pc.in; rm -f configure
libzmq sed -i .bak 's/-lstdc++/-lc++/g' src/libzmq.pc.in
xvidcore cd build/generic; sed -i .bak '/^all:/{ s/ *\\\$(SHARED_LIB)//; }; /^install:/{ s, *\\\$(BUILD_DIR)/\\\$(SHARED_LIB),,; }; s/\\\$(INSTALL).*\\\$(SHARED_LIB).*/:/; s/\\\$(LN_S).*\\\$(SHARED_LIB).*/:/' Makefile
libx265 cd source
ffmpeg sed -i .bak 's/-lstdc++/-lc++/g' configure
"
DIST_POST_BUILD="
"
DIST_OVERRIDES="
zlib --static --prefix=$BUILD_ROOT/root
openssl darwin64-x86_64-cc no-shared --prefix=$BUILD_ROOT/root
"
DIST_ARGS="
pcre --enable-utf8 --enable-pcre8 --enable-pcre16 --enable-pcre32 --enable-unicode-properties --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-jit
libmodplug CC=clang++ CXX=clang++
freetype --with-harfbuzz=no
harfbuzz --with-cairo=no
libvpx --disable-unit-tests --disable-tools --disable-docs --disable-examples
libxavs --disable-asm
libzvbi --without-x --without-doxygen
libxml2 --without-python
wxwidgets --with-macosx-version-min=$MACOSX_DEPLOYMENT_TARGET --enable-stl LDFLAGS='$LDFLAGS -stdlib=libc++' --disable-precomp-headers
libbluray --disable-bdjava
libopencore-amrnb --disable-compile-c
vidstab -DUSE_OMP=NO
ffmpeg --extra-ldflags='-framework CoreText' --pkg-config-flags=--static --enable-nonfree --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-version3 --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-openssl --enable-lzma
#
# TODO: add these if possible (from brew) --enable-indev=qtkit --enable-securetransport --enable-chromaprint --enable-ffplay --enable-frei0r --enable-libbs2b --enable-libcaca --enable-libfdk-aac --enable-libgme --enable-libgsm --enable-librtmp --enable-librubberband --enable-libssh --enable-libtesseract --enable-libtwolame --enable-webp --enable-libzimg
#
# Possibly also: --enable-libzvbi
# I could not get libzvbi to build
#
# these require > 10.7:
# --enable-opencl # requires 10.8
# --enable-videotoolbox # requires 10.8
"
DIST_MAKE_ARGS="
expat DOCBOOK_TO_MAN=docbook2man
"
main() {
read_command_line "$@"
setup
delete_outdated_dists
download_dists
build_dists
build_project
}
read_command_line() {
case "$1" in
--env)
build_env
exit 0
;;
esac
}
setup() {
mkdir -p "$BUILD_ROOT/root/include"
[ -e "$BUILD_ROOT/root/inc" ] || ln -s "$BUILD_ROOT/root/include" "$BUILD_ROOT/root/inc"
DIST_NAMES=$( table_column 0 3 "$DISTS")
DIST_URLS=$( table_column 1 3 "$DISTS")
DIST_TARGETS=$(table_column 2 3 "$DISTS")
DISTS_NUM=$(table_rows "$DISTS")
NUM_CPUS=$(sysctl -n hw.ncpu)
CHECKOUT=$(find_checkout)
}
delete_outdated_dists() {
[ ! -d "$BUILD_ROOT/downloads" ] && return 0
files=
i=0
for dist in $DIST_NAMES; do
dist_url=$(list_get $i $DIST_URLS)
dist_file="$BUILD_ROOT/downloads/$dist-${dist_url##*/}"
files="$files $dist_file"
i=$((i + 1))
done
OLDIFS=$IFS
IFS='
'; find "$BUILD_ROOT/downloads" -type f -maxdepth 1 -not -name '.*' | \
while read -r file; do
IFS=$OLDIFS
if ! list_contains "$file" $files; then
echo "\nDeleting outdated dist: $file\n"
rm -f "$file"
fi
done
IFS=$OLDIFS
}
download_dists() {
mkdir -p "$BUILD_ROOT/downloads"
i=0
while [ $i -lt $DISTS_NUM ]; do
dist_name=$(list_get $i $DIST_NAMES)
dist_url=$( list_get $i $DIST_URLS)
orig_dist_file="$BUILD_ROOT/downloads/${dist_url##*/}"
dist_file="$BUILD_ROOT/downloads/$dist_name-${dist_url##*/}"
dist_dir="$BUILD_ROOT/dists/$dist_name"
cd "$BUILD_ROOT/downloads"
if [ ! -e "$dist_file" ]; then
echo "\nFetching $dist_name: $dist_url\n"
curl -LO "$dist_url"
mv -f "$orig_dist_file" "$dist_file"
# force rebuild for new dist file
rm -f "$BUILD_ROOT/root/$(list_get $i $DIST_TARGETS)"
rm -rf "$dist_dir"
fi
if [ ! -d "$dist_dir" ]; then
mkdir -p "$dist_dir"
tmp_dir="$BUILD_ROOT/dists/tmp"
mkdir -p "$tmp_dir"
cd "$tmp_dir"
case "$dist_file" in
*.tar)
tar xf "$dist_file"
;;
*.tar.gz|*.tgz)
tar zxf "$dist_file"
;;
*.tar.xz)
xzcat "$dist_file" | tar xf -
;;
*.tar.bz2)
bzcat "$dist_file" | tar xf -
;;
*.zip)
unzip -q "$dist_file"
;;
esac
mv */* "$dist_dir"
rm -rf "$tmp_dir"
# force rebuild if dist dir was deleted
rm -f "$BUILD_ROOT/root/$(list_get $i $DIST_TARGETS)"
fi
i=$((i + 1))
done
}
build_dists() {
i=0
while [ $i -lt $DISTS_NUM ]; do
install_artifact="$BUILD_ROOT/root/$(list_get $i $DIST_TARGETS)"
if [ ! -e "$install_artifact" ]; then
build_dist $(list_get $i $DIST_NAMES)
fi
i=$((i + 1))
done
}
build_dist() {
dist=$1
[ -n "$1" ] || error 'build_dist: dist name required'
shift
extra_dist_args=$@
cd "$BUILD_ROOT/dists/$dist"
echo "\nBuilding $dist\n"
ORIG_LDFLAGS=$LDFLAGS
# have to make sure C++ flags are passed when linking, but only for C++ and **NOT** C
# this fails if there are any .c files in the project
if [ "$(find . -name '*.cpp' -o -name '*.cc' | wc -l)" -ne 0 -a "$(find . -name '*.c' | wc -l)" -eq 0 ]; then
export LDFLAGS="$CXXFLAGS $LDFLAGS"
fi
dist_patch "$dist"
dist_pre_build "$dist"
if [ -e configure -o -e configure.ac -o -e configure.in -o -e Makefile.am ]; then
if [ ! -e configure ]; then
if [ -e autogen.sh ]; then
sh autogen.sh
elif [ -e buildconf.sh ]; then
sh buildconf.sh
# bash 3 does not work for this code
if [ -z "$IN_DASH" ]; then
if command -v dash >/dev/null; then
export IN_DASH=1
exec dash "$0" "$@"
else
if [ -d m4 ]; then
aclocal -I m4
else
aclocal
fi
if command -v glibtoolize >/dev/null; then
glibtoolize
else
libtoolize
fi
autoheader || :
autoconf
[ -e Makefile.am ] && automake --add-missing
fi
fi
eval "set -- $(dist_args "$dist" autoconf) $extra_dist_args"
./configure "$@"
eval "set -- $(dist_make_args "$dist")"
make -j$NUM_CPUS "$@"
make install prefix=$BUILD_ROOT/root
elif [ -e CMakeLists.txt ]; then
mkdir -p build
cd build
eval "set -- $(dist_args "$dist" cmake) $extra_dist_args"
cmake .. "$@"
eval "set -- $(dist_make_args "$dist")"
make -j$NUM_CPUS "$@"
rm -rf destdir
mkdir destdir
make install DESTDIR="$PWD/destdir"
cd "destdir/$BUILD_ROOT/root"
OLDPWD=$PWD
find . ! -type d | (cd "$BUILD_ROOT/root";IFS='
'; while read f; do
mkdir -p "${f%/*}"
cp -a "$OLDPWD/$f" "$f"
done)
elif [ -e Makefile.PL ]; then
eval "set -- $(dist_args "$dist" perl) $extra_dist_args"
perl Makefile.PL "$@"
eval "set -- $(dist_make_args "$dist")"
make -j$NUM_CPUS "$@"
make install
elif [ -e Makefile ]; then
eval "set -- $(dist_make_args "$dist")"
make -j$NUM_CPUS "$@"
make install PREFIX="$BUILD_ROOT/root" INSTALL_ROOT="$BUILD_ROOT/root"
else
error "don't know how to build $dist"
fi
dist_post_build "$dist"
export LDFLAGS=$ORIG_LDFLAGS
echo "\nDone!!!\n"
}
list_get() {
i=0
n=${1:=0}
shift
for item; do
if [ $i -eq $n ]; then
echo "$item"
return 0
fi
i=$((i + 1))
done
}
dist_args() {
dist=$1
[ -n "$dist" ] || error 'dist_args: dist name required'
buildsys=$2
case "$buildsys" in
autoconf|cmake|perl)
;;
*)
error "dist_args: buildsystem type required, must be 'autoconf', 'cmake' or 'perl'"
;;
esac
args=$(table_line "$dist" "$DIST_OVERRIDES")
if [ -z "$args" ]; then
case "$buildsys" in
autoconf)
args="$CONFIGURE_ARGS $(table_line "$dist" "$DIST_ARGS")"
;;
cmake)
args="$CMAKE_ARGS $(table_line "$dist" "$DIST_ARGS")"
;;
perl)
args="$(table_line "$dist" "$DIST_ARGS")"
;;
esac
fi
echo "$args"
return 0
}
dist_make_args() {
dist=$1
[ -n "$dist" ] || error 'dist_make_args: dist name required'
echo "$(table_line "$dist" "$DIST_MAKE_ARGS")"
return 0
}
dist_patch() {
[ -n "$1" ] || error 'dist_patch: dist name required'
_patch_url="$(table_line "$1" "$DIST_PATCHES")"
[ -n "$_patch_url" ] || return 0
echo "\nApplying patch $_patch_url to $1\n"
curl -LO "$_patch_url"
patch -p1 < "${_patch_url##*/}"
echo "\nDone!!!\n"
}
dist_pre_build() {
[ -n "$1" ] || error 'dist_pre_build: dist name required'
_cmd=$(table_line "$1" "$DIST_PRE_BUILD")
[ -n "$_cmd" ] || return 0
echo "\nRunning pre-build for: $dist:\n$_cmd\n"
eval "$_cmd"
}
dist_post_build() {
[ -n "$1" ] || error 'dist_post_build: dist name required'
_cmd=$(table_line "$1" "$DIST_POST_BUILD")
[ -n "$_cmd" ] || return 0
if [ -z "$IN_DIST_POST_BUILD" ]; then
IN_DIST_POST_BUILD=1
echo "\nRunning post-build for: $dist:\n$_cmd\n"
eval "$_cmd"
IN_DIST_POST_BUILD=
fi
}
table_line() {
name=$1
[ -n "$name" ] || error 'item name required'
table=$2
[ -n "$table" ] || error 'table string required'
table=$(echo "$table" | grep -Ev '^ *#')
OLDIFS=$IFS
IFS='
'
for line in $table; do
IFS=$OLDIFS
set -- $line
if [ "$1" = "$name" ]; then
shift
echo "$@"
return 0
fi
done
IFS=$OLDIFS
}
find_checkout() {
(
cd "$(dirname "$0")"
while [ "$PWD" != / ]; do
if [ -e src/version.h.in ]; then
echo "$PWD"
exit 0
fi
cd ..
done
echo >&2 "please install dash from homebrew or macports to run this script"
exit 1
) || error 'cannot find project checkout'
}
error() {
printf >&2 '\nERROR: %s\n\n' "$1"
[ -z "$2" ] && exit 1
}
build_project() {
echo "\nBuilding project: $CHECKOUT\n"
mkdir -p "$BUILD_ROOT/project"
cd "$BUILD_ROOT/project"
cmake "$CHECKOUT" -DCMAKE_PREFIX_PATH="$BUILD_ROOT/root" -DCMAKE_BUILD_TYPE=Release -DSFML_STATIC_LIBRARIES=TRUE -DENABLE_FFMPEG=ON -DFFMPEG_STATIC=TRUE
make -j$NUM_CPUS
codesign -s "Developer ID Application" --deep ./visualboyadvance-m.app || :
rm -f ./visualboyadvance-m-Mac.zip
zip -9r ./visualboyadvance-m-Mac.zip ./visualboyadvance-m.app
echo "\nBuild Successful!!!\n\nBuild results can be found in: $BUILD_ROOT/project\n"
}
table_column() {
col=$1
[ -n "$col" ] || error 'table_column: column required'
row_size=$2
[ -n "$row_size" ] || error 'table_column: row_size required'
table=$3
[ -n "$table" ] || error 'table_column: table required'
table=$(echo "$table" | grep -Ev '^ *#')
i=0
res=
for item in $table; do
if [ $((i % row_size)) -eq "$col" ]; then
res="$res $item"
fi
i=$((i + 1))
done
fi
echo $res
BUILD_ROOT=$HOME/vbam-build-mac
return 0
}
BUILD_ENV=$(cat <<'EOF'
export MACOSX_DEPLOYMENT_TARGET=10.7
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"
EOF
)
table_rows() {
table=$1
[ -n "$table" ] || error 'table_rows: table required'
TAR=tar
table=$(echo "$table" | grep -Ev '^ *#')
. "$(dirname "$0")/../builder/core.sh"
i=0
OLDIFS=$IFS
IFS='
'; for line in $table; do
i=$((i + 1))
done
IFS=$OLDIFS
table_line_remove DISTS flex
table_line_remove DISTS libsecret
echo $i
table_line_replace DIST_CONFIGURE_OVERRIDES openssl './Configure darwin64-x86_64-cc no-shared --prefix=/usr --openssldir=/etc/ssl'
return 0
}
table_line_replace DIST_CONFIGURE_TYPES libmodplug autoreconf
table_line_append DIST_PRE_BUILD libmodplug " \
sed -i.bak '/-mmacosx-version-min=/d' configure.ac; \
sed -i.bak 's/-lstdc++/-lc++/g' libmodplug.pc.in; \
"
list_contains() {
_item=$1
[ -n "$_item" ] || error 'list_contains: item required'
shift
table_line_append DIST_PRE_BUILD libzmq "sed -i.bak 's/-lstdc++/-lc++/g' src/libzmq.pc.in"
table_line_append DIST_PRE_BUILD ffmpeg "sed -i.bak 's/-lstdc++/-lc++/g' configure"
for _pos; do
[ "$_item" = "$_pos" ] && return 0
done
table_line_append DIST_ARGS wxwidgets "--with-macosx-version-min=$MACOSX_DEPLOYMENT_TARGET LDFLAGS='$LDFLAGS -stdlib=libc++'"
table_line_append DIST_ARGS ffmpeg "--disable-videotoolbox --extra-ldflags='-framework CoreText'"
table_line_append DIST_ARGS libmodplug "CC=clang++ CXX=clang++"
return 1
}
main "$@"
builder "$@"

11
tools/unix/builder Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
set -e
BUILD_ROOT=$HOME/vbam-build-unix
. "$(dirname "$0")/../builder/core.sh"
table_line_append DIST_ARGS glib '--disable-libmount'
builder "$@"

View File

@ -1,351 +0,0 @@
#!/bin/sh
set -e
BUILD_ROOT=$HOME/vbam-build
# build env
export HOST_SYSTEM=x86_64-w64-mingw32
export CFLAGS="-I$BUILD_ROOT/root/include"
export CPPFLAGS="-I$BUILD_ROOT/root/include"
export CXXFLAGS="-I$BUILD_ROOT/root/include -std=gnu++11"
export OBJCXXFLAGS="-I$BUILD_ROOT/root/include -std=gnu++11"
export LDFLAGS="-L$BUILD_ROOT/root/lib"
export CMAKE_PREFIX_PATH="$BUILD_ROOT/root"
export PKG_CONFIG_PATH="$BUILD_ROOT/root/lib/pkgconfig"
export PATH="$BUILD_ROOT/root/bin:$PATH"
DISTS='
libiconv https://ftp.gnu.org/gnu/libiconv/libiconv-1.15.tar.gz lib/libiconv.a
gettext http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.1.tar.xz lib/libintl.a
openssl https://www.openssl.org/source/openssl-1.0.2l.tar.gz lib/libssl.a
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://dl.maptools.org/dl/libtiff/tiff-3.8.2.tar.gz lib/libtiff.a
sdl2 https://www.libsdl.org/release/SDL2-2.0.6.tar.gz lib/libSDL2.a
openal http://kcat.strangesoft.net/openal-releases/openal-soft-1.18.2.tar.bz2 lib/libOpenAL32.a
ogg http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz lib/libogg.a
vorbis http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xz lib/libvorbis.a
flac https://ftp.osuosl.org/pub/xiph/releases/flac/flac-1.3.2.tar.xz libFLAC.a
sfml https://www.sfml-dev.org/files/SFML-2.4.2-sources.zip lib/libsfml-system-s.a
wxwidgets https://github.com/wxWidgets/wxWidgets/releases/download/v3.0.3/wxWidgets-3.0.3.tar.bz2 lib/libwx_baseu-3.0.a
ffmpeg http://ffmpeg.org/releases/ffmpeg-3.3.4.tar.xz lib/libavformat.a
xz https://tukaani.org/xz/xz-5.2.3.tar.xz lib/liblzma.a
'
CONFIGURE_ARGS="--disable-shared --enable-static --prefix=$BUILD_ROOT/root --host=$HOST_SYSTEM"
CMAKE_ARGS="-DCMAKE_PREFIX_PATH=$BUILD_ROOT/root -DCMAKE_INSTALL_PREFIX=$BUILD_ROOT/root"
DIST_OVERRIDES="
openssl mingw64 no-shared --prefix=$BUILD_ROOT/root
gettext --host=$HOST_SYSTEM --prefix=$BUILD_ROOT/root --enable-static --with-included-glib --enable-threads=win32 --enable-static --with-included-libcroco --with-included-libunistring --with-included-libxml LDFLAGS='-L$BUILD_ROOT/root/lib'
"
DIST_ARGS="
sfml -DBUILD_SHARED_LIBS=NO
wxwidgets --enable-stl
openal -DLIBTYPE=STATIC
"
main() {
setup
delete_outdated_dists
download_dists
build_dists
build_project
}
setup() {
mkdir -p "$BUILD_ROOT"
DIST_NAMES=$( table_column 0 3 "$DISTS")
DIST_URLS=$( table_column 1 3 "$DISTS")
DIST_TARGETS=$(table_column 2 3 "$DISTS")
DISTS_NUM=$(table_rows "$DISTS")
NUM_CPUS=$(nproc)
CHECKOUT=$(find_checkout)
}
delete_outdated_dists() {
files=
i=0
for dist in $DIST_NAMES; do
dist_url=$(list_get $i $DIST_URLS)
dist_file="$BUILD_ROOT/dists/${dist_url##*/}"
files="$files $dist_file"
i=$((i + 1))
done
for file in $BUILD_ROOT/dists/*; do
if ! list_contains "$file" $files; then
echo "\nDeleting outdated dist: $file\n"
rm -f "$file"
fi
done
}
download_dists() {
mkdir -p "$BUILD_ROOT/dists"
i=0
while [ $i -lt $DISTS_NUM ]; do
dist_name=$(list_get $i $DIST_NAMES)
dist_url=$( list_get $i $DIST_URLS)
dist_file="$BUILD_ROOT/dists/${dist_url##*/}"
cd "$BUILD_ROOT/dists"
if [ ! -e "$dist_file" ]; then
echo "\nFetching $dist_name: $dist_url\n"
curl -LO "$dist_url"
# force rebuild for new dist file
rm -f "$BUILD_ROOT/root/$(list_get $i $DIST_TARGETS)"
rm -rf "$BUILD_ROOT/libs/$dist_name"
fi
dist_dir="$BUILD_ROOT/libs/$dist_name"
if [ ! -d "$dist_dir" ]; then
mkdir -p "$dist_dir"
tmp_dir="$BUILD_ROOT/libs/tmp"
mkdir -p "$tmp_dir"
cd "$tmp_dir"
case "$dist_file" in
*.tar.gz)
tar zxf "$dist_file"
;;
*.tar.xz)
xzcat "$dist_file" | tar xf -
;;
*.tar.bz2)
bzcat "$dist_file" | tar xf -
;;
*.zip)
unzip -q "$dist_file"
;;
esac
mv */* "$dist_dir"
rm -rf "$tmp_dir"
fi
i=$((i + 1))
done
}
build_dists() {
cd "$BUILD_ROOT/libs"
i=0
for dist in $DIST_NAMES; do
target_lib="$BUILD_ROOT/root/$(list_get $i $DIST_TARGETS)"
if [ ! -e "$target_lib" ]; then
cd "$dist"
if [ -e configure -o -e configure.ac -o -e configure.in -o -e Makefile.am ]; then
echo "\nBuilding $dist\n"
if [ ! -e configure ]; then
aclocal
if command -v glibtoolize >/dev/null; then
glibtoolize
else
libtoolize
fi
autoheader
autoconf
[ -e Makefile.am ] && automake --add-missing
fi
./configure $(dist_args "$dist" autoconf)
make -j$NUM_CPUS
make install prefix=$BUILD_ROOT/root
echo "\nDone!!!\n"
elif [ -e CMakeLists.txt ]; then
echo "\nBuilding $dist\n"
mkdir -p build
cd build
cmake .. -G"MSYS Makefiles" $(dist_args "$dist" cmake)
make -j$NUM_CPUS
rm -rf destdir
mkdir destdir
make install DESTDIR="$PWD/destdir"
cd "$PWD/destdir/$BUILD_ROOT/root"
find . ! -type d | (cd "$BUILD_ROOT/root"; IFS='
'; while read f; do
mkdir -p "${f%/*}"
cp -a "$BUILD_ROOT/libs/$dist/build/destdir/$BUILD_ROOT/root/$f" "$f"
done)
cd "$BUILD_ROOT/libs/$dist"
echo "\nDone!!!\n"
fi
cd ..
fi
i=$((i + 1))
done
}
list_get() {
i=0
n=${1:=0}
shift
for item; do
if [ $i -eq $n ]; then
echo "$item"
return 0
fi
i=$((i + 1))
done
}
dist_args() {
dist=$1
[ -n "$dist" ] || error 'dist name required'
buildsys=$2
[ "$buildsys" = autoconf -o "$buildsys" = cmake ] || \
error "buildsystem type required, must be 'autoconf' or 'cmake'"
args=$(table_line "$dist" "$DIST_OVERRIDES")
if [ -z "$args" ]; then
case "$buildsys" in
autoconf)
args="$CONFIGURE_ARGS $(table_line "$dist" "$DIST_ARGS")"
;;
cmake)
args="$CMAKE_ARGS $(table_line "$dist" "$DIST_ARGS")"
;;
esac
fi
echo "$args"
return 0
}
table_line() {
name=$1
[ -n "$name" ] || error 'item name required'
table=$2
[ -n "$table" ] || error 'table string required'
OLDIFS=$IFS
IFS='
'
for line in $table; do
IFS=$OLDIFS
set -- $line
if [ "$1" = "$name" ]; then
shift
echo "$@"
return 0
fi
done
IFS=$OLDIFS
}
find_checkout() {
(
cd "$(dirname "$0")"
while [ "$PWD" != / ]; do
if [ -e src/version.h.in ]; then
echo "$PWD"
exit 0
fi
cd ..
done
exit 1
) || error 'cannot find project checkout'
}
error() {
printf >&2 '\nERROR: %s.\n\n' "$1"
[ -z "$2" ] && exit 1
}
build_project() {
echo "\nBuilding project: $CHECKOUT\n"
mkdir -p "$BUILD_ROOT/project"
cd "$BUILD_ROOT/project"
cmake "$CHECKOUT" -DCMAKE_PREFIX_PATH="$BUILD_ROOT/root" -DENABLE_FFMPEG=OFF -DSFML_STATIC_LIBRARIES=TRUE
make -j$NUM_CPUS
echo "\nBuild Successful!!!\n\nBuild results can be found in: $BUILD_ROOT/project\n"
}
table_column() {
col=$1
[ -n "$col" ] || error 'table_column: column required'
row_size=$2
[ -n "$row_size" ] || error 'table_column: row_size required'
table=$3
[ -n "$table" ] || error 'table_column: table required'
i=0
res=
for item in $table; do
if [ $((i % row_size)) -eq "$col" ]; then
res="$res $item"
fi
i=$((i + 1))
done
echo $res
return 0
}
table_rows() {
table=$1
[ -n "$table" ] || error 'table_rows: table required'
i=0
OLDIFS=$IFS
IFS='
'; for line in $table; do
i=$((i + 1))
done
IFS=$OLDIFS
echo $i
return 0
}
list_contains() {
_item=$1
[ -n "$_item" ] || error 'list_contains: item required'
shift
for _pos; do
[ "$_item" = "$_pos" ] && return 0
done
return 1
}
main "$@"

95
tools/win/linux-cross-builder Executable file
View File

@ -0,0 +1,95 @@
#!/bin/sh
set -e
case "$1" in
-32)
target_bits=32
target_cpu=i686
;;
-64)
target_bits=64
target_cpu=x86_64
;;
*)
echo >&2 'First parameter must be -32 or -64 for 32 bit or 64 bit target respectively.'
exit 1
;;
esac
shift
target_arch="${target_cpu}-w64-mingw32"
export BUILD_ROOT="$HOME/vbam-build-mingw${target_bits}"
do_not_remove_dists=
host_dists='
unzip zip cmake autoconf autoconf-archive automake libtool help2man texinfo
xmlto pkgconfig nasm yasm c2man xorg-macros dejavu liberation urw graphviz
docbook4.2 docbook4.1.2 docbook4.3 docbook4.4 docbook4.5 docbook5.0
docbook-xsl docbook-xsl-ns python2 python3 swig doxygen bakefile setuptools
pip intltool ninja meson shared-mime-info gperf
'
both_dists='xz expat libpng freetype fontconfig'
[ -n "$BUILD_ENV" ] && eval "$BUILD_ENV"
BUILD_ENV=$BUILD_ENV$(cat <<EOF
export CC='ccache ${target_arch}-gcc'
export CXX='ccache ${target_arch}-g++'
EOF
)
REQUIRED_CONFIGURE_ARGS="--host=${target_arch}"
REQUIRED_CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE='$(readlink -f "${0%/*}/../../cmake/Toolchain-cross-MinGW-w64-${target_cpu}.cmake")'"
. "${0%/*}/../builder/mingw.sh"
fedora_installdeps() {
pkg_prefix="mingw${target_bits}"
set --
for p in gcc cpp gcc-c++ binutils headers crt filesystem winpthreads-static; do
set -- "$@" "${pkg_prefix}-${p}"
done
sudo dnf install -y --nogpgcheck --best --allowerasing "$@" gettext-devel wxGTK3-devel python
}
if [ $# -eq 0 ] && [ -f /etc/fedora-release ]; then
puts "${NL}Installing cross dependencies for your OS...${NL}${NL}"
fedora_installdeps
fi
openssl_host=mingw
[ "$target_bits" -eq 64 ] && openssl_host=mingw64
table_line_replace DIST_CONFIGURE_OVERRIDES openssl-target "./Configure $openssl_host no-shared --prefix=/usr --openssldir=/etc/ssl"
table_line_append DIST_PRE_BUILD bzip2-target ':; sed -i.bak '\''s,include <sys\\stat.h>,include <sys/stat.h>,g'\'' *.c;'
table_line_replace DIST_POST_BUILD harfbuzz "$(table_line DIST_POST_BUILD harfbuzz | sed 's/build_dist freetype /build_dist freetype-target /')"
table_line_append DIST_ARGS libsoxr '-DHAVE_WORDS_BIGENDIAN_EXITCODE=0'
vpx_target=x86-win32-gcc
[ "$target_bits" -eq 64 ] && vpx_target=x86_64-win64-gcc
table_line_replace DIST_CONFIGURE_OVERRIDES libvpx "./configure --target=$vpx_target $CONFIGURE_ARGS $(table_line DIST_ARGS libvpx)"
table_line_remove DIST_ARGS libvpx
table_line_replace DIST_CONFIGURE_OVERRIDES ffmpeg "\
./configure --arch=$target_cpu --target-os=mingw32 --cross-prefix=${target_arch}- \
--pkg-config='$BUILD_ROOT/host/bin/pkg-config' \
$CONFIGURE_ARGS $(table_line DIST_ARGS ffmpeg) \
"
table_line_remove DIST_ARGS ffmpeg
builder "$@"

147
tools/win/msys2-builder Executable file
View File

@ -0,0 +1,147 @@
#!/bin/sh
set -e
case "$1" in
-32)
shift
if [ "$MSYSTEM" != MINGW32 ]; then
OPWD=$PWD
export MSYSTEM=MINGW32
. /etc/profile
cd "$OPWD"
fi
;;
-64)
shift
if [ "$MSYSTEM" != MINGW64 ]; then
OPWD=$PWD
export MSYSTEM=MINGW64
. /etc/profile
cd "$OPWD"
fi
;;
esac
OMSYSTEM=$MSYSTEM
case "$MSYSTEM" in
MINGW32)
export HOST_SYSTEM=i686-w64-mingw32
sys_base=/mingw32
BUILD_ROOT="$HOME/vbam-build-msys2-i686"
;;
MINGW64)
export HOST_SYSTEM=x86_64-w64-mingw32
sys_base=/mingw64
BUILD_ROOT="$HOME/vbam-build-msys2-x86_64"
;;
*)
echo >&2 'You must be in either the MINGW32 or MINGW64 environment.'
exit 1
;;
esac
CMAKE_PREFIX_PATH=
for dir in /lib /bin "$HOST_SYSTEM/lib" "$HOST_SYSTEM/bin"; do
CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;$(cygpath -m "$sys_base/$dir")"
done
export CMAKE_PREFIX_PATH="$(cygpath -m "$BUILD_ROOT/root");${CMAKE_PREFIX_PATH%;}"
ignore_msys_paths=
for d in /usr /usr/include /usr/lib; do
ignore_msys_paths="$ignore_msys_paths;$(cygpath -m "$d")"
done
ignore_msys_paths=${ignore_msys_paths#;}
CMAKE_BASE_ARGS="-G 'MSYS Makefiles' -DCMAKE_IGNORE_PATH='$ignore_msys_paths'"
TMP_DIR="$BUILD_ROOT/tmp_$$"
BUILD_ENV=$BUILD_ENV$(cat <<'EOF'
# on don't translate prefix and defines by default
export MSYS2_ARG_CONV_EXCL="-D;/usr;/etc"
EOF
)
DIST_TAR_ARGS="
help2man --exclude ChangeLog
sfml --exclude libs-osx
expat --exclude README.md
libsoxr --exclude inst-check-soxr-lsr
graphviz --exclude COPYING --exclude graphviz.spec
"
. "$(dirname "$0")/../builder/mingw.sh"
set_host_env() {
ln -sf "$BUILD_ROOT/host" "$BUILD_ROOT/root"
OPWD=$PWD
MSYSTEM=MSYS . /etc/profile || :
eval "$BUILD_ENV"
cd "$OPWD"
}
unset_host_env() {
ln -sf "$BUILD_ROOT/target" "$BUILD_ROOT/root"
OPWD=$PWD
MSYSTEM=$OMSYSTEM . /etc/profile || :
eval "$BUILD_ENV"
cd "$OPWD"
}
table_line_append DIST_PRE_BUILD c2man ":; sed -i.bak '/test -d c:\\//,/^fi\$/d' Configure"
table_line_append DIST_PATCHES xmlto 'https://gist.githubusercontent.com/rkitover/55d51ab3d55af510b37872a49670436c/raw/b447beaffc2daa747ba6eaf222f69677c7d4a169/xmlto-0.0.28-mingw.patch'
# FIXME: problems with autopoint that need to be sorted
table_line_remove DISTS flex
table_line_replace DIST_CONFIGURE_TYPES fontconfig autoreconf
table_line_append DIST_PRE_BUILD fontconfig ":; \
sed -i.bak 's|ln -s \\\$(templatedir)|cp -af \$(DESTDIR)/\$(templatedir)|g' conf.d/Makefile.am; \
"
if mime_info_libs=$(table_line DIST_EXTRA_LIBS shared-mime-info); then
table_line_replace DIST_EXTRA_LIBS shared-mime-info "$(puts "$mime_info_libs" | sed 's/-ldl//g; s/-lresolv//g;')"
fi
table_line_remove DIST_CONFIGURE_OVERRIDES unzip
table_line_remove DIST_PRE_BUILD unzip
table_line_replace DIST_MAKE_ARGS unzip '-f win32/Makefile.gcc NOASM=1 CC_CPU_OPT='
table_line_replace DIST_INSTALL_OVERRIDES unzip 'cp -af $(find . -name "*.exe") "$BUILD_ROOT/root/bin"'
table_line_replace DIST_PRE_BUILD unzip ":; \
sed -i.bak 's,#include \"../unzip\\.h\",#include <windows.h>,; \
t; \
s,#include <windows.h>,#include \"../unzip.h\",' win32/win32.c win32/nt.c; \
"
table_line_append DIST_PATCHES zip 'https://gist.githubusercontent.com/rkitover/17e4c90185b7ad533e848b6230a90b8d/raw/67686e2332ae8712177957e4a4b871b24b3d07cf/zip-mingw.patch'
table_line_remove DIST_CONFIGURE_OVERRIDES zip
table_line_remove DIST_PRE_BUILD zip
table_line_replace DIST_MAKE_ARGS zip '-f win32/Makefile.gcc'
table_line_replace DIST_INSTALL_OVERRIDES zip 'cp -af *.exe "$BUILD_ROOT/root/bin"'
table_line_replace DIST_POST_BUILD unzip ":; \
mkdir -p \"\$BUILD_ROOT/root/bin\"; \
cp -a \"\$BUILD_ROOT/dists/unzip\"/*.exe \"\$BUILD_ROOT/root/bin\"; \
"
table_line_replace DIST_CONFIGURE_OVERRIDES openssl "$(table_line DIST_CONFIGURE_OVERRIDES openssl | sed 's,^./config ,./Configure Cygwin-x86_64 ,')"
table_line_append DIST_PRE_BUILD zlib ":; \
sed -i.bak ' \
s/defined(_WIN32) *|| *defined(__CYGWIN__)/defined(_WIN32)/ \
' gzguts.h; \
"
builder "$@"