Improved method for finding PostgreSQL libraries in configure script.
[gnucomo.git] / configure.in
1
2 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT(src/gcm_input/message.h)
4 AM_INIT_AUTOMAKE(GnuCoMo, 0.0.9)
5
6
7 dnl Checks for programs.
8 AC_PROG_CC
9 AC_PROG_CXX
10 AC_PROG_CPP
11 AM_PROG_LEX
12 AC_PROG_INSTALL
13 AC_PROG_LN_S
14 AC_PROG_RANLIB
15 AC_PROG_YACC
16 AC_PROG_AWK
17
18 AC_PATH_PROG(XML_CONFIG,xml2-config,no)
19
20 if test $XML_CONFIG = "no"
21 then
22    echo "XML library not found (see http://xmlsoft.org/)."
23    exit 1;
24 fi
25
26
27 dnl Checks for libraries.
28 AC_PATH_XTRA
29
30 XML_CFLAGS=`$XML_CONFIG --cflags`
31 XML_LFLAGS=`$XML_CONFIG --libs`
32
33 LIBS="$LIBS $X_LIBS $X_PRE_LIBS $X_EXTRA_LIBS"
34 LIBS="$LIBS -L/usr/local/lib $XML_LFLAGS"
35 CFLAGS="$CFLAGS $X_CFLAGS $XML_CFLAGS "
36 CXXFLAGS="$CXXFLAGS  -Wno-deprecated $X_CFLAGS $XML_CFLAGS"
37
38 AC_CHECK_LIB(AXE, main, , AC_MSG_ERROR(AXE Library is not installed))
39 #AC_CHECK_LIB(X11, XOpenDisplay)
40 #AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData)
41 #AC_CHECK_LIB(pthread, pthread_create)
42 AC_CHECK_LIB(xml2, xmlParseFile)
43
44 # Where are the postgres includes...
45 postgres_include_default=
46 for usual_suspect in \
47         /usr/local/include/postgresql \
48         /usr/local/include/pgsql \
49         /usr/local/pgsql/include \
50         /usr/local/include \
51         /usr/include/postgresql \
52         /usr/include/pgsql \
53         /usr/include \
54         /opt/postgresql/include \
55         /opt/pgsql/include \
56         /usr/freeware/include \
57 ; do
58 AC_CHECK_FILE([$usual_suspect/libpq-fe.h],
59         [postgres_include_default=$usual_suspect],
60 )
61         if test -n "$postgres_include_default" ; then
62                 break
63         fi
64 done
65
66 AC_ARG_WITH(postgres-include,
67         --with-postgres-include  PostgreSQL headers directory
68         
69         ,       test "$withval" = no || with_postgres_include=$withval
70         , with_postgres_include=$postgres_include_default
71 )
72
73 # ..and libraries?
74 postgres_lib_default=
75 for usual_suspect in \
76         /usr/local/lib/postgresql \
77         /usr/local/lib/pgsql \
78         /usr/local/pgsql/lib \
79         /usr/local/lib \
80         /usr/lib/postgresql \
81         /usr/lib/pgsql \
82         /usr/lib \
83         /opt/postgresql/lib \
84         /opt/pgsql/lib \
85         /usr/freeware/lib32 \
86 ; do
87         for library_extension in so a sa ; do
88 AC_CHECK_FILE([$usual_suspect/libpq.$library_extension],
89         [postgres_lib_default=$usual_suspect],
90 )
91         done
92         if test -n "$postgres_lib_default" ; then
93                 break
94         fi
95 done
96
97 AC_ARG_WITH(postgres-lib,
98         --with-postgres-lib      PostgreSQL library directory containing libpq
99         ,       test "$withval" = no || with_postgres_lib=$withval
100         , with_postgres_lib=$postgres_lib_default
101 )
102
103 # provide one way to specify both include and lib
104 AC_ARG_WITH(postgres,
105         --with-postgres  PostgreSQL common directory. Use this to specify libs & includes rooted at one place
106         ,       test "$withval" = no || with_postgres=$withval
107                 with_postgres_lib=${with_postgres}/lib
108                 with_postgres_include=${with_postgres}/include
109         , with_postgres=no
110 )
111
112 AC_SUBST(with_postgres_lib)
113 AC_SUBST(with_postgres_include)
114 POSTGRES_LIB="-L${with_postgres_lib} -R${with_postgres_lib} -lpq"
115 AC_SUBST(POSTGRES_LIB)
116 POSTGRES_INCLUDE="-I${with_postgres_include}"
117 AC_SUBST(POSTGRES_INCLUDE)
118
119 # Checks for libraries.
120 AC_CHECK_LIB([pq], [PQexec], [], [AC_MSG_ERROR([Failed to find a suitable libpq.
121
122 PostgreSQL's libpq needs to be installed.
123 Perhaps you need to specify --with-postgres-lib?
124 ])], -L${with_postgres_lib})
125
126 # Checks for header files.
127 AC_HEADER_STDC
128 AC_CHECK_HEADER([${with_postgres_include}/libpq-fe.h],,AC_MSG_ERROR(
129 [Can't find libpq-fe.h in ${with_postgres_include}.
130 Please specify the location of the PostgreSQL include files with
131 --with-postgres-include=... or --with-postgres=...]
132 ))
133
134 AC_CHECK_HEADER([${with_postgres_include}/libpq/libpq-fs.h],,AC_MSG_ERROR(
135 [Can't find libpq-fs.h in ${with_postgres_include}/libpq.
136 Please locate it and report your findings so this script can be corrected.]
137 ))
138
139 CXXFLAGS="$CXXFLAGS $POSTGRES_INCLUDE"
140 LIBS="$LIBS $POSTGRES_LIB"
141
142 #
143 #  There is no convenient way to detect libpqxx, so we'll
144 #  use fixed paths for the time being.
145
146 CXXFLAGS="$CXXFLAGS -I/usr/local/pqxx/include"
147 LIBS="$LIBS -L/usr/local/pqxx/lib -lpqxx"
148
149 dnl Checks for header files.
150 AC_HEADER_DIRENT
151 AC_HEADER_STDC
152 AC_CHECK_HEADERS(unistd.h)
153
154 dnl Checks for typedefs, structures, and compiler characteristics.
155 AC_C_CONST
156
157 dnl Checks for library functions.
158 AC_CHECK_FUNCS(strtod strtol strtoul)
159
160 dnl Edit this to be your web server's document root
161
162 DocumentRoot=/var/www/html
163
164 #AC_OUTPUT(Makefile src/Makefile src/lib/Makefile src/gcm_input/Makefile src/web/Makefile)
165 AC_OUTPUT(Makefile src/Makefile src/lib/Makefile src/gcm_input/Makefile)