;; Copyright (c) Camden Dixie O'Brien ;; SPDX-License-Identifier: AGPL-3.0-only (in-package :asdf-user) (eval-when (:compile-toplevel :load-toplevel :execute) (let* ((base-dir (make-pathname :directory (pathname-directory *load-pathname*))) (maxima-dir (merge-pathnames "maxima/" base-dir)) (maxima-src-dir (merge-pathnames "src/" maxima-dir)) (maxima-install-dir (merge-pathnames "maxima-install/" base-dir))) (unless (probe-file (merge-pathnames "bin/maxima" maxima-install-dir)) (uiop:with-current-directory (maxima-dir) (uiop:run-program "./bootstrap" :output *standard-output* :error-output *error-output*) (uiop:run-program (format nil "./configure --prefix=~A" (namestring maxima-install-dir)) :output *standard-output* :error-output *error-output*) (uiop:run-program "make -j" :output *standard-output* :error-output *error-output*) (uiop:run-program "make install" :output *standard-output* :error-output *error-output*))) (pushnew maxima-src-dir asdf:*central-registry* :test #'equal) (pushnew (merge-pathnames "maxima-interface/" base-dir) asdf:*central-registry* :test #'equal) (defparameter *maxima-src-dir* maxima-src-dir))) (defun prebuilt-maxima-fasl (source-file) (let ((source-path (asdf:component-pathname source-file))) (when (uiop:subpathp source-path *maxima-src-dir*) (let ((fasl-file (make-pathname :directory (substitute "src/binary-sbcl" "src" (pathname-directory source-path) :test #'string=) :name (pathname-name source-path) :type "fasl"))) (when (probe-file fasl-file) (list fasl-file)))))) (defmethod asdf:output-files :around ((op asdf:compile-op) (c asdf:cl-source-file)) (or (prebuilt-maxima-fasl c) (call-next-method))) (defmethod asdf:perform :around ((op asdf:compile-op) (c asdf:cl-source-file)) (if (prebuilt-maxima-fasl c) (asdf::mark-operation-done op c) (call-next-method))) (defmethod asdf:input-files :around ((op asdf:load-op) (c asdf:cl-source-file)) (or (prebuilt-maxima-fasl c) (call-next-method))) (defsystem :ham :version "0.1.0" :author "Camden Dixie O'Brien" :license "AGPL-3.0-only" :description "A framework for creating physics simulations" :depends-on (:sdl2 :maxima :maxima-interface) :components ((:file "package") (:file "drawing" :depends-on ("package")) (:file "physics-compiler" :depends-on ("package")) (:file "simulation" :depends-on ("package" "drawing"))))