]> git.proxmox.com Git - ceph.git/blame - ceph/src/liburing/configure
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / liburing / configure
CommitLineData
f67539c2
TL
1#!/bin/sh
2#
3# set temporary file name
4if test ! -z "$TMPDIR" ; then
5 TMPDIR1="${TMPDIR}"
6elif test ! -z "$TEMPDIR" ; then
7 TMPDIR1="${TEMPDIR}"
8else
9 TMPDIR1="/tmp"
10fi
11
12cc=${CC:-gcc}
13cxx=${CXX:-g++}
14
15for opt do
16 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
17 case "$opt" in
18 --help|-h) show_help=yes
19 ;;
20 --prefix=*) prefix="$optarg"
21 ;;
22 --includedir=*) includedir="$optarg"
23 ;;
24 --libdir=*) libdir="$optarg"
25 ;;
26 --libdevdir=*) libdevdir="$optarg"
27 ;;
28 --mandir=*) mandir="$optarg"
29 ;;
30 --datadir=*) datadir="$optarg"
31 ;;
32 --cc=*) cc="$optarg"
33 ;;
34 --cxx=*) cxx="$optarg"
35 ;;
36 *)
37 echo "ERROR: unknown option $opt"
38 echo "Try '$0 --help' for more information"
39 exit 1
40 ;;
41 esac
42done
43
44if test -z "$prefix"; then
45 prefix=/usr
46fi
47if test -z "$includedir"; then
48 includedir="$prefix/include"
49fi
50if test -z "$libdir"; then
51 libdir="$prefix/lib"
52fi
53if test -z "$libdevdir"; then
54 libdevdir="$prefix/lib"
55fi
56if test -z "$mandir"; then
57 mandir="$prefix/man"
58fi
59if test -z "$datadir"; then
60 datadir="$prefix/share"
61fi
62
63if test x"$libdir" = x"$libdevdir"; then
64 relativelibdir=""
65else
66 relativelibdir="$libdir/"
67fi
68
69if test "$show_help" = "yes"; then
70cat <<EOF
71
72Usage: configure [options]
73Options: [defaults in brackets after descriptions]
74 --help print this message
75 --prefix=PATH install in PATH [$prefix]
76 --includedir=PATH install headers in PATH [$includedir]
77 --libdir=PATH install runtime libraries in PATH [$libdir]
78 --libdevdir=PATH install development libraries in PATH [$libdevdir]
79 --mandir=PATH install man pages in PATH [$mandir]
80 --datadir=PATH install shared data in PATH [$datadir]
81EOF
82exit 0
83fi
84
85TMPC="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.c"
86TMPC2="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}-2.c"
87TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o"
88TMPE="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.exe"
89
90# NB: do not call "exit" in the trap handler; this is buggy with some shells;
91# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
92trap "rm -f $TMPC $TMPC2 $TMPO $TMPE" EXIT INT QUIT TERM
93
94rm -rf config.log
95
96config_host_mak="config-host.mak"
97config_host_h="config-host.h"
98
99rm -rf $config_host_mak
100rm -rf $config_host_h
101
102fatal() {
103 echo $@
104 echo "Configure failed, check config.log and/or the above output"
105 rm -rf $config_host_mak
106 rm -rf $config_host_h
107 exit 1
108}
109
110# Print result for each configuration test
111print_config() {
112 printf "%-30s%s\n" "$1" "$2"
113}
114
115# Default CFLAGS
116CFLAGS="-D_GNU_SOURCE -include config-host.h"
117BUILD_CFLAGS=""
118
119# Print configure header at the top of $config_host_h
120echo "/*" > $config_host_h
121echo " * Automatically generated by configure - do not modify" >> $config_host_h
122printf " * Configured with:" >> $config_host_h
123printf " * '%s'" "$0" "$@" >> $config_host_h
124echo "" >> $config_host_h
125echo " */" >> $config_host_h
126
127echo "# Automatically generated by configure - do not modify" > $config_host_mak
128printf "# Configured with:" >> $config_host_mak
129printf " '%s'" "$0" "$@" >> $config_host_mak
130echo >> $config_host_mak
131
132do_cxx() {
133 # Run the compiler, capturing its output to the log.
134 echo $cxx "$@" >> config.log
135 $cxx "$@" >> config.log 2>&1 || return $?
136 return 0
137}
138
139do_cc() {
140 # Run the compiler, capturing its output to the log.
141 echo $cc "$@" >> config.log
142 $cc "$@" >> config.log 2>&1 || return $?
143 # Test passed. If this is an --enable-werror build, rerun
144 # the test with -Werror and bail out if it fails. This
145 # makes warning-generating-errors in configure test code
146 # obvious to developers.
147 if test "$werror" != "yes"; then
148 return 0
149 fi
150 # Don't bother rerunning the compile if we were already using -Werror
151 case "$*" in
152 *-Werror*)
153 return 0
154 ;;
155 esac
156 echo $cc -Werror "$@" >> config.log
157 $cc -Werror "$@" >> config.log 2>&1 && return $?
158 echo "ERROR: configure test passed without -Werror but failed with -Werror."
159 echo "This is probably a bug in the configure script. The failing command"
160 echo "will be at the bottom of config.log."
161 fatal "You can run configure with --disable-werror to bypass this check."
162}
163
164compile_prog() {
165 local_cflags="$1"
166 local_ldflags="$2 $LIBS"
167 echo "Compiling test case $3" >> config.log
168 do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
169}
170
171compile_prog_cxx() {
172 local_cflags="$1"
173 local_ldflags="$2 $LIBS"
174 echo "Compiling test case $3" >> config.log
175 do_cxx $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
176}
177
178has() {
179 type "$1" >/dev/null 2>&1
180}
181
182output_mak() {
183 echo "$1=$2" >> $config_host_mak
184}
185
186output_sym() {
187 output_mak "$1" "y"
188 echo "#define $1" >> $config_host_h
189}
190
191print_and_output_mak() {
192 print_config "$1" "$2"
193 output_mak "$1" "$2"
194}
195print_and_output_mak "prefix" "$prefix"
196print_and_output_mak "includedir" "$includedir"
197print_and_output_mak "libdir" "$libdir"
198print_and_output_mak "libdevdir" "$libdevdir"
199print_and_output_mak "relativelibdir" "$relativelibdir"
200print_and_output_mak "mandir" "$mandir"
201print_and_output_mak "datadir" "$datadir"
202
203##########################################
204# check for __kernel_rwf_t
205__kernel_rwf_t="no"
206cat > $TMPC << EOF
207#include <linux/fs.h>
208int main(int argc, char **argv)
209{
210 __kernel_rwf_t x;
211 x = 0;
212 return x;
213}
214EOF
215if compile_prog "" "" "__kernel_rwf_t"; then
216 __kernel_rwf_t="yes"
217fi
218print_config "__kernel_rwf_t" "$__kernel_rwf_t"
219
220##########################################
221# check for __kernel_timespec
222__kernel_timespec="no"
223cat > $TMPC << EOF
224#include <linux/time.h>
225#include <linux/time_types.h>
226int main(int argc, char **argv)
227{
228 struct __kernel_timespec ts;
229 ts.tv_sec = 0;
230 ts.tv_nsec = 1;
231 return 0;
232}
233EOF
234if compile_prog "" "" "__kernel_timespec"; then
235 __kernel_timespec="yes"
236fi
237print_config "__kernel_timespec" "$__kernel_timespec"
238
239##########################################
240# check for open_how
241open_how="no"
242cat > $TMPC << EOF
243#include <sys/types.h>
244#include <sys/stat.h>
245#include <fcntl.h>
246#include <string.h>
247int main(int argc, char **argv)
248{
249 struct open_how how;
250 how.flags = 0;
251 how.mode = 0;
252 how.resolve = 0;
253 return 0;
254}
255EOF
256if compile_prog "" "" "open_how"; then
257 open_how="yes"
258fi
259print_config "open_how" "$open_how"
260
261##########################################
262# check for statx
263statx="no"
264cat > $TMPC << EOF
265#include <sys/types.h>
266#include <sys/stat.h>
267#include <unistd.h>
268#include <fcntl.h>
269#include <string.h>
270#include <linux/stat.h>
271int main(int argc, char **argv)
272{
273 struct statx x;
274
275 return memset(&x, 0, sizeof(x)) != NULL;
276}
277EOF
278if compile_prog "" "" "statx"; then
279 statx="yes"
280fi
281print_config "statx" "$statx"
282
283##########################################
284# check for C++
285has_cxx="no"
286cat > $TMPC << EOF
287#include <iostream>
288int main(int argc, char **argv)
289{
290 std::cout << "Test";
291 return 0;
292}
293EOF
294if compile_prog_cxx "" "" "C++"; then
295 has_cxx="yes"
296fi
297print_config "C++" "$has_cxx"
298
299#############################################################################
300
301if test "$__kernel_rwf_t" = "yes"; then
302 output_sym "CONFIG_HAVE_KERNEL_RWF_T"
303fi
304if test "$__kernel_timespec" = "yes"; then
305 output_sym "CONFIG_HAVE_KERNEL_TIMESPEC"
306fi
307if test "$open_how" = "yes"; then
308 output_sym "CONFIG_HAVE_OPEN_HOW"
309fi
310if test "$statx" = "yes"; then
311 output_sym "CONFIG_HAVE_STATX"
312fi
313if test "$has_cxx" = "yes"; then
314 output_sym "CONFIG_HAVE_CXX"
315fi
316
317echo "CC=$cc" >> $config_host_mak
318print_config "CC" "$cc"
319echo "CXX=$cxx" >> $config_host_mak
320print_config "CXX" "$cxx"
321
322# generate compat.h
323compat_h="src/include/liburing/compat.h"
324cat > $compat_h << EOF
325/* SPDX-License-Identifier: MIT */
326#ifndef LIBURING_COMPAT_H
327#define LIBURING_COMPAT_H
328
329EOF
330
331if test "$__kernel_rwf_t" != "yes"; then
332cat >> $compat_h << EOF
333typedef int __kernel_rwf_t;
334
335EOF
336fi
337if test "$__kernel_timespec" != "yes"; then
338cat >> $compat_h << EOF
339#include <stdint.h>
340
341struct __kernel_timespec {
342 int64_t tv_sec;
343 long long tv_nsec;
344};
345
346EOF
347else
348cat >> $compat_h << EOF
349#include <linux/time_types.h>
350
351EOF
352fi
353if test "$open_how" != "yes"; then
354cat >> $compat_h << EOF
355#include <inttypes.h>
356
357struct open_how {
358 uint64_t flags;
359 uint64_t mode;
360 uint64_t resolve;
361};
362
363EOF
364fi
365
366cat >> $compat_h << EOF
367#endif
368EOF