make kludge added by mario-goulart on Thu Nov 1 17:36:49 2012

;; -*- scheme -*-
(use make)

(define targets
  (or (and-let* ((targets (get-environment-variable "MAKE_TARGETS")))
        (string-split targets))
      '()))

(define-syntax cd
  (syntax-rules ()
    ((_ dir body ...)
     (let ((cwd (current-directory)))
       (change-directory dir)
       body ...
       (change-directory cwd)))))

(define (build-lib lib . deps)
  `((,(make-pathname "lib" lib ".so")
     ,(cons (make-pathname "lib" lib ".scm") deps)
     ,(lambda ()
        (cd "lib" (compile -s -S -O3 -d1 -J ,(make-pathname #f lib ".scm")))))
    (,(make-pathname "lib" lib ".import.so")
     (,(make-pathname "lib" lib ".import.scm"))
     ,(lambda ()
        (cd "lib" (compile -s -S -O3 -d1 ,(conc lib ".import.scm")))))))

(define lib-rules
  (append
   (build-lib "ossystems-utils")
   ;; ...
   ))

(define all-build-rules
  (append
   lib-rules
   ;; ...
   ))

(define (cleanup-actions)
  (for-each remove-file*
            (append
             (map car lib-rules)
             ;; ...
             )))
  
(make/proc
 (append
  all-build-rules 
  `(("clean" () ,cleanup-actions)))
 targets)

(when (null? targets)
  (install-extension
   'ossystems-utils
   '("lib/ossystems-utils.so" "lib/ossystems-utils.import.so")
   '((version "0.0.1"))))