new files
[monky] / configure.in
1 AC_INIT(conky.c)
2
3 AM_INIT_AUTOMAKE(conky, 1.3)
4 AM_CONFIG_HEADER(config.h)
5
6 uname=`uname`
7
8 case $uname in
9   Linux*)
10     WANT_SYSINFO=yes
11     ;;
12   FreeBSD*)
13     WANT_KVM=yes
14     ;;
15   NetBSD*)
16     WANT_KVM=yes
17     WANT_OSSLIB=yes
18     ;;
19 # Solaris doesn't work at all right now
20
21 #  SunOS*)
22 #    WANT_KSTAT=yes
23 #    ;;
24
25   *)
26     echo "Your operating system $uname isn't supported"
27     echo "Feel free to help. :P"
28     exit 1
29     ;;
30 esac
31
32 AM_CONDITIONAL(BUILD_LINUX, test x$uname = xLinux)
33 AM_CONDITIONAL(BUILD_SOLARIS, test x$uname = xSunOS)
34 AM_CONDITIONAL(BUILD_FREEBSD, test x$uname = xFreeBSD)
35 AM_CONDITIONAL(BUILD_NETBSD, test x$uname = xNetBSD)
36
37 dnl
38 dnl XFT option
39 dnl
40
41 want_xft=no
42 AC_ARG_ENABLE(xft,
43 [  --enable-xft            enable if you want to use Xft [default=no]],
44   [want_xft="$enableval"])
45
46 dnl
47 dnl OWN_WINDOW option
48 dnl
49
50 dah=yes
51 AC_ARG_ENABLE(own_window,
52 [  --enable-own-window     enable if you want support for creating own window [default=yes]],
53   [dah="$enableval"])
54
55 if test $dah != "no"; then
56   AC_DEFINE(OWN_WINDOW, 1, [Define if you want support for window creating])
57 fi
58
59 dnl
60 dnl DOUBLE_BUFFER option
61 dnl
62
63 dah=yes
64 AC_ARG_ENABLE(double_buffer,
65 [  --enable-double-buffer  enable if you want to support flicker-free operation [default=yes]],
66   [dah="$enableval"])
67
68 if test $dah != "no"; then
69   AC_DEFINE(DOUBLE_BUFFER, 1, [Define if you want support for the DBE extension])
70   AC_CHECK_HEADERS([X11/extensions/Xdbe.h], [AC_DEFINE([HAVE_XDBE], 1, [Xdbe])], [XDBE_MISSING=yes])
71   if test "x$XDBE_MISSING" = xyes; then
72       AC_MSG_ERROR([something went wrong when checking for Xdbe (double buffer extension])
73   fi
74 fi
75
76 dnl
77 dnl PROC_UPTIME option
78 dnl
79
80 dah=no
81 AC_ARG_ENABLE(proc_uptime,
82 [  --enable-proc-uptime    enable using /proc/uptime for uptime [default=no]],
83   [dah="$enableval"])
84
85 if test $dah = "yes"; then
86   AC_DEFINE(PROC_UPTIME, 1, [Define if you want to use /proc/uptime for uptime])
87 fi
88
89 dnl
90 dnl Seti@Home
91 dnl
92
93 want_seti=no
94 AC_ARG_ENABLE(seti,
95 [  --enable-seti           enable if you want SETI at Home stats [default=no]],
96   [want_seti="$enableval"])
97
98 AM_CONDITIONAL(BUILD_SETI, test x$want_seti == xyes)
99 if test x$want_seti == xyes; then
100   AC_DEFINE(SETI, 1, [Define if you want SETI at Home stats])
101 fi
102
103 dnl
104 dnl MPD
105 dnl
106
107 want_mpd=no
108 AC_ARG_ENABLE(mpd,
109 [  --enable-mpd           enable if you want MPD support [default=no]],
110   [want_mpd="$enableval"])
111
112 AM_CONDITIONAL(BUILD_MPD, test x$want_mpd == xyes)
113 if test x$want_mpd == xyes; then
114   AC_DEFINE(MPD, 1, [Define if you want MPD support])
115 fi
116
117 dnl
118 dnl Cairo
119 dnl
120
121 want_cairo=no
122 AC_ARG_ENABLE(cairo,
123 [  --enable-cairo           enable if you want Cairo support [default=no]],
124   [want_cairo="$enableval"])
125
126 AM_CONDITIONAL(BUILD_CAIRO, test x$want_cairo == xyes)
127
128
129 if test "$want_cairo" = "yes"; then
130   AC_CHECK_HEADERS([cairo.h cairo-xlib.h], [], [CAIRO_MISSING=yes])
131     if test "x$CAIRO_MISSING" = xyes; then
132       AC_MSG_ERROR([something went wrong when checking for cairo, you're probably missing headers or it's not installed])
133   fi
134   AC_PATH_PROG(CAIROCONFIG, pkg-config)
135   if test x$CAIROCONFIG != x; then
136     dnl TODO: needs more checks
137
138     AC_DEFINE(CAIRO, 1, [Define if you are using Cairo])
139     CFLAGS="$CFLAGS `$CAIROCONFIG --cflags cairo` `$CAIROCONFIG --libs cairo` "
140     CAIRO_LIBS="`$CAIROCONFIG --libs cairo` `$CAIROCONFIG --cflags cairo`"
141   else
142     want_cairo=no
143   fi
144 fi
145
146 dnl metar
147 dnl
148
149 want_metar=no
150 AC_ARG_ENABLE(metar,
151 [  --enable-metar       enable if you want metar stats (weather information) [default=no]],
152   [want_metar="$enableval"])
153
154 AM_CONDITIONAL(BUILD_METAR, test x$want_metar == xyes)
155 if test x$want_metar == xyes; then
156 AC_CHECK_HEADERS([metar.h], [], [METAR_MISSING=yes])
157     if test "x$METAR_MISSING" = xyes; then
158       AC_MSG_ERROR([something went wrong when checking for mdsplib, you're probably missing headers or it's not installed])
159   fi
160   AC_DEFINE(METAR, 1, [Define if you want metar stats (weather information)])
161 fi
162 dnl
163
164
165
166 dnl
167 dnl MLDonkey
168 dnl
169
170 want_mldonkey=no
171 AC_ARG_ENABLE(mldonkey,
172 [  --enable-mldonkey       enable if you want MLDonkey support [default=no]],
173   [want_mldonkey="$enableval"])
174
175 AM_CONDITIONAL(BUILD_MLDONKEY, test x$want_mldonkey == xyes)
176 if test x$want_mldonkey == xyes; then
177   AC_DEFINE(MLDONKEY, 1, [Define if you want MLDonkey support])
178 fi
179
180 dnl
181 dnl C Compiler
182 dnl
183
184 AC_PROG_CC
185
186 dnl
187 dnl X
188 dnl
189
190 want_x11=yes
191 AC_ARG_ENABLE(x11,
192 [  --enable-x11       enable if you want X11 support [default=yes]],
193   [want_x11="$enableval"])
194
195
196 AM_CONDITIONAL(BUILD_X11, test x$want_x11 == xyes)
197 if test x$want_x11 == xyes; then
198 AC_CHECK_HEADERS([X11/Xlib.h], [], [X11_MISSING=yes])
199     if test "x$X11_MISSING" = xyes; then
200       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])
201   fi
202   AC_DEFINE(X11, 1, [Define if you want to use X11])
203   AC_DEFINE(HAVE_X11, 1, [Define if you have X11])
204 fi
205 dnl AC_PATH_X if test $have_x != "yes"; then
206 dnl   echo "Sorry, X is very much needed"
207 dnl   exit 1
208 dnl fi
209 dnl AC_DEFINE(HAVE_X11, 1, [Define if you have X11])
210
211 dnl AC_CHECK_LIB([X11], [XOpenDisplay], [X11_LIBS="-lX11"], [], [[-L$x_libraries]])
212 dnl AC_CHECK_LIB([Xext], [XdbeQueryExtension], [
213 dnl   X11_LIBS="$X11_LIBS -lXext"
214 dnl   AC_DEFINE(HAVE_LIBXEXT, 1, [Define if you have libXext])
215 dnl ], [], [[-L$x_libraries $X11_LIBS]])
216
217 if test "$x_libraries" != ""; then
218   LDFLAGS="$LDFLAGS -L$x_libraries"
219 fi
220
221 if test "$x_includes" != ""; then
222   CFLAGS="$CFLAGS -Wall -I$x_includes"
223 fi
224
225 dnl
226 dnl Xft
227 dnl
228
229 if test "$want_xft" = "yes"; then
230   AC_PATH_PROG(XFTCONFIG, xft-config)
231   if test x$XFTCONFIG != x; then
232     dnl TODO: needs more checks
233   
234 dnl This won't work for some reason
235 dnl  AC_CHECK_HEADERS([X11/Xft/Xft.h], [], [XFT_MISSING=yes])
236     if test "x$XFT_MISSING" = xyes; then
237       AC_MSG_ERROR([something went wrong when checking for Xft, you're probably missing headers or it's not installed])
238   fi
239
240     AC_DEFINE(XFT, 1, [Define if you are using Xft])
241     CFLAGS="$CFLAGS `$XFTCONFIG --cflags`"
242     XFT_LIBS=`$XFTCONFIG --libs`
243   else
244     want_xft=no
245   fi
246 fi
247
248 dnl
249 dnl KVM
250 dnl
251
252 if test x$WANT_KVM = xyes; then
253   AC_CHECK_LIB(kvm, kvm_open,
254         LIBS="$LIBS -lkvm",
255         AC_MSG_ERROR([Could not find kvm_open in -lkvm.])
256   )
257 fi
258
259 dnl
260 dnl OSSLIB for NetBSD
261 dnl
262
263 if test x$WANT_OSSLIB = xyes; then
264     AC_CHECK_LIB(ossaudio, _oss_ioctl,
265         LIBS="$LIBS -lossaudio",
266         AC_MSG_ERROR([Could not find oss_ioctl in -lossaudio.])
267     )
268 fi
269
270 dnl
271 dnl Some random headers
272 dnl
273
274
275 AC_CHECK_HEADERS([signal.h unistd.h X11/Xlib.h sys/utsname.h sys/stat.h linux/soundcard.h dirent.h])
276 AC_CHECK_HEADERS([sys/statfs.h sys/param.h sys/mount.h])
277 dnl For cairo
278 AC_CHECK_HEADERS([proc/procps.h proc/readproc.h], [], [PROCPS_MISSING=yes])
279   if test "x$PROCPS_MISSING" = xyes; then
280       AC_MSG_ERROR([something went wrong when checking for procps, you're probably missing the necessary headers])
281   fi
282
283 dnl
284 dnl Check help2man
285 dnl
286
287 AC_PATH_PROG(HELP2MAN, help2man)
288 AM_CONDITIONAL(HAVE_HELP2MAN, test x$HELP2MAN != x)
289
290 dnl
291 dnl Check sysinfo()
292 dnl
293
294 if test x$WANT_SYSINFO = xyes; then
295   dah=no
296   AC_MSG_CHECKING(for sysinfo)
297   AC_TRY_COMPILE(
298     [#include <sys/types.h>
299      #include <sys/sysinfo.h>],
300     [struct sysinfo s; sysinfo(&s); (void) s.uptime; ],
301     [AC_MSG_RESULT(yes); dah=yes],
302     [AC_MSG_RESULT(not usable); dah=no])
303
304   if test x$dah = xyes; then
305     AC_DEFINE(HAVE_SYSINFO, 1, [Define if you have sysinfo (Linux)])
306   fi
307 fi
308
309 dnl
310 dnl kstat in Solaris
311 dnl
312
313 if test x$WANT_KSTAT = xyes; then
314   dah=no
315   AC_CHECK_LIB([kstat], [kstat_open], [dah=yes], [])
316
317   if test x$dah = xyes; then
318     AC_DEFINE(HAVE_KSTAT, 1, [Define if you have kstat (Solaris)])
319     LDFLAGS="$LDFLAGS -lkstat"
320   fi
321 fi
322
323 AC_DEFUN([AM_LANGINFO_CODESET],
324 [
325   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
326     [AC_TRY_LINK([#include <langinfo.h>],
327       [char* cs = nl_langinfo(CODESET);],
328       am_cv_langinfo_codeset=yes,
329       am_cv_langinfo_codeset=no)
330     ])
331   if test $am_cv_langinfo_codeset = yes; then
332     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
333       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
334   fi
335 ])
336
337 dnl
338 dnl Check getloadavg
339 dnl
340
341 AC_MSG_CHECKING(for getloadavg)
342 AC_TRY_COMPILE(
343   [#include <stdlib.h>],
344   [double v[3]; getloadavg(v, 3);],
345   [AC_MSG_RESULT(yes)
346    AC_DEFINE(HAVE_GETLOADAVG, 1, [Define if you have getloadavg])],
347   [AC_MSG_RESULT(no)])
348
349 dnl
350 dnl Check popen
351 dnl
352
353 AC_CHECK_FUNCS(popen)
354
355 dnl
356 dnl Da.
357 dnl
358
359 CFLAGS="$CFLAGS -Wall -W"
360
361 AC_SUBST(CFLAGS)
362 AC_SUBST(X11_LIBS)
363 AC_SUBST(XFT_LIBS)
364
365 AC_OUTPUT(Makefile)