main.ss
#lang scheme/base

(require dynext/compile
         dynext/link
         dynext/file)

(define (older-than a b)
  (< (file-or-directory-modify-seconds a) (file-or-directory-modify-seconds b)))

(define (depending-on what deps make)
  (when (not (and (file-exists? what)
                  (andmap
                   (λ (dep)
                     (when (not (file-exists? dep))
                       (error "Dependancy not found" dep))
                     (dep . older-than . what))
                   deps)))
    (make what deps))
  what)

(define (library name . sources)
  (let ((objects (map
                  (λ (source)
                    (depending-on
                     (append-object-suffix source)
                     (list source)
                     (λ (object deps)
                       (compile-extension #f (car deps) object null))))
                  sources)))
    (depending-on
     name
     objects
     (λ (object deps)
       (link-extension #f deps object)))))

(provide depending-on library)