mb_rand 0.2.0

Safe Rust bindings to OpenBSD's arc4random functions
Documentation
//
// Copyright (c) 2025 murilo ijanc' <mbsd@m0x.ru>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
use std::env;

fn main() {
    let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();

    // On OpenBSD, the functions are available directly
    if target_os == "openbsd" {
        return;
    }

    // On macOS and FreeBSD, the functions are available in the system library
    if target_os == "macos" || target_os == "freebsd" {
        return;
    }

    // On Linux and others, we typically need to link against libbsd
    println!("cargo:rustc-link-lib=bsd");

    // Output a helpful message if we're on a platform that might need additional setup
    if target_os == "linux" {
        println!(
            "cargo:warning=This crate requires libbsd on Linux. Install it with your package manager (e.g., 'apt install libbsd-dev' on Debian/Ubuntu)."
        );
    }
}