merge the formfield patch from ooo-build
[ooovba.git] / acinclude.m4
blob71f01544d11bb81b2a6012cd755a3d34c1d7524c
1 dnl @synopsis AX_FUNC_WHICH_GETSPNAM_R
2 dnl
3 dnl Determines which historical variant of the getspnam_r() call
4 dnl (taking four or five arguments) is available on the system
5 dnl and sets NEW_SHADOW_API=YES if there are five arguments.
6 dnl
7 dnl Originally named "AX_FUNC_WHICH_GETHOSTBYNAME_R". Rewritten
8 dnl for AX_FUNC_WHICH_GETSPNAM_R
9 dnl
10 dnl @author Caolan McNamara <caolan@skynet.ie>
11 dnl @author Daniel Richard G. <skunk@iskunk.org>
12 dnl @version 2006-05-01
13 dnl @license LGPL
15 AC_DEFUN([AX_FUNC_WHICH_GETSPNAM_R], [
17     AC_LANG_PUSH(C)
18     AC_MSG_CHECKING([how many arguments getspnam_r() takes])
20     AC_CACHE_VAL(ac_cv_func_which_getspnam_r, [
22 ################################################################
24 ac_cv_func_which_getspnam_r=unknown
27 # ONE ARGUMENT (sanity check)
30 # This should fail, as there is no variant of getspnam_r() that takes
31 # a single argument. If it actually compiles, then we can assume that
32 # netdb.h is not declaring the function, and the compiler is thereby
33 # assuming an implicit prototype. In which case, we're out of luck.
35 AC_COMPILE_IFELSE(
36     AC_LANG_PROGRAM(
37         [[
38             #include <sys/types.h>
39             #include <shadow.h>
40         ]],
41         [[
42             const char *name = "myname";
43             getspnam_r(name) /* ; */
44         ]]),
45     ac_cv_func_which_getspnam_r=no)
48 # FIVE ARGUMENTS
51 if test "$ac_cv_func_which_getspnam_r" = "unknown"; then
53 AC_COMPILE_IFELSE(
54     AC_LANG_PROGRAM(
55         [[
56             #include <sys/types.h>
57             #include <shadow.h>
58         ]],
59         [[
60             char buffer[[]] = { '\0' };
61             struct spwd spwdStruct;
62             const char *name = "myname";
63             getspnam_r(name, &spwdStruct, buffer, sizeof buffer, 0) /* ; */
64         ]]),
65     ac_cv_func_which_getspnam_r=five)
70 # FOUR ARGUMENTS
73 if test "$ac_cv_func_which_getspnam_r" = "unknown"; then
75 AC_COMPILE_IFELSE(
76     AC_LANG_PROGRAM(
77         [[
78             #include <sys/types.h>
79             #include <shadow.h>
80         ]],
81         [[
82             char buffer[[]] = { '\0' };
83             struct spwd spwdStruct;
84             const char *name = "myname";
85             getspnam_r(name, &spwdStruct, buffer, sizeof buffer) /* ; */
86         ]]),
87     ac_cv_func_which_getspnam_r=four)
91 ################################################################
93 ]) dnl end AC_CACHE_VAL
95 case "$ac_cv_func_which_getspnam_r" in
96     five)
97     AC_MSG_RESULT([five])
98     NEW_SHADOW_API=YES
99     ;;
101     four)
102     AC_MSG_RESULT([four])
103     ;;
105     no)
106     AC_MSG_RESULT([cannot find function declaration in shadow.h])
107     ;;
109     unknown)
110     AC_MSG_RESULT([can't tell])
111     ;;
113     *)
114     AC_MSG_ERROR([internal error])
115     ;;
116 esac
118 AC_LANG_POP(C)
120 ]) dnl end AC_DEFUN
122 dnl PKG_CHECK_MODULES_MACHACK is like PKG_CHECK_MODULES but sneaks in an extra
123 dnl argument between the first and second, denoting a program to call instead of
124 dnl pkg-config on Mac OS X (aka Darwin):
125 AC_DEFUN([PKG_CHECK_MODULES_MACHACK],
126 [if test "$_os" = "Darwin"; then
127    AC_MSG_CHECKING($1_CFLAGS)
128    $1_CFLAGS=`$2 --cflags`
129    AC_MSG_RESULT($$1_CFLAGS)
130    AC_MSG_CHECKING($1_LIBS)
131    $1_LIBS=`$2 --libs`
132    AC_MSG_RESULT($$1_LIBS)
133    AC_SUBST($1_CFLAGS)
134    AC_SUBST($1_LIBS)
135  else
136    PKG_CHECK_MODULES($1, $3, $4, $5, $6)
137  fi