Debian Codegraph @

m4/progname.m4

raw
1 dnl # Check whether libc defines __progname. Defines HAVE___PROGNAME, if
2 dnl # applicable. This check is heavily inspired by the one in OpenNTPd
3 dnl # (portable.)
4
5 dnl # Copyright (c) 2008 Moritz Grimm <[email protected]>
6 dnl #
7 dnl # Permission to use, copy, modify, and distribute this software for any
8 dnl # purpose with or without fee is hereby granted, provided that the above
9 dnl # copyright notice and this permission notice appear in all copies.
10 dnl #
11 dnl # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 dnl # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 dnl # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 dnl # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 dnl # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 dnl # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 dnl # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
19
20 dnl # AX_CHECK___PROGNAME([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
21
22
23 AC_DEFUN([AX_CHECK___PROGNAME],
24 [
25 AC_MSG_CHECKING([whether libc defines __progname])
26 AC_CACHE_VAL([local_cv_libc_defines___progname],
27 [
28 AC_LANG_PUSH([C])
29 AC_LINK_IFELSE(
30 [AC_LANG_PROGRAM(
31 [[
32 #include <stdio.h>
33 ]],
34 [[
35 extern char *__progname;
36 printf("%s", __progname);
37 ]])],
38 [local_cv_libc_defines___progname=yes],
39 [local_cv_libc_defines___progname=no]
40 )
41 AC_LANG_POP([C])
42 ])
43 if test x"${local_cv_libc_defines___progname}" = "xyes"; then
44 AC_MSG_RESULT([yes])
45 AC_DEFINE([HAVE___PROGNAME], [1],
46 [Define whether libc defines __progname.])
47 :
48 $1
49 else
50 AC_MSG_RESULT([no])
51 :
52 $2
53 fi
54 ])