aboutsummaryrefslogtreecommitdiffstats
path: root/main/motif
diff options
context:
space:
mode:
authorIsaac Dunham <ibid.ag@gmail.com>2014-11-09 12:34:22 -0800
committerNatanael Copa <ncopa@alpinelinux.org>2014-11-11 08:04:31 +0100
commit882b99e9a7e4725d560c06f84469664aec7fe933 (patch)
tree2240ae9252238ac53b17a4a7545fc6a6854229be /main/motif
parenta7cd27edd7761a375740ed7fc1d8619c13049d68 (diff)
downloadaports-882b99e9a7e4725d560c06f84469664aec7fe933.tar.bz2
aports-882b99e9a7e4725d560c06f84469664aec7fe933.tar.xz
main/motif: move from testing
Diffstat (limited to 'main/motif')
-rw-r--r--main/motif/01-fix-autoconf.patch47
-rw-r--r--main/motif/02-fix-format-security.patch607
-rw-r--r--main/motif/03-no-demos.patch53
-rw-r--r--main/motif/06-cast-size_t-to-int.patch17
-rw-r--r--main/motif/07-fix_lintian_reported_manpage_typos.patch118
-rw-r--r--main/motif/08-fix_hyphen_in_man_pages.patch156
-rw-r--r--main/motif/09-fix_typo_in_libxm.patch25
-rw-r--r--main/motif/10-fix_manpage-has-bad-whatis-entry.patch49
-rw-r--r--main/motif/11-fix_underlinking.patch564
-rw-r--r--main/motif/12-fix_buffer_overrun_in_libxm.patch17
-rw-r--r--main/motif/13-fix_hardcoded_x11rgb_path.patch54
-rw-r--r--main/motif/14-fix_ac_find_xft.patch91
-rw-r--r--main/motif/15-link_uil_against_libuil.patch29
-rw-r--r--main/motif/16-fix-undefined-use-of-sprintf.patch17
-rw-r--r--main/motif/17-switch-to-system-iswspace.patch384
-rw-r--r--main/motif/18-updated-fix-1565.patch431
-rw-r--r--main/motif/APKBUILD135
17 files changed, 2794 insertions, 0 deletions
diff --git a/main/motif/01-fix-autoconf.patch b/main/motif/01-fix-autoconf.patch
new file mode 100644
index 0000000000..325707a18b
--- /dev/null
+++ b/main/motif/01-fix-autoconf.patch
@@ -0,0 +1,47 @@
+Description: Update build system to satisfy latest automake/autoconf
+ This is part of the patch submitted by Adam Sampson,
+ so we can build without having to provide AUTHORS and NEWS files
+ .
+ Adam licensed his patch under MIT license (whatever that means ;) )
+Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1571
+Author: Adam Sampson <ats-motif@offog.org>
+Author: Graham Inggs <graham@nerve.org.za>
+Last-Update: 2012-12-25
+--- a/configure.ac
++++ b/configure.ac
+@@ -1,8 +1,13 @@
+ dnl Process this file with autoconf to produce a configure script.
+-AC_INIT
++AC_PREREQ(2.59)
++AC_INIT([motif], [2.3.4])
+ AC_CONFIG_SRCDIR([lib/Xm/Form.c])
+-AC_PREREQ(2.52)
+ AC_CONFIG_AUX_DIR(.)
++AC_CANONICAL_TARGET
++
++AM_INIT_AUTOMAKE([foreign no-define])
++dnl AM_MAINTAINER_MODE
++
+ AC_CHECK_FILE(/usr/X/include/X11/X.h,
+ AC_PREFIX_DEFAULT(/usr/X),
+ AC_PREFIX_DEFAULT(/usr))
+@@ -10,9 +15,6 @@
+ AC_PREFIX_DEFAULT(/usr/X11R6),
+ AC_PREFIX_DEFAULT(/usr))
+
+-dnl AM_MAINTAINER_MODE
+-AC_CANONICAL_TARGET
+-
+ dnl The version of the Motif libraries
+ CURRENT=4
+ REVISION=4
+@@ -21,9 +23,6 @@
+ AC_SUBST(REVISION)
+ AC_SUBST(AGE)
+
+-dnl This is really dumb but it seems to be bug
+-AM_INIT_AUTOMAKE(motif,2.3.4,no-define)
+-
+ LIBTOOL_VERSION=$CURRENT:$REVISION:$AGE
+
+ dnl
diff --git a/main/motif/02-fix-format-security.patch b/main/motif/02-fix-format-security.patch
new file mode 100644
index 0000000000..18c4abdc27
--- /dev/null
+++ b/main/motif/02-fix-format-security.patch
@@ -0,0 +1,607 @@
+Description: Fix unsafe uses of fprintf and sprintf
+ prevent 'format not a string literal and no format arguments' errors
+Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1574
+Author: Graham Inggs <graham@nerve.org.za>
+Last-Update: 2012-12-25
+--- a/lib/Mrm/Mrmhier.c
++++ b/lib/Mrm/Mrmhier.c
+@@ -264,10 +264,10 @@
+ case MrmSUCCESS:
+ break;
+ case MrmNOT_VALID:
+- sprintf (err_stg, _MrmMMsg_0113);
++ sprintf (err_stg, "%s", _MrmMMsg_0113);
+ break;
+ default:
+- sprintf (err_stg, _MrmMMsg_0114);
++ sprintf (err_stg, "%s", _MrmMMsg_0114);
+ break;
+ }
+ }
+--- a/lib/Mrm/Mrmicon.c
++++ b/lib/Mrm/Mrmicon.c
+@@ -1176,7 +1176,7 @@
+ }
+ break;
+ default:
+- sprintf(err_msg, _MrmMMsg_0040);
++ sprintf(err_msg, "%s", _MrmMMsg_0040);
+ return Urm__UT_Error ("Urm__RelizeColorTable",
+ err_msg, NULL, NULL, MrmFAILURE) ;
+ }
+@@ -1252,7 +1252,7 @@
+ break;
+ default:
+ result = MrmFAILURE;
+- sprintf (err_msg, _MrmMMsg_0040);
++ sprintf (err_msg, "%s", _MrmMMsg_0040);
+ Urm__UT_Error ("Urm__RelizeColorTable",
+ err_msg, NULL, NULL, MrmFAILURE) ;
+ }
+--- a/lib/Mrm/Mrmlread.c
++++ b/lib/Mrm/Mrmlread.c
+@@ -698,7 +698,7 @@
+ XBlackPixelOfScreen(XDefaultScreenOfDisplay(display)));
+ break;
+ default:
+- sprintf(err_msg, _MrmMMsg_0040);
++ sprintf(err_msg, "%s", _MrmMMsg_0040);
+ result = Urm__UT_Error ("MrmFetchColorLiteral",
+ err_msg, NULL, NULL, MrmFAILURE) ;
+ _MrmAppUnlock(app);
+--- a/lib/Mrm/Mrmwcrw.c
++++ b/lib/Mrm/Mrmwcrw.c
+@@ -1390,7 +1390,7 @@
+ }
+ break;
+ default:
+- sprintf (err_msg, _MrmMMsg_0040);
++ sprintf (err_msg, "%s", _MrmMMsg_0040);
+ result = Urm__UT_Error ("Urm__CW_ConvertValue",
+ err_msg, NULL, NULL, MrmFAILURE) ;
+ };
+@@ -2426,7 +2426,7 @@
+ }
+ break;
+ default:
+- sprintf(err_msg, _MrmMMsg_0040);
++ sprintf(err_msg, "%s", _MrmMMsg_0040);
+ return Urm__UT_Error ("Urm__CW_ConvertValue",
+ err_msg, NULL, NULL, MrmFAILURE) ;
+ };
+--- a/tools/wml/wmlouth.c
++++ b/tools/wml/wmlouth.c
+@@ -225,12 +225,12 @@
+ printf ("\nCouldn't open UilSymGen.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
++fprintf (outfil, "%s", canned_warn);
+
+ /*
+ * Write the sym_k..._object literals
+ */
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned1);
+ for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
+ {
+ clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
+@@ -244,7 +244,7 @@
+ /*
+ * Define the sym_k_..._reason literals
+ */
+-fprintf (outfil, canned3);
++fprintf (outfil, "%s", canned3);
+ for ( ndx=0 ; ndx<wml_obj_reason_ptr->cnt ; ndx++ )
+ {
+ resobj = (WmlResourceDefPtr) wml_obj_reason_ptr->hvec[ndx].objptr;
+@@ -258,7 +258,7 @@
+ /*
+ * Define the sym_k_..._arg literals
+ */
+-fprintf (outfil, canned4);
++fprintf (outfil, "%s", canned4);
+ for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
+ {
+ resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
+@@ -272,7 +272,7 @@
+ /*
+ * Define the sym_k_..._enumset structs and literals
+ */
+-fprintf (outfil, canned5);
++fprintf (outfil, "%s", canned5);
+ for ( ndx=0 ; ndx<wml_obj_enumset_ptr->cnt ; ndx++ )
+ {
+ enumsetobj = (WmlEnumSetDefPtr) wml_obj_enumset_ptr->hvec[ndx].objptr;
+@@ -286,7 +286,7 @@
+ /*
+ * Define the sym_k_..._enumval literals
+ */
+-fprintf (outfil, canned6);
++fprintf (outfil, "%s", canned6);
+ for ( ndx=0 ; ndx<wml_obj_enumval_ptr->cnt ; ndx++ )
+ {
+ enumvalobj = (WmlEnumValueDefPtr) wml_obj_enumval_ptr->hvec[ndx].objptr;
+@@ -301,7 +301,7 @@
+ * Define the sym_k_..._charsize literals
+ * Define the sym_k_..._charset literals
+ */
+-fprintf (outfil, canned7);
++fprintf (outfil, "%s", canned7);
+ for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
+ {
+ charsetobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
+@@ -315,7 +315,7 @@
+ /*
+ * Define the sym_k_..._child literals
+ */
+-fprintf (outfil, canned8);
++fprintf (outfil, "%s", canned8);
+ for ( ndx=0 ; ndx<wml_obj_child_ptr->cnt ; ndx++ )
+ {
+ childobj = (WmlChildDefPtr) wml_obj_child_ptr->hvec[ndx].objptr;
+@@ -379,12 +379,12 @@
+ printf ("\nCouldn't open UilSymChCL.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
++fprintf (outfil, "%s", canned_warn);
+
+ /*
+ * Create table entries, similar to writing sym_k...
+ */
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned1);
+ for ( ndx=0 ; ndx<wml_obj_child_ptr->cnt ; ndx++ )
+ {
+ childobj = (WmlChildDefPtr) wml_obj_child_ptr->hvec[ndx].objptr;
+@@ -392,7 +392,7 @@
+ fprintf (outfil, " sym_k_%s_object,\n",
+ classobj->tkname);
+ }
+-fprintf (outfil, canned1a);
++fprintf (outfil, "%s", canned1a);
+
+ /*
+ * close the output file
+@@ -446,12 +446,12 @@
+ printf ("\nCouldn't open UilSymArTy.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
++fprintf (outfil, "%s", canned_warn);
+
+ /*
+ * Create table entries, similar to writing sym_k...
+ */
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned1);
+ for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
+ {
+ resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
+@@ -459,7 +459,7 @@
+ fprintf (outfil, " sym_k_%s_value,\n",
+ datobj->tkname);
+ }
+-fprintf (outfil, canned1a);
++fprintf (outfil, "%s", canned1a);
+
+ /*
+ * close the output file
+@@ -509,19 +509,19 @@
+ printf ("\nCouldn't open UilSymRArg.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
++fprintf (outfil, "%s", canned_warn);
+
+ /*
+ * Create table entries, similar to writing sym_k...
+ */
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned1);
+ for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
+ {
+ resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
+ fprintf (outfil, " %d,\n",
+ resobj->related_code);
+ }
+-fprintf (outfil, canned1a);
++fprintf (outfil, "%s", canned1a);
+
+ /*
+ * close the output file
+@@ -621,12 +621,12 @@
+ printf ("\nCouldn't open UilUrmClas.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
++fprintf (outfil, "%s", canned_warn);
+
+ /*
+ * Write entries for widgets
+ */
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned1);
+ for ( ndx=0 ; ndx<wml_obj_class_ptr->cnt ; ndx++ )
+ {
+ clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ndx].objptr;
+@@ -637,7 +637,7 @@
+ else
+ fprintf (outfil, " \"%s\",\t\n", synobj->convfunc);
+ }
+-fprintf (outfil, canned2);
++fprintf (outfil, "%s", canned2);
+
+ /*
+ * Write entries for gadget variants of widget classes
+@@ -661,7 +661,7 @@
+ synobj->name);
+ }
+ }
+-fprintf (outfil, canned3);
++fprintf (outfil, "%s", canned3);
+
+ /*
+ * Write entries for non-dialog widgets
+@@ -685,7 +685,7 @@
+ synobj->name);
+ }
+ }
+-fprintf (outfil, canned4);
++fprintf (outfil, "%s", canned4);
+
+ /*
+ * Write entries for the resource a widget's controls map to
+@@ -701,7 +701,7 @@
+ else
+ fprintf (outfil, " sym_k_%s_arg,\n", mapresobj->tkname);
+ }
+-fprintf (outfil, canned5);
++fprintf (outfil, "%s", canned5);
+
+ /*
+ * Write entries for arguments
+@@ -714,7 +714,7 @@
+ fprintf (outfil, " %s,\n",
+ synres->resliteral);
+ }
+-fprintf (outfil, canned6);
++fprintf (outfil, "%s", canned6);
+
+ /*
+ * Write entries for reasons
+@@ -727,7 +727,7 @@
+ fprintf (outfil, " %s,\n",
+ synres->resliteral);
+ }
+-fprintf (outfil, canned7);
++fprintf (outfil, "%s", canned7);
+
+ /*
+ * close the output file
+@@ -781,13 +781,13 @@
+ printf ("\nCouldn't open UilConst.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
++fprintf (outfil, "%s", canned_warn);
+
+ /*
+ * Process the arguments in code order. We start with 1, and write out
+ * the mask after processing 8 codes.
+ */
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned1);
+ strcpy (maskbuf, "0");
+ for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
+ {
+@@ -805,7 +805,7 @@
+ }
+ if ( bitno != 8 )
+ fprintf (outfil, "%s", maskbuf);
+-fprintf (outfil, canned1a);
++fprintf (outfil, "%s", canned1a);
+
+ /*
+ * close the output file
+@@ -878,8 +878,8 @@
+ printf ("\nCouldn't open UilSymReas.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned_warn);
++fprintf (outfil, "%s", canned1);
+
+ /*
+ * Generate the bit vectors for each class. Outer loop on the reason code,
+@@ -925,13 +925,13 @@
+ /*
+ * Write the vector of vectors.
+ */
+-fprintf (outfil, canned2);
++fprintf (outfil, "%s", canned2);
+ for ( resndx=0 ; resndx<wml_obj_reason_ptr->cnt ; resndx++ )
+ {
+ resobj = (WmlResourceDefPtr) wml_obj_reason_ptr->hvec[resndx].objptr;
+ fprintf (outfil, " reason_class_vec%d,\n", resobj->sym_code);
+ }
+-fprintf (outfil, canned3);
++fprintf (outfil, "%s", canned3);
+
+ /*
+ * close the output file
+@@ -1004,8 +1004,8 @@
+ printf ("\nCouldn't open UilSymArTa.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned_warn);
++fprintf (outfil, "%s", canned1);
+
+ /*
+ * Generate the bit vectors for each class. Outer loop on the argument code,
+@@ -1051,13 +1051,13 @@
+ /*
+ * Write the vector of vectors.
+ */
+-fprintf (outfil, canned2);
++fprintf (outfil, "%s", canned2);
+ for ( resndx=0 ; resndx<wml_obj_arg_ptr->cnt ; resndx++ )
+ {
+ resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[resndx].objptr;
+ fprintf (outfil, " arg_class_vec%d,\n", resobj->sym_code);
+ }
+-fprintf (outfil, canned3);
++fprintf (outfil, "%s", canned3);
+
+ /*
+ * close the output file
+@@ -1129,8 +1129,8 @@
+ printf ("\nCouldn't open UilSymChTa.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned_warn);
++fprintf (outfil, "%s", canned1);
+
+ /*
+ * Generate the bit vectors for each class. Outer loop on the child code,
+@@ -1174,13 +1174,13 @@
+ /*
+ * Write the vector of vectors.
+ */
+-fprintf (outfil, canned2);
++fprintf (outfil, "%s", canned2);
+ for ( childndx=0 ; childndx<wml_obj_child_ptr->cnt ; childndx++ )
+ {
+ childobj = (WmlChildDefPtr) wml_obj_child_ptr->hvec[childndx].objptr;
+ fprintf (outfil, " child_class_vec%d,\n", childobj->sym_code);
+ }
+-fprintf (outfil, canned3);
++fprintf (outfil, "%s", canned3);
+
+ /*
+ * close the output file
+@@ -1251,8 +1251,8 @@
+ printf ("\nCouldn't open UilSymCtl.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned_warn);
++fprintf (outfil, "%s", canned1);
+
+ /*
+ * Generate the bit vectors for each class. Outer loop on the class code,
+@@ -1296,13 +1296,13 @@
+ /*
+ * Write the vector of vectors.
+ */
+-fprintf (outfil, canned2);
++fprintf (outfil, "%s", canned2);
+ for ( ctlndx=0 ; ctlndx<wml_obj_class_ptr->cnt ; ctlndx++ )
+ {
+ clsobj = (WmlClassDefPtr) wml_obj_class_ptr->hvec[ctlndx].objptr;
+ fprintf (outfil, " object_class_vec%d,\n", clsobj->sym_code);
+ }
+-fprintf (outfil, canned3);
++fprintf (outfil, "%s", canned3);
+
+ /*
+ * close the output file
+@@ -1438,7 +1438,7 @@
+ printf ("\nCouldn't open UilSymNam.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
++fprintf (outfil, "%s", canned_warn);
+
+ /*
+ * Write entries for widgets
+@@ -1517,7 +1517,7 @@
+ fprintf (outfil, " \"%s\",\n",
+ synch->name);
+ }
+-fprintf (outfil, canned7);
++fprintf (outfil, "%s", canned7);
+
+ /*
+ * close the output file
+@@ -1621,12 +1621,12 @@
+ printf ("\nCouldn't open UilSymEnum.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
++fprintf (outfil, "%s", canned_warn);
+
+ /*
+ * Generate the enumeration value vectors for each enumeration set.
+ */
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned1);
+ for ( ndx=0 ; ndx<wml_obj_enumset_ptr->cnt ; ndx++ )
+ {
+ enumsetobj = (WmlEnumSetDefPtr) wml_obj_enumset_ptr->hvec[ndx].objptr;
+@@ -1643,7 +1643,7 @@
+ /*
+ * Generate the enumeration set tables
+ */
+-fprintf (outfil, canned3);
++fprintf (outfil, "%s", canned3);
+ for ( ndx=0 ; ndx<wml_obj_enumset_ptr->cnt ; ndx++ )
+ {
+ enumsetobj = (WmlEnumSetDefPtr) wml_obj_enumset_ptr->hvec[ndx].objptr;
+@@ -1655,7 +1655,7 @@
+ /*
+ * Create enumset table entries for arguments, similar to writing sym_k...
+ */
+-fprintf (outfil, canned4);
++fprintf (outfil, "%s", canned4);
+ for ( ndx=0 ; ndx<wml_obj_arg_ptr->cnt ; ndx++ )
+ {
+ resobj = (WmlResourceDefPtr) wml_obj_arg_ptr->hvec[ndx].objptr;
+@@ -1669,13 +1669,13 @@
+ /*
+ * Create the enumval values table.
+ */
+-fprintf (outfil, canned5);
++fprintf (outfil, "%s", canned5);
+ for ( ndx=0 ; ndx<wml_obj_enumval_ptr->cnt ; ndx++ )
+ {
+ evobj = (WmlEnumValueDefPtr) wml_obj_enumval_ptr->hvec[ndx].objptr;
+ fprintf (outfil, " %s,\n", evobj->syndef->enumlit);
+ }
+-fprintf (outfil, canned5a);
++fprintf (outfil, "%s", canned5a);
+
+ /*
+ * close the output file
+@@ -1813,12 +1813,12 @@
+ printf ("\nCouldn't open UilSymCSet.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
++fprintf (outfil, "%s", canned_warn);
+
+ /*
+ * Generate the standards name table
+ */
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned1);
+ for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
+ {
+ csobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
+@@ -1836,7 +1836,7 @@
+ /*
+ * Generate the writing direction table
+ */
+-fprintf (outfil, canned2);
++fprintf (outfil, "%s", canned2);
+ for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
+ {
+ csobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
+@@ -1858,7 +1858,7 @@
+ /*
+ * Generate the parsing direction table
+ */
+-fprintf (outfil, canned3);
++fprintf (outfil, "%s", canned3);
+ for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
+ {
+ csobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
+@@ -1880,7 +1880,7 @@
+ /*
+ * Generate the character size table
+ */
+-fprintf (outfil, canned4);
++fprintf (outfil, "%s", canned4);
+ for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
+ {
+ csobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
+@@ -1906,7 +1906,7 @@
+ /*
+ * Generate the $LANG name recognition table
+ */
+-fprintf (outfil, canned5);
++fprintf (outfil, "%s", canned5);
+ lang_max = 0;
+ for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
+ {
+@@ -1936,7 +1936,7 @@
+ /*
+ * Generate the $LANG code lookup table, in upper case
+ */
+-fprintf (outfil, canned6);
++fprintf (outfil, "%s", canned6);
+ for ( ndx=0 ; ndx<wml_obj_charset_ptr->cnt ; ndx++ )
+ {
+ csobj = (WmlCharSetDefPtr) wml_obj_charset_ptr->hvec[ndx].objptr;
+--- a/tools/wml/wmloutkey.c
++++ b/tools/wml/wmloutkey.c
+@@ -574,16 +574,16 @@
+ printf ("\nCouldn't open UilKeyTab.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
++fprintf (outfil, "%s", canned_warn);
+
+ /*
+ * Print the case sensitive and insensitive tables
+ */
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned1);
+ wmlOutputUilKeyTabBody (outfil, wml_tok_sens_ptr, &maxlen, &maxkey);
+ fprintf (outfil, canned2, maxlen, maxkey);
+ wmlOutputUilKeyTabBody (outfil, wml_tok_insens_ptr, &maxlen, &maxkey);
+-fprintf (outfil, canned3);
++fprintf (outfil, "%s", canned3);
+
+ /*
+ * close the output file
+@@ -812,8 +812,8 @@
+ printf ("\nCouldn't open UilTokName.h");
+ return;
+ }
+-fprintf (outfil, canned_warn);
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned_warn);
++fprintf (outfil, "%s", canned1);
+
+ /*
+ * Print the token name entries
+--- a/tools/wml/wmloutmm.c
++++ b/tools/wml/wmloutmm.c
+@@ -209,9 +209,9 @@
+ /*
+ * Write out header information
+ */
+-fprintf (outfil, canned1);
++fprintf (outfil, "%s", canned1);
+ fprintf (outfil, "%s\n", name);
+-fprintf (outfil, canned2);
++fprintf (outfil, "%s", canned2);
+
+ /*
+ * Alphabetize the controls, reason, and argument lists
+@@ -287,7 +287,7 @@
+ else
+ fprintf (outfil, "\n");
+ }
+-fprintf (outfil, canned3);
++fprintf (outfil, "%s", canned3);
+
+ /*
+ * Write out the argument table
+@@ -323,7 +323,7 @@
+ }
+ argndx += 1;
+ }
+-fprintf (outfil, canned4);
++fprintf (outfil, "%s", canned4);
+
+ }
+
diff --git a/main/motif/03-no-demos.patch b/main/motif/03-no-demos.patch
new file mode 100644
index 0000000000..03953c4f8f
--- /dev/null
+++ b/main/motif/03-no-demos.patch
@@ -0,0 +1,53 @@
+Description: Add option to disable building of demos
+Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1575
+Author: Graham Inggs <graham@nerve.org.za>
+Last-Update: 2013-01-09
+--- a/configure.ac
++++ b/configure.ac
+@@ -311,7 +311,20 @@
+ doc/man/man5/Makefile \
+ tools/Makefile \
+ tools/wml/Makefile \
+-demos/Makefile \
++lib/Xm/xmstring.list \
++])
++
++AC_ARG_ENABLE(demos, [ --disable-demos
++ Disable building demos])
++
++if test x$enable_demos = x
++then
++ enable_demos="yes"
++fi
++
++if test "$enable_demos" = "yes"
++then
++ AC_CONFIG_FILES([demos/Makefile
+ demos/lib/Makefile \
+ demos/lib/Xmd/Makefile \
+ demos/lib/Wsm/Makefile \
+@@ -395,6 +408,11 @@
+ demos/doc/programGuide/ch17/Makefile \
+ demos/doc/programGuide/ch17/simple_drop/Makefile \
+ demos/doc/programGuide/ch17/simple_drag/Makefile \
+-lib/Xm/xmstring.list \
+-])
++ ])
++ MAYBE_DEMOS=demos
++else
++ MAYBE_DEMOS=
++fi
++AC_SUBST(MAYBE_DEMOS)
++
+ AC_OUTPUT
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -29,6 +29,7 @@
+ tools \
+ clients \
+ doc \
+- demos
++ $(MAYBE_DEMOS)
++
+ AUTOMAKE_OPTIONS = 1.4
+ ACLOCAL_AMFLAGS = -I .
diff --git a/main/motif/06-cast-size_t-to-int.patch b/main/motif/06-cast-size_t-to-int.patch
new file mode 100644
index 0000000000..b5ce9c643a
--- /dev/null
+++ b/main/motif/06-cast-size_t-to-int.patch
@@ -0,0 +1,17 @@
+Description: To prevent build failure during building with Hardening options
+ enabled due to "format '%d' expects argument of type 'int', but argument 5 has
+ type 'size_t'", the fifth argument is cast to integer on the input.
+Author: Paul Gevers <elbrus@debian.org>
+Updated: 13-01-2013
+
+--- a/tools/wml/wmloutkey.c
++++ b/tools/wml/wmloutkey.c
+@@ -627,7 +627,7 @@
+ fprintf (outfil, " {%s, %s, %d, %s, \"%s\"},\n",
+ tkclass,
+ tksym,
+- strlen(tokstg),
++ (int)strlen(tokstg),
+ tktoken,
+ tokstg);
+ if ( (int)strlen(tokstg) > *maxlen )
diff --git a/main/motif/07-fix_lintian_reported_manpage_typos.patch b/main/motif/07-fix_lintian_reported_manpage_typos.patch
new file mode 100644
index 0000000000..5ddfd76007
--- /dev/null
+++ b/main/motif/07-fix_lintian_reported_manpage_typos.patch
@@ -0,0 +1,118 @@
+Description: lintian reports several typos in manpages. This patch fixes those
+ reported
+Author: Paul Gevers <elbrus@debian.org>
+Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1587
+Last-reviewed: 14 Jan 2013
+
+--- a/doc/man/man1/mwm.1
++++ b/doc/man/man1/mwm.1
+@@ -359,7 +359,7 @@
+ (and other associated messages) by saving the geometries of its clients to a state file\&.
+ \fBmwm\fP can then be restarted by the XSMP session manager\&.
+ The default location for the state file is \fB$HOME/\&.mwmclientdb\fP\&.
+-This location can be overriden with the resource \fBsessionClientDB\fP\&.
++This location can be overridden with the resource \fBsessionClientDB\fP\&.
+ .SS "X Resources"
+ .PP
+ The \fBmwm\fP command is configured from its resource
+--- a/doc/man/man3/VendorShell.3
++++ b/doc/man/man3/VendorShell.3
+@@ -76,7 +76,7 @@
+ to the VendorShell resources for controlling toolTips. VendorShell displays
+ the XmNtooTipString in an XmLabel that is a child of a transientShell. The name
+ of the transientShell is TipShell, and the name of the XmLabel is TipLabel.
+-The appearance of the tip can be controlled by specifing resources on these
++The appearance of the tip can be controlled by specifying resources on these
+ widgets.
+ .PP
+ If an application uses the \fBXmNmwmDecorations\fP,
+--- a/doc/man/man3/XmComboBox.3
++++ b/doc/man/man3/XmComboBox.3
+@@ -581,7 +581,7 @@
+ ComboBox \fBXmNcomboBoxType\fP is
+ \fBXmDROP_DOWN_LIST\fP,
+ \fB<osfActivate>\fP, \fB<osfCancel>\fP, and
+-\fBReturn\fP are overriden by ComboBox actions\&.
++\fBReturn\fP are overridden by ComboBox actions\&.
+ .IP "\fB:c\fP <Key>\fB<osfDown>\fP:" 10
+ CBDropDownList()
+ .IP "\fB:c\fP <Key>\fB<osfUp>\fP:" 10
+--- a/doc/man/man3/XmGetPixmap.3
++++ b/doc/man/man3/XmGetPixmap.3
+@@ -109,7 +109,7 @@
+ In addition to X bitmap files (XBM), Motif also supports XPM (X
+ Pixmap) file formats and, from version 2.3, JPEG and PNG image formats\&.
+ (Note that support of JPEG and PNG image format is an optional feature
+-of Motif, in order to check if current version supports PNG ang JPEG
++of Motif, in order to check if current version supports PNG and JPEG
+ image formats the PNG_SUPPORT and JPEG_SUPPORT macros should be checked
+ correspondingly.)
+ The \fBXBMLANGPATH\fP specifies the path for
+--- a/doc/man/man3/XmGetPixmapByDepth.3
++++ b/doc/man/man3/XmGetPixmapByDepth.3
+@@ -111,7 +111,7 @@
+ In addition to X bitmap files (XBM), Motif also supports XPM (X
+ Pixmap) file formats, and, from version 2.3, JPEG and PNG image formats\&.
+ (Note that support of JPEG and PNG image format is an optional feature
+-of Motif, in order to check if current version supports PNG ang JPEG
++of Motif, in order to check if current version supports PNG and JPEG
+ image formats the PNG_SUPPORT and JPEG_SUPPORT macros should be checked
+ correspondingly.)
+ The \fBXBMLANGPATH\fP specifies the path for
+--- a/doc/man/man3/XmHierarchyGetChildNodes.3
++++ b/doc/man/man3/XmHierarchyGetChildNodes.3
+@@ -69,8 +69,8 @@
+ \fBXmHierarchy\fP(3)\&.
+ .SH "RETURN"
+ .PP
+-Returns WidgetList with child nodes of the hierachy, or NULL
+-if the hierachy contains no children\&.
++Returns WidgetList with child nodes of the hierarchy, or NULL
++if the hierarchy contains no children\&.
+ .SH "RELATED"
+ .PP
+ \fBXmHierarchy\fP(3)\&.
+--- a/doc/man/man3/XmManager.3
++++ b/doc/man/man3/XmManager.3
+@@ -502,7 +502,7 @@
+ Indicates whether the posting process should continue\&. The
+ application may modify this field\&.
+ .IP "\fItarget\fP" 10
+-Specifies the most specific widget or gadget that the menu sytem found
++Specifies the most specific widget or gadget that the menu system found
+ from the event that matches the event\&.
+ .SS "Translations"
+ .PP
+--- a/doc/man/man3/XmPrimitive.3
++++ b/doc/man/man3/XmPrimitive.3
+@@ -609,7 +609,7 @@
+ Indicates whether the posting process should continue\&. The
+ application may modify this field\&.
+ .IP "\fItarget\fP" 10
+-Specifies the most specific widget or gadget that the menu sytem found
++Specifies the most specific widget or gadget that the menu system found
+ from the event that matches the event\&.
+ .SS "Translations"
+ .PP
+--- a/doc/man/man3/XmRendition.3
++++ b/doc/man/man3/XmRendition.3
+@@ -71,7 +71,7 @@
+ If a resource in a rendition is unspecified, usually by setting it to
+ \fBXmAS_IS\fP or \fBXmUNSPECIFIED_PIXEL\fP,
+ then the value to be used for that resource is the value of the
+-immediately preceeding rendition in \fBXmString\fR\&. If that value
++immediately preceding rendition in \fBXmString\fR\&. If that value
+ is unspecified, then the preceding value is used, and so on\&. If
+ no renditions specify a value for a resource, then a default value
+ will be used\&.
+--- a/doc/man/man3/XmStringGetNextComponent.3
++++ b/doc/man/man3/XmStringGetNextComponent.3
+@@ -111,7 +111,7 @@
+ \fBXmSTRING_COMPONENT_UNKNOWN\fP\&. The data returned by these
+ components is returned in the \fIunknown_tag\fP, \fIunknown_length\fP,
+ and \fIunknown_value\fP fields\&. This apparent inconsistency is
+-designed to accomodate older applications that may not be equipped to
++designed to accommodate older applications that may not be equipped to
+ handle the newer component types of Motif version 2\&.0 and beyond\&.
+ Consequently, the use of this procedure is not recommended\&. Instead,
+ use the \fBXmStringGetNextTriple\fP procedure, which provides all the
diff --git a/main/motif/08-fix_hyphen_in_man_pages.patch b/main/motif/08-fix_hyphen_in_man_pages.patch
new file mode 100644
index 0000000000..bc1beb029c
--- /dev/null
+++ b/main/motif/08-fix_hyphen_in_man_pages.patch
@@ -0,0 +1,156 @@
+Description: lintian reports hyphen misuse in manpages. This patch fixes those
+ reported.
+Author: Paul Gevers <elbrus@debian.org>
+Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1588
+Last-reviewed: 06 Feb 2013
+
+--- a/doc/man/man1/mwm.1
++++ b/doc/man/man1/mwm.1
+@@ -904,7 +904,7 @@
+ resizeCursorsResizeCursorsT/FT
+ transientDecorationTransientDecorationstringmenu title
+ transientFunctionsTransientFunctionsstringT{
+--minimize-maximize
++\-minimize-maximize
+ T}
+ useIconBoxUseIconBoxT/FF
+ .TE
+@@ -941,7 +941,7 @@
+ screen size of the icon box window depends on the iconImageMaximum (size)
+ and \fIiconDecoration\fP resources\&. The default value for size
+ is (6 * iconWidth + padding) wide by (1 * iconHeight + padding) high\&. The
+-default value of the location is +0 -0\&.
++default value of the location is +0 \-0\&.
+ .IP "\fIiconBoxName\fP\ (class\ \fIIconBoxName\fP)" 10
+ This resource specifies the name that is used to look up icon box resources\&.
+ The default name is iconbox\&.
+@@ -1059,7 +1059,7 @@
+ This resource is used to indicate which window management functions
+ are applicable (or not applicable) to transient windows\&. The function specification
+ is exactly the same as for the \fIclientFunctions\fP (client
+-specific) resource\&. The default value for this resource is -minimize -maximize\&.
++specific) resource\&. The default value for this resource is \-minimize \-maximize\&.
+ .IP "" 10
+ An application can also specify which functions \fBmwm\fP
+ should apply to its windows\&. If it does so, \fBmwm\fP applies
+@@ -1176,7 +1176,7 @@
+ titleTitle bar (includes border)\&.
+ .TE
+ .PP
+-Examples: \fIMwm*XClock\&.clientDecoration: -resizeh -maximize\fP This removes the resize handles and maximize button from XClock
++Examples: \fIMwm*XClock\&.clientDecoration: \-resizeh \-maximize\fP This removes the resize handles and maximize button from XClock
+ windows\&. \fIMwm*XClock\&.clientDecoration: menu minimize border\fP This does the same thing as above\&. Note that either \fImenu\fP or \fIminimize\fP implies
+ \fItitle\fP\&.
+ .IP "\fIclientFunctions\fP\ (class\ \fIClientFunctions\fP)" 10
+--- a/doc/man/man4/mwmrc.4
++++ b/doc/man/man4/mwmrc.4
+@@ -84,7 +84,7 @@
+ be specified from the command line:
+ .PP
+ .nf
+-\f(CW/usr/X11R6/bin/X11/mwm -xrm "mwm*configFile: mymwmrc"\fR
++\f(CW/usr/X11R6/bin/X11/mwm \-xrm "mwm*configFile: mymwmrc"\fR
+ .fi
+ .PP
+ .SS "Resource Types"
+--- a/doc/man/man3/XmFontList.3
++++ b/doc/man/man3/XmFontList.3
+@@ -119,7 +119,7 @@
+ without a font list entry tag;
+ .PP
+ .nf
+-\f(CW*fontList: -Adobe-Times-Medium-I-Normal--10*\fR
++\f(CW*fontList: \-Adobe\-Times\-Medium\-I\-Normal\-\-10*\fR
+ .fi
+ .PP
+ .PP
+@@ -138,9 +138,9 @@
+ and an explicit font list entry tag\&.
+ .PP
+ .nf
+-\f(CW*fontList: -Adobe-Courier-Bold-R-Normal--25-180-100-100-M-150;\
+--JIS-Fixed-Medium-R-Normal--26-180-100-100-C-240;\
+--JIS-Fixed-Medium-R-Normal--26-180-100-100-C-120:MY_TAG\fR
++\f(CW*fontList: \-Adobe\-Courier\-Bold\-R\-Normal\-\-25\-180\-100\-100\-M\-150;\
++\-JIS\-Fixed\-Medium\-R\-Normal\-\-26\-180\-100\-100\-C\-240;\
++\-JIS\-Fixed\-Medium\-R\-Normal\-\-26\-180\-100\-100\-C\-120:MY_TAG\fR
+ .fi
+ .PP
+ .PP
+--- a/doc/man/man3/XmGetPixmapByDepth.3
++++ b/doc/man/man3/XmGetPixmapByDepth.3
+@@ -245,8 +245,8 @@
+ \f(CW/* XBM file */
+ #define plaid_width 22
+ #define plaid_height 22
+-#define plaid_x_hot -1
+-#define plaid_y_hot -1
++#define plaid_x_hot \-1
++#define plaid_y_hot \-1
+ static char plaid_bits[] = {
+ 0x75, 0xfd, 0x3f, 0xaa, 0xfa, 0x3e, 0x75, 0xfd, 0x3f, 0xaa, 0xfa, 0x3e,
+ 0x75, 0xfd, 0x3f, 0xff, 0x57, 0x15, 0x75, 0xfd, 0x3f, 0xaa, 0xfa, 0x3e,
+--- a/doc/man/man3/XmList.3
++++ b/doc/man/man3/XmList.3
+@@ -182,7 +182,7 @@
+ A value of 1 transfers the first item in the List; a value of 2
+ transfers the second item; and so on\&.
+ If the entire contents of the List are being transferred, the value is
+--1\&.
++\-1\&.
+ .PP
+ As a source of data, List supports the following targets and associated
+ conversions of data to these targets:
+--- a/doc/man/man3/XmScreen.3
++++ b/doc/man/man3/XmScreen.3
+@@ -300,7 +300,7 @@
+ startup time, either by placing it within a defaults file or by using the
+ \fB-xrm\fP command line argument\&. For example:
+ .IP "" 10
+-\fBmyProg -xrm "*menuCursor: arrow"\fP
++\fBmyProg \-xrm "*menuCursor: arrow"\fP
+ .IP "" 10
+ The menu cursor can also be selected in the program through
+ the function \fBXmSetMenuCursor\fP\&.
+--- a/doc/man/man3/XmTabListCopy.3
++++ b/doc/man/man3/XmTabListCopy.3
+@@ -71,7 +71,7 @@
+ Specifies where to start copying\&. A value of 0 (zero) indicates begin
+ at the beginning, a value of 1 indicates to skip the first tab, and so
+ on\&. A negative indicates to begin counting backwards from the end\&.
+-A value of -1 indicates to start copying from the last tab\&.
++A value of \-1 indicates to start copying from the last tab\&.
+ .IP "\fIcount\fP" 10
+ Specifies the number of tabs to copy\&. A value of 0 (zero) indicates
+ to copy all elements from the starting point to the end (beginning if
+--- a/doc/man/man3/XmTabListInsertTabs.3
++++ b/doc/man/man3/XmTabListInsertTabs.3
+@@ -83,7 +83,7 @@
+ value of 1 makes it the second tab, and so on\&. If \fIposition\fP is
+ greater than the number of tabs in \fIoldlist\fP, then the tabs will
+ be inserted at the end\&. If \fIposition\fP is negative, the count will
+-be backwards from the end\&. A value of -1 makes the first new tab
++be backwards from the end\&. A value of \-1 makes the first new tab
+ the last tab, and so on\&.
+ .SH "RETURN"
+ .PP
+--- a/doc/man/man5/UIL.5
++++ b/doc/man/man5/UIL.5
+@@ -1211,7 +1211,7 @@
+ 3\&.1415E-2 (equals \&.031415)
+ T}2\&.87 e6 (embedded blanks)
+ T{
+--6\&.29e7 (equals -62900000)
++\-6\&.29e7 (equals \-62900000)
+ T}2\&.0e100 (out of range)
+ .TE
+ .PP
+@@ -1322,7 +1322,7 @@
+ You can use parentheses to override the normal precedence of operators\&.
+ In a sequence of unary operators, the operations are performed in
+ right-to-left
+-order\&. For example, \fB- + -A\fP is equivalent to \fB-(+(-A))\fP\&.
++order\&. For example, \fB- + \-A\fP is equivalent to \fB\-(+(\-A))\fP\&.
+ In a sequence of binary operators of the same precedence, the operations
+ are performed in left-to-right order\&. For example, \fBA*B/C*D\fP is
+ equivalent to \fB((A*B)/C)*D\fP\&.
diff --git a/main/motif/09-fix_typo_in_libxm.patch b/main/motif/09-fix_typo_in_libxm.patch
new file mode 100644
index 0000000000..90d39a3f0c
--- /dev/null
+++ b/main/motif/09-fix_typo_in_libxm.patch
@@ -0,0 +1,25 @@
+Description: lintian reports a typo in libXm. This patch fixes it.
+Author: Paul Gevers <elbrus@debian.org>
+Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1589
+Last-reviewed: 06 Feb 2013
+
+--- a/lib/Xm/FontS.c
++++ b/lib/Xm/FontS.c
+@@ -1225,7 +1225,7 @@
+
+ if ((fontdata = XLoadQueryFont(XtDisplay((Widget) fsw), font)) == NULL)
+ {
+- sprintf(buf, "Font '%s'\nis not availiable on this machine", font);
++ sprintf(buf, "Font '%s'\nis not available on this machine", font);
+ DisplayUserError(fsw, buf);
+ err = True;
+ }
+@@ -1275,7 +1275,7 @@
+ fbuf)) == NULL)
+ {
+ sprintf(buf,
+- "Font '%s'\nis not availiable on this machine",
++ "Font '%s'\nis not available on this machine",
+ font);
+ DisplayUserError(fsw, buf);
+ err = True;
diff --git a/main/motif/10-fix_manpage-has-bad-whatis-entry.patch b/main/motif/10-fix_manpage-has-bad-whatis-entry.patch
new file mode 100644
index 0000000000..cf51d1fa3d
--- /dev/null
+++ b/main/motif/10-fix_manpage-has-bad-whatis-entry.patch
@@ -0,0 +1,49 @@
+Description: lintian reports bad whatis entries in manpages. Fixing here
+Author: Paul Gevers <elbrus@debian.org>
+Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1590
+Last-reviewed: 17 Feb 2013
+
+--- a/doc/man/man3/XmColorSelector.3
++++ b/doc/man/man3/XmColorSelector.3
+@@ -1,7 +1,7 @@
+ .DT
+ .TH XmColorSelector 3X ""
+ .SH NAME
+-The Color Selector widget
++XmColorSelector \- The Color Selector widget
+ .SH SYNOPSIS
+ #include <Xm/ColorS.h>
+ .SH DESCRIPTION
+--- a/doc/man/man3/XmExt18List.3
++++ b/doc/man/man3/XmExt18List.3
+@@ -1,7 +1,7 @@
+ .DT
+ .TH XxExt18LIst 3x ""
+ .SH NAME
+-The Internationalized Extended List widget
++XmExt18List \- The Internationalized Extended List widget
+ .SH SYNOPSIS
+ #include <Xm/Ext18List.h>
+ .SH DESCRIPTION
+--- a/doc/man/man3/XmFontSelector.3
++++ b/doc/man/man3/XmFontSelector.3
+@@ -1,7 +1,7 @@
+ .DT
+ .TH XmFontSelector 3X ""
+ .SH NAME
+-The Font Selector widget
++XmFontSelector \- The Font Selector widget
+ .SH SYNOPSIS
+ #include <Xm/FontS.h>
+ .SH DESCRIPTION
+--- a/doc/man/man3/XmIconButton.3
++++ b/doc/man/man3/XmIconButton.3
+@@ -1,7 +1,7 @@
+ .DT
+ .TH XmIconButton 3X "15 July 1992"
+ .SH NAME
+-The Icon Button widget
++XmIconButton \- The Icon Button widget
+ .SH SYNOPSIS
+ Documents the XmIconButton widget
+ .SH DESCRIPTION
diff --git a/main/motif/11-fix_underlinking.patch b/main/motif/11-fix_underlinking.patch
new file mode 100644
index 0000000000..601b091863
--- /dev/null
+++ b/main/motif/11-fix_underlinking.patch
@@ -0,0 +1,564 @@
+Description: Fix underlinking of libXt, libXext and libX11
+ Recent changes to default linker behaviour prevent shared libraries from being
+ indirectly linked, resulting in FTBFS in Ubuntu Raring.
+ .
+ This patch fixes this by explicitly linking libXt, libXext and libX11 wherever
+ necessary. Demos are patched even though they are not built for distribution.
+Author: Graham Inggs <graham@nerve.org.za>
+Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1583
+Last-Update: 2013-02-26
+--- a/clients/mwm/Makefile.am
++++ b/clients/mwm/Makefile.am
+@@ -9,7 +9,7 @@
+ rc_DATA = system.mwmrc
+
+ bin_PROGRAMS = mwm
+-mwm_LDADD = ./WmWsmLib/libWsm.a ../../lib/Xm/libXm.la
++mwm_LDADD = ./WmWsmLib/libWsm.a ../../lib/Xm/libXm.la -lXt -lXext -lX11
+
+ INCLUDES = -DLARGECURSORS -DR2_COMPAT -DUNMAP_ON_RESTART \
+ -DCDE_INSTALLATION_TOP=\"@CDE_INSTALLATION_TOP@\" \
+--- a/clients/uil/Makefile.am
++++ b/clients/uil/Makefile.am
+@@ -11,9 +11,9 @@
+ UilParser.lo: UilParser.c
+ $(LTCOMPILE) -DCALLABLE -c UilParser.c
+
+-libUil_la_LIBADD = UilParser.lo ../../lib/Mrm/libMrm.la ../../lib/Xm/libXm.la
++libUil_la_LIBADD = UilParser.lo ../../lib/Mrm/libMrm.la ../../lib/Xm/libXm.la -lXt
+
+-uil_LDADD = ../../lib/Mrm/libMrm.la ../../lib/Xm/libXm.la
++uil_LDADD = ../../lib/Mrm/libMrm.la ../../lib/Xm/libXm.la -lXt
+
+ INCLUDES = -DINCDIR=\"@INCDIR@\" \
+ -DLIBDIR=\"@LIBDIR@\" \
+--- a/clients/xmbind/Makefile.am
++++ b/clients/xmbind/Makefile.am
+@@ -2,6 +2,6 @@
+
+ bin_PROGRAMS = xmbind
+
+-LDADD = ../../lib/Xm/libXm.la
++LDADD = ../../lib/Xm/libXm.la -lXt -lX11
+
+ INCLUDES = -I$(srcdir)/../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+--- a/demos/doc/programGuide/ch05/Scale/Makefile.am
++++ b/demos/doc/programGuide/ch05/Scale/Makefile.am
+@@ -8,4 +8,4 @@
+
+ INCLUDES = -I$(top_builddir)/lib -I$(top_srcdir)/lib -I$(top_srcdir)/demos/lib $(X_CFLAGS)
+
+-LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la
++LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la -lXt -lX11
+--- a/demos/doc/programGuide/ch06/combo_box/Makefile.am
++++ b/demos/doc/programGuide/ch06/combo_box/Makefile.am
+@@ -9,4 +9,4 @@
+
+ INCLUDES = -I$(top_builddir)/lib -I$(top_srcdir)/lib -I$(top_srcdir)/demos/lib $(X_CFLAGS)
+
+-LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la
++LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la -lXt -lX11
+--- a/demos/doc/programGuide/ch06/spin_box/Makefile.am
++++ b/demos/doc/programGuide/ch06/spin_box/Makefile.am
+@@ -9,4 +9,4 @@
+
+ INCLUDES = -I$(top_builddir)/lib -I$(top_srcdir)/lib -I$(top_srcdir)/demos/lib $(X_CFLAGS)
+
+-LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la
++LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la -lXt -lX11
+--- a/demos/doc/programGuide/ch08/Container/Makefile.am
++++ b/demos/doc/programGuide/ch08/Container/Makefile.am
+@@ -8,4 +8,4 @@
+
+ INCLUDES = -I$(top_builddir)/lib -I$(top_srcdir)/lib -I$(top_srcdir)/demos/lib $(X_CFLAGS)
+
+-LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la
++LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la -lXt -lX11
+--- a/demos/doc/programGuide/ch08/Notebook/Makefile.am
++++ b/demos/doc/programGuide/ch08/Notebook/Makefile.am
+@@ -8,4 +8,4 @@
+
+ INCLUDES = -I$(top_builddir)/lib -I$(top_srcdir)/lib -I$(top_srcdir)/demos/lib $(X_CFLAGS)
+
+-LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la
++LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la -lXt -lX11
+--- a/demos/doc/programGuide/ch16/Makefile.am
++++ b/demos/doc/programGuide/ch16/Makefile.am
+@@ -9,4 +9,4 @@
+
+ INCLUDES = -I$(top_builddir)/lib -I$(top_srcdir)/lib -I$(top_srcdir)/demos/lib $(X_CFLAGS)
+
+-LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la
++LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la -lXt -lX11
+--- a/demos/doc/programGuide/ch17/simple_drag/Makefile.am
++++ b/demos/doc/programGuide/ch17/simple_drag/Makefile.am
+@@ -9,4 +9,4 @@
+
+ INCLUDES = -I$(top_builddir)/lib -I$(top_srcdir)/lib -I$(top_srcdir)/demos/lib $(X_CFLAGS)
+
+-LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la
++LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la -lXt -lX11
+--- a/demos/doc/programGuide/ch17/simple_drop/Makefile.am
++++ b/demos/doc/programGuide/ch17/simple_drop/Makefile.am
+@@ -9,4 +9,4 @@
+
+ INCLUDES = -I$(top_builddir)/lib -I$(top_srcdir)/lib -I$(top_srcdir)/demos/lib $(X_CFLAGS)
+
+-LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la
++LDADD = -L$(top_builddir)/demos/lib/Xmd -lXmd $(top_builddir)/lib/Xm/libXm.la -lXt -lX11
+--- a/demos/lib/Exm/wml/Makefile.am
++++ b/demos/lib/Exm/wml/Makefile.am
+@@ -18,7 +18,7 @@
+ -I$(top_builddir)/clients/uil \
+ ${X_CFLAGS}
+
+-LDADD = $(top_builddir)/lib/Xm/libXm.la
++LDADD = $(top_builddir)/lib/Xm/libXm.la -lXt
+
+ DISTCLEANFILES = motif.wmd
+
+--- a/demos/lib/Xmd/Makefile.am
++++ b/demos/lib/Xmd/Makefile.am
+@@ -12,7 +12,7 @@
+ Print.h PrintP.h \
+ RegEdit.h RegEditI.h
+
+-LDADD = libXmd.a ../../../lib/Xm/libXm.la
++LDADD = libXmd.a ../../../lib/Xm/libXm.la -lXt
+
+ INCLUDES = -I$(top_builddir)/lib -I$(srcdir)/../../../lib ${X_CFLAGS}
+
+--- a/demos/programs/ButtonBox/Makefile.am
++++ b/demos/programs/ButtonBox/Makefile.am
+@@ -8,6 +8,6 @@
+ bboxdemo_SOURCES = bboxdemo.c
+ data_DATA = $(EXTRA_DIST) $(bboxdemo_SOURCES)
+ TOPDIR = ../../..
+-LDADD = $(TOPDIR)/lib/Xm/libXm.la
++LDADD = $(TOPDIR)/lib/Xm/libXm.la -lXt
+
+ INCLUDES = -I$(TOPDIR)/lib -I$(srcdir)/$(TOPDIR)/lib ${X_CFLAGS}
+--- a/demos/programs/ColorSel/Makefile.am
++++ b/demos/programs/ColorSel/Makefile.am
+@@ -7,6 +7,6 @@
+ colordemo_SOURCES = util-c.c colordemo.c
+ EXTRA_DIST = Imakefile
+ data_DATA = $(colordemo_SOURCES) $(EXTRA_DIST)
+-LDADD = $(TOPDIR)/lib/Xm/libXm.la
++LDADD = $(TOPDIR)/lib/Xm/libXm.la -lXt -lX11
+ TOPDIR = ../../..
+ INCLUDES = -I$(TOPDIR)/lib -I$(srcdir)/$(TOPDIR)/lib ${X_CFLAGS}
+--- a/demos/programs/Column/Makefile.am
++++ b/demos/programs/Column/Makefile.am
+@@ -8,5 +8,5 @@
+ EXTRA_DIST = Imakefile Column.ad
+ data_DATA = $(EXTRA_DIST) $(column_SOURCES)
+ TOPDIR = ../../..
+-LDADD = $(TOPDIR)/lib/Xm/libXm.la
++LDADD = $(TOPDIR)/lib/Xm/libXm.la -lXt -lX11
+ INCLUDES = -I$(TOPDIR)/lib -I$(srcdir)/$(TOPDIR)/lib ${X_CFLAGS}
+--- a/demos/programs/Combo2/Makefile.am
++++ b/demos/programs/Combo2/Makefile.am
+@@ -8,5 +8,5 @@
+ combo_SOURCES = combo.c
+ data_DATA = $(EXTRA_DIST) $(combo_SOURCES)
+ TOPDIR = ../../..
+-LDADD = $(TOPDIR)/lib/Xm/libXm.la
++LDADD = $(TOPDIR)/lib/Xm/libXm.la -lXt
+ INCLUDES = -I$(TOPDIR)/lib -I$(srcdir)/$(TOPDIR)/lib ${X_CFLAGS}
+--- a/demos/programs/Exm/app_in_c/Makefile.am
++++ b/demos/programs/Exm/app_in_c/Makefile.am
+@@ -14,4 +14,4 @@
+ -I$(top_builddir)/lib \
+ ${X_CFLAGS}
+ LDADD = ../../../lib/Exm/libExm.a \
+- ../../../../lib/Xm/libXm.la
++ ../../../../lib/Xm/libXm.la -lXt -lXext -lX11
+--- a/demos/programs/Exm/simple_app/Makefile.am
++++ b/demos/programs/Exm/simple_app/Makefile.am
+@@ -14,5 +14,6 @@
+ -I$(srcdir)/../../../lib \
+ -I$(top_builddir)/lib \
+ ${X_CFLAGS}
+-LDADD = ../../../../lib/Xm/libXm.la \
+- ../../../lib/Exm/libExm.a
++LDADD = ../../../lib/Exm/libExm.a \
++ ../../../../lib/Xm/libXm.la -lXt -lX11
++
+--- a/demos/programs/Ext18List/Makefile.am
++++ b/demos/programs/Ext18List/Makefile.am
+@@ -10,6 +10,6 @@
+ EXTRA_DIST = Imakefile
+ data_DATA = $(EXTRA_DIST) $(ext18list_SOURCES)
+ TOPDIR = ../../..
+-LDADD = $(TOPDIR)/lib/Xm/libXm.la
++LDADD = $(TOPDIR)/lib/Xm/libXm.la -lXt -lX11
+
+ INCLUDES = -I$(TOPDIR)/lib -I.. -I$(srcdir)/$(TOPDIR)/lib ${X_CFLAGS}
+--- a/demos/programs/FontSel/Makefile.am
++++ b/demos/programs/FontSel/Makefile.am
+@@ -7,6 +7,6 @@
+ fontsel_SOURCES = callbacks-c.c creation-c.c fontsel.c fontsel.h
+ EXTRA_DIST = Imakefile
+ data_DATA = $(EXTRA_DIST) $(fontsel_SOURCES)
+-LDADD = $(TOPDIR)/lib/Xm/libXm.la
++LDADD = $(TOPDIR)/lib/Xm/libXm.la -lXt
+ TOPDIR = ../../..
+ INCLUDES = -I$(TOPDIR)/lib -I$(srcdir)/$(TOPDIR)/lib ${X_CFLAGS}
+--- a/demos/programs/IconB/Makefile.am
++++ b/demos/programs/IconB/Makefile.am
+@@ -8,7 +8,7 @@
+ iconbuttondemo_SOURCES = misc.c iconbuttondemo.c
+ data_DATA = $(iconbuttondemo_SOURCES) $(EXTRA_DIST)
+ TOPDIR = ../../..
+-LDADD = $(TOPDIR)/lib/Xm/libXm.la
++LDADD = $(TOPDIR)/lib/Xm/libXm.la -lXt -lX11
+
+ INCLUDES = -I$(TOPDIR)/lib -I$(srcdir)/.. \
+ -I$(srcdir)/$(TOPDIR)/lib \
+--- a/demos/programs/Outline/Makefile.am
++++ b/demos/programs/Outline/Makefile.am
+@@ -7,6 +7,6 @@
+ bin_PROGRAMS = outline
+ outline_SOURCES = outline.c
+ data_DATA = $(outline_SOURCES) $(EXTRA_DIST)
+-LDADD = $(TOPDIR)/lib/Xm/libXm.la
++LDADD = $(TOPDIR)/lib/Xm/libXm.la -lXt
+ TOPDIR = ../../..
+ INCLUDES = -I$(TOPDIR)/lib -I$(srcdir)/$(TOPDIR)/lib ${X_CFLAGS}
+--- a/demos/programs/Paned/Makefile.am
++++ b/demos/programs/Paned/Makefile.am
+@@ -8,6 +8,6 @@
+ paned_SOURCES = creation-c.c paned.c
+ data_DATA = $(EXTRA_DIST) $(paned_SOURCES)
+ TOPDIR = ../../..
+-LDADD = $(TOPDIR)/lib/Xm/libXm.la
++LDADD = $(TOPDIR)/lib/Xm/libXm.la -lXt
+
+ INCLUDES = -I$(TOPDIR)/lib -I$(srcdir)/$(TOPDIR)/lib ${X_CFLAGS}
+--- a/demos/programs/TabStack/Makefile.am
++++ b/demos/programs/TabStack/Makefile.am
+@@ -8,6 +8,6 @@
+ EXTRA_DIST = Imakefile
+ data_DATA = $(tabstack_SOURCES) $(EXTRA_DIST)
+ TOPDIR = ../../..
+-LDADD = $(TOPDIR)/lib/Xm/libXm.la
++LDADD = $(TOPDIR)/lib/Xm/libXm.la -lXt -lX11
+
+ INCLUDES = -I$(TOPDIR)/lib -I$(srcdir)/$(TOPDIR)/lib ${X_CFLAGS}
+--- a/demos/programs/Tree/Makefile.am
++++ b/demos/programs/Tree/Makefile.am
+@@ -8,6 +8,6 @@
+ tree_SOURCES = bxutil-c.c tree.c
+ data_DATA = $(EXTRA_DIST) $(tree_SOURCES)
+ TOPDIR = ../../..
+-LDADD = $(TOPDIR)/lib/Xm/libXm.la
++LDADD = $(TOPDIR)/lib/Xm/libXm.la -lXt -lX11
+
+ INCLUDES = -I$(TOPDIR)/lib -I$(srcdir)/.. -I$(srcdir)/$(TOPDIR)/lib ${X_CFLAGS}
+--- a/demos/programs/airport/Makefile.am
++++ b/demos/programs/airport/Makefile.am
+@@ -8,5 +8,5 @@
+ dragsource.h dropsite.h main.h
+ EXTRA_DIST = Imakefile XmdAirport.ad README
+ data_DATA = $(airport_SOURCES) $(EXTRA_DIST)
+-LDADD = ../../../lib/Xm/libXm.la
++LDADD = ../../../lib/Xm/libXm.la -lXt -lX11
+ INCLUDES = -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+--- a/demos/programs/animate/Makefile.am
++++ b/demos/programs/animate/Makefile.am
+@@ -17,7 +17,7 @@
+
+ bin_PROGRAMS = xmanimate
+
+-LDADD = ../../lib/Xmd/libXmd.a ../../../lib/Mrm/libMrm.la ../../../lib/Xm/libXm.la
++LDADD = ../../lib/Xmd/libXmd.a ../../../lib/Mrm/libMrm.la ../../../lib/Xm/libXm.la -lXt -lX11
+
+ INCLUDES = -I$(srcdir)/../../../lib \
+ -I$(srcdir)/../../lib \
+--- a/demos/programs/drag_and_drop/Makefile.am
++++ b/demos/programs/drag_and_drop/Makefile.am
+@@ -10,6 +10,6 @@
+ simpledrop_SOURCES = simpledrop.c
+ data_DATA = $(EXTRA_DIST) $(DNDDemo_SOURCES) $(simpledrop_SOURCES)
+ noinst_HEADERS = DNDDemo.h
+-LDADD = ../../../lib/Xm/libXm.la
++LDADD = ../../../lib/Xm/libXm.la -lXt -lX11
+
+ INCLUDES = -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+--- a/demos/programs/draw/Makefile.am
++++ b/demos/programs/draw/Makefile.am
+@@ -7,5 +7,5 @@
+ draw_SOURCES = draw.c
+ EXTRA_DIST = Imakefile XmdDraw.ad README draw.help draw.man
+ data_DATA = $(EXTRA_DIST) $(draw_SOURCES)
+-LDADD = ../../lib/Xmd/libXmd.a ../../../lib/Xm/libXm.la
++LDADD = ../../lib/Xmd/libXmd.a ../../../lib/Xm/libXm.la -lXt -lX11
+ INCLUDES = -I$(srcdir)/../../lib -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+--- a/demos/programs/earth/Makefile.am
++++ b/demos/programs/earth/Makefile.am
+@@ -7,5 +7,5 @@
+ earth_SOURCES = earth.c
+ EXTRA_DIST = terre.xbm earth.man Imakefile README
+ data_DATA = $(EXTRA_DIST) $(earth_SOURCES)
+-LDADD = ../../../lib/Xm/libXm.la
++LDADD = ../../../lib/Xm/libXm.la -lXt -lXext -lX11
+ INCLUDES = -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+--- a/demos/programs/filemanager/Makefile.am
++++ b/demos/programs/filemanager/Makefile.am
+@@ -11,7 +11,7 @@
+ obj.xpm pix.xpm s_dir.xpm s_exec.xpm s_file.xpm \
+ s_none.xpm s_pix.xpm
+ data_DATA = $(EXTRA_DIST) $(filemanager_SOURCES)
+-LDADD = ../../lib/Xmd/libXmd.a ../../../lib/Xm/libXm.la
++LDADD = ../../lib/Xmd/libXmd.a ../../../lib/Xm/libXm.la -lXt -lX11
+ INCLUDES = -I$(srcdir)/../../lib -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+
+
+--- a/demos/programs/fileview/Makefile.am
++++ b/demos/programs/fileview/Makefile.am
+@@ -11,7 +11,7 @@
+
+ UILS= French.uil German.uil English.uil
+
+-LDADD = ../../../lib/Xm/libXm.la ../../../lib/Mrm/libMrm.la
++LDADD = ../../../lib/Xm/libXm.la ../../../lib/Mrm/libMrm.la -lXt -lX11
+
+ INCLUDES = -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+
+--- a/demos/programs/getsubres/Makefile.am
++++ b/demos/programs/getsubres/Makefile.am
+@@ -7,5 +7,5 @@
+ EXTRA_DIST = getsubres.help getsubres.man README Imakefile
+ getsubres_SOURCES = getsubres.c
+ data_DATA = $(EXTRA_DIST) $(getsubres_SOURCES)
+-LDADD = ../../lib/Xmd/libXmd.a ../../../lib/Xm/libXm.la
++LDADD = ../../lib/Xmd/libXmd.a ../../../lib/Xm/libXm.la -lXt -lX11
+ INCLUDES = -I$(srcdir)/../../lib -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+--- a/demos/programs/hellomotif/Makefile.am
++++ b/demos/programs/hellomotif/Makefile.am
+@@ -7,7 +7,7 @@
+ EXTRA_DIST = hellomotif.uil Imakefile README
+ hellomotif_SOURCES = hellomotif.c
+ data_DATA = $(EXTRA_DIST) $(hellomotif_SOURCES) hellomotif.uid
+-LDADD = ../../../lib/Xm/libXm.la ../../../lib/Mrm/libMrm.la
++LDADD = ../../../lib/Xm/libXm.la ../../../lib/Mrm/libMrm.la -lXt
+ INCLUDES = -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+
+ all: hellomotif.uid
+--- a/demos/programs/hellomotifi18n/Makefile.am
++++ b/demos/programs/hellomotifi18n/Makefile.am
+@@ -12,7 +12,7 @@
+ helloint_DEPENDENCIES = helloint.uid C/uid/l_strings.uid english/uid/l_strings.uid french/uid/l_strings.uid hebrew/uid/l_strings.uid japan/uid/l_strings.uid japanese/uid/l_strings.uid swedish/uid/l_strings.uid
+
+ INCLUDES = -I$(top_srcdir)/lib -I$(top_builddir)/lib ${X_CFLAGS}
+-LDADD = $(top_builddir)/lib/Mrm/libMrm.la $(top_builddir)/lib/Xm/libXm.la
++LDADD = $(top_builddir)/lib/Mrm/libMrm.la $(top_builddir)/lib/Xm/libXm.la -lXt
+
+ SUFFIXES = .uil .uid
+
+--- a/demos/programs/i18ninput/Makefile.am
++++ b/demos/programs/i18ninput/Makefile.am
+@@ -8,6 +8,6 @@
+ EXTRA_DIST = XmdI18nInput.ad README i18ninput.man i18ninput.help \
+ Imakefile
+ data_DATA = $(EXTRA_DIST) $(i18ninput_SOURCES)
+-LDADD = ../../lib/Xmd/libXmd.a ../../../lib/Xm/libXm.la
++LDADD = ../../lib/Xmd/libXmd.a ../../../lib/Xm/libXm.la -lXt -lX11
+
+ INCLUDES = -I$(srcdir)/../../lib -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+--- a/demos/programs/panner/Makefile.am
++++ b/demos/programs/panner/Makefile.am
+@@ -7,5 +7,5 @@
+ panner_SOURCES = panner.c
+ EXTRA_DIST = README panner.man Imakefile
+ data_DATA = $(EXTRA_DIST) $(panner_SOURCES)
+-LDADD = ../../../lib/Xm/libXm.la
++LDADD = ../../../lib/Xm/libXm.la -lXt -lX11
+ INCLUDES = -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+--- a/demos/programs/periodic/Makefile.am
++++ b/demos/programs/periodic/Makefile.am
+@@ -7,7 +7,7 @@
+ EXTRA_DIST = periodic.uil periodic_l.uil XmdPeriodic.ad Imakefile README
+ periodic_SOURCES = periodic.c
+ data_DATA = $(EXTRA_DIST) $(periodic_SOURCES) periodic.uid
+-LDADD = ../../../lib/Xm/libXm.la ../../../lib/Mrm/libMrm.la
++LDADD = ../../../lib/Xm/libXm.la ../../../lib/Mrm/libMrm.la -lXt -lX11
+
+ INCLUDES = -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+
+--- a/demos/programs/piano/Makefile.am
++++ b/demos/programs/piano/Makefile.am
+@@ -8,6 +8,6 @@
+ EXTRA_DIST = piano.images README Inv8_part1.piano Inv8_part2.piano \
+ piano.man Imakefile
+ data_DATA = $(EXTRA_DIST) $(piano_SOURCES)
+-LDADD = ../../../lib/Xm/libXm.la -lm
++LDADD = ../../../lib/Xm/libXm.la -lm -lXt -lX11
+
+ INCLUDES = -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+--- a/demos/programs/popups/Makefile.am
++++ b/demos/programs/popups/Makefile.am
+@@ -7,6 +7,6 @@
+ autopopups_SOURCES = autopopups.c
+ EXTRA_DIST = README autopopups.man Imakefile
+ data_DATA = $(EXTRA_DIST) $(autopopups_SOURCES)
+-LDADD = ../../../lib/Xm/libXm.la
++LDADD = ../../../lib/Xm/libXm.la -lXt -lX11
+
+ INCLUDES = -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+--- a/demos/programs/sampler2_0/Makefile.am
++++ b/demos/programs/sampler2_0/Makefile.am
+@@ -10,6 +10,6 @@
+ bin_PROGRAMS = sampler2_0
+ sampler2_0_SOURCES = sampler2_0.c
+ data_DATA = $(sampler2_0_SOURCES) $(EXTRA_DIST)
+-LDADD = ../../lib/Xmd/libXmd.a ../../../lib/Xm/libXm.la
++LDADD = ../../lib/Xmd/libXmd.a ../../../lib/Xm/libXm.la -lXt -lX11
+
+ INCLUDES = -I$(srcdir)/../../lib -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+--- a/demos/programs/setdate/Makefile.am
++++ b/demos/programs/setdate/Makefile.am
+@@ -7,6 +7,6 @@
+ EXTRA_DIST = XmdSetDate.ad README setDate.man Imakefile
+ setDate_SOURCES = setDate.c
+ data_DATA = $(EXTRA_DIST) $(setDate_SOURCES)
+-LDADD = ../../../lib/Xm/libXm.la
++LDADD = ../../../lib/Xm/libXm.la -lXt -lX11
+
+ INCLUDES = -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+--- a/demos/programs/todo/Makefile.am
++++ b/demos/programs/todo/Makefile.am
+@@ -9,4 +9,4 @@
+ data_DATA = $(EXTRA_DIST) $(todo_SOURCES)
+
+ INCLUDES = -I$(srcdir)/../../../lib -I$(srcdir)/../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+-LDADD = -L../../lib/Xmd -lXmd -L../../lib/Exm -lExm ../../../lib/Xm/libXm.la
++LDADD = -L../../lib/Xmd -lXmd -L../../lib/Exm -lExm ../../../lib/Xm/libXm.la -lXt -lXext -lX11
+--- a/demos/programs/tooltips/Makefile.am
++++ b/demos/programs/tooltips/Makefile.am
+@@ -7,6 +7,6 @@
+ bin_PROGRAMS = tooltips
+ tooltips_SOURCES = tooltips.c
+ data_DATA = $(tooltips_SOURCES) $(EXTRA_DIST)
+-LDADD = ../../../lib/Xm/libXm.la
++LDADD = ../../../lib/Xm/libXm.la -lXt
+
+ INCLUDES = -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+--- a/demos/programs/workspace/Makefile.am
++++ b/demos/programs/workspace/Makefile.am
+@@ -11,4 +11,4 @@
+ wsm.h wsmSend.h wsmStruct.h wsm_ui.h xrmLib.h
+ data_DATA = $(wsm_SOURCES) $(EXTRA_DIST)
+ INCLUDES = -I$(srcdir)/../../../lib -I$(srcdir)/../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+-LDADD = ../../../lib/Xm/libXm.la -L../../lib/Wsm -lWsm
++LDADD = ../../../lib/Xm/libXm.la -L../../lib/Wsm -lWsm -lXt -lX11
+--- a/demos/unsupported/aicon/Makefile.am
++++ b/demos/unsupported/aicon/Makefile.am
+@@ -2,7 +2,7 @@
+
+ noinst_PROGRAMS = aicon
+
+-LDADD = -L../../lib/Xmd -lXmd ../../../lib/Xm/libXm.la
++LDADD = -L../../lib/Xmd -lXmd ../../../lib/Xm/libXm.la -lXt -lX11
+
+ INCLUDES = -I$(srcdir)/../../../lib -I$(srcdir)/../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+
+--- a/demos/unsupported/dainput/Makefile.am
++++ b/demos/unsupported/dainput/Makefile.am
+@@ -4,7 +4,7 @@
+
+ dainput_SOURCES = dainput.c dainput_dlg.c dainput_ui.c
+
+-LDADD = ../../../lib/Xm/libXm.la
++LDADD = ../../../lib/Xm/libXm.la -lXt -lX11
+
+ EXTRA_DIST = Imakefile
+
+--- a/demos/unsupported/dogs/Makefile.am
++++ b/demos/unsupported/dogs/Makefile.am
+@@ -16,7 +16,7 @@
+
+ dogs_DEPENDENCIES = dogs.uid
+
+-LDADD = $(top_builddir)/lib/Mrm/libMrm.la $(top_builddir)/lib/Xm/libXm.la
++LDADD = $(top_builddir)/lib/Mrm/libMrm.la $(top_builddir)/lib/Xm/libXm.la -lXt -lX11
+
+ INCLUDES = -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+
+--- a/demos/unsupported/hellomotif/Makefile.am
++++ b/demos/unsupported/hellomotif/Makefile.am
+@@ -4,7 +4,7 @@
+
+ SOURCES = hellomotif.c
+
+-LDADD = ../../../lib/Xm/libXm.la
++LDADD = ../../../lib/Xm/libXm.la -lXt
+
+ EXTRA_DIST = Imakefile
+
+--- a/demos/unsupported/motifshell/Makefile.am
++++ b/demos/unsupported/motifshell/Makefile.am
+@@ -4,7 +4,7 @@
+
+ SOURCES = motifshell.c
+
+-LDADD = ../../../lib/Xm/libXm.la
++LDADD = ../../../lib/Xm/libXm.la -lXt -lX11
+
+ EXTRA_DIST = Imakefile
+
+--- a/demos/unsupported/xmapdef/Makefile.am
++++ b/demos/unsupported/xmapdef/Makefile.am
+@@ -4,7 +4,7 @@
+
+ SOURCES = xmapdef.c
+
+-LDADD = ../../../lib/Xm/libXm.la
++LDADD = ../../../lib/Xm/libXm.la -lXt -lX11
+
+ EXTRA_DIST = Imakefile
+
+--- a/demos/unsupported/xmfonts/Makefile.am
++++ b/demos/unsupported/xmfonts/Makefile.am
+@@ -4,7 +4,7 @@
+
+ SOURCES = xmfonts.c
+
+-LDADD = ../../../lib/Xm/libXm.la
++LDADD = ../../../lib/Xm/libXm.la -lXt -lX11
+
+ EXTRA_DIST = Imakefile
+
+--- a/demos/unsupported/xmforc/Makefile.am
++++ b/demos/unsupported/xmforc/Makefile.am
+@@ -4,7 +4,7 @@
+
+ SOURCES = xmforc.c
+
+-LDADD = ../../../lib/Xm/libXm.la
++LDADD = ../../../lib/Xm/libXm.la -lXt
+
+ EXTRA_DIST = Imakefile
+
+--- a/demos/unsupported/xmform/Makefile.am
++++ b/demos/unsupported/xmform/Makefile.am
+@@ -6,6 +6,6 @@
+
+ EXTRA_DIST = Imakefile
+
+-LDADD = ../../../lib/Xm/libXm.la
++LDADD = ../../../lib/Xm/libXm.la -lXt
+
+ INCLUDES = -I$(srcdir)/../../../lib -I$(top_builddir)/lib ${X_CFLAGS}
+--- a/tools/wml/Makefile.am
++++ b/tools/wml/Makefile.am
+@@ -30,7 +30,7 @@
+ wml_LDADD = -L. -lwml
+ wml_DEPENDENCIES = libwml.a
+
+-wmldbcreate_LDADD = ../../lib/Xm/libXm.la
++wmldbcreate_LDADD = ../../lib/Xm/libXm.la -lXt
+
+ INCLUDES = -I../../lib -I$(srcdir)/../../lib -I$(srcdir)/../../include ${X_CFLAGS}
+
diff --git a/main/motif/12-fix_buffer_overrun_in_libxm.patch b/main/motif/12-fix_buffer_overrun_in_libxm.patch
new file mode 100644
index 0000000000..227b1c57a3
--- /dev/null
+++ b/main/motif/12-fix_buffer_overrun_in_libxm.patch
@@ -0,0 +1,17 @@
+Description: Fix buffer overrun in libXm (FontS.c)
+Origin: upstream commit dada5ff7f93cb48afaec2469f5dde24178d8d6da
+Bug: http://bugs.motifzone.net/show_bug.cgi?id=1568
+Author: Arthur Haas <ahaas@impactweather.com>
+Author: Graham Inggs <graham@nerve.org.za>
+Last-Update: 2013-02-19
+--- a/lib/Xm/FontS.c
++++ b/lib/Xm/FontS.c
+@@ -1879,7 +1879,7 @@
+ String params[1];
+ Cardinal num = 1;
+
+- params[1] = new_font;
++ params[0] = new_font;
+ dbg(); _XmWarningMsg((Widget) fsw, XmNbadXlfdFont,
+ XmNbadXlfdFontMsg, params, num);
+ }
diff --git a/main/motif/13-fix_hardcoded_x11rgb_path.patch b/main/motif/13-fix_hardcoded_x11rgb_path.patch
new file mode 100644
index 0000000000..6d532859d7
--- /dev/null
+++ b/main/motif/13-fix_hardcoded_x11rgb_path.patch
@@ -0,0 +1,54 @@
+Description: Fix hardcoded path to /usr/lib/X11/rgb.txt in lib/Xm/ColorS.c
+ LibXm is hardcoded to read rgb.txt from /usr/lib/X11 but this file, provided
+ by x11-common in Debian, is located in /etc/X11 and /usr/share/X11 via symlink.
+ .
+ This patch fixes this by allowing the directory in which rgb.txt resides to be
+ customized by the --with-x11rgbdir=DIR configure option.
+Author: Graham Inggs <graham@nerve.org.za>
+Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1585
+Last-Update: 2013-03-12
+--- a/configure.ac
++++ b/configure.ac
+@@ -189,6 +189,10 @@
+ XMBINDDIR_FALLBACK="$xmbinddir"
+ AC_SUBST(XMBINDDIR_FALLBACK)
+
++AC_ARG_WITH(x11rgbdir, [ --with-x11rgbdir=DIR rgb.txt is located in DIR], x11rgbdir=$withval, x11rgbdir="/usr/lib/X11")
++X11RGBPATH="$x11rgbdir/rgb.txt"
++AC_SUBST(X11RGBPATH)
++
+ RM="rm -f"
+ AC_SUBST(RM)
+
+--- a/lib/Xm/ColorS.c
++++ b/lib/Xm/ColorS.c
+@@ -123,6 +123,10 @@
+ * STATIC DECLARATIONS
+ ************************************************************/
+
++#ifndef X11RGBPATH
++#define X11RGBPATH "/usr/lib/X11/rgb.txt"
++#endif
++
+ static XtResource resources[] =
+ {
+ {
+@@ -146,7 +150,7 @@
+ {
+ XmNrgbFile, XmCString, XmRString,
+ sizeof(String), XtOffsetOf(XmColorSelectorRec, cs.rgb_file),
+- XmRString, (XtPointer) "/usr/lib/X11/rgb.txt"
++ XmRString, (XtPointer) X11RGBPATH
+ },
+ #endif
+ {
+--- a/lib/Xm/Makefile.am
++++ b/lib/Xm/Makefile.am
+@@ -8,6 +8,7 @@
+ INCLUDES = -I.. -I$(srcdir)/.. -DXMBINDDIR_FALLBACK=\"@XMBINDDIR_FALLBACK@\" \
+ -DINCDIR=\"@INCDIR@\" \
+ -DLIBDIR=\"@LIBDIR@\" \
++ -DX11RGBPATH=\"@X11RGBPATH@\" \
+ ${X_CFLAGS}
+ xmdir = $(includedir)/Xm
+
diff --git a/main/motif/14-fix_ac_find_xft.patch b/main/motif/14-fix_ac_find_xft.patch
new file mode 100644
index 0000000000..76c23183e8
--- /dev/null
+++ b/main/motif/14-fix_ac_find_xft.patch
@@ -0,0 +1,91 @@
+Description: Fix ac_find_xft.m4
+ ac_find_xft.m4 fails tests required to enable building with Xft anti-aliased fonts.
+ We also need to add -lfontconfig to LIBS to prevent underlinking of libXm.
+ .
+ This patch fixes these. Build-depends on libfontconfig1-dev, libfreetype6-dev and
+ libxrender-dev can be dropped as they are all dependencies of libxft-dev.
+Author: Graham Inggs <graham@nerve.org.za>
+Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1591
+Last-Update: 2013-03-13
+--- a/ac_find_xft.m4
++++ b/ac_find_xft.m4
+@@ -54,28 +54,28 @@
+
+ case "$freetype_lib" in
+ no)
+- freetype_lib=""
++ FREETYPE_LIBS=""
+ ;;
+ yes)
+ case "$ft_config" in
+ no)
+- freetype_lib=""
++ FREETYPE_LIBS="-lfreetype"
+ ;;
+ *)
+- freetype_lib="`$ft_config --libs`"
++ FREETYPE_LIBS="`$ft_config --libs`"
+ ;;
+ esac
+ ;;
+ *)
+- freetype_lib="-L$freetype_lib -lfreetype"
++ FREETYPE_LIBS="-L$freetype_lib -lfreetype"
+ ;;
+ esac
+
+ saved_LIBS="$LIBS"
+-LIBS="$LIBS $freetype_lib"
++LIBS="$LIBS $FREETYPE_LIBS"
+ saved_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS"
+-AC_CHECK_HEADERS(freetype/freetype.h)
++AC_CHECK_HEADERS(freetype/freetype.h,,,[#include <ft2build.h>])
+
+ FINDXFT_HAVE_FREETYPE="no"
+ case "$ac_cv_header_freetype_freetype_h" in
+@@ -94,6 +94,7 @@
+ FINDXFT_HAVE_FREETYPE="yes"
+ AC_DEFINE(HAVE_FREETYPE, 1, Means we have discovered the FreeType library)
+ AC_SUBST(FREETYPE_CFLAGS)
++ AC_SUBST(FREETYPE_LIBS)
+ ;;
+ esac
+ ;;
+@@ -134,8 +135,19 @@
+ FINDXFT_HAVE_XRENDER="no"
+ case "$have_x" in
+ yes)
+- XRENDER_CFLAGS="-I$x_includes"
+- XRENDER_LIBS="-L$x_libraries -lXft -lXrender"
++ if test x$x_includes = x
++ then
++ XRENDER_CFLAGS=""
++ else
++ XRENDER_CFLAGS="-I$x_includes"
++ fi
++
++ if test x$x_libraries = x
++ then
++ XRENDER_LIBS="-lXft -lXrender"
++ else
++ XRENDER_LIBS="-I$x_libraries -lXft -lXrender"
++ fi
+
+ saved_LIBS="$LIBS"
+ LIBS="$LIBS $XRENDER_LIBS"
+@@ -203,12 +215,12 @@
+
+ case "$fontconfig_lib" in
+ no)
+- fontconfig_lib=""
++ FONTCONFIG_LIBS=""
+ ;;
+ yes)
+ case "$fc_config" in
+ no)
+- fontconfig_lib=""
++ FONTCONFIG_LIBS="-lfontconfig"
+ ;;
+ *)
+ FONTCONFIG_LIBS="`$fc_config --libs`"
diff --git a/main/motif/15-link_uil_against_libuil.patch b/main/motif/15-link_uil_against_libuil.patch
new file mode 100644
index 0000000000..11792a7a4c
--- /dev/null
+++ b/main/motif/15-link_uil_against_libuil.patch
@@ -0,0 +1,29 @@
+Description: Link the uil executable against libUil
+ Linking the uil executable againt libUil instead of compiling with the libUil
+ code results in a reduction in size of the uil executable from about 348KB
+ to about 16KB.
+ .
+ This patch originates from Red Hat.
+Author: Graham Inggs <graham@nerve.org.za>
+Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1586
+Last-Update: 2013-03-12
+--- a/clients/uil/Makefile.am
++++ b/clients/uil/Makefile.am
+@@ -13,7 +13,7 @@
+
+ libUil_la_LIBADD = UilParser.lo ../../lib/Mrm/libMrm.la ../../lib/Xm/libXm.la -lXt
+
+-uil_LDADD = ../../lib/Mrm/libMrm.la ../../lib/Xm/libXm.la -lXt
++uil_LDADD = libUil.la ../../lib/Mrm/libMrm.la ../../lib/Xm/libXm.la -lXt
+
+ INCLUDES = -DINCDIR=\"@INCDIR@\" \
+ -DLIBDIR=\"@LIBDIR@\" \
+@@ -42,7 +42,7 @@
+ UilLstMac.c UilSemVal.c UilSemCSet.c UilDB.c
+
+ SRCS = $(COMMON_SRC)
+-SRCS2 = $(COMMON_SRC) UilMain.c
++SRCS2 = UilMain.c
+
+ HEADERS_1 = Uil.h UilSymGl.h UilSymDef.h \
+ UilDef.h XmAppl.uil
diff --git a/main/motif/16-fix-undefined-use-of-sprintf.patch b/main/motif/16-fix-undefined-use-of-sprintf.patch
new file mode 100644
index 0000000000..95a753e083
--- /dev/null
+++ b/main/motif/16-fix-undefined-use-of-sprintf.patch
@@ -0,0 +1,17 @@
+Description: Fix undefined use of sprintf
+ This patch fixes the undefined use of sprintf when the
+ source and destination buffers overlap.
+Author: Graham Inggs <graham@nerve.org.za>
+Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1628
+Last-Update: 2013-09-24
+--- a/lib/Xm/XmRenderT.c
++++ b/lib/Xm/XmRenderT.c
+@@ -2703,7 +2703,7 @@
+ number = tlist -> count;
+ tab = (_XmTab) tlist -> start;
+ while(number > 0) {
+- sprintf(temp, "%s %f %d %d %d, ", temp, tab -> value,
++ sprintf(temp + strlen(temp), " %f %d %d %d, ", tab -> value,
+ tab -> units, tab -> alignment, tab -> offsetModel);
+ tab = (_XmTab) tab -> next;
+ number--;
diff --git a/main/motif/17-switch-to-system-iswspace.patch b/main/motif/17-switch-to-system-iswspace.patch
new file mode 100644
index 0000000000..a77b8793a8
--- /dev/null
+++ b/main/motif/17-switch-to-system-iswspace.patch
@@ -0,0 +1,384 @@
+Description: Switch to system iswspace() function
+ This patch replaces calls to _XmDataFieldIsWSpace() in lib/Xm/DataF.c
+ and _XmTextFieldIsWSpace() in lib/Xm/TextF.c with calls to the system
+ iswspace() function.
+ .
+ It fixes an array bounds error in lib/Xm/DataF.c where
+ _XmDataFieldIsWSpace() is called with num_entries = 3.
+Author: Graham Inggs <graham@nerve.org.za>
+Forwarded: http://bugs.motifzone.net/show_bug.cgi?id=1629
+Last-Update: 2013-11-18
+--- a/lib/Xm/DataF.c
++++ b/lib/Xm/DataF.c
+@@ -208,7 +208,6 @@
+ static Boolean df_VerifyLeave() ;
+ static Boolean _XmDataFieldIsWordBoundary() ;
+ static int _XmGetImage(Screen *, char *, XImage **);
+-static Boolean _XmDataFieldIsWSpace() ;
+ static void df_FindWord() ;
+ static void df_FindPrevWord() ;
+ static void df_FindNextWord() ;
+@@ -549,10 +548,6 @@
+ XmDataFieldWidget tf,
+ XmTextPosition pos1,
+ XmTextPosition pos2) ;
+-static Boolean _XmDataFieldIsWSpace(
+- wchar_t wide_char,
+- wchar_t *white_space,
+- int num_entries) ;
+ static void df_FindWord(
+ XmDataFieldWidget tf,
+ XmTextPosition begin,
+@@ -4549,40 +4544,6 @@
+ return False;
+ }
+
+-/* This routine accepts an array of wchar_t's containing wchar encodings
+- * of whitespace characters (and the number of array elements), comparing
+- * the wide character passed to each element of the array. If a match
+- * is found, we got a white space. This routine exists only because
+- * iswspace(3c) is not yet standard. If a system has isw* available,
+- * calls to this routine should be changed to iswspace(3c) (and callers
+- * should delete initialization of the array), and this routine should
+- * be deleted. Its a stop gap measure to avoid allocating an instance
+- * variable for the white_space array and/or declaring a widget wide
+- * global for the data and using a macro. Its ugly, but it works and
+- * in the long run will be replaced by standard functionality. */
+-
+-/* ARGSUSED */
+-static Boolean
+-#ifdef _NO_PROTO
+-_XmDataFieldIsWSpace( wide_char, white_space, num_entries )
+- wchar_t wide_char ;
+- wchar_t * white_space ;
+- int num_entries ;
+-#else
+-_XmDataFieldIsWSpace(
+- wchar_t wide_char,
+- wchar_t * white_space ,
+- int num_entries )
+-#endif /* _NO_PROTO */
+-{
+- int i;
+-
+- for (i=num_entries; i > 0; i--){
+- if (wide_char == white_space[i]) return True;
+- }
+- return False;
+-}
+-
+ static void
+ #ifdef _NO_PROTO
+ df_FindWord( tf, begin, left, right )
+@@ -4599,7 +4560,6 @@
+ #endif /* _NO_PROTO */
+ {
+ XmTextPosition start, end;
+- wchar_t white_space[3];
+
+ if (XmTextF_max_char_size(tf) == 1) {
+ for (start = begin; start > 0; start--) {
+@@ -4617,11 +4577,8 @@
+ }
+ *right = end - 1;
+ } else { /* check for iswspace and iswordboundary in each direction */
+- (void)mbtowc(&white_space[0], " ", 1);
+- (void)mbtowc(&white_space[1], "\n", 1);
+- (void)mbtowc(&white_space[2], "\t", 1);
+ for (start = begin; start > 0; start --) {
+- if (_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[start-1],white_space, 3)
++ if (iswspace(XmTextF_wc_value(tf)[start-1])
+ || _XmDataFieldIsWordBoundary(tf, (XmTextPosition) start - 1,
+ start)) {
+ break;
+@@ -4630,7 +4587,7 @@
+ *left = start;
+
+ for (end = begin; end <= XmTextF_string_length(tf); end++) {
+- if (_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[end], white_space, 3)){
++ if (iswspace(XmTextF_wc_value(tf)[end])){
+ end++;
+ break;
+ } else if (end < XmTextF_string_length(tf)) {
+@@ -4659,14 +4616,6 @@
+ {
+
+ XmTextPosition start = XmTextF_cursor_position(tf);
+- wchar_t white_space[3];
+-
+- if (XmTextF_max_char_size(tf) != 1) {
+- (void)mbtowc(&white_space[0], " ", 1);
+- (void)mbtowc(&white_space[1], "\n", 1);
+- (void)mbtowc(&white_space[2], "\t", 1);
+- }
+-
+
+ if (XmTextF_max_char_size(tf) == 1) {
+ if ((start > 0) &&
+@@ -4680,11 +4629,9 @@
+ }
+ df_FindWord(tf, start, left, right);
+ } else {
+- if ((start > 0) && (_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[start - 1],
+- white_space, 3))) {
++ if ((start > 0) && (iswspace(XmTextF_wc_value(tf)[start - 1]))) {
+ for (; start > 0; start--) {
+- if (!_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[start -1],
+- white_space, 3)){
++ if (!iswspace(XmTextF_wc_value(tf)[start -1])){
+ start--;
+ break;
+ }
+@@ -4713,14 +4660,6 @@
+ {
+
+ XmTextPosition end = XmTextF_cursor_position(tf);
+- wchar_t white_space[3];
+-
+- if (XmTextF_max_char_size(tf) != 1) {
+- (void)mbtowc(&white_space[0], " ", 1);
+- (void)mbtowc(&white_space[1], "\n", 1);
+- (void)mbtowc(&white_space[2], "\t", 1);
+- }
+-
+
+ if(XmTextF_max_char_size(tf) == 1) {
+ if (isspace((int)(unsigned char)XmTextF_value(tf)[end])) {
+@@ -4742,9 +4681,9 @@
+ if (*right < XmTextF_string_length(tf))
+ *right = *right - 1;
+ } else {
+- if (_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[end], white_space, 3)) {
++ if (iswspace(XmTextF_wc_value(tf)[end])) {
+ for ( ; end < XmTextF_string_length(tf); end ++) {
+- if (!_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[end], white_space, 3)) {
++ if (!iswspace(XmTextF_wc_value(tf)[end])) {
+ break;
+ }
+ }
+@@ -4758,10 +4697,9 @@
+ * If word boundary caused by whitespace, set right to the last
+ * whitespace following the end of the current word.
+ */
+- if (_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[(int)*right], white_space, 3)) {
++ if (iswspace(XmTextF_wc_value(tf)[(int)*right])) {
+ while (*right < XmTextF_string_length(tf) &&
+- _XmDataFieldIsWSpace(XmTextF_wc_value(tf)[(int)*right],
+- white_space, 3)) {
++ iswspace(XmTextF_wc_value(tf)[(int)*right])) {
+ *right = *right + 1;
+ }
+ if (*right < XmTextF_string_length(tf))
+@@ -5872,13 +5810,6 @@
+ {
+ XmDataFieldWidget tf = (XmDataFieldWidget) w;
+ XmTextPosition cursorPos, position, dummy;
+- wchar_t white_space[3];
+-
+- if (XmTextF_max_char_size(tf) != 1) {
+- (void)mbtowc(&white_space[0], " ", 1);
+- (void)mbtowc(&white_space[1], "\n", 1);
+- (void)mbtowc(&white_space[2], "\t", 1);
+- }
+
+ cursorPos = XmTextF_cursor_position(tf);
+
+@@ -5896,16 +5827,13 @@
+ }
+ }
+ } else {
+- if (_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[cursorPos],
+- white_space, 3))
++ if (iswspace(XmTextF_wc_value(tf)[cursorPos]))
+ df_FindWord(tf, cursorPos, &dummy, &position);
+ else
+ df_FindNextWord(tf, &dummy, &position);
+- if (_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[position],
+- white_space, 3)){
++ if (iswspace(XmTextF_wc_value(tf)[position])){
+ for (; position < XmTextF_string_length(tf); position++) {
+- if (!_XmDataFieldIsWSpace(XmTextF_wc_value(tf)[position],
+- white_space, 3))
++ if (!iswspace(XmTextF_wc_value(tf)[position]))
+ break;
+ }
+ }
+--- a/lib/Xm/TextF.c
++++ b/lib/Xm/TextF.c
+@@ -360,10 +360,6 @@
+ XmTextPosition pos1,
+ XmTextPosition pos2);
+
+-static Boolean _XmTextFieldIsWSpace(wchar_t wide_char,
+- wchar_t *white_space,
+- int num_entries);
+-
+ static void FindWord(XmTextFieldWidget tf,
+ XmTextPosition begin,
+ XmTextPosition *left,
+@@ -3514,32 +3510,6 @@
+ return False;
+ }
+
+-/* This routine accepts an array of wchar_t's containing wchar encodings
+- * of whitespace characters (and the number of array elements), comparing
+- * the wide character passed to each element of the array. If a match
+- * is found, we got a white space. This routine exists only because
+- * iswspace(3c) is not yet standard. If a system has isw* available,
+- * calls to this routine should be changed to iswspace(3c) (and callers
+- * should delete initialization of the array), and this routine should
+- * be deleted. Its a stop gap measure to avoid allocating an instance
+- * variable for the white_space array and/or declaring a widget wide
+- * global for the data and using a macro. Its ugly, but it works and
+- * in the long run will be replaced by standard functionality. */
+-
+-/* ARGSUSED */
+-static Boolean
+-_XmTextFieldIsWSpace(wchar_t wide_char,
+- wchar_t * white_space ,
+- int num_entries)
+-{
+- int i;
+-
+- for (i=0; i < num_entries; i++) {
+- if (wide_char == white_space[i]) return True;
+- }
+- return False;
+-}
+-
+ static void
+ FindWord(XmTextFieldWidget tf,
+ XmTextPosition begin,
+@@ -3547,7 +3517,6 @@
+ XmTextPosition *right)
+ {
+ XmTextPosition start, end;
+- wchar_t white_space[3];
+
+ if (tf->text.max_char_size == 1) {
+ for (start = begin; start > 0; start--) {
+@@ -3565,11 +3534,8 @@
+ }
+ *right = end - 1;
+ } else { /* check for iswspace and iswordboundary in each direction */
+- (void)mbtowc(&white_space[0], " ", 1);
+- (void)mbtowc(&white_space[1], "\n", 1);
+- (void)mbtowc(&white_space[2], "\t", 1);
+ for (start = begin; start > 0; start --) {
+- if (_XmTextFieldIsWSpace(TextF_WcValue(tf)[start-1],white_space, 3)
++ if (iswspace(TextF_WcValue(tf)[start-1])
+ || _XmTextFieldIsWordBoundary(tf, (XmTextPosition) start - 1,
+ start)) {
+ break;
+@@ -3578,7 +3544,7 @@
+ *left = start;
+
+ for (end = begin; end <= tf->text.string_length; end++) {
+- if (_XmTextFieldIsWSpace(TextF_WcValue(tf)[end], white_space, 3)) {
++ if (iswspace(TextF_WcValue(tf)[end])) {
+ end++;
+ break;
+ } else if (end < tf->text.string_length) {
+@@ -3599,14 +3565,6 @@
+ {
+
+ XmTextPosition start = TextF_CursorPosition(tf);
+- wchar_t white_space[3];
+-
+- if (tf->text.max_char_size != 1) {
+- (void)mbtowc(&white_space[0], " ", 1);
+- (void)mbtowc(&white_space[1], "\n", 1);
+- (void)mbtowc(&white_space[2], "\t", 1);
+- }
+-
+
+ if (tf->text.max_char_size == 1) {
+ if ((start > 0) &&
+@@ -3620,11 +3578,9 @@
+ }
+ FindWord(tf, start, left, right);
+ } else {
+- if ((start > 0) && (_XmTextFieldIsWSpace(TextF_WcValue(tf)[start - 1],
+- white_space, 3))) {
++ if ((start > 0) && (iswspace(TextF_WcValue(tf)[start - 1]))) {
+ for (; start > 0; start--) {
+- if (!_XmTextFieldIsWSpace(TextF_WcValue(tf)[start -1],
+- white_space, 3)) {
++ if (!iswspace(TextF_WcValue(tf)[start -1])) {
+ start--;
+ break;
+ }
+@@ -3645,14 +3601,6 @@
+ {
+
+ XmTextPosition end = TextF_CursorPosition(tf);
+- wchar_t white_space[3];
+-
+- if (tf->text.max_char_size != 1) {
+- (void)mbtowc(&white_space[0], " ", 1);
+- (void)mbtowc(&white_space[1], "\n", 1);
+- (void)mbtowc(&white_space[2], "\t", 1);
+- }
+-
+
+ if(tf->text.max_char_size == 1) {
+ if (isspace((unsigned char)TextF_Value(tf)[end])) {
+@@ -3674,9 +3622,9 @@
+ if (*right < tf->text.string_length)
+ *right = *right - 1;
+ } else {
+- if (_XmTextFieldIsWSpace(TextF_WcValue(tf)[end], white_space, 3)) {
++ if (iswspace(TextF_WcValue(tf)[end])) {
+ for (; end < tf->text.string_length; end ++) {
+- if (!_XmTextFieldIsWSpace(TextF_WcValue(tf)[end], white_space, 3)) {
++ if (!iswspace(TextF_WcValue(tf)[end])) {
+ break;
+ }
+ }
+@@ -3690,10 +3638,9 @@
+ * If word boundary caused by whitespace, set right to the last
+ * whitespace following the end of the current word.
+ */
+- if (_XmTextFieldIsWSpace(TextF_WcValue(tf)[(int)*right], white_space, 3)) {
++ if (iswspace(TextF_WcValue(tf)[(int)*right])) {
+ while (*right < tf->text.string_length &&
+- _XmTextFieldIsWSpace(TextF_WcValue(tf)[(int)*right],
+- white_space, 3)) {
++ iswspace(TextF_WcValue(tf)[(int)*right])) {
+ *right = *right + 1;
+ }
+ if (*right < tf->text.string_length)
+@@ -4546,13 +4493,6 @@
+ {
+ XmTextFieldWidget tf = (XmTextFieldWidget) w;
+ XmTextPosition cursorPos, position, dummy;
+- wchar_t white_space[3];
+-
+- if (tf->text.max_char_size != 1) {
+- (void)mbtowc(&white_space[0], " ", 1);
+- (void)mbtowc(&white_space[1], "\n", 1);
+- (void)mbtowc(&white_space[2], "\t", 1);
+- }
+
+ cursorPos = TextF_CursorPosition(tf);
+
+@@ -4570,16 +4510,13 @@
+ }
+ }
+ } else {
+- if (_XmTextFieldIsWSpace(TextF_WcValue(tf)[cursorPos],
+- white_space, 3))
++ if (iswspace(TextF_WcValue(tf)[cursorPos]))
+ FindWord(tf, cursorPos, &dummy, &position);
+ else
+ FindNextWord(tf, &dummy, &position);
+- if (_XmTextFieldIsWSpace(TextF_WcValue(tf)[position],
+- white_space, 3)) {
++ if (iswspace(TextF_WcValue(tf)[position])) {
+ for (; position < tf->text.string_length; position++) {
+- if (!_XmTextFieldIsWSpace(TextF_WcValue(tf)[position],
+- white_space, 3))
++ if (!iswspace(TextF_WcValue(tf)[position]))
+ break;
+ }
+ }
diff --git a/main/motif/18-updated-fix-1565.patch b/main/motif/18-updated-fix-1565.patch
new file mode 100644
index 0000000000..850a6e2fbd
--- /dev/null
+++ b/main/motif/18-updated-fix-1565.patch
@@ -0,0 +1,431 @@
+Description: Updated fix for upstream bug #1565
+ This patch fixes the problem introduced by fix #1565, included in
+ Motif 2.3.4, which breaks keyboard navigation in menus.
+Author: Olexiy Chernyavskyy <ochern@ics.com>
+Origin: upstream, http://bugs.motifzone.net/show_bug.cgi?id=1565
+Bug: http://bugs.motifzone.net/show_bug.cgi?id=1630
+Bug-Debian: http://bugs.debian.org/730026
+Last-Update: 2013-11-29
+--- a/lib/Xm/ComboBox.c
++++ b/lib/Xm/ComboBox.c
+@@ -3164,6 +3164,9 @@
+ Arg args[4];
+ ArgList merged_args;
+ Cardinal n;
++#ifdef FIX_1565
++ XmGrabShellWidget grabsh;
++#endif
+
+ n = 0;
+ XtSetArg(args[n], XmNlayoutDirection, LayoutM(parent)), n++;
+@@ -3175,6 +3178,11 @@
+ merged_args, n + *num_args);
+ XtFree((char*)merged_args);
+
++#ifdef FIX_1565
++ grabsh = (XmGrabShellWidget) shell;
++ grabsh->grab_shell.set_input_focus = False;
++#endif
++
+ return shell;
+ }
+
+--- a/lib/Xm/DropDown.c
++++ b/lib/Xm/DropDown.c
+@@ -2027,6 +2027,9 @@
+ Arg *new_list, largs[10];
+ Cardinal num_largs;
+ Widget sb;
++#ifdef FIX_1565
++ XmGrabShellWidget grabsh;
++#endif
+
+ num_largs = 0;
+ XtSetArg(largs[num_largs], XmNoverrideRedirect, True); num_largs++;
+@@ -2040,6 +2043,10 @@
+ xmGrabShellWidgetClass, w,
+ new_list,
+ num_largs + num_args);
++#ifdef FIX_1565
++ grabsh = (XmGrabShellWidget) XmDropDown_popup_shell(cbw);
++ grabsh->grab_shell.set_input_focus = False;
++#endif
+ XtFree((char *) new_list);
+
+ #ifdef FIX_1446
+--- a/lib/Xm/GrabShell.c
++++ b/lib/Xm/GrabShell.c
+@@ -283,6 +283,10 @@
+
+ /* CR 9920: Popdown may be requested before MapNotify. */
+ grabsh->grab_shell.mapped = False;
++
++#ifdef FIX_1565
++ grabsh->grab_shell.set_input_focus = True;
++#endif
+ }
+
+ /*
+@@ -395,8 +399,16 @@
+ XGetInputFocus(XtDisplay(shell), &grabshell->grab_shell.old_focus,
+ &grabshell->grab_shell.old_revert_to);
+ old_handler = XSetErrorHandler(IgnoreXErrors);
+- XSetInputFocus(XtDisplay(shell), XtWindow(shell), RevertToParent, time);
+- XSync(XtDisplay(shell), False);
++#ifdef FIX_1565
++ if (! grabshell->grab_shell.set_input_focus) {
++ XmForceGrabKeyboard(shell, time);
++ } else {
++#endif
++ XSetInputFocus(XtDisplay(shell), XtWindow(shell), RevertToParent, time);
++ XSync(XtDisplay(shell), False);
++#ifdef FIX_1565
++ }
++#endif
+ XSetErrorHandler(old_handler);
+ }
+
+--- a/lib/Xm/GrabShellP.h
++++ b/lib/Xm/GrabShellP.h
+@@ -30,6 +30,7 @@
+ #include <Xm/GrabShell.h>
+ #include <Xm/XmP.h>
+ #include <X11/ShellP.h>
++#include "XmI.h"
+
+ #ifdef __cplusplus
+ extern "C" {
+@@ -55,6 +56,9 @@
+ Boolean mapped;
+ Window old_focus;
+ int old_revert_to;
++#ifdef FIX_1565
++ Boolean set_input_focus;
++#endif
+ } XmGrabShellPart;
+
+
+--- a/lib/Xm/MenuShell.c
++++ b/lib/Xm/MenuShell.c
+@@ -1514,9 +1514,7 @@
+
+ /** the real grab ***/
+ _XmMenuGrabKeyboardAndPointer((Widget)rowcol, _time);
+-#ifndef FIX_1565
+ _XmMenuFocus(XtParent(rowcol), XmMENU_BEGIN, _time);
+-#endif
+
+ /* To support menu replay, keep the pointer in sync mode */
+ XAllowEvents(XtDisplay(rowcol), SyncPointer, CurrentTime);
+--- a/lib/Xm/MenuUtil.c
++++ b/lib/Xm/MenuUtil.c
+@@ -1053,11 +1053,7 @@
+
+ register int status =
+ (_XmGrabKeyboard(widget,
+-#ifdef FIX_1565
+- False,
+-#else
+ True,
+-#endif
+ GrabModeSync,
+ GrabModeAsync,
+ time) != GrabSuccess);
+--- a/lib/Xm/RCMenu.c
++++ b/lib/Xm/RCMenu.c
+@@ -85,6 +85,9 @@
+ #include "TraversalI.h"
+ #include "UniqueEvnI.h"
+ #include "VendorSI.h"
++#ifdef FIX_1565
++#include <Xm/GrabShell.h>
++#endif
+
+ #define FIX_1535
+
+@@ -943,6 +946,13 @@
+ XmMenuState mst = _XmGetMenuState((Widget)w);
+ Window tmpWindow;
+ int tmpRevert;
++#ifdef FIX_1565
++ Widget shell;
++
++ shell = w;
++ while (! XtIsSubclass(shell, shellWidgetClass))
++ shell = XtParent(shell);
++#endif
+
+ if (_time == CurrentTime)
+ _time = XtLastTimestampProcessed(XtDisplay(w));
+@@ -983,6 +993,11 @@
+ shell.popped_up))
+ **/
+ {
++#ifdef FIX_1565
++ if (XtIsSubclass(shell, xmGrabShellWidgetClass) || XtIsSubclass(shell, xmMenuShellWidgetClass))
++ XmForceGrabKeyboard(w, _time);
++ else
++#endif
+ SetInputFocus(XtDisplay(w), mst->RC_menuFocus.oldFocus,
+ mst->RC_menuFocus.oldRevert,
+ mst->RC_menuFocus.oldTime);
+@@ -996,6 +1011,11 @@
+ */
+ else
+ {
++#ifdef FIX_1565
++ if (XtIsSubclass(shell, xmGrabShellWidgetClass) || XtIsSubclass(shell, xmMenuShellWidgetClass))
++ XmForceGrabKeyboard(w, _time);
++ else
++#endif
+ SetInputFocus(XtDisplay(w), mst->RC_menuFocus.oldFocus,
+ mst->RC_menuFocus.oldRevert,
+ mst->RC_menuFocus.oldTime);
+@@ -1014,6 +1034,11 @@
+ RC_menuFocus.oldFocus);
+ mst->RC_menuFocus.oldTime = _time - 1;
+
++#ifdef FIX_1565
++ if (XtIsSubclass(shell, xmGrabShellWidgetClass) || XtIsSubclass(shell, xmMenuShellWidgetClass))
++ XmForceGrabKeyboard(w, _time);
++ else
++#endif
+ SetInputFocus(XtDisplay(w), XtWindow(w), mst->RC_menuFocus.oldRevert,
+ mst->RC_menuFocus.oldTime);
+
+@@ -1027,6 +1052,11 @@
+ XGetInputFocus(XtDisplay(w), &tmpWindow, &tmpRevert);
+ if (tmpWindow != XtWindow(w))
+ {
++#ifdef FIX_1565
++ if (XtIsSubclass(shell, xmGrabShellWidgetClass) || XtIsSubclass(shell, xmMenuShellWidgetClass))
++ XmForceGrabKeyboard(w, _time);
++ else
++#endif
+ SetInputFocus(XtDisplay(w), XtWindow(w), tmpRevert, _time);
+
+ mst->RC_menuFocus.oldRevert = tmpRevert;
+@@ -1048,6 +1078,11 @@
+
+ break;
+ case XmMENU_MIDDLE:
++#ifdef FIX_1565
++ if (XtIsSubclass(shell, xmGrabShellWidgetClass) || XtIsSubclass(shell, xmMenuShellWidgetClass))
++ XmForceGrabKeyboard(w, _time);
++ else
++#endif
+ SetInputFocus(XtDisplay(w), XtWindow(w),
+ mst->RC_menuFocus.oldRevert,
+ mst->RC_menuFocus.oldTime);
+@@ -1062,6 +1097,11 @@
+ if ((tmpWindow != XtWindow(w)) &&
+ (_time > mst->RC_menuFocus.oldTime))
+ {
++#ifdef FIX_1565
++ if (XtIsSubclass(shell, xmGrabShellWidgetClass) || XtIsSubclass(shell, xmMenuShellWidgetClass))
++ XmForceGrabKeyboard(w, _time);
++ else
++#endif
+ SetInputFocus(XtDisplay(w), XtWindow(w), tmpRevert, _time);
+
+ mst->RC_menuFocus.oldRevert = tmpRevert;
+--- a/lib/Xm/Xm.c
++++ b/lib/Xm/Xm.c
+@@ -40,6 +40,10 @@
+ #ifdef FIX_345
+ #include <X11/keysym.h>
+ #endif
++#ifdef FIX_1565
++#include <Xm/GrabShell.h>
++#include <Xm/MenuShell.h>
++#endif
+
+
+ /**************************************************************************
+@@ -530,3 +534,173 @@
+ return p;
+ }
+ #endif
++
++#ifdef FIX_1565
++
++typedef struct _GrabData GrabData;
++struct _GrabData {
++ Widget w;
++ GrabData *next;
++};
++
++static void _XmSendFocusEvent(Widget child, int type);
++static void _XmStartDispatcher(Display *display);
++static Boolean _XmEventDispatcher(XEvent *event);
++static void UnmapHandler(Widget w, XtPointer client_data, XEvent *event, Boolean *cont);
++static Boolean _UngrabKeyboard(Widget w);
++
++static GrabData *grabw_top = NULL;
++static int xm_dispatcher_on = 0;
++static XtEventDispatchProc saved_dispatcher_proc = NULL;
++static XtEventDispatchProc xt_dispatcher_proc = NULL;
++
++/*
++ XmForceGrabKeyboard function is defined to be a substitutor of XSetInputFocus calls
++ for popup and pulldown menus that should grab keyboard focus yet main window at the
++ same time should visually stay in focus for window manager. This resolves focus flip
++ issue when popup or pulldown menu is raised. ~ochern
++ */
++void XmForceGrabKeyboard(Widget w, Time time)
++{
++ GrabData *grabw;
++
++ if (!w)
++ return;
++
++ while (! XtIsSubclass(w, shellWidgetClass))
++ w = XtParent(w);
++
++ if (! (XtIsSubclass(w, xmGrabShellWidgetClass) || XtIsSubclass(w, xmMenuShellWidgetClass)))
++ return;
++
++ _XmStartDispatcher(XtDisplay(w));
++
++ _UngrabKeyboard(w);
++
++ grabw = (GrabData *) XtMalloc(sizeof(GrabData));
++ grabw->w = w;
++ _XmProcessLock();
++ grabw->next = grabw_top;
++ grabw_top = grabw;
++ _XmProcessUnlock();
++
++ XtInsertEventHandler(w, StructureNotifyMask, False, UnmapHandler, NULL, XtListHead);
++
++ _XmSendFocusEvent(w, FocusIn);
++
++ /* Following the XSetInputFocus behaviour we force sending FocusOut (see XGrabKeyboard(3))
++ event to a previous keyboard holder */
++ XtGrabKeyboard(w, True, GrabModeAsync, GrabModeAsync, time);
++}
++
++static void _XmStartDispatcher(Display *display)
++{
++ if (!display)
++ return;
++
++ _XmProcessLock();
++
++ if (xm_dispatcher_on) {
++ _XmProcessUnlock();
++ return;
++ }
++
++ saved_dispatcher_proc = XtSetEventDispatcher(display, KeyPress, _XmEventDispatcher);
++ if (! xt_dispatcher_proc)
++ xt_dispatcher_proc = saved_dispatcher_proc;
++ XtSetEventDispatcher(display, KeyRelease, _XmEventDispatcher);
++ xm_dispatcher_on = 1;
++
++ _XmProcessUnlock();
++}
++
++static Boolean _XmEventDispatcher(XEvent *event)
++{
++ _XmProcessLock();
++ if (grabw_top) {
++ if (event->type == KeyPress || event->type == KeyRelease)
++ event->xany.window = XtWindow(grabw_top->w);
++ }
++ _XmProcessUnlock();
++
++ if (saved_dispatcher_proc) {
++ return (*saved_dispatcher_proc)(event);
++ } else if (xt_dispatcher_proc) {
++ return (*xt_dispatcher_proc)(event);
++ } else {
++ if (grabw_top)
++ XtSetEventDispatcher(XtDisplay(grabw_top->w), event->type, NULL);
++ return XtDispatchEvent(event);
++ }
++}
++
++static void UnmapHandler(Widget w, XtPointer client_data, XEvent *event, Boolean *cont)
++{
++ if (event->type == UnmapNotify)
++ _UngrabKeyboard(w);
++ if (! grabw_top) {
++ XtSetEventDispatcher(XtDisplay(w), KeyPress, saved_dispatcher_proc);
++ XtSetEventDispatcher(XtDisplay(w), KeyRelease, saved_dispatcher_proc);
++ xm_dispatcher_on = 0;
++ }
++
++ /* we do not call XtUngrabKeyboard since X server automatically performs an
++ UngrabKeyboard request if the event window for an active keyboard grab becomes
++ not viewable. ~ochern */
++}
++
++static Boolean _UngrabKeyboard(Widget w)
++{
++ GrabData *grabw, *grabw_prev;
++
++ _XmProcessLock();
++ if (! grabw_top) {
++ _XmProcessUnlock();
++ return False;
++ }
++
++ grabw = grabw_top;
++ grabw_prev = NULL;
++ while(grabw && grabw->w != w) {
++ grabw_prev = grabw;
++ grabw = grabw->next;
++ }
++ if (grabw) {
++ if (grabw_prev)
++ grabw_prev->next = grabw->next;
++ else
++ grabw_top = grabw->next;
++ XtFree((char*) grabw);
++
++ _XmProcessUnlock();
++ return True;
++ }
++
++ _XmProcessUnlock();
++ return False;
++}
++
++static void _XmSendFocusEvent(Widget child, int type)
++{
++ child = XtIsWidget(child) ? child : _XtWindowedAncestor(child);
++ if (XtIsSensitive(child) && !child->core.being_destroyed
++ && XtIsRealized(child) && (XtBuildEventMask(child) & FocusChangeMask))
++ {
++ XFocusChangeEvent event;
++ Display* dpy = XtDisplay (child);
++
++ event.type = type;
++ event.serial = LastKnownRequestProcessed(dpy);
++ event.send_event = True;
++ event.display = dpy;
++ event.window = XtWindow(child);
++ event.mode = NotifyNormal;
++ event.detail = NotifyAncestor;
++ if (XFilterEvent((XEvent*)&event, XtWindow(child)))
++ return;
++ XtDispatchEventToWidget(child, (XEvent*)&event);
++ }
++}
++
++#endif
++
+--- a/lib/Xm/XmI.h
++++ b/lib/Xm/XmI.h
+@@ -242,7 +242,9 @@
+ extern XChar2b* _XmUtf8ToUcs2(char *draw_text,
+ size_t seg_len,
+ size_t *ret_str_len);
+-
++#ifdef FIX_1565
++extern void XmForceGrabKeyboard(Widget w, Time time);
++#endif
+
+ /******** End Private Function Declarations ********/
+
diff --git a/main/motif/APKBUILD b/main/motif/APKBUILD
new file mode 100644
index 0000000000..2e4dda47aa
--- /dev/null
+++ b/main/motif/APKBUILD
@@ -0,0 +1,135 @@
+# Contributor: Isaac Dunham <ibid.ag@gmail.com>
+# Maintainer: Isaac Dunham <ibid.ag@gmail.com>
+
+
+pkgname=motif
+pkgver=2.3.4
+pkgrel=2
+pkgdesc="The Motif library"
+url="http://motif.ics.com/"
+arch="all"
+license="LGPL2+"
+depends=""
+depends_dev="libx11-dev libxft-dev libxt-dev libxpm-dev libxext-dev xbitmaps"
+makedepends="$depends_dev libtool autoconf automake flex flex-libs flex-dev bison"
+install=""
+subpackages="mwm $pkgname-dev $pkgname-doc"
+source="http://downloads.sourceforge.net/$pkgname/Motif%20$pkgver%20Source%20Code/motif-$pkgver-src.tgz
+01-fix-autoconf.patch
+02-fix-format-security.patch
+03-no-demos.patch
+06-cast-size_t-to-int.patch
+07-fix_lintian_reported_manpage_typos.patch
+08-fix_hyphen_in_man_pages.patch
+09-fix_typo_in_libxm.patch
+10-fix_manpage-has-bad-whatis-entry.patch
+11-fix_underlinking.patch
+12-fix_buffer_overrun_in_libxm.patch
+13-fix_hardcoded_x11rgb_path.patch
+14-fix_ac_find_xft.patch
+15-link_uil_against_libuil.patch
+16-fix-undefined-use-of-sprintf.patch
+17-switch-to-system-iswspace.patch
+18-updated-fix-1565.patch"
+
+_builddir="$srcdir/$pkgname-$pkgver"
+prepare() {
+ local i
+ cd "$_builddir"
+ for i in $source; do
+ case $i in
+ *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+ esac
+ done
+}
+
+build() {
+# reasons for --disable- flags:
+#png, jpeg: most programs that use png and jpeg use the libraries directly;
+# enabling these mainly matters if you want to point the resources at a
+# png/jpeg image.
+#printing: this is Xprint support; only CDE uses this, others print directly.
+#demos: one of the demos can break the build
+ cd "$_builddir"
+ ./autogen.sh \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --disable-demos \
+ --disable-printing \
+ --disable-jpeg \
+ --disable-png \
+ --enable-xft \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --localstatedir=/var \
+ || return 1
+ make || return 1
+}
+
+package() {
+ cd "$_builddir"
+ make DESTDIR="$pkgdir" install || return 1
+ rm -f "$pkgdir"/usr/lib/*.la
+}
+
+mwm() {
+ mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/lib/X11
+ mv "$pkgdir"/usr/bin/mwm "$subpkgdir"/usr/bin
+ mv "$pkgdir"/usr/bin/xmbind "$subpkgdir"/usr/bin
+ sed -e 's/\(xterm\)/xfce4-terminal||mrxvt||urxvt||st||\1/g' \
+ "$pkgdir"/usr/lib/X11/system.mwmrc > "$subpkgdir"/usr/lib/X11/system.mwmrc
+}
+
+
+md5sums="612bb8127d0d31da6e5474edf8a5c247 motif-2.3.4-src.tgz
+191cee7af8137e75385153a8f334f50c 01-fix-autoconf.patch
+34044aeba20b7e4e9c543c771ce015f6 02-fix-format-security.patch
+7302c76677201e0be743fe3bb7f1cc8b 03-no-demos.patch
+bb676bc8f0a0d24fbb5c599b72dc827a 06-cast-size_t-to-int.patch
+ec750525c43510227b834d70239f7af4 07-fix_lintian_reported_manpage_typos.patch
+d6d836f83e3f9c9b2754f3486c7e3682 08-fix_hyphen_in_man_pages.patch
+829ee2d6e21de7463bc12ef35347a000 09-fix_typo_in_libxm.patch
+b993f84341d5b015ae1059b68af5ab55 10-fix_manpage-has-bad-whatis-entry.patch
+96bc3c48348c635e3ba03369632fbf09 11-fix_underlinking.patch
+7bb10fb0f0ddaa1c11a43b7110e0f3ff 12-fix_buffer_overrun_in_libxm.patch
+a283720664a1338157532e0b62164f91 13-fix_hardcoded_x11rgb_path.patch
+384688cde092594baf5a9cda9e6ea61d 14-fix_ac_find_xft.patch
+d4e5e74014da80985290d44e52e6296b 15-link_uil_against_libuil.patch
+9a7b47b601ecfc9639c54563e764851a 16-fix-undefined-use-of-sprintf.patch
+382bca380e52e377388a131df9c76245 17-switch-to-system-iswspace.patch
+6ef23e3053818411b2b75c2f40cbfa22 18-updated-fix-1565.patch"
+sha256sums="637efa09608e0b8f93465dbeb7c92e58ebb14c4bc1b488040eb79a65af3efbe0 motif-2.3.4-src.tgz
+cfdd253918b2fdbfa1803d59c7b1a20431a74de4227d20db0343aab866505c21 01-fix-autoconf.patch
+b679d4274c18fd4e29aad8fc757d0d635ce715329b28e8f46f6952ed9a8f390d 02-fix-format-security.patch
+c084ed5838c50296e18bd1354e812699e891d4a326c3fdd6e262a7a9e33eea8d 03-no-demos.patch
+85afe090f6f45ed4baef76a7d73cebf70343a6aaee0209cb4a12ac34b48610c4 06-cast-size_t-to-int.patch
+90e8ac475990c130345f0a1f9365329599184a4f1112dc863f33f727abee22d1 07-fix_lintian_reported_manpage_typos.patch
+5fda6f879619c3d9761b222114e8ee0f548f874cca8ae9122d1b436c96a58d8d 08-fix_hyphen_in_man_pages.patch
+6bd8872bf3099e57a3c47752c5c469b449901be0ede07a5301b7c05eb3a0067a 09-fix_typo_in_libxm.patch
+54481c6a3990b0c2034b759ee4bb28b03880ff6fc0cbca2e8c3f4263830358b1 10-fix_manpage-has-bad-whatis-entry.patch
+86ad1f5c40e1d8f69b927c87e5fcf39b7ce260d4cd156e4cbe9ad0a205ad72cb 11-fix_underlinking.patch
+3664820ec7c2639c4ab66f412121c1e8bcb8ce998a6a3743955e4b5ca7824d5e 12-fix_buffer_overrun_in_libxm.patch
+60b01485d2ef9302533d660eef91e5023d04e71c9d9e727c147f873f2fe86ba2 13-fix_hardcoded_x11rgb_path.patch
+1fe5efb1920c897c979f9292dc93e59d1315c145493fa591ec0000ba6e99eb7e 14-fix_ac_find_xft.patch
+ab061e0cca20b29f5337fed663eef7560defbdf6d0cf0fe21bf3377aaf516dca 15-link_uil_against_libuil.patch
+2bfb2957478f8c66554090dc171f885dc75bf3b0586e3b1abe7c3702f0ef23a2 16-fix-undefined-use-of-sprintf.patch
+8039b803716007d6959101592571f82f3be7590b86ba4d3160ae3b5362745a61 17-switch-to-system-iswspace.patch
+007dec8a19aae3a59723359bc7457692c0d2a6fbf68fc91b8d6e0e866277c8d7 18-updated-fix-1565.patch"
+sha512sums="fb1033caa68f25b93282fa6700d5b7856be217b3651072d86e7c93a747df5b31219230998eb93deae22a8fa698e816b1a30e52b3ae88ae1c01c1f0aac59a2af2 motif-2.3.4-src.tgz
+6ca24c74233552a4ce3ebb72f17ed277a3feca10bfa50c4680ed1eff917a11bf1f0bd39bcfdaaef1104466065c25c70251ba450f884bca637bc935565d0cdd9d 01-fix-autoconf.patch
+aff5be25bd25666e6134bc18faaffd54914cc390ca4d89a498efae5aa6dd175ac2b17dc719f7b8d27cff5db2f17b714ddfd5a163f219cad5f5c949cf5eb4786d 02-fix-format-security.patch
+a54e0bbf95b7af1a2ba3a6031b3d4f36b6516d4b30d97804158c20b7cccda5df9628ed9a3c84ddda7cbd7779781ad065b0a16d39115184eff9fa509f6ec75ec6 03-no-demos.patch
+605f3cc868c179c74ada49bd4ed40a39364f5d883866c99a9e8ffdb1c559e5e06ebf92a776b6a10df516b7f82a186b0084e55a9be1076498f5b742ca9376febc 06-cast-size_t-to-int.patch
+0c4f678e34a00e3281337b06dffbf5f50d345f66b86bb86dd1532d435ce1630443f8ec6245bb773143783d1b5e6e99da5f1e68bd7391e23ee0a10e4fb99ed737 07-fix_lintian_reported_manpage_typos.patch
+fc955d88cc5c64655ec642786449968e2241c92653fec00bcf8a722d2c206a2ebad16e42529d4ba1905d40e4239e567189b7abd1b9f1c2bdad944cb134094b7c 08-fix_hyphen_in_man_pages.patch
+9157f68bf111b081811e08e43b0b67f31364230fd480381668750e130e264867697d3fc461d2011117ee267ebf3801c39d04b24d4c213433ac4a213b6ad8683a 09-fix_typo_in_libxm.patch
+8081bddd444423cfe34995cef6c52eebf98d98616f34e9f9eae6240cfbfe8269cab2bdfbac7f85be85371a6f7375452471b32082d4a2dd0cffee242afe115c2f 10-fix_manpage-has-bad-whatis-entry.patch
+18c155c13a21df3c95e94d15a8f31def6f40257baadc2ec9e29eef3e10197343824adeef54b75863cd9de25b5f46c4dc88e1e1f991f75c59048fc483a1ea1b43 11-fix_underlinking.patch
+666d0e0fe1ac9b63942224b4f49711e2590a99409fbf8893570f9b87b6e4f8f80e14c780fd2c4cdd664c6f130ee929b89bb20e189338c73dc7daf2750aa0c382 12-fix_buffer_overrun_in_libxm.patch
+21dd0ba7fd9ed234d5115ad24547961592dd35c3d4843856800a564ff380482af0c5a35e3ce60d3258e4e9a47cb537435b4f08f460064e130d4327a4955b9975 13-fix_hardcoded_x11rgb_path.patch
+fcb28b3527821c6f4dce0aa86e864f21bf7261ed8a88766858b6f5d4a9ad7affcf94e49c586ae0e87a324a92404fea5965bff2959b2482035e49983d07b5ea45 14-fix_ac_find_xft.patch
+8a726e253fa6ed8d14914fd2e2eb0bce8f240051a5fefc04ff56899f908a26300ad3292507b71c1ce65f57e7889e4067e35d0ab4ce15123bffccb606dfd9067f 15-link_uil_against_libuil.patch
+2230f0af607111d014b0a648b807df18676a4a1421f10978c59a0a29b02dda38060163619bc54fda19a5186315f98fc8597b2ef6eb8ab7bedb6bd6972a77b38d 16-fix-undefined-use-of-sprintf.patch
+0cb0fa3a02a452f067649e02e855d6d3d728e4904bad009aebda9250de0c9fb76d352b6d9a857fcd1f920c5dfc6183f9b12886505c5570164fe92e99e97eea15 17-switch-to-system-iswspace.patch
+15cbb37beebf4b06b65a09612a05e4a5b2eaab09d23860332c90aec02cf8a59e0d351dce831eb98a774cb98d15c2ecf695669e5b5e6d0dcce77ce6b2658a8a84 18-updated-fix-1565.patch"