< prev index next >

common/autoconf/basics.m4

Print this page




   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 




































































  26 # Test if $1 is a valid argument to $3 (often is $JAVA passed as $3)
  27 # If so, then append $1 to $2 \
  28 # Also set JVM_ARG_OK to true/false depending on outcome.
  29 AC_DEFUN([ADD_JVM_ARG_IF_OK],
  30 [
  31   $ECHO "Check if jvm arg is ok: $1" >&AS_MESSAGE_LOG_FD
  32   $ECHO "Command: $3 $1 -version" >&AS_MESSAGE_LOG_FD
  33   OUTPUT=`$3 $1 -version 2>&1`
  34   FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
  35   FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
  36   if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
  37     $2="[$]$2 $1"
  38     JVM_ARG_OK=true
  39   else
  40     $ECHO "Arg failed:" >&AS_MESSAGE_LOG_FD
  41     $ECHO "$OUTPUT" >&AS_MESSAGE_LOG_FD
  42     JVM_ARG_OK=false
  43   fi
  44 ])
  45 




   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 # Create a function/macro that takes a series of named arguments. The call is
  27 # similar to AC_DEFUN, but the setup of the function looks like like this:
  28 # BASIC_DEFUN_NAMED([MYFUNC], [FOO *BAR], [$@], [
  29 # ... do something
  30 #   AC_MSG_NOTICE([Value of BAR is ARG_BAR])
  31 # ])
  32 # A star (*) in front of a named argument means that it is required and it's
  33 # presence will be verified. To pass e.g. the first value as a normal indexed
  34 # argument, use [m4_shift($@)] as the third argument instead of [$@]. These
  35 # arguments are referenced in the function by their name prefixed by ARG_, e.g.
  36 # "ARG_FOO".
  37 #
  38 # The generated function can be called like this:
  39 # MYFUNC(FOO: [foo-val], BAR:
  40 #     [
  41 #         $ECHO hello world
  42 #     ])
  43 #
  44 #
  45 # Argument 1: Name of the function to define
  46 # Argument 2: List of legal named arguments, with a * prefix for required arguments
  47 # Argument 3: Argument array to treat as named, typically $@
  48 # Argument 4: The main function body
  49 AC_DEFUN([BASIC_DEFUN_NAMED],
  50 [
  51   AC_DEFUN($1, [
  52     m4_foreach(arg, m4_split($2), [
  53       m4_if(m4_bregexp(arg, [^\*]), -1,
  54         [
  55           m4_set_add(legal_named_args, arg)
  56         ],
  57         [
  58           m4_set_add(legal_named_args, m4_substr(arg, 1))
  59           m4_set_add(required_named_args, m4_substr(arg, 1))
  60         ]
  61       )
  62     ])
  63 
  64     m4_foreach([arg], [$3], [
  65       m4_define(arg_name, m4_substr(arg, 0, m4_bregexp(arg, [: ])))
  66       m4_set_contains(legal_named_args, arg_name, [],[AC_MSG_ERROR([Internal error: arg_name is not a valid named argument to [$1]. Valid arguments are 'm4_set_contents(legal_named_args, [ ])'.])])
  67       m4_set_remove(required_named_args, arg_name)
  68       m4_set_remove(legal_named_args, arg_name)
  69       m4_pushdef([ARG_][]arg_name, m4_substr(arg, m4_incr(m4_incr(m4_bregexp(arg, [: ])))))
  70       m4_set_add(defined_args, arg_name)
  71       m4_undefine([arg_name])
  72     ])
  73     m4_set_empty(required_named_args, [], [
  74       AC_MSG_ERROR([Internal error: Required named arguments are missing for [$1]. Missing arguments: 'm4_set_contents(required_named_args, [ ])'])
  75     ])
  76     m4_foreach([arg], m4_indir([m4_dquote]m4_set_listc([legal_named_args])), [
  77       m4_pushdef([ARG_][]arg, [])
  78       m4_set_add(defined_args, arg)
  79     ])
  80     m4_set_delete(legal_named_args)
  81     m4_set_delete(required_named_args)
  82 
  83     # Execute function body
  84     $4
  85 
  86     m4_foreach([arg], m4_indir([m4_dquote]m4_set_listc([defined_args])), [
  87       m4_popdef([ARG_][]arg)
  88     ])
  89 
  90     m4_set_delete(defined_args)
  91   ])
  92 ])
  93 
  94 # Test if $1 is a valid argument to $3 (often is $JAVA passed as $3)
  95 # If so, then append $1 to $2 \
  96 # Also set JVM_ARG_OK to true/false depending on outcome.
  97 AC_DEFUN([ADD_JVM_ARG_IF_OK],
  98 [
  99   $ECHO "Check if jvm arg is ok: $1" >&AS_MESSAGE_LOG_FD
 100   $ECHO "Command: $3 $1 -version" >&AS_MESSAGE_LOG_FD
 101   OUTPUT=`$3 $1 -version 2>&1`
 102   FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn`
 103   FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""`
 104   if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
 105     $2="[$]$2 $1"
 106     JVM_ARG_OK=true
 107   else
 108     $ECHO "Arg failed:" >&AS_MESSAGE_LOG_FD
 109     $ECHO "$OUTPUT" >&AS_MESSAGE_LOG_FD
 110     JVM_ARG_OK=false
 111   fi
 112 ])
 113 


< prev index next >