1 dnl sxe-gui.m4 -- GUI stuff
6 ## Oki, now that we really need a more exhaustive way to autodetect
7 ## athena and other widgets we construct a chain. The elements of
8 ## that chain are simple atomic tests (provided by AC_DEFUNs).
9 ## The chain is defined to be:
11 ## neXtaw -> Xaw3d -> XawXpm -> Xaw95 -> Xaw -> Motif -> Nirvana
12 ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ ^^^^^
13 ## 3d sets non-3d non-athena
15 ## Now if the user passes a --with-athena=foo option, we jump
16 ## directly to the according test-suite and in case this fails we jump
20 ## We shall perform every test-suite twice, once the correct way, and
21 ## once with #include'ing the Xfuncproto header.
22 ## Thanks to the many, many distributions which treat their users
23 ## like braindead zombies!
24 ## Especially, I would like to thank Fedora/RedHat for bringing
25 ## this up. Go on guys, you rock!
27 define([SXE_XAW_INCLUDES_XFUNCPROTO], [dnl
28 # if HAVE_XFUNCPROTO_H
29 # include <X11/Xfuncproto.h>
31 ])dnl SXE_XAW_INCLUDES_XFUNCPROTO
33 dnl Check for Xfuncproto first
34 AC_DEFUN([SXE_XAW_FUNCPROTO], [dnl
36 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
37 LDFLAGS="$LDFLAGS $X_LIBS"
38 if test -n "$athena_lib" -a -z "$athena_h_path"; then
39 AC_CHECK_HEADER([X11/Xfuncproto.h], [$1])
42 ])dnl SXE_XAW_FUNCPROTO
44 AC_DEFUN([SXE_TEST_THREED_XAW_LIB], [dnl generic 3d library checker
46 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
47 LDFLAGS="$LDFLAGS $X_PRE_LIBS $X_LIBS $libs_x"
48 if test -z "$athena_lib"; then
49 AC_CHECK_LIB([$1], [threeDClassRec], [athena_lib=$1])
52 ])dnl SXE_TEST_THREED_XAW_LIB
54 define([SXE_XAW_INCLUDES_INTRINSIC], [dnl
55 # if HAVE_X11_INTRINSIC_H
56 # include <X11/Intrinsic.h>
57 # include <X11/IntrinsicP.h>
59 ])dnl SXE_XAW_INCLUDES_INTRINSIC
61 AC_DEFUN([SXE_TEST_THREED_XAW_INC_INTERNAL], [dnl generic 3d library checker
62 ## arg1 is the path to the Xaw headers relative to its prefix
64 ## arg3 is some prefix to the Xaw headers
65 pushdef([XAW_PATH], [$1])
66 pushdef([XAW_PATH_TL], translit([$1], [/], [_]))
67 pushdef([XAW_INCS], [$2])
68 pushdef([XAW_PREFIX], [$3])
69 pushdef([XAW_PREFIX_TL], translit([$3], [/], [_]))
71 if test -n "$athena_lib" -a -z "$athena_h_path"; then
72 ## The three-d Athena headers are so much more slippery.
73 ## Curse this `Lets replace standard libraries' thing that they did. :/
74 ## unset the values before we get our dirty hands on them
75 unset "ac_cv_header_[]XAW_PREFIX_TL[]XAW_PATH_TL[]_XawInit_h"
76 unset "ac_cv_header_[]XAW_PREFIX_TL[]XAW_PATH_TL[]_ThreeD_h"
79 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
80 LDFLAGS="$LDFLAGS $X_LIBS"
81 SXE_CHECK_HEADERS(XAW_PREFIX[]XAW_PATH[/XawInit.h],
82 [], [], XAW_INCS SXE_XAW_INCLUDES_INTRINSIC)
83 SXE_CHECK_HEADERS(XAW_PREFIX[]XAW_PATH[/ThreeD.h],
85 if test "$ac_cv_header_[]XAW_PREFIX_TL[]XAW_PATH_TL[]_XawInit_h" -a \
86 "$ac_cv_header_[]XAW_PREFIX_TL[]XAW_PATH_TL[]_ThreeD_h"; then
87 athena_h_path="XAW_PREFIX[]XAW_PATH"
96 popdef([XAW_PREFIX_TL])
97 ])dnl SXE_TEST_THREED_XAW_INC_INTERNAL
99 AC_DEFUN([SXE_TEST_THREED_XAW_INC], [dnl generic 3d library checker
101 ## arg2 are some INCs
102 pushdef([XAW_INCS], [$2])
104 SXE_TEST_THREED_XAW_INC_INTERNAL([$1], XAW_INCS, [X11/])
105 SXE_TEST_THREED_XAW_INC_INTERNAL([$1], XAW_INCS)
106 SXE_TEST_THREED_XAW_INC_INTERNAL([$1], XAW_INCS, [X11/Xaw/])
109 ])dnl SXE_TEST_THREED_XAW_INC
111 AC_DEFUN([SXE_TEST_THREED_XAW_GENERIC], [dnl
112 SXE_TEST_THREED_XAW_LIB([$1], [$2])
113 SXE_TEST_THREED_XAW_INC([$1])
115 SXE_TEST_THREED_XAW_INC([$1], [SXE_XAW_INCLUDES_XFUNCPROTO])
116 ])dnl SXE_TEST_THREED_XAW_GENERIC
118 AC_DEFUN([SXE_TEST_XAW_LIB], [dnl
120 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
121 LDFLAGS="$LDFLAGS $X_PRE_LIBS $X_LIBS $libs_x"
122 if test -z "$athena_lib"; then
123 AC_CHECK_LIB([Xaw], [XawScrollbarSetThumb], [athena_lib="Xaw"])
126 ])dnl SXE_TEST_XAW_LIB
128 AC_DEFUN([SXE_TEST_XAW_INC], [dnl
129 ## arg1 are some additional INCLUDES
131 ## unset the values before we get our dirty hands on them
132 unset "ac_cv_header_X11_Xaw_XawInit_h"
135 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
136 if test -n "$athena_lib" -a -z "$athena_h_path"; then
137 AC_CHECK_HEADERS([X11/Xaw/XawInit.h],
138 [athena_h_path="X11/Xaw"], [],
139 [$1 SXE_XAW_INCLUDES_INTRINSIC])
142 ])dnl SXE_TEST_XAW_INC
145 AC_DEFUN([SXE_TEST_NEXTAW], [SXE_TEST_THREED_XAW_GENERIC([neXtaw], [$1])])
146 AC_DEFUN([SXE_TEST_XAW3D], [SXE_TEST_THREED_XAW_GENERIC([Xaw3d], [$1])])
147 AC_DEFUN([SXE_TEST_XAWXPM], [SXE_TEST_THREED_XAW_GENERIC([XawXpm], [$1])])
148 AC_DEFUN([SXE_TEST_XAW95], [SXE_TEST_THREED_XAW_GENERIC([Xaw95], [$1])])
149 AC_DEFUN([SXE_TEST_XAW], [dnl
150 ## check if libXaw is a 3d set actually
151 ## no, we don't ... it's bullshit
152 ## if some distro handles it this way, i simply shrug it off.
154 ## SXE_TEST_THREED_XAW_GENERIC(Xaw, $1)
160 SXE_TEST_XAW_INC([SXE_XAW_INCLUDES_XFUNCPROTO])
163 AC_DEFUN([SXE_TEST_MOTIF], [dnl
164 ## autodetect Motif - but only add to libs_x later (if necessary)
165 ## Use a different function to the earlier test to avoid problems with the
168 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
169 LDFLAGS="$LDFLAGS $X_PRE_LIBS $X_LIBS $libs_x"
170 SXE_CHECK_HEADERS([Xm/Xm.h])
172 if test "$ac_cv_header_Xm_Xm_h" = "yes"; then
173 AC_CHECK_LIB([Xm], [XmStringCreate],
174 [have_motif=yes], [have_motif=no])
180 if test "$have_motif" = "yes"; then
181 dnl autodetect lesstif
182 AC_MSG_CHECKING([for Lesstif])
185 #ifdef LESSTIF_VERSION
188 ], [have_lesstif=yes], [have_lesstif=no])
189 AC_MSG_RESULT([$have_lesstif])
194 AC_DEFUN([SXE_CHECK_XTOOLKITS], [
195 AC_MSG_CHECKING([for X11 graphics libraries])
198 ## firstly, check for the Xlib header
200 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
201 LDFLAGS="$LDFLAGS $X_PRE_LIBS $X_LIBS $libs_x"
202 AC_CHECK_HEADERS([X11/Xlib.h])
204 # Check for XkbKeycodeToKeysym to avoid XKeycodeToKeysym which is deprecated
205 AC_CHECK_HEADERS([X11/XKBlib.h])
206 if test "$ac_cv_header_X11_XKBlib_h" = "yes"; then
207 AC_CHECK_FUNC([XkbKeycodeToKeysym], [acx_xkbkeycodetokeysym=yes])
208 if test "$acx_xkbkeycodetokeysym" = "yes"; then
209 AC_DEFINE([HAVE_XKBKEYCODETOKEYSYM],[1],[Has XkbKeycodeToKeysym])
218 ## initialise our have-vars
222 case "$with_athena" in
223 ## autodetect, that is walk through the chain given above
225 AC_MSG_CHECKING([for the Athena widgets])
228 ## ignite the chain :)
250 ## This is the default, old fashioned flat Athena.
255 ## force the motif chain
260 SXE_DIE(["Unknown Athena widget set \`$with_athena'. This should not happen."])
264 ## Do we actually have a usable Athena widget set? Please?
265 if test -n "$athena_lib" -a -n "$athena_h_path"; then
266 if test "athena_lib" = "Xaw"; then
275 ## Finish ensuring that we have values for the various toolkit items.
276 ## Not all toolkits support all widgets
277 ## We gotta rewrite several defaults, now that we know that we either
278 ## have athena or motif
279 if test "$have_xaw" = "yes" -a "$have_motif" = "yes"; then
280 ## nothing's wrong in this case, we use the lucid menubar anyway
281 if test "$with_menubars" = "athena"; then
282 with_menubars="lucid"
285 elif test "$have_xaw" = "yes" -a "$have_motif" = "no"; then
286 with_dialogs="athena"
287 with_widgets="athena"
288 with_menubars="lucid"
290 elif test "$have_xaw" = "no" -a "$have_motif" = "yes"; then
293 with_menubars="lucid"
294 with_scrollbars="lucid"
296 elif test "$have_xaw" = "no" -a "$have_motif" = "no"; then
297 AC_MSG_ERROR([You seem to have no usable X toolkits!
298 However, SXEmacs runs fine even without X, but this may not be what
299 you want. If you explicitly want this, rerun configure with --without-x])
302 SXE_DIE("Now I feel dizzy! I know where the error happened but I won't tell!")
305 ])dnl SXE_CHECK_XTOOLKITS
307 AC_DEFUN([SXE_SUFFICIENT_ATHENA_P], [dnl
308 ## arg #1 is the symbol with all the tk widgets
309 pushdef([tmpwidgets], ifelse($1,,[all_widgets],$1))
311 all_widgets="$with_menubars $with_scrollbars $with_dialogs $with_toolbars $with_widgets"
312 case "$[]tmpwidgets[]" in
314 if test "$have_xaw" != "yes"; then
315 SXE_DIE(["Could not find a suitable Athena library to build with."])
318 dnl Add the Lucid widget Athena code
319 SXE_APPEND([lwlib-Xaw.o], [lwlib_objs])
321 dnl Add the Athena widget library we located earlier
322 SXE_PREPEND([-l$athena_lib], [libs_x])
324 dnl Tell lwlib where to find the Athena header files.
325 dnl Many people have tried to create a `smart' way of doing this,
326 dnl but all have failed. Before changing the following ugly definitions,
327 dnl consult the veterans of many a battle.
328 AC_DEFINE_UNQUOTED([ATHENA_Scrollbar_h_], ["$athena_h_path/Scrollbar.h"],
330 AC_DEFINE_UNQUOTED([ATHENA_Dialog_h_], ["$athena_h_path/Dialog.h"],
332 AC_DEFINE_UNQUOTED([ATHENA_Form_h_], ["$athena_h_path/Form.h"],
334 AC_DEFINE_UNQUOTED([ATHENA_Command_h_], ["$athena_h_path/Command.h"],
336 AC_DEFINE_UNQUOTED([ATHENA_Label_h_], ["$athena_h_path/Label.h"],
338 AC_DEFINE_UNQUOTED([ATHENA_LabelP_h_], ["$athena_h_path/LabelP.h"],
340 AC_DEFINE_UNQUOTED([ATHENA_Toggle_h_], ["$athena_h_path/Toggle.h"],
342 AC_DEFINE_UNQUOTED([ATHENA_ToggleP_h_], ["$athena_h_path/ToggleP.h"],
344 AC_DEFINE_UNQUOTED([ATHENA_AsciiText_h_], ["$athena_h_path/AsciiText.h"],
346 AC_DEFINE_UNQUOTED([ATHENA_XawInit_h_], ["$athena_h_path/XawInit.h"],
349 AC_DEFINE([LWLIB_USES_ATHENA], [1], [Description here!])
350 AC_DEFINE([NEED_ATHENA], [1], [Description here!])
353 if test "$athena_3d" = "yes"; then
354 AC_DEFINE([HAVE_ATHENA_3D], [1], [Description here!])
360 case "$with_widgets" in
362 SXE_APPEND([xlwradio.o xlwcheckbox.o xlwgauge.o], [lwlib_objs])
366 ## final declarations for our config header
367 if test "$with_scrollbars" = "athena"; then
368 AC_DEFINE([LWLIB_SCROLLBARS_ATHENA], [1], [Description here!])
370 if test "$with_dialogs" = "athena"; then
371 AC_DEFINE([LWLIB_DIALOGS_ATHENA], [1], [Description here!])
374 if test "$athena_3d" = "yes" -a \
375 "$with_scrollbars" = "athena"; then
376 AC_DEFINE([LWLIB_SCROLLBARS_ATHENA3D], [1], [Description here!])
378 if test "$athena_3d" = "yes" -a \
379 "$with_dialogs" = "athena"; then
380 AC_DEFINE([LWLIB_DIALOGS_ATHENA3D], [1], [Description here!])
382 case "$with_widgets" in
384 AC_DEFINE([LWLIB_WIDGETS_ATHENA], [1], [Description here!])
389 ])dnl SXE_SUFFICIENT_ATHENA_P
391 AC_DEFUN([SXE_SUFFICIENT_MOTIF_P], [dnl
392 ## arg #1 is the symbol with all the tk widgets
393 pushdef([tmpwidgets], ifelse($1,,[all_widgets],$1))
395 all_widgets="$with_menubars $with_scrollbars $with_dialogs $with_toolbars $with_widgets"
396 case "$[]tmpwidgets[]" in
398 AC_DEFINE([LWLIB_USES_MOTIF], [1], [Description here!])
399 AC_DEFINE([NEED_MOTIF], [1], [Description here!])
400 SXE_APPEND([lwlib-Xm.o], [lwlib_objs])
406 if test "$with_menubars" = "motif"; then
407 SXE_APPEND([xlwmenu.o], [lwlib_objs])
410 ## final declarations for our config header
411 if test "$with_menubars" = "motif"; then
412 AC_DEFINE([LWLIB_MENUBARS_MOTIF], [1], [Description here!])
414 if test "$with_scrollbars" = "motif"; then
415 AC_DEFINE([LWLIB_SCROLLBARS_MOTIF], [1], [Description here!])
417 if test "$with_dialogs" = "motif"; then
418 AC_DEFINE([LWLIB_DIALOGS_MOTIF], [1], [Description here!])
420 if test "$with_widgets" = "motif"; then
421 AC_DEFINE([LWLIB_WIDGETS_MOTIF], [1], [Description here!])
425 ])dnl SXE_SUFFICIENT_MOTIF_P
427 AC_DEFUN([SXE_SUFFICIENT_LUCID_P], [dnl
428 ## arg #1 is the symbol with all the tk widgets
429 pushdef([tmpwidgets], ifelse($1,,[all_widgets],$1))
431 all_widgets="$with_menubars $with_scrollbars $with_dialogs $with_toolbars $with_widgets"
432 case "$[]tmpwidgets[]" in
434 AC_DEFINE([NEED_LUCID], [1], [Description here!])
435 SXE_APPEND([lwlib-Xlw.o], [lwlib_objs])
440 if test "$with_menubars" = "lucid"; then
441 SXE_APPEND([xlwmenu.o], [lwlib_objs])
443 if test "$with_scrollbars" = "lucid"; then
444 SXE_APPEND([xlwscrollbar.o], [lwlib_objs])
447 ## final declarations for our config header
448 if test "$with_menubars" = "lucid"; then
449 AC_DEFINE([LWLIB_MENUBARS_LUCID], [1], [Description here!])
451 if test "$with_scrollbars" = "lucid"; then
452 AC_DEFINE([LWLIB_SCROLLBARS_LUCID], [1], [Description here!])
456 ])dnl SXE_SUFFICIENT_LUCID_P
458 AC_DEFUN([SXE_CHECK_XT_DEPENDENCIES], [dnl
460 SXE_SUFFICIENT_ATHENA_P
461 SXE_SUFFICIENT_MOTIF_P
462 SXE_SUFFICIENT_LUCID_P
464 all_widgets="$with_menubars $with_scrollbars $with_dialogs $with_toolbars $with_widgets"
465 if test "$with_x11" = "yes"; then
467 if test "$with_menubars" != "no"; then
468 SXE_ADD_SXEUIX11_OBJS([menubar-x.o])
470 if test "$with_scrollbars" != "no"; then
471 SXE_ADD_SXEUIX11_OBJS([scrollbar-x.o])
473 if test "$with_dialogs" != "no"; then
474 SXE_ADD_SXEUIX11_OBJS([dialog-x.o])
476 if test "$with_toolbars" != "no"; then
477 SXE_ADD_SXEUIX11_OBJS([toolbar-x.o])
479 if test "$all_widgets" != "no no no no no"; then
480 SXE_ADD_SXEUIX11_OBJS([gui-x.o])
484 ])dnl SXE_CHECK_XT_DEPENDENCIES
486 AC_DEFUN([SXE_CHECK_UI_SUFFICIENCY], [dnl
487 ## common-to-all stuff
488 if test "$with_menubars" != "no"; then
489 AC_DEFINE([HAVE_MENUBARS], [1], [Description here!])
490 AC_DEFINE([HAVE_POPUPS], [1], [Description here!])
491 SXE_ADD_SXEUI_OBJS([menubar.o])
493 if test "$with_scrollbars" != "no"; then
494 AC_DEFINE([HAVE_SCROLLBARS], [1], [Description here!])
495 SXE_ADD_SXEUI_OBJS([scrollbar.o])
497 if test "$with_dialogs" != "no"; then
498 AC_DEFINE([HAVE_DIALOGS], [1], [Description here!])
499 AC_DEFINE([HAVE_POPUPS], [1], [Description here!])
500 SXE_ADD_SXEUI_OBJS([dialog.o])
502 if test "$with_toolbars" != "no"; then
503 AC_DEFINE([HAVE_TOOLBARS], [1], [Description here!])
504 SXE_ADD_SXEUI_OBJS([toolbar.o])
506 if test "$with_widgets" != "no"; then
507 AC_DEFINE([HAVE_WIDGETS], [1], [Description here!])
508 AC_DEFINE([LWLIB_TABS_LUCID], [1], [Description here!])
509 SXE_APPEND([xlwtabs.o xlwgcs.o], [lwlib_objs])
511 AC_SUBST([lwlib_objs])
513 SXE_SUBST_SXEUITTY_OBJS
514 SXE_SUBST_SXEUIX11_OBJS
516 ])dnl SXE_CHECK_UI_SUFFICIENCY
518 dnl sxe-gui.m4 ends here