New version: 3.0.0
[libsmb2.git] / configure.ac
1 AC_PREREQ(2.50)
2 AC_INIT([libsmb2], [3.0.0], [ronniesahlberg@gmail.com])
3 AC_CONFIG_HEADERS([config.h])
4 AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
5 AC_CANONICAL_HOST
6 AC_CONFIG_MACRO_DIR([m4])
7 m4_pattern_allow([AM_PROG_AR])
8 AM_PROG_AR
9
10 # Work around stupid autoconf default cflags. pt 1
11 SAVE_CFLAGS="x${CFLAGS}"
12
13 AC_PROG_CC
14 AC_PROG_LIBTOOL
15
16 AM_PROG_CC_C_O
17 PKG_PROG_PKG_CONFIG
18
19 # Work around stupid autoconf default cflags. pt 2
20 if test "$SAVE_CFLAGS" = "x"; then
21   CFLAGS=""
22 fi
23
24 # We always want 64 bit file offsets
25 CFLAGS="${CFLAGS} -D_FILE_OFFSET_BITS=64"
26
27 #option: examples
28 AC_ARG_ENABLE([examples],
29               [AC_HELP_STRING([--enable-examples],
30                               [Build example programs])],
31               [ENABLE_EXAMPLES=$enableval],
32               [ENABLE_EXAMPLES="no"])
33
34 # We need popt to compile the examples
35 if test x$ENABLE_EXAMPLES = xyes; then
36 AC_MSG_CHECKING(whether libpopt is available)
37 ac_save_CFLAGS="$CFLAGS"
38 ac_save_LIBS="$LIBS"
39 CFLAGS="$CFLAGS $GLIB_CFLAGS"
40 LIBS="$GLIB_LIBS $LIBS -lpopt"
41 AC_TRY_RUN([
42 /*
43  * Just see if we can compile/link with popt
44  */
45 #include <popt.h>
46
47 int main(int argc, const char *argv[])
48 {
49         struct poptOption popt_options[] = {
50                 POPT_TABLEEND
51         };
52         poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
53
54         return 0;
55 }
56 ], ac_cv_have_popt=yes, ac_cv_have_popt=no,
57    [echo $ac_n "compile with POPT. Assuming OK... $ac_c"
58     ac_cv_have_popt=yes])
59 CFLAGS="$ac_save_CFLAGS"
60 LIBS="$ac_save_LIBS"
61 if test "$ac_cv_have_popt" = yes ; then
62   AC_MSG_RESULT(yes)
63   MAYBE_EXAMPLES="examples"
64 else
65   AC_MSG_RESULT(no)
66   AC_MSG_NOTICE(You need libpopt to compile the sample libsmb2 clients.)
67   AC_MSG_NOTICE(Only the library will be compiled and installed.)
68 fi
69 fi
70
71 AC_SUBST(MAYBE_EXAMPLES)
72
73 AC_ARG_WITH([libkrb5],
74     AS_HELP_STRING([--without-libkrb5], [Do not link with libkrb5 and use builtin NTLMSSP module for authentication instead.]))
75
76 AS_IF([test "x$with_libkrb5" != "xno"],
77       [MAYBE_LIBKRB5="-lgssapi_krb5"
78        AC_DEFINE(HAVE_LIBKRB5,1,[Whether we use gssapi_krb5 or not])
79        AC_MSG_NOTICE(Build with gssapi_krb5 support)
80        # check for gssapi/gssapi.h
81        dnl Check for gssapi/gssapi.h
82        AC_CHECK_HEADERS([gssapi/gssapi.h], [], [
83          AC_MSG_ERROR(You need gssapi development files to compile libsmb2.)
84          ])
85        ],
86       [MAYBE_LIBKRB5=""
87        AC_MSG_NOTICE(Build WITHOUT gssapi_krb5 support)])
88
89 AC_SUBST(MAYBE_LIBKRB5)
90
91 AC_ARG_ENABLE([werror], [AS_HELP_STRING([--disable-werror],
92               [Disables building with -Werror by default])])
93
94 if test "$ac_cv_prog_gcc" = yes; then
95    WARN_CFLAGS="-Wall -Wshadow -Wno-write-strings -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wno-strict-aliasing"
96    if test "x$enable_werror" != "xno"; then
97        WARN_CFLAGS="$WARN_CFLAGS -Werror"
98    fi
99 fi
100 AC_SUBST(WARN_CFLAGS)
101
102 LIBSOCKET=
103 SYS=
104
105 case $host in
106   *solaris*)
107     AC_CHECK_HEADERS([sys/filio.h])
108     AC_CHECK_HEADERS([sys/sockio.h])
109     AC_CHECK_LIB([socket], [main], , [AC_MSG_ERROR([Can not find required library])])
110     AC_CHECK_LIB([nsl],    [main], , [AC_MSG_ERROR([Can not find required library])])
111     ;;
112   *mingw32* | *cygwin* | *wince* | *mingwce*)
113     LIBSOCKET='-lws2_32'
114     SYS=mingw32
115     ;;
116   *)
117     ;;
118 esac
119 AM_CONDITIONAL(HAVE_WIN32,   test "${SYS}" = "mingw32")
120 AC_SUBST([LIBSOCKET])
121
122 # check for poll.h
123 dnl Check for poll.h
124 AC_CHECK_HEADERS([poll.h])
125
126 # check for unistd.h
127 dnl Check for unistd.h
128 AC_CHECK_HEADERS([unistd.h])
129
130 # check for netdb.h
131 dnl Check for netdb.h
132 AC_CHECK_HEADERS([netdb.h])
133
134 # check for utime.h
135 dnl Check for utime.h
136 AC_CHECK_HEADERS([utime.h])
137
138 # check for net/if.h
139 dnl Check for net/if.h
140 AC_CHECK_HEADERS([net/if.h])
141
142 # check for sys/time.h
143 dnl Check for sys/time.h
144 AC_CHECK_HEADERS([sys/time.h])
145
146 # check for sys/ioctl.h
147 dnl Check for sys/ioctl.h
148 AC_CHECK_HEADERS([sys/ioctl.h])
149
150 # check for sys/vfs.h
151 dnl Check for sys/vfs.h
152 AC_CHECK_HEADERS([sys/vfs.h])
153
154 # check for sys/statvfs.h
155 dnl Check for sys/statvfs.h
156 AC_CHECK_HEADERS([sys/statvfs.h])
157
158 # check for sys/socket.h
159 dnl Check for sys/socket.h
160 AC_CHECK_HEADERS([sys/socket.h])
161
162 # check for sys/uio.h
163 dnl Check for sys/uio.h
164 AC_CHECK_HEADERS([sys/uio.h])
165
166 # check for netinet/tcp.h
167 dnl Check for netinet/tcp.h
168 AC_CHECK_HEADERS([netinet/tcp.h])
169
170 # check for netinet/in.h
171 dnl Check for netinet/in.h
172 AC_CHECK_HEADERS([netinet/in.h])
173
174 # check for arpa/inet.h
175 dnl Check for arpa/inet.h
176 AC_CHECK_HEADERS([arpa/inet.h])
177
178 # check for SA_LEN
179 dnl Check if sockaddr data structure includes a "sa_len"
180 AC_CHECK_MEMBER([struct sockaddr.sa_len],
181                 [ AC_DEFINE(HAVE_SOCKADDR_LEN,1,[Whether sockaddr struct has sa_len]) ],
182                 [],
183                 [
184 #include <sys/types.h>
185 #include <sys/socket.h>
186 ])
187
188 # check for sockaddr_storage
189 dnl Check if sockaddr structure includes a "ss_family"
190 AC_CHECK_MEMBER([struct sockaddr_storage.ss_family],
191                 [ AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[Whether we have sockaddr_Storage]) ],
192                 [],
193                 [
194 #include <sys/types.h>
195 #include <sys/socket.h>
196 ])
197
198 # check where makedev is defined
199 AC_HEADER_MAJOR
200
201 #output
202 AC_CONFIG_FILES([Makefile]
203                 [examples/Makefile]
204                 [include/Makefile]
205                 [lib/Makefile]
206                )
207
208 AC_OUTPUT([libsmb2.pc])