Sha256: 2c2e0f11b1927f5f6394d11b13d5468d2d258a79cbbcf0174213ee157eec163b

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

#!/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

program_compiles() {
	echo "$1" > "$tmpfile"
	$CC $CFLAGS -x c "$tmpfile" -o /dev/null > /dev/null 2>&1
}

check_function() {
	funcname="$1"
	macro="HAVE_$(echo $funcname | tr a-z A-Z)"
	echo
	echo "/* Is the $funcname() function available? */"
	if program_compiles "int main() { $funcname(); }"; then
		echo "#define $macro 1"
	else
		echo "/* $macro is not set */"
	fi
}

have_stat_field() {
	program_compiles "#include <sys/types.h>
			  #include <sys/stat.h>
			  int main() { struct stat st; st.$1; }"
}

check_stat_nanosecond_precision() {
	echo
	echo "/* Does stat() provide nanosecond-precision timestamps? */"
	if have_stat_field st_atim; then
		echo "#define HAVE_STAT_NANOSECOND_PRECISION 1"
	elif have_stat_field st_atimespec; then
		# Nonstandard field names used by OS X and older BSDs
		echo "#define HAVE_STAT_NANOSECOND_PRECISION 1"
		echo "#define st_atim st_atimespec"
		echo "#define st_mtim st_mtimespec"
		echo "#define st_ctim st_ctimespec"
	else
		echo "/* HAVE_STAT_NANOSECOND_PRECISION is not set */"
	fi
}

check_function clock_gettime
check_function futimens
check_function futimes
check_function posix_fadvise
check_function posix_madvise

check_stat_nanosecond_precision

echo
echo "#endif /* CONFIG_H */"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
libdeflate-0.1.1 ext/libdeflate/libdeflate/programs/detect.sh
libdeflate-0.1.0 ext/libdeflate/libdeflate/programs/detect.sh