1
dnl This Source Code Form is subject to the terms of the Mozilla Public
2
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
3
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
dnl altoptions.m4 - An alternative way of specifying command-line options.
6
dnl These macros are needed to support a menu-based configurator.
7
dnl This file also includes the macro, AM_READ_MYCONFIG, for reading
8
dnl the 'myconfig.m4' file.
10
dnl Send comments, improvements, bugs to Steve Lamm (slamm@netscape.com).
13
dnl MOZ_ARG_ENABLE_BOOL( NAME, HELP, IF-YES [, IF-NO [, ELSE]])
14
dnl MOZ_ARG_DISABLE_BOOL( NAME, HELP, IF-NO [, IF-YES [, ELSE]])
15
dnl MOZ_ARG_ENABLE_STRING( NAME, HELP, IF-SET [, ELSE])
16
dnl MOZ_ARG_ENABLE_BOOL_OR_STRING( NAME, HELP, IF-YES, IF-NO, IF-SET[, ELSE]]])
17
dnl MOZ_ARG_WITH_BOOL( NAME, HELP, IF-YES [, IF-NO [, ELSE])
18
dnl MOZ_ARG_WITHOUT_BOOL( NAME, HELP, IF-NO [, IF-YES [, ELSE])
19
dnl MOZ_ARG_WITH_STRING( NAME, HELP, IF-SET [, ELSE])
20
dnl MOZ_ARG_HEADER(Comment)
21
dnl MOZ_CHECK_PTHREADS( NAME, IF-YES [, ELSE ])
22
dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file
25
dnl MOZ_TWO_STRING_TEST(NAME, VAL, STR1, IF-STR1, STR2, IF-STR2 [, ELSE])
26
AC_DEFUN([MOZ_TWO_STRING_TEST],
27
[if test "[$2]" = "[$3]"; then
28
ifelse([$4], , :, [$4])
29
elif test "[$2]" = "[$5]"; then
30
ifelse([$6], , :, [$6])
33
[AC_MSG_ERROR([Option, [$1], does not take an argument ([$2]).])],
37
dnl MOZ_ARG_ENABLE_BOOL(NAME, HELP, IF-YES [, IF-NO [, ELSE]])
38
AC_DEFUN([MOZ_ARG_ENABLE_BOOL],
39
[AC_ARG_ENABLE([$1], [$2],
40
[MOZ_TWO_STRING_TEST([$1], [$enableval], yes, [$3], no, [$4])],
43
dnl MOZ_ARG_DISABLE_BOOL(NAME, HELP, IF-NO [, IF-YES [, ELSE]])
44
AC_DEFUN([MOZ_ARG_DISABLE_BOOL],
45
[AC_ARG_ENABLE([$1], [$2],
46
[MOZ_TWO_STRING_TEST([$1], [$enableval], no, [$3], yes, [$4])],
49
dnl MOZ_ARG_ENABLE_STRING(NAME, HELP, IF-SET [, ELSE])
50
AC_DEFUN([MOZ_ARG_ENABLE_STRING],
51
[AC_ARG_ENABLE([$1], [$2], [$3], [$4])])
53
dnl MOZ_ARG_ENABLE_BOOL_OR_STRING(NAME, HELP, IF-YES, IF-NO, IF-SET[, ELSE]]])
54
AC_DEFUN([MOZ_ARG_ENABLE_BOOL_OR_STRING],
56
[errprint([Option, $1, needs an "IF-SET" argument.
59
[AC_ARG_ENABLE([$1], [$2],
60
[MOZ_TWO_STRING_TEST([$1], [$enableval], yes, [$3], no, [$4], [$5])],
63
dnl MOZ_ARG_WITH_BOOL(NAME, HELP, IF-YES [, IF-NO [, ELSE])
64
AC_DEFUN([MOZ_ARG_WITH_BOOL],
65
[AC_ARG_WITH([$1], [$2],
66
[MOZ_TWO_STRING_TEST([$1], [$withval], yes, [$3], no, [$4])],
69
dnl MOZ_ARG_WITHOUT_BOOL(NAME, HELP, IF-NO [, IF-YES [, ELSE])
70
AC_DEFUN([MOZ_ARG_WITHOUT_BOOL],
71
[AC_ARG_WITH([$1], [$2],
72
[MOZ_TWO_STRING_TEST([$1], [$withval], no, [$3], yes, [$4])],
75
dnl MOZ_ARG_WITH_STRING(NAME, HELP, IF-SET [, ELSE])
76
AC_DEFUN([MOZ_ARG_WITH_STRING],
77
[AC_ARG_WITH([$1], [$2], [$3], [$4])])
79
dnl MOZ_ARG_HEADER(Comment)
80
dnl This is used by webconfig to group options
81
define(MOZ_ARG_HEADER, [# $1])
84
dnl Apparently, some systems cannot properly check for the pthread
85
dnl library unless <pthread.h> is included so we need to test
88
dnl MOZ_CHECK_PTHREADS(lib, success, failure)
89
AC_DEFUN([MOZ_CHECK_PTHREADS],
91
AC_MSG_CHECKING([for pthread_create in -l$1])
95
void *foo(void *v) { int a = 1; }
98
if (!pthread_create(&t, 0, &foo, 0)) {
103
echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS" 1>&5;
104
${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS 2>&5;
106
rm -f dummy.c dummy${ac_exeext} ;
107
if test "$_res" = "0"; then
116
dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file
117
AC_DEFUN([MOZ_READ_MOZCONFIG],
118
[AC_REQUIRE([AC_INIT_BINSH])dnl
119
# Read in '.mozconfig' script to set the initial options.
120
# See the mozconfig2configure script for more details.
121
_AUTOCONF_TOOLS_DIR=`dirname [$]0`/[$1]/build/autoconf
122
. $_AUTOCONF_TOOLS_DIR/mozconfig2configure])