Check for AM_PROG_AR instead of defining to nothing
[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 1.11])
5 AC_CANONICAL_HOST
6 AC_CONFIG_MACRO_DIR([m4])
7
8 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
9
10 # Do not add default CFLAGS in AC_PROG_CC
11 : ${CFLAGS=""}
12 AC_PROG_CC
13 AC_PROG_LIBTOOL
14
15 AM_PROG_CC_C_O
16 PKG_PROG_PKG_CONFIG
17
18 # We always want 64 bit file offsets
19 CFLAGS="${CFLAGS} -D_FILE_OFFSET_BITS=64"
20
21 #option: examples
22 AC_ARG_ENABLE([examples],
23               [AC_HELP_STRING([--enable-examples],
24                               [Build example programs])])
25
26 AM_CONDITIONAL([ENABLE_EXAMPLES],
27                [test "$enable_examples" = "yes"])
28
29 AC_ARG_WITH([libkrb5],
30     AS_HELP_STRING([--without-libkrb5], [Do not link with libkrb5 and use builtin NTLMSSP module for authentication instead.]))
31
32 AS_IF([test "x$with_libkrb5" != "xno"],
33       [MAYBE_LIBKRB5="-lgssapi_krb5"
34        AC_DEFINE(HAVE_LIBKRB5,1,[Whether we use gssapi_krb5 or not])
35        AC_MSG_NOTICE(Build with gssapi_krb5 support)
36        # check for gssapi/gssapi.h
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 AC_SUBST(MAYBE_LIBKRB5)
46
47 AC_ARG_ENABLE([werror], [AS_HELP_STRING([--disable-werror],
48               [Disables building with -Werror by default])])
49
50 if test "$ac_cv_prog_gcc" = yes; then
51    WARN_CFLAGS="-Wall -Wshadow -Wno-write-strings -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wno-strict-aliasing"
52    if test "x$enable_werror" != "xno"; then
53        WARN_CFLAGS="$WARN_CFLAGS -Werror"
54    fi
55 fi
56 AC_SUBST(WARN_CFLAGS)
57
58 LIBSOCKET=
59 SYS=
60
61 case $host in
62   *solaris*)
63     AC_CHECK_HEADERS([sys/filio.h])
64     AC_CHECK_HEADERS([sys/sockio.h])
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 # check for poll.h
79 dnl Check for poll.h
80 AC_CHECK_HEADERS([poll.h])
81
82 # check for unistd.h
83 dnl Check for unistd.h
84 AC_CHECK_HEADERS([unistd.h])
85
86 # check for netdb.h
87 dnl Check for netdb.h
88 AC_CHECK_HEADERS([netdb.h])
89
90 # check for utime.h
91 dnl Check for utime.h
92 AC_CHECK_HEADERS([utime.h])
93
94 # check for net/if.h
95 dnl Check for net/if.h
96 AC_CHECK_HEADERS([net/if.h])
97
98 # check for sys/time.h
99 dnl Check for sys/time.h
100 AC_CHECK_HEADERS([sys/time.h])
101
102 # check for sys/ioctl.h
103 dnl Check for sys/ioctl.h
104 AC_CHECK_HEADERS([sys/ioctl.h])
105
106 # check for sys/vfs.h
107 dnl Check for sys/vfs.h
108 AC_CHECK_HEADERS([sys/vfs.h])
109
110 # check for sys/statvfs.h
111 dnl Check for sys/statvfs.h
112 AC_CHECK_HEADERS([sys/statvfs.h])
113
114 # check for sys/socket.h
115 dnl Check for sys/socket.h
116 AC_CHECK_HEADERS([sys/socket.h])
117
118 # check for sys/uio.h
119 dnl Check for sys/uio.h
120 AC_CHECK_HEADERS([sys/uio.h])
121
122 # check for netinet/tcp.h
123 dnl Check for netinet/tcp.h
124 AC_CHECK_HEADERS([netinet/tcp.h])
125
126 # check for netinet/in.h
127 dnl Check for netinet/in.h
128 AC_CHECK_HEADERS([netinet/in.h])
129
130 # check for arpa/inet.h
131 dnl Check for arpa/inet.h
132 AC_CHECK_HEADERS([arpa/inet.h])
133
134 # check for SA_LEN
135 dnl Check if sockaddr data structure includes a "sa_len"
136 AC_CHECK_MEMBER([struct sockaddr.sa_len],
137                 [ AC_DEFINE(HAVE_SOCKADDR_LEN,1,[Whether sockaddr struct has sa_len]) ],
138                 [],
139                 [
140 #include <sys/types.h>
141 #include <sys/socket.h>
142 ])
143
144 # check for sockaddr_storage
145 dnl Check if sockaddr structure includes a "ss_family"
146 AC_CHECK_MEMBER([struct sockaddr_storage.ss_family],
147                 [ AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[Whether we have sockaddr_Storage]) ],
148                 [],
149                 [
150 #include <sys/types.h>
151 #include <sys/socket.h>
152 ])
153
154 # check where makedev is defined
155 AC_HEADER_MAJOR
156
157 #output
158 AC_CONFIG_FILES([Makefile]
159                 [examples/Makefile]
160                 [include/Makefile]
161                 [lib/Makefile]
162                )
163
164 AC_OUTPUT([libsmb2.pc])