Adding tests
[mozilla-central.git] / build / autoconf / altoptions.m4
blobf9db0a539e2556a294893af5f7bca20060650c69
1 dnl ***** BEGIN LICENSE BLOCK *****
2 dnl Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 dnl
4 dnl The contents of this file are subject to the Mozilla Public License Version
5 dnl 1.1 (the "License"); you may not use this file except in compliance with
6 dnl the License. You may obtain a copy of the License at
7 dnl http://www.mozilla.org/MPL/
8 dnl
9 dnl Software distributed under the License is distributed on an "AS IS" basis,
10 dnl WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 dnl for the specific language governing rights and limitations under the
12 dnl License.
13 dnl
14 dnl The Original Code is mozilla.org code.
15 dnl
16 dnl The Initial Developer of the Original Code is
17 dnl Netscape Communications Corporation.
18 dnl Portions created by the Initial Developer are Copyright (C) 1999
19 dnl the Initial Developer. All Rights Reserved.
20 dnl
21 dnl Contributor(s):
22 dnl
23 dnl Alternatively, the contents of this file may be used under the terms of
24 dnl either of the GNU General Public License Version 2 or later (the "GPL"),
25 dnl or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 dnl in which case the provisions of the GPL or the LGPL are applicable instead
27 dnl of those above. If you wish to allow use of your version of this file only
28 dnl under the terms of either the GPL or the LGPL, and not to allow others to
29 dnl use your version of this file under the terms of the MPL, indicate your
30 dnl decision by deleting the provisions above and replace them with the notice
31 dnl and other provisions required by the GPL or the LGPL. If you do not delete
32 dnl the provisions above, a recipient may use your version of this file under
33 dnl the terms of any one of the MPL, the GPL or the LGPL.
34 dnl
35 dnl ***** END LICENSE BLOCK *****
37 dnl altoptions.m4 - An alternative way of specifying command-line options.
38 dnl    These macros are needed to support a menu-based configurator.
39 dnl    This file also includes the macro, AM_READ_MYCONFIG, for reading
40 dnl    the 'myconfig.m4' file.
42 dnl Send comments, improvements, bugs to Steve Lamm (slamm@netscape.com).
45 dnl MOZ_ARG_ENABLE_BOOL(           NAME, HELP, IF-YES [, IF-NO [, ELSE]])
46 dnl MOZ_ARG_DISABLE_BOOL(          NAME, HELP, IF-NO [, IF-YES [, ELSE]])
47 dnl MOZ_ARG_ENABLE_STRING(         NAME, HELP, IF-SET [, ELSE])
48 dnl MOZ_ARG_ENABLE_BOOL_OR_STRING( NAME, HELP, IF-YES, IF-NO, IF-SET[, ELSE]]])
49 dnl MOZ_ARG_WITH_BOOL(             NAME, HELP, IF-YES [, IF-NO [, ELSE])
50 dnl MOZ_ARG_WITHOUT_BOOL(          NAME, HELP, IF-NO [, IF-YES [, ELSE])
51 dnl MOZ_ARG_WITH_STRING(           NAME, HELP, IF-SET [, ELSE])
52 dnl MOZ_ARG_HEADER(Comment)
53 dnl MOZ_CHECK_PTHREADS(            NAME, IF-YES [, ELSE ])
54 dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file
57 dnl MOZ_TWO_STRING_TEST(NAME, VAL, STR1, IF-STR1, STR2, IF-STR2 [, ELSE])
58 AC_DEFUN([MOZ_TWO_STRING_TEST],
59 [if test "[$2]" = "[$3]"; then
60     ifelse([$4], , :, [$4])
61   elif test "[$2]" = "[$5]"; then
62     ifelse([$6], , :, [$6])
63   else
64     ifelse([$7], ,
65       [AC_MSG_ERROR([Option, [$1], does not take an argument ([$2]).])],
66       [$7])
67   fi])
69 dnl MOZ_ARG_ENABLE_BOOL(NAME, HELP, IF-YES [, IF-NO [, ELSE]])
70 AC_DEFUN([MOZ_ARG_ENABLE_BOOL],
71 [AC_ARG_ENABLE([$1], [$2], 
72  [MOZ_TWO_STRING_TEST([$1], [$enableval], yes, [$3], no, [$4])],
73  [$5])])
75 dnl MOZ_ARG_DISABLE_BOOL(NAME, HELP, IF-NO [, IF-YES [, ELSE]])
76 AC_DEFUN([MOZ_ARG_DISABLE_BOOL],
77 [AC_ARG_ENABLE([$1], [$2],
78  [MOZ_TWO_STRING_TEST([$1], [$enableval], no, [$3], yes, [$4])],
79  [$5])])
81 dnl MOZ_ARG_ENABLE_STRING(NAME, HELP, IF-SET [, ELSE])
82 AC_DEFUN([MOZ_ARG_ENABLE_STRING],
83 [AC_ARG_ENABLE([$1], [$2], [$3], [$4])])
85 dnl MOZ_ARG_ENABLE_BOOL_OR_STRING(NAME, HELP, IF-YES, IF-NO, IF-SET[, ELSE]]])
86 AC_DEFUN([MOZ_ARG_ENABLE_BOOL_OR_STRING],
87 [ifelse([$5], , 
88  [errprint([Option, $1, needs an "IF-SET" argument.
90   m4exit(1)],
91  [AC_ARG_ENABLE([$1], [$2],
92   [MOZ_TWO_STRING_TEST([$1], [$enableval], yes, [$3], no, [$4], [$5])],
93   [$6])])])
95 dnl MOZ_ARG_WITH_BOOL(NAME, HELP, IF-YES [, IF-NO [, ELSE])
96 AC_DEFUN([MOZ_ARG_WITH_BOOL],
97 [AC_ARG_WITH([$1], [$2],
98  [MOZ_TWO_STRING_TEST([$1], [$withval], yes, [$3], no, [$4])],
99  [$5])])
101 dnl MOZ_ARG_WITHOUT_BOOL(NAME, HELP, IF-NO [, IF-YES [, ELSE])
102 AC_DEFUN([MOZ_ARG_WITHOUT_BOOL],
103 [AC_ARG_WITH([$1], [$2],
104  [MOZ_TWO_STRING_TEST([$1], [$withval], no, [$3], yes, [$4])],
105  [$5])])
107 dnl MOZ_ARG_WITH_STRING(NAME, HELP, IF-SET [, ELSE])
108 AC_DEFUN([MOZ_ARG_WITH_STRING],
109 [AC_ARG_WITH([$1], [$2], [$3], [$4])])
111 dnl MOZ_ARG_HEADER(Comment)
112 dnl This is used by webconfig to group options
113 define(MOZ_ARG_HEADER, [# $1])
116 dnl Apparently, some systems cannot properly check for the pthread
117 dnl library unless <pthread.h> is included so we need to test
118 dnl using it
120 dnl MOZ_CHECK_PTHREADS(lib, success, failure)
121 AC_DEFUN([MOZ_CHECK_PTHREADS],
123 AC_MSG_CHECKING([for pthread_create in -l$1])
124 echo "
125     #include <pthread.h>
126     #include <stdlib.h>
127     void *foo(void *v) { int a = 1;  } 
128     int main() { 
129         pthread_t t;
130         if (!pthread_create(&t, 0, &foo, 0)) {
131             pthread_join(t, 0);
132         }
133         exit(0);
134     }" > dummy.c ;
135     echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS" 1>&5;
136     ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS 2>&5;
137     _res=$? ;
138     rm -f dummy.c dummy${ac_exeext} ;
139     if test "$_res" = "0"; then
140         AC_MSG_RESULT([yes])
141         [$2]
142     else
143         AC_MSG_RESULT([no])
144         [$3]
145     fi
148 dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file
149 AC_DEFUN([MOZ_READ_MOZCONFIG],
150 [AC_REQUIRE([AC_INIT_BINSH])dnl
151 # Read in '.mozconfig' script to set the initial options.
152 # See the mozconfig2configure script for more details.
153 _AUTOCONF_TOOLS_DIR=`dirname [$]0`/[$1]/build/autoconf
154 . $_AUTOCONF_TOOLS_DIR/mozconfig2configure])