diff --git a/.gitignore b/.gitignore index 794a9f29..d7490186 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ *.pl *.cache .DS_Store +meson-cross.txt diff --git a/3ds/2_build_toolchain.sh b/3ds/2_build_toolchain.sh index fce650ce..08e96c7f 100755 --- a/3ds/2_build_toolchain.sh +++ b/3ds/2_build_toolchain.sh @@ -16,6 +16,21 @@ test_ccache # Toolchain available? test_dkp "devkitARM" +export PATH=$DEVKITARM/bin:$DEVKITPRO/tools/bin:$PATH + +# Extra tools available? +if test_tool bannertool && test_tool makerom && test_tool 3dstool; then + : # nothing +else + msg "The following tools need to be installed to allow building .cia" + msg "bundles or creating custom banners:" + msg " https://github.com/dnasdw/3dstool" + #msg " https://github.com/Steveice10/bannertool" + msg " https://github.com/carstene1ns/3ds-bannertool" + msg " https://github.com/profi200/Project_CTR" +fi +require_tool tex3ds +require_tool 3dsxtool if [ ! -f .patches-applied ]; then echo "Patching libraries" @@ -25,6 +40,7 @@ if [ ! -f .patches-applied ]; then # Fix pixman (cd $PIXMAN_DIR patch -Np1 < $SCRIPT_DIR/../shared/extra/pixman-no-tls.patch + patch -Np1 < $SCRIPT_DIR/pixman-fix-types.patch ) # Fix mpg123 @@ -33,23 +49,19 @@ if [ ! -f .patches-applied ]; then autoreconf -fi ) + # Fix tremor + patch -d $TREMOR_DIR -Np1 < $SCRIPT_DIR/tremor-fix-types.patch + # Fix opus (remove when next version is out) - (cd $OPUS_DIR - patch -Np1 < $SCRIPT_DIR/opus-fix-types.patch - ) + patch -d $OPUS_DIR -Np1 < $SCRIPT_DIR/opus-fix-types.patch # Fix opusfile - (cd $OPUSFILE_DIR - patch -Np1 < $SCRIPT_DIR/../shared/extra/opusfile-devkit.patch - ) + patch -d $OPUSFILE_DIR -Np1 < $SCRIPT_DIR/../shared/extra/opusfile-devkit.patch # Fix lhasa - (cd $LHASA_DIR - patch -Np1 < $SCRIPT_DIR/../shared/extra/lhasa.patch - ) + patch -d $LHASA_DIR -Np1 < $SCRIPT_DIR/../shared/extra/lhasa.patch # Fix icu build - cp -rup icu icu-native patch -Np0 < $SCRIPT_DIR/icu-3ds.patch touch .patches-applied @@ -59,8 +71,6 @@ cd $WORKSPACE echo "Preparing toolchain" -export PATH=$DEVKITARM/bin:$PATH - export PLATFORM_PREFIX=$WORKSPACE export TARGET_HOST=arm-none-eabi unset PKG_CONFIG_PATH @@ -70,10 +80,6 @@ export MAKEFLAGS="-j${nproc:-2}" function set_build_flags { export CC="$TARGET_HOST-gcc" export CXX="$TARGET_HOST-g++" - if [ "$ENABLE_CCACHE" ]; then - export CC="ccache $CC" - export CXX="ccache $CXX" - fi ARCH_FLAGS="-march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -mword-relocations" export CFLAGS="-g0 -O2 $ARCH_FLAGS -ffunction-sections -fdata-sections" export CXXFLAGS="$CFLAGS" @@ -82,15 +88,15 @@ function set_build_flags { export LIBS="-lctru" export CMAKE_SYSTEM_NAME="Generic" - $SCRIPT_DIR/../shared/mk-meson-cross.sh 3ds > meson-cross.txt + make_meson_cross 3ds > meson-cross.txt } install_lib_icu_native set_build_flags -install_lib_zlib -install_lib $LIBPNG_DIR $LIBPNG_ARGS +install_lib_cmake $ZLIB_DIR $ZLIB_ARGS +install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON #install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS #install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF diff --git a/3ds/3_cleanup.sh b/3ds/3_cleanup.sh index ddeb8285..b9803ec9 100755 --- a/3ds/3_cleanup.sh +++ b/3ds/3_cleanup.sh @@ -7,6 +7,4 @@ headermsg "Cleaning up library build folders and other stuff..." cleanup -rm -f meson-cross.txt - echo " -> done" diff --git a/3ds/opus-fix-types.patch b/3ds/opus-fix-types.patch index fc325016..9d243f73 100644 --- a/3ds/opus-fix-types.patch +++ b/3ds/opus-fix-types.patch @@ -1,6 +1,6 @@ -diff '--color=auto' -Naur opus-1.5.1-orig/src/opus_private.h opus-1.5.1/src/opus_private.h ---- opus-1.5.1-orig/src/opus_private.h 2024-01-26 06:17:36.000000000 +0100 -+++ opus-1.5.1/src/opus_private.h 2024-03-29 12:35:28.073702694 +0100 +diff --color -Nur opus-1.5.1.orig/src/opus_private.h opus-1.5.1/src/opus_private.h +--- opus-1.5.1.orig/src/opus_private.h 2024-01-26 06:17:36.000000000 +0100 ++++ opus-1.5.1/src/opus_private.h 2024-06-07 19:15:48.414257500 +0200 @@ -214,7 +214,7 @@ opus_int32 opus_packet_extensions_parse(const unsigned char *data, opus_int32 len, opus_extension_data *extensions, opus_int32 *nb_extensions); @@ -10,3 +10,16 @@ diff '--color=auto' -Naur opus-1.5.1-orig/src/opus_private.h opus-1.5.1/src/opus opus_int32 opus_packet_extensions_count(const unsigned char *data, opus_int32 len); +diff --color -Nur opus-1.5.1.orig/src/repacketizer.c opus-1.5.1/src/repacketizer.c +--- opus-1.5.1.orig/src/repacketizer.c 2024-02-20 21:05:04.000000000 +0100 ++++ opus-1.5.1/src/repacketizer.c 2024-06-07 19:33:17.139842439 +0200 +@@ -155,7 +155,8 @@ + /* incorporate any extensions from the repacketizer padding */ + for (i=begin;ipaddings[i], rp->padding_len[i], + &all_extensions[ext_count], &frame_ext_count); diff --git a/3ds/pixman-fix-types.patch b/3ds/pixman-fix-types.patch new file mode 100644 index 00000000..27996307 --- /dev/null +++ b/3ds/pixman-fix-types.patch @@ -0,0 +1,35 @@ +diff --color -Nur pixman-0.43.4.orig/pixman/pixman.h pixman-0.43.4/pixman/pixman.h +--- pixman-0.43.4.orig/pixman/pixman.h 2024-02-29 17:13:20.000000000 +0100 ++++ pixman-0.43.4/pixman/pixman.h 2024-06-07 18:28:33.819563120 +0200 +@@ -120,7 +120,7 @@ + typedef uint32_t pixman_fixed_1_31_t; + typedef uint32_t pixman_fixed_1_16_t; + typedef int32_t pixman_fixed_16_16_t; +-typedef pixman_fixed_16_16_t pixman_fixed_t; ++typedef int pixman_fixed_t; + + #define pixman_fixed_e ((pixman_fixed_t) 1) + #define pixman_fixed_1 (pixman_int_to_fixed(1)) +@@ -632,7 +632,7 @@ + + struct pixman_box32 + { +- int32_t x1, y1, x2, y2; ++ int x1, y1, x2, y2; + }; + + struct pixman_region32 +diff --color -Nur pixman-0.43.4.orig/pixman/pixman-inlines.h pixman-0.43.4/pixman/pixman-inlines.h +--- pixman-0.43.4.orig/pixman/pixman-inlines.h 2024-02-29 17:13:20.000000000 +0100 ++++ pixman-0.43.4/pixman/pixman-inlines.h 2024-06-07 18:19:58.620034383 +0200 +@@ -792,8 +792,8 @@ + int32_t * right_tz, + int32_t * right_pad) + { +- int width1 = *width, left_pad1, right_pad1; +- int width2 = *width, left_pad2, right_pad2; ++ int32_t width1 = *width, left_pad1, right_pad1; ++ int32_t width2 = *width, left_pad2, right_pad2; + + pad_repeat_get_scanline_bounds (source_image_width, vx, unit_x, + &width1, &left_pad1, &right_pad1); diff --git a/3ds/tremor-fix-types.patch b/3ds/tremor-fix-types.patch new file mode 100644 index 00000000..d08e9151 --- /dev/null +++ b/3ds/tremor-fix-types.patch @@ -0,0 +1,31 @@ +--- tremor.orig/sharedbook.c 2018-03-19 21:08:57.000000000 +0100 ++++ tremor-7c30a66346199f3f09017a09567c6c8a3a0eedc8/sharedbook.c 2024-06-07 19:26:43.278590551 +0200 +@@ -218,12 +218,11 @@ + quantvals=_book_maptype1_quantvals(b); + for(j=0;jentries;j++){ + if((sparsemap && b->lengthlist[j]) || !sparsemap){ +- ogg_int32_t last=0; +- int lastpoint=0; ++ ogg_int32_t last=0, lastpoint=0; + int indexdiv=1; + for(k=0;kdim;k++){ + int index= (j/indexdiv)%quantvals; +- int point=0; ++ ogg_int32_t point=0; + int val=VFLOAT_MULTI(delta,delpoint, + abs(b->quantlist[index]),&point); + +@@ -253,11 +252,10 @@ + case 2: + for(j=0;jentries;j++){ + if((sparsemap && b->lengthlist[j]) || !sparsemap){ +- ogg_int32_t last=0; +- int lastpoint=0; ++ ogg_int32_t last=0, lastpoint=0; + + for(k=0;kdim;k++){ +- int point=0; ++ ogg_int32_t point=0; + int val=VFLOAT_MULTI(delta,delpoint, + abs(b->quantlist[j*b->dim+k]),&point); + diff --git a/android/2_build_toolchain.sh b/android/2_build_toolchain.sh index bcd25b21..f9654952 100755 --- a/android/2_build_toolchain.sh +++ b/android/2_build_toolchain.sh @@ -12,11 +12,9 @@ source $SCRIPT_DIR/../shared/import.sh os=`uname` if [ $os = "Darwin" ] ; then nproc=$(getconf _NPROCESSORS_ONLN) - CP_ARGS="-r" NDK_ARCH="darwin-x86_64" else nproc=$(nproc) - CP_ARGS="-rup" NDK_ARCH="linux-x86_64" fi @@ -28,8 +26,6 @@ if [ ! -f .patches-applied ]; then patches_common - cp $CP_ARGS icu icu-native - # pixman: hardcode cpufeatures (crashes armeabi-v7a) (cd $PIXMAN_DIR patch -Np1 < ../pixman-cpufeatures.patch @@ -97,16 +93,12 @@ function build() { export TARGET_HOST="$4" export CC="clang -target ${TARGET_HOST}${TARGET_API}" export CXX="clang++ -target ${TARGET_HOST}${TARGET_API}" - if [ "$ENABLE_CCACHE" ]; then - export CC="ccache $CC" - export CXX="ccache $CXX" - fi mkdir -p $PLATFORM_PREFIX - $SCRIPT_DIR/../shared/mk-meson-cross.sh "${TARGET_HOST}${TARGET_API}" > $PLATFORM_PREFIX/meson-cross.txt + make_meson_cross "${TARGET_HOST}${TARGET_API}" > $PLATFORM_PREFIX/meson-cross.txt - install_lib_zlib - install_lib $LIBPNG_DIR $LIBPNG_ARGS + install_lib_cmake $ZLIB_DIR $ZLIB_ARGS + install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF diff --git a/emscripten/2_build_toolchain.sh b/emscripten/2_build_toolchain.sh index 63100e33..1d1a1ffe 100755 --- a/emscripten/2_build_toolchain.sh +++ b/emscripten/2_build_toolchain.sh @@ -12,10 +12,8 @@ source $SCRIPT_DIR/../shared/import.sh os=`uname` if [ $os = "Darwin" ] ; then nproc=$(getconf _NPROCESSORS_ONLN) - CP_ARGS="-r" else nproc=$(nproc) - CP_ARGS="-rup" fi # no ccache support currently with em* wrappers @@ -44,8 +42,6 @@ if [ ! -f .patches-applied ]; then ) fi - cp $CP_ARGS icu icu-native - touch .patches-applied fi @@ -68,6 +64,7 @@ function set_build_flags { export EM_CFLAGS="-Wno-warn-absolute-paths" export EMCC_CFLAGS="$EM_CFLAGS" export EM_PKG_CONFIG_PATH="$PLATFORM_PREFIX/lib/pkgconfig" + export CMAKE_EXTRA_ARGS="-DCMAKE_FIND_ROOT_PATH=$PLATFORM_PREFIX" # force mmap support in mpg123 (actually unused, but needed for building) export ac_cv_func_mmap_fixed_mapped=yes @@ -96,8 +93,8 @@ if [ $os = "Darwin" ] ; then export TARGET_HOST="asmjs-unknown-emscripten" fi -install_lib_zlib -install_lib $LIBPNG_DIR $LIBPNG_ARGS +install_lib_cmake $ZLIB_DIR $ZLIB_ARGS +install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF -DCMAKE_FIND_ROOT_PATH=$PLATFORM_PREFIX diff --git a/emscripten/3_cleanup.sh b/emscripten/3_cleanup.sh index 6c8dcb52..24173e7a 100755 --- a/emscripten/3_cleanup.sh +++ b/emscripten/3_cleanup.sh @@ -8,6 +8,5 @@ headermsg "Cleaning up library build folders and other stuff..." cleanup rm -rf SDL2/ -rm -f meson-cross.txt echo " -> done" diff --git a/ios/2_build_toolchain.sh b/ios/2_build_toolchain.sh index 811c83fe..dfa065af 100755 --- a/ios/2_build_toolchain.sh +++ b/ios/2_build_toolchain.sh @@ -22,8 +22,6 @@ if [ ! -f .patches-applied ]; then patches_common - cp -rp icu icu-native - touch .patches-applied fi @@ -43,10 +41,6 @@ function set_build_flags { export CC="$CLANG $ARCH" export CXX="$CLANGXX $ARCH" export OBJC="$CLANG $ARCH" - if [ "$ENABLE_CCACHE" ]; then - export CC="ccache $CC" - export CXX="ccache $CXX" - fi export CFLAGS="-g -O2 -miphoneos-version-min=9.0 -isysroot $SDKPATH $3" export CXXFLAGS=$CFLAGS # ICU include is required for arm64 @@ -58,14 +52,14 @@ function set_build_flags { export TARGET_HOST="$2" mkdir -p $PLATFORM_PREFIX - $SCRIPT_DIR/../shared/mk-meson-cross.sh "${TARGET_HOST}" > $PLATFORM_PREFIX/meson-cross.txt + make_meson_cross "${TARGET_HOST}" > $PLATFORM_PREFIX/meson-cross.txt } function build() { cd "$WORKSPACE" - install_lib_zlib - install_lib $LIBPNG_DIR $LIBPNG_ARGS + install_lib_cmake $ZLIB_DIR $ZLIB_ARGS + install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF diff --git a/linux-static/2_build_toolchain.sh b/linux-static/2_build_toolchain.sh index 08a2b039..b7ed6e96 100755 --- a/linux-static/2_build_toolchain.sh +++ b/linux-static/2_build_toolchain.sh @@ -28,6 +28,13 @@ echo "Preparing toolchain" export PLATFORM_PREFIX=$WORKSPACE +if test_tool clang && test_tool clang++; then + export CC=clang + export CXX=clang++ +elif test_tool gcc && test_tool g++; then + export CC=gcc + export CXX=g++ +fi export CFLAGS="-Os -g0 -fPIC -ffunction-sections -fdata-sections" export CXXFLAGS=$CFLAGS export CPPFLAGS="-I$PLATFORM_PREFIX/include" @@ -35,13 +42,9 @@ export LDFLAGS="-fPIC -L$PLATFORM_PREFIX/lib" export MAKEFLAGS="-j${nproc:-2}" export PKG_CONFIG_PATH=$WORKSPACE/lib/pkgconfig export PKG_CONFIG_LIBDIR=$PKG_CONFIG_PATH -if [ "$ENABLE_CCACHE" ]; then - export CC="ccache gcc" - export CXX="ccache g++" -fi -install_lib_zlib -install_lib $LIBPNG_DIR $LIBPNG_ARGS +install_lib_cmake $ZLIB_DIR $ZLIB_ARGS +install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF diff --git a/macos/2_build_toolchain.sh b/macos/2_build_toolchain.sh index 7d1fabd0..1d3293af 100755 --- a/macos/2_build_toolchain.sh +++ b/macos/2_build_toolchain.sh @@ -22,8 +22,6 @@ if [ ! -f .patches-applied ]; then patches_common - cp -rp icu icu-native - touch .patches-applied fi @@ -42,10 +40,6 @@ function set_build_flags() { export PATH=$PLATFORM_PREFIX/bin:$PATH export CC="$CLANG $ARCH" export CXX="$CLANGXX $ARCH" - if [ "$ENABLE_CCACHE" ]; then - export CC="ccache $CC" - export CXX="ccache $CXX" - fi export CFLAGS="-g -O2 -mmacosx-version-min=10.9 -isysroot $SDKPATH $3" export CXXFLAGS=$CFLAGS # ICU include is required for arm64 @@ -59,14 +53,14 @@ function set_build_flags() { export TARGET_HOST="$2" mkdir -p $PLATFORM_PREFIX - $SCRIPT_DIR/../shared/mk-meson-cross.sh "${TARGET_HOST}" > $PLATFORM_PREFIX/meson-cross.txt + make_meson_cross "${TARGET_HOST}" > $PLATFORM_PREFIX/meson-cross.txt } function build() { cd "$WORKSPACE" - install_lib_zlib - install_lib $LIBPNG_DIR $LIBPNG_ARGS + install_lib_cmake $ZLIB_DIR $ZLIB_ARGS + install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF diff --git a/shared/common.sh b/shared/common.sh index 905780c8..a2c16538 100644 --- a/shared/common.sh +++ b/shared/common.sh @@ -97,15 +97,57 @@ function msg { colormsg "$1" "32m" } +function verbosemsg { + colormsg "$1" "33m" +} + +function test_tool { + hash $1 >/dev/null 2>&1 +} + +function require_tool { + if ! test_tool $1; then + errormsg "The required tool $1 is missing!" + fi +} + +ENABLE_CCACHE=0 function test_ccache { if [ -z ${NO_CCACHE+x} ]; then - if hash ccache >/dev/null 2>&1; then + if test_tool ccache; then ENABLE_CCACHE=1 echo "CCACHE enabled" fi fi } +function ccachify_compiler { + if [ $ENABLE_CCACHE -eq 1 ]; then + if [ -n "$CC" ]; then + saved_CC=$CC + export CC="ccache $CC" + fi + + if [ -n "$CXX" ]; then + saved_CXX=$CXX + export CXX="ccache $CXX" + fi + fi +} + +function unccachify_compiler { + if [ $ENABLE_CCACHE -eq 1 ]; then + [ -n "$saved_CC" ] && export CC=$saved_CC + [ -n "$saved_CXX" ] && export CXX=$saved_CXX + fi +} + +function make_meson_cross { + ccachify_compiler + $SCRIPT_DIR/../shared/mk-meson-cross.sh $@ + unccachify_compiler +} + function test_dkp { platform=$1 envvar=${platform^^} @@ -119,6 +161,8 @@ function test_dkp { function install_lib { headermsg "**** Building ${1%-*} ****" + ccachify_compiler + (cd $1 shift @@ -129,6 +173,8 @@ function install_lib { make make install ) + + unccachify_compiler } # generic cmake library installer @@ -140,30 +186,35 @@ function install_lib_cmake { rm -rf build + # cmake 3.17+, but this only reports unused options on older versions, + # so users unwilling to update cmake will not get ccache acceleration + CMAKE_CCACHE= + if [ $ENABLE_CCACHE -eq 1 ]; then + CMAKE_CCACHE="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" + fi + + CMAKE_AR= if [ -n "$AR" ]; then - export CMAKE_AR="-DCMAKE_AR=$AR" - else - CMAKE_AR= + CMAKE_AR="-DCMAKE_AR=$AR" fi + CMAKE_NM= if [ -n "$NM" ]; then - export CMAKE_NM="-DCMAKE_NM=$NM" - else - CMAKE_NM= + CMAKE_NM="-DCMAKE_NM=$NM" fi + CMAKE_RANLIB= if [ -n "$RANLIB" ]; then - export CMAKE_RANLIB="-DCMAKE_RANLIB=$RANLIB" - else - CMAKE_RANLIB= + CMAKE_RANLIB="-DCMAKE_RANLIB=$RANLIB" fi - $CMAKE_WRAPPER cmake . -GNinja -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=OFF \ + $CMAKE_WRAPPER cmake . -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_C_FLAGS="$CFLAGS $CPPFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS $CPPFLAGS" \ - -DCMAKE_INSTALL_LIBDIR=lib $CMAKE_AR $CMAKE_NM $CMAKE_RANLIB \ + -DCMAKE_INSTALL_LIBDIR=lib $CMAKE_AR $CMAKE_NM $CMAKE_RANLIB $CMAKE_CCACHE \ -DCMAKE_INSTALL_PREFIX=$PLATFORM_PREFIX -DCMAKE_SYSTEM_NAME=$CMAKE_SYSTEM_NAME \ -DCMAKE_PREFIX_PATH=$PLATFORM_PREFIX $CMAKE_EXTRA_ARGS $@ cmake --build build --target clean + cmake --build build cmake --build build --target install ) } @@ -189,18 +240,6 @@ function install_lib_meson { ) } -function install_lib_zlib { - headermsg "**** Building zlib ****" - - (cd $ZLIB_DIR - CHOST=$TARGET_HOST $CONFIGURE_WRAPPER ./configure --static --prefix=$PLATFORM_PREFIX - make clean - # only build static library, no tests/examples - make libz.a - make install - ) -} - function install_lib_liblcf { if [ "$BUILD_LIBLCF" == "1" ]; then install_lib liblcf --disable-update-mimedb --disable-tools @@ -210,36 +249,59 @@ function install_lib_liblcf { function install_lib_icu_native { headermsg "**** Building ICU (native) ****" - (cd icu-native/source - unset CC - unset CXX - unset CFLAGS - unset CPPFLAGS - unset CXXFLAGS - unset LDFLAGS + # do not use cross environment + unset CC + unset CXX + unset CFLAGS + unset CPPFLAGS + unset CXXFLAGS + unset LDFLAGS + + # ICU's configure will always check clang and then gcc first. Since they + # are used on many of our platforms, we can accelerate with ccache + if test_tool clang && test_tool clang++; then + export CC=clang + export CXX=clang++ + elif test_tool gcc && test_tool g++; then + export CC=gcc + export CXX=g++ + fi + if [ $ENABLE_CCACHE -eq 1 ]; then + export CC="ccache $CC" + export CXX="ccache $CXX" + fi - chmod u+x configure - ./configure --enable-static --enable-shared=no $ICU_ARGS + mkdir -p icu-native + (cd icu-native + ../icu/source/configure --enable-static --disable-shared $ICU_ARGS + make clean make ) + + # reset + unset CC + unset CXX } function install_lib_icu_cross { headermsg "**** Building ICU (cross) ****" - export ICU_CROSS_BUILD=$PWD/icu-native/source + ICU_CROSS_BUILD=$PWD/icu-native - (cd icu/source - cp config/mh-linux config/mh-unknown + ccachify_compiler - chmod u+x configure - $CONFIGURE_WRAPPER ./configure --enable-static --enable-shared=no --prefix=$PLATFORM_PREFIX \ + mkdir -p icu-cross + (cd icu-cross + $CONFIGURE_WRAPPER ../icu/source/configure \ + --enable-static --disable-shared --prefix=$PLATFORM_PREFIX \ --host=$TARGET_HOST --with-cross-build=$ICU_CROSS_BUILD \ - --enable-tools=no $ICU_ARGS + --disable-tools $ICU_ARGS make clean make make install ) + + unccachify_compiler } # Use this when crosscompiling but configure assumes we are building native @@ -248,9 +310,9 @@ function icu_force_data_install { headermsg "**** Force install ICU data file ****" # Disable assembly - export PKGDATA_OPTS="-w -v -O $PWD/icu/source/config/pkgdata.inc" + export PKGDATA_OPTS="-w -v -O $PWD/icu-cross/config/pkgdata.inc" - (cd icu/source/data + (cd icu-cross/data make clean make @@ -261,15 +323,30 @@ function icu_force_data_install { function patches_common { _SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - # disable png utils - (cd $LIBPNG_DIR - perl -pi -e 's/^check_PROGRAMS.*//' Makefile.am - perl -pi -e 's/^bin_PROGRAMS.*//' Makefile.am - autoreconf -fi - ) + # zlib: Install pkgconfig into lib and only build static library + if [ -d "$ZLIB_DIR" ]; then + verbosemsg "zlib" + + (cd $ZLIB_DIR + perl -pi -e 's#/share/pkgconfig#/lib/pkgconfig#' CMakeLists.txt + patch -Np1 < $_SCRIPT_DIR/zlib-only-static.patch + ) + fi + + # png: move cmake configuration, fix using compiler with arguments + if [ -d "$LIBPNG_DIR" ]; then + verbosemsg "libpng" + + (cd $LIBPNG_DIR + perl -pi -e 's#DESTINATION lib/libpng#DESTINATION lib/cmake/libpng#' CMakeLists.txt + patch -Np1 < $_SCRIPT_DIR/libpng-custom-cc.patch + ) + fi # disable unsupported compiler flags by clang in libvorbis if [ -d "$LIBVORBIS_DIR" ]; then + verbosemsg "libvorbis" + perl -pi -e 's/-mno-ieee-fp//' $LIBVORBIS_DIR/configure # Invalid since macOS Sonoma perl -pi -e 's/-force_cpusubtype_ALL//' $LIBVORBIS_DIR/configure @@ -277,6 +354,8 @@ function patches_common { # disable libsndfile examples and tests if [ -d "$LIBSNDFILE_DIR" ]; then + verbosemsg "libsndfile" + (cd $LIBSNDFILE_DIR perl -pi -e 's/ examples tests//' Makefile.am perl -pi -e 's/ examples regtest tests programs//' Makefile.am @@ -286,6 +365,8 @@ function patches_common { # Tremor: Generate configure & Makefile, fix build if [ -d "$TREMOR_DIR" ]; then + verbosemsg "tremor" + (cd $TREMOR_DIR perl -pi -e 's/XIPH_PATH_OGG.*//' configure.in autoreconf -fi @@ -294,6 +375,8 @@ function patches_common { # libsamplerate: disable examples if [ -d "$LIBSAMPLERATE_DIR" ]; then + verbosemsg "libsamplerate" + (cd $LIBSAMPLERATE_DIR patch -Np1 < $_SCRIPT_DIR/libsamplerate-no-examples.patch autoreconf -fi @@ -302,6 +385,8 @@ function patches_common { # Expat: Disable error when high entropy randomness is unavailable if [ -d "$EXPAT_DIR" ]; then + verbosemsg "expat" + (cd $EXPAT_DIR perl -pi -e 's/# error/#warning/' lib/xmlparse.c ) @@ -309,6 +394,8 @@ function patches_common { # FluidSynth: Shim glib and disable all optional features if [ -d "$FLUIDSYNTH_DIR" ]; then + verbosemsg "fluidsynth" + (cd $FLUIDSYNTH_DIR patch -Np1 < $_SCRIPT_DIR/fluidsynth-no-glib.patch patch -Np1 < $_SCRIPT_DIR/fluidsynth-no-deps.patch @@ -317,20 +404,28 @@ function patches_common { # nlohmann json: Install pkgconfig/cmake into lib (share is deleted by us) if [ -d "$NLOHMANNJSON_DIR" ]; then + verbosemsg "nlohmann_json" + (cd $NLOHMANNJSON_DIR perl -pi -e 's/CMAKE_INSTALL_DATADIR/CMAKE_INSTALL_LIBDIR/' CMakeLists.txt ) fi # lhasa: disable binary and tests - (cd $LHASA_DIR - perl -pi -e 's/ src test//' Makefile.am - autoreconf -fi - ) + if [ -d "$LHASA_DIR" ]; then + verbosemsg "lhasa" + (cd $LHASA_DIR + perl -pi -e 's/ src test//' Makefile.am + autoreconf -fi + ) + fi + + verbosemsg "ICU" cp icudt*.dat $ICU_DIR/source/data/in (cd $ICU_DIR/source chmod u+x configure + cp config/mh-linux config/mh-unknown perl -pi -e 's/SMALL_BUFFER_MAX_SIZE 512/SMALL_BUFFER_MAX_SIZE 2048/' tools/toolutil/pkg_genc.h ) } @@ -338,9 +433,10 @@ function patches_common { function cleanup { rm -rf zlib-*/ libpng-*/ freetype-*/ harfbuzz-*/ pixman-*/ expat-*/ libogg-*/ \ libvorbis-*/ tremor-*/ mpg123-*/ libsndfile-*/ libxmp-lite-*/ speexdsp-*/ \ - libsamplerate-*/ wildmidi-*/ opus-*/ opusfile-*/ icu/ icu-native/ \ + libsamplerate-*/ wildmidi-*/ opus-*/ opusfile-*/ icu/ icu-native/ icu-cross/ \ SDL2-*/ SDL2_image-*/ fmt-*/ FluidLite-*/ fluidsynth-*/ json-*/ inih-*/ \ lhasa-*/ liblcf/ - rm -f *.zip *.bz2 *.gz *.xz *.tgz icudt* .patches-applied config.cache + rm -f *.zip *.bz2 *.gz *.xz *.tgz icudt* .patches-applied config.cache meson-cross.txt rm -rf sbin/ share/ + rm -f lib/*.la } diff --git a/shared/extra/icu69-no-mutex.patch b/shared/extra/icu69-no-mutex.patch deleted file mode 100644 index 284d3fcd..00000000 --- a/shared/extra/icu69-no-mutex.patch +++ /dev/null @@ -1,340 +0,0 @@ -diff '--color=auto' -Naur icu-native/source/common/umutex.cpp icu/source/common/umutex.cpp ---- icu-native/source/common/umutex.cpp 2021-07-13 00:45:56.917784151 +0200 -+++ icu/source/common/umutex.cpp 2021-07-13 00:46:06.537784279 +0200 -@@ -43,16 +43,18 @@ - * - *************************************************************************************************/ - -+#if 0 -+ - namespace { --std::mutex *initMutex; --std::condition_variable *initCondition; -+//std::mutex *initMutex; -+//std::condition_variable *initCondition; - - // The ICU global mutex. - // Used when ICU implementation code passes nullptr for the mutex pointer. - UMutex globalMutex; - --std::once_flag initFlag; --std::once_flag *pInitFlag = &initFlag; -+//std::once_flag initFlag; -+//std::once_flag *pInitFlag = &initFlag; - - } // Anonymous namespace - -@@ -106,24 +108,28 @@ - } - gListHead = nullptr; - } -- -+#endif - - U_CAPI void U_EXPORT2 - umtx_lock(UMutex *mutex) { -+#if 0 - if (mutex == nullptr) { - mutex = &globalMutex; - } - mutex->lock(); -+#endif - } - - - U_CAPI void U_EXPORT2 - umtx_unlock(UMutex* mutex) - { -+#if 0 - if (mutex == nullptr) { - mutex = &globalMutex; - } - mutex->unlock(); -+#endif - } - - -@@ -143,6 +149,7 @@ - // - U_COMMON_API UBool U_EXPORT2 - umtx_initImplPreInit(UInitOnce &uio) { -+#if 0 - std::call_once(*pInitFlag, umtx_init); - std::unique_lock lock(*initMutex); - if (umtx_loadAcquire(uio.fState) == 0) { -@@ -157,6 +164,8 @@ - U_ASSERT(uio.fState == 2); - return false; - } -+#endif -+ return true; - } - - -@@ -168,11 +177,13 @@ - - U_COMMON_API void U_EXPORT2 - umtx_initImplPostInit(UInitOnce &uio) { -+#if 0 - { - std::unique_lock lock(*initMutex); - umtx_storeRelease(uio.fState, 2); - } - initCondition->notify_all(); -+#endif - } - - U_NAMESPACE_END -diff '--color=auto' -Naur icu-native/source/common/umutex.h icu/source/common/umutex.h ---- icu-native/source/common/umutex.h 2021-07-13 00:45:56.917784151 +0200 -+++ icu/source/common/umutex.h 2021-07-13 00:46:06.537784279 +0200 -@@ -20,9 +20,9 @@ - #ifndef UMUTEX_H - #define UMUTEX_H - --#include --#include --#include -+//#include -+//#include -+//#include - #include - - #include "unicode/utypes.h" -@@ -37,7 +37,7 @@ - #error U_USER_ATOMICS and U_USER_MUTEX_H are not supported - #endif - --// Export an explicit template instantiation of std::atomic. -+// Export an explicit template instantiation of std::atomic. - // When building DLLs for Windows this is required as it is used as a data member of the exported SharedObject class. - // See digitlst.h, pluralaffix.h, datefmt.h, and others for similar examples. - // -@@ -49,15 +49,15 @@ - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Winstantiation-after-specialization" - #endif --template struct U_COMMON_API std::atomic; --template struct U_COMMON_API std::atomic; -+//template struct U_COMMON_API std::atomic; -+//template struct U_COMMON_API std::atomic; - #if defined(__clang__) - #pragma clang diagnostic pop - #endif - #elif defined(__GNUC__) - // For GCC this class is already exported/visible, so no need for U_COMMON_API. --template struct std::atomic; --template struct std::atomic; -+//template struct std::atomic; -+//template struct std::atomic; - #endif - #endif - -@@ -70,23 +70,25 @@ - * - ****************************************************************************/ - --typedef std::atomic u_atomic_int32_t; -+typedef int32_t u_atomic_int32_t; - #define ATOMIC_INT32_T_INITIALIZER(val) ATOMIC_VAR_INIT(val) - - inline int32_t umtx_loadAcquire(u_atomic_int32_t &var) { -- return var.load(std::memory_order_acquire); -+ return var; - } - - inline void umtx_storeRelease(u_atomic_int32_t &var, int32_t val) { -- var.store(val, std::memory_order_release); -+ var = val; - } - - inline int32_t umtx_atomic_inc(u_atomic_int32_t *var) { -- return var->fetch_add(1) + 1; -+ *var += 1; -+ return *var; - } - - inline int32_t umtx_atomic_dec(u_atomic_int32_t *var) { -- return var->fetch_sub(1) - 1; -+ *var -= 1; -+ return *var; - } - - -@@ -231,17 +233,17 @@ - - // requirements for C++ BasicLockable, allows UMutex to work with std::lock_guard - void lock() { -- std::mutex *m = fMutex.load(std::memory_order_acquire); -+ /*std::mutex *m = fMutex.load(std::memory_order_acquire); - if (m == nullptr) { m = getMutex(); } -- m->lock(); -+ m->lock();*/ - } -- void unlock() { fMutex.load(std::memory_order_relaxed)->unlock(); } -+ void unlock() { /*fMutex.load(std::memory_order_relaxed)->unlock();*/ } - -- static void cleanup(); -+ static void cleanup() {}; - - private: -- alignas(std::mutex) char fStorage[sizeof(std::mutex)] {}; -- std::atomic fMutex { nullptr }; -+ //alignas(std::mutex) char fStorage[sizeof(std::mutex)] {}; -+ //std::atomic fMutex { nullptr }; - - /** All initialized UMutexes are kept in a linked list, so that they can be found, - * and the underlying std::mutex destructed, by u_cleanup(). -@@ -253,7 +255,7 @@ - * Initial fast check is inline, in lock(). The returned value may never - * be nullptr. - */ -- std::mutex *getMutex(); -+ //std::mutex *getMutex(); - }; - - -diff '--color=auto' -Naur icu-native/source/common/unifiedcache.cpp icu/source/common/unifiedcache.cpp ---- icu-native/source/common/unifiedcache.cpp 2021-07-13 00:45:56.917784151 +0200 -+++ icu/source/common/unifiedcache.cpp 2021-07-13 00:46:06.537784279 +0200 -@@ -13,15 +13,15 @@ - #include "unifiedcache.h" - - #include // For std::max() --#include -+//#include - - #include "uassert.h" - #include "uhash.h" - #include "ucln_cmn.h" - - static icu::UnifiedCache *gCache = NULL; --static std::mutex *gCacheMutex = nullptr; --static std::condition_variable *gInProgressValueAddedCond; -+//static std::mutex *gCacheMutex = nullptr; -+//static std::condition_variable *gInProgressValueAddedCond; - static icu::UInitOnce gCacheInitOnce = U_INITONCE_INITIALIZER; - - static const int32_t MAX_EVICT_ITERATIONS = 10; -@@ -34,10 +34,10 @@ - gCacheInitOnce.reset(); - delete gCache; - gCache = nullptr; -- gCacheMutex->~mutex(); -- gCacheMutex = nullptr; -- gInProgressValueAddedCond->~condition_variable(); -- gInProgressValueAddedCond = nullptr; -+ //gCacheMutex->~mutex(); -+ //gCacheMutex = nullptr; -+ //gInProgressValueAddedCond->~condition_variable(); -+ //gInProgressValueAddedCond = nullptr; - return TRUE; - } - U_CDECL_END -@@ -72,8 +72,8 @@ - ucln_common_registerCleanup( - UCLN_COMMON_UNIFIED_CACHE, unifiedcache_cleanup); - -- gCacheMutex = STATIC_NEW(std::mutex); -- gInProgressValueAddedCond = STATIC_NEW(std::condition_variable); -+ //gCacheMutex = STATIC_NEW(std::mutex); -+ //gInProgressValueAddedCond = STATIC_NEW(std::condition_variable); - gCache = new UnifiedCache(status); - if (gCache == NULL) { - status = U_MEMORY_ALLOCATION_ERROR; -@@ -135,28 +135,28 @@ - status = U_ILLEGAL_ARGUMENT_ERROR; - return; - } -- std::lock_guard lock(*gCacheMutex); -+ //std::lock_guard lock(*gCacheMutex); - fMaxUnused = count; - fMaxPercentageOfInUse = percentageOfInUseItems; - } - - int32_t UnifiedCache::unusedCount() const { -- std::lock_guard lock(*gCacheMutex); -+ //std::lock_guard lock(*gCacheMutex); - return uhash_count(fHashtable) - fNumValuesInUse; - } - - int64_t UnifiedCache::autoEvictedCount() const { -- std::lock_guard lock(*gCacheMutex); -+ //std::lock_guard lock(*gCacheMutex); - return fAutoEvictedCount; - } - - int32_t UnifiedCache::keyCount() const { -- std::lock_guard lock(*gCacheMutex); -+ //std::lock_guard lock(*gCacheMutex); - return uhash_count(fHashtable); - } - - void UnifiedCache::flush() const { -- std::lock_guard lock(*gCacheMutex); -+ //std::lock_guard lock(*gCacheMutex); - - // Use a loop in case cache items that are flushed held hard references to - // other cache items making those additional cache items eligible for -@@ -165,7 +165,7 @@ - } - - void UnifiedCache::handleUnreferencedObject() const { -- std::lock_guard lock(*gCacheMutex); -+ //std::lock_guard lock(*gCacheMutex); - --fNumValuesInUse; - _runEvictionSlice(); - } -@@ -184,7 +184,7 @@ - } - - void UnifiedCache::dumpContents() const { -- std::lock_guard lock(*gCacheMutex); -+ //std::lock_guard lock(*gCacheMutex); - _dumpContents(); - } - -@@ -224,7 +224,7 @@ - // Now all that should be left in the cache are entries that refer to - // each other and entries with hard references from outside the cache. - // Nothing we can do about these so proceed to wipe out the cache. -- std::lock_guard lock(*gCacheMutex); -+ //std::lock_guard lock(*gCacheMutex); - _flush(TRUE); - } - uhash_close(fHashtable); -@@ -325,7 +325,7 @@ - const CacheKeyBase &key, - const SharedObject *&value, - UErrorCode &status) const { -- std::lock_guard lock(*gCacheMutex); -+ //std::lock_guard lock(*gCacheMutex); - const UHashElement *element = uhash_find(fHashtable, &key); - if (element != NULL && !_inProgress(element)) { - _fetch(element, value, status); -@@ -350,14 +350,14 @@ - UErrorCode &status) const { - U_ASSERT(value == NULL); - U_ASSERT(status == U_ZERO_ERROR); -- std::unique_lock lock(*gCacheMutex); -+ //std::unique_lock lock(*gCacheMutex); - const UHashElement *element = uhash_find(fHashtable, &key); - - // If the hash table contains an inProgress placeholder entry for this key, - // this means that another thread is currently constructing the value object. - // Loop, waiting for that construction to complete. - while (element != NULL && _inProgress(element)) { -- gInProgressValueAddedCond->wait(lock); -+ //gInProgressValueAddedCond->wait(lock); - element = uhash_find(fHashtable, &key); - } - -@@ -430,7 +430,7 @@ - - // Tell waiting threads that we replace in-progress status with - // an error. -- gInProgressValueAddedCond->notify_all(); -+ //gInProgressValueAddedCond->notify_all(); - } - - void UnifiedCache::_fetch( diff --git a/shared/libpng-custom-cc.patch b/shared/libpng-custom-cc.patch new file mode 100644 index 00000000..9bf29de4 --- /dev/null +++ b/shared/libpng-custom-cc.patch @@ -0,0 +1,20 @@ +diff -Nur libpng-1.6.39-orig/scripts/genout.cmake.in libpng-1.6.39/scripts/genout.cmake.in +--- libpng-1.6.39-orig/scripts/genout.cmake.in 2022-11-20 22:53:23.000000000 +0100 ++++ libpng-1.6.39/scripts/genout.cmake.in 2024-06-09 18:38:38.953706845 +0200 +@@ -14,6 +14,7 @@ + + set(AWK "@AWK@") + set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@") ++set(CMAKE_C_COMPILER_ARG1 @CMAKE_C_COMPILER_ARG1@) + set(CMAKE_C_FLAGS @CMAKE_C_FLAGS@) + set(INCDIR "@CMAKE_CURRENT_BINARY_DIR@") + set(PNG_PREFIX "@PNG_PREFIX@") +@@ -58,7 +59,7 @@ + set(PNG_PREFIX_DEF "-DPNG_PREFIX=${PNG_PREFIX}") + endif() + +- execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" ++ execute_process(COMMAND "${CMAKE_C_COMPILER}" ${CMAKE_C_COMPILER_ARG1} "-E" + ${CMAKE_C_FLAGS} + ${PLATFORM_C_FLAGS} + "-I${SRCDIR}" diff --git a/shared/packages.ini b/shared/packages.ini index 37ac249a..775e1f92 100644 --- a/shared/packages.ini +++ b/shared/packages.ini @@ -4,11 +4,13 @@ directory = "${section}-${version}" [zlib] version = 1.3.1 url = "https://zlib.net/fossils/zlib-${version}.tar.gz" +arguments = "-DZLIB_BUILD_EXAMPLES=OFF" anitya_id = 5303 [libpng] version = 1.6.39 url = "https://download.sourceforge.net/libpng/libpng-${version}.tar.xz" +arguments = "-DPNG_SHARED=OFF -DPNG_EXECUTABLES=OFF -DPNG_TESTS=OFF" anitya_id = 15294 [freetype] diff --git a/shared/packages.sh b/shared/packages.sh index a2e23b28..d7206059 100644 --- a/shared/packages.sh +++ b/shared/packages.sh @@ -6,9 +6,11 @@ ZLIB_URL="https://zlib.net/fossils/zlib-1.3.1.tar.gz" +ZLIB_ARGS="-DZLIB_BUILD_EXAMPLES=OFF" ZLIB_DIR="zlib-1.3.1" LIBPNG_URL="https://download.sourceforge.net/libpng/libpng-1.6.39.tar.xz" +LIBPNG_ARGS="-DPNG_SHARED=OFF -DPNG_EXECUTABLES=OFF -DPNG_TESTS=OFF" LIBPNG_DIR="libpng-1.6.39" FREETYPE_URL="https://mirrors.sarata.com/non-gnu/freetype/freetype-2.13.2.tar.xz" diff --git a/shared/zlib-only-static.patch b/shared/zlib-only-static.patch new file mode 100644 index 00000000..60e3f8d3 --- /dev/null +++ b/shared/zlib-only-static.patch @@ -0,0 +1,54 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -123,9 +123,11 @@ set(ZLIB_SRCS + ) + + if(NOT MINGW) ++ if(BUILD_SHARED_LIBS) + set(ZLIB_DLL_SRCS + win32/zlib1.rc # If present will override custom build rule below. + ) ++ endif() + endif() + + # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION +@@ -146,15 +148,17 @@ if(MINGW) + -I ${CMAKE_CURRENT_BINARY_DIR} + -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj + -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) ++ if(BUILD_SHARED_LIBS) + set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) ++ endif() + endif(MINGW) + +-add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) ++add_library(zlib ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) + target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +-target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) ++if (BUILD_SHARED_LIBS) + set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) + set_target_properties(zlib PROPERTIES SOVERSION 1) ++endif() + + if(NOT CYGWIN) + # This property causes shared libraries on Linux to have the full version +@@ -169,7 +173,7 @@ endif() + + if(UNIX) + # On unix-like platforms the library is almost always called libz +- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z) ++ set_target_properties(zlib PROPERTIES OUTPUT_NAME z) + if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX)) + set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") + endif() +@@ -179,7 +183,7 @@ elseif(BUILD_SHARED_LIBS AND WIN32) + endif() + + if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) +- install(TARGETS zlib zlibstatic ++ install(TARGETS zlib + RUNTIME DESTINATION "${INSTALL_BIN_DIR}" + ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) diff --git a/switch/2_build_toolchain.sh b/switch/2_build_toolchain.sh index e81f4f60..28743f50 100755 --- a/switch/2_build_toolchain.sh +++ b/switch/2_build_toolchain.sh @@ -18,6 +18,10 @@ test_ccache if [[ -z $DEVKITPRO || ! -d "$DEVKITPRO/devkitA64" ]]; then errormsg "Setup devkitA64 properly. \$DEVKITPRO needs to be set." fi +export PATH=$DEVKITPRO/devkitA64/bin:$DEVKITPRO/tools/bin:$PATH + +# Extra tools available? +require_tool elf2nro if [ ! -f .patches-applied ]; then echo "Patching libraries" @@ -46,8 +50,6 @@ if [ ! -f .patches-applied ]; then patch -Np1 < $SCRIPT_DIR/../shared/extra/lhasa.patch ) - cp -rup icu icu-native - touch .patches-applied fi @@ -55,8 +57,6 @@ cd $WORKSPACE echo "Preparing toolchain" -export PATH=$DEVKITPRO/devkitA64/bin:$PATH - export PLATFORM_PREFIX=$WORKSPACE export TARGET_HOST=aarch64-none-elf unset PKG_CONFIG_PATH @@ -66,10 +66,6 @@ export MAKEFLAGS="-j${nproc:-2}" function set_build_flags { export CC="$TARGET_HOST-gcc" export CXX="$TARGET_HOST-g++" - if [ "$ENABLE_CCACHE" ]; then - export CC="ccache $CC" - export CXX="ccache $CXX" - fi ARCH_FLAGS="-march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec" export CFLAGS="-g0 -O2 $ARCH_FLAGS -ffunction-sections -fdata-sections" export CXXFLAGS="$CFLAGS" @@ -78,15 +74,15 @@ function set_build_flags { export LIBS="-lnx" export CMAKE_SYSTEM_NAME="Generic" - $SCRIPT_DIR/../shared/mk-meson-cross.sh switch > meson-cross.txt + make_meson_cross switch > meson-cross.txt } install_lib_icu_native set_build_flags -install_lib_zlib -install_lib $LIBPNG_DIR $LIBPNG_ARGS +install_lib_cmake $ZLIB_DIR $ZLIB_ARGS +install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF diff --git a/switch/3_cleanup.sh b/switch/3_cleanup.sh index ddeb8285..b9803ec9 100755 --- a/switch/3_cleanup.sh +++ b/switch/3_cleanup.sh @@ -7,6 +7,4 @@ headermsg "Cleaning up library build folders and other stuff..." cleanup -rm -f meson-cross.txt - echo " -> done" diff --git a/vita/2_build_toolchain.sh b/vita/2_build_toolchain.sh index 74ecdc68..c4d2bd25 100755 --- a/vita/2_build_toolchain.sh +++ b/vita/2_build_toolchain.sh @@ -31,7 +31,6 @@ if [ ! -f .patches-applied ]; then ) # Fix icu build - cp -rup icu icu-native patch -Np0 < $SCRIPT_DIR/icu-vita.patch # Disable vita2dlib jpeg dependency @@ -59,16 +58,12 @@ export MAKEFLAGS="-j${nproc:-2}" function set_build_flags { export CC="$TARGET_HOST-gcc" export CXX="$TARGET_HOST-g++" - if [ "$ENABLE_CCACHE" ]; then - export CC="ccache $CC" - export CXX="ccache $CXX" - fi export CFLAGS="-g0 -O2" export CXXFLAGS="$CFLAGS" export CPPFLAGS="-DPSP2" export CMAKE_SYSTEM_NAME="Generic" - $SCRIPT_DIR/../shared/mk-meson-cross.sh vita > $PLATFORM_PREFIX/meson-cross.txt + make_meson_cross vita > $PLATFORM_PREFIX/meson-cross.txt } function install_lib_vita2d() { @@ -84,8 +79,9 @@ function install_lib_vita2d() { install_lib_icu_native set_build_flags -install_lib_zlib -install_lib $LIBPNG_DIR $LIBPNG_ARGS + +install_lib_cmake $ZLIB_DIR $ZLIB_ARGS +install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF diff --git a/vita/3_cleanup.sh b/vita/3_cleanup.sh index fce27707..db428287 100755 --- a/vita/3_cleanup.sh +++ b/vita/3_cleanup.sh @@ -7,7 +7,6 @@ headermsg "Cleaning up library build folders and other stuff..." cleanup -rm -f meson-cross.txt rm -rf libvita2d/ echo " -> done" diff --git a/wii/2_build_toolchain.sh b/wii/2_build_toolchain.sh index c2231529..a84aaa60 100755 --- a/wii/2_build_toolchain.sh +++ b/wii/2_build_toolchain.sh @@ -16,6 +16,10 @@ test_ccache # Toolchain available? test_dkp "devkitPPC" +export PATH=$DEVKITPPC/bin:$DEVKITPRO/tools/bin:$PATH + +# Extra tools available? +require_tool elf2dol if [ ! -f .patches-applied ]; then echo "Patching libraries" @@ -23,9 +27,7 @@ if [ ! -f .patches-applied ]; then patches_common # Fix pixman - (cd $PIXMAN_DIR - patch -Np1 < $SCRIPT_DIR/../shared/extra/pixman-no-tls.patch - ) + patch -d $PIXMAN_DIR -Np1 < $SCRIPT_DIR/../shared/extra/pixman-no-tls.patch # Fix mpg123 (cd $MPG123_DIR @@ -41,14 +43,11 @@ if [ ! -f .patches-applied ]; then ) # Fix lhasa - (cd $LHASA_DIR - patch -Np1 < $SCRIPT_DIR/../shared/extra/lhasa.patch - ) + patch -d $LHASA_DIR -Np1 < $SCRIPT_DIR/../shared/extra/lhasa.patch # Fix icu build # Do not write objects, but source files perl -pi -e 's|#ifndef U_DISABLE_OBJ_CODE|#if 0 // U_DISABLE_OBJ_CODE|' icu/source/tools/toolutil/pkg_genc.h - cp -rup icu icu-native # Emit correct bigendian icudata header patch -Np0 < icu-pkg_genc.patch # Patch mutex support in @@ -61,8 +60,6 @@ cd $WORKSPACE echo "Preparing toolchain" -export PATH=$DEVKITPPC/bin:$PATH - export PLATFORM_PREFIX=$WORKSPACE export TARGET_HOST=powerpc-eabi unset PKG_CONFIG_PATH @@ -72,25 +69,21 @@ export MAKEFLAGS="-j${nproc:-2}" function set_build_flags { export CC="$TARGET_HOST-gcc" export CXX="$TARGET_HOST-g++" - if [ "$ENABLE_CCACHE" ]; then - export CC="ccache $CC" - export CXX="ccache $CXX" - fi export CFLAGS="-g0 -O2 -mcpu=750 -meabi -mhard-float -ffunction-sections -fdata-sections" export CXXFLAGS="$CFLAGS" export CPPFLAGS="-I$PLATFORM_PREFIX/include -DGEKKO -I$DEVKITPRO/libogc/include" export LDFLAGS="-L$PLATFORM_PREFIX/lib" export CMAKE_SYSTEM_NAME="Generic" - $SCRIPT_DIR/../shared/mk-meson-cross.sh ogc > meson-cross.txt + make_meson_cross ogc > meson-cross.txt } install_lib_icu_native set_build_flags -install_lib_zlib -install_lib $LIBPNG_DIR $LIBPNG_ARGS +install_lib_cmake $ZLIB_DIR $ZLIB_ARGS +install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON #install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS #install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF diff --git a/wii/3_cleanup.sh b/wii/3_cleanup.sh index ddeb8285..b9803ec9 100755 --- a/wii/3_cleanup.sh +++ b/wii/3_cleanup.sh @@ -7,6 +7,4 @@ headermsg "Cleaning up library build folders and other stuff..." cleanup -rm -f meson-cross.txt - echo " -> done" diff --git a/wii/icu-wii-mutex.patch b/wii/icu-wii-mutex.patch index 2730e5a7..1b31b812 100644 --- a/wii/icu-wii-mutex.patch +++ b/wii/icu-wii-mutex.patch @@ -1,12 +1,13 @@ -diff --color -Naur icu.orig icu ---- icu.orig/source/common/umutex.cpp 2023-10-27 23:53:02.000000000 +0200 -+++ icu/source/common/umutex.cpp 2023-12-02 04:50:47.142748510 +0100 -@@ -44,20 +44,26 @@ +diff --color -Nur icu.orig/source/common/umutex.cpp icu/source/common/umutex.cpp +--- icu.orig/source/common/umutex.cpp 2023-12-11 23:27:41.000000000 +0100 ++++ icu/source/common/umutex.cpp 2024-06-07 15:05:24.928001030 +0200 +@@ -44,20 +44,29 @@ *************************************************************************************************/ namespace { ++#ifdef __wii__ +mutex_t initMutex; -+#if 0 ++#else std::mutex *initMutex; std::condition_variable *initCondition; +#endif @@ -15,7 +16,7 @@ diff --color -Naur icu.orig icu // Used when ICU implementation code passes nullptr for the mutex pointer. UMutex globalMutex; -+#if 0 ++#ifndef __wii__ std::once_flag initFlag; std::once_flag *pInitFlag = &initFlag; +#endif @@ -24,35 +25,37 @@ diff --color -Naur icu.orig icu U_CDECL_BEGIN static UBool U_CALLCONV umtx_cleanup() { -+#if 0 ++#ifdef __wii__ ++ LWP_MutexDestroy(initMutex); ++#else initMutex->~mutex(); initCondition->~condition_variable(); UMutex::cleanup(); -@@ -66,17 +72,23 @@ +@@ -66,17 +75,23 @@ // Do not use this trick anywhere else in ICU; use umtx_initOnce, not std::call_once(). pInitFlag->~once_flag(); pInitFlag = new(&initFlag) std::once_flag(); +#endif -+ LWP_MutexDestroy(initMutex); return true; } static void U_CALLCONV umtx_init() { -+#if 0 ++#ifdef __wii__ ++ LWP_MutexInit(&initMutex, 0); ++#else initMutex = STATIC_NEW(std::mutex); initCondition = STATIC_NEW(std::condition_variable); ucln_common_registerCleanup(UCLN_COMMON_MUTEX, umtx_cleanup); +#endif -+ LWP_MutexInit(&initMutex, 0); } U_CDECL_END -+#if 0 ++#ifndef __wii__ std::mutex *UMutex::getMutex() { std::mutex *retPtr = fMutex.load(std::memory_order_acquire); if (retPtr == nullptr) { -@@ -106,6 +118,7 @@ +@@ -106,6 +121,7 @@ } gListHead = nullptr; } @@ -60,95 +63,96 @@ diff --color -Naur icu.orig icu U_CAPI void U_EXPORT2 -@@ -143,8 +156,11 @@ +@@ -143,8 +159,12 @@ // U_COMMON_API UBool U_EXPORT2 umtx_initImplPreInit(UInitOnce &uio) { ++#ifdef __wii__ + LWP_MutexLock(initMutex); -+#if 0 ++#else std::call_once(*pInitFlag, umtx_init); std::unique_lock lock(*initMutex); +#endif if (umtx_loadAcquire(uio.fState) == 0) { umtx_storeRelease(uio.fState, 1); return true; // Caller will next call the init function. -@@ -152,7 +168,7 @@ +@@ -152,7 +172,9 @@ while (umtx_loadAcquire(uio.fState) == 1) { // Another thread is currently running the initialization. // Wait until it completes. -- initCondition->wait(lock); -+// initCondition->wait(lock); ++#ifndef __wii__ + initCondition->wait(lock); ++#endif } U_ASSERT(uio.fState == 2); return false; -@@ -168,11 +184,15 @@ +@@ -168,11 +190,16 @@ U_COMMON_API void U_EXPORT2 umtx_initImplPostInit(UInitOnce &uio) { -+#if 0 ++#ifdef __wii__ ++ umtx_storeRelease(uio.fState, 2); ++ LWP_MutexUnlock(initMutex); ++#else { std::unique_lock lock(*initMutex); umtx_storeRelease(uio.fState, 2); } initCondition->notify_all(); +#endif -+ umtx_storeRelease(uio.fState, 2); -+ LWP_MutexUnlock(initMutex); } U_NAMESPACE_END -diff --color -Naur icu.orig icu ---- icu.orig/source/common/umutex.h 2023-10-27 23:53:02.000000000 +0200 -+++ icu/source/common/umutex.h 2023-12-02 04:53:38.320939984 +0100 -@@ -25,6 +25,8 @@ +diff --color -Nur icu.orig/source/common/umutex.h icu/source/common/umutex.h +--- icu.orig/source/common/umutex.h 2023-12-11 23:27:41.000000000 +0100 ++++ icu/source/common/umutex.h 2024-06-07 15:11:45.936084300 +0200 +@@ -25,6 +25,10 @@ #include #include -+#include ++#ifdef __wii__ ++ #include ++#endif + #include "unicode/utypes.h" #include "unicode/uclean.h" #include "unicode/uobject.h" -@@ -218,8 +220,10 @@ +@@ -218,8 +222,13 @@ class U_COMMON_API UMutex { public: -- UMUTEX_CONSTEXPR UMutex() {} -- ~UMutex() = default; -+ //UMUTEX_CONSTEXPR UMutex() {} -+ //~UMutex() = default; -+ UMutex() { LWP_MutexInit(&mutex, 0); } ++#ifdef __wii__ ++ UMUTEX_CONSTEXPR UMutex() { LWP_MutexInit(&mutex, 0); } + ~UMutex() { LWP_MutexDestroy(mutex); } ++#else + UMUTEX_CONSTEXPR UMutex() {} + ~UMutex() = default; ++#endif UMutex(const UMutex &other) = delete; UMutex &operator =(const UMutex &other) = delete; -@@ -227,12 +231,24 @@ +@@ -227,10 +236,20 @@ // requirements for C++ BasicLockable, allows UMutex to work with std::lock_guard void lock() { -+#if 0 ++#ifdef __wii__ ++ LWP_MutexLock(mutex); ++#else std::mutex *m = fMutex.load(std::memory_order_acquire); if (m == nullptr) { m = getMutex(); } m->lock(); +#endif -+ LWP_MutexLock(mutex); -+ } -+ void unlock() { -+#if 0 -+ fMutex.load(std::memory_order_relaxed)->unlock(); -+#endif -+ LWP_MutexUnlock(mutex); } -- void unlock() { fMutex.load(std::memory_order_relaxed)->unlock(); } - ++#ifdef __wii__ ++ void unlock() { LWP_MutexUnlock(mutex); } ++ +private: + mutex_t mutex; -+ -+#if 0 - static void cleanup(); ++#else + void unlock() { fMutex.load(std::memory_order_relaxed)->unlock(); } - private: -@@ -250,6 +266,7 @@ + static void cleanup(); +@@ -250,6 +269,7 @@ * be nullptr. */ std::mutex *getMutex(); diff --git a/wiiu/2_build_toolchain.sh b/wiiu/2_build_toolchain.sh index 9d92d39b..9d810f63 100755 --- a/wiiu/2_build_toolchain.sh +++ b/wiiu/2_build_toolchain.sh @@ -16,6 +16,10 @@ test_ccache # Toolchain available? test_dkp "devkitPPC" +export PATH=$DEVKITPPC/bin:$DEVKITPRO/tools/bin:$PATH + +# Extra tools available? +require_tool wuhbtool if [ ! -f .patches-applied ]; then echo "Patching libraries" @@ -40,7 +44,6 @@ if [ ! -f .patches-applied ]; then # Fix icu build # Do not write objects, but source files perl -pi -e 's|#ifndef U_DISABLE_OBJ_CODE.*|#if 0 // U_DISABLE_OBJ_CODE|' icu/source/tools/toolutil/pkg_genc.h - cp -rup icu icu-native # Emit correct bigendian icudata header patch -Np0 < icu-pkg_genc.patch @@ -51,8 +54,6 @@ cd $WORKSPACE echo "Preparing toolchain" -export PATH=$DEVKITPPC/bin:$PATH - export PLATFORM_PREFIX=$WORKSPACE export TARGET_HOST=powerpc-eabi unset PKG_CONFIG_PATH @@ -62,10 +63,6 @@ export MAKEFLAGS="-j${nproc:-2}" function set_build_flags { export CC="$TARGET_HOST-gcc" export CXX="$TARGET_HOST-g++" - if [ "$ENABLE_CCACHE" ]; then - export CC="ccache $CC" - export CXX="ccache $CXX" - fi export CFLAGS="-g0 -O2 -mcpu=750 -meabi -mhard-float -ffunction-sections -fdata-sections" export CXXFLAGS="$CFLAGS" export CPPFLAGS="-DESPRESSO -D__WIIU__ -D__WUT__ -I$PLATFORM_PREFIX/include -I$DEVKITPRO/wut/include" @@ -74,15 +71,15 @@ function set_build_flags { export CMAKE_SYSTEM_NAME="Generic" export CMAKE_EXTRA_ARGS="-DCMAKE_C_BYTE_ORDER=BIG_ENDIAN" - $SCRIPT_DIR/../shared/mk-meson-cross.sh ogc > meson-cross.txt + make_meson_cross ogc > meson-cross.txt } install_lib_icu_native set_build_flags -install_lib_zlib -install_lib $LIBPNG_DIR $LIBPNG_ARGS +install_lib_cmake $ZLIB_DIR $ZLIB_ARGS +install_lib_cmake $LIBPNG_DIR $LIBPNG_ARGS install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=ON #install_lib_meson $HARFBUZZ_DIR $HARFBUZZ_ARGS #install_lib_cmake $FREETYPE_DIR $FREETYPE_ARGS -DFT_DISABLE_HARFBUZZ=OFF diff --git a/wiiu/3_cleanup.sh b/wiiu/3_cleanup.sh index ddeb8285..b9803ec9 100755 --- a/wiiu/3_cleanup.sh +++ b/wiiu/3_cleanup.sh @@ -7,6 +7,4 @@ headermsg "Cleaning up library build folders and other stuff..." cleanup -rm -f meson-cross.txt - echo " -> done"