| 1 | # Copyright 1999-2007 Gentoo Foundation |
1 | # Copyright 1999-2007 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/xemacs-elisp-common.eclass,v 1.1 2007/09/15 07:19:22 graaff Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/xemacs-elisp-common.eclass,v 1.2 2007/09/25 18:27:12 graaff Exp $ |
| 4 | # |
4 | # |
| 5 | # Copyright 2007 Hans de Graaff <graaff@gentoo.org> |
5 | # Copyright 2007 Hans de Graaff <graaff@gentoo.org> |
| 6 | # |
6 | # |
| 7 | # Based on elisp-common.eclass: |
7 | # Based on elisp-common.eclass: |
| 8 | # Copyright 2007 Christian Faulhammer <opfer@gentoo.org> |
8 | # Copyright 2007 Christian Faulhammer <opfer@gentoo.org> |
| … | |
… | |
| 35 | # src_compile() usage: |
35 | # src_compile() usage: |
| 36 | # |
36 | # |
| 37 | # An elisp file is compiled by the xemacs-elisp-compile() function |
37 | # An elisp file is compiled by the xemacs-elisp-compile() function |
| 38 | # defined here and simply takes the source files as arguments. |
38 | # defined here and simply takes the source files as arguments. |
| 39 | # |
39 | # |
| 40 | # xemacs-elisp-compile *.el || die "xemacs-elisp-compile failed" |
40 | # xemacs-elisp-compile *.el |
|
|
41 | # |
|
|
42 | # In the case of interdependent elisp files, you can use the |
|
|
43 | # xemacs-elisp-comp() function which makes sure all files are |
|
|
44 | # loadable. |
|
|
45 | # |
|
|
46 | # xemacs-elisp-comp *.el |
| 41 | # |
47 | # |
| 42 | # Function xemacs-elisp-make-autoload-file() can be used to generate a |
48 | # Function xemacs-elisp-make-autoload-file() can be used to generate a |
| 43 | # file with autoload definitions for the lisp functions. It takes a |
49 | # file with autoload definitions for the lisp functions. It takes a |
| 44 | # list of directories (default: working directory) as its argument. |
50 | # list of directories (default: working directory) as its argument. |
| 45 | # Use of this function requires that the elisp source files contain |
51 | # Use of this function requires that the elisp source files contain |
| … | |
… | |
| 47 | # (node "Autoload") for a detailed explanation. |
53 | # (node "Autoload") for a detailed explanation. |
| 48 | # |
54 | # |
| 49 | # .SS |
55 | # .SS |
| 50 | # src_install() usage: |
56 | # src_install() usage: |
| 51 | # |
57 | # |
| 52 | # The resulting compiled files (.elc) should be put in a subdirectory of |
58 | # The resulting compiled files (.elc) should be put in a subdirectory |
| 53 | # /usr/lib/xemacs/site-lisp/ which is named after the first argument |
59 | # of /usr/lib/xemacs/site-lisp/ which is named after the first |
| 54 | # of elisp-install(). The following parameters are the files to be put in |
60 | # argument of xemacs-elisp-install(). The following parameters are |
| 55 | # that directory. Usually the subdirectory should be ${PN}, you can choose |
61 | # the files to be put in that directory. Usually the subdirectory |
| 56 | # something else, but remember to tell elisp-site-file-install() (see below) |
62 | # should be ${PN}, but you can choose something else. |
| 57 | # the change, as it defaults to ${PN}. |
|
|
| 58 | # |
63 | # |
| 59 | # elisp-install ${PN} *.el *.elc || die "elisp-install failed" |
64 | # xemacs-elisp-install ${PN} *.el *.elc |
| 60 | # |
65 | # |
| 61 | |
66 | |
| 62 | |
67 | |
| 63 | SITEPACKAGE=/usr/lib/xemacs/site-packages |
68 | SITEPACKAGE=/usr/lib/xemacs/site-packages |
| 64 | XEMACS=/usr/bin/xemacs |
69 | XEMACS=/usr/bin/xemacs |
| 65 | XEMACS_BATCH_CLEAN="${XEMACS} --batch --no-site-file --no-init-file" |
70 | XEMACS_BATCH_CLEAN="${XEMACS} --batch --no-site-file --no-init-file" |
| 66 | |
71 | |
| 67 | # @FUNCTION: xemacs-elisp-compile |
72 | # @FUNCTION: xemacs-elisp-compile |
| 68 | # @USAGE: <list of elisp files> |
73 | # @USAGE: <list of elisp files> |
| 69 | # @DESCRIPTION: |
74 | # @DESCRIPTION: |
| 70 | # Byte-compile elisp files with xemacs |
75 | # Byte-compile elisp files with xemacs. This function will die when |
|
|
76 | # there is a problem compiling the lisp files. |
| 71 | xemacs-elisp-compile () { |
77 | xemacs-elisp-compile () { |
|
|
78 | { |
| 72 | ${XEMACS_BATCH_CLEAN} -f batch-byte-compile "$@" |
79 | ${XEMACS_BATCH_CLEAN} -f batch-byte-compile "$@" |
| 73 | xemacs-elisp-make-autoload-file "$@" |
80 | xemacs-elisp-make-autoload-file "$@" |
|
|
81 | } || die "Compile lisp files failed" |
| 74 | } |
82 | } |
| 75 | |
83 | |
| 76 | xemacs-elisp-make-autoload-file () { |
84 | xemacs-elisp-make-autoload-file () { |
| 77 | ${XEMACS_BATCH_CLEAN} \ |
85 | ${XEMACS_BATCH_CLEAN} \ |
| 78 | -eval "(setq autoload-package-name \"${PN}\")" \ |
86 | -eval "(setq autoload-package-name \"${PN}\")" \ |
| … | |
… | |
| 83 | # @FUNCTION: xemacs-elisp-install |
91 | # @FUNCTION: xemacs-elisp-install |
| 84 | # @USAGE: <subdirectory> <list of files> |
92 | # @USAGE: <subdirectory> <list of files> |
| 85 | # @DESCRIPTION: |
93 | # @DESCRIPTION: |
| 86 | # Install elisp source and byte-compiled files. All files are installed |
94 | # Install elisp source and byte-compiled files. All files are installed |
| 87 | # in site-packages in their own directory, indicated by the first |
95 | # in site-packages in their own directory, indicated by the first |
| 88 | # argument to the function. |
96 | # argument to the function. This function will die if there is a problem |
|
|
97 | # installing the list files. |
| 89 | |
98 | |
| 90 | xemacs-elisp-install () { |
99 | xemacs-elisp-install () { |
| 91 | local subdir="$1" |
100 | local subdir="$1" |
| 92 | shift |
101 | shift |
| 93 | ( # use sub-shell to avoid possible environment polution |
102 | ( # use sub-shell to avoid possible environment polution |
| 94 | dodir "${SITEPACKAGE}"/lisp/"${subdir}" |
103 | dodir "${SITEPACKAGE}"/lisp/"${subdir}" |
| 95 | insinto "${SITEPACKAGE}"/lisp/"${subdir}" |
104 | insinto "${SITEPACKAGE}"/lisp/"${subdir}" |
| 96 | doins "$@" |
105 | doins "$@" |
| 97 | ) || die "Installing lisp files failed" |
106 | ) || die "Installing lisp files failed" |
| 98 | } |
107 | } |
|
|
108 | |
|
|
109 | # @FUNCTION: xemacs-elisp-comp |
|
|
110 | # @USAGE: <list of elisp files> |
|
|
111 | # @DESCRIPTION: |
|
|
112 | # Byte-compile interdependent XEmacs lisp files. |
|
|
113 | # Originally taken from GNU autotools, but some configuration options |
|
|
114 | # removed as they don't make sense with the current status of XEmacs |
|
|
115 | # in Gentoo. |
|
|
116 | |
|
|
117 | xemacs-elisp-comp() { |
|
|
118 | # Copyright 1995 Free Software Foundation, Inc. |
|
|
119 | # François Pinard <pinard@iro.umontreal.ca>, 1995. |
|
|
120 | # This script byte-compiles all `.el' files which are part of its |
|
|
121 | # arguments, using XEmacs, and put the resulting `.elc' files into |
|
|
122 | # the current directory, so disregarding the original directories used |
|
|
123 | # in `.el' arguments. |
|
|
124 | # |
|
|
125 | # This script manages in such a way that all XEmacs LISP files to |
|
|
126 | # be compiled are made visible between themselves, in the event |
|
|
127 | # they require or load-library one another. |
|
|
128 | |
|
|
129 | test $# -gt 0 || return 1 |
|
|
130 | |
|
|
131 | einfo "Compiling XEmacs Elisp files ..." |
|
|
132 | |
|
|
133 | tempdir=elc.$$ |
|
|
134 | mkdir ${tempdir} |
|
|
135 | cp "$@" ${tempdir} |
|
|
136 | pushd ${tempdir} |
|
|
137 | |
|
|
138 | echo "(add-to-list 'load-path \"../\")" > script |
|
|
139 | ${XEMACS_BATCH_CLEAN} -l script -f batch-byte-compile *.el |
|
|
140 | local ret=$? |
|
|
141 | mv *.elc .. |
|
|
142 | |
|
|
143 | popd |
|
|
144 | rm -fr ${tempdir} |
|
|
145 | return ${ret} |
|
|
146 | } |