| 1 | ;;; APEL-MK --- installer for APEL. -*-Emacs-Lisp-*- |
|---|
| 2 | |
|---|
| 3 | ;;; Commentary: |
|---|
| 4 | |
|---|
| 5 | ;; DON'T EDIT THIS FILE; edit APEL-CFG instead. |
|---|
| 6 | |
|---|
| 7 | ;;; Code: |
|---|
| 8 | |
|---|
| 9 | ;;; Configuration variables. |
|---|
| 10 | |
|---|
| 11 | ;; Set these four variables in "APEL-CFG" or in "Makefile". |
|---|
| 12 | |
|---|
| 13 | ;; This variable will be detected automatically. |
|---|
| 14 | (defvar PREFIX nil) |
|---|
| 15 | |
|---|
| 16 | ;; This variable will be detected automatically using PREFIX. |
|---|
| 17 | ;; v18: (no standard site-lisp directory) |
|---|
| 18 | ;; Emacs 19.28 and earlier: "PREFIX/lib/emacs/site-lisp" |
|---|
| 19 | ;; Emacs 19.29 and later: "PREFIX/share/emacs/site-lisp" |
|---|
| 20 | (defvar LISPDIR nil) |
|---|
| 21 | |
|---|
| 22 | ;; This variable will be detected automatically using PREFIX. |
|---|
| 23 | ;; Emacs 19.31 and later: "PREFIX/share/emacs/VERSION/site-lisp" |
|---|
| 24 | (defvar VERSION_SPECIFIC_LISPDIR nil) |
|---|
| 25 | |
|---|
| 26 | ;; This variable will be detected automatically. |
|---|
| 27 | ;; XEmacs 21.0 and later: "/usr/local/lib/xemacs/xemacs-packages" |
|---|
| 28 | (defvar PACKAGEDIR nil) |
|---|
| 29 | |
|---|
| 30 | ;; Install APEL modules to "apel" subdirectory. |
|---|
| 31 | (defvar APEL_PREFIX "apel") |
|---|
| 32 | |
|---|
| 33 | ;; Install EMU modules to "emu" subdirectory if emacs supports some features. |
|---|
| 34 | ;; If your emacs does not have `normal-top-level-add-subdirs-to-load-path' |
|---|
| 35 | ;; but have `normal-top-level-add-to-load-path' and you want to use it in |
|---|
| 36 | ;; "subdirs.el", put the following line to "APEL-CFG". |
|---|
| 37 | ;; (setq EMU_PREFIX "emu") |
|---|
| 38 | (defvar EMU_PREFIX |
|---|
| 39 | (if (or (featurep 'xemacs) |
|---|
| 40 | (fboundp 'normal-top-level-add-subdirs-to-load-path)) |
|---|
| 41 | ;; Make "emu" subdirectory. |
|---|
| 42 | "emu" |
|---|
| 43 | ;; Don't make "emu" subdirectory. |
|---|
| 44 | "")) |
|---|
| 45 | |
|---|
| 46 | ;; The directories where APEL and EMU modules will be installed. |
|---|
| 47 | ;; These two variables will be generated from other variables above. |
|---|
| 48 | (defvar APEL_DIR nil) ; LISPDIR/APEL_PREFIX |
|---|
| 49 | (defvar EMU_DIR nil) ; VERSION_SPECIFIC_LISPDIR/EMU_PREFIX |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | ;;; Configure, Compile, and Install. |
|---|
| 53 | |
|---|
| 54 | (defun config-apel () |
|---|
| 55 | ;; Override everything you want. |
|---|
| 56 | (load-file "APEL-CFG") |
|---|
| 57 | ;; Override PREFIX, LISPDIR, and VERSION_SPECIFIC_LISPDIR with |
|---|
| 58 | ;; command-line options. |
|---|
| 59 | (let (prefix lisp-dir version-specific-lisp-dir) |
|---|
| 60 | (and (setq prefix |
|---|
| 61 | ;; Avoid using `pop'. |
|---|
| 62 | ;; (pop command-line-args-left) |
|---|
| 63 | (prog1 |
|---|
| 64 | (car command-line-args-left) |
|---|
| 65 | (setq command-line-args-left |
|---|
| 66 | (cdr command-line-args-left)))) |
|---|
| 67 | (or (string-equal "NONE" prefix) |
|---|
| 68 | (setq PREFIX prefix))) |
|---|
| 69 | (and (setq lisp-dir |
|---|
| 70 | ;; Avoid using `pop'. |
|---|
| 71 | ;; (pop command-line-args-left) |
|---|
| 72 | (prog1 |
|---|
| 73 | (car command-line-args-left) |
|---|
| 74 | (setq command-line-args-left |
|---|
| 75 | (cdr command-line-args-left)))) |
|---|
| 76 | (or (string-equal "NONE" lisp-dir) |
|---|
| 77 | (setq LISPDIR lisp-dir))) |
|---|
| 78 | (and (setq version-specific-lisp-dir |
|---|
| 79 | ;; Avoid using `pop'. |
|---|
| 80 | ;; (pop command-line-args-left) |
|---|
| 81 | (prog1 |
|---|
| 82 | (car command-line-args-left) |
|---|
| 83 | (setq command-line-args-left |
|---|
| 84 | (cdr command-line-args-left)))) |
|---|
| 85 | (or (string-equal "NONE" version-specific-lisp-dir) |
|---|
| 86 | (setq VERSION_SPECIFIC_LISPDIR version-specific-lisp-dir)))) |
|---|
| 87 | ;; Load some APEL modules from this directory. |
|---|
| 88 | (defvar default-load-path load-path) |
|---|
| 89 | (setq load-path (cons (expand-file-name ".") load-path)) |
|---|
| 90 | (require 'poe) |
|---|
| 91 | (require 'path-util) |
|---|
| 92 | (require 'install) |
|---|
| 93 | |
|---|
| 94 | ;; Import `apel-modules'. |
|---|
| 95 | (load-file "APEL-ELS") |
|---|
| 96 | ;; Import `emu-modules' and `emu-modules-to-compile'. |
|---|
| 97 | (load-file "EMU-ELS") |
|---|
| 98 | |
|---|
| 99 | ;; Set PREFIX, LISPDIR, and VERSION_SPECIFIC_LISPDIR if not set yet. |
|---|
| 100 | (or PREFIX |
|---|
| 101 | (setq PREFIX install-prefix)) |
|---|
| 102 | (or LISPDIR |
|---|
| 103 | (setq LISPDIR (install-detect-elisp-directory PREFIX))) |
|---|
| 104 | (or VERSION_SPECIFIC_LISPDIR |
|---|
| 105 | (setq VERSION_SPECIFIC_LISPDIR |
|---|
| 106 | (install-detect-elisp-directory PREFIX nil 'version-specific))) |
|---|
| 107 | ;; The directories where APEL and EMU will be installed. |
|---|
| 108 | (or APEL_DIR |
|---|
| 109 | (setq APEL_DIR (expand-file-name APEL_PREFIX LISPDIR))) |
|---|
| 110 | (or EMU_DIR |
|---|
| 111 | (setq EMU_DIR (expand-file-name EMU_PREFIX VERSION_SPECIFIC_LISPDIR))) |
|---|
| 112 | (princ (format "\nLISPDIR=%s\n" LISPDIR)) |
|---|
| 113 | (princ (format "VERSION_SPECIFIC_LISPDIR=%s\n" VERSION_SPECIFIC_LISPDIR))) |
|---|
| 114 | |
|---|
| 115 | (defun compile-apel () |
|---|
| 116 | (config-apel) |
|---|
| 117 | ;; Compile emu modules first. |
|---|
| 118 | (compile-elisp-modules emu-modules-to-compile ".") |
|---|
| 119 | (compile-elisp-modules apel-modules ".")) |
|---|
| 120 | |
|---|
| 121 | (defun install-apel (&optional just-print) |
|---|
| 122 | (config-apel) |
|---|
| 123 | (or just-print |
|---|
| 124 | (setq just-print (install-just-print-p))) |
|---|
| 125 | (install-elisp-modules emu-modules "." EMU_DIR just-print) |
|---|
| 126 | (install-elisp-modules apel-modules "." APEL_DIR just-print)) |
|---|
| 127 | |
|---|
| 128 | ;; For XEmacs package system. |
|---|
| 129 | (defun config-apel-package () |
|---|
| 130 | ;; Override everything you want. |
|---|
| 131 | (load-file "APEL-CFG") |
|---|
| 132 | ;; Override PACKAGEDIR with command-line option. |
|---|
| 133 | (let (package-dir) |
|---|
| 134 | (and (setq package-dir |
|---|
| 135 | ;; Avoid using `pop'. |
|---|
| 136 | ;; (pop command-line-args-left) |
|---|
| 137 | (prog1 |
|---|
| 138 | (car command-line-args-left) |
|---|
| 139 | (setq command-line-args-left |
|---|
| 140 | (cdr command-line-args-left)))) |
|---|
| 141 | (or (string= "NONE" package-dir) |
|---|
| 142 | (setq PACKAGEDIR package-dir)))) |
|---|
| 143 | ;; Load some APEL modules from this directory. |
|---|
| 144 | (defvar default-load-path load-path) |
|---|
| 145 | (setq load-path (cons (expand-file-name ".") load-path)) |
|---|
| 146 | (require 'poe) |
|---|
| 147 | (require 'path-util) |
|---|
| 148 | (require 'install) |
|---|
| 149 | |
|---|
| 150 | ;; Import `apel-modules'. |
|---|
| 151 | (load-file "APEL-ELS") |
|---|
| 152 | ;; Import `emu-modules' and `emu-modules-to-compile'. |
|---|
| 153 | (load-file "EMU-ELS") |
|---|
| 154 | |
|---|
| 155 | ;; Set PACKAGEDIR if not set yet. |
|---|
| 156 | (or PACKAGEDIR |
|---|
| 157 | (setq PACKAGEDIR |
|---|
| 158 | (if (boundp 'early-packages) |
|---|
| 159 | (let ((dirs (append (if early-package-load-path |
|---|
| 160 | early-packages) |
|---|
| 161 | (if late-package-load-path |
|---|
| 162 | late-packages) |
|---|
| 163 | (if last-package-load-path |
|---|
| 164 | last-packages))) |
|---|
| 165 | dir) |
|---|
| 166 | (while (not (file-exists-p (setq dir (car dirs)))) |
|---|
| 167 | (setq dirs (cdr dirs))) |
|---|
| 168 | dir)))) |
|---|
| 169 | (if PACKAGEDIR |
|---|
| 170 | (princ (format "\nPACKAGEDIR=%s\n" PACKAGEDIR)) |
|---|
| 171 | (error "XEmacs package system is not available"))) |
|---|
| 172 | |
|---|
| 173 | (defun compile-apel-package () |
|---|
| 174 | (config-apel-package) |
|---|
| 175 | ;; Compile emu modules first. |
|---|
| 176 | (compile-elisp-modules emu-modules-to-compile ".") |
|---|
| 177 | (compile-elisp-modules apel-modules ".")) |
|---|
| 178 | |
|---|
| 179 | (defun install-apel-package () |
|---|
| 180 | (config-apel-package) |
|---|
| 181 | (let ((just-print (install-just-print-p)) |
|---|
| 182 | (dir (expand-file-name APEL_PREFIX |
|---|
| 183 | (expand-file-name "lisp" PACKAGEDIR)))) |
|---|
| 184 | (install-elisp-modules emu-modules "." dir just-print) |
|---|
| 185 | (install-elisp-modules apel-modules "." dir just-print) |
|---|
| 186 | (install-update-package-files "apel" dir just-print))) |
|---|
| 187 | |
|---|
| 188 | (defun what-where-apel () |
|---|
| 189 | (install-apel 'just-print) |
|---|
| 190 | ;; (config-apel) |
|---|
| 191 | ;;; (princ (format " |
|---|
| 192 | ;;; The files that belong to the EMU modules: |
|---|
| 193 | ;;; %s |
|---|
| 194 | ;;; -> %s |
|---|
| 195 | |
|---|
| 196 | ;;; The files that belong to the APEL modules: |
|---|
| 197 | ;;; %s |
|---|
| 198 | ;;; -> %s |
|---|
| 199 | |
|---|
| 200 | ;;; Do `make elc', `make install', `make package', or `make install-package'. |
|---|
| 201 | ;;; " |
|---|
| 202 | ;;; (mapconcat (function symbol-name) emu-modules ", ") |
|---|
| 203 | ;;; EMU_DIR |
|---|
| 204 | ;;; (mapconcat (function symbol-name) apel-modules ", ") |
|---|
| 205 | ;;; APEL_DIR)) |
|---|
| 206 | ) |
|---|
| 207 | |
|---|
| 208 | ;;; APEL-MK ends here |
|---|