tirpc: use pkg-config to find details
[deb_libnfs.git] / configure.ac
1 AC_PREREQ(2.50)
2 AC_INIT([libnfs], [1.0.0], [ronniesahlberg@gmail.com])
3 AC_CONFIG_HEADERS([config.h])
4 AM_INIT_AUTOMAKE([foreign])
5 AC_CANONICAL_HOST
6
7 # Work around stupid autoconf default cflags. pt 1
8 SAVE_CFLAGS="x${CFLAGS}"
9
10 AC_PROG_CC
11 AC_PROG_LIBTOOL
12
13 AM_PROG_CC_C_O
14 PKG_PROG_PKG_CONFIG
15
16 # Work around stupid autoconf default cflags. pt 2
17 if test "$SAVE_CFLAGS" = "x"; then
18 CFLAGS=""
19 fi
20
21 AC_CHECK_PROG([HAVE_RPCGEN], [rpcgen], [yes], [no])
22 if test x$HAVE_RPCGEN != xyes; then
23 AC_MSG_ERROR([Can not find required program])
24 fi
25
26 #option: examples
27 AC_ARG_ENABLE([examples],
28 [AC_HELP_STRING([--enable-examples],
29 [Build example programs])],
30 [ENABLE_EXAMPLES=$enableval],
31 [ENABLE_EXAMPLES="no"])
32
33 if test x$ENABLE_EXAMPLES = xyes; then
34 MAYBE_EXAMPLES="examples"
35 fi
36 AC_SUBST(MAYBE_EXAMPLES)
37
38 AC_ARG_ENABLE(tirpc,
39 [AC_HELP_STRING([--enable-tirpc],
40 [enable use of TI-RPC @<:@default=no@:>@])],
41 enable_tirpc=$enableval,
42 enable_tirpc='no')
43
44 case $host in
45 *darwin*)
46 RPCGENFLAGS=-DU_INT64_PLATTFORM_TYPE="u_int64_t"
47 ;;
48 *cygwin*)
49 RPCGENFLAGS=-DU_INT64_PLATTFORM_TYPE="u_int64_t"
50 ;;
51 *solaris*)
52 AC_CHECK_HEADERS([sys/filio.h])
53 AC_CHECK_HEADERS([sys/sockio.h])
54 if test x$ENABLE_EXAMPLES = xyes; then
55 AC_CHECK_LIB([socket], [main], , [AC_MSG_ERROR([Can not find required library])])
56 AC_CHECK_LIB([nsl], [main], , [AC_MSG_ERROR([Can not find required library])])
57 fi
58 ;;
59 *)
60 ;;
61 esac
62
63 AC_SUBST(RPCGENFLAGS)
64
65 # check for SA_LEN
66 dnl Check if sockaddr data structure includes a "sa_len"
67 AC_CHECK_MEMBER([struct sockaddr.sa_len],
68 [ AC_DEFINE(HAVE_SOCKADDR_LEN,1,[Whether sockaddr struct has sa_len]) ],
69 [],
70 [
71 #include <sys/types.h>
72 #include <sys/socket.h>
73 ])
74
75 LIBNFS_PC_REQ_PRIVATE=
76
77 if test "$enable_tirpc" = "yes"; then
78 PKG_CHECK_MODULES(TIRPC, libtirpc, [],
79 AC_MSG_ERROR([unable to locate libtirpc files]))
80 CFLAGS="${CFLAGS} ${TIRPC_CFLAGS}"
81 LIBS="${LIBS} ${TIRPC_LIBS}"
82 LIBNFS_PC_REQ_PRIVATE="${LIBNFS_PC_REQ_PRIVATE} libtirpc"
83 fi
84
85 AC_SUBST(LIBNFS_PC_REQ_PRIVATE)
86
87 #output
88 AC_CONFIG_FILES([Makefile]
89 [include/Makefile]
90 [lib/Makefile]
91 [mount/Makefile]
92 [nfs/Makefile]
93 [portmap/Makefile]
94 [rquota/Makefile]
95 [examples/Makefile]
96 )
97
98 AC_OUTPUT([libnfs.pc])