1 dnl ***** BEGIN LICENSE BLOCK *****
2 dnl Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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
14 dnl The Original Code is mozilla.org code.
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.
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.
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])
65 [AC_MSG_ERROR([Option, [$1], does not take an argument ([$2]).])],
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])],
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])],
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],
88 [errprint([Option, $1, needs an "IF-SET" argument.
91 [AC_ARG_ENABLE([$1], [$2],
92 [MOZ_TWO_STRING_TEST([$1], [$enableval], yes, [$3], no, [$4], [$5])],
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])],
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])],
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
120 dnl MOZ_CHECK_PTHREADS(lib, success, failure)
121 AC_DEFUN([MOZ_CHECK_PTHREADS],
123 AC_MSG_CHECKING([for pthread_create in -l$1])
127 void *foo(void *v) { int a = 1; }
130 if (!pthread_create(&t, 0, &foo, 0)) {
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;
138 rm -f dummy.c dummy${ac_exeext} ;
139 if test "$_res" = "0"; then
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])