<commit_before>#!/bin/bash
#
# Compiler detection
# Sets:
#  CC, CXX, CFLAGS, CPPFLAGS, LDFLAGS, ARFLAGS, PKG_CONFIG, INSTALL, MBITS


mkl_require host

function checks {

    # C compiler
    mkl_meta_set "ccenv" "name" "C compiler from CC env"
    if ! mkl_command_check "ccenv" "WITH_CC" cont "$CC --version"; then
        if mkl_command_check "gcc" "WITH_GCC" cont "gcc --version"; then
            CC=gcc
        elif mkl_command_check "clang" "WITH_CLANG" cont "clang --version"; then
            CC=clang
        elif mkl_command_check "cc" "WITH_CC" fail "cc --version"; then
            CC=cc
        fi
    fi
    export CC="${CC}"
    mkl_mkvar_set CC CC "$CC"

    if [[ $MKL_CC_WANT_CXX == 1 ]]; then
    # C++ compiler
        mkl_meta_set "cxxenv" "name" "C++ compiler from CXX env"
        if ! mkl_command_check "cxxenv" "WITH_CXX" cont "$CXX --version" ; then
            mkl_meta_set "gxx" "name" "C++ compiler (g++)"
            mkl_meta_set "clangxx" "name" "C++ compiler (clang++)"
            mkl_meta_set "cxx" "name" "C++ compiler (c++)"
            if mkl_command_check "gxx" "WITH_GXX" cont "g++ --version"; then
                CXX=g++
            elif mkl_command_check "clangxx" "WITH_CLANGXX" cont "clang++ --version"; then
                CXX=clang++
            elif mkl_command_check "cxx" "WITH_CXX" fail "c++ --version"; then
                CXX=c++
            fi
        fi
        export CXX="${CXX}"
        mkl_mkvar_set "CXX" CXX $CXX
    fi

    # Handle machine bits, if specified.
    if [[ ! -z "$MBITS" ]]; then
	mkl_meta_set mbits_m name "mbits compiler flag (-m$MBITS)"
	if mkl_compile_check mbits_m "" ignore CC "-m$MBITS"; then
	    mkl_mkvar_append CPPFLAGS CPPFLAGS "-m$MBITS"
	    mkl_mkvar_append LDFLAGS LDFLAGS "-m$MBITS"
	fi
	if [[ $MBITS == 64 && $MKL_DISTRO == "SunOS" ]]; then
	    # Turn on 64-bit archives on SunOS
	    mkl_mkvar_append ARFLAGS ARFLAGS "S"
	fi
    fi

    # Provide prefix and checks for various other build tools.
    local t=
    for t in LD:ld NM:nm OBJDUMP:objdump STRIP:strip ; do
        local tenv=${t%:*}
        t=${t#*:}
	local tval="${!tenv}"

        [[ -z $tval ]] && tval="$t"

        if mkl_prog_check "$t" "" disable "$tval" ; then
            if [[ $tval != ${!tenv} ]]; then
		export "$tenv"="$tval"
	    fi
            mkl_mkvar_set $tenv $tenv "$tval"
        fi
    done

    # Compiler and linker flags
    [[ ! -z $CFLAGS ]]   && mkl_mkvar_set "CFLAGS" "CFLAGS" "$CFLAGS"
    [[ ! -z $CPPFLAGS ]] && mkl_mkvar_set "CPPFLAGS" "CPPFLAGS" "$CPPFLAGS"
    [[ ! -z $CXXFLAGS ]] && mkl_mkvar_set "CXXFLAGS" "CXXFLAGS" "$CXXFLAGS"
    [[ ! -z $LDFLAGS ]]  && mkl_mkvar_set "LDFLAGS" "LDFLAGS" "$LDFLAGS"
    [[ ! -z $ARFLAGS ]]  && mkl_mkvar_set "ARFLAGS" "ARFLAGS" "$ARFLAGS"

    mkl_mkvar_append CPPFLAGS CPPFLAGS "-g"


    # pkg-config
    if [ -z "$PKG_CONFIG" ]; then
        PKG_CONFIG=pkg-config
    fi

    if mkl_command_check "pkgconfig" "WITH_PKGCONFIG" cont "$PKG_CONFIG --version"; then
        export PKG_CONFIG
    fi<commit_msg>Fail on failing --mbits, honour ARFLAGS, and use -gstrict-dwarf on OSX (for static linking on osx 10.9)<commit_after>#!/bin/bash
#
# Compiler detection
# Sets:
#  CC, CXX, CFLAGS, CPPFLAGS, LDFLAGS, ARFLAGS, PKG_CONFIG, INSTALL, MBITS


mkl_require host

function checks {

    # C compiler
    mkl_meta_set "ccenv" "name" "C compiler from CC env"
    if ! mkl_command_check "ccenv" "WITH_CC" cont "$CC --version"; then
        if mkl_command_check "gcc" "WITH_GCC" cont "gcc --version"; then
            CC=gcc
        elif mkl_command_check "clang" "WITH_CLANG" cont "clang --version"; then
            CC=clang
        elif mkl_command_check "cc" "WITH_CC" fail "cc --version"; then
            CC=cc
        fi
    fi
    export CC="${CC}"
    mkl_mkvar_set CC CC "$CC"

    if [[ $MKL_CC_WANT_CXX == 1 ]]; then
    # C++ compiler
        mkl_meta_set "cxxenv" "name" "C++ compiler from CXX env"
        if ! mkl_command_check "cxxenv" "WITH_CXX" cont "$CXX --version" ; then
            mkl_meta_set "gxx" "name" "C++ compiler (g++)"
            mkl_meta_set "clangxx" "name" "C++ compiler (clang++)"
            mkl_meta_set "cxx" "name" "C++ compiler (c++)"
            if mkl_command_check "gxx" "WITH_GXX" cont "g++ --version"; then
                CXX=g++
            elif mkl_command_check "clangxx" "WITH_CLANGXX" cont "clang++ --version"; then
                CXX=clang++
            elif mkl_command_check "cxx" "WITH_CXX" fail "c++ --version"; then
                CXX=c++
            fi
        fi
        export CXX="${CXX}"
        mkl_mkvar_set "CXX" CXX $CXX
    fi

    # Handle machine bits, if specified.
    if [[ ! -z "$MBITS" ]]; then
	mkl_meta_set mbits_m name "mbits compiler flag (-m$MBITS)"
	if mkl_compile_check mbits_m "" fail CC "-m$MBITS"; then
	    mkl_mkvar_append CPPFLAGS CPPFLAGS "-m$MBITS"
	    mkl_mkvar_append LDFLAGS LDFLAGS "-m$MBITS"
	fi
	if [[ -z "$ARFLAGS" && $MBITS == 64 && $MKL_DISTRO == "SunOS" ]]; then
	    # Turn on 64-bit archives on SunOS
	    mkl_mkvar_append ARFLAGS ARFLAGS "S"
	fi
    fi

    # Provide prefix and checks for various other build tools.
    local t=
    for t in LD:ld NM:nm OBJDUMP:objdump STRIP:strip ; do
        local tenv=${t%:*}
        t=${t#*:}
	local tval="${!tenv}"

        [[ -z $tval ]] && tval="$t"

        if mkl_prog_check "$t" "" disable "$tval" ; then
            if [[ $tval != ${!tenv} ]]; then
		export "$tenv"="$tval"
	    fi
            mkl_mkvar_set $tenv $tenv "$tval"
        fi
    done

    # Compiler and linker flags
    [[ ! -z $CFLAGS ]]   && mkl_mkvar_set "CFLAGS" "CFLAGS" "$CFLAGS"
    [[ ! -z $CPPFLAGS ]] && mkl_mkvar_set "CPPFLAGS" "CPPFLAGS" "$CPPFLAGS"
    [[ ! -z $CXXFLAGS ]] && mkl_mkvar_set "CXXFLAGS" "CXXFLAGS" "$CXXFLAGS"
    [[ ! -z $LDFLAGS ]]  && mkl_mkvar_set "LDFLAGS" "LDFLAGS" "$LDFLAGS"
    [[ ! -z $ARFLAGS ]]  && mkl_mkvar_set "ARFLAGS" "ARFLAGS" "$ARFLAGS"


    # Add debug symbol flag (-g)
    # OSX 10.9 requires -gstrict-dwarf for some reason.
    mkl_meta_set cc_g_dwarf name "debug symbols compiler flag (-g...)"
    if [[ $MKL_DISTRO == "osx" ]]; then
	if mkl_compile_check cc_g_dwarf "" cont CC "-gstrict-dwarf"; then
	    mkl_mkvar_append CPPFLAGS CPPFLAGS "-gstrict-dwarf"
	else
	    mkl_mkvar_append CPPFLAGS CPPFLAGS "-g"
	fi
    else
	mkl_mkvar_append CPPFLAGS CPPFLAGS "-g"
    fi


    # pkg-config
    if [ -z "$PKG_CONFIG" ]; then
        PKG_CONFIG=pkg-config
    fi

    if mkl_command_check "pkgconfig" "WITH_PKGCONFIG" cont "$PKG_CONFIG --version"; then
        export PKG_CONFIG
    fi
{'fraction_non_alphanumeric': 0.1382138517618469, 'fraction_numerical': 0.002430133657351154, 'mean_word_length': 2.5063897763578273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4698609', 'n_tokens_mistral': 2543, 'n_tokens_neox': 2415, 'n_words': 656}