APPROVE COMMIT
NOTE: This patch has been committed
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1530824281 -3600
#      Thu Jul 05 21:58:01 2018 +0100
# Node ID 8d3aef8af4dfcc40d85867e5494d24d8c637d5e9
# Parent  3c7e9dbadbbcd1d3a85c798275e0cfb283519955
Silence an extensive list of byte-compiler warnings, lisp/
lisp/ChangeLog addition:
2018-07-05  Aidan Kehoe  <kehoea(a)parhasard.net>
	Silence an extensive list of byte compile warnings, chiefly
	through use of #'globally-declare-fboundp and
	#'globally-declare-boundp.
	Also prefer (default-device 'x) to (default-x-device), since the
	former always exists when byte compiling.
	* autoload.el:
	* autoload.el (make-autoload):
	* autoload.el (autoload-make-autoload-operators): New.
	* autoload.el (autoload-make-autoload-complex-operators): New.
	Be a bit better about silencing byte compile warnings regarding
	autoload-make-autoload-operators here
	* behavior.el:
	* behavior.el (unless):
	* buff-menu.el:
	* buff-menu.el (unless):
	* cmdloop.el:
	* cmdloop.el (unless):
	* cmdloop.el (yes-or-no-p):
	* cmdloop.el (y-or-n-p):
	* cus-edit.el:
	* cus-edit.el (unless):
	* custom.el (custom-theme-reset-internal-face):
	* custom.el (custom-define-hook):
	* dialog-items.el:
	* dialog-items.el (unless):
	* dialog.el:
	* easymenu.el:
	* easymenu.el (unless):
	* font-menu.el:
	* font-menu.el (unless):
	* font.el:
	* font.el (fontconfig):
	* font.el (font-xft-font-regexp):
	* font.el (font-xft-font-regexp)): New.
	* font.el (x-font-build-cache):
	* font.el (xft-font-create-object):
	* fontconfig.el (fc-try-font):
	* fontconfig.el (fc-find-available-font-families):
	* fontconfig.el (fc-find-available-weights-for-family):
	* gnuserv.el:
	* gnuserv.el (unless):
	* gtk-faces.el:
	* gtk-faces.el (unless):
	* gtk-faces.el (gtk-convert-font-from-xlfd):
	* help.el:
	* help.el (unless):
	* help.el (help):
	* hyper-apropos.el:
	* hyper-apropos.el (unless):
	* info.el:
	* info.el (unless):
	* lisp-mode.el:
	* lisp-mode.el (unless):
	* menubar-items.el:
	* menubar-items.el (unless):
	* menubar.el:
	* menubar.el (unless):
	* minibuf.el:
	* minibuf.el (unless):
	* minibuf.el (insert-default-directory):
	* mode-motion.el:
	* mode-motion.el (mouse):
	* modeline.el:
	* modeline.el (unless):
	* mouse.el:
	* mouse.el (unless):
	* mouse.el (shift):
	* msw-select.el:
	* msw-select.el (unless):
	* mule/mule-charset.el (do-define-charset-tags):
	* mule/mule-charset.el (script):
	* mwheel.el:
	* mwheel.el (unless):
	* occur.el:
	* occur.el (unless):
	* package-ui.el:
	* package-ui.el (unless):
	* picture.el:
	* picture.el (unless):
	* printer.el:
	* printer.el (unless):
	* scrollbar.el:
	* scrollbar.el (unless):
	* select.el:
	* select.el (unless):
	* startup.el:
	* startup.el (unless):
	* toolbar-items.el:
	* toolbar-items.el (unless):
	* toolbar.el:
	* toolbar.el (unless):
	* userlock.el:
	* userlock.el (unless):
	* userlock.el (ask-user-about-lock-minibuf):
	* wid-edit.el:
	* wid-edit.el (unless):
	* x-faces.el (x-make-font-bold-xft):
	* x-faces.el (x-make-font-unbold-xft):
	* x-faces.el (x-make-font-italic-xft):
	* x-faces.el (x-make-font-unitalic-xft):
	* x-faces.el (x-font-size-xft):
	* x-faces.el (x-find-xft-font-of-size):
	* x-font-menu.el:
	* x-font-menu.el (unless):
	* x-init.el:
	* x-init.el (unless):
	* x-mouse.el:
	* x-mouse.el (unless):
	* x-scrollbar.el:
	* x-scrollbar.el (unless):
	* x-scrollbar.el (x-init-scrollbar-from-resources):
	* x-win-sun.el:
	* x-win-sun.el (unless):
	* x-win-sun.el (x-win-init-sun):
	* x-win-xfree86.el:
	* x-win-xfree86.el (unless):
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/ChangeLog
--- a/lisp/ChangeLog	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/ChangeLog	Thu Jul 05 21:58:01 2018 +0100
@@ -1,3 +1,125 @@
+2018-07-05  Aidan Kehoe  <kehoea(a)parhasard.net>
+
+	Silence an extensive list of byte compile warnings, chiefly
+	through use of #'globally-declare-fboundp and
+	#'globally-declare-boundp.
+
+	Also prefer (default-device 'x) to (default-x-device), since the
+	former always exists when byte compiling.
+
+	* autoload.el:
+	* autoload.el (make-autoload):
+	* autoload.el (autoload-make-autoload-operators): New.
+	* autoload.el (autoload-make-autoload-complex-operators): New.
+	Be a bit better about silencing byte compile warnings regarding
+	autoload-make-autoload-operators here
+
+	* behavior.el:
+	* behavior.el (unless):
+	* buff-menu.el:
+	* buff-menu.el (unless):
+	* cmdloop.el:
+	* cmdloop.el (unless):
+	* cmdloop.el (yes-or-no-p):
+	* cmdloop.el (y-or-n-p):
+	* cus-edit.el:
+	* cus-edit.el (unless):
+	* custom.el (custom-theme-reset-internal-face):
+	* custom.el (custom-define-hook):
+	* dialog-items.el:
+	* dialog-items.el (unless):
+	* dialog.el:
+	* easymenu.el:
+	* easymenu.el (unless):
+	* font-menu.el:
+	* font-menu.el (unless):
+	* font.el:
+	* font.el (fontconfig):
+	* font.el (font-xft-font-regexp):
+	* font.el (font-xft-font-regexp)): New.
+	* font.el (x-font-build-cache):
+	* font.el (xft-font-create-object):
+	* fontconfig.el (fc-try-font):
+	* fontconfig.el (fc-find-available-font-families):
+	* fontconfig.el (fc-find-available-weights-for-family):
+	* gnuserv.el:
+	* gnuserv.el (unless):
+	* gtk-faces.el:
+	* gtk-faces.el (unless):
+	* gtk-faces.el (gtk-convert-font-from-xlfd):
+	* help.el:
+	* help.el (unless):
+	* help.el (help):
+	* hyper-apropos.el:
+	* hyper-apropos.el (unless):
+	* info.el:
+	* info.el (unless):
+	* lisp-mode.el:
+	* lisp-mode.el (unless):
+	* menubar-items.el:
+	* menubar-items.el (unless):
+	* menubar.el:
+	* menubar.el (unless):
+	* minibuf.el:
+	* minibuf.el (unless):
+	* minibuf.el (insert-default-directory):
+	* mode-motion.el:
+	* mode-motion.el (mouse):
+	* modeline.el:
+	* modeline.el (unless):
+	* mouse.el:
+	* mouse.el (unless):
+	* mouse.el (shift):
+	* msw-select.el:
+	* msw-select.el (unless):
+	* mule/mule-charset.el (do-define-charset-tags):
+	* mule/mule-charset.el (script):
+	* mwheel.el:
+	* mwheel.el (unless):
+	* occur.el:
+	* occur.el (unless):
+	* package-ui.el:
+	* package-ui.el (unless):
+	* picture.el:
+	* picture.el (unless):
+	* printer.el:
+	* printer.el (unless):
+	* scrollbar.el:
+	* scrollbar.el (unless):
+	* select.el:
+	* select.el (unless):
+	* startup.el:
+	* startup.el (unless):
+	* toolbar-items.el:
+	* toolbar-items.el (unless):
+	* toolbar.el:
+	* toolbar.el (unless):
+	* userlock.el:
+	* userlock.el (unless):
+	* userlock.el (ask-user-about-lock-minibuf):
+	* wid-edit.el:
+	* wid-edit.el (unless):
+	* x-faces.el (x-make-font-bold-xft):
+	* x-faces.el (x-make-font-unbold-xft):
+	* x-faces.el (x-make-font-italic-xft):
+	* x-faces.el (x-make-font-unitalic-xft):
+	* x-faces.el (x-font-size-xft):
+	* x-faces.el (x-find-xft-font-of-size):
+	* x-font-menu.el:
+	* x-font-menu.el (unless):
+	* x-init.el:
+	* x-init.el (unless):
+	* x-mouse.el:
+	* x-mouse.el (unless):
+	* x-scrollbar.el:
+	* x-scrollbar.el (unless):
+	* x-scrollbar.el (x-init-scrollbar-from-resources):
+	* x-win-sun.el:
+	* x-win-sun.el (unless):
+	* x-win-sun.el (x-win-init-sun):
+	* x-win-xfree86.el:
+	* x-win-xfree86.el (unless):
+
 2018-07-05  Aidan Kehoe  <kehoea(a)parhasard.net>
 
 	* cl-macs.el (defsubst*):
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/autoload.el
--- a/lisp/autoload.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/autoload.el	Thu Jul 05 21:58:01 2018 +0100
@@ -228,36 +228,35 @@
 ; package.
 (ignore-errors (require 'autoload-operators))
 
-; As autoload-operators is new, provide stopgap measure for a while.
-(if (not (boundp 'autoload-make-autoload-operators))
-    (progn
-      (defvar autoload-make-autoload-operators
-	'(defun define-skeleton defmacro define-derived-mode define-generic-mode
-	  easy-mmode-define-minor-mode easy-mmode-define-global-mode
-	  define-minor-mode defun* defmacro*)
-	"`defun'-like operators that use `autoload' to load the library.")
-      
-      (defvar autoload-make-autoload-complex-operators
-	'(easy-mmode-define-minor-mode easy-mmode-define-global-mode
-	  define-minor-mode)
-	"`defun'-like operators to macroexpand before using `autoload'.")
-      
-      (put 'autoload 'doc-string-elt 3)
-      (put 'defun    'doc-string-elt 3)
-      (put 'defun*   'doc-string-elt 3)
-      (put 'defvar   'doc-string-elt 3)
-      (put 'defcustom 'doc-string-elt 3)
-      (put 'defconst 'doc-string-elt 3)
-      (put 'defmacro 'doc-string-elt 3)
-      (put 'defmacro* 'doc-string-elt 3)
-      (put 'defsubst 'doc-string-elt 3)
-      (put 'define-skeleton 'doc-string-elt 2)
-      (put 'define-derived-mode 'doc-string-elt 4)
-      (put 'easy-mmode-define-minor-mode 'doc-string-elt 2)
-      (put 'define-minor-mode 'doc-string-elt 2)
-      (put 'define-generic-mode 'doc-string-elt 7)
-      ;; defin-global-mode has no explicit docstring.
-      (put 'easy-mmode-define-global-mode 'doc-string-elt 1000)))
+; As autoload-operators is new, provide stopgap measure for a
+; while. This defvar won't override the value from
+; autoload-operators.el, if that has been loaded.
+(defvar autoload-make-autoload-operators
+  '(defun define-skeleton defmacro define-derived-mode define-generic-mode
+    easy-mmode-define-minor-mode easy-mmode-define-global-mode
+    define-minor-mode defun* defmacro*))
+
+(defvar autoload-make-autoload-complex-operators
+  '(easy-mmode-define-minor-mode easy-mmode-define-global-mode
+    define-minor-mode))
+
+(unless (featurep 'autoload-operators)
+  (put 'autoload 'doc-string-elt 3)
+  (put 'defun    'doc-string-elt 3)
+  (put 'defun*   'doc-string-elt 3)
+  (put 'defvar   'doc-string-elt 3)
+  (put 'defcustom 'doc-string-elt 3)
+  (put 'defconst 'doc-string-elt 3)
+  (put 'defmacro 'doc-string-elt 3)
+  (put 'defmacro* 'doc-string-elt 3)
+  (put 'defsubst 'doc-string-elt 3)
+  (put 'define-skeleton 'doc-string-elt 2)
+  (put 'define-derived-mode 'doc-string-elt 4)
+  (put 'easy-mmode-define-minor-mode 'doc-string-elt 2)
+  (put 'define-minor-mode 'doc-string-elt 2)
+  (put 'define-generic-mode 'doc-string-elt 7)
+  ;; defin-global-mode has no explicit docstring.
+  (put 'easy-mmode-define-global-mode 'doc-string-elt 1000))
 
 (defun make-autoload (form file)
   "Turn FORM into an autoload or defvar for source file FILE.
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/behavior.el
--- a/lisp/behavior.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/behavior.el	Thu Jul 05 21:58:01 2018 +0100
@@ -165,6 +165,10 @@
 
 ;;; Code:
 
+(globally-declare-fboundp
+ (unless (featurep 'menubar)
+   '(submenu-generate-accelerator-spec menu-split-long-menu menu-sort-menu)))
+
 ;; Hash table mapping behavior names to property lists, with entries for
 ;; :group, :custom-group, :short-doc, :require, :enable, :disable,
 ;; and :commands.
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/buff-menu.el
--- a/lisp/buff-menu.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/buff-menu.el	Thu Jul 05 21:58:01 2018 +0100
@@ -47,6 +47,10 @@
 
 ;;; Code:
 
+(globally-declare-fboundp (unless (featurep 'mouse) '(mouse-set-point)))
+
+(globally-declare-fboundp (unless (featurep 'menubar) '(popup-menu)))
+
 ;;;Trying to preserve the old window configuration works well in
 ;;;simple scenarios, when you enter the buffer menu, use it, and exit it.
 ;;;But it does strange things when you switch back to the buffer list buffer
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/cmdloop.el
--- a/lisp/cmdloop.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/cmdloop.el	Thu Jul 05 21:58:01 2018 +0100
@@ -32,6 +32,9 @@
 
 ;;; Code:
 
+(globally-declare-fboundp
+ (unless (featurep 'dialog) '(yes-or-no-p-dialog-box)))
+
 (defun recursion-depth ()
   "Return the current depth in recursive edits."
   (+ command-loop-level (minibuffer-depth)))
@@ -509,7 +512,7 @@
       ;; and-fboundp is redundant, since yes-or-no-p-dialog-box is only
       ;; bound if (featurep 'dialog). But it eliminates a compile-time
       ;; warning.
-      (and-fboundp 'yes-or-no-p-dialog-box (yes-or-no-p-dialog-box prompt))
+      (yes-or-no-p-dialog-box prompt)
     (yes-or-no-p-minibuf prompt)))
 
 (defun y-or-n-p (prompt)
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/cus-edit.el
--- a/lisp/cus-edit.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/cus-edit.el	Thu Jul 05 21:58:01 2018 +0100
@@ -49,6 +49,9 @@
 
 ;;; Code:
 
+(globally-declare-fboundp
+ (unless (featurep 'menubar) '(menu-split-long-menu)))
+
 (require 'cus-face)
 (require 'wid-edit)
 (require 'easymenu)
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/custom.el
--- a/lisp/custom.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/custom.el	Thu Jul 05 21:58:01 2018 +0100
@@ -42,6 +42,7 @@
 (provide 'custom)
 
 (autoload 'custom-declare-face "cus-face")
+(autoload 'custom-theme-reset-internal-face "cus-face")
 
 (require 'widget)
 
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/dialog-items.el
--- a/lisp/dialog-items.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/dialog-items.el	Thu Jul 05 21:58:01 2018 +0100
@@ -25,6 +25,8 @@
 
 ;;; Commentary:
 
+(globally-declare-fboundp (unless (featurep 'dialog) '(make-dialog-box)))
+
 ;;
 ;; Simple search dialog
 ;;
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/dialog.el
--- a/lisp/dialog.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/dialog.el	Thu Jul 05 21:58:01 2018 +0100
@@ -39,6 +39,13 @@
 ;; yes-or-no-p-dialog-box, but such code is difficult to write and test.
 
 ;;; Code:
+
+(globally-declare-fboundp
+ (unless (featurep 'dialog) '(make-dialog-box-internal)))
+
+(globally-declare-boundp
+ (unless (featurep 'dialog) '(dialog-frame-plist)))
+
 (defun yes-or-no-p-dialog-box (prompt)
   "Ask user a yes-or-no question with a popup dialog box.
 Return t if the answer is \"yes\".
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/easymenu.el
--- a/lisp/easymenu.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/easymenu.el	Thu Jul 05 21:58:01 2018 +0100
@@ -82,6 +82,13 @@
 
 ;;; Code:
 
+(globally-declare-boundp (unless (featurep 'menubar) '(current-menubar)))
+
+(globally-declare-fboundp
+ (unless (featurep 'menubar)
+   '(set-buffer-menubar add-menu delete-menu-item add-menu-button
+     find-menu-item)))
+
 ;; ;;;###autoload
 (defmacro easy-menu-define (symbol maps doc menu)
   "Define a menu bar submenu in maps MAPS, according to MENU.
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/font-menu.el
--- a/lisp/font-menu.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/font-menu.el	Thu Jul 05 21:58:01 2018 +0100
@@ -117,6 +117,12 @@
 ;;;  "-dt-interface user-medium-r-normal-s-14-120-75-75-m-120-jisx0208.1983-0"
 ;;;  "-dt-interface user-medium-r-normal-s-14-120-75-75-m-60-jisx0201.1976-0")
 
+(globally-declare-fboundp
+ (unless (featurep 'menubar)
+   '(menu-split-long-menu menu-item-strip-accelerator-spec enable-menu-item
+     disable-menu-item select-toggle-menu-item deselect-toggle-menu-item
+     submenu-generate-accelerator-spec)))
+
 ;;;###autoload
 (defcustom font-menu-ignore-scaled-fonts nil
   "*If non-nil, the font menu shows only bitmap fonts.
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/font.el
--- a/lisp/font.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/font.el	Thu Jul 05 21:58:01 2018 +0100
@@ -59,6 +59,7 @@
    mswindows-font-regexp))
 
 (require 'cl)
+(require 'fontconfig)
 
 (eval-and-compile
   (defvar device-fonts-cache)
@@ -560,6 +561,8 @@
     )
   "A list of font family mappings on X devices.")
 
+(defvar font-xft-font-regexp)
+
 (defun x-font-create-object (fontname &optional device)
   "Return a font descriptor object for FONTNAME, appropriate for X devices."
   (let ((case-fold-search t))
@@ -713,7 +716,7 @@
     (while fonts
       (setq cur (car fonts)
 	    fonts (cdr fonts)
-	    plist (cl-gethash (car (font-family cur)) hash-table))
+	    plist (gethash (car (font-family cur)) hash-table))
       (if (not (memq (font-weight cur) (plist-get plist 'weights)))
 	  (setq plist (plist-put plist 'weights (cons (font-weight cur)
 						      (plist-get plist 'weights)))))
@@ -726,7 +729,7 @@
       (if (and (font-italic-p cur)
 	       (not (memq 'italic (plist-get plist 'styles))))
 	  (setq plist (plist-put plist 'styles (cons 'italic (plist-get plist 'styles)))))
-      (cl-puthash (car (font-family cur)) plist hash-table))
+      (puthash (car (font-family cur)) plist hash-table))
     hash-table))
 
 
@@ -785,7 +788,7 @@
 
 Optional DEVICE defaults to `default-x-device'."
   (let* ((name fontname)
-	 (device (or device (default-x-device)))
+	 (device (or device (default-device 'x)))
 	 ;; names generated by font-instance-truename may contain
 	 ;; unparseable object specifications
 	 (pattern (fc-font-match device (fc-name-parse-harder name)))
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/fontconfig.el
--- a/lisp/fontconfig.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/fontconfig.el	Thu Jul 05 21:58:01 2018 +0100
@@ -474,7 +474,7 @@
 FONT may be a fontconfig pattern object or a fontconfig font name (a string).
 Optional DEVICE is the device object to query, defaulting to the currently
 selected device."
-  (fc-list-fonts-pattern-objects (or device (default-x-device))
+  (fc-list-fonts-pattern-objects (or device (default-device 'x))
 				 (if (fc-pattern-p font) 
 				     font
 				   (fc-name-parse font))
@@ -488,7 +488,7 @@
 
 (defun fc-find-available-font-families (&optional device filter-fun)
   "Find all available font families."
-  (let ((device (or device (default-x-device)))
+  (let ((device (or device (default-device 'x)))
 	(pattern (make-fc-pattern))
 	(objectset '("family" "style")))
     (let* ((all-fonts
@@ -503,7 +503,7 @@
 
 (defun fc-find-available-weights-for-family (family &optional style device)
   "Find available weights for font FAMILY."
-  (let* ((device (or device (default-x-device)))
+  (let* ((device (or device (default-device 'x)))
 	 (pattern (make-fc-pattern))
 	 (objectset '("weight")))
     (fc-pattern-add-family pattern family)
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/gnuserv.el
--- a/lisp/gnuserv.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/gnuserv.el	Thu Jul 05 21:58:01 2018 +0100
@@ -81,6 +81,12 @@
 
 ;;; Code:
 
+(globally-declare-boundp (unless (featurep 'menubar) '(current-menubar)))
+
+(globally-declare-fboundp
+ (unless (featurep 'menubar)
+   '(set-buffer-menubar add-menu-button delete-menu-item)))
+
 (defgroup gnuserv nil
   "The gnuserv suite of programs to talk to Emacs from outside."
   :group 'environment
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/gtk-faces.el
--- a/lisp/gtk-faces.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/gtk-faces.el	Thu Jul 05 21:58:01 2018 +0100
@@ -30,17 +30,23 @@
 ;; This file is dumped with XEmacs (when GTK support is compiled in).
 
 (globally-declare-fboundp
- '(gtk-init-pointers
-   gtk-font-selection-dialog-new
-   gtk-widget-set-sensitive gtk-font-selection-dialog-apply-button
-   gtk-signal-connect gtk-main-quit
-   gtk-font-selection-dialog-ok-button
-   gtk-font-selection-dialog-get-font-name gtk-widget-destroy
-   font-menu-set-font font-family font-size
-   gtk-font-selection-dialog-cancel-button gtk-widget-show-all
-   gtk-main gtk-style-info))
+ (unless (valid-device-type-p 'gtk)
+   '(gtk-init-pointers
+     gtk-font-selection-dialog-new
+     gtk-widget-set-sensitive gtk-font-selection-dialog-apply-button
+     gtk-signal-connect gtk-main-quit
+     gtk-font-selection-dialog-ok-button
+     gtk-font-selection-dialog-get-font-name gtk-widget-destroy
+     font-menu-set-font font-family font-size
+     gtk-font-selection-dialog-cancel-button gtk-widget-show-all
+     gtk-main gtk-style-info)))
 
-(globally-declare-boundp '(gtk-major-version gtk-fallback-font-name))
+(globally-declare-boundp
+ (unless (valid-device-type-p 'gtk)
+   '(gtk-major-version gtk-fallback-font-name)))
+
+(autoload 'x-font-xlfd-font-name-p "x-faces")
+(autoload 'x-font-size "x-faces")
 
 (eval-when-compile
   (defmacro gtk-style-munge-face (face attribute value)
@@ -198,6 +204,7 @@
           (weight (match-string 1 font))
           (slant (match-string 2 font))
           (size (x-font-size font)))
+      (defvar x-font-regexp-foundry-and-family)
       (if (string-match x-font-regexp-foundry-and-family font)
           (setq family (capitalize (match-string 1 font)))
         (setq family gtk-fallback-font-name))
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/help.el
--- a/lisp/help.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/help.el	Thu Jul 05 21:58:01 2018 +0100
@@ -39,6 +39,12 @@
 ;; or run interpreted, but not when the compiled code is loaded.
 (eval-when-compile (require 'help-macro))
 
+(globally-declare-boundp
+ (unless (featurep 'menubar) '(last-popup-menu-event)))
+
+(globally-declare-fboundp
+ (unless (featurep 'toolbar) '(toolbar-button-callback)))
+
 (require 'loadhist) ;; For symbol-file. 
 
 (defgroup help nil
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/hyper-apropos.el
--- a/lisp/hyper-apropos.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/hyper-apropos.el	Thu Jul 05 21:58:01 2018 +0100
@@ -64,6 +64,9 @@
 
 ;;; Code:
 
+(globally-declare-fboundp (unless (featurep 'menubar) '(popup-menu)))
+(globally-declare-fboundp (unless (featurep 'mouse) '(mouse-set-point)))
+
 (defgroup hyper-apropos nil
   "Hypertext emacs lisp documentation interface."
   :group 'docs
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/info.el
--- a/lisp/info.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/info.el	Thu Jul 05 21:58:01 2018 +0100
@@ -317,6 +317,16 @@
 (eval-when-compile
   (condition-case nil (require 'browse-url) (error nil)))
 
+(globally-declare-fboundp
+ (unless (featurep 'toolbar) '(toolbar-make-button-list)))
+
+(globally-declare-boundp
+ (unless (featurep 'toolbar) '(toolbar-info-frame default-toolbar
+			       toolbar-icon-directory)))
+
+(globally-declare-fboundp (unless (featurep 'menubar) '(popup-menu)))
+(globally-declare-boundp (unless (featurep 'menubar) '(popup-menu-titles)))
+
 (defgroup info nil
   "The info package for Emacs."
   :group 'help
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/lisp-mode.el
--- a/lisp/lisp-mode.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/lisp-mode.el	Thu Jul 05 21:58:01 2018 +0100
@@ -33,6 +33,11 @@
 
 ;;; Code:
 
+(globally-declare-boundp (unless (featurep 'menubar) '(current-menubar)))
+
+(globally-declare-fboundp
+ (unless (featurep 'menubar) '(set-buffer-menubar add-submenu)))
+
 (defgroup lisp nil
   "Lisp support, including Emacs Lisp."
   :group 'languages
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/menubar-items.el
--- a/lisp/menubar-items.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/menubar-items.el	Thu Jul 05 21:58:01 2018 +0100
@@ -52,6 +52,14 @@
 
 ;;; Code:
 
+(globally-declare-fboundp
+ (unless (featurep 'menubar)
+   '(menu-split-long-menu-and-sort submenu-generate-accelerator-spec
+     menu-split-long-menu add-menu-button menu-item-generate-accelerator-spec
+     set-menubar)))
+
+(globally-declare-boundp (unless (featurep 'menubar) '(current-menubar)))
+
 (defun Menubar-items-truncate-history (list count label-length)
   "Truncate a history LIST to first COUNT items.
 Return a list of (label value) lists with labels truncated to last
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/menubar.el
--- a/lisp/menubar.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/menubar.el	Thu Jul 05 21:58:01 2018 +0100
@@ -32,6 +32,13 @@
 
 ;;; Code:
 
+(globally-declare-boundp
+ (unless (featurep 'menubar)
+   '(current-menubar menu-accelerator-map popup-menu-titles)))
+
+(globally-declare-fboundp
+ (unless (featurep 'menubar) '(compare-menu-text popup-menu popup-up-p)))
+
 (defgroup menu nil
   "Input from the menus."
   :group 'environment)
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/minibuf.el
--- a/lisp/minibuf.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/minibuf.el	Thu Jul 05 21:58:01 2018 +0100
@@ -40,11 +40,19 @@
 
 (require 'cl)
 
+(globally-declare-fboundp
+ (unless (featurep 'window-system)
+   '(mode-motion-highlight-internal default-mouse-track-beginning-of-word
+     default-mouse-track-end-of-word make-dialog-frame insert-gui-button
+     make-gui-button get-dialog-box-response)))
+
+(globally-declare-boundp
+ (unless (featurep 'window-system) '(mode-motion-hook)))
+
 (defgroup minibuffer nil
   "Controlling the behavior of the minibuffer."
   :group 'environment)
 
-
 (defcustom insert-default-directory t
  "*Non-nil means when reading a filename start with default dir in minibuffer."
  :type 'boolean
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/mode-motion.el
--- a/lisp/mode-motion.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/mode-motion.el	Thu Jul 05 21:58:01 2018 +0100
@@ -28,6 +28,8 @@
 
 ;;; Code:
 
+(require 'mouse)
+
 (defvar mode-motion-hook nil
   "Function or functions which are called whenever the mouse moves.
 Each function must take a single argument of the motion event.
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/modeline.el
--- a/lisp/modeline.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/modeline.el	Thu Jul 05 21:58:01 2018 +0100
@@ -29,6 +29,12 @@
 
 ;;; Code:
 
+(globally-declare-fboundp
+ (unless (featurep 'mouse) '(mouse-bury-buffer mouse-unbury-buffer)))
+
+(globally-declare-fboundp
+ (unless (featurep 'menubar) '(popup-menu-and-execute-in-window)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;                     General mouse modeline stuff                    ;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/mouse.el
--- a/lisp/mouse.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/mouse.el	Thu Jul 05 21:58:01 2018 +0100
@@ -39,6 +39,15 @@
 
 ;;; Code:
 
+(globally-declare-boundp
+ (unless (featurep 'toolbar)
+   '(toolbar-active last-pressed-toolbar-button toolbar-help-enabled)))
+
+(globally-declare-fboundp
+ (unless (featurep 'toolbar)
+   '(toolbar-button-help-string release-previous-toolbar-button
+     press-toolbar-button toolbar-button-enabled-p)))
+
 (provide 'mouse)
 
 (global-set-key 'button1 'mouse-track)
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/msw-select.el
--- a/lisp/msw-select.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/msw-select.el	Thu Jul 05 21:58:01 2018 +0100
@@ -30,6 +30,9 @@
 
 ;;; Code:
 
+(globally-declare-boundp
+ (unless (featurep 'mouse) '(mouse-track-rectangle-p)))
+
 (defun mswindows-paste-clipboard ()
   "Insert the current contents of the mswindows clipboard at point,
 replacing the active selection if there is one."
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/mule/mule-charset.el
--- a/lisp/mule/mule-charset.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/mule/mule-charset.el	Thu Jul 05 21:58:01 2018 +0100
@@ -556,15 +556,14 @@
   ;; should specify short-form tags, which will have CATEGORY added to make
   ;; them full-form.
   (loop for (class parents doc) in stuff
-    for parents = (or parents category)
-    for parents = (if (listp parents) parents (list parents))
-    do
-    (define-charset-tag
-      (intern (format "%s/%s" class category))
-      :parent (loop for par in parents
-		collect (if (eq par category) category
-			  (intern (format "%s/%s" par category))))
-      :doc-string doc)))
+    do (progn (setq parents (or parents category)
+		    parents (if (listp parents) parents (list parents)))
+	      (define-charset-tag
+		(intern (format "%s/%s" class category))
+		:parent (loop for par in parents
+			  collect (if (eq par category) category
+				    (intern (format "%s/%s" par category))))
+		:doc-string doc))))
 
 ;; define classes of scripts
 
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/mwheel.el
--- a/lisp/mwheel.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/mwheel.el	Thu Jul 05 21:58:01 2018 +0100
@@ -37,6 +37,11 @@
 
 ;;; Code:
 
+(globally-declare-boundp
+ (unless (featurep 'mouse)
+   '(mouse-track-up-time mouse-track-multi-click-time
+     mouse-track-click-count)))
+
 (require 'custom)
 
 ;; XEmacs; I don't feel it's reasonable to support a minor mode for the mouse
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/occur.el
--- a/lisp/occur.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/occur.el	Thu Jul 05 21:58:01 2018 +0100
@@ -23,6 +23,12 @@
 
 ;;; Synched up with: FSF 22.0.50.1 (CVS)
 
+(globally-declare-fboundp
+ (unless (featurep 'window-system) '(mouse-set-point)))
+
+(globally-declare-boundp
+ (unless (featurep 'window-system) '(mode-motion-hook)))
+
 (require 'next-error)
 (defun query-replace-descr (string)
   (mapconcat 'isearch-text-char-description string ""))
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/package-ui.el
--- a/lisp/package-ui.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/package-ui.el	Thu Jul 05 21:58:01 2018 +0100
@@ -22,6 +22,14 @@
 
 ;;; Synched up with: Not in FSF
 
+(globally-declare-fboundp
+ (unless (featurep 'menubar)
+   '(set-menubar-dirty-flag popup-menu popup-up-p set-buffer-menubar
+     add-submenu)))
+
+(globally-declare-boundp (unless (featurep 'menubar) '(current-menubar)))
+
+
 (require 'package-get)		;; which, in turn, requires 'package-admin
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/picture.el
--- a/lisp/picture.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/picture.el	Thu Jul 05 21:58:01 2018 +0100
@@ -37,6 +37,12 @@
 
 ;;; Code:
 
+(globally-declare-fboundp (unless (featurep 'mouse) '(mouse-set-point)))
+
+(globally-declare-boundp
+ (unless (featurep 'mouse) '(mouse-yank-at-point mouse-track-rectangle-p)))
+
+
 (defun move-to-column-force (column)
   "Move to column COLUMN in current line.
 Differs from `move-to-column' in that it creates or modifies whitespace
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/printer.el
--- a/lisp/printer.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/printer.el	Thu Jul 05 21:58:01 2018 +0100
@@ -32,6 +32,8 @@
 
 ;; This file is dumped with XEmacs.
 
+(globally-declare-fboundp (unless (featurep 'dialog) '(make-dialog-box)))
+
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;                          generic printing code                        ;;
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/scrollbar.el
--- a/lisp/scrollbar.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/scrollbar.el	Thu Jul 05 21:58:01 2018 +0100
@@ -28,6 +28,13 @@
 
 ;;; Code:
 
+(globally-declare-fboundp
+ (unless (featurep 'scrollbar) '(scrollbar-set-hscroll)))
+
+(globally-declare-boundp
+ (unless (featurep 'scrollbar)
+   '(vertical-scrollbar-visible-p horizontal-scrollbar-visible-p)))
+
 ;; added for the options menu - dverna
 (defcustom scrollbars-visible-p t
   "Whether the scrollbars are globally visible.
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/select.el
--- a/lisp/select.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/select.el	Thu Jul 05 21:58:01 2018 +0100
@@ -31,6 +31,11 @@
 
 ;;; Code:
 
+(globally-declare-fboundp
+ (unless (featurep 'window-system)
+   '(default-mouse-track-next-move-rect
+     mouse-track-activate-rectangular-selection)))
+
 ;; We prefer UTF8_STRING to COMPOUND_TEXT because, even though the latter
 ;; gives us more information when taking data from other XEmacs invocations,
 ;; Mozilla will happily give us broken COMPOUND_TEXT where a non-broken
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/startup.el
--- a/lisp/startup.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/startup.el	Thu Jul 05 21:58:01 2018 +0100
@@ -65,6 +65,12 @@
 
 ;;; Code:
 
+(globally-declare-fboundp
+ (unless (featurep 'toolbar) '(init-toolbar-location init-toolbar)))
+
+(globally-declare-fboundp
+ (unless (featurep 'menubar) '(init-menubar-at-startup)))
+
 (setq top-level '(normal-top-level))
 
 (defvar command-line-processed nil "t once command line has been processed")
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/toolbar-items.el
--- a/lisp/toolbar-items.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/toolbar-items.el	Thu Jul 05 21:58:01 2018 +0100
@@ -35,6 +35,17 @@
 
 ;;; Code:
 
+(globally-declare-fboundp
+ (unless (featurep 'dialog) '(make-dialog-box)))
+
+(globally-declare-fboundp
+ (unless (featurep 'toolbar) '(toolbar-make-button-list)))
+
+(globally-declare-boundp
+ (unless (featurep 'toolbar)
+   '(default-toolbar initial-toolbar-spec toolbar-icon-directory)))
+
+
 (defgroup toolbar nil
   "Configure XEmacs Toolbar functions and properties"
   :group 'environment)
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/toolbar.el
--- a/lisp/toolbar.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/toolbar.el	Thu Jul 05 21:58:01 2018 +0100
@@ -29,6 +29,16 @@
 
 ;;; Code:
 
+(globally-declare-fboundp
+ (unless (featurep 'toolbar)
+   '(set-default-toolbar-position set-toolbar-button-down-flag
+     toolbar-button-enabled-p toolbar-button-callback)))
+
+(globally-declare-boundp
+ (unless (featurep 'toolbar)
+   '(default-toolbar-visible-p toolbar-buttons-captioned-p)))
+
+
 (defcustom toolbar-visible-p ;; added for the options menu - dverna apr. 98
   (specifier-instance default-toolbar-visible-p)
   "*Whether the default toolbar is globally visible.
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/userlock.el
--- a/lisp/userlock.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/userlock.el	Thu Jul 05 21:58:01 2018 +0100
@@ -31,6 +31,9 @@
 
 ;;; Code:
 
+(globally-declare-fboundp (unless (featurep 'dialog) '(make-dialog-box)))
+(globally-declare-fboundp (unless (featurep 'window-system) '(popup-up-p)))
+
 (define-error 'file-locked "File is locked" 'file-error) ; XEmacs
 
 (defun ask-user-about-lock-minibuf (filename other-user)
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/wid-edit.el
--- a/lisp/wid-edit.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/wid-edit.el	Thu Jul 05 21:58:01 2018 +0100
@@ -31,6 +31,15 @@
 
 ;;; Code:
 
+(globally-declare-fboundp
+ (unless (featurep 'window-system)
+   '(make-gui-button get-popup-menu-response mouse-set-point)))
+
+(globally-declare-boundp
+ (unless (featurep 'window-system)
+   '(help-echo-owns-message gui-button-shadow-thickness)))
+
+
 (require 'widget)
 
 ;; XEmacs: autoload of `finder-commentary' is redundant.
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/x-faces.el
--- a/lisp/x-faces.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/x-faces.el	Thu Jul 05 21:58:01 2018 +0100
@@ -192,7 +192,7 @@
     (x-make-font-bold-core font device)))
 
 (defun x-make-font-bold-xft (font &optional device)
-  (let ((pattern (fc-font-match (or device (default-x-device))
+  (let ((pattern (fc-font-match (or device (default-device 'x))
 				(fc-name-parse font))))
     (if pattern
 	(let ((size (fc-pattern-get-size pattern 0))
@@ -236,7 +236,7 @@
     (x-make-font-unbold-core font device)))
   
 (defun x-make-font-unbold-xft (font &optional device)
-  (let ((pattern (fc-font-match (or device (default-x-device))
+  (let ((pattern (fc-font-match (or device (default-device 'x))
 				(fc-name-parse font))))
     (when pattern
       (fc-pattern-del-weight pattern)
@@ -266,7 +266,7 @@
     (x-make-font-italic-core font device)))
 
 (defun x-make-font-italic-xft (font &optional device)
-  (let ((pattern (fc-font-match (or device (default-x-device))
+  (let ((pattern (fc-font-match (or device (default-device 'x))
 				(fc-name-parse font))))
     (if pattern
       (let ((size (fc-pattern-get-size pattern 0))
@@ -320,7 +320,7 @@
     (x-make-font-unitalic-core font device)))
   
 (defun x-make-font-unitalic-xft (font &optional device)
-  (let ((pattern (fc-font-match (or device (default-x-device))
+  (let ((pattern (fc-font-match (or device (default-device 'x))
 				(fc-name-parse font))))
     (when pattern
       (fc-pattern-del-slant pattern)
@@ -387,7 +387,7 @@
 
 ;; this is unbelievable &*@#
 (defun x-font-size-xft (font)
-  (let ((pattern (fc-font-match (default-x-device)
+  (let ((pattern (fc-font-match (default-device 'x)
 				(fc-name-parse font))))
     (when pattern
       (let ((pixelsize (fc-pattern-get-pixelsize pattern 0)))
@@ -519,7 +519,7 @@
     (x-find-smaller-font-core font device)))
 
 (defun x-find-xft-font-of-size (font new-size-proc &optional device)
-  (let* ((pattern (fc-font-match (or device (default-x-device))
+  (let* ((pattern (fc-font-match (or device (default-device 'x))
 				 (fc-name-parse font))))
     (when pattern
       (let ((size (fc-pattern-get-size pattern 0)))
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/x-font-menu.el
--- a/lisp/x-font-menu.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/x-font-menu.el	Thu Jul 05 21:58:01 2018 +0100
@@ -36,32 +36,19 @@
   (require 'fontconfig))
 
 (globally-declare-boundp
- '(x-font-regexp
-   x-font-regexp-foundry-and-family
-   x-font-regexp-spacing))
+ (unless (valid-device-type-p 'x)
+   '(x-font-regexp x-font-regexp-foundry-and-family x-font-regexp-spacing)))
 
-(globally-declare-boundp
- '(charset-registries
-   fc-find-available-font-families
-   fc-find-available-weights-for-family
-   fc-font-match
-   fc-font-slant-translate-from-string
-   fc-font-slant-translate-to-string
-   fc-font-weight-translate-from-string
-   fc-font-weight-translate-to-string
-   fc-name-parse
-   fc-name-unparse
-   fc-pattern-add-family
-   fc-pattern-add-size
-   fc-pattern-add-slant
-   fc-pattern-add-weight
-   fc-pattern-get-family
-   fc-pattern-get-size
-   fc-pattern-get-slant
-   fc-pattern-get-successp
-   fc-pattern-get-weight
-   make-fc-pattern
-   xlfd-font-name-p))
+(globally-declare-fboundp
+ (unless (featurep 'font-mgr)
+   '(fc-find-available-weights-for-family fc-find-available-font-families
+     xlfd-font-name-p fc-font-match fc-name-parse fc-pattern-get-family
+     fc-pattern-get-successp fc-pattern-get-weight fc-pattern-get-size
+     fc-pattern-get-slant fc-font-weight-translate-to-string
+     fc-font-slant-translate-to-string make-fc-pattern fc-pattern-add-family
+     fc-pattern-add-weight fc-font-weight-translate-from-string
+     fc-pattern-add-size fc-pattern-add-slant
+     fc-font-slant-translate-from-string fc-name-unparse)))
 
 (defvar x-font-menu-registry-encoding nil
   "Registry and encoding to use with font menu fonts.")
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/x-init.el
--- a/lisp/x-init.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/x-init.el	Thu Jul 05 21:58:01 2018 +0100
@@ -31,10 +31,19 @@
 ;;; Code:
 
 (globally-declare-fboundp
- '(x-server-vendor x-init-specifier-from-resources init-mule-x-win))
+ (unless (valid-device-type-p 'x)
+   '(x-server-vendor x-init-specifier-from-resources init-mule-x-win
+     x-keysym-hash-table)))
 
 (globally-declare-boundp
- '(x-initial-argv-list x-app-defaults-directory))
+ (unless (valid-device-type-p 'x)
+   '(x-initial-argv-list x-app-defaults-directory)))
+
+(globally-declare-boundp
+ (unless (featurep 'toolbar)
+   '(top-toolbar-height bottom-toolbar-height left-toolbar-width
+     right-toolbar-width top-toolbar-border-width bottom-toolbar-border-width
+     left-toolbar-border-width right-toolbar-border-width)))
 
 ;; If you want to change this variable, this is the place you must do it.
 ;; Do not set it to a string containing periods.  X doesn't like that.
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/x-mouse.el
--- a/lisp/x-mouse.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/x-mouse.el	Thu Jul 05 21:58:01 2018 +0100
@@ -30,7 +30,14 @@
 ;;; Code:
 
 (globally-declare-fboundp
- '(x-store-cutbuffer x-get-resource))
+ (unless (valid-device-type-p 'x) '(x-store-cutbuffer x-get-resource)))
+
+(globally-declare-fboundp
+ (unless (featurep 'mouse)
+   '(mouse-set-point mouse-yank insert-selection mouse-track)))
+
+(globally-declare-boundp
+ (unless (featurep 'mouse) '(mouse-yank-at-point)))
 
 ;;(define-key global-map 'button2 'x-set-point-and-insert-selection)
 ;; This is reserved for use by Hyperbole.
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/x-scrollbar.el
--- a/lisp/x-scrollbar.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/x-scrollbar.el	Thu Jul 05 21:58:01 2018 +0100
@@ -32,7 +32,13 @@
 ;;; Code:
 
 (globally-declare-fboundp
- '(x-init-specifier-from-resources x-get-resource))
+ (unless (valid-device-type-p 'x) 
+   '(x-init-specifier-from-resources x-get-resource)))
+
+(globally-declare-boundp
+ (unless (featurep 'scrollbar)
+   '(scrollbar-width scrollbar-height scrollbar-on-top-p
+     scrollbar-on-left-p)))
 
 (defun x-init-scrollbar-from-resources (locale)
   (x-init-specifier-from-resources
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/x-win-sun.el
--- a/lisp/x-win-sun.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/x-win-sun.el	Thu Jul 05 21:58:01 2018 +0100
@@ -63,7 +63,11 @@
 ;;; Code:
 
 (globally-declare-fboundp
- '(x-keysym-on-keyboard-sans-modifiers-p))
+ (unless (valid-device-type-p 'x) '(x-keysym-on-keyboard-sans-modifiers-p)))
+
+(globally-declare-boundp
+ (unless (valid-device-type-p 'x)
+   '(x-us-keymap-first-keycode x-us-keymap-description)))
 
 (defun x-win-init-sun (device)
 
diff -r 3c7e9dbadbbc -r 8d3aef8af4df lisp/x-win-xfree86.el
--- a/lisp/x-win-xfree86.el	Thu Jul 05 21:52:04 2018 +0100
+++ b/lisp/x-win-xfree86.el	Thu Jul 05 21:58:01 2018 +0100
@@ -39,6 +39,13 @@
 
 ;;; Code:
 
+(globally-declare-fboundp
+ (unless (valid-device-type-p 'x) '(x-keysym-hash-table)))
+
+(globally-declare-boundp
+ (unless (valid-device-type-p 'x)
+   '(x-us-keymap-first-keycode x-us-keymap-description)))
+
 (defun x-win-init-xfree86 (device)
 
   ;; We know this keyboard is an XFree86 keyboard. As such, we can predict
-- 
‘As I sat looking up at the Guinness ad, I could never figure out /
How your man stayed up on the surfboard after forty pints of stout’
(C. Moore)