A whole bunch of changes, mostly Lua related.
[monky] / configure.ac.in
1 dnl major, minor and micro version macros.
2 m4_define([conky_version_major], [1])
3 m4_define([conky_version_minor], [7])
4 m4_define([conky_version_micro], [2])
5 m4_define([conky_version_tag], [pre]) dnl [] for releases
6 m4_define([conky_version_revision],[_pre@REVISION@])
7 m4_define([conky_version],
8     [conky_version_major().conky_version_minor().conky_version_micro()ifelse(
9       conky_version_tag(), [pre],
10       [conky_version_revision()],
11       [ifelse(conky_version_tag(), [], [], [conky_version_tag()])])])
12
13 AC_INIT([Conky], [conky_version()], [brenden1@users.sourceforge.net])
14
15 AM_INIT_AUTOMAKE(conky, conky_version())
16 AM_CONFIG_HEADER(src/config.h)
17 AC_CONFIG_MACRO_DIR([m4])
18
19 dnl prevent libtool setting LTCFLAGS to default of -g -O2 when CFLAGS unset.
20 dnl libtool must be deleted with make distclean to see this fix.
21 if test x"$CFLAGS" = x""; then
22   AC_SUBST(CFLAGS, [ ])
23 fi
24
25 AC_DEFINE([_GNU_SOURCE], [], [Define for GNU source and extensions])
26
27 dnl
28 dnl Tools
29 dnl
30 AC_PROG_CC
31 AC_PROG_LD
32 AC_PROG_INSTALL
33 AC_PROG_LIBTOOL
34 AM_PROG_LIBTOOL
35
36 AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, yes, no)
37 if test x"$HAVE_PKGCONFIG" = x"no"; then
38   AC_MSG_ERROR([pkg-config is required!])
39 fi
40 PKG_PROG_PKG_CONFIG([0.19])
41
42 AC_CONFIG_FILES(
43   Makefile
44   data/Makefile
45   doc/Makefile
46   src/Makefile
47   src/build.h
48   lua/Makefile
49   )
50
51 uname=`uname`
52
53 case $uname in
54   Linux*)
55     WANT_SYSINFO=yes
56     ;;
57   FreeBSD*|GNU/kFreeBSD*)
58     WANT_KVM=yes
59     WANT_DEVSTAT=yes
60     ;;
61 #  NetBSD*)
62 #    WANT_KVM=yes
63 #    WANT_OSSLIB=yes
64 #    ;;
65
66   OpenBSD*)
67     WANT_KVM=yes
68     WANT_OSSLIB=yes
69     ;;
70
71 # Solaris doesn't work at all right now
72 #  SunOS*)
73 #    WANT_KSTAT=yes
74 #    ;;
75
76   *)
77     echo "Your operating system $uname isn't supported"
78     echo "Feel free to help. :P"
79     exit 1
80     ;;
81 esac
82
83 AM_CONDITIONAL(BUILD_LINUX, test x$uname = xLinux)
84 #AM_CONDITIONAL(BUILD_SOLARIS, test x$uname = xSunOS)
85 AM_CONDITIONAL(BUILD_FREEBSD, test x$uname = xFreeBSD -o x$uname = xGNU/kFreeBSD)
86 #AM_CONDITIONAL(BUILD_NETBSD, test x$uname = xNetBSD)
87 AM_CONDITIONAL(BUILD_OPENBSD, test x$uname = xOpenBSD)
88
89 BUILD_DATE=$(LANG=en_US LC_ALL=en_US LOCALE=en_US date)
90 BUILD_ARCH="$(uname -sr) ($(uname -m))"
91 AC_SUBST(BUILD_DATE)
92 AC_SUBST(BUILD_ARCH)
93
94
95 dnl
96 dnl BUILD_CONFIG_OUTPUT option
97 dnl
98
99 AC_ARG_ENABLE([config_output],
100               AC_HELP_STRING([--disable-config-output], [disable if you do not want conky to output a default config (with -C) @<:@default=yes@:>@]),
101               [want_config_output="$enableval"], [want_config_output=yes])
102
103 AM_CONDITIONAL(BUILD_CONFIG_OUTPUT, test x$want_config_output = xyes)
104 if test x$want_config_output = xyes; then
105   AC_DEFINE(CONFIG_OUTPUT, 1, [Define if you want conky to output a default config (with -C)])
106   AC_CHECK_FUNCS(fopencookie)
107   AC_CHECK_FUNCS(funopen)
108 fi
109
110 dnl
111 dnl OWN_WINDOW option
112 dnl
113
114 AC_ARG_ENABLE([own_window],
115               AC_HELP_STRING([--disable-own-window],
116                              [disable if you do not want support for creating own window @<:@default=yes@:>@]),
117               [dah="$enableval"], [dah=yes])
118
119 if test $dah != "no"; then
120   AC_DEFINE(OWN_WINDOW, 1, [Define if you want support for window creating])
121 fi
122
123
124 dnl
125 dnl Audacious Media Player
126 dnl
127
128 AC_ARG_ENABLE([audacious],
129               AC_HELP_STRING([--enable-audacious=[[yes|no|legacy]]],
130                              [enable audacious player support @<:@default=no@:>@]),
131               [want_audacious="$enableval"], [want_audacious=no])
132
133 AM_CONDITIONAL(BUILD_AUDACIOUS, test x$want_audacious = xyes -o x$want_audacious = xlegacy)
134 if test x$want_audacious = xyes; then
135       PKG_CHECK_MODULES([Audacious], [audacious >= 1.4.0 dbus-glib-1 glib-2.0 gobject-2.0])
136       conky_CFLAGS="$conky_CFLAGS $Audacious_CFLAGS"
137       conky_LIBS="$conky_LIBS $Audacious_LIBS"
138       save_CPPFLAGS="$CPPFLAGS"
139       CPPFLAGS="$Audacious_CFLAGS -I`pkg-config --variable=audacious_include_dir audacious`/audacious"
140       AC_CHECK_HEADERS([audacious/audctrl.h audacious/dbus.h glib.h glib-object.h],
141                        [], AC_MSG_ERROR([required header(s) not found]))
142       CPPFLAGS="$save_CPPFLAGS"
143       AC_DEFINE(AUDACIOUS, 1, [Define for Audacious support])
144 else if test x$want_audacious = xlegacy; then
145       PKG_CHECK_MODULES([Audacious], [audacious < 1.4.0 glib-2.0])
146       conky_CFLAGS="$conky_CFLAGS $Audacious_CFLAGS"
147       conky_LIBS="$conky_LIBS $Audacious_LIBS"
148       save_CPPFLAGS="$CPPFLAGS"
149       CPPFLAGS="$Audacious_CFLAGS -I`pkg-config --variable=audacious_include_dir audacious`/audacious"
150       AC_CHECK_HEADERS([audacious/beepctrl.h glib.h], [], AC_MSG_ERROR([required  header(s) not found]))
151       CPPFLAGS="$save_CPPFLAGS"
152       AC_DEFINE(AUDACIOUS, 1, [Define for Audacious support])
153       AC_DEFINE(AUDACIOUS_LEGACY, 1, [Define for Audacious Legacy support])
154       fi
155 fi
156
157
158 dnl
159 dnl BMPx
160 dnl
161
162 AC_ARG_ENABLE([bmpx],
163               AC_HELP_STRING([--enable-bmpx], [enable if you want BMPx support @<:@default=no@:>@]),
164               [want_bmpx="$enableval"], [want_bmpx=no])
165
166 AM_CONDITIONAL(BUILD_BMPX, test x$want_bmpx = xyes)
167 if test x$want_bmpx = xyes; then
168   PKG_CHECK_MODULES([BMPx], [bmp-2.0 >= 0.14.0])
169   conky_CFLAGS="$conky_CFLAGS $BMPx_CFLAGS"
170   conky_LIBS="$conky_LIBS $BMPx_LIBS"
171   AC_DEFINE(BMPX, 1, [Define if you want BMPx support])
172 fi
173
174
175 dnl
176 dnl Support for IBM/Lenovo notebooks
177 dnl
178
179 AC_ARG_ENABLE([ibm],
180               AC_HELP_STRING([--enable-ibm], [enable if you want support for IBM/Lenovo notebooks @<:default=no@:>@]),
181               [want_ibm="$enableval"], [want_ibm=no])
182
183 AM_CONDITIONAL(BUILD_IBM, test x$want_ibm = xyes)
184 if test x$want_ibm = xyes; then
185         if test x"$uname" != xLinux; then
186                 AC_MSG_NOTICE([support for IBM/Lenovo notebooks not supported on $uname... disabling])
187                 want_ibm=no
188         else
189                 AC_DEFINE(IBM, 1, [Define if you want support for IBM/Lenovo notebooks (SMAPI)])
190         fi
191 fi
192
193
194 dnl
195 dnl Hddtemp
196 dnl
197
198 AC_ARG_ENABLE([hddtemp],
199               AC_HELP_STRING([--disable-hddtemp],
200                              [disable if you do not want hddtemp support @<:@default=yes@:>@]),
201               [want_hddtemp="$enableval"], [want_hddtemp=yes])
202
203 AM_CONDITIONAL(BUILD_HDDTEMP, test x$want_hddtemp = xyes)
204 if test x$want_hddtemp = xyes; then
205   if test x"$uname" != xLinux; then
206       AC_MSG_NOTICE([hddtemp not supported on $uname... disabling])
207       want_hddtemp=no
208   else
209       AC_DEFINE(HDDTEMP, 1, [Define if you want hddtemp support])
210   fi
211 fi
212
213
214 dnl
215 dnl Apcupsd
216 dnl
217
218 AC_ARG_ENABLE([apcupsd],
219               AC_HELP_STRING([--disable-apcupsd],
220                              [disable if you do not want apcupsd support @<:@default=yes@:>@]),
221               [want_apcupsd="$enableval"], [want_apcupsd=yes])
222
223 if test x$want_apcupsd = xyes; then
224   if test x"$uname" != xLinux; then
225       AC_MSG_NOTICE([apcupsd not supported on $uname... disabling])
226       want_apcupsd=no
227   else
228       AC_DEFINE(APCUPSD, 1, [Define if you want apcupsd support])
229   fi
230 fi
231 AM_CONDITIONAL(BUILD_APCUPSD, test x$want_apcupsd = xyes)
232
233
234 dnl
235 dnl I/O stats
236 dnl
237
238 AC_ARG_ENABLE([iostats],
239               AC_HELP_STRING([--enable-iostats],
240                              [enable if you want support for per-task I/O statistics @<:@default=no@:>@]),
241               [want_iostats="$enableval"], [want_iostats=no])
242
243 if test x$want_iostats = xyes; then
244   if test x"$uname" != xLinux; then
245       AC_MSG_NOTICE([iostats not supported on $uname... disabling])
246       want_apcupsd=no
247   else
248       AC_DEFINE(IOSTATS, 1, [Define if you want support for per-task I/O statistics])
249   fi
250 fi
251
252
253 dnl
254 dnl Math
255 dnl
256
257 AC_ARG_ENABLE([math],
258               AC_HELP_STRING([--disable-math], [disable if you do not want math support @<:@default=yes@:>@]),
259               [want_math="$enableval"], [want_math=yes])
260
261 AM_CONDITIONAL(BUILD_MATH, test x$want_math = xyes)
262 if test x$want_math = xyes; then
263   conky_LIBS="$conky_LIBS -lm"
264   AC_DEFINE(MATH, 1, [Define if you want math support])
265 fi
266
267 dnl
268 dnl MPD
269 dnl
270
271 AC_ARG_ENABLE([mpd],
272               AC_HELP_STRING([--disable-mpd], [disable if you do not want MPD support @<:@default=yes@:>@]),
273               [want_mpd="$enableval"], [want_mpd=yes])
274
275 AM_CONDITIONAL(BUILD_MPD, test x$want_mpd = xyes)
276 if test x$want_mpd = xyes; then
277   AC_DEFINE(MPD, 1, [Define if you want MPD support])
278 fi
279
280 dnl
281 dnl MOC
282 dnl
283
284 AC_ARG_ENABLE([moc],
285               AC_HELP_STRING([--disable-moc], [disable if you do not want MOC support @<:@default=yes@:>@]),
286               [want_moc="$enableval"], [want_moc=yes])
287
288 AM_CONDITIONAL(BUILD_MOC, test x$want_moc = xyes)
289 if test x$want_moc = xyes; then
290   AC_DEFINE(MOC, 1, [Define if you want MOC support])
291 fi
292
293 dnl
294 dnl XMMS2
295 dnl
296
297 AC_ARG_ENABLE([xmms2],
298               AC_HELP_STRING([--enable-xmms2], [enable if you want XMMS2 support @<:@default=no@:>@]),
299               [want_xmms2="$enableval"], [want_xmms2=no])
300
301 AM_CONDITIONAL(BUILD_XMMS2, test x$want_xmms2 = xyes)
302 if test x$want_xmms2 = xyes; then
303   PKG_CHECK_MODULES([XMMS2], [xmms2-client])
304     conky_CFLAGS="$conky_CFLAGS $XMMS2_CFLAGS"
305     conky_LIBS="$conky_LIBS $XMMS2_LIBS"
306     AC_DEFINE(XMMS2, 1, [Define if you want XMMS2 support])
307 fi
308
309 dnl
310 dnl EVE Skill Monitor
311 dnl
312
313 AC_ARG_ENABLE([eve],
314               AC_HELP_STRING([--enable-eve], [Eve-Online skill monitor @<:@default=no@:>@]),
315               [want_eve="$enableval"], [want_eve=no])
316
317 AM_CONDITIONAL(BUILD_EVE, test x$want_eve = xyes)
318 if test x$want_eve = xyes; then
319         PKG_CHECK_MODULES([libxml2], libxml-2.0)
320         PKG_CHECK_MODULES([libcurl], libcurl)
321         conky_CFLAGS="$conky_CFLAGS $libxml2_CFLAGS $libcurl_CFLAGS"
322         conky_LIBS="$conky_LIBS $libxml2_LIBS $libcurl_LIBS"
323         AC_DEFINE(EVE, 1, [Define if you want Eve-Online Skill monitor support])
324         AC_DEFINE(EVEURL_TRAINING, "http://api.eve-online.com/char/SkillInTraining.xml.aspx", [Eve training URL])
325         AC_DEFINE(EVEURL_SKILLTREE, "http://api.eve-online.com/eve/Skilltree.xml.aspx", [Eve skilltree URL])
326         AC_DEFINE(MY_ENCODING, "ISO-8859-1", [Textencoding to use])
327         AC_DEFINE(EVE_OUTPUT_FORMAT, "%s %d in %s", [Eve output format])
328 fi
329
330 dnl
331 dnl RSS
332 dnl
333
334 AC_ARG_ENABLE([rss],
335               AC_HELP_STRING([--enable-rss], [enable if you want rss support @<:@default=no@:>@]),
336               [want_rss="$enableval"], [want_rss=no])
337 #
338 AM_CONDITIONAL(BUILD_RSS, test x$want_rss = xyes)
339 if test x$want_rss = xyes; then
340         WANT_GLIB=yes
341         PKG_CHECK_MODULES([libxml2], libxml-2.0)
342         PKG_CHECK_MODULES([libcurl], libcurl)
343         conky_CFLAGS="$conky_CFLAGS $libxml2_CFLAGS $libcurl_CFLAGS"
344         conky_LIBS="$conky_LIBS $libxml2_LIBS $libcurl_LIBS"
345         AC_DEFINE(RSS, 1, [Define if you want rss support])
346 fi
347
348 dnl
349 dnl WEATHER
350 dnl
351
352 AC_ARG_ENABLE([weather],
353               AC_HELP_STRING([--enable-weather], [enable if you want weather support @<:@default=no@:>@]),
354               [want_weather="$enableval"], [want_weather=no])
355 #
356 AM_CONDITIONAL(BUILD_WEATHER, test x$want_weather = xyes)
357 if test x$want_weather = xyes; then
358         WANT_GLIB=yes
359         PKG_CHECK_MODULES([libcurl], libcurl)
360         conky_CFLAGS="$conky_CFLAGS $libcurl_CFLAGS"
361         conky_LIBS="$conky_LIBS $libcurl_LIBS"
362         AC_DEFINE(WEATHER, 1, [Define if you want weather support])
363 fi
364
365 dnl
366 dnl X11
367 dnl
368
369 AC_ARG_ENABLE([x11],
370               AC_HELP_STRING([--disable-x11], [disable if you do not want X11 support @<:@default=yes@:>@]),
371               [want_x11="$enableval"], [want_x11=yes])
372
373 AM_CONDITIONAL(BUILD_X11, test x$want_x11 = xyes)
374 if test "x$want_x11" = "xyes"; then
375     if $PKG_CONFIG --exists x11; then
376       PKG_CHECK_MODULES([X11], [x11])
377       conky_CFLAGS="$conky_CFLAGS $X11_CFLAGS"
378       conky_LIBS="$conky_LIBS $X11_LIBS"
379     else
380       dnl non-modular X11 installations
381       AC_PATH_X
382       AC_PATH_XTRA
383       conky_CFLAGS="$conky_CFLAGS $X_CFLAGS"
384       conky_LIBS="$conky_LIBS $X_LIBS"
385       conky_LDFLAGS="$conky_LDFLAGS $conky_LIBS $X_PRE_LIBS"
386       if test "x$no_x" = "xyes"; then
387         AC_MSG_ERROR([Can't locate your X11 installation])
388       fi
389       AC_CHECK_LIB([X11], [XOpenDisplay], [], AC_MSG_ERROR([Could not find XOpenDisplay in -lX11]))
390     fi
391     AC_DEFINE(X11, 1, [Define if you want to use X11])
392 fi
393
394 dnl
395 dnl IMLIB2
396 dnl
397
398 AC_ARG_ENABLE([imlib2],
399                           AC_HELP_STRING([--enable-imlib2], [enable if you want Imlib2 support (also enables Lua Imlib2 support if lua-extras enabled) [[default=no]]]),
400                           [want_imlib2="$enableval"], [want_imlib2=no])
401 if test x$want_imlib2 = xyes; then
402         if test "x$want_x11" != "xyes"; then
403                 dnl silently disable if no x11
404                 want_imlib2=no
405         else
406                 PKG_CHECK_MODULES([Imlib2], [imlib2])
407                 conky_CFLAGS="$conky_CFLAGS $Imlib2_CFLAGS"
408                 conky_LIBS="$conky_LIBS $Imlib2_LIBS"
409                 AC_DEFINE(IMLIB2, 1, [Define if you want Imlib2 support])
410         fi
411 fi
412 AM_CONDITIONAL(BUILD_IMLIB2, test x$want_imlib2 = xyes)
413
414 dnl
415 dnl Lua
416 dnl
417
418 AC_ARG_ENABLE([lua],
419               AC_HELP_STRING([--enable-lua], [enable if you want Lua scripting support @<:@default=yes@:>@]),
420               [want_lua="$enableval"], [want_lua=yes])
421 AC_ARG_ENABLE([lua-extras],
422               AC_HELP_STRING([--enable-lua-extras], [enable if you want to install Lua extras (including bindings) @<:@default=no@:>@]),
423               [want_lua_extras="$enableval"], [want_lua_extras=no])
424 AC_ARG_ENABLE([lua-cairo],
425               AC_HELP_STRING([--enable-lua-cairo], [enable if you want Lua Cairo bindings for Conky (requires lua-extras enabled) @<:@default=no@:>@]),
426               [want_lua_cairo="$enableval"], [want_lua_cairo=no])
427
428 AM_CONDITIONAL(BUILD_LUA, test x$want_lua = xyes)
429 if test x$want_lua = xyes; then
430         PKG_CHECK_MODULES(LUA, lua >= 5.1, [ ],[
431                 PKG_CHECK_MODULES(LUA51, lua-5.1 >= 5.1, [ ],[
432                         PKG_CHECK_MODULES(LUA51, lua5.1 >= 5.1)
433                 ])
434         ])
435         conky_CFLAGS="$conky_CFLAGS $LUA_CFLAGS $LUA51_CFLAGS"
436         conky_LIBS="$conky_LIBS $LUA_LIBS $LUA51_LIBS"
437
438         want_lua_imlib2="$want_imlib2"
439         if test x$want_lua_extras != xyes; then
440                 want_lua_cairo=no
441                 want_lua_imlib2=no
442         else
443                 AC_CHECK_PROG(HAVE_TOLUAPP, tolua++, yes, no)
444                 if test "x$want_x11" != "xyes"; then
445                         dnl silently disable if no x11
446                         want_lua_cairo=no
447                 else
448                         if test x$want_lua_cairo = xyes; then
449                                 PKG_CHECK_MODULES([cairo], cairo)
450                                 PKG_CHECK_MODULES([cairo_xlib], cairo-xlib)
451                                 if test x"$HAVE_TOLUAPP" = x"no"; then
452                                         AC_MSG_ERROR([tolua++ is required for Lua Cairo support.])
453                                 else
454                                         AC_CHECK_PROGS(toluapp, tolua++)
455                                         AC_DEFINE(HAVE_LUA_CAIRO, 1, [Define if you want Lua Cairo bindings for Conky])
456                                 fi
457                                 libcairo_CFLAGS="$libcairo_CFLAGS $cairo_CFLAGS $cairo_xlib_CFLAGS"
458                                 libcairo_LIBS="$libcairo_LIBS $cairo_LIBS $cairo_xlib_LIBS"
459                         fi
460                         if test x$want_imlib2 = xyes; then
461                                 if test x"$HAVE_TOLUAPP" = x"no"; then
462                                         AC_MSG_ERROR([tolua++ is required for Lua Imlib2 support.])
463                                 else
464                                         want_lua_imlib2=yes
465                                         AC_CHECK_PROGS(toluapp, tolua++)
466                                         AC_DEFINE(HAVE_LUA_IMLIB2, 1, [Define if you want Lua Imlib2 bindings for Conky])
467                                 fi
468                         fi
469                 fi
470         fi
471         AM_CONDITIONAL(BUILD_LUA_CAIRO, test x$want_lua_cairo = xyes)
472         AM_CONDITIONAL(BUILD_LUA_IMLIB2, test x$want_lua_imlib2 = xyes)
473         AC_DEFINE(HAVE_LUA, 1, [Define if you want Lua scripting support])
474 fi
475
476 dnl
477 dnl Wireless extensions
478 dnl
479
480 AC_ARG_ENABLE([wlan],
481               AC_HELP_STRING([--enable-wlan], [enable if you want wireless support @<:@default=no@:>@]),
482               [want_wlan="$enableval"], [want_wlan=no])
483
484 AM_CONDITIONAL(BUILD_WLAN, test x$want_wlan = xyes)
485 if test x$want_wlan = xyes; then
486   AC_CHECK_HEADERS([iwlib.h], [], AC_MSG_ERROR([iwlib.h header not found]))
487   AC_CHECK_LIB([iw], [iw_sockets_open], [conky_LIBS="$conky_LIBS -liw"], AC_MSG_ERROR([iw_sockets_open not found]))
488         AC_DEFINE(HAVE_IWLIB, 1, [Define if you want wireless support])
489 fi
490
491 dnl
492 dnl PORT_MONITORS
493 dnl
494
495 AC_ARG_ENABLE([portmon],
496               AC_HELP_STRING([--disable-portmon],
497                              [disable if you do not want tcp (ip4) port monitoring @<:@default=yes@:>@]),
498               [want_portmon="$enableval"], [want_portmon=yes])
499
500 if test x"$want_portmon" = xyes; then
501   if test x"$uname" != xLinux; then
502       AC_MSG_NOTICE([port monitors not supported on $uname... disabling])
503       want_portmon=no
504   else
505         AC_CHECK_FUNCS([getnameinfo], [], AC_MSG_ERROR([getnameinfo function not found]))
506         AC_CHECK_HEADERS([netdb.h netinet/in.h netinet/tcp.h sys/socket.h arpa/inet.h], [],
507            [PORT_MONITORS_MISSING=yes])
508         if test x"$PORT_MONITORS_MISSING" = xyes; then
509               AC_MSG_ERROR([missing a needed network header for port monitoring])
510         fi
511         WANT_GLIB=yes
512         AC_DEFINE(TCP_PORT_MONITOR, 1, [Define if you want tcp port monitoring support])
513   fi
514 fi
515 AM_CONDITIONAL(BUILD_PORT_MONITORS, test x"$want_portmon" = xyes)
516
517
518 dnl
519 dnl ICONV
520 dnl
521
522 AM_ICONV
523 if test "$am_cv_func_iconv" != yes; then
524   AC_MSG_WARN([Could not find libiconv])
525 else
526   conky_LIBS="$conky_LIBS $LIBICONV"
527 fi
528
529 dnl
530 dnl Xext Double-buffering Extension
531 dnl
532
533 AC_ARG_ENABLE([double_buffer],
534               AC_HELP_STRING([--disable-double-buffer],
535                              [disable for no Xdbe double-buffering support @<:@default=yes@:>@]),
536               [want_double_buffer="$enableval"], [want_double_buffer=yes])
537
538 if test "x$want_double_buffer" = "xyes"; then
539     if test "x$want_x11" != "xyes"; then
540       dnl silently disable if no x11
541       want_double_buffer=no
542     else
543       if $PKG_CONFIG --exists xext; then
544         PKG_CHECK_MODULES([Xext],[xext])
545         conky_CFLAGS="$conky_CFLAGS $Xext_CFLAGS"
546         conky_LIBS="$conky_LIBS $Xext_LIBS"
547       else
548         dnl non-modular X11 installation
549         AC_CHECK_LIB([Xext], [XdbeQueryExtension], [conky_LIBS="$conky_LIBS -lXext"],
550                     AC_MSG_ERROR([Could not find XdbeQueryExtension in -lXext]))
551       fi
552       AC_DEFINE(HAVE_XDBE, 1, [Define for X11 double-buffering])
553     fi
554 fi
555
556
557 dnl
558 dnl Xdamage Extension
559 dnl
560
561 AC_ARG_ENABLE([xdamage],
562               AC_HELP_STRING([--disable-xdamage],
563                              [disable if you do not want Xdamage support @<:@default=yes@:>@]),
564               [want_xdamage="$enableval"], [want_xdamage=yes])
565
566 if test "x$want_xdamage" = "xyes"; then
567     if test "x$want_x11" != "xyes"; then
568       dnl silently disable if no x11
569       want_xdamage=no
570     else
571       if $PKG_CONFIG --exists xdamage; then
572         PKG_CHECK_MODULES([XDamage],[xdamage])
573         conky_CFLAGS="$conky_CFLAGS $XDamage_CFLAGS"
574         conky_LIBS="$conky_LIBS $XDamage_LIBS"
575       else
576         dnl non-modular X11 installation
577         AC_CHECK_LIB([Xdamage], [XDamageQueryExtension], [conky_LIBS="$conky_LIBS -lXdamage"],
578                      AC_MSG_ERROR([Could not find XDamageQueryExtension in -lXdamage]))
579       fi
580       AC_DEFINE(HAVE_XDAMAGE, 1, [Define for X11 Xdamage extension])
581     fi
582 fi
583
584
585 dnl
586 dnl Xft
587 dnl
588
589 AC_ARG_ENABLE([xft],
590               AC_HELP_STRING([--disable-xft], [disable if you do not want to use Xft @<:@default=yes@:>@]),
591               [want_xft="$enableval"], [want_xft=yes])
592
593 if test x$want_xft = "xyes"; then
594     if test "x$want_x11" != "xyes"; then
595       dnl silently disable if no x11
596       want_xft=no
597     else
598       PKG_CHECK_MODULES([Xft], [xft])
599       conky_CFLAGS="$conky_CFLAGS $Xft_CFLAGS"
600       conky_LIBS="$conky_LIBS $Xft_LIBS"
601       AC_DEFINE(XFT, 1, [Define for Xft support])
602     fi
603 fi
604
605 dnl
606 dnl NVIDIA libXNVCtrl support
607 dnl
608
609 AC_ARG_ENABLE([nvidia],
610                 AC_HELP_STRING([--enable-nvidia], [enable if you want nvidia support @<:@default=no@:>@]),
611                 [want_nvidia="$enableval"], [want_nvidia=no])
612 if test x$want_nvidia = xyes; then
613     if test "x$want_x11" != "xyes"; then
614                 # do nada
615                 want_nvidia=no
616         else
617                 AC_CHECK_HEADERS([NVCtrl/NVCtrl.h], [], AC_MSG_ERROR([NVCtrl/NVCtrl.h header not found]))
618 dnl AC_CHECK_LIB([XNVCtrl], [XNVCTRLQueryVersion], [] ,[AC_MSG_ERROR([grrr])] )
619 dnl AC_CHECK_LIB([XNVCtrl], [XNVCTRLCheckTargetData], [], [AC_MSG_ERROR([grr])])
620 dnl ## am I Stupid ??
621 dnl ## it won't find the lib for some reason!?
622                 conky_LIBS="$conky_LIBS -lXNVCtrl"
623                         AC_DEFINE(NVIDIA, 1, [Define if you want nvidia support])
624         fi
625 fi
626 AM_CONDITIONAL(BUILD_NVIDIA, test x$want_nvidia = xyes)
627
628 dnl
629 dnl GLIB
630 dnl
631
632 if test x$WANT_GLIB = xyes; then
633         PKG_CHECK_MODULES([GLib2], [glib-2.0])
634         conky_CFLAGS="$conky_CFLAGS $GLib2_CFLAGS"
635         conky_LIBS="$conky_LIBS $GLib2_LIBS"
636 fi
637
638 dnl
639 dnl KVM
640 dnl
641
642 if test x$WANT_KVM = xyes; then
643   AC_CHECK_LIB(kvm, kvm_open,
644     conky_LIBS="$conky_LIBS -lkvm",
645   AC_MSG_ERROR([Could not find kvm_open in -lkvm.])
646   )
647 fi
648
649 dnl
650 dnl devstat
651 dnl
652
653 if test x$WANT_DEVSTAT = xyes; then
654   AC_CHECK_LIB(devstat, devstat_getversion,
655          conky_LIBS="$conky_LIBS -ldevstat",
656          AC_MSG_ERROR([Cound not find devstat_getversion in -ldevstat.])
657   )
658 fi
659
660 dnl
661 dnl OSSLIB for NetBSD/OpenBSD
662 dnl
663
664 if test x$WANT_OSSLIB = xyes; then
665     AC_CHECK_LIB(ossaudio, _oss_ioctl,
666   conky_LIBS="$conky_LIBS -lossaudio",
667   AC_MSG_ERROR([Could not find oss_ioctl in -lossaudio.])
668     )
669 fi
670
671 dnl
672 dnl ALSA for Linux
673 dnl
674 AC_ARG_ENABLE([alsa],
675               AC_HELP_STRING([--disable-alsa], [disable if you do not
676   want ALSA support @<:@default=yes@:>@]),
677               [want_alsa="$enableval"], [want_alsa=yes])
678
679 if test x$want_alsa = xyes; then
680     AC_CHECK_HEADER(alsa/asoundlib.h,, want_alsa=no)
681 fi
682 if test x$want_alsa = xyes; then
683     AC_CHECK_LIB(asound, snd_pcm_open,conky_LIBS="$conky_LIBS -lasound", want_alsa=no)
684 fi
685 if test x$want_alsa = xyes; then
686 AC_DEFINE(MIXER_IS_ALSA, 1, [Define if the mixers use ALSA])
687 fi
688 dnl
689 dnl Some headers
690 dnl
691
692 AC_CHECK_HEADERS([signal.h unistd.h sys/utsname.h sys/stat.h linux/soundcard.h alsa/asoundlib.h dirent.h mcheck.h \
693       sys/statfs.h sys/param.h pthread.h assert.h errno.h time.h])
694 AC_CHECK_HEADERS([sys/mount.h], [], [],
695      [#ifdef HAVE_SYS_PARAM_H
696       #include <sys/param.h>
697       #endif
698       ])
699 # check if we have inotify support
700 AC_CHECK_HEADERS([sys/inotify.h])
701
702 dnl
703 dnl Some defines
704 dnl
705
706 AC_DEFINE(DEFAULTNETDEV, "eth0", [Default networkdevice])
707 AC_DEFINE(CONFIG_FILE, "$HOME/.conkyrc", [Configfile of the user])
708 AC_DEFINE(MAX_SPECIALS_DEFAULT, 512, [Default maximum number of special things, e.g. fonts, offsets, aligns, etc.])
709 AC_DEFINE(MAX_USER_TEXT_DEFAULT, 16384, [Default maximum size of config TEXT buffer, i.e. below TEXT line.])
710 AC_DEFINE(DEFAULT_TEXT_BUFFER_SIZE, 256, [Default size used for temporary, static text buffers])
711
712 dnl
713 dnl Some functions
714 dnl
715
716 AC_CHECK_FUNCS([calloc malloc free popen sysinfo getloadavg memrchr strndup gethostbyname_r])
717 AC_SEARCH_LIBS(clock_gettime, [rt],
718                [AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])],
719                [AC_CHECK_FUNCS([gettimeofday], [], [AC_MSG_ERROR([gettimeofday() not available!])])], [])
720
721 dnl
722 dnl Structure checks
723 dnl
724
725 AC_CHECK_MEMBER([struct statfs.f_fstypename],
726                  [AC_DEFINE(HAVE_STRUCT_STATFS_F_FSTYPENAME, 1, [Define if struct statfs has the f_fstypename member])],
727                  [],
728                  [#include <sys/statfs.h>])
729
730 dnl
731 dnl Check for zlib
732 dnl
733
734 AC_CHECK_HEADER(zlib.h,
735                 [],
736                 [AC_MSG_ERROR([zlib is missing; please install the headers first])])
737
738
739 dnl
740 dnl Check for OpenMP support
741 dnl
742
743 AC_ARG_ENABLE([openmp],
744               AC_HELP_STRING([--enable-openmp], [enable if you want OpenMP support @<:@default=no@:>@]),
745               [want_openmp="$enableval"], [want_openmp=no])
746
747 if test x$want_openmp = xyes; then
748         AX_OPENMP([
749           gcc_version=`$CC -dumpversion`
750           gcc_major=`echo $gcc_version | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
751           gcc_minor=`echo $gcc_version | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
752           dnl check that the gcc version is >=4.3, if we're using gcc
753           if test ! "x$GCC" = "xyes" -o $gcc_major -ge 4 -a $gcc_minor -ge 3; then
754             AC_DEFINE(HAVE_OPENMP,1,[Define if OpenMP is enabled])
755             conky_CFLAGS="$conky_CFLAGS $OPENMP_CFLAGS"
756           else
757             want_openmp=no
758           fi
759
760         ])
761 fi
762
763 dnl
764 dnl Check doc stuff
765 dnl
766
767 AC_CHECK_PROGS(db2x_xsltproc_cmd, db2x_xsltproc)
768 AC_CHECK_PROGS(db2x_manxml_cmd, db2x_manxml)
769 AC_CHECK_PROGS(xsltproc_cmd, xsltproc)
770 if test x$db2x_xsltproc_cmd = "x" -o x$xsltproc_cmd = "x"; then
771   AM_CONDITIONAL(HAVE_DOCSTUFF, false)
772 else
773   AM_CONDITIONAL(HAVE_DOCSTUFF, true)
774 fi
775
776 dnl
777 dnl kstat in Solaris
778 dnl
779
780 if test x$WANT_KSTAT = xyes; then
781   dah=no
782   AC_CHECK_LIB([kstat], [kstat_open], [dah=yes], [])
783
784   if test x$dah = xyes; then
785     AC_DEFINE(HAVE_KSTAT, 1, [Define if you have kstat (Solaris)])
786     conky_LDFLAGS="$conky_LDFLAGS -lkstat"
787   fi
788 fi
789
790 AC_DEFUN([AM_LANGINFO_CODESET],
791 [
792   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
793     [AC_TRY_LINK([#include <langinfo.h>],
794       [char* cs = nl_langinfo(CODESET);],
795       am_cv_langinfo_codeset=yes,
796       am_cv_langinfo_codeset=no)
797     ])
798   if test $am_cv_langinfo_codeset = yes; then
799     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
800       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
801   fi
802 ])
803
804
805 dnl ************************
806 dnl * Linker optimizations *
807 dnl ************************
808 AC_MSG_CHECKING([if $LD accepts -O1])
809 case `$LD -O1 -v 2>&1 </dev/null` in
810 *GNU* | *BSD*)
811   conky_LDFLAGS="$conky_LDFLAGS -Wl,-O1"
812   AC_MSG_RESULT([yes])
813   ;;
814 *)
815   AC_MSG_RESULT([no])
816   ;;
817 esac
818
819 dnl Solve multiple definitions (only necessary when gnulib is used)
820 dnl conky_LDFLAGS="$conky_LDFLAGS -Xlinker -zmuldefs"
821
822 dnl
823 dnl Da.
824 dnl
825
826 conky_CFLAGS="$conky_CFLAGS -Wall -W"
827
828 dnl
829 dnl debug
830 dnl
831
832 AC_ARG_ENABLE([debug],
833               AC_HELP_STRING([--enable-debug], [compile with debug symbols @<:@default=no@:>@]),
834               [want_debug="$enableval"], [want_debug=no])
835
836 if test "x$want_debug" = "xyes" -a $ac_cv_c_compiler_gnu != no; then
837   conky_CFLAGS="$conky_CFLAGS -g3"
838   AC_DEFINE([DEBUG], 1, [Define for debugging])
839 fi
840
841 dnl
842 dnl testing
843 dnl
844
845 AC_ARG_ENABLE([testing],
846               AC_HELP_STRING([--enable-testing], [use strict compiler flags for testing @<:@default=no@:>@]),
847               [want_testing="$enableval"], [want_testing=no])
848
849 if test "x$want_testing" = "xyes" -a $ac_cv_c_compiler_gnu != no; then
850   if test "x$want_debug" = "xyes"; then
851     conky_CFLAGS="$conky_CFLAGS -Wextra -Wunused -Wdeclaration-after-statement -Wundef -Wendif-labels -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wold-style-definition -Winline -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -std=c99 -pedantic -Werror"
852     AC_DEFINE([TESTING], [], [Define for testing (enables strict compiler flags)])
853   else
854     conky_CFLAGS="$conky_CFLAGS -g3 -Wextra -Wunused -Wdeclaration-after-statement -Wundef -Wendif-labels -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wold-style-definition -Winline -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -std=c99 -pedantic -Werror"
855     AC_DEFINE([TESTING], [], [Define for testing (enables strict compiler flags)])
856   fi
857 fi
858
859 AC_SUBST(conky_CFLAGS)
860 AC_SUBST(conky_LIBS)
861 AC_SUBST(X11_LIBS)
862
863 AC_OUTPUT
864
865 dnl
866 dnl Print summary
867 dnl
868 cat << EOF
869
870 $PACKAGE $VERSION configured successfully:
871
872  Installing into:   $prefix
873  System config dir: $sysconfdir
874  C compiler flags:  $conky_CFLAGS
875  Libraries:         $conky_LIBS
876  Linker flags:      $conky_LDFLAGS
877
878  * X11:
879   X11 support:      $want_x11
880   XDamage support:  $want_xdamage
881   XDBE support:     $want_double_buffer
882   Xft support:      $want_xft
883
884  * Music detection:
885   Audacious:        $want_audacious
886   BMPx:             $want_bmpx
887   MPD:              $want_mpd
888   MOC:              $want_moc
889   XMMS2:            $want_xmms2
890
891  * General:
892   OpenMP:           $want_openmp
893   math:             $want_math
894   hddtemp:          $want_hddtemp
895   portmon:          $want_portmon
896   RSS:              $want_rss
897   Weather (METAR):  $want_weather
898   wireless:         $want_wlan
899   IBM:              $want_ibm
900   nvidia:           $want_nvidia
901   eve-online:       $want_eve
902   config-output:    $want_config_output
903   Imlib2:           $want_imlib2
904   ALSA mixer:       $want_alsa
905   apcupsd:          $want_apcupsd
906   I/O stats:        $want_iostats
907
908  * Lua ($want_lua) bindings:
909   Cairo:            $want_lua_cairo
910   Imlib2:           $want_lua_imlib2
911
912 EOF