;;; common -*- scheme -*-

;; Copyright (C) 2003, 2009 Thien-Thi Nguyen
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 3 of
;; the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public
;; License along with this program; if not, write to the Free
;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA  02110-1301  USA

(define (env-1? x)
  (string=? "1" (or (getenv x) "")))

(define *have-ttf*    (env-1? "HAVE_TTF"))
(define *have-mixer*  (env-1? "HAVE_MIXER"))
(define *interactive* (env-1? "INTERACTIVE"))

(define (fso s . args)
  (apply simple-format #t s args))

(define (exit-77 msg)
  (fso "INFO: ~A: ~A\n" (car (command-line)) (string-upcase msg))
  (exit 77))

(define (datafile name)
  (in-vicinity (or (and=> (getenv "srcdir")
                          (lambda (d) (in-vicinity d "test")))
                   ".")
               name))

(define debug? (env-1? "DEBUG"))
(and debug? (debug-enable 'debug 'backtrace))

;;; common ends here
