Support "make distcheck".
authorDaiki Ueno <ueno@unixuser.org>
Thu, 14 Oct 2010 07:59:10 +0000 (16:59 +0900)
committerDaiki Ueno <ueno@unixuser.org>
Thu, 14 Oct 2010 07:59:10 +0000 (16:59 +0900)
* COMPILE: Support "make distcheck".
* Makefile.am: Support "make distcheck".

* test/test-riece-log.el (test-riece-log-delete-directory)
(test-riece-log-display-message-function): Don't bind
default-file-name-coding-system.

* riece-log.el (riece-log-display-message-function)
(riece-log-insert): Don't bind default-file-name-coding-system.

lisp/COMPILE
lisp/Makefile.am
lisp/riece-log.el
lisp/test/test-riece-log.el

index 8bbae79..0d3598b 100644 (file)
@@ -12,7 +12,6 @@
                riece-version
                riece-coding
                riece-complete
                riece-version
                riece-coding
                riece-complete
-               riece-mcat
                riece-addon-modules
                riece-addon
                riece-ruby
                riece-addon-modules
                riece-addon
                riece-ruby
@@ -54,6 +53,9 @@
 (defvar riece-mcat-modules
   '(riece-mcat-japanese))
 
 (defvar riece-mcat-modules
   '(riece-mcat-japanese))
 
+(defvar riece-generated-modules
+  '(riece-package-info))
+
 (defvar riece-icons
   '("riece-command-previous-channel.xpm"
     "riece-command-next-channel.xpm"
 (defvar riece-icons
   '("riece-command-previous-channel.xpm"
     "riece-command-next-channel.xpm"
   '("server.rb"
     "aproxy.rb"))
 
   '("server.rb"
     "aproxy.rb"))
 
-(defun riece-compile-modules (modules)
-  (let ((load-path (cons nil load-path))
+(defun riece-byte-compile-dest-file-function (filename)
+  (expand-file-name
+   (concat (file-name-nondirectory filename) "c")))
+
+(defun riece-compile-modules (modules srcdir)
+  (let ((load-path (cons nil (cons srcdir load-path)))
        error-modules)
     (while modules
       (let ((source (expand-file-name
        error-modules)
     (while modules
       (let ((source (expand-file-name
-                    (concat (symbol-name (car modules)) ".el"))))
-       (if (file-newer-than-file-p source (concat source "c"))
+                    (concat (symbol-name (car modules)) ".el")
+                    srcdir))
+           (binary (expand-file-name
+                    (concat (symbol-name (car modules)) ".elc"))))
+       (if (file-newer-than-file-p source binary)
            (condition-case error
            (condition-case error
-               (byte-compile-file source)
+               (let ((byte-compile-dest-file-function
+                      #'riece-byte-compile-dest-file-function))
+                 (byte-compile-file source))
              (error
               (setq error-modules (cons (car modules) error-modules))))))
       (setq modules (cdr modules)))
              (error
               (setq error-modules (cons (car modules) error-modules))))))
       (setq modules (cdr modules)))
       (if (file-newer-than-file-p source (concat source "c"))
          (byte-compile-file source)))))
 
       (if (file-newer-than-file-p source (concat source "c"))
          (byte-compile-file source)))))
 
-(defun riece-install-modules (modules dest just-print)
-  (unless (or just-print (file-exists-p dest))
-    (make-directory dest t))
+(defun riece-install-modules (modules srcdir lispdir just-print)
+  (unless (or just-print (file-exists-p lispdir))
+    (make-directory lispdir t))
+  ;; Workaround for "make distcheck"
+  (set-file-modes lispdir 493)
   (while modules
     (let ((name (symbol-name (car modules))))
   (while modules
     (let ((name (symbol-name (car modules))))
-      (princ (format "%s.el -> %s\n" name dest))
+      (princ (format "%s.el -> %s\n" name lispdir))
       (unless just-print
       (unless just-print
-       (copy-file (expand-file-name (concat name ".el"))
-                  (expand-file-name (concat name ".el") dest)
+       (copy-file (expand-file-name
+                   (concat name ".el")
+                   (if (memq (car modules) riece-generated-modules)
+                       nil
+                     srcdir))
+                  (expand-file-name (concat name ".el") lispdir)
                   t t))
                   t t))
-      (princ (format "%s.elc -> %s\n" name dest))
+      (princ (format "%s.elc -> %s\n" name lispdir))
       (unless just-print
        (if (file-exists-p (expand-file-name (concat name ".elc")))
            (copy-file (expand-file-name (concat name ".elc"))
       (unless just-print
        (if (file-exists-p (expand-file-name (concat name ".elc")))
            (copy-file (expand-file-name (concat name ".elc"))
-                      (expand-file-name (concat name ".elc") dest)
+                      (expand-file-name (concat name ".elc") lispdir)
                       t t)
          (princ (format "(%s was not successfully compiled, ignored)\n"
                         name)))))
     (setq modules (cdr modules))))
 
                       t t)
          (princ (format "(%s was not successfully compiled, ignored)\n"
                         name)))))
     (setq modules (cdr modules))))
 
-(defun riece-install-icons (icons dest just-print)
-  (unless (or just-print (file-exists-p dest))
-    (make-directory dest t))
+(defun riece-install-icons (icons srcdir lispdir just-print)
+  (unless (or just-print (file-exists-p lispdir))
+    (make-directory lispdir t))
+  ;; Workaround for "make distcheck"
+  (set-file-modes lispdir 493)
   (while icons
   (while icons
-    (when (file-exists-p (expand-file-name (car icons)))
-      (princ (format "%s -> %s\n" (car icons) dest))
+    (when (file-exists-p (expand-file-name (car icons) srcdir))
+      (princ (format "%s -> %s\n" (car icons) lispdir))
       (unless just-print
       (unless just-print
-       (copy-file (expand-file-name (car icons))
-                  (expand-file-name (car icons) dest)
+       (copy-file (expand-file-name (car icons) srcdir)
+                  (expand-file-name (car icons) lispdir)
                   t t)))
     (setq icons (cdr icons))))
 
                   t t)))
     (setq icons (cdr icons))))
 
-(defun riece-install-scripts (scripts dest just-print)
-  (unless (or just-print (file-exists-p dest))
-    (make-directory dest t))
+(defun riece-install-scripts (scripts srcdir lispdir just-print)
+  (unless (or just-print (file-exists-p lispdir))
+    (make-directory lispdir t))
+  ;; Workaround for "make distcheck"
+  (set-file-modes lispdir 493)
   (while scripts
   (while scripts
-    (when (file-exists-p (expand-file-name (car scripts)))
-      (princ (format "%s -> %s\n" (car scripts) dest))
+    (when (file-exists-p (expand-file-name (car scripts) srcdir))
+      (princ (format "%s -> %s\n" (car scripts) lispdir))
       (unless just-print
       (unless just-print
-       (copy-file (expand-file-name (car scripts))
-                  (expand-file-name (car scripts) dest)
+       (copy-file (expand-file-name (car scripts) srcdir)
+                  (expand-file-name (car scripts) lispdir)
                   t t)))
     (setq scripts (cdr scripts))))
 
                   t t)))
     (setq scripts (cdr scripts))))
 
     (if flag
        (string-match "^\\(\\(--[^ ]+ \\)+-\\|[^ =-]\\)*n" flag))))
 
     (if flag
        (string-match "^\\(\\(--[^ ]+ \\)+-\\|[^ =-]\\)*n" flag))))
 
-(defun riece-examine-modules ()
-  (let ((load-path (cons nil load-path)))
+(defun riece-examine-modules (srcdir)
+  (let ((load-path (cons nil (cons srcdir load-path))))
     (require 'riece-mcat)
     (require 'riece-addon-modules)
     (append riece-modules
     (require 'riece-mcat)
     (require 'riece-addon-modules)
     (append riece-modules
       (setq pointer (cdr pointer)))))
 
 (defun riece-compile ()
       (setq pointer (cdr pointer)))))
 
 (defun riece-compile ()
-  (riece-compile-modules (riece-examine-modules)))
+  (let ((srcdir (car command-line-args-left)))
+    (riece-compile-modules (riece-examine-modules srcdir) srcdir)))
 
 (defun riece-install ()
 
 (defun riece-install ()
-  (riece-install-modules
-   (riece-examine-modules)
-   (expand-file-name "riece" (car command-line-args-left))
-   (riece-install-just-print-p))
-  (riece-install-icons
-   riece-icons
-   (expand-file-name "riece" (car command-line-args-left))
-   (riece-install-just-print-p))
-  (riece-install-scripts
-   riece-scripts
-   (expand-file-name "riece" (car command-line-args-left))
-   (riece-install-just-print-p))
-  ;; Workaround for an XEmacs 21.5 bug ("xemacs -batch -f <func> <arg1>"
-  ;; attempts to open <arg1> as a file after <func>).
-  (setq command-line-args-left (cdr command-line-args-left)))
+  (let ((srcdir (car command-line-args-left))
+       (lispdir (nth 1 command-line-args-left)))
+    (riece-install-modules
+     (riece-examine-modules srcdir)
+     srcdir
+     (expand-file-name "riece" lispdir)
+     (riece-install-just-print-p))
+    (riece-install-icons
+     riece-icons
+     srcdir
+     (expand-file-name "riece" lispdir)
+     (riece-install-just-print-p))
+    (riece-install-scripts
+     riece-scripts
+     srcdir
+     (expand-file-name "riece" lispdir)
+     (riece-install-just-print-p))
+    ;; Workaround for an XEmacs 21.5 bug ("xemacs -batch -f <func> <arg1>"
+    ;; attempts to open <arg1> as a file after <func>).
+    (setq command-line-args-left (nthcdr 2 command-line-args-left))))
+
+(defun riece-uninstall ()
+  (let ((files (directory-files (expand-file-name "riece"
+                                                 (car command-line-args-left))
+                               t "\\.\\(elc?\\|rb\\|xpm\\)$")))
+    (while files
+      (delete-file (car files))
+      (setq files (cdr files)))
+    ;; Workaround for an XEmacs 21.5 bug ("xemacs -batch -f <func> <arg1>"
+    ;; attempts to open <arg1> as a file after <func>).
+    (setq command-line-args-left (cdr command-line-args-left))))
 
 (defun riece-compile-package ()
   (setq autoload-package-name "riece")
 
 (defun riece-compile-package ()
   (setq autoload-package-name "riece")
    (riece-install-just-print-p)))
 
 (defun riece-test ()
    (riece-install-just-print-p)))
 
 (defun riece-test ()
-  (let ((load-path (cons (expand-file-name "test") (cons nil load-path)))
-       (files (directory-files "test" t "^test-.*\\.el$"))
-        suite)
+  (let* ((srcdir (car command-line-args-left))
+        (load-path (cons (expand-file-name "test" srcdir)
+                         (cons srcdir (cons nil load-path))))
+        (files (directory-files (expand-file-name "test" srcdir) t
+                                "^test-.*\\.el$"))
+        suite)
     (require 'lunit-report)
     (setq suite (lunit-make-test-suite))
     (while files
     (require 'lunit-report)
     (setq suite (lunit-make-test-suite))
     (while files
          (intern (file-name-sans-extension
                   (file-name-nondirectory (car files)))))))
       (setq files (cdr files)))
          (intern (file-name-sans-extension
                   (file-name-nondirectory (car files)))))))
       (setq files (cdr files)))
-    (lunit-report suite (car command-line-args-left))))
+    (lunit-report suite (nth 1 command-line-args-left))))
index 3b5204f..6b6e272 100644 (file)
@@ -27,35 +27,43 @@ EXTRA_DIST = COMPILE ChangeLog ChangeLog.Liece \
        riece-command-join.xpm riece-command-part.xpm \
        server.rb aproxy.rb
 
        riece-command-join.xpm riece-command-part.xpm \
        server.rb aproxy.rb
 
-CLEANFILES = auto-autoloads.el custom-load.el *.elc
+CLEANFILES = auto-autoloads.el custom-load.el *.elc lunit-report.xml
 DISTCLEANFILES = riece-package-info.el
 FLAGS ?= -batch -q -no-site-file
 
 all: elc
 
 elc:
 DISTCLEANFILES = riece-package-info.el
 FLAGS ?= -batch -q -no-site-file
 
 all: elc
 
 elc:
-       $(EMACS) $(FLAGS) -l COMPILE -f riece-compile
+       $(EMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-compile \
+               $(srcdir)
 
 install: elc
 
 install: elc
-       $(EMACS) $(FLAGS) -l COMPILE -f riece-install $(lispdir) # $(MAKE)
+       $(EMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-install \
+               $(srcdir) $(lispdir) # $(MAKE)
+
+uninstall:
+       $(EMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-uninstall \
+               $(lispdir)
 
 package:
 
 package:
-       $(XEMACS) $(FLAGS) -l COMPILE -f riece-compile-package
+       $(XEMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-compile-package
 
 install-package: package
 
 install-package: package
-       $(XEMACS) $(FLAGS) -l COMPILE -f riece-install-package \
+       $(XEMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-install-package \
                $(PACKAGEDIR) # $(MAKE)
 
 check-local:
                $(PACKAGEDIR) # $(MAKE)
 
 check-local:
-       $(EMACS) $(FLAGS) -l COMPILE -f riece-test lunit-report.xml
+       $(EMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-test \
+               $(srcdir) lunit-report.xml
 
 compile-individually:
 
 compile-individually:
-       @for i in `$(EMACS) $(FLAGS) -l COMPILE -f riece-examine`; do \
-               echo $(EMACS) $(FLAGS) -l COMPILE \
+       @for i in `$(EMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-examine`; \
+       do \
+               echo $(EMACS) $(FLAGS) -l $(srcdir)/COMPILE \
                        -f riece-compile-module $$i; \
                        -f riece-compile-module $$i; \
-               $(EMACS) $(FLAGS) -l COMPILE \
+               $(EMACS) $(FLAGS) -l $(srcdir)/COMPILE \
                        -f riece-compile-module $$i; \
        done
 
 update-mcat:
                        -f riece-compile-module $$i; \
        done
 
 update-mcat:
-       $(EMACS) $(FLAGS) -l COMPILE -f riece-update-mcat
+       $(EMACS) $(FLAGS) -l $(srcdir)/COMPILE -f riece-update-mcat
index 624115b..0938456 100644 (file)
@@ -102,8 +102,7 @@ It is created if there is at least one instance of Emacs running riece-log.")
                                              'coding-system)))))
             (file (riece-log-make-file-name (riece-message-target message)
                                             coding-system-for-write))
                                              'coding-system)))))
             (file (riece-log-make-file-name (riece-message-target message)
                                             coding-system-for-write))
-            file-name-coding-system
-            default-file-name-coding-system)
+            (file-name-coding-system 'no-conversion))
        (unless (file-directory-p (file-name-directory file))
          (make-directory (file-name-directory file) t))
        (write-region (concat (format-time-string "%H:%M") " "
        (unless (file-directory-p (file-name-directory file))
          (make-directory (file-name-directory file) t))
        (write-region (concat (format-time-string "%H:%M") " "
@@ -185,8 +184,7 @@ It is created if there is at least one instance of Emacs running riece-log.")
 (defun riece-log-insert (identity lines)
   "Insert logs for IDENTITY at most LINES.
 If LINES is t, insert today's logs entirely."
 (defun riece-log-insert (identity lines)
   "Insert logs for IDENTITY at most LINES.
 If LINES is t, insert today's logs entirely."
-  (let* (file-name-coding-system
-        default-file-name-coding-system
+  (let* ((file-name-coding-system 'no-conversion)
         (files (riece-log-list-files identity
                                      (if (eq lines t) (current-time))))
         name coding-system date point)
         (files (riece-log-list-files identity
                                      (if (eq lines t) (current-time))))
         name coding-system date point)
index fc14774..06966ac 100644 (file)
@@ -3,8 +3,7 @@
 (luna-define-class test-riece-log (lunit-test-case))
 
 (defun test-riece-log-delete-directory (directory)
 (luna-define-class test-riece-log (lunit-test-case))
 
 (defun test-riece-log-delete-directory (directory)
-  (let (file-name-coding-system
-       default-file-name-coding-system
+  (let ((file-name-coding-system 'no-conversion)
         (files (directory-files directory t nil t)))
     (while files
       (if (file-directory-p (car files))
         (files (directory-files directory t nil t)))
     (while files
       (if (file-directory-p (car files))
                           "")
       "a b c\n" nil t))
     (put 'riece-log 'riece-addon-enabled nil))
                           "")
       "a b c\n" nil t))
     (put 'riece-log 'riece-addon-enabled nil))
-  (let (file-name-coding-system
-       default-file-name-coding-system)
+  (let ((file-name-coding-system 'no-conversion))
     (lunit-assert-2
      case
      (file-directory-p
     (lunit-assert-2
      case
      (file-directory-p