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