Add better diagnostics of configure failure
[navit-package] / configure.in
1 AC_INIT(navit, 0.0.3)
2 AM_INIT_AUTOMAKE
3 AM_CONFIG_HEADER(config.h)
4 AM_MAINTAINER_MODE
5
6 AC_GNU_SOURCE
7
8 AC_PROG_CC
9 if eval "test x$GCC = xyes"; then
10         CFLAGS="$CFLAGS -Wall -Wcast-align -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Wreturn-type -D_GNU_SOURCE"
11 fi
12 AC_PROG_CXX
13 if eval "test x$GXX = xyes"; then
14         CXXFLAGS="$CXXFLAGS -Wall -Wcast-align -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Wreturn-type -D_GNU_SOURCE"
15 fi
16
17 PKG_CHECK_EXISTS
18
19 AC_DISABLE_STATIC
20 AC_PROG_LIBTOOL
21
22 AC_ARG_ENABLE(avoid-unaligned, [  --enable-avoid-unaligned          avoid unaligned accesses], AVOID_UNALIGNED=$enableval, AVOID_UNALIGNED=no)
23 test x"${AVOID_UNALIGNED}" = xyes && AC_DEFINE(AVOID_UNALIGNED,[],Define to avoid unaligned access)
24
25 AC_ARG_ENABLE(avoid-float, [  --enable-avoid-float              avoid floating point calculations], AVOID_FLOAT=$enableval, AVOID_FLOAT=no)
26 test x"${AVOID_FLOAT}" = xyes && AC_DEFINE(AVOID_FLOAT,[],Define to avoid floating point)
27
28 AC_ARG_ENABLE(libgps, [  --disable-libgps             don't use libgps], USE_LIBGPS=$enableval, USE_LIBGPS=yes)
29
30 AC_ARG_ENABLE(samplemap, [  --disable-samplemap             don't build the samplemap], samplemap=$enableval, samplemap=yes)
31 AM_CONDITIONAL(BUILD_SAMPLEMAP, [test "x$samplemap" = "xyes"])
32
33 AC_ARG_ENABLE(fastmath, [  --disable-fastmath             don't build with fastmath], fastmath=$enableval, fastmath=yes)
34 AM_CONDITIONAL(FASTMATH, [test "x$fastmath" = "xyes"])
35
36 if test x"$fastmath" = xyes; then
37         if eval "test x$GCC = xyes"; then
38                 CFLAGS="$CFLAGS -ffast-math"
39         fi
40 fi
41
42 X_CFLAGS="-I$x_includes"
43 X_LIBS="-L$ac_x_libraries"
44
45 PKG_CHECK_MODULES(NAVIT, [glib-2.0 gmodule-2.0], [], AC_MSG_ERROR([glib-2.0 or gmodule-2.0 not found. Usually you need to install a package named glib2-devel or libglib2.0-dev]))
46 AC_SUBST(NAVIT_CFLAGS)
47 AC_SUBST(NAVIT_LIBS)
48
49 AC_CHECK_HEADER(
50         zlib.h,
51         AC_DEFINE(
52                 [HAVE_ZLIB],
53                 [],
54                 Define to 1 if you have the <zlib.h> header file.
55                 )
56                 ZLIB_LIBS="-lz",
57         AC_MSG_WARN([*** no zlib.h\ -- reduced functionality of osm2navit])
58         )
59 AC_SUBST(ZLIB_LIBS)
60
61 AC_ARG_ENABLE(gui-gtk, [  --disable-gui-gtk             don't create gui gtk ], MODULE_GUI_GTK=$enableval, MODULE_GUI_GTK=yes)
62 if test "x$MODULE_GUI_GTK" = "xyes"; then
63         PKG_CHECK_MODULES(GTK2, [gtk+-2.0], [gtk2_pkgconfig=yes], [gtk2_pkgconfig=no])
64         if test "x$gtk2_pkgconfig" = "xyes"; then
65                 AC_DEFINE(HAVE_GTK2, 1, [Define to 1 if you have imlib2])
66         fi
67 fi
68
69 GTK2_CFLAGS="$GTK2_CFLAGS -DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
70
71 AC_SUBST(GTK2_CFLAGS)
72 AC_SUBST(GTK2_LIBS)
73 AM_CONDITIONAL(GUI_GTK, [test "x$gtk2_pkgconfig" = "xyes"])
74 AM_CONDITIONAL(GRAPHICS_GTK_DRAWING_AREA, [test "x$gtk2_pkgconfig" = "xyes"])
75
76 PKG_CHECK_MODULES(FREETYPE2, [freetype2], [freetype2_pkgconfig=yes], [freetype2_pkgconfig=no])
77 if test "x$freetype2_pkgconfig" = "xyes"; then
78    AC_DEFINE(HAVE_FREETYPE2, 1, [Define to 1 if you have imlib2])
79 fi
80 AC_SUBST(FREETYPE2_CFLAGS)
81 AC_SUBST(FREETYPE2_LIBS)
82
83 PKG_CHECK_MODULES(IMLIB2, [imlib2], [imlib2_pkgconfig=yes], [imlib2_pkgconfig=no])
84 if test "x$imlib2_pkgconfig" = "xyes"; then
85    AC_DEFINE(HAVE_IMLIB2, 1, [Define to 1 if you have imlib2])
86 fi
87 AC_SUBST(IMLIB2_CFLAGS)
88 AC_SUBST(IMLIB2_LIBS)
89
90
91 AC_ARG_ENABLE(speech-speechd, [  --disable-speech-speechd             don't create speech speechd ], MODULE_SPEECH_SPEECHD=$enableval, MODULE_SPEECH_SPEECHD=yes)
92 if test "x$MODULE_SPEECH_SPEECHD" = "xyes"; then
93         AC_CHECK_HEADER(libspeechd.h, AC_DEFINE([HAVE_LIBSPEECHD],[],Define to 1 if you have the <libspeechd.h> header file.) SPEECHD_LIBS="-lspeechd" speechd=yes,  AC_MSG_WARN([*** no libspeechd.h -- Speech output disabled]))
94 fi
95 AC_SUBST(SPEECHD_CFLAGS)
96 AC_SUBST(SPEECHD_LIBS)
97 AM_CONDITIONAL(SPEECH_SPEECH_DISPATCHER, [test "x$speechd" = "xyes"])
98
99
100 AC_ARG_ENABLE(gui-sdl, [  --disable-gui-sdl             don't create gui sdl ], MODULE_GUI_SDL=$enableval, MODULE_GUI_SDL=yes)
101 if test "x$MODULE_GUI_SDL" = "xyes"; then
102         AC_CHECK_HEADER(
103                 SDL/SDL.h,
104                 AC_DEFINE(
105                         [HAVE_LIBSDL],
106                         [],
107                         Define to 1 if you have the <SDL/SDL.h> header file.
108                         )
109                         SDL_LIBS="-lSDL"
110                         sdl=yes,
111                 AC_MSG_WARN([*** no SDL/SDL.h -- SDL support disabled])
112         )
113 fi
114 AC_SUBST(SDL_CFLAGS)
115 AC_SUBST(SDL_LIBS)
116
117 PKG_CHECK_MODULES(
118         [CEGUI],
119         [CEGUI-OPENGL >= 0.5.0],
120         [
121                 AC_DEFINE(
122                         [HAVE_CEGUI],
123                         [],
124                         [Define to 1 if you have the @<:@CEGUI/CEGUI.h@:>@ header file.])
125                 cegui=yes
126         ],
127         [AC_MSG_WARN([*** CEGUI not found -- SDL support disabled])]
128 )
129
130 AC_CHECK_HEADER(
131         GL/gl.h,
132         AC_DEFINE(
133                 [HAVE_OPENGL],
134                 [],
135                 Define to 1 if you have the <GL/gl.h> header file.
136                 )
137                 OPENGL_LIBS="$X_LIBS -lGL -lGLU"
138                 opengl=yes,
139         AC_MSG_WARN([*** no GL/gl.h -- opengl and SDL support disabled])
140 )
141
142 AC_CHECK_HEADER(
143         GL/glut.h,
144         AC_DEFINE(
145                 [HAVE_GLUT],
146                 [],
147                 Define to 1 if you have the <GL/glut.h> header file.
148                 )
149                 glut=yes,
150         AC_MSG_WARN([*** no GL/glut.h -- opengl and SDL support disabled])
151 )
152
153 AC_SUBST(OPENGL_CFLAGS)
154 AC_SUBST(OPENGL_LIBS)
155
156 AC_CHECK_HEADER(
157         GL/glc.h,
158         AC_DEFINE(
159                 [HAVE_GLC],
160                 [],
161                 Define to 1 if you have the <GL/glc.h> header file.
162                 )
163                 GLC_LIBS="-lGLC"
164                 glc=yes,
165         AC_MSG_WARN([*** no GL/glc.h -- opengl and SDL support disabled])
166 )
167 AC_SUBST(GLC_CFLAGS)
168 AC_SUBST(GLC_LIBS)
169
170 if test x"$cegui" = xyes         
171                 then     
172          # Save the LIBS into a temp var since AC_CHECK_LIB adds the lib into LIBS       
173          # and we want just to check and use CEGUI_LIBS          
174          libstemp="$LIBS"        
175          # For CEGUI, we have to check the presence of some libraries.   
176          # The following are mandatory (used by navit)   
177          # If the user installed NavIt without, issue a warning and disable CEGUI        
178          AC_CHECK_LIB(CEGUIBase, main,   
179                   [],    
180                   [      
181                  echo "Error! Something is wrong with CEGUIBase. Do you have at least cegui-0.5?"        
182                  exit -1         
183                  ])      
184          AC_CHECK_LIB(CEGUIOpenGLRenderer, main,         
185                   [],    
186                   [      
187                  echo "Error! Something is wrong with CEGUIOpenGLRenderer. Do you have at least cegui-0.5? "     
188                  exit -1         
189                  ], $OPENGL_LIBS )       
190          AC_CHECK_LIB(CEGUIFalagardWRBase, main,         
191                   [],    
192                   [      
193                  echo "Error! Something is wrong with CEGUIFalagardWRBase. Do you have at least cegui-0.5?"      
194                  exit -1         
195                  ], $OPENGL_LIBS)        
196          CEGUI_LIBS="-lCEGUIBase -lCEGUIOpenGLRenderer -lCEGUIFalagardWRBase"    
197                  
198          # The following are optionnal, but we need to link against them if cegui was built with them    
199          libssilly="$OPENGL_LIBS -lpng"          
200          AC_CHECK_LIB(CEGUISILLYImageCodec, createImageCodec,    
201                   [CEGUI_LIBS="$CEGUI_LIBS -lCEGUISILLYImageCodec"],     
202                   [echo "CEGUISILLYImageCodec not found/not working, disabled."],        
203                   $libssilly     
204          )       
205                  
206          AC_CHECK_LIB(CEGUIXercesParser, main,   
207                   [CEGUI_LIBS="$CEGUI_LIBS -lCEGUIXercesParser"],        
208                   [echo "CEGUIXercesParser not found/not working, disabled."],   
209                   $OPENGL_LIBS   
210          )       
211                  
212          AC_CHECK_LIB(CEGUIExpatParser, main,    
213                   [CEGUI_LIBS="$CEGUI_LIBS -lCEGUIExpatParser"],         
214                   [echo "CEGUIExpatParser not found/not working, disabled."],    
215                   $OPENGL_LIBS   
216          )       
217                  
218          AC_CHECK_LIB(CEGUILibxmlParser, main,   
219                   [CEGUI_LIBS="$CEGUI_LIBS -lCEGUILibxmlParser"],        
220                   [echo "CEGUILibxmlParser not found/not working, disabled."],   
221                   $OPENGL_LIBS   
222          )       
223                  
224          AC_CHECK_LIB(CEGUITinyXMLParser, main,          
225                   [CEGUI_LIBS="$CEGUI_LIBS -lCEGUITinyXMLParser"],       
226                   [echo "CEGUITinyXMLParser not found/not working, disabled."],          
227                   $OPENGL_LIBS   
228          )       
229                  
230          AC_CHECK_LIB(CEGUIDevILImageCodec, main,        
231                   [CEGUI_LIBS="$CEGUI_LIBS -lCEGUIDevILImageCodec"],     
232                   [echo "CEGUIDevILImageCodec not found/not working, disabled."],        
233                   $OPENGL_LIBS   
234          )       
235                  
236          AC_CHECK_LIB(CEGUITGAImageCodec, createImageCodec,      
237                   [CEGUI_LIBS="$CEGUI_LIBS -lCEGUITGAImageCodec"],       
238                   [echo "GUITGAImageCodec not found/not working, disabled."],    
239                   $OPENGL_LIBS   
240          )       
241                  
242          LIBS="$libstemp"        
243          echo "LIBS : $CEGUI_LIBS"       
244          fi
245
246 AC_SUBST(CEGUI_CFLAGS)
247 AC_SUBST(CEGUI_LIBS)
248
249 AM_CONDITIONAL(GUI_SDL, [test "x$sdl" = "xyes" -a "x$cegui" = "xyes" -a "x$opengl" = "xyes" -a "x$glc" = "xyes" ])
250 AM_CONDITIONAL(GRAPHICS_OPENGL, [test "x$opengl" = "xyes" -a "x$glc" = "xyes" ])
251
252
253 if test x"${USE_LIBGPS}" = xyes
254 then
255         AC_CHECK_HEADER(gps.h, AC_DEFINE([HAVE_LIBGPS],[],Define to 1 if you have the <gps.h> header file.) GPSD_LIBS="-lgps" gpsd=yes,  AC_MSG_WARN([*** no gps.h -- gpsd support disabled]))
256 fi
257 AC_SUBST(GPSD_CFLAGS)
258 AC_SUBST(GPSD_LIBS)
259 AM_CONDITIONAL(VEHICLE_GPSD, [test "x$gpsd" = "xyes"])
260
261 # check for libgarmin
262 PKG_CHECK_MODULES(LIBGARMIN, libgarmin, use_libgarmin=yes, use_libgarmin=no)
263 AC_SUBST(LIBGARMIN_CFLAGS)
264 AC_SUBST(LIBGARMIN_LIBS)
265 AM_CONDITIONAL(HAVELIBGARMIN, [test "x$use_libgarmin" = "xyes"])
266
267 AC_ARG_ENABLE(binding-python, [  --disable-binding-python             don't create binding python ], MODULE_BINDING_PYTHON=$enableval, MODULE_BINDING_PYTHON=yes)
268 if test "$cross_compiling" = no; then
269         if test "x$MODULE_BINDING_PYTHON" = "xyes"; then
270                 AC_PATH_PROG(_PATH_PYTHON,[python])
271                 dnl Libraries and flags for embedded Python.
272                 dnl FIXME: I wish there was a less icky way to get this.
273                 if test x"$_PATH_PYTHON" != x ; then
274                         AC_MSG_CHECKING(for Python linkage)
275                         py_prefix=`$_PATH_PYTHON -c 'import sys; print sys.prefix'`
276                         py_ver=`$_PATH_PYTHON -c 'import sys; print sys.version[[:3]]'`
277                         py_libdir="${py_prefix}/lib/python${py_ver}"
278                         PYTHON_CFLAGS="-I${py_prefix}/include/python${py_ver}"
279                         if test -f $py_libdir/config/Makefile -a -f $py_prefix/include/python${py_ver}/Python.h; then
280                                 py_libs=`grep '^LIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
281                                 py_libc=`grep '^LIBC=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
282                                 py_libm=`grep '^LIBM=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
283                                 py_liblocalmod=`grep '^LOCALMODLIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
284                                 py_libbasemod=`grep '^BASEMODLIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
285                                 PYTHON_LIBS="-L$py_libdir/config $py_libs $py_libc $py_libm -lpython$py_ver $py_liblocalmod $py_libbasemod"
286                                 PYTHON_LIBS=`echo $PYTHON_LIBS | sed -e 's/[ \\t]*/ /g'`
287                                 AC_DEFINE(HAVE_PYTHON, 1, [Define to 1 if you have python])
288                                 python=yes
289                                 AC_MSG_RESULT($py_libdir)
290                         else
291                                 AC_MSG_WARN([$py_libdir/config/Makefile or $py_prefix/include/python${py_ver}/Python.h missing, support for python disabled])
292                         fi
293                 fi
294         fi
295 else
296         AC_MSG_WARN([*** cross compiling, support for python disabled])
297 fi
298 AC_SUBST(PYTHON_CFLAGS)
299 AC_SUBST(PYTHON_LIBS)
300 AM_CONDITIONAL(BINDING_PYTHON, [test "x$python" = "xyes"])
301
302 # NLS
303
304 AC_ARG_ENABLE(nls,
305   [  --disable-nls        disable Native Language Support ( gettext/libintl )],
306    enable_nls=$enableval, enable_nls=yes)
307
308
309 INTLIBS=""
310 MOFILES=""
311 POFILES=""
312 LINGUAS=""
313
314 if test x$enable_nls = xyes; then
315
316   AC_CHECK_FUNC(gettext, [HAVEGETTEXT="yes"], 
317              AC_CHECK_LIB(intl, gettext, [INTLIBS="-lintl" HAVEGETTEXT="yes"],
318                          INTLIBS="" ))
319
320   AC_CHECK_PROG(XGETTEXT, xgettext, xgettext)
321   AC_CHECK_PROG(MSGMERGE, msgmerge, msgmerge)
322   AC_CHECK_PROG(MSGFMT, msgfmt, msgfmt)
323
324   if test "$XGETTEXT" != ""; then 
325     if $XGETTEXT --help 2>&1 | grep illegal >/dev/null ; then
326         echo "xgettext isn't GNU version"
327         XGETTEXT=""
328     fi
329   fi
330
331   if test "$XGETTEXT" != "" -a "$HAVEGETTEXT" != ""; then
332      PO=""
333      if test "$LINGUAS" = ""; then
334            ling=` (cd $srcdir/po; /bin/ls *.po) `
335            for l in $ling; do
336                 lcode=`basename $l .po`
337                 LINGUAS="$LINGUAS$lcode "
338            done
339     fi
340     AC_DEFINE(ENABLE_NLS, [1], [NLS Please])
341     echo "xgettext and gettext() exist; will build i18n support for $LINGUAS"
342   else
343    LINGUAS=""
344    PO=""
345    echo "xgettext and libintl.a don't both exist; will not build i18n support"
346  fi
347  for lang in $LINGUAS; do
348     MOFILES="$MOFILES $lang.mo"
349  done
350  for lang in $LINGUAS; do
351     POFILES="$POFILES $lang.po"
352  done
353 fi
354
355
356 AC_SUBST(INTLIBS)
357 AC_SUBST(MOFILES)
358 AC_SUBST(POFILES)
359 AM_GNU_GETTEXT_VERSION
360 AM_GNU_GETTEXT
361
362 LIBS="$LIBS -lm -rdynamic"
363
364 PACKAGE=navit
365 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
366 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
367 AC_SUBST(PACKAGE)
368 AC_SUBST(VERSION)
369
370 AC_CONFIG_FILES([
371 Makefile
372 src/Makefile
373 src/binding/Makefile
374 src/binding/python/Makefile
375 src/data/Makefile
376 src/data/mg/Makefile
377 src/data/textfile/Makefile
378 src/data/binfile/Makefile
379 src/data/garmin/Makefile
380 src/data/poi_geodownload/Makefile
381 src/data/poi_geodownload/libmdb/Makefile
382 src/data/poi_geodownload/libmdb/include/Makefile
383 src/fib-1.1/Makefile
384 src/graphics/Makefile
385 src/graphics/gtk_drawing_area/Makefile
386 src/graphics/opengl/Makefile
387 src/graphics/null/Makefile
388 src/gui/Makefile
389 src/gui/gtk/Makefile
390 src/gui/sdl/Makefile
391 src/gui/sdl/datafiles/Makefile
392 src/osd/Makefile
393 src/osd/core/Makefile
394 src/speech/Makefile
395 src/speech/cmdline/Makefile
396 src/speech/speech_dispatcher/Makefile
397 src/vehicle/Makefile
398 src/vehicle/file/Makefile
399 src/vehicle/gpsd/Makefile
400 src/xpm/Makefile
401 src/maps/Makefile
402 intl/Makefile
403 po/Makefile
404 ])
405 #src/data/garmin_img/Makefile
406
407 AC_OUTPUT
408
409
410 echo ""
411 echo ""
412 echo "Summary of your installation :"
413 if test x"$gtk2_pkgconfig" = xyes
414         then
415         echo "GTK gui     : ENABLED"
416         else
417         echo "GTK gui     : DISABLED : you are missing a dependency. To fix this install a package named gtk2-devel or libgtk2.0-dev"
418 fi
419 # FIXME : maybe elaborate missing dependencies
420 if test x"$sdl" = xyes
421         then
422         if test x"$cegui" = xyes
423                 then
424                 if test x"$glut" = xyes
425                         then
426                         if test x"$glc" = xyes
427                                 then
428                                 echo "SDL gui     : ENABLED, with $CEGUI_LIBS"
429                                 else
430                                 echo "SDL gui     : DISABLED, you are missing quesoglc"
431                                 fi
432                         else
433                         echo "SDL gui     : DISABLED, your are missing glut"
434                         fi
435                 else
436                 echo "SDL gui     : DISABLED : you are missing cegui-devel >= 0.5"
437         fi
438         else
439         echo "SDL gui     : DISABLED : you are missing a SDL dependency"
440 fi
441 if test x"$gpsd" = xyes
442         then
443         echo "GPSD support: ENABLED"
444         else
445         echo "GPSD support: DISABLED"
446 fi
447 if test x"$speechd" = xyes
448         then
449         echo "SPEECHD     : ENABLED"
450         else
451         echo "SPEECHD     : DISABLED"
452 fi
453 if test "x$use_libgarmin" = "xyes"
454         then
455         echo "Garmin IMG  : ENABLED"
456         else
457         echo "Garmin IMG  : DISABLED (you don't have libgarmin)"
458 fi
459 if test "x$samplemap" = "xyes"
460         then
461         echo "Samplemap   : ENABLED"
462         else
463         echo "Samplemap   : DISABLED"
464 fi
465 if  [ test x"$gtk2_pkgconfig" != xyes ] && [ test x"$sdl" != xyes ]
466         then
467         echo ""
468         echo "" 
469         echo "*** WARNING! you have no gui that can be built! ***"
470         echo "Please install the dependency for at least gtk or sdl gui"
471         echo "For more details, see the wiki at http://navit.sf.net/wiki/"
472         echo "" 
473         exit 1
474 fi