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