Annotation of embedaddon/istgt/configure.in, revision 1.1.1.2

1.1       misho       1: #                                               -*- Autoconf -*-
                      2: # Process this file with autoconf to produce a configure script.
                      3: 
1.1.1.2 ! misho       4: AC_PREREQ([2.62])
        !             5: AC_INIT([istgt], [0.5])
1.1       misho       6: AC_CONFIG_SRCDIR([src/istgt.c])
                      7: AC_CONFIG_HEADERS([src/config.h])
                      8: 
                      9: # Checks for programs.
1.1.1.2 ! misho      10: AC_PROG_CC([clang gcc cc])
1.1       misho      11: AC_PROG_INSTALL
                     12: AC_PROG_RANLIB
                     13: AC_PROG_SED
1.1.1.2 ! misho      14: AC_PROG_MKDIR_P
        !            15: 
        !            16: # clagn with -O3
        !            17: if test "$CC" = "clang" && test "$ac_test_CFLAGS" != "set"; then
        !            18:   CFLAGS="-g -O3"
        !            19: fi
        !            20: 
        !            21: # host OS related
        !            22: vboxinc="/usr/local/src/virtualbox/*/include"
        !            23: vboxlib="/usr/local/lib/virtualbox"
        !            24: AC_SUBST([rctemplate], [""])
        !            25: AC_SUBST([rcdir], ['${prefix}/etc/rc.d'])
        !            26: AC_CANONICAL_HOST
        !            27: case "$host_os" in
        !            28: *linux*)
        !            29:        tmp="/usr/src/virtualbox/*/include"
        !            30:        if test -d "`echo $tmp`"; then
        !            31:            vboxinc=$tmp
        !            32:        fi
        !            33:        vboxlib="/usr/lib/virtualbox"
        !            34:        AC_SUBST([rctemplate], ["istgt_linux.sh.in"])
        !            35:        AC_SUBST([rcdir], ['/etc/init.d'])
        !            36:        AC_DEFINE([_GNU_SOURCE], 1, [Define if linux host])
        !            37:        ;;
        !            38: *netbsd*)
        !            39:        AC_SUBST([rctemplate], ["istgt_netbsd.sh.in"])
        !            40:        AC_SUBST([rcdir], ['/etc/rc.d'])
        !            41:        ;;
        !            42: *freebsd*)
        !            43:        tmp="/usr/ports/emulators/virtualbox-ose/work/*/include"
        !            44:        if test -d "`echo $tmp`"; then
        !            45:            vboxinc=$tmp
        !            46:        else
        !            47:            tmp="/usr/ports/emulators/virtualbox-ose-legacy/work/*/include"
        !            48:            if test -d "`echo $tmp`"; then
        !            49:                vboxinc=$tmp
        !            50:            fi
        !            51:        fi
        !            52:        vboxlib="/usr/local/lib/virtualbox"
        !            53:        AC_SUBST([rctemplate], ["istgt.sh.in"])
        !            54:        AC_SUBST([rcdir], ['${prefix}/etc/rc.d'])
        !            55:        if test "$mandir" = '${datarootdir}/man'; then
        !            56:            AC_SUBST([mandir], ['${prefix}/man'])
        !            57:        fi
        !            58:        ;;
        !            59: esac
1.1       misho      60: 
                     61: # Checks for libraries.
                     62: AC_CHECK_LIB([pthread], [pthread_create])
                     63: AC_CHECK_LIB([crypto], [MD5_Update])
                     64: AC_CHECK_LIB([cam], [cam_open_spec_device])
                     65: 
                     66: # Checks for header files.
                     67: AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h limits.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h])
                     68: 
                     69: # Checks for typedefs, structures, and compiler characteristics.
                     70: AC_C_INLINE
                     71: AC_TYPE_INT32_T
                     72: AC_TYPE_INT64_T
                     73: AC_TYPE_OFF_T
                     74: AC_TYPE_PID_T
                     75: AC_TYPE_SIZE_T
                     76: AC_TYPE_SSIZE_T
                     77: AC_STRUCT_ST_BLOCKS
                     78: AC_TYPE_UINT16_T
                     79: AC_TYPE_UINT32_T
                     80: AC_TYPE_UINT64_T
                     81: AC_TYPE_UINT8_T
                     82: 
                     83: # Checks for library functions.
                     84: AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
                     85: AC_FUNC_MALLOC
                     86: AC_FUNC_REALLOC
                     87: AC_CHECK_FUNCS([ftruncate memset realpath socket strcasecmp strchr strncasecmp strspn strtol strtoull])
                     88: 
                     89: # check compatibility
                     90: AC_SYS_LARGEFILE
                     91: AC_CHECK_HEADERS([aio.h sched.h uuid.h sys/disk.h sys/disklabel.h])
                     92: AC_CHECK_HEADERS([pthread.h])
                     93: AC_CHECK_HEADERS([pthread_np.h], [], [],
                     94: [#if HAVE_PTHREAD_H
                     95: #include <pthread.h>
                     96: #endif
                     97: ])
                     98: AC_CHECK_FUNCS([strlcpy arc4random srandomdev pthread_yield sched_yield])
                     99: AC_CHECK_FUNCS([pthread_set_name_np setproctitle])
1.1.1.2 ! misho     100: AC_SUBST([MKDEP])
        !           101: AC_PATH_PROG([MKDEP], ["mkdep"])
1.1       misho     102: #if test -z "$MKDEP"; then
1.1.1.2 ! misho     103: #   AC_PATH_PROG([MKDEP], ["makedepend"])
1.1       misho     104: #fi
                    105: 
                    106: # paths
                    107: configdir="$ac_default_prefix/etc/istgt"
                    108: mediadir="/var/istgt"
                    109: if test "$prefix" != "NONE"; then
                    110:   configdir="$prefix/etc/istgt"
                    111: fi
1.1.1.2 ! misho     112: AC_ARG_WITH([configdir],
        !           113:   AS_HELP_STRING([--with-configdir=DIR], [(default PREFIX/etc/istgt)]),
1.1       misho     114:   [case $withval in
                    115:     yes|no)
                    116:         ;;
                    117:     *)
                    118:         configdir="$withval"
                    119:         ;;
                    120:   esac])
1.1.1.2 ! misho     121: AC_SUBST([configdir])
        !           122: AC_ARG_WITH([mediadir],
        !           123:   AS_HELP_STRING([--with-mediadir=DIR], [(default /var/istgt)]),
1.1       misho     124:   [case $withval in
                    125:     yes|no)
                    126:         ;;
                    127:     *)
                    128:         mediadir="$withval"
                    129:         ;;
                    130:   esac])
1.1.1.2 ! misho     131: AC_SUBST([mediadir])
        !           132: 
        !           133: # startup script directory
        !           134: AC_ARG_WITH([rcdir],
        !           135:   AS_HELP_STRING([--with-rcdir=DIR], [(default PREFIX/etc/rc.d)]),
        !           136:   [case $withval in
        !           137:     yes|no)
        !           138:         ;;
        !           139:     *)
        !           140:         rcdir="$withval"
        !           141:         ;;
        !           142:   esac])
        !           143: AC_SUBST([rcdir])
1.1       misho     144: 
                    145: # test for -Wall
                    146: saved_CFLAGS="$CFLAGS"
                    147: AC_MSG_CHECKING([whether the C compiler accepts -Wall])
                    148: CFLAGS="$CFLAGS -Wall"
                    149: AC_TRY_COMPILE(,,
                    150:   AC_MSG_RESULT(yes); saved_CFLAGS="$CFLAGS",
                    151:   AC_MSG_RESULT(no))
                    152: CFLAGS="$saved_CFLAGS"
                    153: 
1.1.1.2 ! misho     154: # test for -Wextra
        !           155: saved_CFLAGS="$CFLAGS"
        !           156: AC_MSG_CHECKING([whether the C compiler accepts -Wextra])
        !           157: CFLAGS="$CFLAGS -Wextra"
        !           158: AC_TRY_COMPILE(,,
        !           159:   AC_MSG_RESULT(yes); saved_CFLAGS="$CFLAGS",
        !           160:   AC_MSG_RESULT(no))
        !           161: CFLAGS="$saved_CFLAGS"
        !           162: 
1.1       misho     163: # check enable features
                    164: AC_MSG_CHECKING([whether to use debug mode])
1.1.1.2 ! misho     165: AC_ARG_ENABLE([debug],
        !           166:   AS_HELP_STRING([--enable-debug], [enable debug(logging)]),
        !           167:   AC_MSG_RESULT(yes); AC_DEFINE([DEBUG], 1, [Define if enable debug]),
        !           168:   AC_MSG_RESULT(no))
        !           169: AC_SUBST([DEBUG])
        !           170: 
        !           171: AC_MSG_CHECKING([whether to use symlink device])
        !           172: AC_ARG_ENABLE([symlink-device],
        !           173:   AS_HELP_STRING([--enable-symlink-device], [allow symlink device]),
        !           174:   AC_MSG_RESULT(yes); AC_DEFINE([ALLOW_SYMLINK_DEVICE], 1, [Define if enable symlink-device]),
1.1       misho     175:   AC_MSG_RESULT(no))
1.1.1.2 ! misho     176: AC_SUBST([ALLOW_SYMLINK_DEVICE])
1.1       misho     177: 
                    178: AC_MSG_CHECKING([which syslog facility to use])
1.1.1.2 ! misho     179: AC_ARG_WITH([logfacility],
        !           180:   AS_HELP_STRING([--with-logfacility], [syslog facility to log with (default "local7")]),
1.1       misho     181:   [case $with_logfacility in
                    182:     daemon|auth|authpriv|local0|local1|local2|local3|local4|local5|local6|local7)
                    183:         logfacility=$with_logfacility
                    184:         ;;
                    185:     *)  AC_MSG_ERROR(["unsupported facility $with_logfacility"])
                    186:         ;;
                    187:   esac],
                    188:   [logfacility="local7"])
1.1.1.2 ! misho     189: AC_DEFINE_UNQUOTED([DEFAULT_LOG_FACILITY], ["$logfacility"], [syslog facility])
1.1       misho     190: AC_MSG_RESULT("$logfacility")
                    191: 
                    192: AC_MSG_CHECKING([which syslog priority to use])
1.1.1.2 ! misho     193: AC_ARG_WITH([logpriority],
        !           194:   AS_HELP_STRING([--with-logpriority], [syslog priority to log with (default "info")]),
1.1       misho     195:   [case $with_logpriority in
                    196:     emerg|alert|crit|err|warning|notice|info|debug)
                    197:         logpriority=$with_logpriority
                    198:         ;;
                    199:     *)  AC_MSG_ERROR(["unsupported priority $with_logpriority"])
                    200:         ;;
                    201:   esac],
                    202:   [logpriority="info"])
1.1.1.2 ! misho     203: AC_DEFINE_UNQUOTED([DEFAULT_LOG_PRIORITY], ["$logpriority"], [syslog priority])
1.1       misho     204: AC_MSG_RESULT("$logpriority")
                    205: 
                    206: #AC_MSG_CHECKING([whether to use asynchronous io])
1.1.1.2 ! misho     207: #AC_ARG_WITH([aio],
        !           208: #  AS_HELP_STRING([--with-aio], [use aio (default "no")]),
1.1       misho     209: #  [case $with_aio in
                    210: #    yes)
1.1.1.2 ! misho     211: #        AC_DEFINE([USE_AIO], 1, [use aio])
1.1       misho     212: #        AC_MSG_RESULT(yes)
                    213: #        ;;
                    214: #    *)
                    215: #        AC_MSG_RESULT(no)
                    216: #        ;;
                    217: #  esac],
                    218: #  AC_MSG_RESULT(no))
1.1.1.2 ! misho     219: #AC_SUBST([USE_AIO])
        !           220: 
        !           221: # vbox support
        !           222: vbox="no"
        !           223: AC_MSG_CHECKING([VirtualBox Virtual Disk support])
        !           224: AC_ARG_WITH([vbox],
        !           225:   AS_HELP_STRING([--with-vbox=INC], [VirtualBox include]),
        !           226:   [case $with_vbox in
        !           227:      no)
        !           228:          AC_MSG_RESULT([no])
        !           229:          ;;
        !           230:      yes|*)
        !           231:          AC_MSG_RESULT([yes])
        !           232:          vbox="yes"
        !           233:          if test "$with_vbox" != "yes"; then
        !           234:              vboxinc="$with_vbox"
        !           235:          fi
        !           236:          ;;
        !           237:    esac],
        !           238:   [AC_MSG_RESULT([no])])
        !           239: AC_ARG_WITH([vboxlib],
        !           240:   AS_HELP_STRING([--with-vboxlib=LIB], [VirtualBox lib]),
        !           241:   [case $with_vboxlib in
        !           242:      no)
        !           243:          ;;
        !           244:      yes|*)
        !           245:          vbox="yes"
        !           246:          if test "$with_vboxlib" != "yes"; then
        !           247:              vboxlib="$with_vboxlib"
        !           248:          fi
        !           249:          ;;
        !           250:    esac],
        !           251:   [])
        !           252: # vbox support yes?
        !           253: if test "$vbox" = "yes"; then
        !           254:     vboxinc=`echo $vboxinc`
        !           255:     vboxlib=`echo $vboxlib`
        !           256:     if test ! -d "$vboxinc"; then
        !           257:         AC_MSG_ERROR([not directory: $vboxinc])
        !           258:     fi
        !           259:     if test ! -d "$vboxlib"; then
        !           260:         AC_MSG_ERROR([not directory: $vboxlib])
        !           261:     fi
        !           262:     CPPFLAGS="$CPPFLAGS -I$vboxinc"
        !           263:     LDFLAGS="$LDFLAGS -Wl,-rpath,$vboxlib"
        !           264:     LIBS="$LIBS $vboxlib/VBoxDDU.so $vboxlib/VBoxRT.so"
        !           265:     AC_DEFINE([USE_VBOXVD], 1, [Use vbox virtual disk support])
        !           266:     # define vbox include version
        !           267:     changequote(<<, >>)
        !           268:     vbox_major=`$SED -e '/^VBOX_VERSION_MAJOR[         ]*=/!d' -e 's/.*=[^0-9]*\([0-9]*\).*/\1/' $vboxinc/../Config.kmk`
        !           269:     vbox_minor=`$SED -e '/^VBOX_VERSION_MINOR[         ]*=/!d' -e 's/.*=[^0-9]*\([0-9]*\).*/\1/' $vboxinc/../Config.kmk`
        !           270:     vbox_build=`$SED -e '/^VBOX_VERSION_BUILD[         ]*=/!d' -e 's/.*=[^0-9]*\([0-9]*\).*/\1/' $vboxinc/../Config.kmk`
        !           271:     changequote([, ])
        !           272:     AC_DEFINE_UNQUOTED([ISTGT_VBOXINC_VERSION_MAJOR], [$vbox_major], [VBox include major])
        !           273:     AC_DEFINE_UNQUOTED([ISTGT_VBOXINC_VERSION_MINOR], [$vbox_minor], [VBox include minor])
        !           274:     AC_DEFINE_UNQUOTED([ISTGT_VBOXINC_VERSION_BUILD], [$vbox_build], [VBox include build])
        !           275: fi
        !           276: 
        !           277: # check for PTHREAD_MUTEX_ADAPTIVE_NP
        !           278: AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
        !           279: AC_TRY_COMPILE([
        !           280: #include <pthread.h>
        !           281: ],
        !           282: [
        !           283:        return (PTHREAD_MUTEX_ADAPTIVE_NP);
        !           284: ],
        !           285: [AC_MSG_RESULT([yes])
        !           286: AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [1], [Define 1 if you have the value.])],
        !           287: [AC_MSG_RESULT([no])]
        !           288: )
1.1       misho     289: 
                    290: AC_CHECK_HEADERS([sys/types.h])
                    291: AC_CHECK_HEADERS([machine/atomic.h], [], [],
                    292: [#if HAVE_SYS_TYPES_H
                    293: #include <sys/types.h>
                    294: #endif
                    295: ])
                    296: AC_CHECK_HEADERS([sys/atomic.h])
                    297: 
                    298: # for FeeeBSD
                    299: #AC_CHECK_FUNCS([atomic_store_rel_int atomic_load_acq_int])
                    300: #AC_CHECK_FUNCS([atomic_cmpset_ptr atomic_cmpset_64 atomic_cmpset_32])
                    301: 
                    302: # for NetBSD
                    303: #AC_CHECK_FUNCS([atomic_swap_uint atomic_or_uint_nv])
                    304: #AC_CHECK_FUNCS([atomic_cas_ptr atomic_cas_64 atomic_cas_32])
                    305: 
                    306: atomic="no"
                    307: AC_MSG_CHECKING([for atomic operations])
1.1.1.2 ! misho     308: AC_TRY_LINK([
        !           309: #if HAVE_SYS_TYPES_H
1.1       misho     310: #include <sys/types.h>
                    311: #endif
                    312: #include <machine/atomic.h>
                    313: ],
                    314: [
                    315:        int x, y;
                    316:        atomic_store_rel_int(&x, 1);
                    317:        y = atomic_load_acq_int(&x);
                    318: ],
1.1.1.2 ! misho     319: [AC_DEFINE([USE_ATOMIC], [1], [Use atomic])
        !           320: AC_DEFINE([HAVE_ATOMIC_STORE_REL_INT], [1], [Define 1 if you have the function.])
        !           321: AC_DEFINE([HAVE_ATOMIC_LOAD_ACQ_INT], [1], [Define 1 if you have the function.])
1.1       misho     322: atomic="yes"]
                    323: )
                    324: if test $atomic = "no"; then
                    325: AC_TRY_LINK([
                    326: #if HAVE_SYS_TYPES_H
                    327: #include <sys/types.h>
                    328: #endif
                    329: #include <sys/atomic.h>
                    330: ],
                    331: [
                    332:        unsigned int x, y;
                    333:        atomic_swap_uint(&x, 1);
                    334:        y = atomic_or_uint_nv(&x, 0);
                    335: ],
1.1.1.2 ! misho     336: [AC_DEFINE([USE_ATOMIC], [1], [Use atomic])
        !           337: AC_DEFINE([HAVE_ATOMIC_SWAP_UINT], [1], [Define 1 if you have the function.])
        !           338: AC_DEFINE([HAVE_ATOMIC_OR_UINT_NV], [1], [Define 1 if you have the function.])
1.1       misho     339: atomic="yes"]
                    340: )
                    341: fi
                    342: AC_TRY_LINK([
                    343: #if HAVE_SYS_TYPES_H
                    344: #include <sys/types.h>
                    345: #endif
                    346: #include <sys/atomic.h>
                    347: ],
                    348: [
                    349:        membar_producer();
                    350: ],
1.1.1.2 ! misho     351: [AC_DEFINE([HAVE_MEMBAR_PRODUCER], [1], [Define 1 if you have the function.])]
1.1       misho     352: )
                    353: AC_MSG_RESULT($atomic)
                    354: 
1.1.1.2 ! misho     355: # for gcc builtin
        !           356: #AC_CHECK_FUNCS([__sync_fetch_and_add __sync_val_compare_and_swap])
        !           357: #AC_CHECK_FUNCS([__sync_synchronize])
        !           358: 
        !           359: gcc_atomic="no"
        !           360: AC_MSG_CHECKING([for gcc builtin atomic operations])
        !           361: AC_TRY_LINK([
        !           362: #if HAVE_SYS_TYPES_H
        !           363: #include <sys/types.h>
        !           364: #endif
        !           365: ],
        !           366: [
        !           367:        unsigned int x, y;
        !           368:        y = __sync_fetch_and_add(&x, 0);
        !           369:        __sync_val_compare_and_swap(&x, y, 2);
        !           370: ],
        !           371: [AC_DEFINE([USE_GCC_ATOMIC], [1], [Use gcc builtin atomic])
        !           372: AC_DEFINE([HAVE_GCC_ATOMIC_FETCH_AND_ADD_UINT], [1], [Define 1 if you have the function.])
        !           373: AC_DEFINE([HAVE_GCC_ATOMIC_VAL_COMPARE_AND_SWAP_UINT], [1], [Define 1 if you have the function.])
        !           374: gcc_atomic="yes"]
        !           375: )
        !           376: AC_TRY_LINK([
        !           377: #if HAVE_SYS_TYPES_H
        !           378: #include <sys/types.h>
        !           379: #endif
        !           380: ],
        !           381: [
        !           382:        __sync_synchronize();
        !           383: ],
        !           384: [AC_DEFINE([HAVE_GCC_ATOMIC_SYNCHRONIZE], [1], [Define 1 if you have the function.])]
        !           385: )
        !           386: AC_MSG_RESULT($gcc_atomic)
        !           387: 
1.1       misho     388: AC_CONFIG_FILES([Makefile src/Makefile etc/Makefile doc/Makefile])
                    389: AC_CONFIG_FILES([src/build.h])
                    390: AC_OUTPUT

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>