Externalize default config file: /conky/conky.conf
[monky] / configure.ac.in
1 dnl $Id$ 
2
3 dnl major, minor and micro version macros.
4 m4_define([conky_version_major], [1])
5 m4_define([conky_version_minor], [4])
6 m4_define([conky_version_micro], [9])
7 m4_define([conky_version_tag], [svn]) dnl [] for releases
8 m4_define([conky_version_revision],[r@REVISION@])
9 m4_define([conky_version], 
10     [conky_version_major().conky_version_minor().conky_version_micro()ifelse(
11       conky_version_tag(), [svn], 
12       [-conky_version_tag()-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
20 dnl prevent libtool setting LTCFLAGS to default of -g -O2 when CFLAGS unset.
21 dnl libtool must be deleted with make distclean to see this fix.
22 if test x"$CFLAGS" = x""; then
23   AC_SUBST(CFLAGS, [ ])
24 fi
25
26 dnl
27 dnl Tools
28 dnl
29 AC_PROG_CC
30 AC_PROG_LD
31 AC_PROG_INSTALL
32 AC_PROG_LIBTOOL
33
34 AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, yes, no)
35 if test x"$HAVE_PKGCONFIG" = x"no"; then
36   AC_MSG_ERROR([pkg-config is required!])
37 fi
38 PKG_PROG_PKG_CONFIG([0.19])
39
40 AC_CONFIG_FILES(
41   Makefile
42   data/Makefile
43   doc/Makefile
44   src/Makefile
45   src/build.h
46   )
47
48 uname=`uname`
49
50 case $uname in
51   Linux*)
52     WANT_SYSINFO=yes
53     ;;
54   FreeBSD*)
55     WANT_KVM=yes
56     WANT_DEVSTAT=yes
57     ;;
58 #  NetBSD*)
59 #    WANT_KVM=yes
60 #    WANT_OSSLIB=yes
61 #    ;;
62
63   OpenBSD*)
64     WANT_KVM=yes
65     WANT_OSSLIB=yes
66     ;;
67
68 # Solaris doesn't work at all right now
69 #  SunOS*)
70 #    WANT_KSTAT=yes
71 #    ;;
72
73   *)
74     echo "Your operating system $uname isn't supported"
75     echo "Feel free to help. :P"
76     exit 1
77     ;;
78 esac
79
80 AM_CONDITIONAL(BUILD_LINUX, test x$uname = xLinux)
81 #AM_CONDITIONAL(BUILD_SOLARIS, test x$uname = xSunOS)
82 AM_CONDITIONAL(BUILD_FREEBSD, test x$uname = xFreeBSD)
83 #AM_CONDITIONAL(BUILD_NETBSD, test x$uname = xNetBSD)
84 AM_CONDITIONAL(BUILD_OPENBSD, test x$uname = xOpenBSD)
85
86 BUILD_DATE=$(LANG=en_US LC_ALL=en_US LOCALE=en_US date)
87 BUILD_ARCH="$(uname -sr) ($(uname -m))"
88 AC_SUBST(BUILD_DATE)
89 AC_SUBST(BUILD_ARCH)
90
91
92 dnl
93 dnl OWN_WINDOW option
94 dnl
95
96 AC_ARG_ENABLE([own_window],
97               AC_HELP_STRING([--disable-own-window], 
98                              [disable if you do not want support for creating own window @<:@default=yes@:>@]),
99               [dah="$enableval"], [dah=yes])
100
101 if test $dah != "no"; then
102   AC_DEFINE(OWN_WINDOW, 1, [Define if you want support for window creating])
103 fi
104
105
106 dnl
107 dnl Audacious Media Player
108 dnl
109
110 AC_ARG_ENABLE([audacious],
111               AC_HELP_STRING([--enable-audacious], [enable audacious player support @<:@default=no@:>@]),
112               [want_audacious="$enableval"], [want_audacious=no])
113
114 AM_CONDITIONAL(BUILD_AUDACIOUS, test x$want_audacious = xyes)
115 if test x$want_audacious = xyes; then
116   PKG_CHECK_MODULES([AUDACIOUS], [audacious >= 0.1])
117       CFLAGS="$CFLAGS $AUDACIOUS_CFLAGS"
118       LIBS="$LIBS $AUDACIOUS_LIBS"
119       AC_DEFINE(AUDACIOUS, 1, [Define for Audacious support])
120 fi
121
122
123 dnl
124 dnl BMPx
125 dnl
126
127 AC_ARG_ENABLE([bmpx],
128               AC_HELP_STRING([--enable-bmpx], [enable if you want BMPx support @<:@default=no@:>@]),
129               [want_bmpx="$enableval"], [want_bmpx=no])
130
131 AM_CONDITIONAL(BUILD_BMPX, test x$want_bmpx = xyes)
132 if test x$want_bmpx = xyes; then
133   PKG_CHECK_MODULES([BMPX], [bmp-2.0 >= 0.14.0])
134   CFLAGS="$CFLAGS $BMPX_CFLAGS"
135   LIBS="$LIBS $BMPX_LIBS"
136   AC_DEFINE(BMPX, 1, [Define if you want BMPx support])
137 fi
138
139
140 dnl
141 dnl Hddtemp
142 dnl
143
144 AC_ARG_ENABLE([hddtemp],
145               AC_HELP_STRING([--disable-hddtemp], 
146                              [disable if you do not want hddtemp support @<:@default=yes@:>@]),
147               [want_hddtemp="$enableval"], [want_hddtemp=yes])
148
149 AM_CONDITIONAL(BUILD_HDDTEMP, test x$want_hddtemp = xyes)
150 if test x$want_hddtemp = xyes; then
151   if test x"$uname" != xLinux; then
152       AC_MSG_NOTICE([hddtemp not supported on $uname... disabling])
153       want_hddtemp=no
154   else
155       AC_DEFINE(HDDTEMP, 1, [Define if you want hddtemp support])
156   fi
157 fi
158
159 dnl
160 dnl MPD
161 dnl
162
163 AC_ARG_ENABLE([mpd],
164               AC_HELP_STRING([--disable-mpd], [disable if you do not want MPD support @<:@default=yes@:>@]),
165               [want_mpd="$enableval"], [want_mpd=yes])
166
167 AM_CONDITIONAL(BUILD_MPD, test x$want_mpd = xyes)
168 if test x$want_mpd = xyes; then
169   AC_DEFINE(MPD, 1, [Define if you want MPD support])
170 fi
171
172 dnl
173 dnl XMMS2
174 dnl
175
176 AC_ARG_ENABLE([xmms2],
177               AC_HELP_STRING([--enable-xmms2], [enable if you want XMMS2 support @<:@default=no@:>@]),
178               [want_xmms2="$enableval"], [want_xmms2=no])
179
180 AM_CONDITIONAL(BUILD_XMMS2, test x$want_xmms2 = xyes)
181 if test x$want_xmms2 = xyes; then
182   PKG_CHECK_MODULES([XMMS2], [xmms2-client])
183     CFLAGS="$CFLAGS $XMMS2_CFLAGS"
184     LIBS="$LIBS $XMMS2_LIBS"
185     AC_DEFINE(XMMS2, 1, [Define if you want XMMS2 support])
186 fi
187
188 dnl
189 dnl RSS
190 dnl
191
192 AC_ARG_ENABLE([rss],
193               AC_HELP_STRING([--enable-rss], [enable if you want rss support @<:@default=no@:>@]),
194               [want_rss="$enableval"], [want_rss=no])
195 #
196 AM_CONDITIONAL(BUILD_RSS, test x$want_rss = xyes)
197 if test x$want_rss = xyes; then
198         WANT_GLIB=yes
199         PKG_CHECK_MODULES(RSS, libxml-2.0 libcurl,,exit)
200         CFLAGS="$CFLAGS $RSS_CFLAGS"
201         LIBS="$LIBS $RSS_LIBS"
202         AC_DEFINE(RSS, 1, [Define if you want rss support])
203 fi
204
205 dnl
206 dnl Wireless extensions
207 dnl
208
209 AC_ARG_ENABLE([wlan],
210               AC_HELP_STRING([--enable-wlan], [enable if you want wireless support @<:@default=no@:>@]),
211               [want_wlan="$enableval"], [want_wlan=no])
212 #
213 AM_CONDITIONAL(BUILD_WLAN, test x$want_wlan = xyes)
214 if test x$want_wlan = xyes; then
215   AC_CHECK_HEADERS([iwlib.h], [], AC_MSG_ERROR([iwlib.h header not found]))
216   AC_CHECK_LIB([iw], [iw_sockets_open], [LIBS="$LIBS -liw"], AC_MSG_ERROR([iw_sockets_open not found]))
217         AC_DEFINE(HAVE_IWLIB, 1, [Define if you want wireless support])
218 fi
219
220 dnl
221 dnl IMLIB2
222 dnl
223
224 dnl --commented out until brenden finishes it --
225 dnl AC_ARG_ENABLE([imlib2],
226 dnl    AC_HELP_STRING([--enable-imlib2], [enable if you want Imlib2 support [[default=no]]]),
227 dnl    [want_imlib2="$enableval"], [want_imlib2=no])
228 dnl
229 dnl AM_CONDITIONAL(BUILD_IMLIB2, test x$want_imlib2 = xyes)
230 dnl if test x$want_imlib2 = xyes; then
231 dnl PKG_CHECK_MODULES([Imlib2], [imlib2])
232 dnl CFLAGS="$CFLAGS $Imlib2_CFLAGS"
233 dnl LIBS="$LIBS $Imlib2_LIBS"
234 dnl AC_DEFINE(IMLIB2, 1, [Define if you want Imlib2 support])
235 dnl fi
236
237
238 dnl
239 dnl PORT_MONITORS
240 dnl
241
242 AC_ARG_ENABLE([portmon],
243               AC_HELP_STRING([--disable-portmon], 
244                              [disable if you do not want tcp (ip4) port monitoring @<:@default=yes@:>@]),
245               [want_portmon="$enableval"], [want_portmon=yes])
246
247 if test x"$want_portmon" = xyes; then
248   if test x"$uname" != xLinux; then
249       AC_MSG_NOTICE([port monitors not supported on $uname... disabling])
250       want_portmon=no
251   else
252         AC_CHECK_HEADERS([netdb.h netinet/in.h netinet/tcp.h sys/socket.h arpa/inet.h], [], 
253            [PORT_MONITORS_MISSING=yes])
254         if test x"$PORT_MONITORS_MISSING" = xyes; then
255               AC_MSG_ERROR([missing a needed network header for port monitoring])
256         fi
257         WANT_GLIB=yes
258         AC_DEFINE(TCP_PORT_MONITOR, 1, [Define if you want tcp port monitoring support])
259   fi
260 fi
261 AM_CONDITIONAL(BUILD_PORT_MONITORS, test x"$want_portmon" = xyes)
262
263
264 dnl
265 dnl ICONV
266 dnl
267
268 AM_ICONV
269 if test "$am_cv_func_iconv" != yes; then
270   AC_MSG_WARN([Could not find libiconv])
271 else
272   LIBS="$LIBS $LIBICONV"
273 fi
274
275 dnl
276 dnl debug
277 dnl
278
279 AC_ARG_ENABLE([debug], 
280               AC_HELP_STRING([--enable-debug], [compile with debug symbols @<:@default=no@:>@]),
281               [want_debug="$enableval"], [want_debug=no])
282
283 if test "x$want_debug" = "xyes" -a $ac_cv_c_compiler_gnu != no; then
284   CFLAGS="$CFLAGS -g3"
285   AC_DEFINE([DEBUG], [], [Define for debugging])
286 fi
287
288 dnl
289 dnl X11
290 dnl
291
292 AC_ARG_ENABLE([x11],
293               AC_HELP_STRING([--disable-x11], [disable if you do not want X11 support @<:@default=yes@:>@]),
294               [want_x11="$enableval"], [want_x11=yes])
295
296 AM_CONDITIONAL(BUILD_X11, test x$want_x11 = xyes)
297 if test "x$want_x11" = "xyes"; then
298     if $PKG_CONFIG --exists x11; then
299       PKG_CHECK_MODULES([X11], [x11])
300       CFLAGS="$CFLAGS $X11_CFLAGS"
301       LIBS="$LIBS $X11_LIBS"
302     else
303       dnl non-modular X11 installations
304       AC_PATH_X
305       AC_PATH_XTRA
306       CFLAGS="$CFLAGS $X_CFLAGS"
307       LIBS="$LIBS $X_LIBS"
308       LDFLAGS="$LDFLAGS $LIBS $X_PRE_LIBS"
309       if test "x$no_x" = "xyes"; then
310         AC_MSG_ERROR([Can't locate your X11 installation])
311       fi
312       AC_CHECK_LIB([X11], [XOpenDisplay], [], AC_MSG_ERROR([Could not find XOpenDisplay in -lX11]))
313     fi
314     AC_DEFINE(X11, 1, [Define if you want to use X11])
315 fi
316   
317
318 dnl
319 dnl Xext Double-buffering Extension
320 dnl
321
322 AC_ARG_ENABLE([double_buffer],
323               AC_HELP_STRING([--disable-double-buffer], 
324                              [disable for no Xdbe double-buffering support @<:@default=yes@:>@]),
325               [want_double_buffer="$enableval"], [want_double_buffer=yes])
326
327 if test "x$want_double_buffer" = "xyes"; then
328     if test "x$want_x11" != "xyes"; then
329       dnl silently disable if no x11
330       want_double_buffer=no
331     else 
332       if $PKG_CONFIG --exists xext; then
333         PKG_CHECK_MODULES([XEXT],[xext])
334         CFLAGS="$CFLAGS $XEXT_CFLAGS"
335         LIBS="$LIBS $XEXT_LIBS"
336       else
337         dnl non-modular X11 installation
338         AC_CHECK_LIB([Xext], [XdbeQueryExtension], [LIBS="$LIBS -lXext"], 
339                     AC_MSG_ERROR([Could not find XdbeQueryExtension in -lXext]))
340       fi
341       AC_DEFINE(HAVE_XDBE, 1, [Define for X11 double-buffering])
342     fi
343 fi
344
345
346 dnl
347 dnl Xdamage Extension
348 dnl
349
350 AC_ARG_ENABLE([xdamage],
351               AC_HELP_STRING([--disable-xdamage], 
352                              [disable if you do not want Xdamage support @<:@default=yes@:>@]),
353               [want_xdamage="$enableval"], [want_xdamage=yes])
354
355 if test "x$want_xdamage" = "xyes"; then
356     if test "x$want_x11" != "xyes"; then
357       dnl silently disable if no x11
358       want_xdamage=no
359     else 
360       if $PKG_CONFIG --exists xdamage; then
361         PKG_CHECK_MODULES([XDAMAGE],[xdamage])
362         CFLAGS="$CFLAGS $XDAMAGE_CFLAGS"
363         LIBS="$LIBS $XDAMAGE_LIBS"
364       else
365         dnl non-modular X11 installation
366         AC_CHECK_LIB([Xdamage], [XDamageQueryExtension], [LIBS="$LIBS -lXdamage"],
367                      AC_MSG_ERROR([Could not find XDamageQueryExtension in -lXdamage]))
368       fi
369       AC_DEFINE(HAVE_XDAMAGE, 1, [Define for X11 Xdamage extension])
370     fi
371 fi
372
373
374 dnl
375 dnl Xft
376 dnl
377
378 AC_ARG_ENABLE([xft],
379               AC_HELP_STRING([--disable-xft], [disable if you do not want to use Xft @<:@default=yes@:>@]),
380               [want_xft="$enableval"], [want_xft=yes])
381
382 if test x$want_xft = "xyes"; then
383     if test "x$want_x11" != "xyes"; then
384       dnl silently disable if no x11
385       want_xft=no
386     else 
387       PKG_CHECK_MODULES(XFT, [xft])
388       CFLAGS="$CFLAGS $XFT_CFLAGS"
389       LIBS="$LIBS $XFT_LIBS"
390       AC_DEFINE(XFT, 1, [Define for Xft support])
391     fi
392 fi
393
394 dnl
395 dnl GLIB
396 dnl
397
398 if test x$WANT_GLIB = xyes; then
399         PKG_CHECK_MODULES([GLIB], [glib-2.0])
400         CFLAGS="$CFLAGS $GLIB_CFLAGS"
401         LIBS="$LIBS $GLIB_LIBS"
402 fi
403
404 dnl
405 dnl KVM
406 dnl
407
408 if test x$WANT_KVM = xyes; then
409   AC_CHECK_LIB(kvm, kvm_open,
410     LIBS="$LIBS -lkvm",
411   AC_MSG_ERROR([Could not find kvm_open in -lkvm.])
412   )
413 fi
414
415 dnl
416 dnl devstat
417 dnl
418
419 if test x$WANT_DEVSTAT = xyes; then
420   AC_CHECK_LIB(devstat, devstat_getversion,
421          LIBS="$LIBS -ldevstat",
422          AC_MSG_ERROR([Cound not find devstat_getversion in -ldevstat.])
423   )
424 fi
425
426 dnl
427 dnl OSSLIB for NetBSD/OpenBSD
428 dnl
429
430 if test x$WANT_OSSLIB = xyes; then
431     AC_CHECK_LIB(ossaudio, _oss_ioctl,
432   LIBS="$LIBS -lossaudio",
433   AC_MSG_ERROR([Could not find oss_ioctl in -lossaudio.])
434     )
435 fi
436
437 dnl
438 dnl Some headers
439 dnl
440
441 AC_CHECK_HEADERS([signal.h unistd.h sys/utsname.h sys/stat.h linux/soundcard.h dirent.h mcheck.h \
442       sys/statfs.h sys/param.h pthread.h assert.h errno.h time.h])
443 AC_CHECK_HEADERS([sys/mount.h], [], [],
444      [#ifdef HAVE_SYS_PARAM_H
445       #include <sys/param.h>
446       #endif
447       ])
448
449 AC_DEFINE([_GNU_SOURCE], [], [Define for GNU source and extensions])
450
451 dnl
452 dnl Some functions
453 dnl
454
455 AC_CHECK_FUNCS([calloc malloc free popen sysinfo getloadavg memrchr])
456 AC_SEARCH_LIBS(clock_gettime, [rt], 
457                [AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])],
458                [AC_CHECK_FUNCS([gettimeofday], [], [AC_MSG_ERROR([gettimeofday() not available!])])], [])
459
460
461 dnl
462 dnl Check for zlib
463 dnl
464
465 AC_CHECK_HEADER(zlib.h,
466                 [],
467                 [AC_MSG_ERROR([zlib is missing; please install the headers first])])
468
469
470 dnl
471 dnl Check doc stuff
472 dnl
473
474 AC_CHECK_PROGS(db2x_xsltproc_cmd, db2x_xsltproc)
475 AC_CHECK_PROGS(db2x_manxml_cmd, db2x_manxml)
476 AC_CHECK_PROGS(xsltproc_cmd, xsltproc)
477 if test x$db2x_xsltproc_cmd = "x" -o x$xsltproc_cmd = "x"; then
478   AM_CONDITIONAL(HAVE_DOCSTUFF, false)
479 else
480   AM_CONDITIONAL(HAVE_DOCSTUFF, true)
481 fi
482
483
484 dnl
485 dnl kstat in Solaris
486 dnl
487
488 if test x$WANT_KSTAT = xyes; then
489   dah=no
490   AC_CHECK_LIB([kstat], [kstat_open], [dah=yes], [])
491
492   if test x$dah = xyes; then
493     AC_DEFINE(HAVE_KSTAT, 1, [Define if you have kstat (Solaris)])
494     LDFLAGS="$LDFLAGS -lkstat"
495   fi
496 fi
497
498 AC_DEFUN([AM_LANGINFO_CODESET],
499 [
500   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
501     [AC_TRY_LINK([#include <langinfo.h>],
502       [char* cs = nl_langinfo(CODESET);],
503       am_cv_langinfo_codeset=yes,
504       am_cv_langinfo_codeset=no)
505     ])
506   if test $am_cv_langinfo_codeset = yes; then
507     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
508       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
509   fi
510 ])
511
512
513 dnl ************************
514 dnl * Linker optimizations *
515 dnl ************************
516 AC_MSG_CHECKING([if $LD accepts -O1])
517 case `$LD -O1 -v 2>&1 </dev/null` in
518 *GNU* | *BSD*)
519   LDFLAGS="$LDFLAGS -Wl,-O1"
520   AC_MSG_RESULT([yes])
521   ;;
522 *)
523   AC_MSG_RESULT([no])
524   ;;
525 esac
526
527
528 dnl
529 dnl Da.
530 dnl
531
532 CFLAGS="$CFLAGS -Wall -W"
533
534 AC_SUBST(CFLAGS)
535 AC_SUBST(X11_LIBS)
536
537 AC_OUTPUT
538
539 dnl
540 dnl Print summary
541 dnl
542 cat << EOF
543
544 $PACKAGE $VERSION configured successfully:
545
546  Installing into:   $prefix
547  System config dir: $sysconfdir
548  C compiler flags:  $CFLAGS
549  Linker flags:      $LDFLAGS
550  Libraries:         $LIBS
551
552  * x11:
553   x11 support:      $want_x11
554   xdamage support:  $want_xdamage
555   xdbe support:     $want_double_buffer
556   xft support:      $want_xft
557
558  * music detection:
559   audacious:        $want_audacious
560   bmpx:             $want_bmpx
561   mpd:              $want_mpd
562   xmms2:            $want_xmms2
563
564  * general:
565   hddtemp:          $want_hddtemp
566   portmon:          $want_portmon  
567   rss:              $want_rss
568   wireless:         $want_wlan
569 EOF