]> granicus.if.org Git - linux-pam/blob - acinclude.m4
Relevant BUGIDs: none
[linux-pam] / acinclude.m4
1 dnl
2 dnl JAPHAR_GREP_CFLAGS(flag, cmd_if_missing, cmd_if_present)
3 dnl
4 dnl From Japhar.  Report changes to japhar@hungry.com
5 dnl
6 AC_DEFUN([JAPHAR_GREP_CFLAGS],
7 [case "$CFLAGS" in
8 "$1" | "$1 "* | *" $1" | *" $1 "* )
9   ifelse($#, 3, [$3], [:])
10   ;;
11 *)
12   $2
13   ;;
14 esac
15 ])
16
17 dnl
18 dnl Test for __attribute__ ((unused))
19 dnl Based on code from the tcpdump version 3.7.2 source.
20 dnl
21
22 AC_DEFUN([AC_C___ATTRIBUTE__], [
23 AC_MSG_CHECKING(for __attribute__)
24 AC_CACHE_VAL(ac_cv___attribute__, [
25 AC_TRY_COMPILE([
26 #include <stdlib.h>
27 static void foo (void) __attribute__ ((unused));
28
29 static void
30 foo (void)
31 {
32   exit(1);
33 }
34 ],
35 [
36   exit (0);
37 ],
38 ac_cv___attribute__=yes,
39 ac_cv___attribute__=no)])
40 if test "$ac_cv___attribute__" = "yes"; then
41   AC_DEFINE(UNUSED, __attribute__ ((unused)), [define if your compiler has __att
42 ribute__ ((unused))])
43 else
44   AC_DEFINE(UNUSED,,)
45 fi
46 AC_MSG_RESULT($ac_cv___attribute__)
47 ])
48
49 dnl Autoconf macros for libprelude
50 dnl $id$
51
52 # Modified for LIBPRELUDE -- Yoann Vandoorselaere
53 # Modified for LIBGNUTLS -- nmav
54 # Configure paths for LIBGCRYPT
55 # Shamelessly stolen from the one of XDELTA by Owen Taylor
56 # Werner Koch   99-12-09
57
58 dnl AM_PATH_LIBPRELUDE([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
59 dnl Test for libprelude, and define LIBPRELUDE_PREFIX, LIBPRELUDE_CFLAGS, LIBPRELUDE_PTHREAD_CFLAGS, 
60 dnl LIBPRELUDE_LDFLAGS, and LIBPRELUDE_LIBS
61 dnl
62 AC_DEFUN([AM_PATH_LIBPRELUDE],
63 [dnl
64 dnl Get the cflags and libraries from the libprelude-config script
65 dnl
66 AC_ARG_WITH(libprelude-prefix,
67           [  --with-libprelude-prefix=PFX   Prefix where libprelude is installed (optional)],
68           libprelude_config_prefix="$withval", libprelude_config_prefix="")
69
70   if test x$libprelude_config_prefix != x ; then
71      if test x${LIBPRELUDE_CONFIG+set} != xset ; then
72         LIBPRELUDE_CONFIG=$libprelude_config_prefix/bin/libprelude-config
73      fi
74   fi
75
76   AC_PATH_PROG(LIBPRELUDE_CONFIG, libprelude-config, no)
77   min_libprelude_version=ifelse([$1], ,0.1.0,$1)
78   AC_MSG_CHECKING(for libprelude - version >= $min_libprelude_version)
79   no_libprelude=""
80   if test "$LIBPRELUDE_CONFIG" = "no" ; then
81     no_libprelude=yes
82   else
83     LIBPRELUDE_CFLAGS=`$LIBPRELUDE_CONFIG $libprelude_config_args --cflags`
84     LIBPRELUDE_PTHREAD_CFLAGS=`$LIBPRELUDE_CONFIG $libprelude_config_args --pthread-cflags`
85     LIBPRELUDE_LDFLAGS=`$LIBPRELUDE_CONFIG $libprelude_config_args --ldflags`
86     LIBPRELUDE_LIBS=`$LIBPRELUDE_CONFIG $libprelude_config_args --libs`
87     LIBPRELUDE_PREFIX=`$LIBPRELUDE_CONFIG $libprelude_config_args --prefix`
88     LIBPRELUDE_CONFIG_PREFIX=`$LIBPRELUDE_CONFIG $libprelude_config_args --config-prefix`
89     libprelude_config_version=`$LIBPRELUDE_CONFIG $libprelude_config_args --version`
90
91
92       ac_save_CFLAGS="$CFLAGS"
93       ac_save_LDFLAGS="$LDFLAGS"
94       ac_save_LIBS="$LIBS"
95       CFLAGS="$CFLAGS $LIBPRELUDE_CFLAGS"
96       LDFLAGS="$LDFLAGS $LIBPRELUDE_LDFLAGS"
97       LIBS="$LIBS $LIBPRELUDE_LIBS"
98 dnl
99 dnl Now check if the installed libprelude is sufficiently new. Also sanity
100 dnl checks the results of libprelude-config to some extent
101 dnl
102       rm -f conf.libpreludetest
103       AC_TRY_RUN([
104 #include <stdio.h>
105 #include <stdlib.h>
106 #include <string.h>
107 #include <libprelude/prelude.h>
108
109 int
110 main ()
111 {
112     system ("touch conf.libpreludetest");
113
114     if( strcmp( prelude_check_version(NULL), "$libprelude_config_version" ) )
115     {
116       printf("\n*** 'libprelude-config --version' returned %s, but LIBPRELUDE (%s)\n",
117              "$libprelude_config_version", prelude_check_version(NULL) );
118       printf("*** was found! If libprelude-config was correct, then it is best\n");
119       printf("*** to remove the old version of LIBPRELUDE. You may also be able to fix the error\n");
120       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
121       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
122       printf("*** required on your system.\n");
123       printf("*** If libprelude-config was wrong, set the environment variable LIBPRELUDE_CONFIG\n");
124       printf("*** to point to the correct copy of libprelude-config, and remove the file config.cache\n");
125       printf("*** before re-running configure\n");
126     }
127     else if ( strcmp(prelude_check_version(NULL), LIBPRELUDE_VERSION ) )
128     {
129       printf("\n*** LIBPRELUDE header file (version %s) does not match\n", LIBPRELUDE_VERSION);
130       printf("*** library (version %s)\n", prelude_check_version(NULL) );
131     }
132     else
133     {
134       if ( prelude_check_version( "$min_libprelude_version" ) )
135       {
136         return 0;
137       }
138      else
139       {
140         printf("no\n*** An old version of LIBPRELUDE (%s) was found.\n",
141                 prelude_check_version(NULL) );
142         printf("*** You need a version of LIBPRELUDE newer than %s. The latest version of\n",
143                "$min_libprelude_version" );
144         printf("*** LIBPRELUDE is always available from http://www.prelude-ids.org/download/releases.\n");
145         printf("*** \n");
146         printf("*** If you have already installed a sufficiently new version, this error\n");
147         printf("*** probably means that the wrong copy of the libprelude-config shell script is\n");
148         printf("*** being found. The easiest way to fix this is to remove the old version\n");
149         printf("*** of LIBPRELUDE, but you can also set the LIBPRELUDE_CONFIG environment to point to the\n");
150         printf("*** correct copy of libprelude-config. (In this case, you will have to\n");
151         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
152         printf("*** so that the correct libraries are found at run-time))\n");
153       }
154     }
155   return 1;
156 }
157 ],, no_libprelude=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
158        CFLAGS="$ac_save_CFLAGS"
159        LIBS="$ac_save_LIBS"
160        LDFLAGS="$ac_save_LDFLAGS"
161   fi
162
163   if test "x$no_libprelude" = x ; then
164      AC_MSG_RESULT(yes)
165      ifelse([$2], , :, [$2])
166   else
167      if test -f conf.libpreludetest ; then
168         :
169      else
170         AC_MSG_RESULT(no)
171      fi
172      if test "$LIBPRELUDE_CONFIG" = "no" ; then
173        echo "*** The libprelude-config script installed by LIBPRELUDE could not be found"
174        echo "*** If LIBPRELUDE was installed in PREFIX, make sure PREFIX/bin is in"
175        echo "*** your path, or set the LIBPRELUDE_CONFIG environment variable to the"
176        echo "*** full path to libprelude-config."
177      else
178        if test -f conf.libpreludetest ; then
179         :
180        else
181           echo "*** Could not run libprelude test program, checking why..."
182           CFLAGS="$CFLAGS $LIBPRELUDE_CFLAGS"
183           LDFLAGS="$LDFLAGS $LIBPRELUDE_LDFLAGS"
184           LIBS="$LIBS $LIBPRELUDE_LIBS"
185           AC_TRY_LINK([
186 #include <stdio.h>
187 #include <stdlib.h>
188 #include <string.h>
189 #include <libprelude/prelude.h>
190 ],      [ return !!prelude_check_version(NULL); ],
191         [ echo "*** The test program compiled, but did not run. This usually means"
192           echo "*** that the run-time linker is not finding LIBPRELUDE or finding the wrong"
193           echo "*** version of LIBPRELUDE. If it is not finding LIBPRELUDE, you'll need to set your"
194           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
195           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
196           echo "*** is required on your system"
197           echo "***"
198           echo "*** If you have an old version installed, it is best to remove it, although"
199           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
200           echo "***" ],
201         [ echo "*** The test program failed to compile or link. See the file config.log for the"
202           echo "*** exact error that occured. This usually means LIBPRELUDE was incorrectly installed"
203           echo "*** or that you have moved LIBPRELUDE since it was installed. In the latter case, you"
204           echo "*** may want to edit the libprelude-config script: $LIBPRELUDE_CONFIG" ])
205           CFLAGS="$ac_save_CFLAGS"
206           LDFLAGS="$ac_save_LDFLAGS"
207           LIBS="$ac_save_LIBS"
208        fi
209      fi
210      LIBPRELUDE_CFLAGS=""
211      LIBPRELUDE_LDFLAGS=""
212      LIBPRELUDE_LIBS=""
213      ifelse([$3], , :, [$3])
214   fi
215   rm -f conf.libpreludetest
216   AC_SUBST(LIBPRELUDE_CFLAGS)
217   AC_SUBST(LIBPRELUDE_PTHREAD_CFLAGS)
218   AC_SUBST(LIBPRELUDE_LDFLAGS)
219   AC_SUBST(LIBPRELUDE_LIBS)
220   AC_SUBST(LIBPRELUDE_PREFIX)
221   AC_SUBST(LIBPRELUDE_CONFIG_PREFIX)
222 ])
223
224 dnl *-*wedit:notab*-*  Please keep this as the last line.