162306a36Sopenharmony_ci#!/bin/sh
262306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
362306a36Sopenharmony_ci#
462306a36Sopenharmony_ci# Probe for libraries and create header files to record the results. Both C
562306a36Sopenharmony_ci# header files and Makefile include fragments are created.
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciOUTPUT_H_FILE=local_config.h
862306a36Sopenharmony_ciOUTPUT_MKFILE=local_config.mk
962306a36Sopenharmony_ci
1062306a36Sopenharmony_citmpname=$(mktemp)
1162306a36Sopenharmony_citmpfile_c=${tmpname}.c
1262306a36Sopenharmony_citmpfile_o=${tmpname}.o
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci# liburing
1562306a36Sopenharmony_ciecho "#include <sys/types.h>"        > $tmpfile_c
1662306a36Sopenharmony_ciecho "#include <liburing.h>"        >> $tmpfile_c
1762306a36Sopenharmony_ciecho "int func(void) { return 0; }" >> $tmpfile_c
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciCC=${1:?"Usage: $0 <compiler> # example compiler: gcc"}
2062306a36Sopenharmony_ci$CC -c $tmpfile_c -o $tmpfile_o >/dev/null 2>&1
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciif [ -f $tmpfile_o ]; then
2362306a36Sopenharmony_ci    echo "#define LOCAL_CONFIG_HAVE_LIBURING 1"  > $OUTPUT_H_FILE
2462306a36Sopenharmony_ci    echo "IOURING_EXTRA_LIBS = -luring"          > $OUTPUT_MKFILE
2562306a36Sopenharmony_cielse
2662306a36Sopenharmony_ci    echo "// No liburing support found"          > $OUTPUT_H_FILE
2762306a36Sopenharmony_ci    echo "# No liburing support found, so:"      > $OUTPUT_MKFILE
2862306a36Sopenharmony_ci    echo "IOURING_EXTRA_LIBS = "                >> $OUTPUT_MKFILE
2962306a36Sopenharmony_cifi
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_cirm ${tmpname}.*
32