ports/52358: New Port: ASDF, a Common Lisp library manager

Henrik Motakef henrik.motakef at web.de
Sat May 17 13:00:44 UTC 2003


>Number:         52358
>Category:       ports
>Synopsis:       New Port: ASDF, a Common Lisp library manager
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat May 17 06:00:22 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Henrik Motakef
>Release:        FreeBSD 5.1-BETA i386
>Organization:
>Environment:
System: FreeBSD interim.henrik-motakef.de 5.1-BETA FreeBSD 5.1-BETA #0: Wed May 7 14:59:01 CEST 2003 henrik at interim.henrik-motakef.de:/usr/obj/usr/src/sys/GENERIC i386


	
>Description:
	ASDF (A System Definition Facility) is a Common Lisp package
	used to compile and install libraries. It is used by some ports
	I'm going to submit shortly.

	This port installs the source files and a FreeBSD specific
	configuration file. Binaries for the various supported Lisp systems
	have their own ports.
>How-To-Repeat:
>Fix:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	cl-asdf
#	cl-asdf/distinfo
#	cl-asdf/Makefile
#	cl-asdf/pkg-plist
#	cl-asdf/files
#	cl-asdf/files/patch-asdf.lisp
#	cl-asdf/files/asdf-init.lisp
#	cl-asdf/files/README.FreeBSD
#	cl-asdf/pkg-message
#	cl-asdf/pkg-descr
#
echo c - cl-asdf
mkdir -p cl-asdf > /dev/null 2>&1
echo x - cl-asdf/distinfo
sed 's/^X//' >cl-asdf/distinfo << 'END-of-cl-asdf/distinfo'
XMD5 (asdf-2003.05.16.tar.gz) = fa9b84d932ba1632df37b86e38a72e2d
END-of-cl-asdf/distinfo
echo x - cl-asdf/Makefile
sed 's/^X//' >cl-asdf/Makefile << 'END-of-cl-asdf/Makefile'
X# New ports collection Makefile for:	cl-asdf
X# Date created:				10 May 2003
X# Whom:					Henrik Motakef <henrik.motakef at web.de>
X#
X# $FreeBSD$
X
XPORTNAME=		asdf
XPORTVERSION=		2003.05.16
XCATEGORIES=		devel
XMASTER_SITES=		http://www.henrik-motakef.de/freebsd-distfiles/asdf/
XPKGNAMEPREFIX=		cl-
X
XMAINTAINER=		henrik.motakef at web.de
XCOMMENT=		A system definition facility for Common Lisp
X
XWRKSRC=			${WRKDIR}/${PORTNAME}
XNO_BUILD=		yes # Sources only, see cl-asdf-[cmucl|sbcl|clisp]
XCL_LIBDIR=		${PREFIX}/lib/common-lisp
XASDF_SYSTEM_REGISTRY=	${CL_LIBDIR}/system-registry
X
Xdo-install:
X	${MKDIR} ${CL_LIBDIR}/asdf
X	${MKDIR} ${ASDF_SYSTEM_REGISTRY}
X	${INSTALL_DATA} ${WRKSRC}/asdf.lisp ${CL_LIBDIR}/asdf/
X	${INSTALL_DATA} ${WRKSRC}/wild-modules.lisp ${CL_LIBDIR}/asdf/
X	${SED}	-e 's|%%ASDF_PATHNAME%%|${CL_LIBDIR}/asdf/asdf|' \
X		-e 's|%%ASDF_SYSTEM_REGISTRY%%|${ASDF_SYSTEM_REGISTRY}|' \
X		${FILESDIR}/asdf-init.lisp > \
X		${PREFIX}/etc/asdf-init.lisp.default
X	[ -f ${PREFIX}/etc/asdf-init.lisp ] || \
X		${CP} ${PREFIX}/etc/asdf-init.lisp.default \
X		${PREFIX}/etc/asdf-init.lisp
X.if !defined(NOPORTDOCS)
X	${MKDIR} ${PREFIX}/share/doc/cl-asdf/
X	${MKDIR} ${PREFIX}/share/examples/cl-asdf/
X	${INSTALL_DATA} ${WRKSRC}/README ${PREFIX}/share/doc/cl-asdf/
X	${INSTALL_DATA} ${WRKSRC}/LICENSE ${PREFIX}/share/doc/cl-asdf/
X	${INSTALL_DATA} ${FILESDIR}/README.FreeBSD ${PREFIX}/share/doc/cl-asdf/
X	${INSTALL_DATA} ${WRKSRC}/test/* ${PREFIX}/share/examples/cl-asdf/
X.endif
X
Xpost-install:
X	@${CAT} ${MASTERDIR}/pkg-message
X
X.include <bsd.port.mk>
END-of-cl-asdf/Makefile
echo x - cl-asdf/pkg-plist
sed 's/^X//' >cl-asdf/pkg-plist << 'END-of-cl-asdf/pkg-plist'
Xlib/common-lisp/asdf/asdf.lisp
Xlib/common-lisp/asdf/wild-modules.lisp
Xetc/asdf-init.lisp.default
X at dirrm lib/common-lisp/asdf
X at dirrm lib/common-lisp/system-registry
X%%PORTDOCS%%share/doc/cl-asdf/README
X%%PORTDOCS%%share/doc/cl-asdf/README.FreeBSD
X%%PORTDOCS%%share/doc/cl-asdf/LICENSE
X%%PORTDOCS%%share/examples/cl-asdf/file1.lisp
X%%PORTDOCS%%share/examples/cl-asdf/file2.lisp
X%%PORTDOCS%%share/examples/cl-asdf/file3.lisp
X%%PORTDOCS%%share/examples/cl-asdf/file4.lisp
X%%PORTDOCS%%share/examples/cl-asdf/run-tests.sh
X%%PORTDOCS%%share/examples/cl-asdf/test1.asd
X%%PORTDOCS%%share/examples/cl-asdf/test1.script
X%%PORTDOCS%%share/examples/cl-asdf/test2.asd
X%%PORTDOCS%%share/examples/cl-asdf/test2.script
X%%PORTDOCS%%share/examples/cl-asdf/test2a.asd
X%%PORTDOCS%%share/examples/cl-asdf/test2b1.asd
X%%PORTDOCS%%share/examples/cl-asdf/test2b2.asd
X%%PORTDOCS%%share/examples/cl-asdf/test2b3.asd
X%%PORTDOCS%%share/examples/cl-asdf/test3.asd
X%%PORTDOCS%%share/examples/cl-asdf/test3.script
X%%PORTDOCS%%share/examples/cl-asdf/test4.script
X%%PORTDOCS%%share/examples/cl-asdf/wild-module.asd
X%%PORTDOCS%%share/examples/cl-asdf/wild-module.script
X%%PORTDOCS%%@dirrm share/examples/cl-asdf
X%%PORTDOCS%%@dirrm share/doc/cl-asdf
X at exec [ -f %D/etc/asdf-init.lisp ] || cp %D/etc/asdf-init.lisp.default %D/etc/asdf-init.lisp
X at exec mkdir -p %D/lib/common-lisp/system-registry
END-of-cl-asdf/pkg-plist
echo c - cl-asdf/files
mkdir -p cl-asdf/files > /dev/null 2>&1
echo x - cl-asdf/files/patch-asdf.lisp
sed 's/^X//' >cl-asdf/files/patch-asdf.lisp << 'END-of-cl-asdf/files/patch-asdf.lisp'
X--- asdf.lisp.orig	Thu Mar 20 13:58:09 2003
X+++ asdf.lisp	Thu Mar 20 13:58:49 2003
X@@ -322,8 +322,7 @@
X 	
X (defvar *central-registry*
X   '(*default-pathname-defaults*
X-    #+nil "/home/dan/src/sourceforge/cclan/asdf/systems/"
X-    #+nil "telent:asdf;systems;"))
X+    "/usr/local/lib/common-lisp/system-registry/"))
X 
X (defun sysdef-central-registry-search (system)
X   (let ((name (coerce-name system)))
END-of-cl-asdf/files/patch-asdf.lisp
echo x - cl-asdf/files/asdf-init.lisp
sed 's/^X//' >cl-asdf/files/asdf-init.lisp << 'END-of-cl-asdf/files/asdf-init.lisp'
X;;;; asdf-config.lisp - Setup ASDF to deal with FBSD ports conventions
X
X;; Copyright (c) 2003 Henrik Motakef <henrik.motakef at web.de>
X
X;; Redistribution and use  in source and binary   forms, with or  without
X;; modification, are permitted provided that the following conditions are
X;; met:                                                                  
X
X;; 1. Redistributions  of  source  code  must retain  the above copyright
X;;    notice, this list of conditions and the following disclaimer.      
X;; 								      
X;; 2. Redistributions in  binary form must reproduce  the above copyright
X;;    notice, this list of conditions and the following disclaimer in the
X;;    documentation and/or other materials provided with the distribution
X
X;; THIS  SOFTWARE   IS PROVIDED ``AS  IS''   AND ANY  EXPRESS  OR IMPLIED
X;; WARRANTIES, INCLUDING, BUT NOT LIMITED  TO, THE IMPLIED WARRANTIES  OF
X;; MERCHANTABILITY  AND FITNESS FOR A  PARTICULAR PURPOSE ARE DISCLAIMED.
X;; IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
X;; INDIRECT,  INCIDENTAL,  SPECIAL, EXEMPLARY,  OR CONSEQUENTIAL  DAMAGES
X;; (INCLUDING, BUT NOT LIMITED TO,   PROCUREMENT OF SUBSTITUTE GOODS   OR
X;; SERVICES;  LOSS OF  USE,  DATA, OR  PROFITS; OR BUSINESS INTERRUPTION)
X;; HOWEVER  CAUSED AND ON ANY THEORY  OF LIABILITY,  WHETHER IN CONTRACT,
X;; STRICT LIABILITY, OR  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
X;; IN ANY WAY  OUT OF THE  USE OF THIS SOFTWARE,  EVEN IF ADVISED OF  THE
X;; POSSIBILITY OF SUCH DAMAGE.
X
X;;;; How to use
X
X;; A number of FreeBSD ports related to Common Lisp use the asdf
X;; system definition library, available as devel/cl-asdf-* (which you
X;; obviously already have installed, scince this file is included with
X;; that port). That implies that you will have to load and configure
X;; asdf to use these ports with your Lisp system.
X;;
X;; This file takes all neccessary actions. The easiest way is to load
X;; it in your Lisp everytime it starts, by putting
X;;
X;;  (load "/usr/local/etc/freebsd-lisp-init")
X;;
X;; in your init file.
X;;
X;; Each Lisp implementation has it's own files where this can be done:
X;;
X;; CLISP:
X;;   /usr/local/lib/clisp/config.lisp
X;;   ~/.clisprc
X;;
X;; CMUCL:
X;;   /usr/local/lib/cmucl/lib/cmucl/lib/site-init.lisp
X;;   ~/.cmucl-init.lisp
X;;
X;; SBCL:
X;;  /usr/local/etc/sbclrc
X;;  ~/.sbclrc
X;;
X;; After that, you can load your installed ports like this (using
X;; textproc/cl-ppcre as an example):
X;;
X;;    (asdf:operate 'asdf:load-op 'cl-ppcre)
X;;
X
X;; Have fun!
X
X
X;;;; What's going on here
X
X;; We mess around with asdf:output-files in interesting ways to
X;; enforce a filesystem layout that works without multiple Lisp
X;; implementations overwriting their fasls. Basically, each lib has
X;; it's own directory in /usr/local/lib/common-lisp, initially
X;; containing its sources. Each fasl port will create an
X;; implementation-specific subdirectory where all it's fasls go, for
X;; example ./cmuclfasl, ./clispfasl etc.
X
X;; Additionally, all fasl files have the pathname-type "fasl", not
X;; "x86f" or "fas". The reason is that I want to be prepared for the
X;; case that CMUCL some lucky day might be supported on non-x86
X;; archs. Scince it encodes the arch in the fasl file-type (x86f,
X;; sparcf etc), hardcoding this in pkg-plists would then
X;; break. Enforcing this policy for all implementations (for example,
X;; CLISP uses .fas by default) simply is more convenient then handling
X;; CMUCL specially.
X
X;; The drawback is that users cannot easily load compiled code unless
X;; they set up asdf properly, which boils down to loading this file
X;; instead of asdf.lisp directly.
X
X;; Yet another thing that has to be handled is compiling ports: During
X;; 'make build', no files outside of ${WRKSRC} may be created. On the
X;; other hand, it is a good idea to use the source files from their
X;; final location, because CMUCL and SBCL record the source path and
X;; can use, for example, to show the misbehaving form in the debugger.
X;; And the fasl ports depend on the source port to be installed
X;; anyway, because of the .asd file.
X;; Hence, in the case of port compilation, we redirect the output to
X;; ${WRKSRC}. This situation is detected by checking if an environment
X;; variable FBSD_ASDF_COMPILE_PORT is set (and if we have a WRKSRC
X;; envvar as well), so each port Makefile has to create this variable
X;; in the envorinment in which it calls Lisp in do-build, see existing
X;; ports for examples.
X
X;; Note that it is only neccessary to modify
X;; (output-files ((op compile-op)) ...), because asdf:load-op will use
X;; this method too to decide which files are to be loaded, there is no
X;; separate method for load-op.
X
X;;;; Adding support for other Lisp implementations
X
X;; In order to make all this work for not-handled-yet Lisps, it is
X;; only neccessary to change LISP-SPECIFIC-FASL-SUDBIR and GETENV. Of
X;; course, you'll also have to create new binary ports, if that's what
X;; you want.
X
X
X
X;;;; Package declaration
X
X(defpackage :freebsd-asdf
X  (:use :common-lisp)
X  (:export #:*asdf-pathname*
X	   #:unsupported-lisp-implementation))
X
X(in-package :freebsd-asdf)
X
X;;;; Pathes
X
X(defvar *asdf-pathname*
X  "/usr/local/lib/common-lisp/asdf/asdf"
X  "Path of the ASDF library")
X
X(defvar *system-registry*
X  "/usr/local/lib/common-lisp/system-registry"
X  "FreeBSDs contribution to the entral registry for ASDF system
Xdefinitions.  This will be added to asdf:*central-registry*, you
Xshould modify that in order to add other directories.")
X
X;;;; Implementation-specific functions
X
X(define-condition unsupported-lisp-implementation ()
X  ()
X  (:report (lambda (condition stream)
X	     (declare (ignore condition)
X		      (type stream stream))
X	     (format stream "Your Lisp system, ~A ~A, is currently not ~
X                             supported by the FreeBSD ports system."
X		     (lisp-implementation-type)
X		     (lisp-implementation-version)))))
X
X
X(defun lisp-specific-fasl-subdir ()
X  "Return the subdirectory in which fasl files for this Lisp
Ximplementations should be stored, as a sting without any slashes.
X
XIf no subdirectory for the current implementation is known, signal an
Xerror of type UNSUPPORTED-LISP-IMPLEMENTATION.
X
XThis function has to be extended for each new Lisp implementation that
Xshould be able to use the ASDF-based Lisp ports. If you do this, you
Xshould probably extend GETENV as well."
X  #+clisp "clispfasl"
X  #+cmu   "cmuclfasl"
X  #+sbcl  "sbclfasl"
X  #-(or clisp cmu sbcl) (error 'unsupported-lisp-implementation))
X
X(defun getenv (varname)
X  "Return the value of environment variable VARNAME, as a string.
XIf VARNAME is not found in the current environment, return nil.
XMay signal an error of type UNSUPPORTED-LISP-IMPLEMENTATION, see
Xbelow.
X
XThis is used to communicate make variables like WRKSRC from the ports
Xsystem to Lisp. Note that this doesn't happen automatically for
Xvariables defined in a Makefile, you'll have to pass these to the
Xenvironment in which Lisp runs explicitly.
X
XScince accessing environment variables is not portable, this function
Xhas to be extended for each Lisp implementation that is to work with
XFreeBSDs Lisp ports. If you do this, you should probably extend
XLISP-SPECIFIC-FASL-SUBDIR as well."
X  #+sbcl (sb-ext:posix-getenv varname)
X  #+cmu  (cdr (assoc varname ext:*environment-list* 
X		     :test #'equalp
X		     :key #'string))
X  #+clisp (sys::getenv varname)
X  #-(or sbcl cmu clisp) (error 'unsupported-lisp-implementation))
X
X
X;;;; Load and configure ASDF
X
X(defvar *asdf-binary-pathname*
X  (make-pathname
X   :directory `(:absolute ,@(cdr (pathname-directory *asdf-pathname*))
X			  ,(lisp-specific-fasl-subdir))
X   :type "fasl"
X   :defaults *asdf-pathname*))
X
X(or (ignore-errors (load *asdf-binary-pathname* :verbose t :print nil))
X    (load *asdf-pathname* :verbose t :print nil))
X
X(pushnew *system-registry* asdf:*central-registry*)
X
X;;;; Messing with asdf:output-files
X
X(if (and (getenv "FBSD_ASDF_COMPILE_PORT")
X	 (getenv "WRKSRC"))
X
X    ;;;; We are compiling a port - fasls should go to ${WRKSRC}
X    (defmethod asdf:output-files :around ((op asdf:compile-op)
X					  (file asdf:cl-source-file))
X      (let ((wrksrc (getenv "WRKSRC"))
X	    (relative-name (asdf:component-relative-pathname file))
X	    (default-output-name (car (call-next-method))))
X	(list
X	 (make-pathname
X	  :host (pathname-host wrksrc)
X	  :device (pathname-device wrksrc)
X	  :directory `(:absolute ,@(cdr (pathname-directory wrksrc))
X				 ,@(cdr (pathname-directory relative-name)))
X	  :name (pathname-name default-output-name)
X	  :type "fasl"))))
X
X  ;; Normal operation: load from lisp-specific-fasl-subdir
X  (defmethod asdf:output-files :around ((op asdf:compile-op)
X					(file asdf:cl-source-file))
X    (let ((default-output-file (car (call-next-method))))
X      (list
X       (make-pathname
X	:directory `(:absolute ,@(cdr (pathname-directory default-output-file))
X			       ,(lisp-specific-fasl-subdir))
X	:type "fasl"
X	:defaults default-output-file))))
X)
X
X
X;;; freebsd-lisp-init.lisp ends here
END-of-cl-asdf/files/asdf-init.lisp
echo x - cl-asdf/files/README.FreeBSD
sed 's/^X//' >cl-asdf/files/README.FreeBSD << 'END-of-cl-asdf/files/README.FreeBSD'
XTo use asdf and depending ports, you will have to configure your
XLisp systems so they know where to find asdf itself and the system
Xdefinition files.
X
XA default configuration is installed in
X
X  ${PREFIX}/etc/asdf-init.lisp
X
XReview this file for further information, or simply load it from your
XLisp initialization file.
X
END-of-cl-asdf/files/README.FreeBSD
echo x - cl-asdf/pkg-message
sed 's/^X//' >cl-asdf/pkg-message << 'END-of-cl-asdf/pkg-message'
X==========================================================================
XTo use asdf and depending ports, you will have to configure your
XLisp systems so they know where to find asdf itself and the system
Xdefinition files.
X
XA default configuration is installed in
X
X  ${PREFIX}/etc/asdf-init.lisp
X
XReview this file for further information, or simply load it from your
XLisp initialization file.
X==========================================================================
END-of-cl-asdf/pkg-message
echo x - cl-asdf/pkg-descr
sed 's/^X//' >cl-asdf/pkg-descr << 'END-of-cl-asdf/pkg-descr'
Xasdf is Another System Definition Facility for Common Lisp. It intends
Xto solve the same class of problems as mk-defsystem - compiling and
Xinstalling Lisp libraries -, but internally it takes advantage of
Xmodern CL features like pathname support etc., and uses CLOS for
Xextensibility.
X
XWWW: http://www.cliki.net/asdf
X
X- Henrik Motakef
END-of-cl-asdf/pkg-descr
exit

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list