- (let* (;; KLUDGE: Note that this CONCATENATE 'STRING stuff is not The Common
- ;; Lisp Way, although it works just fine for common UNIX environments.
- ;; Should it come to pass that the system is ported to environments
- ;; where version numbers and so forth become an issue, it might become
- ;; urgent to rewrite this using the fancy Common Lisp PATHNAME
- ;; machinery instead of just using strings. In the absence of such a
- ;; port, it might or might be a good idea to do the rewrite.
- ;; -- WHN 19990815
- (src (concatenate 'string src-prefix stem src-suffix))
- (obj (concatenate 'string obj-prefix stem obj-suffix))
- (tmp-obj (concatenate 'string obj tmp-obj-suffix-suffix)))
-
- (ensure-directories-exist obj :verbose t)
-
- ;; We're about to set about building a new object file. First, we
- ;; delete any preexisting object file in order to avoid confusing
- ;; ourselves later should we happen to bail out of compilation with an
- ;; error.
- (when (probe-file obj)
- (delete-file obj))
-
- ;; Work around a bug in CLISP 1999-01-08 #'COMPILE-FILE: CLISP mangles
- ;; relative pathnames passed as :OUTPUT-FILE arguments, but works OK
- ;; with absolute pathnames.
- #+clisp
- (setf tmp-obj
- ;; (Note that this idiom is taken from the ANSI documentation
- ;; for TRUENAME.)
- (with-open-file (stream tmp-obj :direction :output)
- (close stream)
- (truename stream)))
-
- ;; Try to use the compiler to generate a new temporary object file.
- (multiple-value-bind (output-truename warnings-p failure-p)
- (funcall compile-file src :output-file tmp-obj)
- (declare (ignore warnings-p))
- (cond ((not output-truename)
- (error "couldn't compile ~S" src))
- (failure-p
- (if ignore-failure-p
- (warn "ignoring FAILURE-P return value from compilation of ~S"
- src)
- (unwind-protect
- (progn
- ;; FIXME: This should have another option, redoing
- ;; compilation.
- (cerror "Continue, using possibly-bogus ~S."
- "FAILURE-P was set when creating ~S."
- obj)
- (setf failure-p nil))
- ;; Don't leave failed object files lying around.
- (when (and failure-p (probe-file tmp-obj))
- (delete-file tmp-obj)
- (format t "~&deleted ~S~%" tmp-obj)))))
- ;; Otherwise: success, just fall through.
- (t nil)))
-
- ;; If we get to here, compilation succeeded, so it's OK to rename the
- ;; temporary output file to the permanent object file.
- (rename-file-a-la-unix tmp-obj obj)
-
- ;; nice friendly traditional return value
- (pathname obj)))
+ (let* (;; KLUDGE: Note that this CONCATENATE 'STRING stuff is not The Common
+ ;; Lisp Way, although it works just fine for common UNIX environments.
+ ;; Should it come to pass that the system is ported to environments
+ ;; where version numbers and so forth become an issue, it might become
+ ;; urgent to rewrite this using the fancy Common Lisp PATHNAME
+ ;; machinery instead of just using strings. In the absence of such a
+ ;; port, it might or might be a good idea to do the rewrite.
+ ;; -- WHN 19990815
+ (src (concatenate 'string src-prefix stem src-suffix))
+ (obj (concatenate 'string obj-prefix stem obj-suffix))
+ (tmp-obj (concatenate 'string obj tmp-obj-suffix-suffix)))
+
+ (ensure-directories-exist obj :verbose t)
+
+ ;; We're about to set about building a new object file. First, we
+ ;; delete any preexisting object file in order to avoid confusing
+ ;; ourselves later should we happen to bail out of compilation
+ ;; with an error.
+ (when (probe-file obj)
+ (delete-file obj))
+
+ ;; Work around a bug in CLISP 1999-01-08 #'COMPILE-FILE: CLISP
+ ;; mangles relative pathnames passed as :OUTPUT-FILE arguments,
+ ;; but works OK with absolute pathnames.
+ #+clisp
+ (setf tmp-obj
+ ;; (Note that this idiom is taken from the ANSI
+ ;; documentation for TRUENAME.)
+ (with-open-file (stream tmp-obj :direction :output)
+ (close stream)
+ (truename stream)))
+
+ ;; Try to use the compiler to generate a new temporary object file.
+ (multiple-value-bind (output-truename warnings-p failure-p)
+ (funcall compile-file src :output-file tmp-obj)
+ (declare (ignore warnings-p))
+ (cond ((not output-truename)
+ (error "couldn't compile ~S" src))
+ (failure-p
+ (if ignore-failure-p
+ (warn "ignoring FAILURE-P return value from compilation of ~S"
+ src)
+ (unwind-protect
+ (progn
+ ;; FIXME: This should have another option,
+ ;; redoing compilation.
+ (cerror "Continue, using possibly-bogus ~S."
+ "FAILURE-P was set when creating ~S."
+ obj)
+ (setf failure-p nil))
+ ;; Don't leave failed object files lying around.
+ (when (and failure-p (probe-file tmp-obj))
+ (delete-file tmp-obj)
+ (format t "~&deleted ~S~%" tmp-obj)))))
+ ;; Otherwise: success, just fall through.
+ (t nil)))
+
+ ;; If we get to here, compilation succeeded, so it's OK to rename
+ ;; the temporary output file to the permanent object file.
+ (rename-file-a-la-unix tmp-obj obj)
+
+ ;; nice friendly traditional return value
+ (pathname obj)))