diff --git a/app/deps/common b/app/deps/common index 6f8f80dc..49587e17 100644 --- a/app/deps/common +++ b/app/deps/common @@ -2,25 +2,45 @@ # This file is intended to be sourced by other scripts, not executed process_args() { - if [[ $# != 1 ]] + if [[ $# != 3 ]] then # : win32 or win64 - echo "Syntax: $0 " >&2 + # : native or cross + # : static or shared + echo "Syntax: $0 " >&2 exit 1 fi HOST="$1" + BUILD_TYPE="$2" # native or cross + LINK_TYPE="$3" # static or shared + DIRNAME="$HOST-$BUILD_TYPE-$LINK_TYPE" - if [[ "$HOST" = win32 ]] + if [[ "$BUILD_TYPE" != native && "$BUILD_TYPE" != cross ]] then - HOST_TRIPLET=i686-w64-mingw32 - elif [[ "$HOST" = win64 ]] - then - HOST_TRIPLET=x86_64-w64-mingw32 - else - echo "Unsupported host: $HOST" >&2 + echo "Unsupported build type (expected native or cross): $BUILD_TYPE" >&2 exit 1 fi + + if [[ "$LINK_TYPE" != static && "$LINK_TYPE" != shared ]] + then + echo "Unsupported link type (expected static or shared): $LINK_TYPE" >&2 + exit 1 + fi + + if [[ "$BUILD_TYPE" == cross ]] + then + if [[ "$HOST" = win32 ]] + then + HOST_TRIPLET=i686-w64-mingw32 + elif [[ "$HOST" = win64 ]] + then + HOST_TRIPLET=x86_64-w64-mingw32 + else + echo "Unsupported cross-build to host: $HOST" >&2 + exit 1 + fi + fi } DEPS_DIR=$(dirname ${BASH_SOURCE[0]}) diff --git a/app/deps/ffmpeg.sh b/app/deps/ffmpeg.sh index 20e59375..2484da23 100755 --- a/app/deps/ffmpeg.sh +++ b/app/deps/ffmpeg.sh @@ -23,41 +23,26 @@ fi mkdir -p "$BUILD_DIR/$PROJECT_DIR" cd "$BUILD_DIR/$PROJECT_DIR" -if [[ "$HOST" = win32 ]] +if [[ -d "$DIRNAME" ]] then - ARCH=x86 -elif [[ "$HOST" = win64 ]] -then - ARCH=x86_64 + echo "'$PWD/$DIRNAME' already exists, not reconfigured" + cd "$DIRNAME" else - echo "Unsupported host: $HOST" >&2 - exit 1 -fi + mkdir "$DIRNAME" + cd "$DIRNAME" -# -static-libgcc to avoid missing libgcc_s_dw2-1.dll -# -static to avoid dynamic dependency to zlib -export CFLAGS='-static-libgcc -static' -export CXXFLAGS="$CFLAGS" -export LDFLAGS='-static-libgcc -static' - -if [[ -d "$HOST" ]] -then - echo "'$PWD/$HOST' already exists, not reconfigured" - cd "$HOST" -else - mkdir "$HOST" - cd "$HOST" + if [[ "$HOST" == win* ]] + then + # -static-libgcc to avoid missing libgcc_s_dw2-1.dll + # -static to avoid dynamic dependency to zlib + export CFLAGS='-static-libgcc -static' + export CXXFLAGS="$CFLAGS" + export LDFLAGS='-static-libgcc -static' + fi conf=( - --prefix="$INSTALL_DIR/$HOST" - --enable-cross-compile - --target-os=mingw32 - --arch="$ARCH" - --cross-prefix="${HOST_TRIPLET}-" - --cc="${HOST_TRIPLET}-gcc" + --prefix="$INSTALL_DIR/$DIRNAME" --extra-cflags="-O2 -fPIC" - --enable-shared - --disable-static --disable-programs --disable-doc --disable-swscale @@ -89,6 +74,48 @@ else --enable-muxer=wav ) + if [[ "$LINK_TYPE" == static ]] + then + conf+=( + --enable-static + --disable-shared + ) + else + conf+=( + --disable-static + --enable-shared + ) + fi + + if [[ "$BUILD_TYPE" == cross ]] + then + conf+=( + --enable-cross-compile + --cross-prefix="${HOST_TRIPLET}-" + --cc="${HOST_TRIPLET}-gcc" + ) + + case "$HOST" in + win32) + conf+=( + --target-os=mingw32 + --arch=x86 + ) + ;; + + win64) + conf+=( + --target-os=mingw32 + --arch=x86_64 + ) + ;; + + *) + echo "Unsupported host: $HOST" >&2 + exit 1 + esac + fi + "$SOURCES_DIR/$PROJECT_DIR"/configure "${conf[@]}" fi diff --git a/app/deps/libusb.sh b/app/deps/libusb.sh index ee36d141..340b0f70 100755 --- a/app/deps/libusb.sh +++ b/app/deps/libusb.sh @@ -26,21 +26,38 @@ cd "$BUILD_DIR/$PROJECT_DIR" export CFLAGS='-O2' export CXXFLAGS="$CFLAGS" -if [[ -d "$HOST" ]] +if [[ -d "$DIRNAME" ]] then - echo "'$PWD/$HOST' already exists, not reconfigured" - cd "$HOST" + echo "'$PWD/$DIRNAME' already exists, not reconfigured" + cd "$DIRNAME" else - mkdir "$HOST" - cd "$HOST" + mkdir "$DIRNAME" + cd "$DIRNAME" conf=( - --prefix="$INSTALL_DIR/$HOST" - --host="$HOST_TRIPLET" - --enable-shared - --disable-static + --prefix="$INSTALL_DIR/$DIRNAME" ) + if [[ "$LINK_TYPE" == static ]] + then + conf+=( + --enable-static + --disable-shared + ) + else + conf+=( + --disable-static + --enable-shared + ) + fi + + if [[ "$BUILD_TYPE" == cross ]] + then + conf+=( + --host="$HOST_TRIPLET" + ) + fi + "$SOURCES_DIR/$PROJECT_DIR"/bootstrap.sh "$SOURCES_DIR/$PROJECT_DIR"/configure "${conf[@]}" fi diff --git a/app/deps/sdl.sh b/app/deps/sdl.sh index d8d0d734..71314118 100755 --- a/app/deps/sdl.sh +++ b/app/deps/sdl.sh @@ -26,21 +26,38 @@ cd "$BUILD_DIR/$PROJECT_DIR" export CFLAGS='-O2' export CXXFLAGS="$CFLAGS" -if [[ -d "$HOST" ]] +if [[ -d "$DIRNAME" ]] then - echo "'$PWD/$HOST' already exists, not reconfigured" - cd "$HOST" + echo "'$PWD/$HDIRNAME' already exists, not reconfigured" + cd "$DIRNAME" else - mkdir "$HOST" - cd "$HOST" + mkdir "$DIRNAME" + cd "$DIRNAME" conf=( - --prefix="$INSTALL_DIR/$HOST" - --host="$HOST_TRIPLET" - --enable-shared - --disable-static + --prefix="$INSTALL_DIR/$DIRNAME" ) + if [[ "$LINK_TYPE" == static ]] + then + conf+=( + --enable-static + --disable-shared + ) + else + conf+=( + --disable-static + --enable-shared + ) + fi + + if [[ "$BUILD_TYPE" == cross ]] + then + conf+=( + --host="$HOST_TRIPLET" + ) + fi + "$SOURCES_DIR/$PROJECT_DIR"/configure "${conf[@]}" fi @@ -48,4 +65,7 @@ make -j # There is no "make install-strip" make install # Strip manually -${HOST_TRIPLET}-strip "$INSTALL_DIR/$HOST/bin/SDL2.dll" +if [[ "$LINK_TYPE" == shared && "$HOST" == win* ]] +then + ${HOST_TRIPLET}-strip "$INSTALL_DIR/$DIRNAME/bin/SDL2.dll" +fi diff --git a/release/build_windows.sh b/release/build_windows.sh index 1b738ea3..dbd6cbf4 100755 --- a/release/build_windows.sh +++ b/release/build_windows.sh @@ -21,11 +21,11 @@ cd .. # root project dir WINXX_BUILD_DIR="$WORK_DIR/build-$WINXX" app/deps/adb_windows.sh -app/deps/sdl.sh $WINXX -app/deps/ffmpeg.sh $WINXX -app/deps/libusb.sh $WINXX +app/deps/sdl.sh $WINXX cross shared +app/deps/ffmpeg.sh $WINXX cross shared +app/deps/libusb.sh $WINXX cross shared -DEPS_INSTALL_DIR="$PWD/app/deps/work/install/$WINXX" +DEPS_INSTALL_DIR="$PWD/app/deps/work/install/$WINXX-cross-shared" ADB_INSTALL_DIR="$PWD/app/deps/work/install/adb-windows" rm -rf "$WINXX_BUILD_DIR"