Rename the original adesklets interpreter to adesklets.bin, and create
[adesklets.git] / configure.ac
blobc453fcedeb354edb214894015e12f19b06f6dbe5
1 dnl Initialize autoconf and automake
2 AC_INIT
3 AC_CONFIG_SRCDIR(src/main.c)
4 AC_PREREQ(2.52)
5 AM_INIT_AUTOMAKE(adesklets,0.4.10)
7 dnl Language selection
8 AC_LANG(C)
10 dnl Locate required external software
11 AC_PROG_CPP
12 if test "x$CPP" != 'x'; then
14 AC_SUBST(CPP)
16 AC_PROG_CC
17 AM_PROG_LEX
18 if test "x$LEX" != 'xflex'; then
19 AC_MSG_WARN([
20 -----------------------------------------------------
21 `flex' was not found on your system. If you encounter
22 problems recompiling a `l' file, please try `flex' 
23 first. You can get it from any GNU archive site. 
24 You will not need `flex' as long as you do not 
25 modify `l' files.
26 ----------------------------------------------------])
28 AC_PROG_YACC
29 if test "x$YACC" != "xbison -y"; then
30 AC_MSG_WARN([
31 -----------------------------------------------------
32 Nor `byacc' or `yacc' parsers had been used
33 for developing adesklets. If you encounter problems
34 recompiling a `y' file, please try `bison' instead. 
35 You can get it from any GNU archive site. You will 
36 not need `bison' as long as you do not modify 
37 `y' files.
38 -----------------------------------------------------])
40 AC_PROG_INSTALL
42 dnl Check for python support
43 withval=
44 AC_ARG_WITH(python-support,
45 [  --without-python-support   
46                           do not install adesklets python package
47                           Do not set this option unless you have
48                           good reasons])
49 : ${withval:=yes}
50 if test x$withval = "xyes"; then
51 withval=
52 AC_ARG_WITH(python-force-detection,
53 [  --with-python-force-detection
54                           bypass all the python version check mechanism. 
55                           When using this, make sure you have a version
56                           greater or egal to python 2.3 installed 
57                           as 'python' in your path [default=no]])
58 : ${withval:=no}
59 if test x$withval = "xno"; then
60 AM_PATH_PYTHON([2.3])
61 else
62 AM_PATH_PYTHON()
64 AC_PYTHON_DEVEL
65 withval=
66 AC_ARG_WITH(python-install-submission-scripts,
67 [  --with-python-install-submission-scripts
68                           install in the path the submission-related scripts
69                           from submit/ in the $PREFIX/bin program path.
70                           Useful for desklets author [default=no]])
71 : ${withval:=no}
72 if test x$withval = "xyes"; then
73 AM_CONDITIONAL(PYTHON_INSTALL_SUBMISSION_SCRIPTS, true)
74 else
75 AM_CONDITIONAL(PYTHON_INSTALL_SUBMISSION_SCRIPTS, false)
77 AC_CHECK_FUNCS(sigprocmask,
78 [HAVE_SIGPROCMASK="#define HAVE_SIGPROCMASK 1", SIGPROC=yes],
79 [HAVE_SIGPROCMASK="#undef HAVE_SIGPROCMASK"])
80 else
81 HAVE_SIGPROCMASK="#undef HAVE_SIGPROCMASK"
83 AC_SUBST(HAVE_SIGPROCMASK)
84 AM_CONDITIONAL(PYTHON_SUPPORT, test "x$PYTHON" != "x")
85 AM_CONDITIONAL(PYTHON_INSTALL_SUBMISSION_SCRIPTS, true)
87 dnl help2man presence
88 AC_PATH_PROG(HELP2MAN, help2man)
89 AM_CONDITIONAL(HELP2MAN_SUPPORT, test "x$HELP2MAN" != "x")
91 dnl htmltidy presence
92 AC_PATH_PROG(TIDY,tidy)
94 dnl doxygen presence
95 AC_PATH_PROG(DOXYGEN,doxygen)
96 AM_CONDITIONAL(DOXYGEN_SUPPORT, test "x$DOXYGEN" != "x")
98 dnl makeinfo support
99 AM_CONDITIONAL(MAKEINFO_SUPPORT, test "x$MAKEINFO:" != "x")
101 dnl Try to enforce ISO C (iso9899 1999)
102 dnl This will more likely work
103 dnl only with gcc. In fact,
104 dnl expect for variadic macros, this program
105 dnl should be ansi C (ISO C90).
106 TMP_CFLAGS="$CFLAGS"
107 CFLAGS="$CFLAGS -std=c99 -pedantic -Wall"
108 AC_MSG_CHECKING([for ISO C99 warnings generation])
109 AC_TRY_COMPILE(
111 int 
112 main(void) 
114    return 0L;
116 AC_MSG_RESULT([yes]),
117 AC_MSG_RESULT([no])
118 CFLAGS="$TMP_CFLAGS"
121 dnl Define source to be BSD compliant (ISO C, POSIX, and 4.3BSD)
122 AC_DEFINE(_BSD_SOURCE,1,[Source is BSD compliant (ISO C, POSIX and 4.3BSD)])
123 if test "x`uname`" = xNetBSD; then
124 dnl NetBSD (at least version 1.6.1) is following the standard less closely than 
125 dnl the other... Hence, we declare the source specifically as _POSIX_SOURCE 
126 dnl instead of the newer _POSIX_C_SOURCE 199309
127 AC_DEFINE(_POSIX_SOURCE,1,[Source is POSIX 1 compliant (IEEE Std 1003.1)])
128 else
129 dnl For some unspecified reason, it as been reported than FreeBSD [5|6].x 
130 dnl doesn't like those POSIX keywords either
131 UNAME_REDUX=`uname -r -s | sed 's/\..*//' 2> /dev/null`
132 if test "$UNAME_REDUX" != 'FreeBSD 5' && test "$UNAME_REDUX" != 'FreeBSD 6'
133 then
134 AC_DEFINE(_POSIX_C_SOURCE,199309,[Source is POSIX 4 compliant (IEEE Std 1003.1b)])
138 dnl Check for system header files
139 AC_HEADER_STDC
140 AC_CHECK_HEADERS(stdio.h stdarg.h errno.h fcntl.h signal.h time.h math.h sys/time.h sys/types.h sys/stat.h grp.h pwd.h libgen.h dirent.h iconv.h)
142 dnl Enable debugging
143 dnl This will filter out optimisation switch (-O[s0-9]) 
144 dnl for gcc compiler
145 AC_ARG_ENABLE(
146   debug, [  --enable-debug        enable debugging symbols and supplementary 
147                           messages generation in final binary])
149 : ${enableval="no"}
150 AC_MSG_CHECKING([for debugging symbols generation])
151 if test x$enableval = "xyes"; then
152    AC_MSG_RESULT([yes])
153    AC_DEFINE(DEBUG, 1, [Debug mode is on if defined.])
154    CFLAGS="$CFLAGS -g"
155    DEBUG=yes
156 else
157    AC_MSG_RESULT([no])
158    CFLAGS=`echo "$CFLAGS" | sed 's/^-g$//; s/^-g@<:@@<:@:space:@:>@@:>@\+// ; s/@<:@@<:@:space:@:>@@:>@\+-g$//; s/@<:@@<:@:space:@:>@@:>@\+-g@<:@@<:@:space:@:>@@:>@\+/ /'`
161 dnl SIGKILL timeout setting
162 enableval=
163 AC_MSG_CHECKING([for sigkill timeout])
164 AC_ARG_ENABLE(sigkill-timeout,
165 [  --enable-sigkill-timeout=SEC
166                           timeout (in seconds) before sending `kill'
167                           signal to parent process in case of restart 
168                           if `term' has no effect [default=5]])
169 : ${enableval:=5}
170 test $enableval -gt 0 2> /dev/null || {
171 AC_MSG_RESULT([no])
172 AC_MSG_ERROR([Given sigkill timeout was not understood])
174 AC_MSG_RESULT([yes])
175 AC_DEFINE_UNQUOTED(SIGKILL_TIMEOUT,$enableval,
176 [Delay between SIGTERM ans SIGKILL to parent process in case of restart.])
178 dnl X polling frequency setting
179 enableval=
180 period=
181 AC_MSG_CHECKING([for polling frequency])
182 AC_ARG_ENABLE(x-polling-frequency,
183 [  --enable-x-polling-frequency=FREQ
184                           frequency (in hertz) for polling the X server
185                           for events. Lower values leads to less responsive,
186                           but less CPU hungry desklets [default=50]])
187 : ${enableval:=50}
188 test $enableval -gt 0 2> /dev/null || {
189 AC_MSG_RESULT([no])
190 AC_MSG_ERROR([Positive, integer value is required as x-polling-frequency])
193 AC_CHECK_PROG(EXISTS,bc,yes,no)
194 if test $enableval -ne 50; then
195 if test x$EXISTS = "xyes"; then
196    period=`echo "1000000 / $enableval" | bc`
197 else
198    AC_MSG_WARN([Could not find the `bc' calculator to perform arithmetic 
199 computation of X server polling period value. Default 50 Hz is assumed.])
202 : ${period:=20000}
203 AC_DEFINE_UNQUOTED(X_POLLING_PERIOD,$period,
204 [Polling period (in 10e-6 seconds) of stdin between two cycles of events loop.])
206 dnl Lock files directory setting
207 enableval=
208 AC_MSG_CHECKING([for lock files directory setting])
209 AC_ARG_ENABLE(lockfiles-dir,
210 [  --enable-lockfiles-dir=DIR
211                           directory to put lock files in [default=/tmp]])
212 : ${enableval:=/tmp}
213 test -d $enableval || {
214 AC_MSG_RESULT([no])
215 AC_MSG_ERROR([Given lock files directory does not exist on your system])
217 AC_MSG_RESULT([yes])
218 AC_DEFINE_UNQUOTED(LOCKFILES_DIR,"$enableval",
219 [Directory to put lock files in.])
221 dnl Control modifier on context menu
222 enableval=
223 AC_MSG_CHECKING([for control modifier on context menu])
224 AC_ARG_ENABLE(control-on-context-menu,
225 [  --enable-control-on-context-menu
226                           force CTRL to be pressed to fire context menu
227                           [default=no]])
228 : ${enableval:=no}
229 if test x$enableval != "xno" ; then
230 AC_MSG_RESULT([yes])
231 AC_DEFINE(CONTROL_ON_CONTEXT_MENU, 1,
232 [Force CTRL to be pressed to fire context menu])
233 else
234 AC_MSG_RESULT([no])
237 dnl Legacy Window Manager detection code
238 enableval=
239 AC_MSG_CHECKING([for legacy fake root window detection code])
240 AC_ARG_ENABLE(legacy-fake-root-window-detection,
241 [  --enable-legacy-fake-root-window-detection
242                           Use the old code to detect fake root windows
243                           [default=no]])
244 : ${enableval:=no}
245 if test x$enableval != "xno" ; then
246 AC_MSG_RESULT([yes])
247 AC_DEFINE(WM_DETECTION_OLD_STYLE, 1,
248 [Use former fake root window detection code])
249 else
250 AC_MSG_RESULT([no])
253 dnl Collect various system informations strings,
254 dnl for embedding into final executable
255 EXISTS=
256 WELCOME1="\"$PACKAGE $VERSION"
257 AC_CHECK_PROG(EXISTS,date,yes)
258 if test x$EXISTS = "xyes"; then
259    WELCOME1="$WELCOME1 ("`date | sed 's/@<:@@<:@:space:@:>@@:>@\+/ /g'`")"
260 else
261    WELCOME1="$WELCOME1 (unknown time)"
263 EXISTS=
264 AC_CHECK_PROG(EXISTS,uname,yes)
265 if test x$EXISTS = "xyes"; then
266    if uname -rs &> /dev/null; then
267       WELCOME1="$WELCOME1, on "`uname -rs`"\""
268    else
269       WELCOME1="$WELCOME1, on an unknown OS\""
270    fi
271 else
272    WELCOME1="$WELCOME1, on an unknown OS\""
274 AC_DEFINE_UNQUOTED(WELCOME_LINE_1, $WELCOME1, [Welcome message, first line.])
275 dnl Note: @<:@ and @:>@ are respective quadrigraphs for `[' and `]'
276 ${CC} --version &> /dev/null && \
277       WELCOME2="\"${CC} "`${CC} --version | sed -n '1 s/^@<:@^0-9@:>@*//p'`"\""
278 : ${WELCOME2:=\"${CC} unknown version\"}
279 AC_DEFINE_UNQUOTED(WELCOME_LINE_2, $WELCOME2, [Welcome message, second line.])
281 dnl Variables save: all changes to CFLAGS, LIBS and LDFLAGS beyond
282 dnl this point will be wiped
283 TMP_CFLAGS="$CFLAGS"
284 TMP_LIBS="$LIBS"
285 TMP_LDFLAGS="$LDFLAGS"
287 dnl Check for readline
288 AC_CHECK_LIB(ncurses, tputs, HaveLibTermcap=yes; LibTermcap=ncurses,
289    AC_CHECK_LIB(termcap, tputs, HaveLibTermcap=yes; LibTermcap=termcap,
290       AC_CHECK_LIB(curses, tputs, HaveLibTermcap=yes; LibTermcap=curses,
291                    HaveLibTermcap=no)))
292 if test $HaveLibTermcap = "yes" ; then
293    LIBS="$LIBS -l$LibTermcap"
294 else
295    AC_MSG_ERROR([Could not find terminal management library for readline
296 (either ncurses, termcap or curses).])
298 AC_CHECK_LIB(readline,readline,
299   READLINE_LIBS="-l$LibTermcap -lreadline",
300   AC_MSG_ERROR([Could not find the readline library]),
301   $LFLAGS)
302 LIBS="$TMP_LIBS"
304 dnl Check for libhistory support
305 withval=
306 AC_ARG_WITH(history,
307 [  --without-history       remove history support in interactive use
308                           of the interpreter])
309 : ${withval:=yes}
310 if test x$withval = "xyes"; then
311 AC_CHECK_LIB(history,add_history,
312         READLINE_LIBS="$READLINE_LIBS -lhistory";
313         AC_DEFINE(HAVE_READLINE_HISTORY_H,1,
314         [Define to 1 if you have the <readline/history.h> header file.])
315         HaveLibHistory=yes
316         AC_CHECK_LIB(history,free_history_entry,
317         AC_DEFINE(HAVE_FREE_HISTORY_ENTRY,1,
318         [Define to 1 if you have the `free_history_entry' function.])),
319         HaveLibHistory=no,
320         $LFLAGS)
321 if test $HaveLibHistory = "no"; then
322 AC_MSG_WARN([Could not find GNU history library in the system])
324 AC_MSG_CHECKING([for history max command lenght])
325 enableval=
326 AC_ARG_ENABLE(history-max-command-lenght,
327 [  --enable-history-max-command-lenght=LEN
328                           maximum string lenght (in characters) that a single
329                           command can have and still be kept in history 
330                           (a lenght of zero meaning no limits) [default=256]])
331 : ${enableval:=256}
333 if test $enableval -ge 0 ; then
334 AC_MSG_RESULT([yes])
335 AC_DEFINE_UNQUOTED(HISTORY_MAX_COMMAND_LENGHT,$enableval,
336 [maximum history string lenght.])
337 else
338 AC_MSG_RESULT([no])
339 AC_MSG_ERROR([history max command lenght must be positive or null])
343 AC_SUBST(READLINE_LIBS) 
345 dnl Check for 8 bit characters support forcing
346 enableval=
347 AC_ARG_ENABLE(force-extended-characters-input,
348 [  --enable-force-extended-characters-input
349                           force input and ouput of unescaped 
350                           height bits characters through GNU readline, 
351                           regardless of the inputrc settings [default=no]])
352 : ${enableval:=no}
353 if ! test x$enableval = "xno" ; then
354 AC_DEFINE(FORCE_EXTENDED_CHARACTERS_INPUT,1,
355 [force 8 bit characters support in GNU readline])
358 dnl Check for fontconfig
359 withval=
360 AC_ARG_WITH(fontconfig,
361 [  --without-fontconfig    remove fontconfig support enabling automatic 
362                           detection of all truetype fonts already available
363                           on the machine])
364 : ${withval:=yes}
365 if test x$withval = "xyes"; then
366 AC_PATH_PROG(PKG_CONFIG, pkg-config)
367 if ! test x$PKG_CONFIG = "x" ; then
368    if $PKG_CONFIG --exists fontconfig 2> /dev/null; then
369       FONTCONFIG_LIBS=`pkg-config --libs fontconfig`
370       FONTCONFIG_CFLAGS=`pkg-config --cflags fontconfig`
371    fi
373 if test x$FONTCONFIG_LIBS = "x"; then
374    FONTCONFIG_LIBS=-lfontconfig
376 LIBS="$LIBS $FONTCONFIG_LIBS"
377 CFLAGS="$CFLAGS $FONTCONFIG_CFLAGS"
378 AC_MSG_CHECKING([for fontconfig])
379 AC_TRY_LINK(
380 #include <fontconfig/fontconfig.h>
381 , FcInit(),
382 AC_MSG_RESULT([yes])
383 AC_DEFINE(HAVE_FONTCONFIG_FONTCONFIG_H,1,[Define to 1 if you have the <fontconfig/fontconfig.h> header file.]),
384 AC_MSG_RESULT([no])
385 FONTCONFIG_LIBS=
386 FONTCONFIG_CFLAGS=
387 AC_MSG_WARN([
388 -----------------------------------------------------
389 `fontconfig' was not found on your system. 
390 Although `adesklets' will work anyway system-wide 
391 automatic font detection will not occur: 
392 it is therefore quite possible that only the 
393 default font provided with the package will display.
394 -----------------------------------------------------]))
395 AC_SUBST(FONTCONFIG_LIBS)
396 AC_SUBST(FONTCONFIG_CFLAGS)
397 LIBS="$TMP_LIBS"
398 CFLAGS="$TMP_CFLAGS"
401 dnl Check for fork() system call
402 AC_CHECK_FUNCS(fork,,
403 AC_MSG_ERROR([Could not find the fork() system call]))
405 dnl Check for X headers and libraries
406 AC_PATH_X
407 AC_PATH_XTRA
409 if test x$no_x != "xyes"; then
411 test x$x_includes = "x" && x_includes="/usr/include"
412 test x$x_libraries = "x" && x_libraries="/usr/lib"
414 X_LIBS="$X_LIBS $X_EXTRA_LIBS"
415 LIBS="$LIBS $X_LIBS"
416 CFLAGS="$CFLAGS $X_CFLAGS"
417 LDFLAGS="$LDFLAGS $LIBS $X_PRE_LIBS"
418 dnl Check for required functions in -lX11
419 AC_CHECK_LIB(X11, XOpenDisplay,
420   X_LIBS="$X_LIBS -lX11"
421   LIBS="$LIBS -lX11",
422   AC_MSG_ERROR([Could not find XOpenDisplay in -lX11.])
424 AC_DEFINE(X_DISPLAY_SUPPORT,1,[Define to 1 if the X Window System is supported, 0 otherwise.])
425 else
426 AC_DEFINE(X_DISPLAY_SUPPORT,0,[Define to 1 if the X Window System is supported, 0 otherwise.])
427    X_CFLAGS=
428    X_LIBS=
429    X_PRE_LIBS=
431 AC_SUBST(X_CFLAGS)
432 AC_SUBST(X_LIBS)
433 AC_SUBST(X_PRE_LIBS)
435 dnl Imlib2 detection
436 withval=
437 AC_ARG_WITH(imlib2,
438         [  --with-imlib2=DIR       use imlib2 in <DIR>],
439         [CFLAGS="$CFLAGS -I$withval/include"
440         LIBS="-L$withval/lib $LIBS"])
442 AC_PATH_GENERIC_MODIFIED(imlib2, 1.1.2, 
443 [ AC_SUBST(IMLIB2_LIBS)
444   AC_SUBST(IMLIB2_CFLAGS) ],
445   AC_MSG_ERROR([Cannot find imlib2: Is imlib2-config in the path?]),
446   1.2.0,,
447   AC_MSG_WARN([
448 -----------------------------------------------------
449 $PACKAGE should work with your version of imlib2...
450 But for better results you are _warmly_ encouraged 
451 to try out version 1.2.0 or above;
452 known bugs are still lurking in dark corners 
453 with what you have installed: beware strange problems 
454 with dynamic image filters for instance!  
455 -----------------------------------------------------]))
456 LIBS="$LIBS $IMLIB2_LIBS"
457 CFLAGS="$CFLAGS $IMLIB2_CFLAGS"
459 AC_MSG_CHECKING([for imlib2 program linking])
460 AC_TRY_LINK(
461 #ifndef X_DISPLAY_MISSING
462         #include <X11/Xlib.h>
463         #include <X11/Xutil.h>
464         #include <X11/Xos.h>
465         #include <X11/Xatom.h>
466 #endif  
467         #include <Imlib2.h>
468 ,       Imlib_Image image;
469         image = imlib_load_image("toto.png");
470 #ifndef X_DISPLAY_MISSING
471         imlib_context_set_display(NULL);
472 #endif
474         AC_MSG_RESULT([yes]),
475         AC_MSG_RESULT([no])
476         AC_MSG_ERROR([Cannot link Imlib2 program. 
477 If you specified you did not want X support this can be caused 
478 by your Imlib2 installment being configured so it needs it
479 or conversely. In that case reinstall Imlib2 with proper 
480 --enable-x11-support parameter (as from enlightement CVS) 
481 before retrying to configure this package.]))
483 dnl Test for uint typedef
484 AC_MSG_CHECKING([for uint typedef in standard library])
485 AC_TRY_COMPILE(
486 #ifdef HAVE_SYS_TYPES_H
487         #include <sys/types.h>
488 #endif
489 #ifdef HAVE_UNISTD_H
490         #include <unistd.h>
491 #endif
492 ,       uint i,
493         AC_MSG_RESULT([yes]),
494         AC_MSG_RESULT([no])
495         AC_DEFINE(UINT_NOT_DEFINED,1,
496                   [Define to 1 if compability type uint is not detected.])      
499 dnl Important variables reset
500 CFLAGS="$TMP_CFLAGS"
501 LIBS="$TMP_LIBS"
502 LDFLAGS="$TMP_LDFLAGS"
504 dnl PKGDATADIR definition
505 dnl PKGDATADIR is only well constructed in make context,
506 dnl so let's put this AFTER all tests.
507 CFLAGS="$CFLAGS"' -DPKGDATADIR=\"$(pkgdatadir)\"'
509 dnl Output files
510 AM_CONFIG_HEADER(src/config.h)
511 AC_OUTPUT(Makefile
512 src/Makefile
513 data/Makefile
514 utils/Makefile
515 doc/Makefile
516 doc/htmldoc.sh
517 doc/imlib2/Makefile
518 scripting/Makefile
519 scripting/protoize.sh
520 scripting/python/Makefile
521 scripting/python/config.h
522 scripting/python/setup.py
523 src/adesklets
526 dnl Change script(s) permissions
527 chmod +x scripting/protoize.sh doc/htmldoc.sh src/adesklets
529 dnl Final warning, if needed
530 if test x$DEBUG = "xyes"; then
531 AC_MSG_WARN([
532 -----------------------------------------------------
533 you choosed to make a `debug' compilation: this will
534 generate a significantly bigger executable
535 that produces on stderr (by default) a lot of outputs 
536 unwanted during normal use; set up the ADESKLETS_LOG 
537 environment variable to a filename the interpreter 
538 can safely suffix with a pid related extension
539 than truncate to collect all debug outputs 
540 there instead. Be also aware that all optimisation 
541 settings (-O flags in CFLAGS) are discarded when 
542 enabling this.
543 -----------------------------------------------------])
545 if test x$no_x = "xyes"; then
546 AC_MSG_WARN([
547 -----------------------------------------------------
548 you choosed to perform an `X Window less' build - 
549 which means you will eventually end up with 
550 a strictly command line program free of all
551 dependencies on xlib. If it is not what you intended 
552 please reconfigure. For this to work you do need first
553 to configure your Imlib2 incantation for not using
554 X Window itself.
555 -----------------------------------------------------
559 if test x$PYTHON != "x" ; then
560 if test x$SIGPROC != "xyes" ; then
561 AC_MSG_WARN([
562 -----------------------------------------------------
563 your system does not seem to support reliable POSIX
564 signal calls such as `sigprocmask', `sigpending' or
565 `sigsuspend'. Although this does not affect $PACKAGE
566 directly, it seriously impedes python ability
567 to handle things well through its package. 
568 To our knowledge, no modern UNIX platforms lack 
569 those system calls...
570 -----------------------------------------------------