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