libdeflate/programs/detect.sh
Eric Biggers f2c3a5b4e9 Various reorganization and cleanups
* Bring in common headers and program code from xpack project
* Move program code to programs/
* Move library code to lib/
* GNU89 and MSVC2010 compatibility
* Other changes
2016-05-21 15:38:15 -05:00

33 lines
672 B
Bash
Executable File

#!/bin/sh
if [ -z "$CC" ]; then
CC=cc
fi
echo "/* THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. */"
echo "#ifndef _CONFIG_H"
echo "#define _CONFIG_H"
tmpfile="$(mktemp -t libdeflate_config.XXXXXXXX)"
trap "rm -f \"$tmpfile\"" EXIT
check_function() {
funcname="$1"
macro="HAVE_$(echo $funcname | tr a-z A-Z)"
echo "int main() { $funcname(); }" > "$tmpfile"
echo
echo "/* Is the $funcname() function available? */"
if $CC -x c $tmpfile -o /dev/null > /dev/null 2>&1; then
echo "#define $macro 1"
else
echo "/* $macro is not set */"
fi
}
check_function clock_gettime
check_function futimens
check_function futimes
echo
echo "#endif /* _CONFIG_H */"