[CMake] Autotools conversion: case statement

Nicola Brisotto nicolabrisotto at gmail.com
Thu Dec 17 09:43:37 EST 2009


Hello,
I've an autotools script to convert to cmake. It has a lot of long case statement. Any tips to easily convert this statement?

Here an example:

case "$THREADS" in
 no | none | single)
    THREADS=none
    ;;
 posix | pthreads)
    THREADS=posix
    THREADDLLIBS=-lpthread
    case "$host" in
     x86-*-linux* | ia64-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | alpha-*-linux* | sparc*-*-linux*)
	AC_DEFINE(GC_LINUX_THREADS)
	AC_DEFINE(_REENTRANT)
        if test "${enable_parallel_mark}" = yes; then
	  AC_DEFINE(PARALLEL_MARK)
	fi
	AC_DEFINE(THREAD_LOCAL_ALLOC)
	AC_MSG_WARN("Explicit GC_INIT() calls may be required.");
	;;
     *-*-linux*)
	AC_DEFINE(GC_LINUX_THREADS)
	AC_DEFINE(_REENTRANT)
	;;
     *-*-aix*)
	AC_DEFINE(GC_AIX_THREADS)
	AC_DEFINE(_REENTRANT)
	;;
     *-*-hpux11*)
	AC_MSG_WARN("Only HP/UX 11 POSIX threads are supported.")
	AC_DEFINE(GC_HPUX_THREADS)
	AC_DEFINE(_POSIX_C_SOURCE,199506L)
	if test "${enable_parallel_mark}" = yes; then
	  AC_DEFINE(PARALLEL_MARK)
	fi
	AC_DEFINE(THREAD_LOCAL_ALLOC)
	AC_MSG_WARN("Explicit GC_INIT() calls may be required.");
	THREADDLLIBS="-lpthread -lrt"
	# HPUX needs REENTRANT for the _r calls.
	AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads.])
	;;
     *-*-hpux10*)
	AC_MSG_WARN("Only HP-UX 11 POSIX threads are supported.")
	;;
     *-*-openbsd*)
        AC_DEFINE(GC_OPENBSD_THREADS)
        THREADDLLIBS=-pthread
        INCLUDES="$INCLUDES -pthread"
        openbsd_threads=true
        ;;
     *-*-freebsd*)
	AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
	AC_DEFINE(GC_FREEBSD_THREADS)
	INCLUDES="$INCLUDES -pthread"
      	;;
     *-*-kfreebsd*-gnu)
	AC_DEFINE(GC_FREEBSD_THREADS)
	INCLUDES="$INCLUDES -pthread"
	THREADDLLIBS=-pthread
	AC_DEFINE(_REENTRANT)
        if test "${enable_parallel_mark}" = yes; then
	  AC_DEFINE(PARALLEL_MARK)
	fi
	AC_DEFINE(THREAD_LOCAL_ALLOC)
	AC_DEFINE(USE_COMPILER_TLS)
      	;;
     *-*-gnu*)
	AC_DEFINE(GC_GNU_THREADS)
	AC_DEFINE(_REENTRANT)
	AC_DEFINE(THREAD_LOCAL_ALLOC)
	;;
     *-*-netbsd*)
	AC_MSG_WARN("Only on NetBSD 2.0 or later.")
	AC_DEFINE(GC_NETBSD_THREADS)
	AC_DEFINE(_REENTRANT)
	AC_DEFINE(_PTHREADS)
	THREADDLLIBS="-lpthread -lrt"
	;;
     *-*-solaris*)
	AC_DEFINE(GC_SOLARIS_THREADS)
	AC_DEFINE(THREAD_LOCAL_ALLOC)
	THREADDLLIBS="-lpthread -lrt"
	if test "$GCC" != yes; then
          CFLAGS="$CFLAGS -O"
          need_atomic_ops_asm=true
        fi
	;;
     *-*-irix*)
	AC_DEFINE(GC_IRIX_THREADS)
	;;
     *-*-cygwin*)
	AC_DEFINE(GC_THREADS)
        if test "${enable_parallel_mark}" = yes; then
	  AC_DEFINE(PARALLEL_MARK)
	fi
	AC_DEFINE(THREAD_LOCAL_ALLOC)
	# Cygwin doesn't have a real libpthread, so Libtool can't link
	# against it.
	THREADDLLIBS=""
	win32_threads=true
	;;
     *-*-darwin*)
	AC_DEFINE(GC_DARWIN_THREADS)
	AC_DEFINE(THREAD_LOCAL_ALLOC)
	AC_MSG_WARN("Explicit GC_INIT() calls may be required.");
	# Parallel-mark is currently unreliable on Darwin; ignore request
	# if test "${enable_parallel_mark}" = yes; then
	#   AC_DEFINE(PARALLEL_MARK)
	# fi
	darwin_threads=true
	;;
     *-*-osf*)
	AC_DEFINE(GC_OSF1_THREADS)
        if test "${enable_parallel_mark}" = yes; then
	  AC_DEFINE(PARALLEL_MARK)
	  AC_DEFINE(THREAD_LOCAL_ALLOC)
	  AC_MSG_WARN("Explicit GC_INIT() calls may be required.");
	  # May want to enable it in other cases, too.
	  # Measurements havent yet been done.
	fi
	INCLUDES="$INCLUDES -pthread"
	THREADDLLIBS="-lpthread -lrt"
	;;
      *)
	AC_MSG_ERROR("Pthreads not supported by the GC on this platform.")
	;;
    esac
    ;;
 win32)
    AC_DEFINE(GC_THREADS)
    if test "${enable_parallel_mark}" = yes; then
      AC_DEFINE(PARALLEL_MARK)
      AC_DEFINE(THREAD_LOCAL_ALLOC)
    fi
    win32_threads=true
    AC_DEFINE([EMPTY_GETENV_RESULTS], [1],
	      [Wine getenv may not return NULL for missing entry.])
    ;;
 dgux386)
    THREADS=dgux386
    AC_MSG_RESULT($THREADDLLIBS)
    # Use pthread GCC  switch
    THREADDLLIBS=-pthread
    if test "${enable_parallel_mark}" = yes; then
        AC_DEFINE(PARALLEL_MARK)
    fi
    AC_DEFINE(THREAD_LOCAL_ALLOC)
    AC_MSG_WARN("Explicit GC_INIT() calls may be required.");
    AC_DEFINE([GC_DGUX386_THREADS], 1,
	      [Define to enable support for DB/UX threads on i386.])
    AC_DEFINE([DGUX_THREADS], 1,
	      [Define to enable support for DB/UX threads.])
    # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
    INCLUDES="-pthread $INCLUDES"
    ;;
 aix)
    THREADS=posix
    THREADDLLIBS=-lpthread
    AC_DEFINE(GC_AIX_THREADS)
    AC_DEFINE(_REENTRANT)
    ;;
 decosf1 | irix | mach | os2 | solaris | dce | vxworks)
    AC_MSG_ERROR(thread package $THREADS not yet supported)
    ;;
 *)
    AC_MSG_ERROR($THREADS is an unknown thread package)
    ;;
esac


Nicola Brisotto
vcard







-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091217/33583ed2/attachment.htm>


More information about the CMake mailing list