+ AC_MSG_CHECKING([if we need -lXp and/or -lSM -lICE])
+ libp_link=""
+ libsm_ice_link=""
+ libs_found=0
+ for libp in "" " -lXp"; do
+ if test "$libs_found" = "0"; then
+ for libsm_ice in " -lSM -lICE"; do
+ if test "$libs_found" = "0"; then
+ save_LIBS="$LIBS"
+ LIBS="$GUI_TK_LIBRARY -lXm${xpm_link} ${libp} -lXmu -lXext -lXt${libsm_ice} -lX11"
+ save_CFLAGS=$CFLAGS
+ CFLAGS="$CFLAGS $TOOLKIT_INCLUDE"
+
+ AC_TRY_LINK(
+ [
+ #include <Xm/Xm.h>
+ #include <Xm/List.h>
+ ],
+ [
+ XmString string = NULL;
+ Widget w = NULL;
+ int position = 0;
+ XmListAddItem(w, string, position);
+ ],
+ [
+ libp_link="$libp"
+ libsm_ice_link="$libsm_ice"
+ AC_MSG_RESULT(
+ [need${libp_link}${libsm_ice_link}])
+ libs_found=1
+ ], []
+ )
+
+ LIBS="$save_LIBS"
+ CFLAGS=$save_CFLAGS
+ fi
+ done
+ fi
+ done
+
+ if test "$libs_found" = "0"; then
+ AC_MSG_RESULT([can't find the right libraries])
+ AC_MSG_ERROR([can't link a simple motif program])
+ fi
+
+ GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lXm$xpm_link${libp_link} -lXmu -lXext -lXt${libsm_ice_link} -lX11"