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])
209 ## initialise our have-vars
213 case "$with_athena" in
214 ## autodetect, that is walk through the chain given above
216 AC_MSG_CHECKING([for the Athena widgets])
219 ## ignite the chain :)
241 ## This is the default, old fashioned flat Athena.
246 ## force the motif chain
251 SXE_DIE(["Unknown Athena widget set \`$with_athena'. This should not happen."])
255 ## Do we actually have a usable Athena widget set? Please?
256 if test -n "$athena_lib" -a -n "$athena_h_path"; then
257 if test "athena_lib" = "Xaw"; then
266 ## Finish ensuring that we have values for the various toolkit items.
267 ## Not all toolkits support all widgets
268 ## We gotta rewrite several defaults, now that we know that we either
269 ## have athena or motif
270 if test "$have_xaw" = "yes" -a "$have_motif" = "yes"; then
271 ## nothing's wrong in this case, we use the lucid menubar anyway
272 if test "$with_menubars" = "athena"; then
273 with_menubars="lucid"
276 elif test "$have_xaw" = "yes" -a "$have_motif" = "no"; then
277 with_dialogs="athena"
278 with_widgets="athena"
279 with_menubars="lucid"
281 elif test "$have_xaw" = "no" -a "$have_motif" = "yes"; then
284 with_menubars="lucid"
285 with_scrollbars="lucid"
287 elif test "$have_xaw" = "no" -a "$have_motif" = "no"; then
288 AC_MSG_ERROR([You seem to have no usable X toolkits!
289 However, SXEmacs runs fine even without X, but this may not be what
290 you want. If you explicitly want this, rerun configure with --without-x])
293 SXE_DIE("Now I feel dizzy! I know where the error happened but I won't tell!")
296 ])dnl SXE_CHECK_XTOOLKITS
298 AC_DEFUN([SXE_SUFFICIENT_ATHENA_P], [dnl
299 ## arg #1 is the symbol with all the tk widgets
300 pushdef([tmpwidgets], ifelse($1,,[all_widgets],$1))
302 all_widgets="$with_menubars $with_scrollbars $with_dialogs $with_toolbars $with_widgets"
303 case "$[]tmpwidgets[]" in
305 if test "$have_xaw" != "yes"; then
306 SXE_DIE(["Could not find a suitable Athena library to build with."])
309 dnl Add the Lucid widget Athena code
310 SXE_APPEND([lwlib-Xaw.o], [lwlib_objs])
312 dnl Add the Athena widget library we located earlier
313 SXE_PREPEND([-l$athena_lib], [libs_x])
315 dnl Tell lwlib where to find the Athena header files.
316 dnl Many people have tried to create a `smart' way of doing this,
317 dnl but all have failed. Before changing the following ugly definitions,
318 dnl consult the veterans of many a battle.
319 AC_DEFINE_UNQUOTED([ATHENA_Scrollbar_h_], ["$athena_h_path/Scrollbar.h"],
321 AC_DEFINE_UNQUOTED([ATHENA_Dialog_h_], ["$athena_h_path/Dialog.h"],
323 AC_DEFINE_UNQUOTED([ATHENA_Form_h_], ["$athena_h_path/Form.h"],
325 AC_DEFINE_UNQUOTED([ATHENA_Command_h_], ["$athena_h_path/Command.h"],
327 AC_DEFINE_UNQUOTED([ATHENA_Label_h_], ["$athena_h_path/Label.h"],
329 AC_DEFINE_UNQUOTED([ATHENA_LabelP_h_], ["$athena_h_path/LabelP.h"],
331 AC_DEFINE_UNQUOTED([ATHENA_Toggle_h_], ["$athena_h_path/Toggle.h"],
333 AC_DEFINE_UNQUOTED([ATHENA_ToggleP_h_], ["$athena_h_path/ToggleP.h"],
335 AC_DEFINE_UNQUOTED([ATHENA_AsciiText_h_], ["$athena_h_path/AsciiText.h"],
337 AC_DEFINE_UNQUOTED([ATHENA_XawInit_h_], ["$athena_h_path/XawInit.h"],
340 AC_DEFINE([LWLIB_USES_ATHENA], [1], [Description here!])
341 AC_DEFINE([NEED_ATHENA], [1], [Description here!])
344 if test "$athena_3d" = "yes"; then
345 AC_DEFINE([HAVE_ATHENA_3D], [1], [Description here!])
351 case "$with_widgets" in
353 SXE_APPEND([xlwradio.o xlwcheckbox.o xlwgauge.o], [lwlib_objs])
357 ## final declarations for our config header
358 if test "$with_scrollbars" = "athena"; then
359 AC_DEFINE([LWLIB_SCROLLBARS_ATHENA], [1], [Description here!])
361 if test "$with_dialogs" = "athena"; then
362 AC_DEFINE([LWLIB_DIALOGS_ATHENA], [1], [Description here!])
365 if test "$athena_3d" = "yes" -a \
366 "$with_scrollbars" = "athena"; then
367 AC_DEFINE([LWLIB_SCROLLBARS_ATHENA3D], [1], [Description here!])
369 if test "$athena_3d" = "yes" -a \
370 "$with_dialogs" = "athena"; then
371 AC_DEFINE([LWLIB_DIALOGS_ATHENA3D], [1], [Description here!])
373 case "$with_widgets" in
375 AC_DEFINE([LWLIB_WIDGETS_ATHENA], [1], [Description here!])
380 ])dnl SXE_SUFFICIENT_ATHENA_P
382 AC_DEFUN([SXE_SUFFICIENT_MOTIF_P], [dnl
383 ## arg #1 is the symbol with all the tk widgets
384 pushdef([tmpwidgets], ifelse($1,,[all_widgets],$1))
386 all_widgets="$with_menubars $with_scrollbars $with_dialogs $with_toolbars $with_widgets"
387 case "$[]tmpwidgets[]" in
389 AC_DEFINE([LWLIB_USES_MOTIF], [1], [Description here!])
390 AC_DEFINE([NEED_MOTIF], [1], [Description here!])
391 SXE_APPEND([lwlib-Xm.o], [lwlib_objs])
397 if test "$with_menubars" = "motif"; then
398 SXE_APPEND([xlwmenu.o], [lwlib_objs])
401 ## final declarations for our config header
402 if test "$with_menubars" = "motif"; then
403 AC_DEFINE([LWLIB_MENUBARS_MOTIF], [1], [Description here!])
405 if test "$with_scrollbars" = "motif"; then
406 AC_DEFINE([LWLIB_SCROLLBARS_MOTIF], [1], [Description here!])
408 if test "$with_dialogs" = "motif"; then
409 AC_DEFINE([LWLIB_DIALOGS_MOTIF], [1], [Description here!])
411 if test "$with_widgets" = "motif"; then
412 AC_DEFINE([LWLIB_WIDGETS_MOTIF], [1], [Description here!])
416 ])dnl SXE_SUFFICIENT_MOTIF_P
418 AC_DEFUN([SXE_SUFFICIENT_LUCID_P], [dnl
419 ## arg #1 is the symbol with all the tk widgets
420 pushdef([tmpwidgets], ifelse($1,,[all_widgets],$1))
422 all_widgets="$with_menubars $with_scrollbars $with_dialogs $with_toolbars $with_widgets"
423 case "$[]tmpwidgets[]" in
425 AC_DEFINE([NEED_LUCID], [1], [Description here!])
426 SXE_APPEND([lwlib-Xlw.o], [lwlib_objs])
431 if test "$with_menubars" = "lucid"; then
432 SXE_APPEND([xlwmenu.o], [lwlib_objs])
434 if test "$with_scrollbars" = "lucid"; then
435 SXE_APPEND([xlwscrollbar.o], [lwlib_objs])
438 ## final declarations for our config header
439 if test "$with_menubars" = "lucid"; then
440 AC_DEFINE([LWLIB_MENUBARS_LUCID], [1], [Description here!])
442 if test "$with_scrollbars" = "lucid"; then
443 AC_DEFINE([LWLIB_SCROLLBARS_LUCID], [1], [Description here!])
447 ])dnl SXE_SUFFICIENT_LUCID_P
449 AC_DEFUN([SXE_CHECK_XT_DEPENDENCIES], [dnl
451 SXE_SUFFICIENT_ATHENA_P
452 SXE_SUFFICIENT_MOTIF_P
453 SXE_SUFFICIENT_LUCID_P
455 all_widgets="$with_menubars $with_scrollbars $with_dialogs $with_toolbars $with_widgets"
456 if test "$with_x11" = "yes" -a \
457 "$with_gtk" != "yes" -a \
458 "$with_gnome" != "yes"; then
460 if test "$with_menubars" != "no"; then
461 SXE_ADD_SXEUIX11_OBJS([menubar-x.o])
463 if test "$with_scrollbars" != "no"; then
464 SXE_ADD_SXEUIX11_OBJS([scrollbar-x.o])
466 if test "$with_dialogs" != "no"; then
467 SXE_ADD_SXEUIX11_OBJS([dialog-x.o])
469 if test "$with_toolbars" != "no"; then
470 SXE_ADD_SXEUIX11_OBJS([toolbar-x.o])
472 if test "$all_widgets" != "no no no no no"; then
473 SXE_ADD_SXEUIX11_OBJS([gui-x.o])
477 ])dnl SXE_CHECK_XT_DEPENDENCIES
479 AC_DEFUN([SXE_CHECK_GTK_DEPENDENCIES], [dnl
481 all_widgets="$with_menubars $with_scrollbars $with_dialogs $with_toolbars $with_widgets"
482 if test "$with_menubars" != "no"; then
483 SXE_ADD_SXEUIGTK_OBJS([menubar-gtk.o])
485 if test "$with_scrollbars" != "no"; then
486 SXE_ADD_SXEUIGTK_OBJS([scrollbar-gtk.o])
488 if test "$with_dialogs" != "no"; then
489 SXE_ADD_SXEUIGTK_OBJS([dialog-gtk.o])
491 if test "$with_toolbars" != "no"; then
492 SXE_ADD_SXEUIGTK_OBJS([toolbar-gtk.o])
494 if test "$all_widgets" != "no no no no no"; then
495 SXE_ADD_SXEUIGTK_OBJS([gui-gtk.o])
500 Congratulations!!! You've won already!!!
502 You have been chosen to implement a GTK user interface for us!
503 Finish all your work IMMEDIATELY and contact us to obtain detailed orders.
507 ])dnl SXE_CHECK_GTK_DEPENDENCIES
510 AC_DEFUN([SXE_CHECK_UI_SUFFICIENCY], [dnl
511 ## common-to-all stuff
512 if test "$with_menubars" != "no"; then
513 AC_DEFINE([HAVE_MENUBARS], [1], [Description here!])
514 AC_DEFINE([HAVE_POPUPS], [1], [Description here!])
515 SXE_ADD_SXEUI_OBJS([menubar.o])
517 if test "$with_scrollbars" != "no"; then
518 AC_DEFINE([HAVE_SCROLLBARS], [1], [Description here!])
519 SXE_ADD_SXEUI_OBJS([scrollbar.o])
521 if test "$with_dialogs" != "no"; then
522 AC_DEFINE([HAVE_DIALOGS], [1], [Description here!])
523 AC_DEFINE([HAVE_POPUPS], [1], [Description here!])
524 SXE_ADD_SXEUI_OBJS([dialog.o])
526 if test "$with_toolbars" != "no"; then
527 AC_DEFINE([HAVE_TOOLBARS], [1], [Description here!])
528 SXE_ADD_SXEUI_OBJS([toolbar.o])
530 if test "$with_widgets" != "no"; then
531 AC_DEFINE([HAVE_WIDGETS], [1], [Description here!])
532 AC_DEFINE([LWLIB_TABS_LUCID], [1], [Description here!])
533 SXE_APPEND([xlwtabs.o xlwgcs.o], [lwlib_objs])
535 AC_SUBST([lwlib_objs])
537 SXE_SUBST_SXEUITTY_OBJS
538 SXE_SUBST_SXEUIX11_OBJS
539 SXE_SUBST_SXEUIGTK_OBJS
541 ])dnl SXE_CHECK_UI_SUFFICIENCY
543 dnl sxe-gui.m4 ends here