diff --git a/recipes/libs/expat/recipe.toml b/recipes/libs/expat/recipe.toml index c88685e4d..37f15adb0 100644 --- a/recipes/libs/expat/recipe.toml +++ b/recipes/libs/expat/recipe.toml @@ -9,12 +9,8 @@ autotools_recursive_regenerate [build] template = "custom" script = """ -DYNAMIC_INIT -COOKBOOK_CONFIGURE_FLAGS=( - --host="${GNU_TARGET}" - --prefix="/usr" - --enable-shared - --enable-static +DYNAMIC_STATIC_INIT +COOKBOOK_CONFIGURE_FLAGS+=( --without-docbook --without-examples --without-tests diff --git a/recipes/libs/libffi/recipe.toml b/recipes/libs/libffi/recipe.toml index 1cc1701e3..8851cfcea 100644 --- a/recipes/libs/libffi/recipe.toml +++ b/recipes/libs/libffi/recipe.toml @@ -13,12 +13,6 @@ autotools_recursive_regenerate -I$(realpath ./m4) [build] template = "custom" script = """ -DYNAMIC_INIT -COOKBOOK_CONFIGURE_FLAGS=( - --host="${GNU_TARGET}" - --prefix="/usr" - --enable-shared - --enable-static -) +DYNAMIC_STATIC_INIT cookbook_configure """ \ No newline at end of file diff --git a/recipes/libs/libiconv/recipe.toml b/recipes/libs/libiconv/recipe.toml index 43db90f75..bce6869a8 100644 --- a/recipes/libs/libiconv/recipe.toml +++ b/recipes/libs/libiconv/recipe.toml @@ -19,12 +19,8 @@ autotools_recursive_regenerate -I$(realpath ./m4) -I$(realpath ./srcm4) [build] template = "custom" script = """ -DYNAMIC_INIT -COOKBOOK_CONFIGURE_FLAGS=( - --host="${GNU_TARGET}" - --prefix="/usr" - --enable-shared - --enable-static +DYNAMIC_STATIC_INIT +COOKBOOK_CONFIGURE_FLAGS+=( ac_cv_have_decl_program_invocation_name=no ) cookbook_configure diff --git a/recipes/libs/libpng/recipe.toml b/recipes/libs/libpng/recipe.toml index d516a8571..cd413dafd 100644 --- a/recipes/libs/libpng/recipe.toml +++ b/recipes/libs/libpng/recipe.toml @@ -12,12 +12,6 @@ autotools_recursive_regenerate template = "custom" dependencies = ["zlib"] script = """ -DYNAMIC_INIT -COOKBOOK_CONFIGURE_FLAGS=( - --host="${GNU_TARGET}" - --prefix="/usr" - --enable-shared - --enable-static -) +DYNAMIC_STATIC_INIT cookbook_configure """ diff --git a/recipes/libs/libxml2/recipe.toml b/recipes/libs/libxml2/recipe.toml index 4e4b936da..f37f42966 100644 --- a/recipes/libs/libxml2/recipe.toml +++ b/recipes/libs/libxml2/recipe.toml @@ -13,12 +13,8 @@ dependencies = [ "zlib" ] script = """ -DYNAMIC_INIT -COOKBOOK_CONFIGURE_FLAGS=( - --host="${GNU_TARGET}" - --prefix="/usr" - --enable-shared - --enable-static +DYNAMIC_STATIC_INIT +COOKBOOK_CONFIGURE_FLAGS+=( --without-python ) cookbook_configure diff --git a/recipes/libs/pcre/recipe.toml b/recipes/libs/pcre/recipe.toml index bf12da075..773c8f48c 100644 --- a/recipes/libs/pcre/recipe.toml +++ b/recipes/libs/pcre/recipe.toml @@ -12,12 +12,6 @@ patches = [ [build] template = "custom" script = """ -DYNAMIC_INIT -COOKBOOK_CONFIGURE_FLAGS=( - --host="${GNU_TARGET}" - --prefix="/usr" - --enable-shared - --enable-static -) +DYNAMIC_STATIC_INIT cookbook_configure """ diff --git a/recipes/libs/pcre2/recipe.toml b/recipes/libs/pcre2/recipe.toml index 176f992ce..09c4d86b0 100644 --- a/recipes/libs/pcre2/recipe.toml +++ b/recipes/libs/pcre2/recipe.toml @@ -9,12 +9,6 @@ autotools_recursive_regenerate [build] template = "custom" script = """ -DYNAMIC_INIT -COOKBOOK_CONFIGURE_FLAGS=( - --host="${GNU_TARGET}" - --prefix="/usr" - --enable-shared - --enable-static -) +DYNAMIC_STATIC_INIT cookbook_configure """ diff --git a/recipes/libs/zlib/recipe.toml b/recipes/libs/zlib/recipe.toml index 865247ba4..626018c72 100644 --- a/recipes/libs/zlib/recipe.toml +++ b/recipes/libs/zlib/recipe.toml @@ -6,9 +6,20 @@ blake3 = "ec1abc6f672a7a6ee6f49ba544cc9529f73121b478310473be44fee22a140ebf" template = "custom" script = """ DYNAMIC_INIT +COOKBOOK_CONFIGURE_FLAGS=(--prefix="/usr") +if [ "${COOKBOOK_DYNAMIC}" == "1" ] +then + COOKBOOK_CONFIGURE_FLAGS+=(--shared) +else + COOKBOOK_CONFIGURE_FLAGS+=(--static) +fi # See https://stackoverflow.com/questions/21396988/zlib-build-not-configuring-properly-with-cross-compiler-ignores-ar. -CHOST="${TARGET}" "${COOKBOOK_CONFIGURE}" --prefix="/usr" +env CHOST="${TARGET}" "${COOKBOOK_CONFIGURE}" "${COOKBOOK_CONFIGURE_FLAGS[@]}" "${COOKBOOK_MAKE}" -j "$(nproc)" "${COOKBOOK_MAKE}" install DESTDIR="${COOKBOOK_STAGE}" -patchelf --set-soname 'libz.so.1.3' "${COOKBOOK_STAGE}/usr/lib/libz.so.1.3" +solib="${COOKBOOK_STAGE}/usr/lib/libz.so.1.3" +if [ -e "${solib}" ] +then + patchelf --set-soname 'libz.so.1.3' "${solib}" +fi """ \ No newline at end of file diff --git a/recipes/tools/gettext/recipe.toml b/recipes/tools/gettext/recipe.toml index e30751579..276e4e83d 100644 --- a/recipes/tools/gettext/recipe.toml +++ b/recipes/tools/gettext/recipe.toml @@ -23,10 +23,8 @@ dependencies = [ "libiconv" ] script = """ -DYNAMIC_INIT +DYNAMIC_STATIC_INIT COOKBOOK_CONFIGURE_FLAGS+=( - --enable-static - --enable-shared ac_cv_have_decl_program_invocation_name=no gt_cv_locale_fr=false gt_cv_locale_fr_utf8=false diff --git a/recipes/tools/xz/recipe.toml b/recipes/tools/xz/recipe.toml index 339b5102a..51ca7e47b 100644 --- a/recipes/tools/xz/recipe.toml +++ b/recipes/tools/xz/recipe.toml @@ -9,16 +9,12 @@ autotools_recursive_regenerate [build] template = "custom" script = """ -DYNAMIC_INIT -COOKBOOK_CONFIGURE_FLAGS=( - --host="${GNU_TARGET}" - --prefix="/usr" +DYNAMIC_STATIC_INIT +COOKBOOK_CONFIGURE_FLAGS+=( --disable-lzmadec --disable-lzmainfo --disable-xz --disable-xzdec - --enable-shared=yes - --enable-static=yes --enable-threads=no ) cookbook_configure diff --git a/src/bin/cook.rs b/src/bin/cook.rs index 7b3f291ab..365e7315e 100644 --- a/src/bin/cook.rs +++ b/src/bin/cook.rs @@ -203,29 +203,66 @@ fn serialize_and_write(file_path: &Path, content: &T) -> Result<() } static SHARED_PRESCRIPT: &str = r#" +# Build dynamically function DYNAMIC_INIT { - COOKBOOK_AUTORECONF="autoreconf" - autotools_recursive_regenerate() { - for f in $(find . -name configure.ac -o -name configure.in -type f | sort); do - echo "* autotools regen in '$(dirname $f)'..." - ( cd "$(dirname "$f")" && "${COOKBOOK_AUTORECONF}" -fvi "$@" -I${COOKBOOK_HOST_SYSROOT}/share/aclocal ) - done - } + COOKBOOK_AUTORECONF="autoreconf" + autotools_recursive_regenerate() { + for f in $(find . -name configure.ac -o -name configure.in -type f | sort); do + echo "* autotools regen in '$(dirname $f)'..." + ( cd "$(dirname "$f")" && "${COOKBOOK_AUTORECONF}" -fvi "$@" -I${COOKBOOK_HOST_SYSROOT}/share/aclocal ) + done + } - echo "DEBUG: Program is being compiled dynamically." + if [ "${TARGET}" != "x86_64-unknown-redox" ] + then + echo "WARN: ${TARGET} does not support dynamic linking." >&2 + return + fi - COOKBOOK_CONFIGURE_FLAGS=( - --host="${GNU_TARGET}" - --prefix="/usr" - --enable-shared - --disable-static - ) + echo "DEBUG: Program is being compiled dynamically." - # TODO: check paths for spaces - export LDFLAGS="-L${COOKBOOK_SYSROOT}/lib" - export LDFLAGS="-Wl,-rpath-link,${COOKBOOK_SYSROOT}/lib $LDFLAGS" - export RUSTFLAGS="-C target-feature=-crt-static" - export COOKBOOK_DYNAMIC=1 + COOKBOOK_CONFIGURE_FLAGS=( + --host="${GNU_TARGET}" + --prefix="/usr" + --enable-shared + --disable-static + ) + + COOKBOOK_MESON_FLAGS=( + --buildtype release + --wrap-mode nofallback + --strip + -Ddefault_library=shared + -Dprefix=/usr + ) + + # TODO: check paths for spaces + export LDFLAGS="-L${COOKBOOK_SYSROOT}/lib" + export LDFLAGS="-Wl,-rpath-link,${COOKBOOK_SYSROOT}/lib $LDFLAGS" + export RUSTFLAGS="-C target-feature=-crt-static" + export COOKBOOK_DYNAMIC=1 +} + +# Build both dynamically and statically +function DYNAMIC_STATIC_INIT { + DYNAMIC_INIT + if [ "${COOKBOOK_DYNAMIC}" == "1" ] + then + COOKBOOK_CONFIGURE_FLAGS=( + --host="${GNU_TARGET}" + --prefix="/usr" + --enable-shared + --enable-static + ) + + COOKBOOK_MESON_FLAGS=( + --buildtype release + --wrap-mode nofallback + --strip + -Ddefault_library=both + -Dprefix=/usr + ) + fi } function GNU_CONFIG_GET { @@ -938,6 +975,7 @@ COOKBOOK_MESON_FLAGS=( --buildtype release --wrap-mode nofallback --strip + -Ddefault_library=static -Dprefix=/usr ) function cookbook_meson {