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