Merge pull request #113 from ePirat/configure-cleanup
[libsmb2.git] / configure.ac
1 AC_INIT([libsmb2], [3.0.0], [ronniesahlberg@gmail.com])
2
3 AC_PREREQ([2.58])
4 AC_CONFIG_HEADERS([config.h])
5 AM_INIT_AUTOMAKE([-Wall foreign subdir-objects 1.11])
6 AC_CANONICAL_HOST
7 AC_CONFIG_MACRO_DIR([m4])
8
9 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
10
11 dnl  Do not add default CFLAGS in AC_PROG_CC
12 : ${CFLAGS=""}
13 AC_PROG_CC
14 AC_PROG_LIBTOOL
15
16 AM_PROG_CC_C_O
17
18 dnl  We always want 64 bit file offsets
19 CFLAGS="${CFLAGS} -D_FILE_OFFSET_BITS=64"
20
21 AC_ARG_ENABLE([examples],
22               [AS_HELP_STRING([--enable-examples],
23                               [Build example programs])])
24
25 AM_CONDITIONAL([ENABLE_EXAMPLES],
26                [test "$enable_examples" = "yes"])
27
28 AC_ARG_WITH([libkrb5],
29             [AS_HELP_STRING([--without-libkrb5],
30                             [Do not link with libkrb5 and use builtin
31                              NTLMSSP module for authentication instead.])])
32
33 AS_IF([test "x$with_libkrb5" != "xno"], [
34     MAYBE_LIBKRB5="-lgssapi_krb5"
35     AC_DEFINE([HAVE_LIBKRB5], [1], [Whether we use gssapi_krb5 or not])
36     AC_MSG_NOTICE([Build with gssapi_krb5 support])
37     dnl  Check for gssapi/gssapi.h
38     AC_CHECK_HEADERS([gssapi/gssapi.h], [], [
39         AC_MSG_ERROR([You need gssapi development files to compile libsmb2.])
40     ])
41 ], [
42     MAYBE_LIBKRB5=""
43     AC_MSG_NOTICE([Build WITHOUT gssapi_krb5 support])
44 ])
45
46 AC_SUBST([MAYBE_LIBKRB5])
47
48 AC_ARG_ENABLE([werror],
49               [AS_HELP_STRING([--disable-werror],
50               [Disables building with -Werror by default])])
51
52 AS_IF([test "$GCC" = "yes"], [
53     WARN_CFLAGS="-Wall -Wshadow -Wno-write-strings -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wno-strict-aliasing"
54     AS_IF([test "$enable_werror" != "no"], [
55         WARN_CFLAGS="${WARN_CFLAGS} -Werror"
56     ])
57 ])
58 AC_SUBST([WARN_CFLAGS])
59
60 LIBSOCKET=
61 SYS=
62
63 case $host in
64   *solaris*)
65     AC_CHECK_LIB([socket], [main], , [AC_MSG_ERROR([Can not find required library])])
66     AC_CHECK_LIB([nsl],    [main], , [AC_MSG_ERROR([Can not find required library])])
67     ;;
68   *mingw32* | *cygwin* | *wince* | *mingwce*)
69     LIBSOCKET='-lws2_32'
70     SYS=mingw32
71     ;;
72   *)
73     ;;
74 esac
75 AM_CONDITIONAL([HAVE_WIN32], [test "${SYS}" = "mingw32"])
76 AC_SUBST([LIBSOCKET])
77
78 dnl  Check for poll.h
79 AC_CHECK_HEADERS([poll.h])
80
81 dnl  Check for unistd.h
82 AC_CHECK_HEADERS([unistd.h])
83
84 dnl  Check for netdb.h
85 AC_CHECK_HEADERS([netdb.h])
86
87 dnl  Check for sys/ioctl.h
88 AC_CHECK_HEADERS([sys/ioctl.h])
89
90 dnl  Check for sys/socket.h
91 AC_CHECK_HEADERS([sys/socket.h])
92
93 dnl  Check for sys/uio.h
94 AC_CHECK_HEADERS([sys/uio.h])
95
96 dnl  Check for netinet/tcp.h
97 AC_CHECK_HEADERS([netinet/tcp.h])
98
99 dnl  Check for netinet/in.h
100 AC_CHECK_HEADERS([netinet/in.h])
101
102 dnl  Check for arpa/inet.h
103 AC_CHECK_HEADERS([arpa/inet.h])
104
105 dnl  Check if sockaddr data struct includes a "sa_len"
106 AC_CHECK_MEMBER([struct sockaddr.sa_len], [
107     AC_DEFINE([HAVE_SOCKADDR_LEN], [1], [Whether sockaddr struct has sa_len])
108 ], [], [
109 #include <sys/types.h>
110 #include <sys/socket.h>
111 ])
112
113 dnl  Check if sockaddr_storage struct includes a "ss_family"
114 AC_CHECK_MEMBER([struct sockaddr_storage.ss_family], [
115     AC_DEFINE([HAVE_SOCKADDR_STORAGE], [1], [Whether we have sockaddr_Storage])
116 ], [], [
117 #include <sys/types.h>
118 #include <sys/socket.h>
119 ])
120
121 dnl  Output
122 AC_CONFIG_FILES([
123     Makefile
124     examples/Makefile
125     include/Makefile
126     lib/Makefile
127 ])
128
129 AC_OUTPUT([libsmb2.pc])