Autotools conversion: case statement

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Autotools conversion: case statement

Nicola Brisotto
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








_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Autotools conversion: case statement

Eric Noulard
2009/12/17 Nicola Brisotto <[hidden email]>:
> 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

I would try a set of

if(string MATCHES regex)

endif(string MATCHES regex)

see
cmake --help-command if

--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Autotools conversion: case statement

Moreland, Kenneth
In reply to this post by Nicola Brisotto
Re: [CMake] Autotools conversion: case statement For this particular use, doesn’t the FindThreads package do this for you?

-Ken


On 12/17/09 7:43 AM, "Nicola Brisotto" <nicolabrisotto@...> wrote:

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 <http://www.breezit.net/vcards/NicolaBrisotto.vcf>










   ****      Kenneth Moreland
    ***      Sandia National Laboratories
***********  
*** *** ***  email: kmorel@...
**  ***  **  phone: (505) 844-8919
    ***      web:   http://www.cs.unm.edu/~kmorel


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake