744a5051e8716d6ef42b0ce98f6c355414b92e3f
[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
155 dnl
156 dnl Hddtemp
157 dnl
158
159 AC_ARG_ENABLE([hddtemp],
160     AC_HELP_STRING([--enable-hddtemp], [enable if you want hddtemp support [[default=yes]]]),
161     [want_hddtemp="$enableval"], [want_hddtemp=yes])
162
163 AM_CONDITIONAL(BUILD_HDDTEMP, test x$want_hddtemp = xyes)
164 if test x$want_hddtemp = xyes; then
165   AC_DEFINE(HDDTEMP, 1, [Define if you want hddtemp support])
166 fi
167
168 dnl
169 dnl MPD
170 dnl
171
172 AC_ARG_ENABLE([mpd],
173     AC_HELP_STRING([--enable-mpd], [enable if you want MPD support [[default=yes]]]),
174     [want_mpd="$enableval"], [want_mpd=yes])
175
176 AM_CONDITIONAL(BUILD_MPD, test x$want_mpd = xyes)
177 if test x$want_mpd = xyes; then
178   AC_DEFINE(MPD, 1, [Define if you want MPD support])
179 fi
180
181 dnl
182 dnl XMMS2
183 dnl
184
185 AC_ARG_ENABLE([xmms2],
186     AC_HELP_STRING([--enable-xmms2], [enable if you want XMMS2 support [[default=no]]]),
187     [want_xmms2="$enableval"], [want_xmms2=no])
188
189 AM_CONDITIONAL(BUILD_XMMS2, test x$want_xmms2 = xyes)
190 if test x$want_xmms2 = xyes; then
191   CFLAGS="$CFLAGS `pkg-config --cflags xmms2-client`"
192   LIBS="$LIBS `pkg-config --libs xmms2-client`"
193   AC_DEFINE(XMMS2, 1, [Define if you want XMMS2 support])
194 fi
195
196 dnl
197 dnl IMLIB2
198 dnl
199
200 AC_ARG_ENABLE([imlib2],
201     AC_HELP_STRING([--enable-imlib2], [enable if you want Imlib2 support [[default=no]]]),
202     [want_imlib2="$enableval"], [want_imlib2=no])
203
204 AM_CONDITIONAL(BUILD_IMLIB2, test x$want_imlib2 = xyes)
205 if test x$want_imlib2 = xyes; then
206         PKG_CHECK_MODULES([Imlib2], [imlib2])
207         CFLAGS="$CFLAGS $Imlib2_CFLAGS"
208         LIBS="$LIBS $Imlib2_LIBS"
209         AC_DEFINE(IMLIB2, 1, [Define if you want Imlib2 support])
210 fi
211
212 dnl
213 dnl PORT_MONITORS
214 dnl
215
216 AC_ARG_ENABLE([portmon],
217     AC_HELP_STRING([--enable-portmon], [enable if you want tcp (ip4) port monitoring [[default=yes]]]),
218     [want_portmon="$enableval"], [want_portmon=yes])
219
220 AM_CONDITIONAL(BUILD_PORT_MONITORS, test x$want_portmon = xyes)
221 if test x$want_portmon = xyes; then
222   AC_CHECK_HEADERS([netdb.h netinet/in.h netinet/tcp.h sys/socket.h arpa/inet.h], [], [PORT_MONITORS_MISSING=yes])
223   if test "x$PORT_MONITORS_MISSING" = xyes; then
224          AC_MSG_ERROR([missing a needed network header for port monitoring])
225   fi
226   AC_DEFINE(TCP_PORT_MONITOR, 1, [Define if you want tcp port monitoring support])
227 fi
228
229 dnl
230 dnl Cairo
231 dnl
232
233
234 dnl
235 dnl ICONV
236 dnl
237
238 AM_ICONV
239 if test "$am_cv_func_iconv" != yes; then
240         AC_MSG_WARN([Could not find libiconv])
241 else
242         LIBS="$LIBS $LIBICONV"
243 fi
244
245 dnl
246 dnl debug
247 dnl
248
249 AC_ARG_ENABLE([debug], 
250     AC_HELP_STRING([--enable-debug], [compile with debug symbols [[default=no]]]),
251     [want_debug="$enableval"], [want_debug=no])
252
253 if test "x$want_debug" = "xyes" -a $ac_cv_c_compiler_gnu != no; then
254         CFLAGS="$CFLAGS -g3"
255 fi
256
257 dnl
258 dnl X
259 dnl
260
261 AC_ARG_ENABLE([double_buffer],
262     AC_HELP_STRING([--enable-double-buffer], [enable if you want to support flicker-free operation [[default=yes]]]),
263     [want_double_buffer="$enableval"], [want_double_buffer=yes])
264
265 AC_ARG_ENABLE([xdamage],
266     AC_HELP_STRING([--enable-xdamage], [enable if you want Xdamage support [[default=yes]]]),
267     [want_xdamage="$enableval"], [want_xdamage=yes])
268
269 AC_ARG_ENABLE([x11],
270     AC_HELP_STRING([--enable-x11], [enable if you want X11 support [[default=yes]]]),
271     [want_x11="$enableval"], [want_x11=yes])
272
273
274 if test "x$want_x11" = "xyes"; then
275         AC_PATH_X
276         AC_PATH_XTRA
277         CFLAGS="$CFLAGS $X_CFLAGS"
278         LIBS="$LIBS $X_LIBS $X11_LIBS"
279         LDFLAGS="$LDFLAGS $LIBS $X_PRE_LIBS"
280         
281         if test "x$no_x" = xyes; then
282                 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])
283         fi
284         
285         AC_CHECK_LIB(
286                 [X11], [XOpenDisplay],[], 
287                 AC_MSG_ERROR([Could not find XOpenDisplay in -lX11.])
288         )
289
290         AC_DEFINE(X11, 1, [Define if you want to use X11])
291         AC_DEFINE(HAVE_X11, 1, [Define if you have X11])
292         AM_CONDITIONAL(BUILD_X11, true)
293         
294         if test "x$want_double_buffer" != xno; then
295                 AC_DEFINE(DOUBLE_BUFFER, 1, [Define if you want support for the DBE extension])
296                 AC_CHECK_LIB(Xext, XdbeQueryExtension, [AC_DEFINE([HAVE_XDBE], 1, [Xdbe]) LIBS="$LIBS -lXext"],
297                      [AC_MSG_ERROR([something went wrong when checking for Xdbe (double buffer extension)])])
298         fi
299
300         if test "x$want_xdamage" = "xyes"; then
301                 AC_DEFINE(XDAMAGE, 1, [Define if you want support for the Xdamage extension])
302                 AC_CHECK_LIB(Xdamage, XDamageQueryExtension, 
303                              [AC_DEFINE([HAVE_XDAMAGE], 1, [Xdamage]) LIBS="$LIBS -lXdamage"],
304                               [AC_MSG_ERROR([something went wrong when checking for Xdamage])])
305         fi
306 else
307         AM_CONDITIONAL(BUILD_X11, false)
308 fi
309
310 dnl
311 dnl Xft
312 dnl
313
314 if test x$want_xft && test x$want_x11; then
315   PKG_CHECK_MODULES(XFT, [xft],
316                     [
317                      AC_DEFINE(XFT, 1, [Define if you are using Xft])
318                      CFLAGS="$CFLAGS $XFT_CFLAGS"
319                      AC_SUBST(XFT_LIBS)
320                     ], 
321                     [want_xft=no])
322 fi
323
324 dnl
325 dnl KVM
326 dnl
327
328 if test x$WANT_KVM = xyes; then
329   AC_CHECK_LIB(kvm, kvm_open,
330         LIBS="$LIBS -lkvm",
331         AC_MSG_ERROR([Could not find kvm_open in -lkvm.])
332   )
333 fi
334
335 dnl
336 dnl devstat
337 dnl
338
339 if test x$WANT_DEVSTAT = xyes; then
340         AC_CHECK_LIB(devstat, devstat_getversion,
341                      LIBS="$LIBS -ldevstat",
342                      AC_MSG_ERROR([Cound not find devstat_getversion in -ldevstat.])
343         )
344 fi
345
346 dnl
347 dnl OSSLIB for NetBSD/OpenBSD
348 dnl
349
350 if test x$WANT_OSSLIB = xyes; then
351     AC_CHECK_LIB(ossaudio, _oss_ioctl,
352         LIBS="$LIBS -lossaudio",
353         AC_MSG_ERROR([Could not find oss_ioctl in -lossaudio.])
354     )
355 fi
356
357 dnl
358 dnl Some random headers
359 dnl
360
361
362 AC_CHECK_HEADERS([signal.h unistd.h sys/utsname.h sys/stat.h linux/soundcard.h dirent.h mcheck.h])
363 AC_CHECK_HEADERS([sys/statfs.h sys/param.h])
364 AC_CHECK_HEADERS([sys/mount.h], [], [],
365                  [#ifdef HAVE_SYS_PARAM_H
366                   #include <sys/param.h>
367                   #endif
368 ])
369
370 dnl
371 dnl Check doc stuff
372 dnl
373
374 AC_CHECK_PROGS(db2x_xsltproc_cmd, db2x_xsltproc)
375 AC_CHECK_PROGS(db2x_manxml_cmd, db2x_manxml)
376 AC_CHECK_PROGS(xsltproc_cmd, xsltproc)
377 if test x$db2x_xsltproc_cmd = "x" -o x$xsltproc_cmd = "x"; then
378         AM_CONDITIONAL(HAVE_DOCSTUFF, false)
379 else
380         AM_CONDITIONAL(HAVE_DOCSTUFF, true)
381 fi
382
383 dnl
384 dnl Check sysinfo()
385 dnl
386
387 if test x$WANT_SYSINFO = xyes; then
388   dah=no
389   AC_MSG_CHECKING(for sysinfo)
390   AC_TRY_COMPILE(
391     [#include <sys/types.h>
392      #include <sys/sysinfo.h>],
393     [struct sysinfo s; sysinfo(&s); (void) s.uptime; ],
394     [AC_MSG_RESULT(yes); dah=yes],
395     [AC_MSG_RESULT(not usable); dah=no])
396
397   if test x$dah = xyes; then
398     AC_DEFINE(HAVE_SYSINFO, 1, [Define if you have sysinfo (Linux)])
399   fi
400 fi
401
402 dnl
403 dnl kstat in Solaris
404 dnl
405
406 if test x$WANT_KSTAT = xyes; then
407   dah=no
408   AC_CHECK_LIB([kstat], [kstat_open], [dah=yes], [])
409
410   if test x$dah = xyes; then
411     AC_DEFINE(HAVE_KSTAT, 1, [Define if you have kstat (Solaris)])
412     LDFLAGS="$LDFLAGS -lkstat"
413   fi
414 fi
415
416 AC_DEFUN([AM_LANGINFO_CODESET],
417 [
418   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
419     [AC_TRY_LINK([#include <langinfo.h>],
420       [char* cs = nl_langinfo(CODESET);],
421       am_cv_langinfo_codeset=yes,
422       am_cv_langinfo_codeset=no)
423     ])
424   if test $am_cv_langinfo_codeset = yes; then
425     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
426       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
427   fi
428 ])
429
430 dnl
431 dnl Check getloadavg
432 dnl
433
434 AC_MSG_CHECKING(for getloadavg)
435 AC_TRY_COMPILE(
436   [#include <stdlib.h>],
437   [double v[3]; getloadavg(v, 3);],
438   [AC_MSG_RESULT(yes)
439    AC_DEFINE(HAVE_GETLOADAVG, 1, [Define if you have getloadavg])],
440   [AC_MSG_RESULT(no)])
441
442 dnl
443 dnl Check popen
444 dnl
445
446 AC_CHECK_FUNCS(popen)
447
448 dnl
449 dnl Da.
450 dnl
451
452 CFLAGS="$CFLAGS -Wall -W"
453
454 AC_SUBST(CFLAGS)
455 AC_SUBST(X11_LIBS)
456
457 AC_OUTPUT
458
459 dnl
460 dnl Print summary
461 dnl
462 cat << EOF
463
464 $PACKAGE $VERSION configured successfully:
465
466  Installing into:       $prefix
467  C compiler flags:      $CFLAGS
468  Linker flags:          $LDFLAGS
469  Libraries:             $LIBS
470
471  * x11:
472   x11 support:          $want_x11
473   xft support:          $want_xft
474   xdamage extension:    $want_xdamage  
475
476  * music detection:
477   audacious:            $want_audacious
478   bmpx:                 $want_bmpx
479   mpd:                  $want_mpd
480   xmms2:                $want_xmms2
481
482  * general:
483   hddtemp:              $want_hddtemp
484   portmon:              $want_portmon  
485
486 EOF