Skip to content
This repository
Browse code

eclass for common lisp

  • Loading branch information...
commit 01ae6d473cbfbd2bd36eb55d627613b09e9cfb24 1 parent 7f5db0d
longlene authored August 12, 2012

Showing 1 changed file with 138 additions and 0 deletions. Show diff stats Hide diff stats

  1. 138  eclass/common-lisp-2.eclass
138  eclass/common-lisp-2.eclass
... ...
@@ -0,0 +1,138 @@
  1
+# Copyright 1999-2010 Gentoo Foundation
  2
+# Distributed under the terms of the GNU General Public License v2
  3
+# $Header: $
  4
+#
  5
+# Maintained by the Gentoo Common Lisp project
  6
+# irc: #gentoo-lisp, herd: <common-lisp@gentoo.org>, list: <gentoo-lisp@gentoo.org>
  7
+#
  8
+# This eclass supports the installation of Common Lisp libraries
  9
+#
  10
+# Public functions:
  11
+#
  12
+# common-lisp-install path [<other_paths>...]
  13
+#   recursively install sources
  14
+#
  15
+# common-lisp-symlink-asdf [<paths>...]
  16
+#   create symlinks in $CLSYSTEMROOT to asdf files
  17
+#
  18
+# common-lisp-export-impl-args lisp-implementation
  19
+#   export a few variables containing the switches necessary
  20
+#   to make the CL implementation perform basic functions:
  21
+#   * CL_NORC: don't load initfiles
  22
+#   * CL_LOAD: load a certain file
  23
+#   * CL_EVAL: eval a certain expression at startup
  24
+#
  25
+
  26
+inherit eutils
  27
+
  28
+# CL packages in the overlay don't have their tarballs on the mirrors
  29
+# so it's useless to mirror them
  30
+RESTRICT="mirror"
  31
+
  32
+CLSOURCEROOT="${ROOT%/}"/usr/share/common-lisp/source
  33
+CLSYSTEMROOT="${ROOT%/}"/usr/share/common-lisp/systems
  34
+
  35
+# Sources will be installed into ${CLSOURCEROOT}/${CLPACKAGE}/
  36
+# Any asdf files will be symlinked in ${CLSYSTEMROOT}/${CLSYSTEM} as they may be
  37
+# in an arbitrarily deeply nested directory under ${CLSOURCEROOT}/${CLPACKAGE}/
  38
+
  39
+# To override, set these after inheriting this eclass
  40
+CLPACKAGE="${PN}"
  41
+CLSYSTEMS="${PN}"
  42
+
  43
+RDEPEND="virtual/commonlisp"
  44
+
  45
+EXPORT_FUNCTIONS src_install
  46
+
  47
+absolute-path-p() {
  48
+	[[ $# = 1 ]] || die "${FUNCNAME[0]} must receive one argument"
  49
+	[[ ${1} = /* ]]
  50
+}
  51
+
  52
+common-lisp-install-source() {
  53
+	[[ $# = 2 ]] || die "${FUNCNAME[0]} must receive exactly two arguments"
  54
+
  55
+	local source="${1}"
  56
+	local target="${CLSOURCEROOT}/${CLPACKAGE}/${2}"
  57
+	insinto "${target}"
  58
+	doins -r "${source}" || die "Failed to install ${source} into $(dirname "${target}")"
  59
+}
  60
+
  61
+common-lisp-install() {
  62
+	[[ $# = 0 ]] && die "${FUNCNAME[0]} must receive at least one argument"
  63
+	for path in "$@"; do
  64
+		if absolute-path-p "${path}" ; then
  65
+			die "Cannot install files with absolute path: ${path}"
  66
+		fi
  67
+		common-lisp-install-source "${path}" "$(dirname "${path}")"
  68
+	done
  69
+}
  70
+
  71
+common-lisp-install-single-system() {
  72
+	[[ $# != 1 ]] && die "${FUNCNAME[0]} must receive exactly one argument"
  73
+
  74
+	local file="${CLSOURCEROOT%/}/${CLPACKAGE}/${1}.asd"
  75
+	[[ -f "${D}"/${file} ]] || die "${D}/${file} does not exist"
  76
+	dosym "${file}" "${CLSYSTEMROOT%/}/$(basename ${file})"
  77
+}
  78
+
  79
+# Symlink asdf files
  80
+# if no arguments received, default to the contents of ${CLSYSTEMS}
  81
+common-lisp-symlink-asdf() {
  82
+	dodir "${CLSYSTEMROOT}"
  83
+
  84
+	[[ $# = 0 ]] && set - ${CLSYSTEMS}
  85
+	for package in "$@" ; do
  86
+		common-lisp-install-single-system "${package}"
  87
+	done
  88
+}
  89
+
  90
+common-lisp-system-symlink() {
  91
+	die "common-lisp-system-symlink() has been renamed to common-lisp-symlink-asdf()"
  92
+}
  93
+
  94
+common-lisp-2_src_install() {
  95
+	common-lisp-install *.{lisp,asd}
  96
+	common-lisp-symlink-asdf
  97
+	for i in README HEADER TODO CHANGELOG ChangeLog CHANGES BUGS CONTRIBUTORS *NEWS ; do
  98
+		[[ -f ${i} ]] && dodoc ${i}
  99
+	done
  100
+}
  101
+
  102
+common-lisp-export-impl-args() {
  103
+	if [[ $# != 1 ]]; then
  104
+		eerror "Usage: ${0} lisp-implementation"
  105
+		die "${0}: wrong number of arguments: $#"
  106
+	fi
  107
+	case ${1} in
  108
+		clisp)
  109
+			CL_NORC="-norc"
  110
+			CL_LOAD="-i"
  111
+			CL_EVAL="-x"
  112
+			;;
  113
+		clozure|ccl|openmcl)
  114
+			CL_NORC="--no-init"
  115
+			CL_LOAD="--load"
  116
+			CL_EVAL="--eval"
  117
+			;;
  118
+		cmucl)
  119
+			CL_NORC="-nositeinit -noinit"
  120
+			CL_LOAD="-load"
  121
+			CL_EVAL="-eval"
  122
+			;;
  123
+		ecl)
  124
+			CL_NORC="-norc"
  125
+			CL_LOAD="-load"
  126
+			CL_EVAL="-eval"
  127
+			;;
  128
+		sbcl)
  129
+			CL_NORC="--sysinit /dev/null --userinit /dev/null"
  130
+			CL_LOAD="--load"
  131
+			CL_EVAL="--eval"
  132
+			;;
  133
+		*)
  134
+			die ${1} is not supported by ${0}
  135
+			;;
  136
+	esac
  137
+	export CL_NORC CL_LOAD CL_EVAL
  138
+}

0 notes on commit 01ae6d4

Please sign in to comment.
Something went wrong with that request. Please try again.