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