summaryrefslogtreecommitdiff
path: root/configure.in
blob: ec17d6bd4759eec00512c70008ec6be1011c00e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
dnl Process this file with autoconf to produce a configure script.
AC_INIT(README)
LACMAJOR_VERSION=0
LACMINOR_VERSION=6
LACVERSION=$LACMAJOR_VERSION.$LACMINOR_VERSION
dnl
AC_SUBST(LACMAJOR_VERSION)
AC_SUBST(LACMINOR_VERSION)
AC_SUBST(LACVERSION)

VERSION=$LACVERSION
#VERSION=0.1
PACKAGE=lac

AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
AM_CONFIG_HEADER(src/config.h)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_AWK
AC_PROG_CPP
AC_PROG_LN_S
AC_PROG_MAKE_SET

AM_PROG_LIBTOOL

#AWK="$AWK -W lint"

dnl Only use -Wall if we have gcc
if test "x$GCC" = "xyes"; then
  if test -z "`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
    CFLAGS="$CFLAGS -Wall"
  fi
  if test -z "`echo "$CFLAGS" | grep "\-Wmissing\-declarations" 2> /dev/null`"; then
    CFLAGS="$CFLAGS -Wmissing-declarations"
  fi
fi

#LIBS="$LIBS `glib-config --libs`"
#CFLAGS="$CFLAGS -D_REENTRANT"

AC_CHECK_FUNC(connect,,AC_CHECK_LIB(socket, connect))
AC_CHECK_FUNC(inet_aton,,AC_CHECK_LIB(resolv, inet_aton))
AC_CHECK_FUNC(gethostbyname,,AC_CHECK_LIB(nsl, gethostbyname))
AC_CHECK_FUNC(hstrerror, AC_DEFINE(HAVE_HSTRERROR, 1,
			[Define if we have hstrerror]))

PKG_CHECK_MODULES(MODULES_XML, libxml-2.0 >= 2.0.8)
AC_SUBST(MODULES_XML_CFLAGS)
AC_SUBST(MODULES_XML_LIBS)

# ****************************************
# Checks for library functions.

# Check if we have gethostbyname_r (we assume that if the user has
# gethostbyname_r, he also has a similar gethostbyaddr_r).

AC_CHECK_FUNC(gethostbyname_r,
  [
     AC_DEFINE(HAVE_GETHOSTBYNAME_R, 1,
	       [Define if we have gethostbyname_r])
     dnl   if (gethostbyname with six args.)
     dnl   ================================
     AC_MSG_CHECKING(for gethostbyname_r() with six arguments)
      AC_TRY_LINK([
          #include <netdb.h>],[
	  struct hostent result_buf;
	  char buf[1024];
	  struct hostent* result;
	  int h_errnop;

	  gethostbyname_r("localhost", &result_buf, buf, sizeof(buf),
	                  &result, &h_errnop);
	], 
      dnl  then
      dnl  ====
        [

	  dnl Have glibc gethostbyname_r

	  AC_MSG_RESULT(yes)
	  AC_DEFINE(HAVE_GETHOSTBYNAME_R_SIX_ARGS, 1,
                    [Define if gethostbyname_r() takes six arguments])
	  HAVE_GETHOSTBYNAME_R=yes

        ], 
      dnl  else if (gethostbyname with five args)
      dnl  ======================================
        [
           AC_MSG_RESULT(no)
           AC_MSG_CHECKING(for gethostbyname_r() with five arguments)
       AC_TRY_LINK([
          #include <netdb.h>],[
	  struct hostent result;
	  char buf[1024];
	  int h_errnop;

	  gethostbyname_r("localhost", &result, buf, sizeof(buf), &h_errnop);

	], 
      dnl  then
      dnl  ====
        [
  	  AC_MSG_RESULT(yes)
	  AC_DEFINE(HAVE_GETHOSTBYNAME_R_FIVE_ARGS, 1,
                    [Define if gethostbyname_r() takes five arguments])
	  HAVE_GETHOSTBYNAME_R=yes

	], 
      dnl  else if (gethostbyname with three args.)
      dnl  ========================================
        [
          AC_MSG_RESULT(no)
          AC_MSG_CHECKING(for gethostbyname_r() with three arguments)
          AC_TRY_LINK([ #include <netdb.h>],[
	  struct hostent result;
	  char buf[1024];
          gethostbyname_r("localhost", &result, buf);
        ], 
       dnl  then
       dnl  ====
        [
          AC_MSG_RESULT(yes)
	  AC_DEFINE(HAVE_GETHOSTBYNAME_R_THREE_ARGS, 1,
	            [Define if gethostbyname_r() takes three arguments])
	  HAVE_GETHOSTBYNAME_R=yes
	],
       dnl  else
       dnl  ====
        [
          AC_MSG_RESULT(no)
          AC_MSG_WARN(Emulating gethostbyname_r() with gethostbyname() and a mutex)
        ]
     )]
  )]
)],
[
  AC_MSG_WARN(Emulating gethostbyname_r() with gethostbyname() and a mutex)
])

dnl Checks for libraries.
PKG_CHECK_MODULES(DEP, libnul glib-2.0 gnutls >= 1.4)

LIBS="$LIBS $DEP_LIBS"
CFLAGS="$CFLAGS $DEP_CFLAGS"

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(strings.h)
AC_CHECK_HEADERS(sys/types.h)
AC_CHECK_HEADERS(sys/socket.h)
AC_CHECK_HEADERS(signal.h)
AC_CHECK_HEADERS(netinet/in.h)
AC_CHECK_HEADERS(netdb.h)
AC_CHECK_HEADERS(arpa/inet.h)
AC_CHECK_HEADERS(signal.h)
AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS(sys/utsname.h)
AC_CHECK_HEADERS(sys/time.h)
AC_CHECK_HEADERS(netinet/tcp.h)
AC_CHECK_HEADERS(fcntl.h)

dnl Checks for typedefs, structures, and compiler characteristics.

dnl inline
AC_C_INLINE

dnl Checks for library functions.

AC_OUTPUT([
Makefile 
src/Makefile 
tests/Makefile 
lac-1.0.pc
])