< prev index next >

common/autoconf/basics.m4

Print this page


   1 #
   2 # Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   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 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 


   1 #
   2 # Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   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 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],
  40 #     BAR: [
  41 #         $ECHO hello world
  42 #     ])
  43 # Note that the argument value must start on the same line as the argument name.
  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 


< prev index next >