<commit_before>extern crate gcc;

use std::fs::File;
use std::path::Path;
use std::io::Write;
use std::process::Command;
use std::env;

// Only Linux yet
fn main() {
    env::set_var("CC", "gcc");
    env::set_var("AS", "gcc -c");
    env::set_var("AR", "ar");

    // /bin/grep -m 1 -o ssse3 /proc/cpuinfo
    let output = Command::new("grep")
                     .arg("-m")
                     .arg("1")
                     .arg("-o")
                     .arg("sse3")
                     .arg("/proc/cpuinfo")
                     .output()
                     .unwrap();
    let output = std::str::from_utf8(&output.stdout[..]).unwrap().trim();
    let sse3 = output == "sse3";

    let mut cflags = "-g -Wall -Wextra -Wno-unused-parameter".to_owned();
    if sse3 {
        // TODO check if SSE feature was enabled
        cflags = cflags + " -mssse3";
    }
    cflags = cflags + " -O2";

    env::set_var("CFLAGS", cflags);

    let mut config = gcc::Config::new();
    config.file("src/c/src/bitstring.c")
          .file("src/c/src/encparams.c")
          .file("src/c/src/hash.c")
          .file("src/c/src/idxgen.c")
          .file("src/c/src/key.c")
          .file("src/c/src/mgf.c")
          .file("src/c/src/ntru.c")
          .file("src/c/src/poly.c")
          .file("src/c/src/rand.c")
          .file("src/c/src/arith.c")
          .file("src/c/src/sha1.c")
          .file("src/c/src/sha2.c");

    if sse3 && cfg!(target_pointer_width = "64") {
        let out = Command::new("perl")
                      .arg("src/c/src/sha1-mb-x86_64.pl")
                      .arg("elf")
                      .output()
                      .unwrap();<commit_msg>Added BSD support, still needs testing<commit_after>extern crate gcc;

use std::fs::File;
use std::path::Path;
use std::io::Write;
use std::process::Command;
use std::env;

// Only Linux yet
fn main() {
    if cfg!(target_os = "linux") {
        env::set_var("CC", "gcc");
        env::set_var("AS", "gcc -c");
    } else if cfg!(target_os = "freebsd") || cfg!(target_os = "openbsd") {
        env::set_var("CC", "cc");
        env::set_var("AS", "cc -c");
    }
    env::set_var("AR", "ar");

    // /bin/grep -m 1 -o ssse3 /proc/cpuinfo
    let output = if cfg!(target_os = "linux") {
        Command::new("grep")
            .arg("-m")
            .arg("1")
            .arg("-o")
            .arg("sse3")
            .arg("/proc/cpuinfo")
            .output()
            .unwrap()
    } else {
        // if cfg!(target_os = "freebsd") || cfg!(target_os = "openbsd") {
        Command::new("grep")
            .arg("-o")
            .arg("SSE3")
            .arg("/var/run/dmesg.boot")
            .arg("|")
            .arg("/usr/bin/head")
            .output()
            .unwrap()
    };
    let output = std::str::from_utf8(&output.stdout[..]).unwrap().trim();
    let sse3 = if cfg!(target_os = "linux") {
        output == "sse3"
    } else {
        // if cfg!(target_os = "freebsd") || cfg!(target_os = "openbsd") {
        output == "SSE3"
    };

    let mut cflags = "-g -Wall -Wextra -Wno-unused-parameter".to_owned();
    if sse3 {
        // TODO check if SSE feature was enabled
        cflags = cflags + " -mssse3";
    }
    cflags = cflags + " -O2";

    env::set_var("CFLAGS", cflags);

    let mut config = gcc::Config::new();
    config.file("src/c/src/bitstring.c")
          .file("src/c/src/encparams.c")
          .file("src/c/src/hash.c")
          .file("src/c/src/idxgen.c")
          .file("src/c/src/key.c")
          .file("src/c/src/mgf.c")
          .file("src/c/src/ntru.c")
          .file("src/c/src/poly.c")
          .file("src/c/src/rand.c")
          .file("src/c/src/arith.c")
          .file("src/c/src/sha1.c")
          .file("src/c/src/sha2.c");

    if sse3 && cfg!(target_pointer_width = "64") {
        let out = Command::new("perl")
                      .arg("src/c/src/sha1-mb-x86_64.pl")
                      .arg("elf")
                      .output()
                      .unwrap();
{'fraction_non_alphanumeric': 0.20263223243109013, 'fraction_numerical': 0.010429600198659052, 'mean_word_length': 1.6054333764553688, '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': '2570312', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1432, 'n_words': 244}