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