af2c1d97f6667aa20a4de571b09abc022e3fe3df
[fio.git] / configure
1 #!/bin/sh
2 #
3 # Fio configure script. Heavily influenced by the manual qemu configure
4 # script. Sad this this is easier than autoconf and enemies.
5 #
6
7 # set temporary file name
8 if test ! -z "$TMPDIR" ; then
9     TMPDIR1="${TMPDIR}"
10 elif test ! -z "$TEMPDIR" ; then
11     TMPDIR1="${TEMPDIR}"
12 else
13     TMPDIR1="/tmp"
14 fi
15
16 TMPC="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.c"
17 TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o"
18 TMPE="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.exe"
19
20 # NB: do not call "exit" in the trap handler; this is buggy with some shells;
21 # see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
22 trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
23
24 rm -rf config.log
25
26 config_host_mak="config-host.mak"
27 config_host_ld="config-host.ld"
28
29 # Print a helpful header at the top of config.log
30 echo "# FIO configure log $(date)" >> config.log
31 printf "# Configured with:" >> config.log
32 printf " '%s'" "$0" "$@" >> config.log
33 echo >> config.log
34 echo "#" >> config.log
35
36 do_cc() {
37     # Run the compiler, capturing its output to the log.
38     echo $cc "$@" >> config.log
39     $cc "$@" >> config.log 2>&1 || return $?
40     # Test passed. If this is an --enable-werror build, rerun
41     # the test with -Werror and bail out if it fails. This
42     # makes warning-generating-errors in configure test code
43     # obvious to developers.
44     if test "$werror" != "yes"; then
45         return 0
46     fi
47     # Don't bother rerunning the compile if we were already using -Werror
48     case "$*" in
49         *-Werror*)
50            return 0
51         ;;
52     esac
53     echo $cc -Werror "$@" >> config.log
54     $cc -Werror "$@" >> config.log 2>&1 && return $?
55     echo "ERROR: configure test passed without -Werror but failed with -Werror."
56     echo "This is probably a bug in the configure script. The failing command"
57     echo "will be at the bottom of config.log."
58     echo "You can run configure with --disable-werror to bypass this check."
59     exit 1
60 }
61
62 compile_object() {
63   do_cc $CFLAGS -c -o $TMPO $TMPC
64 }
65
66 compile_prog() {
67   local_cflags="$1"
68   local_ldflags="$2"
69   echo "Compiling test case $3" >> config.log
70   do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
71 }
72
73 feature_not_found() {
74   feature=$1
75
76   echo "ERROR"
77   echo "ERROR: User requested feature $feature"
78   echo "ERROR: configure was not able to find it"
79   echo "ERROR"
80   exit 1;
81 }
82
83 has() {
84   type "$1" >/dev/null 2>&1
85 }
86
87 check_define() {
88   cat > $TMPC <<EOF
89 #if !defined($1)
90 #error $1 not defined
91 #endif
92 int main(void)
93 {
94   return 0;
95 }
96 EOF
97   compile_object
98 }
99
100 targetos=""
101 cpu=""
102
103 cc="${CC-${cross_prefix}gcc}"
104
105 # default options
106 gfio="no"
107 show_help="no"
108 exit_val=0
109
110 # parse options
111 for opt do
112   optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
113   case "$opt" in
114   --cc=*)
115     CC="$optarg"
116     ;;
117   --enable-gfio)
118     gfio="yes"
119     ;;
120   --help)
121     show_help="yes"
122     ;;
123   *)
124   echo "Bad option $opt"
125   show_help="yes"
126   exit_val=1
127   esac
128 done
129
130 if test "$show_help" = "yes" ; then
131     echo "--cc=                  Specify compiler to use"
132     echo "--enable-gfio          Enable building of gtk gfio"
133     exit $exit_val
134 fi
135
136 if check_define __linux__ ; then
137   targetos="Linux"
138 elif check_define __OpenBSD__ ; then
139   targetos='OpenBSD'
140 elif check_define __sun__ ; then
141   targetos='SunOS'
142 else
143   targetos=`uname -s`
144 fi
145
146 # Some host OSes need non-standard checks for which CPU to use.
147 # Note that these checks are broken for cross-compilation: if you're
148 # cross-compiling to one of these OSes then you'll need to specify
149 # the correct CPU with the --cpu option.
150 case $targetos in
151 Darwin)
152   # on Leopard most of the system is 32-bit, so we have to ask the kernel if
153   # we can run 64-bit userspace code.
154   # If the user didn't specify a CPU explicitly and the kernel says this is
155   # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
156   # detection code.
157   if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
158     cpu="x86_64"
159   fi
160   ;;
161 SunOS)
162   # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
163   if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
164     cpu="x86_64"
165   fi
166   ;;
167 CYGWIN*)
168   echo "Forcing known good options on Windows"
169   if test -z "$CC" ; then
170     CC="x86_64-w64-mingw32-gcc"
171   fi
172   echo "CC=$CC"                    >  $config_host_mak
173   echo "CONFIG_LITTLE_ENDIAN=y"    >> $config_host_mak
174   echo "CONFIG_64BIT_LLP64=y"      >> $config_host_mak
175   echo "CONFIG_CLOCK_GETTIME=y"    >> $config_host_mak
176   echo "CONFIG_CLOCK_MONOTONIC=y"  >> $config_host_mak
177   echo "CONFIG_GETTIMEOFDAY=y"     >> $config_host_mak
178   echo "CONFIG_FADVISE=y"          >> $config_host_mak
179   echo "CONFIG_SOCKLEN_T=y"        >> $config_host_mak
180   echo "CONFIG_POSIX_FALLOCATE=y"  >> $config_host_mak
181   echo "CONFIG_FADVISE=y"          >> $config_host_mak
182   echo "CONFIG_SFAA=y"             >> $config_host_mak
183   exit 0
184 esac
185
186 if test ! -z "$cpu" ; then
187   # command line argument
188   :
189 elif check_define __i386__ ; then
190   cpu="i386"
191 elif check_define __x86_64__ ; then
192   cpu="x86_64"
193 elif check_define __sparc__ ; then
194   if check_define __arch64__ ; then
195     cpu="sparc64"
196   else
197     cpu="sparc"
198   fi
199 elif check_define _ARCH_PPC ; then
200   if check_define _ARCH_PPC64 ; then
201     cpu="ppc64"
202   else
203     cpu="ppc"
204   fi
205 elif check_define __mips__ ; then
206   cpu="mips"
207 elif check_define __ia64__ ; then
208   cpu="ia64"
209 elif check_define __s390__ ; then
210   if check_define __s390x__ ; then
211     cpu="s390x"
212   else
213     cpu="s390"
214   fi
215 elif check_define __arm__ ; then
216   cpu="arm"
217 elif check_define __hppa__ ; then
218   cpu="hppa"
219 else
220   cpu=`uname -m`
221 fi
222
223 # Normalise host CPU name and set ARCH.
224 case "$cpu" in
225   ia64|ppc|ppc64|s390|s390x|sparc64)
226     cpu="$cpu"
227   ;;
228   i386|i486|i586|i686|i86pc|BePC)
229     cpu="i386"
230   ;;
231   x86_64|amd64)
232     cpu="x86_64"
233   ;;
234   armv*b|armv*l|arm)
235     cpu="arm"
236   ;;
237   hppa|parisc|parisc64)
238     cpu="hppa"
239   ;;
240   mips*)
241     cpu="mips"
242   ;;
243   sparc|sun4[cdmuv])
244     cpu="sparc"
245   ;;
246   *)
247     echo "Unknown CPU"
248     exit 1;
249   ;;
250 esac
251
252 if test -z $CC; then
253   if test "$targetos" = "FreeBSD"; then
254     if has clang; then
255       CC=clang
256     else
257       CC=gcc
258     fi
259   fi
260 fi
261
262 cc="${CC-${cross_prefix}gcc}"
263
264 ##########################################
265 # check endianness
266 bigendian="no"
267 cat > $TMPC <<EOF
268 #include <inttypes.h>
269 int main(void)
270 {
271   volatile uint32_t i=0x01234567;
272   return (*((uint8_t*)(&i))) == 0x67;
273 }
274 EOF
275 if compile_prog "" "" "endian"; then
276   $TMPE && bigendian="yes"
277 fi
278
279
280 echo "Operating system              $targetos"
281 echo "CPU                           $cpu"
282 echo "Big endian                    $bigendian"
283 echo "Compiler                      $cc"
284 echo
285
286 ##########################################
287 # check for wordsize
288 wordsize="0"
289 cat > $TMPC <<EOF
290 #include <stdio.h>
291 int main(void)
292 {
293   unsigned int wsize = sizeof(long) * 8;
294   printf("%d\n", wsize);
295   return 0;
296 }
297 EOF
298 if compile_prog "" "" "wordsize"; then
299   wordsize=$($TMPE)
300 fi
301 echo "Wordsize                      $wordsize"
302
303 ##########################################
304 # linux-aio probe
305 libaio="no"
306 cat > $TMPC <<EOF
307 #include <libaio.h>
308 #include <stddef.h>
309 int main(void)
310 {
311   io_setup(0, NULL);
312   return 0;
313 }
314 EOF
315 if compile_prog "" "-laio" "libaio" ; then
316   libaio=yes
317   LIBS="-laio $LIBS"
318 else
319   if test "$libaio" = "yes" ; then
320     feature_not_found "linux AIO"
321   fi
322   libaio=no
323 fi
324 echo "Linux AIO support             $libaio"
325
326 ##########################################
327 # posix aio probe
328 posix_aio="no"
329 posix_aio_lrt="no"
330 cat > $TMPC <<EOF
331 #include <aio.h>
332 int main(void)
333 {
334   struct aiocb cb;
335   aio_read(&cb);
336   return 0;
337 }
338 EOF
339 if compile_prog "" "" "posixaio" ; then
340   posix_aio="yes"
341 elif compile_prog "" "-lrt" "posixaio"; then
342   posix_aio="yes"
343   posix_aio_lrt="yes"
344   LIBS="-lrt $LIBS"
345 fi
346 echo "POSIX AIO support             $posix_aio"
347 echo "POSIX AIO support needs -lrt  $posix_aio_lrt"
348
349 ##########################################
350 # posix aio fsync probe
351 posix_aio_fsync="no"
352 if test "$posix_aio" = "yes" ; then
353   cat > $TMPC <<EOF
354 #include <fcntl.h>
355 #include <aio.h>
356 int main(void)
357 {
358   struct aiocb cb;
359   return aio_fsync(O_SYNC, &cb);
360   return 0;
361 }
362 EOF
363   if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
364     posix_aio_fsync=yes
365   fi
366 fi
367 echo "POSIX AIO fsync               $posix_aio_fsync"
368
369 ##########################################
370 # solaris aio probe
371 solaris_aio="no"
372 cat > $TMPC <<EOF
373 #include <sys/types.h>
374 #include <sys/asynch.h>
375 #include <unistd.h>
376 int main(void)
377 {
378   aio_result_t res;
379   return aioread(0, NULL, 0, 0, SEEK_SET, &res);
380   return 0;
381 }
382 EOF
383 if compile_prog "" "-laio" "solarisaio" ; then
384   solaris_aio=yes
385   LIBS="-laio $LIBS"
386 fi
387 echo "Solaris AIO support           $solaris_aio"
388
389 ##########################################
390 # __sync_fetch_and_and test
391 sfaa="no"
392 cat > $TMPC << EOF
393 static int sfaa(int *ptr)
394 {
395   return __sync_fetch_and_and(ptr, 0);
396 }
397
398 int main(int argc, char **argv)
399 {
400   int val = 42;
401   sfaa(&val);
402   return val;
403 }
404 EOF
405 if compile_prog "" "" "__sync_fetch_and_add()" ; then
406     sfaa="yes"
407 fi
408 echo "__sync_fetch_and add          $sfaa"
409
410 ##########################################
411 # libverbs probe
412 libverbs="no"
413 cat > $TMPC << EOF
414 #include <stdio.h>
415 #include <infiniband/arch.h>
416 int main(int argc, char **argv)
417 {
418   struct ibv_pd *pd = ibv_alloc_pd(NULL);
419   return 0;
420 }
421 EOF
422 if compile_prog "" "-libverbs" "libverbs" ; then
423     libverbs="yes"
424     LIBS="-libverbs $LIBS"
425 fi
426 echo "libverbs                      $libverbs"
427
428 ##########################################
429 # rdmacm probe
430 rdmacm="no"
431 cat > $TMPC << EOF
432 #include <stdio.h>
433 #include <rdma/rdma_cma.h>
434 int main(int argc, char **argv)
435 {
436   rdma_destroy_qp(NULL);
437   return 0;
438 }
439 EOF
440 if compile_prog "" "-lrdmacm" "rdma"; then
441     rdmacm="yes"
442     LIBS="-lrdmacm $LIBS"
443 fi
444 echo "rdmacm                        $rdmacm"
445
446 ##########################################
447 # Linux fallocate probe
448 linux_fallocate="no"
449 cat > $TMPC << EOF
450 #include <stdio.h>
451 #include <linux/falloc.h>
452 int main(int argc, char **argv)
453 {
454   int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
455   return r;
456 }
457 EOF
458 if compile_prog "" "" "linux_fallocate"; then
459     linux_fallocate="yes"
460 fi
461 echo "Linux fallocate               $linux_fallocate"
462
463 ##########################################
464 # POSIX fadvise probe
465 posix_fadvise="no"
466 cat > $TMPC << EOF
467 #include <stdio.h>
468 #include <fcntl.h>
469 int main(int argc, char **argv)
470 {
471   int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
472   return r;
473 }
474 EOF
475 if compile_prog "" "" "posix_fadvise"; then
476     posix_fadvise="yes"
477 fi
478 echo "POSIX fadvise                 $posix_fadvise"
479
480 ##########################################
481 # POSIX fallocate probe
482 posix_fallocate="no"
483 cat > $TMPC << EOF
484 #include <stdio.h>
485 #include <fcntl.h>
486 int main(int argc, char **argv)
487 {
488   int r = posix_fallocate(0, 0, 1024);
489   return r;
490 }
491 EOF
492 if compile_prog "" "" "posix_fallocate"; then
493     posix_fallocate="yes"
494 fi
495 echo "POSIX fallocate               $posix_fallocate"
496
497 ##########################################
498 # sched_set/getaffinity 2 or 3 argument test
499 linux_2arg_affinity="no"
500 linux_3arg_affinity="no"
501 cat > $TMPC << EOF
502 #define _GNU_SOURCE
503 #include <sched.h>
504 int main(int argc, char **argv)
505 {
506   cpu_set_t mask;
507   return sched_setaffinity(0, sizeof(mask), &mask);
508 }
509 EOF
510 if compile_prog "" "" "sched_setaffinity(,,)"; then
511   linux_3arg_affinity="yes"
512 else
513   cat > $TMPC << EOF
514 #define _GNU_SOURCE
515 #include <sched.h>
516 int main(int argc, char **argv)
517 {
518   cpu_set_t mask;
519   return sched_setaffinity(0, &mask);
520 }
521 EOF
522   if compile_prog "" "" "sched_setaffinity(,)"; then
523     linux_2arg_affinity="yes"
524   fi
525 fi
526 echo "sched_setaffinity(3 arg)      $linux_3arg_affinity"
527 echo "sched_setaffinity(2 arg)      $linux_2arg_affinity"
528
529 ##########################################
530 # clock_gettime probe
531 clock_gettime="no"
532 cat > $TMPC << EOF
533 #include <stdio.h>
534 #include <time.h>
535 int main(int argc, char **argv)
536 {
537   return clock_gettime(0, NULL);
538 }
539 EOF
540 if compile_prog "" "" "clock_gettime"; then
541     clock_gettime="yes"
542 elif compile_prog "" "-lrt" "clock_gettime"; then
543     clock_gettime="yes"
544     LIBS="-lrt $LIBS"
545 fi
546 echo "clock_gettime                 $clock_gettime"
547
548 ##########################################
549 # CLOCK_MONOTONIC probe
550 clock_monotonic="no"
551 if test "$clock_gettime" = "yes" ; then
552   cat > $TMPC << EOF
553 #include <stdio.h>
554 #include <time.h>
555 int main(int argc, char **argv)
556 {
557   return clock_gettime(CLOCK_MONOTONIC, NULL);
558 }
559 EOF
560   if compile_prog "" "$LIBS" "clock monotonic"; then
561       clock_monotonic="yes"
562   fi
563 fi
564 echo "CLOCK_MONOTONIC               $clock_monotonic"
565
566 ##########################################
567 # CLOCK_MONOTONIC_PRECISE probe
568 clock_monotonic_precise="no"
569 if test "$clock_gettime" = "yes" ; then
570   cat > $TMPC << EOF
571 #include <stdio.h>
572 #include <time.h>
573 int main(int argc, char **argv)
574 {
575   return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
576 }
577 EOF
578   if compile_prog "" "$LIBS" "clock monotonic precise"; then
579       clock_monotonic_precise="yes"
580   fi
581 fi
582 echo "CLOCK_MONOTONIC_PRECISE       $clock_monotonic_precise"
583
584 ##########################################
585 # gettimeofday() probe
586 gettimeofday="no"
587 cat > $TMPC << EOF
588 #include <sys/time.h>
589 #include <stdio.h>
590 int main(int argc, char **argv)
591 {
592   struct timeval tv;
593   return gettimeofday(&tv, NULL);
594 }
595 EOF
596 if compile_prog "" "" "gettimeofday"; then
597     gettimeofday="yes"
598 fi
599 echo "gettimeofday                  $gettimeofday"
600
601 ##########################################
602 # fdatasync() probe
603 fdatasync="no"
604 cat > $TMPC << EOF
605 #include <stdio.h>
606 #include <unistd.h>
607 int main(int argc, char **argv)
608 {
609   return fdatasync(0);
610 }
611 EOF
612 if compile_prog "" "" "fdatasync"; then
613   fdatasync="yes"
614 fi
615 echo "fdatasync                     $fdatasync"
616
617 ##########################################
618 # sync_file_range() probe
619 sync_file_range="no"
620 cat > $TMPC << EOF
621 #include <stdio.h>
622 #include <unistd.h>
623 #define _GNU_SOURCE
624 #include <fcntl.h>
625 #include <linux/fs.h>
626 int main(int argc, char **argv)
627 {
628   unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
629                         SYNC_FILE_RANGE_WAIT_AFTER;
630   return sync_file_range(0, 0, 0, flags);
631 }
632 EOF
633 if compile_prog "" "" "sync_file_range"; then
634   sync_file_range="yes"
635 fi
636 echo "sync_file_range               $sync_file_range"
637
638 ##########################################
639 # ext4 move extent probe
640 ext4_me="no"
641 cat > $TMPC << EOF
642 #include <fcntl.h>
643 #include <sys/ioctl.h>
644 int main(int argc, char **argv)
645 {
646   struct move_extent me;
647   return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
648 }
649 EOF
650 if compile_prog "" "" "ext4 move extent" ; then
651   ext4_me="yes"
652 elif test $targetos = "Linux" ; then
653   # On Linux, just default to it on and let it error at runtime if we really
654   # don't have it. None of my updated systems have it defined, but it does
655   # work. Takes a while to bubble back.
656   ext4_me="yes"
657 fi
658 echo "EXT4 move extent              $ext4_me"
659
660 ##########################################
661 # splice probe
662 linux_splice="no"
663 cat > $TMPC << EOF
664 #define _GNU_SOURCE
665 #include <stdio.h>
666 #include <fcntl.h>
667 int main(int argc, char **argv)
668 {
669   return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
670 }
671 EOF
672 if compile_prog "" "" "linux splice"; then
673   linux_splice="yes"
674 fi
675 echo "Linux splice(2)               $linux_splice"
676
677 ##########################################
678 # GUASI probe
679 guasi="no"
680 cat > $TMPC << EOF
681 #include <guasi.h>
682 #include <guasi_syscalls.h>
683 int main(int argc, char **argv)
684 {
685   guasi_t ctx = guasi_create(0, 0, 0);
686   return 0;
687 }
688 EOF
689 if compile_prog "" "" "guasi"; then
690   guasi="yes"
691 fi
692 echo "GUASI                         $guasi"
693
694 ##########################################
695 # fusion-aw probe
696 fusion_aw="no"
697 cat > $TMPC << EOF
698 #include <nvm/vectored_write.h>
699 int main(int argc, char **argv)
700 {
701   struct vsl_iovec iov;
702   return vsl_vectored_write(0, &iov, 0, O_ATOMIC);
703 }
704 EOF
705 if compile_prog "" "-L/usr/lib/fio -lnvm-primitives" "fusion-aw"; then
706   LIBS="-L/usr/lib/fio -lnvm-primitives $LIBS"
707   fusion_aw="yes"
708 fi
709 echo "Fusion-io atomic engine       $fusion_aw"
710
711 ##########################################
712 # libnuma probe
713 libnuma="no"
714 cat > $TMPC << EOF
715 #include <numa.h>
716 int main(int argc, char **argv)
717 {
718   return numa_available();
719 }
720 EOF
721 if compile_prog "" "-lnuma" "libnuma"; then
722   libnuma="yes"
723   LIBS="-lnuma $LIBS"
724 fi
725 echo "libnuma                       $libnuma"
726
727 ##########################################
728 # strsep() probe
729 strsep="no"
730 cat > $TMPC << EOF
731 #include <string.h>
732 int main(int argc, char **argv)
733 {
734   strsep(NULL, NULL);
735   return 0;
736 }
737 EOF
738 if compile_prog "" "" "strsep"; then
739   strsep="yes"
740 fi
741 echo "strsep                        $strsep"
742
743 ##########################################
744 # getopt_long_only() probe
745 getopt_long_only="no"
746 cat > $TMPC << EOF
747 #include <unistd.h>
748 #include <stdio.h>
749 int main(int argc, char **argv)
750 {
751   int c = getopt_long_only(argc, argv, NULL, NULL, NULL);
752   return c;
753 }
754 EOF
755 if compile_prog "" "" "getopt_long_only"; then
756   getopt_long_only="yes"
757 fi
758 echo "getopt_long_only()            $getopt_long_only"
759
760 ##########################################
761 # inet_aton() probe
762 inet_aton="no"
763 cat > $TMPC << EOF
764 #include <sys/socket.h>
765 #include <arpa/inet.h>
766 #include <stdio.h>
767 int main(int argc, char **argv)
768 {
769   struct in_addr in;
770   return inet_aton(NULL, &in);
771 }
772 EOF
773 if compile_prog "" "" "inet_aton"; then
774   inet_aton="yes"
775 fi
776 echo "inet_aton                     $inet_aton"
777
778 ##########################################
779 # socklen_t probe
780 socklen_t="no"
781 cat > $TMPC << EOF
782 #include <string.h>
783 #include <netinet/in.h>
784 int main(int argc, char **argv)
785 {
786   socklen_t len = 0;
787   return len;
788 }
789 EOF
790 if compile_prog "" "" "socklen_t"; then
791   socklen_t="yes"
792 fi
793 echo "socklen_t                     $socklen_t"
794
795 ##########################################
796 # Whether or not __thread is supported for TLS
797 tls_thread="no"
798 cat > $TMPC << EOF
799 #include <stdio.h>
800 static int __thread ret;
801 int main(int argc, char **argv)
802 {
803   return ret;
804 }
805 EOF
806 if compile_prog "" "" "__thread"; then
807   tls_thread="yes"
808 fi
809 echo "__thread                      $tls_thread"
810
811 ##########################################
812 # Whether or not __thread is supported for TLS
813 if test "$gfio" = "yes" ; then
814   cat > $TMPC << EOF
815 #include <glib.h>
816 #include <cairo.h>
817 #include <gtk/gtk.h>
818 int main(void)
819 {
820   gdk_threads_enter();
821   gtk_main();
822   gdk_threads_leave();
823   return 0;
824 }
825 EOF
826 GTK_CFLAGS=$(pkg-config --cflags gtk+-2.0 gthread-2.0)
827 if test "$?" != "0" ; then
828   echo "configure: gtk and gthread not found"
829   exit 1
830 fi
831 GTK_LIBS=$(pkg-config --libs gtk+-2.0 gthread-2.0)
832 if test "$?" != "0" ; then
833   echo "configure: gtk and gthread not found"
834   exit 1
835 fi
836 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio"; then
837   gfio="yes"
838   LIBS="$LIBS $GTK_LIBS"
839   CFLAGS="$CFLAGS $GTK_CFLAGS"
840 else
841   echo "Please install gtk and gdk libraries"
842   gfio="no"
843 fi
844 fi
845
846 echo "gfio                          $gfio"
847
848 #############################################################################
849
850 echo "# Automatically generated by configure - do not modify" > $config_host_mak
851 printf "# Configured with:" >> $config_host_mak
852 printf " '%s'" "$0" "$@" >> $config_host_mak
853 echo >> $config_host_mak
854
855 if test "$wordsize" = "64" ; then
856   echo "CONFIG_64BIT=y" >> $config_host_mak
857 elif test "$wordsize" = "32" ; then
858   echo "CONFIG_32BIT=y" >> $config_host_mak
859 else
860   echo "Unknown wordsize!"
861   exit 1
862 fi
863 if test "$bigendian" = "yes" ; then
864   echo "CONFIG_BIG_ENDIAN=y" >> $config_host_mak
865 else
866   echo "CONFIG_LITTLE_ENDIAN=y" >> $config_host_mak
867 fi
868 if test "$libaio" = "yes" ; then
869   echo "CONFIG_LIBAIO=y" >> $config_host_mak
870 fi
871 if test "$posix_aio" = "yes" ; then
872   echo "CONFIG_POSIXAIO=y" >> $config_host_mak
873 fi
874 if test "$posix_aio_fsync" = "yes" ; then
875   echo "CONFIG_POSIXAIO_FSYNC=y" >> $config_host_mak
876 fi
877 if test "$linux_fallocate" = "yes" ; then
878   echo "CONFIG_LINUX_FALLOCATE=y" >> $config_host_mak
879 fi
880 if test "$posix_fallocate" = "yes" ; then
881   echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
882 fi
883 if test "$fdatasync" = "yes" ; then
884   echo "CONFIG_FDATASYNC=y" >> $config_host_mak
885 fi
886 if test "$sync_file_range" = "yes" ; then
887   echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
888 fi
889 if test "$sfaa" = "yes" ; then
890   echo "CONFIG_SFAA=y" >> $config_host_mak
891 fi
892 if test "$libverbs" = "yes" -o "rdmacm" = "yes" ; then
893   echo "CONFIG_RDMA=y" >> $config_host_mak
894 fi
895 if test "$clock_gettime" = "yes" ; then
896   echo "CONFIG_CLOCK_GETTIME=y" >> $config_host_mak
897 fi
898 if test "$clock_monotonic" = "yes" ; then
899   echo "CONFIG_CLOCK_MONOTONIC=y" >> $config_host_mak
900 fi
901 if test "$clock_monotonic_precise" = "yes" ; then
902   echo "CONFIG_CLOCK_MONOTONIC_PRECISE=y" >> $config_host_mak
903 fi
904 if test "$gettimeofday" = "yes" ; then
905   echo "CONFIG_GETTIMEOFDAY=y" >> $config_host_mak
906 fi
907 if test "$posix_fadvise" = "yes" ; then
908   echo "CONFIG_POSIX_FADVISE=y" >> $config_host_mak
909 fi
910 if test "$linux_3arg_affinity" = "yes" ; then
911   echo "CONFIG_3ARG_AFFINITY=y" >> $config_host_mak
912 elif test "$linux_2arg_affinity" = "yes" ; then
913   echo "CONFIG_2ARG_AFFINITY=y" >> $config_host_mak
914 fi
915 if test "$strsep" = "yes" ; then
916   echo "CONFIG_STRSEP=y" >> $config_host_mak
917 fi
918 if test "$getopt_long_only" = "yes" ; then
919   echo "CONFIG_GETOPT_LONG_ONLY=y" >> $config_host_mak
920 fi
921 if test "$inet_aton" = "yes" ; then
922   echo "CONFIG_INET_ATON=y" >> $config_host_mak
923 fi
924 if test "$socklen_t" = "yes" ; then
925   echo "CONFIG_SOCKLEN_T=y" >> $config_host_mak
926 fi
927 if test "$ext4_me" = "yes" ; then
928   echo "CONFIG_LINUX_EXT4_MOVE_EXTENT=y" >> $config_host_mak
929 fi
930 if test "$linux_splice" = "yes" ; then
931   echo "CONFIG_LINUX_SPLICE=y" >> $config_host_mak
932 fi
933 if test "$guasi" = "yes" ; then
934   echo "CONFIG_GUASI=y" >> $config_host_mak
935 fi
936 if test "$fusion_aw" = "yes" ; then
937   echo "CONFIG_FUSION_AW=y" >> $config_host_mak
938 fi
939 if test "$libnuma" = "yes" ; then
940   echo "CONFIG_LIBNUMA=y" >> $config_host_mak
941 fi
942 if test "$solaris_aio" = "yes" ; then
943   echo "CONFIG_SOLARISAIO=y" >> $config_host_mak
944 fi
945 if test "$tls_thread" = "yes" ; then
946   echo "CONFIG_TLS_THREAD=y" >> $config_host_mak
947 fi
948 if test "$gfio" = "yes" ; then
949   echo "CONFIG_GFIO=y" >> $config_host_mak
950 fi
951
952 echo "LIBS+=$LIBS" >> $config_host_mak
953 echo "CFLAGS+=$CFLAGS" >> $config_host_mak
954 echo "CC=$cc" >> $config_host_mak