r1190: Moved CPPFLAGS to pixmaps rule to avoid getting it twice.
[rox-filer.git] / ROX-Filer / src / configure.in
blobcb8c0fcf957007a746b9f469785fc9643783cc30
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(main.c)
3 AC_CONFIG_HEADER(config.h)
5 AC_ARG_WITH(platform,
6 [  --with-platform        platform name, as detected by AppRun],
7 [AC_SUBST(with_platform)],
9 AC_MSG_ERROR([
11 Please do not run 'configure' manually - instead, run the AppRun script with
12 the --compile option, like this:
13         $ ROX-Filer/AppRun --compile
15 Thank you.
19 AC_ARG_WITH(gtk2,
20 [  --with-gtk2            Use Gtk+-2.0 API instead of Gtk+-1.2], gtk2=1, gtk2=0)
23 dnl rox_ARG_WITH(PACKAGE, HELP-STRING, ACTION-IF-TRUE [, ACTION-IF-FALSE])
24 dnl This macro does the same thing as AC_ARG_WITH, but it also defines
25 dnl with_PACKAGE_arg and with_PACKAGE_sign to avoid complicated logic later.
26 dnl Stolen from icewm's configure.in
27 AC_DEFUN(rox_ARG_WITH, [
28 AC_ARG_WITH([$1], [$2], [
29 case "[${with_]patsubst([$1], -, _)}" in
30 [no)]
31  [with_]patsubst([$1], -, _)_sign=no
32  ;;
33 [yes)]
34  [with_]patsubst([$1], -, _)_sign=yes
35  ;;
36 [*)] 
37  [with_]patsubst([$1], -, _)_arg="[${with_]patsubst([$1], -, _)}"
38  [with_]patsubst([$1], -, _)_sign=yes
39  ;;
40 esac
42 ], [$4])])
44 dnl rox_CHECK_EXISTS(PROGRAM, ERROR)
45 dnl Ensure that PROGRAM --version works.
46 dnl Stops and displays ERROR if it's missing.
47 AC_DEFUN(rox_CHECK_EXISTS, [
48 AC_MSG_CHECKING(that $1 runs)
49 if "$1" --version > /dev/null 2>&1 ; then
50   AC_MSG_RESULT(yes)
51 else
52   AC_MSG_RESULT(no)
53   AC_MSG_ERROR([*** Missing program ***
55 $1 failed to run - make sure it is inside one of the
56 directories in your PATH environment variable!
58 $2)
62 dnl Checks for programs.
63 AC_PROG_CC
65 dnl Use -Wall if possible
67 if test "x$GCC" = "xyes"; then
68   case " $CFLAGS " in
69   *[\ \ ]-Wall[\ \      ]*) ;;
70   *) CFLAGS="$CFLAGS -Wall" ;;
71   esac
75 if test -z "$PKG_CONFIG"; then
76   PKG_CONFIG=pkg-config
78 AC_SUBST(PKG_CONFIG)
80 if test -z "$XML_CONFIG"; then
81   AC_CHECK_PROG(XML_CONFIG, xml2-config, xml2-config, xml-config)
83 AC_SUBST(XML_CONFIG)
85 if test -z "$GTK_CONFIG"; then
86   GTK_CONFIG=gtk-config
89 dnl See if we've got Gtk+ 2.0 (or 1.3 developement version)
90 dnl AC_MSG_CHECKING(for Gtk+-1.3.13 or later)
91 dnl gtk2=0
92 dnl if $PKG_CONFIG "--atleast-version=1.3.13" "gtk+-2.0"; then
94 if test "$gtk2" = "1"; then
95   dnl AC_MSG_RESULT(yes)
96   AC_MSG_WARN([Using EXPERIMENTAL Gtk+-2.0 API])
97   AC_DEFINE(GTK2)
98   gtk2=1
99   GTK_CFLAGS="$PKG_CONFIG gtk+-2.0 --cflags"
100   GTK_LIBS="$PKG_CONFIG gtk+-2.0 --libs"
101   GDK_PIXBUF_LIBS=`$PKG_CONFIG gdk-pixbuf-2.0 --libs`
102   GDK_PIXBUF_CFLAGS=`$PKG_CONFIG gdk-pixbuf-2.0 --cflags`
103 else
104   dnl AC_MSG_RESULT(no)
106   GTK_CFLAGS="$GTK_CONFIG --cflags"
107   GTK_LIBS="$GTK_CONFIG --libs"
109   dnl Warn the user if stuff is missing...
110   rox_CHECK_EXISTS([$GTK_CONFIG],
111                    [You need to install the gtk-devel package before compiling:
112                     http://www.gtk.org])
114   dnl Make sure we have gdk-pixbuf
115   AC_MSG_CHECKING(for gdk-pixbuf library)
116   if test -z "$GDK_PIXBUF_CONFIG"; then
117     GDK_PIXBUF_CONFIG=gdk-pixbuf-config
118   fi
119   GDK_PIXBUF_CFLAGS=`$GDK_PIXBUF_CONFIG --cflags`
120   GDK_PIXBUF_LIBS=`$GDK_PIXBUF_CONFIG --libs`
121   [
122   if [ -n "$GDK_PIXBUF_LIBS" ]; then
123   ]
124     AC_MSG_RESULT(yes - use '$GDK_PIXBUF_LIBS')
125   else
126     AC_MSG_ERROR(can't run '$GDK_PIXBUF_CONFIG --libs' - make sure it is in your PATH)
127   fi
129 AC_SUBST(GTK_CFLAGS)
130 AC_SUBST(GTK_LIBS)
131 AC_SUBST(GDK_PIXBUF_CFLAGS)
132 AC_SUBST(GDK_PIXBUF_LIBS)
134 rox_CHECK_EXISTS([$XML_CONFIG],
135            [You need to install the xml-devel package before compiling:
136             http://xmlsoft.org/])
138 dnl Does file(1) support '-b' ?
139 AC_MSG_CHECKING(whether file -b works)
140 if file -b / > /dev/null 2> /dev/null
141 then
142   AC_DEFINE(FILE_B_FLAG)
143   AC_MSG_RESULT(yes)
144 else
145   AC_MSG_RESULT(no)
148 AC_MSG_CHECKING(for large file support)
149 if getconf LFS64_CFLAGS > /dev/null 2> /dev/null; then
150   AC_MSG_RESULT(yes)
151   LFS_CFLAGS="`getconf LFS_CFLAGS`"
152   LFS_LDFLAGS="`getconf LFS_LDFLAGS`"
153   LFS_LIBS="`getconf LFS_LIBS`"
154   disable_vfs=yes
155   AC_DEFINE(LARGE_FILE_SUPPORT)
156 else
157   AC_MSG_RESULT(no)
158   LFS_CFLAGS=""
159   LFS_LDFLAGS=""
160   LFS_LIBS=""
161   disable_vfs=no
163 AC_SUBST(LFS_CFLAGS)
164 AC_SUBST(LFS_LDFLAGS)
165 AC_SUBST(LFS_LIBS)
167 dnl Checks for header files.
168 AC_PATH_X
169 AC_HEADER_DIRENT
170 AC_HEADER_STDC
171 AC_HEADER_SYS_WAIT
172 AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h mntent.h sys/ucred.h sys/mntent.h)
173 AC_CHECK_HEADERS(regex.h iconv.h)
175 rox_ARG_WITH(vfs,
176   [  --with-vfs[=prefix]     use libvfs for virtual file system [search it in prefix/include and prefix/lib]])
178 dnl Checks for typedefs, structures, and compiler characteristics.
179 AC_C_CONST
180 AC_TYPE_UID_T
181 AC_TYPE_SIZE_T
183 dnl Checks for library functions.
184 AC_CHECK_FUNCS(gethostname unsetenv mkdir rmdir strdup strtol getopt_long)
186 VFS_LIBS=""
187 VFS_CFLAGS=""
188 if test "$disable_vfs" != "yes" ; then
189   AC_MSG_CHECKING(for vfs library)
190   if test x"$with_vfs_sign" = xyes; then
191     if test x"$with_vfs_arg" != x; then
192       vfs_includes="-I${with_vfs_arg}/include"
193       vfs_libs="-L${with_vfs_arg}/lib -R${with_vfs_arg}/lib"
194       AC_MSG_RESULT(yes - use '$vfs_libs')
195     else
196       vfs_includes=""
197       vfs_libs=""
198       AC_MSG_RESULT(yes)
199     fi
200     CFLAGS="$CFLAGS $vfs_includes"
201     LDFLAGS="$LDFLAGS $vfs_libs"
202     VFS_CFLAGS="$vfs_includes"
203     VFS_LIBS="$vfs_libs"
204   else
205     AC_MSG_RESULT(no)
206   fi
208 AC_SUBST(VFS_CFLAGS)
209 AC_SUBST(VFS_LIBS)
211 dnl Extract version info from AppInfo.xml
212 AC_MSG_CHECKING(extracting version information)
214 VERSION=`sed -n 's/^.*<Version>\([.0-9]*\).*<\/Version>.*$/\1/p' ../AppInfo.xml`
216 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
217 AC_MSG_RESULT(version $VERSION)
219 dnl Check for the Midnight Commander VFS library
220 if test "$disable_vfs" != "yes" ; then
221   AC_CHECK_LIB(vfs, mc_stat, , , `$GTK_CONFIG --libs`)
224 dnl Check for libpng
225 LIBPNG=""
226 if test "$gtk2" != "1" ; then
227   AC_CHECK_LIB(png, png_read_info,
228     AC_TRY_CPP([#include <png.h>], png=yes, png=no),
229     png=no,
230     -lz -lm)
231   if test "$png" = "yes" ; then
232     AC_MSG_CHECKING([if libpng version is >= 1.0.1])
233     oldLIBS=$LIBS
234     LIBS="$LIBS -lpng -lz -lm"
235     AC_TRY_RUN(
236   [#include <stdlib.h>
237   #include <png.h>
238   int main(int argc, char **argv)
239   {
240   #ifdef PNG_LIBPNG_VER
241     if (PNG_LIBPNG_VER >= 10001)
242         exit(0);
243     else
244         exit(1);
245   #else
246     exit(2);
247   #endif
248   }
249   ], png=yes, png=no, png=no)
250     AC_MSG_RESULT($png)
251     LIBS=$oldLIBS
252     if test "$png" = "yes" ; then
253       LIBPNG="-lpng -lz -lm"
254       AC_DEFINE(HAVE_LIBPNG)
255     fi
256   fi
258 AC_SUBST(LIBPNG)
260 AC_OUTPUT(Makefile)