diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-09-11 23:15:16 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-09-13 10:13:24 +0300 |
commit | 2cbce6f40d92d42218dd5c4c38dd9badb244dc79 (patch) | |
tree | d19ab8c29077911dbe4817669405c19bf206078e /acinclude.m4 | |
download | vmod-sql-2cbce6f40d92d42218dd5c4c38dd9badb244dc79.tar.gz vmod-sql-2cbce6f40d92d42218dd5c4c38dd9badb244dc79.tar.bz2 |
Initial commit
Diffstat (limited to 'acinclude.m4')
-rw-r--r-- | acinclude.m4 | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..3cefdf8 --- /dev/null +++ b/acinclude.m4 | |||
@@ -0,0 +1,109 @@ | |||
1 | # Copyright (C) 2001, 2006, 2008-2012 Sergey Poznyakoff | ||
2 | # | ||
3 | # This program is free software; you can redistribute it and/or modify | ||
4 | # it under the terms of the GNU General Public License as published by | ||
5 | # the Free Software Foundation; either version 3, or (at your option) | ||
6 | # any later version. | ||
7 | # | ||
8 | # This program is distributed in the hope that it will be useful, | ||
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | # GNU General Public License for more details. | ||
12 | # | ||
13 | # You should have received a copy of the GNU General Public License along | ||
14 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | |||
16 | AC_DEFUN([GR_ENABLE],[ | ||
17 | AC_ARG_ENABLE($1, | ||
18 | AC_HELP_STRING([--disable-$1], [Disable pam_$1]), | ||
19 | [build_$1=$enableval], | ||
20 | [build_$1=m4_if([$2],[],yes,m4_if([$3],[],probe,[$3]))]) | ||
21 | m4_pushdef([upmodname],translit($1, [a-z.-], [A-Z__])) | ||
22 | m4_if([$2],[],,[if test $build_$1 != no; then | ||
23 | $2 | ||
24 | test $build_$1 = probe && build_$1=no | ||
25 | fi]) | ||
26 | AM_CONDITIONAL([GR_COND_]upmodname, [test "$[]build_$1" = "yes"]) | ||
27 | m4_popdef([upmodname]) | ||
28 | ]) | ||
29 | |||
30 | dnl GR_FLUSHLEFT -- remove all whitespace at the beginning of lines | ||
31 | dnl This is useful for c-code which may include cpp statements | ||
32 | dnl | ||
33 | define([GR_FLUSHLEFT], | ||
34 | [changequote(`,')dnl | ||
35 | patsubst(`$1', `^[ ]+') | ||
36 | changequote([,])])dnl | ||
37 | |||
38 | dnl GR_RESULT_ACTIONS -- generate shell code for the result of a test | ||
39 | dnl $1 -- CVAR -- cache variable to check | ||
40 | dnl $2 -- NAME -- if not empty, used to generate a default value TRUE: | ||
41 | dnl `AC_DEFINE(HAVE_NAME)' | ||
42 | dnl $2 -- TRUE -- what to do if the CVAR is not `no' | ||
43 | dnl $3 -- FALSE -- what to do otherwise; defaults to `:' | ||
44 | dnl | ||
45 | AC_DEFUN([GR_RESULT_ACTIONS], [ | ||
46 | [if test "$$1" != "" -a "$$1" != no; then | ||
47 | ]ifelse([$3], , | ||
48 | [AC_DEFINE(HAVE_]translit($2, [a-z ./<>], [A-Z___])[,1,[FIXME])], | ||
49 | [$3])[ | ||
50 | else | ||
51 | ]ifelse([$4], , [:], [$4])[ | ||
52 | fi]])dnl | ||
53 | |||
54 | dnl GR_CHECK_STRUCT_FIELD -- See if a structure has a particular field | ||
55 | dnl $1 - NAME -- name of structure | ||
56 | dnl $2 - FIELD -- name of field to test | ||
57 | dnl $3 - INCLS -- C program text to inculde necessary files for testing | ||
58 | dnl $4 - TRUE -- what to do if struct NAME has FIELD; defaults to | ||
59 | dnl `AC_DEFINE(HAVE_NAME_FIELD)' | ||
60 | dnl $5 - FALSE -- what to do if not; defaults to `:' | ||
61 | dnl | ||
62 | dnl NOTE: We still don't use AC_CHECK_MEMBERS, since it has (as of | ||
63 | dnl autoconf 2.53) a bug which prevents it from recognizing members | ||
64 | dnl of aggregate type. | ||
65 | |||
66 | AC_DEFUN([GR_CHECK_STRUCT_FIELD], [ | ||
67 | define([pm_CVAR], [pm_cv_struct_]translit($1_$2, [A-Z], [a-z]))dnl | ||
68 | AC_CACHE_CHECK([whether struct $1 has $2 field], pm_CVAR, | ||
69 | AC_TRY_COMPILE(GR_FLUSHLEFT([$3]), | ||
70 | [struct $1 pm_x; int pm_y = sizeof pm_x.$2;], | ||
71 | pm_CVAR[=yes], pm_CVAR[=no])) | ||
72 | GR_RESULT_ACTIONS(pm_CVAR, [$1_$2], [$4], [$5])dnl | ||
73 | undefine([pm_CVAR])])dnl | ||
74 | |||
75 | dnl Arguments: | ||
76 | dnl $1 -- Library to look for | ||
77 | dnl $2 -- Function to check in the library | ||
78 | dnl $3 -- Any additional libraries that might be needed | ||
79 | dnl $4 -- Action to be taken when test succeeds | ||
80 | dnl $5 -- Action to be taken when test fails | ||
81 | dnl $6 -- Directories where the library may reside | ||
82 | AC_DEFUN([GR_CHECK_LIB], | ||
83 | [m4_ifval([$4], , [AH_CHECK_LIB([$1])])dnl | ||
84 | AS_VAR_PUSHDEF([pm_Lib], [pm_cv_lib_$1])dnl | ||
85 | AC_CACHE_CHECK([for $2 in -l$1], [pm_Lib], | ||
86 | [AS_VAR_SET([pm_Lib], [no]) | ||
87 | pm_check_lib_save_LIBS=$LIBS | ||
88 | for path in "" $6 | ||
89 | do | ||
90 | if test -n "$path"; then | ||
91 | pm_ldflags="-L$path -l$1 $3" | ||
92 | else | ||
93 | pm_ldflags="-l$1 $3" | ||
94 | fi | ||
95 | LIBS="$pm_ldflags $pm_check_lib_save_LIBS" | ||
96 | AC_LINK_IFELSE([AC_LANG_CALL([], [$2])], | ||
97 | [AS_VAR_SET([pm_Lib], ["$pm_ldflags"]) | ||
98 | break]) | ||
99 | done | ||
100 | LIBS=$pm_check_lib_save_LIBS]) | ||
101 | AS_IF([test "AS_VAR_GET([pm_Lib])" != no], | ||
102 | [m4_default([$4], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1)) | ||
103 | LIBS="-l$1 $LIBS" | ||
104 | ])], | ||
105 | [$5])dnl | ||
106 | AS_VAR_POPDEF([pm_Lib])dnl | ||
107 | ])# GR_CHECK_LIB | ||
108 | |||
109 | |||