1# getopt.m4 serial 7
2dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# The getopt module assume you want GNU getopt, with getopt_long etc,
8# rather than vanilla POSIX getopt.  This means your your code should
9# always include <getopt.h> for the getopt prototypes.
10
11AC_DEFUN([gl_GETOPT_SUBSTITUTE],
12[
13  GETOPT_H=getopt.h
14  AC_LIBOBJ([getopt])
15  AC_LIBOBJ([getopt1])
16  AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
17    [Define to rpl_ if the getopt replacement functions and variables
18     should be used.])
19  AC_SUBST([GETOPT_H])
20])
21
22AC_DEFUN([gl_GETOPT],
23[
24  gl_PREREQ_GETOPT
25
26  if test -z "$GETOPT_H"; then
27    GETOPT_H=
28    AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
29    AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h])
30
31    dnl BSD getopt_long uses an incompatible method to reset option processing,
32    dnl and (as of 2004-10-15) mishandles optional option-arguments.
33    AC_CHECK_DECL([optreset], [GETOPT_H=getopt.h], [], [#include <getopt.h>])
34
35    if test -n "$GETOPT_H"; then
36      gl_GETOPT_SUBSTITUTE
37    fi
38  fi
39])
40
41# Prerequisites of lib/getopt*.
42AC_DEFUN([gl_PREREQ_GETOPT], [:])
43