/[gentoo-x86]/eclass/common-lisp-3.eclass
Gentoo

Contents of /eclass/common-lisp-3.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Fri Dec 19 06:52:10 2014 UTC (4 years, 4 months ago) by gienah
Branch: MAIN
CVS Tags: HEAD
Add common-lisp-3.eclass from the lisp overlay, required by app-emacs/slime-2.11

1 # Copyright 1999-2010 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 # @ECLASS: common-lisp-3.eclass
6 # @MAINTAINER:
7 # Common Lisp project <common-lisp@gentoo.org>
8 # @BLURB: functions to support the installation of Common Lisp libraries
9 # @DESCRIPTION:
10 # Since Common Lisp libraries share similar structure, this eclass aims
11 # to provide a simple way to write ebuilds with these characteristics.
12
13 inherit eutils
14
15 # CL packages in the overlay don't have their tarballs on the mirrors
16 # so it's useless to mirror them
17 RESTRICT="mirror"
18
19 # @ECLASS-VARIABLE: CLSOURCEROOT
20 # @DESCRIPTION:
21 # Default path of Common Lisp libraries sources. Sources will
22 # be installed into ${CLSOURCEROOT}/${CLPACKAGE}.
23 CLSOURCEROOT="${ROOT%/}"/usr/share/common-lisp/source
24
25 # @ECLASS-VARIABLE: CLSYSTEMROOT
26 # @DESCRIPTION:
27 # Default path to find any asdf file. Any asdf files will be
28 # symlinked in ${CLSYSTEMROOT}/${CLSYSTEM} as they may be in
29 # an arbitrarily deeply nested directory under ${CLSOURCEROOT}/${CLPACKAGE}.
30 CLSYSTEMROOT="${ROOT%/}"/usr/share/common-lisp/systems
31
32 # @ECLASS-VARIABLE: CLPACKAGE
33 # @DESCRIPTION:
34 # Default package name. To override, set these after inheriting this eclass.
35 CLPACKAGE="${PN}"
36
37 PDEPEND="virtual/commonlisp"
38
39 EXPORT_FUNCTIONS src_compile src_install
40
41 # @FUNCTION: common-lisp-3_src_compile
42 # @DESCRIPTION:
43 # Since there's nothing to build in most cases, default doesn't do
44 # anything.
45 common-lisp-3_src_compile() { true; }
46
47 # @FUNCTION: absolute-path-p
48 # @DESCRIPTION:
49 # Returns true if ${1} is an absolute path.
50 absolute-path-p() {
51 [[ $# -eq 1 ]] || die "${FUNCNAME[0]} must receive one argument"
52 [[ ${1} == /* ]]
53 }
54
55 # @FUNCTION: common-lisp-install-one-source
56 # @DESCRIPTION:
57 # Installs ${2} source file in ${3} inside CLSOURCEROOT/CLPACKAGE.
58 common-lisp-install-one-source() {
59 [[ $# -eq 3 ]] || die "${FUNCNAME[0]} must receive exactly three arguments"
60
61 local fpredicate=${1}
62 local source=${2}
63 local target="${CLSOURCEROOT}/${CLPACKAGE}/${3}"
64
65 if absolute-path-p "${source}" ; then
66 die "Cannot install files with absolute path: ${source}"
67 fi
68
69 if ${fpredicate} "${source}" ; then
70 insinto "${target}"
71 doins "${source}" || die "Failed to install ${source} into $(dirname "${target}")"
72 fi
73 }
74
75 # @FUNCTION: lisp-file-p
76 # @DESCRIPTION:
77 # Returns true if ${1} is lisp source file.
78 lisp-file-p() {
79 [[ $# -eq 1 ]] || die "${FUNCNAME[0]} must receive one argument"
80
81 [[ ${1} =~ \.(lisp|lsp|cl)$ ]]
82 }
83
84 # @FUNCTION: common-lisp-get-fpredicate
85 # @DESCRIPTION:
86 # Outputs the corresponding predicate to check files of type ${1}.
87 common-lisp-get-fpredicate() {
88 [[ $# -eq 1 ]] || die "${FUNCNAME[0]} must receive one argument"
89
90 local ftype=${1}
91 case ${ftype} in
92 "lisp") echo "lisp-file-p" ;;
93 "all" ) echo "true" ;;
94 * ) die "Unknown filetype specifier ${ftype}" ;;
95 esac
96 }
97
98 # @FUNCTION: common-lisp-install-sources
99 # @USAGE: common-lisp-install-sources path [<other_paths>...]
100 # @DESCRIPTION:
101 # Recursively install lisp sources of type ${2} if ${1} is -t or
102 # Lisp by default. When given a directory, it will be recursively
103 # scanned for Lisp source files with suffixes: .lisp, .lsp or .cl.
104 common-lisp-install-sources() {
105 local ftype="lisp"
106 if [[ ${1} == "-t" ]] ; then
107 ftype=${2}
108 shift ; shift
109 fi
110
111 [[ $# -ge 1 ]] || die "${FUNCNAME[0]} must receive one non-option argument"
112
113 local fpredicate=$(common-lisp-get-fpredicate "${ftype}")
114
115 for path in "${@}" ; do
116 if [[ -f ${path} ]] ; then
117 common-lisp-install-one-source ${fpredicate} "${path}" "$(dirname "${path}")"
118 elif [[ -d ${path} ]] ; then
119 common-lisp-install-sources -t ${ftype} $(find "${path}" -type f)
120 else
121 die "${path} it neither a regular file nor a directory"
122 fi
123 done
124 }
125
126 # @FUNCTION: common-lisp-install-one-asdf
127 # @DESCRIPTION:
128 # Installs ${1} asdf file in CLSOURCEROOT/CLPACKAGE and symlinks it in
129 # CLSYSTEMROOT.
130 common-lisp-install-one-asdf() {
131 [[ $# != 1 ]] && die "${FUNCNAME[0]} must receive exactly one argument"
132
133 # the suffix «.asd» is optional
134 local source=${1/.asd}.asd
135 common-lisp-install-one-source true "${source}" "$(dirname "${source}")"
136 local target="${CLSOURCEROOT%/}/${CLPACKAGE}/${source}"
137 dosym "${target}" "${CLSYSTEMROOT%/}/$(basename ${target})"
138 }
139
140 # @FUNCTION: common-lisp-install-asdf
141 # @USAGE: common-lisp-install-asdf path [<other_paths>...]
142 # @DESCRIPTION:
143 # Installs all ASDF files and creates symlinks in CLSYSTEMROOT.
144 # When given a directory, it will be recursively scanned for ASDF
145 # files with extension .asd.
146 common-lisp-install-asdf() {
147 dodir "${CLSYSTEMROOT}"
148
149 [[ $# = 0 ]] && set - ${CLSYSTEMS}
150 [[ $# = 0 ]] && set - $(find . -type f -name \*.asd)
151 for sys in "${@}" ; do
152 common-lisp-install-one-asdf ${sys}
153 done
154 }
155
156 # @FUNCTION: common-lisp-3_src_install
157 # @DESCRIPTION:
158 # Recursively install Lisp sources, asdf files and most common doc files.
159 common-lisp-3_src_install() {
160 common-lisp-install-sources .
161 common-lisp-install-asdf
162 for i in AUTHORS README* HEADER TODO* CHANGELOG Change[lL]og CHANGES BUGS CONTRIBUTORS *NEWS* ; do
163 [[ -f ${i} ]] && dodoc ${i}
164 done
165 }
166
167 # @FUNCTION: common-lisp-export-impl-args
168 # @USAGE: common-lisp-export-impl-args <lisp-implementation>
169 # @DESCRIPTION:
170 # Export a few variables containing the switches necessary
171 # to make the CL implementation perform basic functions:
172 # * CL_NORC: don't load syste-wide or user-specific initfiles
173 # * CL_LOAD: load a certain file
174 # * CL_EVAL: eval a certain expression at startup
175 common-lisp-export-impl-args() {
176 if [[ $# != 1 ]]; then
177 eerror "Usage: ${FUNCNAME[0]} lisp-implementation"
178 die "${FUNCNAME[0]}: wrong number of arguments: $#"
179 fi
180 case ${1} in
181 clisp)
182 CL_NORC="-norc"
183 CL_LOAD="-i"
184 CL_EVAL="-x"
185 ;;
186 clozure | ccl | openmcl)
187 CL_NORC="--no-init"
188 CL_LOAD="--load"
189 CL_EVAL="--eval"
190 ;;
191 cmucl)
192 CL_NORC="-nositeinit -noinit"
193 CL_LOAD="-load"
194 CL_EVAL="-eval"
195 ;;
196 ecl)
197 CL_NORC="-norc"
198 CL_LOAD="-load"
199 CL_EVAL="-eval"
200 ;;
201 sbcl)
202 CL_NORC="--sysinit /dev/null --userinit /dev/null"
203 CL_LOAD="--load"
204 CL_EVAL="--eval"
205 ;;
206 *)
207 die ${1} is not supported by ${0}
208 ;;
209 esac
210 export CL_NORC CL_LOAD CL_EVAL
211 }

  ViewVC Help
Powered by ViewVC 1.1.20