libtar-1.2.11 tarball sources, taken from Debian's orig tar
[libtar.git] / autoconf / aclocal.m4
blobee34c8e557b4eda4eb136b2160ee8b4ef71f5bf8
1 m4_include([encap.m4])
2 m4_include([ac_path_generic.m4])
5 # PSG_LIB_READLINE
6 # ----------------
7 # Check for GNU readline library.
8 AC_DEFUN([PSG_LIB_READLINE], [
9   AC_CHECK_HEADERS([readline/readline.h])
10   AC_CHECK_HEADERS([readline/history.h])
11   if test "$ac_cv_header_readline_readline_h" = "yes"; then
12     AC_SEARCH_LIBS([tputs], [termcap curses])
13     AC_CHECK_LIB([readline], [rl_callback_handler_install])
14   fi
18 # PSG_LIB_TAR
19 # -----------
20 # Check for usable version of libtar library.
21 AC_DEFUN([PSG_LIB_TAR], [
22   psg_old_libs="$LIBS"
23   LIBS="$LIBS -ltar"
24   AC_CACHE_CHECK([for usable version of libtar],
25     [psg_cv_lib_tar_usable],
26     [AC_TRY_RUN([
27 #include <stdio.h>
28 #include <string.h>
29 #include <libtar.h>
31 int main(int argc, char *argv[]) {
32   return (strcmp(libtar_version, "1.2") >= 0 ? 0 : 1);
35       [psg_cv_lib_tar_usable=yes],
36       [psg_cv_lib_tar_usable=no],
37       [psg_cv_lib_tar_usable=no]
38     )]
39   )
40   if test "$psg_cv_lib_tar_usable" = "yes"; then
41     AC_DEFINE([HAVE_LIBTAR], 1,
42               [Define if your system has a current version of libtar])
43   else
44     LIBS="$psg_old_libs"
45   fi
49 # PSG_LIB_FGET
50 # ------------
51 # Check for usable version of libfget library.
52 AC_DEFUN([PSG_LIB_FGET], [
53   psg_old_libs="$LIBS"
54   AC_CHECK_LIB([socket], [socket])
55   AC_CHECK_LIB([nsl], [gethostbyname])
56   LIBS="$LIBS -lfget"
57   AC_CACHE_CHECK([for usable version of libfget],
58     [psg_cv_lib_fget_usable],
59     [AC_TRY_COMPILE([
60         #include <libfget.h>
61       ], [
62         FTP *ftp;
63         char buf[10240];
64         struct ftp_url fu;
66         ftp_url_parse("ftp://host.com/dir/file.txt", &fu);
68         ftp_connect(&ftp, fu.fu_hostname, buf, sizeof(buf), 0, 0,
69                     -1, -1, NULL, NULL);
70       ],
71       [psg_cv_lib_fget_usable=yes],
72       [psg_cv_lib_fget_usable=no]
73     )]
74   )
75   if test "$psg_cv_lib_fget_usable" = "yes"; then
76     AC_DEFINE([HAVE_LIBFGET], 1,
77               [Define if your system has a current version of libfget])
78   else
79     LIBS="$psg_old_libs";
80   fi
84 # PSG_LIB_WRAP
85 # ------------
86 # Check for TCP Wrapper library.
87 AC_DEFUN([PSG_LIB_WRAP], [
88   AC_CHECK_HEADERS([tcpd.h])
89   if test "$ac_cv_header_tcpd_h" = "yes"; then
90     psg_old_libs="$LIBS"
91     LIBS="$LIBS -lwrap"
92     AC_CACHE_CHECK([for libwrap library],
93       [psg_cv_lib_wrap_hosts_ctl],
94       AC_TRY_LINK([
95           #include <stdio.h>
96           #include <tcpd.h>
97           int allow_severity;
98           int deny_severity;
99         ], [
100           hosts_ctl("test", STRING_UNKNOWN, "10.0.0.1", STRING_UNKNOWN);
101         ],
102         [psg_cv_lib_wrap_hosts_ctl=yes],
103         [psg_cv_lib_wrap_hosts_ctl=no]
104       )
105     )
106     if test "$psg_cv_lib_wrap_hosts_ctl" = "yes"; then
107       AC_DEFINE([HAVE_LIBWRAP], 1, [Define if you have libwrap])
108     else
109       LIBS="$psg_old_libs"
110     fi
111   fi
115 # PSG_REPLACE_TYPE(type_t, default, [includes])
116 # ---------------------------------------------
117 # Check for arbitrary type in arbitrary header file(s).
118 AC_DEFUN([PSG_REPLACE_TYPE],
119   [AC_CHECK_TYPES([$1],
120     ,
121     [AC_DEFINE($1, $2,
122       [Define to `$2' if not defined in system header files.]
123     )],
124     $3
125   )]
129 # PSG_SHLIB(includes, code)
130 # -------------------------
131 # Check how to build shared libraries containing the specified code
132 # (very rudimentary).
133 AC_DEFUN([PSG_SHLIB], [
134   AC_MSG_CHECKING([how to build shared libraries])
135   cflag_options="-fpic";
136   ldflag_options="-G -shared";
137   if test "$CC" != "gcc"; then
138     case "`uname`" in
139       HP-UX)
140         cflag_options="+Z $cflag_options";
141         ldflag_options="-Wl,-b $ldflag_options";
142         ;;
143       SunOS)
144         cflag_options="-Kpic $cflag_options";
145         ;;
146     esac
147   fi
148   for SHLIB_CFLAGS in $cflag_options ""; do
149     for SHLIB_LDFLAGS in $ldflag_options ""; do
150       psg_old_cflags="$CFLAGS";
151       CFLAGS="$CFLAGS $SHLIB_CFLAGS";
152       psg_old_ldflags="$LDFLAGS";
153       LDFLAGS="$LDFLAGS $SHLIB_LDFLAGS";
154       AC_LINK_IFELSE([AC_LANG_SOURCE([[
158 dummy(void)
160         $2
161         return 0;
163 ]])],
164         [psg_cv_flags_shlib="CFLAGS=$SHLIB_CFLAGS LDFLAGS=$SHLIB_LDFLAGS"],
165         [psg_cv_flags_shlib=no]
166       )
167       CFLAGS="$psg_old_cflags";
168       LDFLAGS="$psg_old_ldflags";
169       if test "$psg_cv_flags_shlib" != "no"; then
170         break;
171       fi
172     done
173     if test "$psg_cv_flags_shlib" != "no"; then
174       break;
175     fi
176   done
177   if test "$psg_cv_flags_shlib" = "no"; then
178     SHLIB_CFLAGS="";
179     SHLIB_LDFLAGS="";
180   fi
181   AC_SUBST([SHLIB_CFLAGS])
182   AC_SUBST([SHLIB_LDFLAGS])
183   AC_MSG_RESULT([$psg_cv_flags_shlib])
187 # PSG_MODULE(subdir, [args, ...])
188 # -------------------------------
189 # Process the module.ac file in subdir.  If the module.ac file defines a
190 # macro called subdir[]_INIT, call it with the arguments passed to
191 # PSG_MODULE().
192 AC_DEFUN([PSG_MODULE], [
193   m4_define([subdir], [$1])dnl
194   m4_include([$1/module.ac])dnl
195   m4_ifdef([$1][_INIT], [$1][_INIT($@)])dnl
196   m4_undefine([subdir])dnl