1 # Copyright 1999-2010 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: common-lisp-3.eclass
7 # Common Lisp project <common-lisp@gentoo.org>
8 # @BLURB: functions to support the installation of Common Lisp libraries
10 # Since Common Lisp libraries share similar structure, this eclass aims
11 # to provide a simple way to write ebuilds with these characteristics.
15 # CL packages in the overlay don't have their tarballs on the mirrors
16 # so it's useless to mirror them
19 # @ECLASS-VARIABLE: CLSOURCEROOT
21 # Default path of Common Lisp libraries sources. Sources will
22 # be installed into ${CLSOURCEROOT}/${CLPACKAGE}.
23 CLSOURCEROOT="${ROOT%/}"/usr/share/common-lisp/source
25 # @ECLASS-VARIABLE: CLSYSTEMROOT
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
32 # @ECLASS-VARIABLE: CLPACKAGE
34 # Default package name. To override, set these after inheriting this eclass.
37 PDEPEND="virtual/commonlisp"
39 EXPORT_FUNCTIONS src_compile src_install
41 # @FUNCTION: common-lisp-3_src_compile
43 # Since there's nothing to build in most cases, default doesn't do
45 common-lisp-3_src_compile() { true; }
47 # @FUNCTION: absolute-path-p
49 # Returns true if ${1} is an absolute path.
51 [[ $# -eq 1 ]] || die "${FUNCNAME[0]} must receive one argument"
55 # @FUNCTION: common-lisp-install-one-source
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"
63 local target="${CLSOURCEROOT}/${CLPACKAGE}/${3}"
65 if absolute-path-p "${source}" ; then
66 die "Cannot install files with absolute path: ${source}"
69 if ${fpredicate} "${source}" ; then
71 doins "${source}" || die "Failed to install ${source} into $(dirname "${target}")"
75 # @FUNCTION: lisp-file-p
77 # Returns true if ${1} is lisp source file.
79 [[ $# -eq 1 ]] || die "${FUNCNAME[0]} must receive one argument"
81 [[ ${1} =~ \.(lisp|lsp|cl)$ ]]
84 # @FUNCTION: common-lisp-get-fpredicate
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"
92 "lisp") echo "lisp-file-p" ;;
93 "all" ) echo "true" ;;
94 * ) die "Unknown filetype specifier ${ftype}" ;;
98 # @FUNCTION: common-lisp-install-sources
99 # @USAGE: common-lisp-install-sources path [<other_paths>...]
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() {
106 if [[ ${1} == "-t" ]] ; then
111 [[ $# -ge 1 ]] || die "${FUNCNAME[0]} must receive one non-option argument"
113 local fpredicate=$(common-lisp-get-fpredicate "${ftype}")
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)
121 die "${path} it neither a regular file nor a directory"
126 # @FUNCTION: common-lisp-install-one-asdf
128 # Installs ${1} asdf file in CLSOURCEROOT/CLPACKAGE and symlinks it in
130 common-lisp-install-one-asdf() {
131 [[ $# != 1 ]] && die "${FUNCNAME[0]} must receive exactly one argument"
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})"
140 # @FUNCTION: common-lisp-install-asdf
141 # @USAGE: common-lisp-install-asdf path [<other_paths>...]
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}"
149 [[ $# = 0 ]] && set - ${CLSYSTEMS}
150 [[ $# = 0 ]] && set - $(find . -type f -name \*.asd)
151 for sys in "${@}" ; do
152 common-lisp-install-one-asdf ${sys}
156 # @FUNCTION: common-lisp-3_src_install
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}
167 # @FUNCTION: common-lisp-export-impl-args
168 # @USAGE: common-lisp-export-impl-args <lisp-implementation>
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: $#"
186 clozure | ccl | openmcl)
192 CL_NORC="-nositeinit -noinit"
202 CL_NORC="--sysinit /dev/null --userinit /dev/null"
207 die ${1} is not supported by ${0}
210 export CL_NORC CL_LOAD CL_EVAL