build/autoconf/altoptions.m4

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build/autoconf/altoptions.m4	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,122 @@
     1.4 +dnl This Source Code Form is subject to the terms of the Mozilla Public
     1.5 +dnl License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 +dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.7 +
     1.8 +dnl altoptions.m4 - An alternative way of specifying command-line options.
     1.9 +dnl    These macros are needed to support a menu-based configurator.
    1.10 +dnl    This file also includes the macro, AM_READ_MYCONFIG, for reading
    1.11 +dnl    the 'myconfig.m4' file.
    1.12 +
    1.13 +dnl Send comments, improvements, bugs to Steve Lamm (slamm@netscape.com).
    1.14 +
    1.15 +
    1.16 +dnl MOZ_ARG_ENABLE_BOOL(           NAME, HELP, IF-YES [, IF-NO [, ELSE]])
    1.17 +dnl MOZ_ARG_DISABLE_BOOL(          NAME, HELP, IF-NO [, IF-YES [, ELSE]])
    1.18 +dnl MOZ_ARG_ENABLE_STRING(         NAME, HELP, IF-SET [, ELSE])
    1.19 +dnl MOZ_ARG_ENABLE_BOOL_OR_STRING( NAME, HELP, IF-YES, IF-NO, IF-SET[, ELSE]]])
    1.20 +dnl MOZ_ARG_WITH_BOOL(             NAME, HELP, IF-YES [, IF-NO [, ELSE])
    1.21 +dnl MOZ_ARG_WITHOUT_BOOL(          NAME, HELP, IF-NO [, IF-YES [, ELSE])
    1.22 +dnl MOZ_ARG_WITH_STRING(           NAME, HELP, IF-SET [, ELSE])
    1.23 +dnl MOZ_ARG_HEADER(Comment)
    1.24 +dnl MOZ_CHECK_PTHREADS(            NAME, IF-YES [, ELSE ])
    1.25 +dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file
    1.26 +
    1.27 +
    1.28 +dnl MOZ_TWO_STRING_TEST(NAME, VAL, STR1, IF-STR1, STR2, IF-STR2 [, ELSE])
    1.29 +AC_DEFUN([MOZ_TWO_STRING_TEST],
    1.30 +[if test "[$2]" = "[$3]"; then
    1.31 +    ifelse([$4], , :, [$4])
    1.32 +  elif test "[$2]" = "[$5]"; then
    1.33 +    ifelse([$6], , :, [$6])
    1.34 +  else
    1.35 +    ifelse([$7], ,
    1.36 +      [AC_MSG_ERROR([Option, [$1], does not take an argument ([$2]).])],
    1.37 +      [$7])
    1.38 +  fi])
    1.39 +
    1.40 +dnl MOZ_ARG_ENABLE_BOOL(NAME, HELP, IF-YES [, IF-NO [, ELSE]])
    1.41 +AC_DEFUN([MOZ_ARG_ENABLE_BOOL],
    1.42 +[AC_ARG_ENABLE([$1], [$2], 
    1.43 + [MOZ_TWO_STRING_TEST([$1], [$enableval], yes, [$3], no, [$4])],
    1.44 + [$5])])
    1.45 +
    1.46 +dnl MOZ_ARG_DISABLE_BOOL(NAME, HELP, IF-NO [, IF-YES [, ELSE]])
    1.47 +AC_DEFUN([MOZ_ARG_DISABLE_BOOL],
    1.48 +[AC_ARG_ENABLE([$1], [$2],
    1.49 + [MOZ_TWO_STRING_TEST([$1], [$enableval], no, [$3], yes, [$4])],
    1.50 + [$5])])
    1.51 +
    1.52 +dnl MOZ_ARG_ENABLE_STRING(NAME, HELP, IF-SET [, ELSE])
    1.53 +AC_DEFUN([MOZ_ARG_ENABLE_STRING],
    1.54 +[AC_ARG_ENABLE([$1], [$2], [$3], [$4])])
    1.55 +
    1.56 +dnl MOZ_ARG_ENABLE_BOOL_OR_STRING(NAME, HELP, IF-YES, IF-NO, IF-SET[, ELSE]]])
    1.57 +AC_DEFUN([MOZ_ARG_ENABLE_BOOL_OR_STRING],
    1.58 +[ifelse([$5], , 
    1.59 + [errprint([Option, $1, needs an "IF-SET" argument.
    1.60 +])
    1.61 +  m4exit(1)],
    1.62 + [AC_ARG_ENABLE([$1], [$2],
    1.63 +  [MOZ_TWO_STRING_TEST([$1], [$enableval], yes, [$3], no, [$4], [$5])],
    1.64 +  [$6])])])
    1.65 +
    1.66 +dnl MOZ_ARG_WITH_BOOL(NAME, HELP, IF-YES [, IF-NO [, ELSE])
    1.67 +AC_DEFUN([MOZ_ARG_WITH_BOOL],
    1.68 +[AC_ARG_WITH([$1], [$2],
    1.69 + [MOZ_TWO_STRING_TEST([$1], [$withval], yes, [$3], no, [$4])],
    1.70 + [$5])])
    1.71 +
    1.72 +dnl MOZ_ARG_WITHOUT_BOOL(NAME, HELP, IF-NO [, IF-YES [, ELSE])
    1.73 +AC_DEFUN([MOZ_ARG_WITHOUT_BOOL],
    1.74 +[AC_ARG_WITH([$1], [$2],
    1.75 + [MOZ_TWO_STRING_TEST([$1], [$withval], no, [$3], yes, [$4])],
    1.76 + [$5])])
    1.77 +
    1.78 +dnl MOZ_ARG_WITH_STRING(NAME, HELP, IF-SET [, ELSE])
    1.79 +AC_DEFUN([MOZ_ARG_WITH_STRING],
    1.80 +[AC_ARG_WITH([$1], [$2], [$3], [$4])])
    1.81 +
    1.82 +dnl MOZ_ARG_HEADER(Comment)
    1.83 +dnl This is used by webconfig to group options
    1.84 +define(MOZ_ARG_HEADER, [# $1])
    1.85 +
    1.86 +dnl
    1.87 +dnl Apparently, some systems cannot properly check for the pthread
    1.88 +dnl library unless <pthread.h> is included so we need to test
    1.89 +dnl using it
    1.90 +dnl
    1.91 +dnl MOZ_CHECK_PTHREADS(lib, success, failure)
    1.92 +AC_DEFUN([MOZ_CHECK_PTHREADS],
    1.93 +[
    1.94 +AC_MSG_CHECKING([for pthread_create in -l$1])
    1.95 +echo "
    1.96 +    #include <pthread.h>
    1.97 +    #include <stdlib.h>
    1.98 +    void *foo(void *v) { int a = 1;  } 
    1.99 +    int main() { 
   1.100 +        pthread_t t;
   1.101 +        if (!pthread_create(&t, 0, &foo, 0)) {
   1.102 +            pthread_join(t, 0);
   1.103 +        }
   1.104 +        exit(0);
   1.105 +    }" > dummy.c ;
   1.106 +    echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS" 1>&5;
   1.107 +    ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS 2>&5;
   1.108 +    _res=$? ;
   1.109 +    rm -f dummy.c dummy${ac_exeext} ;
   1.110 +    if test "$_res" = "0"; then
   1.111 +        AC_MSG_RESULT([yes])
   1.112 +        [$2]
   1.113 +    else
   1.114 +        AC_MSG_RESULT([no])
   1.115 +        [$3]
   1.116 +    fi
   1.117 +])
   1.118 +
   1.119 +dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file
   1.120 +AC_DEFUN([MOZ_READ_MOZCONFIG],
   1.121 +[AC_REQUIRE([AC_INIT_BINSH])dnl
   1.122 +# Read in '.mozconfig' script to set the initial options.
   1.123 +# See the mozconfig2configure script for more details.
   1.124 +_AUTOCONF_TOOLS_DIR=`dirname [$]0`/[$1]/build/autoconf
   1.125 +. $_AUTOCONF_TOOLS_DIR/mozconfig2configure])

mercurial