diff options
| author | Thien-Thi Nguyen | 2003-11-24 18:04:06 +0000 |
|---|---|---|
| committer | Thien-Thi Nguyen | 2003-11-24 18:04:06 +0000 |
| commit | ad80578f633d7d8db33525261bc44756aff564dc (patch) | |
| tree | aca2622d475162faca37b07875d3d3462c13eaeb | |
| parent | 1466c287bffdf8df36c569a398b549b9f7397558 (diff) | |
| download | emacs-ad80578f633d7d8db33525261bc44756aff564dc.tar.gz emacs-ad80578f633d7d8db33525261bc44756aff564dc.zip | |
Initial revision
| -rw-r--r-- | vms/make-mms-derivative.el | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/vms/make-mms-derivative.el b/vms/make-mms-derivative.el new file mode 100644 index 00000000000..13b4b2bf906 --- /dev/null +++ b/vms/make-mms-derivative.el | |||
| @@ -0,0 +1,122 @@ | |||
| 1 | ;;; make-mms-derivative.el --- framework to do horrible things for VMS support | ||
| 2 | |||
| 3 | ;; Copyright (C) 2003 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Thien-Thi Nguyen <ttn@gnu.org> | ||
| 6 | ;; Keywords: maint build vms mms makefile levitte autoconf war-is-a-lose | ||
| 7 | ;; Favorite-TV-Game-Show: L'Eredità | ||
| 8 | |||
| 9 | ;; This file is part of GNU Emacs. | ||
| 10 | |||
| 11 | ;; GNU Emacs is free software; you can redistribute it and/or modify | ||
| 12 | ;; it under the terms of the GNU General Public License as published by | ||
| 13 | ;; the Free Software Foundation; either version 2, or (at your option) | ||
| 14 | ;; any later version. | ||
| 15 | |||
| 16 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 19 | ;; GNU General Public License for more details. | ||
| 20 | |||
| 21 | ;; You should have received a copy of the GNU General Public License | ||
| 22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | ||
| 23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 24 | ;; Boston, MA 02111-1307, USA. | ||
| 25 | |||
| 26 | ;;; Commentary: | ||
| 27 | |||
| 28 | ;; Under OpenVMS the standard make-like program is called MMS, which | ||
| 29 | ;; looks for an input file in the default directory named DESCRIP.MMS | ||
| 30 | ;; and runs the DCL command rules therein. As of 2003, the build | ||
| 31 | ;; process requires a hand translation of the Makefile.in and related | ||
| 32 | ;; Emacs-specific methodology to DCL and TPU commands, so to alleviate | ||
| 33 | ;; this pain, we provide `make-mms-derivative', which given a source | ||
| 34 | ;; FILENAME (under `make-mms-derivative-root-dir'), inserts the file | ||
| 35 | ;; contents in a new buffer and loads FILENAME.2mms. The elisp in the | ||
| 36 | ;; .2mms file can (do whatever -- it's emacs -- and) arrange to write | ||
| 37 | ;; out the modified buffer after FILENAME.2mms loading by using: | ||
| 38 | ;; | ||
| 39 | ;; (make-mms-derivative-data 'write-under-root RELATIVE-FILENAME) | ||
| 40 | ;; | ||
| 41 | ;; where RELATIVE-FILENAME is something like "src/descrip.mms_in_in". | ||
| 42 | ;; Over the long run, the convenience procedures provided (see source) | ||
| 43 | ;; will be augmented by factoring maximally the .2mms files, squeezing | ||
| 44 | ;; as much algorithm out of those nasty heuristics as possible. What | ||
| 45 | ;; makes them nasty is not that they rely on the conventions of the | ||
| 46 | ;; Emacs makefiles; that's no big deal. What makes them nasty is that | ||
| 47 | ;; they rely on the conventions of separately maintained tools (namely | ||
| 48 | ;; Autoconf 1.11 under OpenVMS and the rest of GNU), and the separation | ||
| 49 | ;; of conventions is how people drift apart, dragging their software | ||
| 50 | ;; behind mercilessly. | ||
| 51 | ;; | ||
| 52 | ;; In general, codified thought w/o self-synchronization is doomed. | ||
| 53 | ;; That a generation would eat its young (most discriminatingly, even) | ||
| 54 | ;; is no reason GNU cannot build around such woe. | ||
| 55 | |||
| 56 | ;;; Code: | ||
| 57 | |||
| 58 | (defvar make-mms-derivative-root-dir "~/build/GNU/emacs" | ||
| 59 | "Source tree root directory.") | ||
| 60 | |||
| 61 | (defvar make-mms-derivative-data nil | ||
| 62 | "Alist of data specific to `make-mms-derivative'.") | ||
| 63 | |||
| 64 | (defun make-mms-derivative-data (key &optional newval) | ||
| 65 | (if newval | ||
| 66 | (setq make-mms-derivative-data | ||
| 67 | (cons (cons key newval) make-mms-derivative-data)) | ||
| 68 | (cdr (assq key make-mms-derivative-data)))) | ||
| 69 | |||
| 70 | (defun make-mms-derivative-write-under-root (rel-filename) | ||
| 71 | (write-file (expand-file-name rel-filename make-mms-derivative-root-dir))) | ||
| 72 | |||
| 73 | (defmacro make-mms-derivative-progn (msg &rest body) | ||
| 74 | `(progn | ||
| 75 | (message "(%s) %s" (point) ,msg) | ||
| 76 | ,@body)) | ||
| 77 | |||
| 78 | (put 'make-mms-derivative-progn 'lisp-indent-function 1) | ||
| 79 | |||
| 80 | (defun make-mms-derivative-load-edits-file (name) | ||
| 81 | (make-mms-derivative-data 'edits-filename name) | ||
| 82 | (let ((i 0) tmp res) | ||
| 83 | (while (progn | ||
| 84 | (setq tmp | ||
| 85 | (shell-command-to-string | ||
| 86 | (format "grep '^;;;%s;;' %s | sed 's/^;;;[0-9][0-9]*;;//g'" | ||
| 87 | i name))) | ||
| 88 | (not (string= "" tmp))) | ||
| 89 | (setq res (cons (cons i tmp) res) | ||
| 90 | i (1+ i))) | ||
| 91 | (make-mms-derivative-data 'raw-data res)) | ||
| 92 | (load name)) | ||
| 93 | |||
| 94 | (defun make-mms-derivative-insert-raw-data (n) | ||
| 95 | (insert (cdr (assq n (make-mms-derivative-data 'raw-data))))) | ||
| 96 | |||
| 97 | (defun make-mms-derivative (file) | ||
| 98 | (interactive "fSource File: ") | ||
| 99 | (let ((root (expand-file-name make-mms-derivative-root-dir)) | ||
| 100 | (file (expand-file-name file))) | ||
| 101 | (unless (string-match (concat "^" root) file) | ||
| 102 | (error "Not under root (%s)" root)) | ||
| 103 | (let ((edits-filename (concat file ".2mms"))) | ||
| 104 | (unless (file-exists-p edits-filename) | ||
| 105 | (error "Could not find %s" edits-filename)) | ||
| 106 | (let* ((pre (+ (length root) (if (string= "/" (substring root -1)) 0 1))) | ||
| 107 | (buf (get-buffer-create (format "*mms-derivative: %s" | ||
| 108 | (substring file pre))))) | ||
| 109 | (message "Munging ...") | ||
| 110 | (switch-to-buffer buf) | ||
| 111 | (erase-buffer) | ||
| 112 | (make-variable-buffer-local 'make-mms-derivative-data) | ||
| 113 | (insert-file file) | ||
| 114 | (make-mms-derivative-load-edits-file edits-filename) | ||
| 115 | (let ((out (make-mms-derivative-data 'write-under-root))) | ||
| 116 | (when out (make-mms-derivative-write-under-root out)) | ||
| 117 | (kill-buffer buf) | ||
| 118 | (unless out (message "Munging ... done"))))))) | ||
| 119 | |||
| 120 | (provide 'make-mms-derivative) | ||
| 121 | |||
| 122 | ;;; make-mms-derivative.el ends here | ||