(or (get reason 'output-type)
(error "Unknown output type `~(~A~)'" reason)))
+(export 'module-output-file)
+(defgeneric module-output-file (module output-type output-dir)
+ (:documentation
+ "Return a pathname to which the output should be written.
+
+ Specifically, if we're processing a MODULE for a particular OUTPUT-TYPE,
+ and the user has requested that output be written to OUTPUT-DIR (a
+ pathname), then return the pathname to which the output should be
+ written.
+
+ The OUTPUT-TYPE can be an `reason' symbol or a raw pathname. (Or
+ something else, of course.)"))
+
+(defmethod module-output-file
+ ((module module) (output-type symbol) output-dir)
+ (module-output-file module (output-type-pathname output-type) output-dir))
+
+(defmethod module-output-file
+ ((module module) (output-type pathname) output-dir)
+ (reduce #'merge-pathnames
+ (list output-dir output-type
+ (make-pathname :directory nil
+ :defaults (module-name module)))))
+
(define-clear-the-decks reset-output-types
"Clear out the registered output types."
(dolist (reason *output-types*) (remprop reason 'output-type))