<commit_before>#!/bin/sh

pkg_configure() {
    [ "$pkg_source_dir" ] || return 0

    local IFS="$jagen_IFS" S="$jagen_FS" A= MA="$(cat "${jagen_build_args_file:?}" 2>&-)"
    local build_profile=$(pkg_get_build_profile)
    local cc_prefix= cxx_prefix= gnu_default_cflags= 
    local toolchain_file="$pkg_build_dir/toolchain.cmake"
    local cmake_config=RELEASE

    # Prepend default toolchain prefix only if pathnames do not contain '/'.
    if [ "${pkg_build_cc#*/}" = "$pkg_build_cc" ]; then
        cc_prefix="$pkg_toolchain_prefix"
    fi
    if [ "${pkg_build_cxx#*/}" = "$pkg_build_cxx" ]; then
        cxx_prefix="$pkg_toolchain_prefix"
    fi

    case $pkg_build_type in
        gnu)
            if [ "$pkg_build_cc" ]; then
                export CC="${cc_prefix}${pkg_build_cc}"
            fi
            if [ "$pkg_build_cxx" ]; then
                export CXX="${cxx_prefix}${pkg_build_cxx}"
            fi

            # Jagen sets C(XX)FLAGS in the environment. This will override
            # Autoconf's default '-g -O2' even if the values ended up empty.
            # We expicitly add some of the defaults back as appropriate.

            case $build_profile in
                release)
                    gnu_default_cflags='-O2' ;;
                debug)
                    gnu_default_cflags='-g' ;;
                release_with_debug)
                    gnu_default_cflags='-g -O1' ;;
            esac

            CFLAGS="${CFLAGS:+$CFLAGS }${pkg_build_cflags:-$gnu_default_cflags}"
            CXXFLAGS="${CXXFLAGS:+$CXXFLAGS }${pkg_build_cxxflags:-$gnu_default_cflags}"
            LDFLAGS="${LDFLAGS:+$LDFLAGS }${pkg_build_ldflags}"

            if [ "$pkg_install_root" ]; then
                LDFLAGS="$LDFLAGS -Wl,-rpath-link=$pkg_install_dir/lib"
            fi

            if [ "$pkg_build_configure_needs_install_dir" ]; then
                CFLAGS="$CFLAGS -I$pkg_install_dir/include"
                LDFLAGS="$LDFLAGS -L$pkg_install_dir/lib"
            fi

            pkg_run "${pkg_build_configure_file:-$pkg_source_dir/configure}" $A \
                ${pkg_build_system:+--host="$pkg_build_system"} \
                --prefix="$pkg_install_prefix" \
                --disable-dependency-tracking \
                ${pkg_install_root:+--with-sysroot="$pkg_install_root"} \
                $pkg_build_options "$@" $MA

            # Never add RPATH to generated binaries because libtool uses
            # various heuristics to determine when to add it, some Linux
            # distributions patch it to adjust a list of 'system' paths, but
            # generally things seems to work because everyone install to
            # /usr/local/lib or /usr/lib or lib64 whatever and these are
            # handled specially. Embedded systems often have different
            # conventions and naming schemes, libtool not always does the
            # 'right' thing and you might end up with a mixed bag of libraries
            # some having RPATH and some not.

            if [ -x ./libtool ]; then
                pkg_run sed -i 's|\(hardcode_into_libs\)=yes|\1=no|g' \
                    "./libtool"
            fi

            ;;
        cmake)
            if ! [ -f "$pkg_source_dir/CMakeLists.txt" ]; then
                die "CMake build type specified but no CMakeLists.txt was found in $pkg_source_dir"
            fi

            if [ "$pkg_build_cmake_module_path" ]; then
                A="$A$S-DCMAKE_MODULE_PATH=$pkg_build_cmake_module_path"
            fi

            if [ "$pkg_build_cmake_toolchain_file" ]; then
                A="$A$S-DCMAKE_TOOLCHAIN_FILE=$pkg_build_cmake_toolchain_file"
            else
                A="$A$S-DCMAKE_TOOLCHAIN_FILE=$toolchain_file"
                : >"$toolchain_file"
                echo "set(CMAKE_C_COMPILER \"${cc_prefix}${pkg_build_cc:-gcc}\")" >> "$toolchain_file"
                echo "set(CMAKE_CXX_COMPILER \"${cxx_prefix}${pkg_build_cxx:-g++}\")" >> "$toolchain_file"
                if [ "$pkg_config" = "target" ]; then
                    echo "set(CMAKE_SYSTEM_NAME \"Linux\")" >>"$toolchain_file"<commit_msg>Set CMAKE_SYSTEM_PROCESSOR when cross-compiling<commit_after>#!/bin/sh

pkg_configure() {
    [ "$pkg_source_dir" ] || return 0

    local IFS="$jagen_IFS" S="$jagen_FS" A= MA="$(cat "${jagen_build_args_file:?}" 2>&-)"
    local build_profile=$(pkg_get_build_profile)
    local build_cpu="${pkg_build_cpu:-$pkg_build_arch}"
    local cc_prefix= cxx_prefix= gnu_default_cflags= 
    local toolchain_file="$pkg_build_dir/toolchain.cmake"
    local cmake_config=RELEASE

    # Prepend default toolchain prefix only if pathnames do not contain '/'.
    if [ "${pkg_build_cc#*/}" = "$pkg_build_cc" ]; then
        cc_prefix="$pkg_toolchain_prefix"
    fi
    if [ "${pkg_build_cxx#*/}" = "$pkg_build_cxx" ]; then
        cxx_prefix="$pkg_toolchain_prefix"
    fi

    case $pkg_build_type in
        gnu)
            if [ "$pkg_build_cc" ]; then
                export CC="${cc_prefix}${pkg_build_cc}"
            fi
            if [ "$pkg_build_cxx" ]; then
                export CXX="${cxx_prefix}${pkg_build_cxx}"
            fi

            # Jagen sets C(XX)FLAGS in the environment. This will override
            # Autoconf's default '-g -O2' even if the values ended up empty.
            # We expicitly add some of the defaults back as appropriate.

            case $build_profile in
                release)
                    gnu_default_cflags='-O2' ;;
                debug)
                    gnu_default_cflags='-g' ;;
                release_with_debug)
                    gnu_default_cflags='-g -O1' ;;
            esac

            CFLAGS="${CFLAGS:+$CFLAGS }${pkg_build_cflags:-$gnu_default_cflags}"
            CXXFLAGS="${CXXFLAGS:+$CXXFLAGS }${pkg_build_cxxflags:-$gnu_default_cflags}"
            LDFLAGS="${LDFLAGS:+$LDFLAGS }${pkg_build_ldflags}"

            if [ "$pkg_install_root" ]; then
                LDFLAGS="$LDFLAGS -Wl,-rpath-link=$pkg_install_dir/lib"
            fi

            if [ "$pkg_build_configure_needs_install_dir" ]; then
                CFLAGS="$CFLAGS -I$pkg_install_dir/include"
                LDFLAGS="$LDFLAGS -L$pkg_install_dir/lib"
            fi

            pkg_run "${pkg_build_configure_file:-$pkg_source_dir/configure}" $A \
                ${pkg_build_system:+--host="$pkg_build_system"} \
                --prefix="$pkg_install_prefix" \
                --disable-dependency-tracking \
                ${pkg_install_root:+--with-sysroot="$pkg_install_root"} \
                $pkg_build_options "$@" $MA

            # Never add RPATH to generated binaries because libtool uses
            # various heuristics to determine when to add it, some Linux
            # distributions patch it to adjust a list of 'system' paths, but
            # generally things seems to work because everyone install to
            # /usr/local/lib or /usr/lib or lib64 whatever and these are
            # handled specially. Embedded systems often have different
            # conventions and naming schemes, libtool not always does the
            # 'right' thing and you might end up with a mixed bag of libraries
            # some having RPATH and some not.

            if [ -x ./libtool ]; then
                pkg_run sed -i 's|\(hardcode_into_libs\)=yes|\1=no|g' \
                    "./libtool"
            fi

            ;;
        cmake)
            if ! [ -f "$pkg_source_dir/CMakeLists.txt" ]; then
                die "CMake build type specified but no CMakeLists.txt was found in $pkg_source_dir"
            fi

            if [ "$pkg_build_cmake_module_path" ]; then
                A="$A$S-DCMAKE_MODULE_PATH=$pkg_build_cmake_module_path"
            fi

            if [ "$pkg_build_cmake_toolchain_file" ]; then
                A="$A$S-DCMAKE_TOOLCHAIN_FILE=$pkg_build_cmake_toolchain_file"
            else
                A="$A$S-DCMAKE_TOOLCHAIN_FILE=$toolchain_file"
                : >"$toolchain_file"
                echo "set(CMAKE_C_COMPILER \"${cc_prefix}${pkg_build_cc:-gcc}\")" >> "$toolchain_file"
                echo "set(CMAKE_CXX_COMPILER \"${cxx_prefix}${pkg_build_cxx:-g++}\")" >> "$toolchain_file"
                if [ "$pkg_config" = "target" ]; then
                    echo "set(CMAKE_SYSTEM_NAME \"Linux\")" >>"$toolchain_file"
                    if [ "$build_cpu" ]; then
                        echo "set(CMAKE_SYSTEM_PROCESSOR \"$build_cpu\")" >>"$toolchain_file"
                    fi
{'fraction_non_alphanumeric': 0.11417831551744391, 'fraction_numerical': 0.001879478444731587, 'mean_word_length': 2.0063559322033897, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1407966', 'n_tokens_mistral': 2697, 'n_tokens_neox': 2513, 'n_words': 550}