michael@0: dnl This Source Code Form is subject to the terms of the Mozilla Public michael@0: dnl License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: dnl altoptions.m4 - An alternative way of specifying command-line options. michael@0: dnl These macros are needed to support a menu-based configurator. michael@0: dnl This file also includes the macro, AM_READ_MYCONFIG, for reading michael@0: dnl the 'myconfig.m4' file. michael@0: michael@0: dnl Send comments, improvements, bugs to Steve Lamm (slamm@netscape.com). michael@0: michael@0: michael@0: dnl MOZ_ARG_ENABLE_BOOL( NAME, HELP, IF-YES [, IF-NO [, ELSE]]) michael@0: dnl MOZ_ARG_DISABLE_BOOL( NAME, HELP, IF-NO [, IF-YES [, ELSE]]) michael@0: dnl MOZ_ARG_ENABLE_STRING( NAME, HELP, IF-SET [, ELSE]) michael@0: dnl MOZ_ARG_ENABLE_BOOL_OR_STRING( NAME, HELP, IF-YES, IF-NO, IF-SET[, ELSE]]]) michael@0: dnl MOZ_ARG_WITH_BOOL( NAME, HELP, IF-YES [, IF-NO [, ELSE]) michael@0: dnl MOZ_ARG_WITHOUT_BOOL( NAME, HELP, IF-NO [, IF-YES [, ELSE]) michael@0: dnl MOZ_ARG_WITH_STRING( NAME, HELP, IF-SET [, ELSE]) michael@0: dnl MOZ_ARG_HEADER(Comment) michael@0: dnl MOZ_CHECK_PTHREADS( NAME, IF-YES [, ELSE ]) michael@0: dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file michael@0: michael@0: michael@0: dnl MOZ_TWO_STRING_TEST(NAME, VAL, STR1, IF-STR1, STR2, IF-STR2 [, ELSE]) michael@0: AC_DEFUN([MOZ_TWO_STRING_TEST], michael@0: [if test "[$2]" = "[$3]"; then michael@0: ifelse([$4], , :, [$4]) michael@0: elif test "[$2]" = "[$5]"; then michael@0: ifelse([$6], , :, [$6]) michael@0: else michael@0: ifelse([$7], , michael@0: [AC_MSG_ERROR([Option, [$1], does not take an argument ([$2]).])], michael@0: [$7]) michael@0: fi]) michael@0: michael@0: dnl MOZ_ARG_ENABLE_BOOL(NAME, HELP, IF-YES [, IF-NO [, ELSE]]) michael@0: AC_DEFUN([MOZ_ARG_ENABLE_BOOL], michael@0: [AC_ARG_ENABLE([$1], [$2], michael@0: [MOZ_TWO_STRING_TEST([$1], [$enableval], yes, [$3], no, [$4])], michael@0: [$5])]) michael@0: michael@0: dnl MOZ_ARG_DISABLE_BOOL(NAME, HELP, IF-NO [, IF-YES [, ELSE]]) michael@0: AC_DEFUN([MOZ_ARG_DISABLE_BOOL], michael@0: [AC_ARG_ENABLE([$1], [$2], michael@0: [MOZ_TWO_STRING_TEST([$1], [$enableval], no, [$3], yes, [$4])], michael@0: [$5])]) michael@0: michael@0: dnl MOZ_ARG_ENABLE_STRING(NAME, HELP, IF-SET [, ELSE]) michael@0: AC_DEFUN([MOZ_ARG_ENABLE_STRING], michael@0: [AC_ARG_ENABLE([$1], [$2], [$3], [$4])]) michael@0: michael@0: dnl MOZ_ARG_ENABLE_BOOL_OR_STRING(NAME, HELP, IF-YES, IF-NO, IF-SET[, ELSE]]]) michael@0: AC_DEFUN([MOZ_ARG_ENABLE_BOOL_OR_STRING], michael@0: [ifelse([$5], , michael@0: [errprint([Option, $1, needs an "IF-SET" argument. michael@0: ]) michael@0: m4exit(1)], michael@0: [AC_ARG_ENABLE([$1], [$2], michael@0: [MOZ_TWO_STRING_TEST([$1], [$enableval], yes, [$3], no, [$4], [$5])], michael@0: [$6])])]) michael@0: michael@0: dnl MOZ_ARG_WITH_BOOL(NAME, HELP, IF-YES [, IF-NO [, ELSE]) michael@0: AC_DEFUN([MOZ_ARG_WITH_BOOL], michael@0: [AC_ARG_WITH([$1], [$2], michael@0: [MOZ_TWO_STRING_TEST([$1], [$withval], yes, [$3], no, [$4])], michael@0: [$5])]) michael@0: michael@0: dnl MOZ_ARG_WITHOUT_BOOL(NAME, HELP, IF-NO [, IF-YES [, ELSE]) michael@0: AC_DEFUN([MOZ_ARG_WITHOUT_BOOL], michael@0: [AC_ARG_WITH([$1], [$2], michael@0: [MOZ_TWO_STRING_TEST([$1], [$withval], no, [$3], yes, [$4])], michael@0: [$5])]) michael@0: michael@0: dnl MOZ_ARG_WITH_STRING(NAME, HELP, IF-SET [, ELSE]) michael@0: AC_DEFUN([MOZ_ARG_WITH_STRING], michael@0: [AC_ARG_WITH([$1], [$2], [$3], [$4])]) michael@0: michael@0: dnl MOZ_ARG_HEADER(Comment) michael@0: dnl This is used by webconfig to group options michael@0: define(MOZ_ARG_HEADER, [# $1]) michael@0: michael@0: dnl michael@0: dnl Apparently, some systems cannot properly check for the pthread michael@0: dnl library unless is included so we need to test michael@0: dnl using it michael@0: dnl michael@0: dnl MOZ_CHECK_PTHREADS(lib, success, failure) michael@0: AC_DEFUN([MOZ_CHECK_PTHREADS], michael@0: [ michael@0: AC_MSG_CHECKING([for pthread_create in -l$1]) michael@0: echo " michael@0: #include michael@0: #include michael@0: void *foo(void *v) { int a = 1; } michael@0: int main() { michael@0: pthread_t t; michael@0: if (!pthread_create(&t, 0, &foo, 0)) { michael@0: pthread_join(t, 0); michael@0: } michael@0: exit(0); michael@0: }" > dummy.c ; michael@0: echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS" 1>&5; michael@0: ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS 2>&5; michael@0: _res=$? ; michael@0: rm -f dummy.c dummy${ac_exeext} ; michael@0: if test "$_res" = "0"; then michael@0: AC_MSG_RESULT([yes]) michael@0: [$2] michael@0: else michael@0: AC_MSG_RESULT([no]) michael@0: [$3] michael@0: fi michael@0: ]) michael@0: michael@0: dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file michael@0: AC_DEFUN([MOZ_READ_MOZCONFIG], michael@0: [AC_REQUIRE([AC_INIT_BINSH])dnl michael@0: # Read in '.mozconfig' script to set the initial options. michael@0: # See the mozconfig2configure script for more details. michael@0: _AUTOCONF_TOOLS_DIR=`dirname [$]0`/[$1]/build/autoconf michael@0: . $_AUTOCONF_TOOLS_DIR/mozconfig2configure])