Conky 1.4.4 Really Final
[monky] / configure.ac
1 AC_INIT([Conky],[1.4.4],[brenden1@users.sourceforge.net])
2
3 AM_INIT_AUTOMAKE(conky, 1.4.4)
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
71 dnl
72 dnl OWN_WINDOW option
73 dnl
74
75 AC_ARG_ENABLE([own_window],
76     AC_HELP_STRING([--enable-own-window], [enable if you want support for creating own window [[default=yes]]]),
77     [dah="$enableval"], [dah=yes])
78
79 if test $dah != "no"; then
80   AC_DEFINE(OWN_WINDOW, 1, [Define if you want support for window creating])
81 fi
82
83 dnl
84 dnl PROC_UPTIME option
85 dnl
86
87 AC_ARG_ENABLE([proc_uptime],
88     AC_HELP_STRING([--enable-proc-uptime], [enable using /proc/uptime for uptime [[default=yes]]]),
89     [dah="$enableval"], [dah=yes])
90
91 if test $dah = "yes"; then
92   AC_DEFINE(PROC_UPTIME, 1, [Define if you want to use /proc/uptime for uptime])
93 fi
94
95
96 dnl
97 dnl Audacious Media Player
98 dnl
99
100 AC_ARG_ENABLE([audacious],
101     AC_HELP_STRING([--enable-audacious], [enable audacious player support [[default=no]]]),
102     [want_audacious="$enableval"], [want_audacious=no])
103
104 AM_CONDITIONAL(BUILD_AUDACIOUS, test x$want_audacious = xyes)
105 if test x$want_audacious = xyes; then
106         PKG_CHECK_MODULES([AUDACIOUS], [audacious >= 0.1])
107         CFLAGS="$CFLAGS $AUDACIOUS_CFLAGS"
108         LIBS="$LIBS $AUDACIOUS_LIBS"
109         AC_DEFINE(AUDACIOUS, 1, [Define for Audacious support])
110 fi
111
112
113 dnl
114 dnl BMPx
115 dnl
116
117 AC_ARG_ENABLE([bmpx],
118     AC_HELP_STRING([--enable-bmpx], [enable if you want BMPx support [[default=no]]]),
119     [want_bmpx="$enableval"], [want_bmpx=no])
120
121 AM_CONDITIONAL(BUILD_BMPX, test x$want_bmpx = xyes)
122 if test x$want_bmpx = xyes; then
123         PKG_CHECK_MODULES([BMPX], [bmp-2.0 >= 0.14.0])
124         CFLAGS="$CFLAGS $BMPX_CFLAGS"
125         LIBS="$LIBS $BMPX_LIBS"
126         AC_DEFINE(BMPX, 1, [Define if you want BMPx support])
127 fi
128
129
130 dnl
131 dnl Hddtemp
132 dnl
133
134 AC_ARG_ENABLE([hddtemp],
135     AC_HELP_STRING([--enable-hddtemp], [enable if you want hddtemp support [[default=yes]]]),
136     [want_hddtemp="$enableval"], [want_hddtemp=yes])
137
138 AM_CONDITIONAL(BUILD_HDDTEMP, test x$want_hddtemp = xyes)
139 if test x$want_hddtemp = xyes; then
140   AC_DEFINE(HDDTEMP, 1, [Define if you want hddtemp support])
141 fi
142
143 dnl
144 dnl MPD
145 dnl
146
147 AC_ARG_ENABLE([mpd],
148     AC_HELP_STRING([--enable-mpd], [enable if you want MPD support [[default=yes]]]),
149     [want_mpd="$enableval"], [want_mpd=yes])
150
151 AM_CONDITIONAL(BUILD_MPD, test x$want_mpd = xyes)
152 if test x$want_mpd = xyes; then
153   AC_DEFINE(MPD, 1, [Define if you want MPD support])
154 fi
155
156 dnl
157 dnl XMMS2
158 dnl
159
160 AC_ARG_ENABLE([xmms2],
161     AC_HELP_STRING([--enable-xmms2], [enable if you want XMMS2 support [[default=no]]]),
162     [want_xmms2="$enableval"], [want_xmms2=no])
163
164 AM_CONDITIONAL(BUILD_XMMS2, test x$want_xmms2 = xyes)
165 if test x$want_xmms2 = xyes; then
166         PKG_CHECK_MODULES([XMMS2], [xmms2-client])
167         CFLAGS="$CFLAGS $XMMS2_CFLAGS"
168         LIBS="$LIBS $XMMS2_LIBS"
169         AC_DEFINE(XMMS2, 1, [Define if you want XMMS2 support])
170 fi
171
172
173 dnl
174 dnl IMLIB2
175 dnl
176
177 dnl --commented out until brenden finishes it --
178 dnl AC_ARG_ENABLE([imlib2],
179 dnl    AC_HELP_STRING([--enable-imlib2], [enable if you want Imlib2 support [[default=no]]]),
180 dnl    [want_imlib2="$enableval"], [want_imlib2=no])
181 dnl
182 dnl AM_CONDITIONAL(BUILD_IMLIB2, test x$want_imlib2 = xyes)
183 dnl if test x$want_imlib2 = xyes; then
184 dnl     PKG_CHECK_MODULES([Imlib2], [imlib2])
185 dnl     CFLAGS="$CFLAGS $Imlib2_CFLAGS"
186 dnl     LIBS="$LIBS $Imlib2_LIBS"
187 dnl     AC_DEFINE(IMLIB2, 1, [Define if you want Imlib2 support])
188 dnl fi
189
190 dnl
191 dnl PORT_MONITORS
192 dnl
193
194 AC_ARG_ENABLE([portmon],
195     AC_HELP_STRING([--enable-portmon], [enable if you want tcp (ip4) port monitoring [[default=yes]]]),
196     [want_portmon="$enableval"], [want_portmon=yes])
197
198 AM_CONDITIONAL(BUILD_PORT_MONITORS, test x$want_portmon = xyes)
199 if test x$want_portmon = xyes; then
200         AC_CHECK_HEADERS([netdb.h netinet/in.h netinet/tcp.h sys/socket.h arpa/inet.h], [], 
201                          [PORT_MONITORS_MISSING=yes])
202         if test "x$PORT_MONITORS_MISSING" = xyes; then
203             AC_MSG_ERROR([missing a needed network header for port monitoring])
204         fi
205         AC_DEFINE(TCP_PORT_MONITOR, 1, [Define if you want tcp port monitoring support])
206 fi
207
208
209 dnl
210 dnl ICONV
211 dnl
212
213 AM_ICONV
214 if test "$am_cv_func_iconv" != yes; then
215         AC_MSG_WARN([Could not find libiconv])
216 else
217         LIBS="$LIBS $LIBICONV"
218 fi
219
220 dnl
221 dnl debug
222 dnl
223
224 AC_ARG_ENABLE([debug], 
225     AC_HELP_STRING([--enable-debug], [compile with debug symbols [[default=no]]]),
226     [want_debug="$enableval"], [want_debug=no])
227
228 if test "x$want_debug" = "xyes" -a $ac_cv_c_compiler_gnu != no; then
229         CFLAGS="$CFLAGS -g3"
230 fi
231
232 dnl
233 dnl X11
234 dnl
235
236 AC_ARG_ENABLE([x11],
237     AC_HELP_STRING([--enable-x11], [enable if you want X11 support [[default=yes]]]),
238     [want_x11="$enableval"], [want_x11=yes])
239
240 AM_CONDITIONAL(BUILD_X11, test x$want_x11 = xyes)
241 if test "x$want_x11" = "xyes"; then
242     if $PKG_CONFIG --exists x11; then
243         PKG_CHECK_MODULES([X11], [x11])
244         CFLAGS="$CFLAGS $X11_CFLAGS"
245         LIBS="$LIBS $X11_LIBS"
246     else
247         dnl non-modular X11 installations
248         AC_PATH_X
249         AC_PATH_XTRA
250         CFLAGS="$CFLAGS $X_CFLAGS"
251         LIBS="$LIBS $X_LIBS"
252         LDFLAGS="$LDFLAGS $LIBS $X_PRE_LIBS"
253         if test "x$no_x" = "xyes"; then
254             AC_MSG_ERROR([Can't locate your X11 installation])
255         fi
256         AC_CHECK_LIB([X11], [XOpenDisplay], [], AC_MSG_ERROR([Could not find XOpenDisplay in -lX11]))
257     fi
258     AC_DEFINE(X11, 1, [Define if you want to use X11])
259 fi
260         
261
262 dnl
263 dnl Xext Double-buffering Extension
264 dnl
265
266 AC_ARG_ENABLE([double_buffer],
267     AC_HELP_STRING([--enable-double-buffer], [enable for flicker-free operation [[default=yes]]]),
268     [want_double_buffer="$enableval"], [want_double_buffer=yes])
269
270 if test "x$want_double_buffer" = "xyes"; then
271     if test "x$want_x11" != "xyes"; then
272             AC_MSG_ERROR([--enable-x11 is required for double-buffering])
273     fi
274     if $PKG_CONFIG --exists xext; then
275         PKG_CHECK_MODULES([XEXT],[xext])
276         CFLAGS="$CFLAGS $XEXT_CFLAGS"
277         LIBS="$LIBS $XEXT_LIBS"
278     else
279         dnl non-modular X11 installation
280         AC_CHECK_LIB([Xext], [XdbeQueryExtension], [LIBS="$LIBS -lXext"], 
281                      AC_MSG_ERROR([Could not find XdbeQueryExtension in -lXext]))
282     fi
283     AC_DEFINE(HAVE_XDBE, 1, [Define for X11 double-buffering])
284 fi
285
286
287 dnl
288 dnl Xdamage Extension
289 dnl
290
291 AC_ARG_ENABLE([xdamage],
292     AC_HELP_STRING([--enable-xdamage], [enable if you want Xdamage support [[default=yes]]]),
293     [want_xdamage="$enableval"], [want_xdamage=yes])
294
295 if test "x$want_xdamage" = "xyes"; then
296     if test "x$want_x11" != "xyes"; then
297             AC_MSG_ERROR([--enable-x11 is required for xdamage])
298     fi
299     if $PKG_CONFIG --exists xdamage; then
300         PKG_CHECK_MODULES([XDAMAGE],[xdamage])
301         CFLAGS="$CFLAGS $XDAMAGE_CFLAGS"
302         LIBS="$LIBS $XDAMAGE_LIBS"
303     else
304         dnl non-modular X11 installation
305         AC_CHECK_LIB([Xdamage], [XDamageQueryExtension], [LIBS="$LIBS -lXdamage"],
306                      AC_MSG_ERROR([Could not find XDamageQueryExtension in -lXdamage]))
307     fi
308     AC_DEFINE(HAVE_XDAMAGE, 1, [Define for X11 Xdamage extension])
309 fi
310
311
312 dnl
313 dnl Xft
314 dnl
315
316 AC_ARG_ENABLE([xft],
317     AC_HELP_STRING([--enable-xft], [enable if you want to use Xft [[default=yes]]]),
318     [want_xft="$enableval"], [want_xft=yes])
319
320 if test x$want_xft = "xyes"; then
321     if test "x$want_x11" != "xyes"; then
322             AC_MSG_ERROR([--enable-x11 is required for xft])
323     fi
324     PKG_CHECK_MODULES(XFT, [xft])
325     CFLAGS="$CFLAGS $XFT_CFLAGS"
326     LIBS="$LIBS $XFT_LIBS"
327     AC_DEFINE(XFT, 1, [Define for Xft support])
328 fi
329
330
331 dnl
332 dnl KVM
333 dnl
334
335 if test x$WANT_KVM = xyes; then
336   AC_CHECK_LIB(kvm, kvm_open,
337         LIBS="$LIBS -lkvm",
338         AC_MSG_ERROR([Could not find kvm_open in -lkvm.])
339   )
340 fi
341
342 dnl
343 dnl devstat
344 dnl
345
346 if test x$WANT_DEVSTAT = xyes; then
347         AC_CHECK_LIB(devstat, devstat_getversion,
348                      LIBS="$LIBS -ldevstat",
349                      AC_MSG_ERROR([Cound not find devstat_getversion in -ldevstat.])
350         )
351 fi
352
353 dnl
354 dnl OSSLIB for NetBSD/OpenBSD
355 dnl
356
357 if test x$WANT_OSSLIB = xyes; then
358     AC_CHECK_LIB(ossaudio, _oss_ioctl,
359         LIBS="$LIBS -lossaudio",
360         AC_MSG_ERROR([Could not find oss_ioctl in -lossaudio.])
361     )
362 fi
363
364 dnl
365 dnl Some random headers
366 dnl
367
368
369 AC_CHECK_HEADERS([signal.h unistd.h sys/utsname.h sys/stat.h linux/soundcard.h dirent.h mcheck.h])
370 AC_CHECK_HEADERS([sys/statfs.h sys/param.h])
371 AC_CHECK_HEADERS([sys/mount.h], [], [],
372                  [#ifdef HAVE_SYS_PARAM_H
373                   #include <sys/param.h>
374                   #endif
375 ])
376
377 dnl
378 dnl Check doc stuff
379 dnl
380
381 AC_CHECK_PROGS(db2x_xsltproc_cmd, db2x_xsltproc)
382 AC_CHECK_PROGS(db2x_manxml_cmd, db2x_manxml)
383 AC_CHECK_PROGS(xsltproc_cmd, xsltproc)
384 if test x$db2x_xsltproc_cmd = "x" -o x$xsltproc_cmd = "x"; then
385         AM_CONDITIONAL(HAVE_DOCSTUFF, false)
386 else
387         AM_CONDITIONAL(HAVE_DOCSTUFF, true)
388 fi
389
390 dnl
391 dnl Check sysinfo()
392 dnl
393
394 if test x$WANT_SYSINFO = xyes; then
395   dah=no
396   AC_MSG_CHECKING(for sysinfo)
397   AC_TRY_COMPILE(
398     [#include <sys/types.h>
399      #include <sys/sysinfo.h>],
400     [struct sysinfo s; sysinfo(&s); (void) s.uptime; ],
401     [AC_MSG_RESULT(yes); dah=yes],
402     [AC_MSG_RESULT(not usable); dah=no])
403
404   if test x$dah = xyes; then
405     AC_DEFINE(HAVE_SYSINFO, 1, [Define if you have sysinfo (Linux)])
406   fi
407 fi
408
409 dnl
410 dnl kstat in Solaris
411 dnl
412
413 if test x$WANT_KSTAT = xyes; then
414   dah=no
415   AC_CHECK_LIB([kstat], [kstat_open], [dah=yes], [])
416
417   if test x$dah = xyes; then
418     AC_DEFINE(HAVE_KSTAT, 1, [Define if you have kstat (Solaris)])
419     LDFLAGS="$LDFLAGS -lkstat"
420   fi
421 fi
422
423 AC_DEFUN([AM_LANGINFO_CODESET],
424 [
425   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
426     [AC_TRY_LINK([#include <langinfo.h>],
427       [char* cs = nl_langinfo(CODESET);],
428       am_cv_langinfo_codeset=yes,
429       am_cv_langinfo_codeset=no)
430     ])
431   if test $am_cv_langinfo_codeset = yes; then
432     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
433       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
434   fi
435 ])
436
437 dnl
438 dnl Check getloadavg
439 dnl
440
441 AC_MSG_CHECKING(for getloadavg)
442 AC_TRY_COMPILE(
443   [#include <stdlib.h>],
444   [double v[3]; getloadavg(v, 3);],
445   [AC_MSG_RESULT(yes)
446    AC_DEFINE(HAVE_GETLOADAVG, 1, [Define if you have getloadavg])],
447   [AC_MSG_RESULT(no)])
448
449 dnl
450 dnl Check popen
451 dnl
452
453 AC_CHECK_FUNCS(popen)
454
455 dnl
456 dnl Da.
457 dnl
458
459 CFLAGS="$CFLAGS -Wall -W"
460
461 AC_SUBST(CFLAGS)
462 AC_SUBST(X11_LIBS)
463
464 AC_OUTPUT
465
466 dnl
467 dnl Print summary
468 dnl
469 cat << EOF
470
471 $PACKAGE $VERSION configured successfully:
472
473  Installing into:       $prefix
474  C compiler flags:      $CFLAGS
475  Linker flags:          $LDFLAGS
476  Libraries:             $LIBS
477
478  * x11:
479   x11 support:          $want_x11
480   xdamage support:      $want_xdamage
481   xdbe support:         $want_double_buffer
482   xft support:          $want_xft
483
484  * music detection:
485   audacious:            $want_audacious
486   bmpx:                 $want_bmpx
487   mpd:                  $want_mpd
488   xmms2:                $want_xmms2
489
490  * general:
491   hddtemp:              $want_hddtemp
492   portmon:              $want_portmon  
493
494 EOF