;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; LUSH Lisp Universal Shell
;;;   Copyright (C) 2002 Leon Bottou, Yann Le Cun, AT&T Corp, NECI.
;;; Includes parts of TL3:
;;;   Copyright (C) 1987-1999 Leon Bottou and Neuristique.
;;; Includes selected parts of SN3.2:
;;;   Copyright (C) 1991-2001 AT&T Corp.
;;;
;;; 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 2 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., 59 Temple Place, Suite 330, Boston, MA 02111, USA
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;  9/9/2002       adapted from gsl-config.lsh  by jhuangfu
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defvar inventor-libinventor ())
(defvar inventor-libinventor-loaded ())
(defvar inventor-libname "libInventor")
(defvar inventor-version 2.1.5)
(defvar inventor-cpheader-cmd ())

(when (not inventor-libinventor-loaded)

  ;; find library
  (cond
   ;; inventor-libinventor was already defined, don't touch it
   (inventor-libinventor t)
   ;; look for dynamic libInventor.so installed
   ((progn
      (let* ((lib (find-shared-library  inventor-libname )))
        (when (and lib (filep lib)) (setq inventor-libinventor lib)))))
   ;; look for static libopeninventor.a installed
   ((progn
      (let* ((lib (find-static-library  inventor-libname )))
        (when (and lib (filep lib)) (setq inventor-libinventor lib)))))
   ;; couldn't find it, complain loudly.
   (t (printf "neither the libInventor.so nor libInventor.a could be found\n")
      (printf "You can download inventor from\n")
      (printf "http://oss.sgi.com/projects/inventor/\n")
      (printf "compile it, and install it\n")
      (printf "in standard paths (e.g. in /usr/lib) so that I can find it.\n")
      (printf "If you have installed Open Inventor and still get this message, please do\n")
      (printf "(defparameter inventor-libinventor \"yourlibrary\") before loading this file\n")
      (printf "(see %s for more details)\n" file-being-loaded)
      (error "cannot configure inventor")))
  
  (setq inventor-cpheader-cmd
      '(progn
	 (cpheader "#include <Inventor/Sb.h>")
	 (cpheader "#include <Inventor/So.h>")
	 (cpheader "#include <Inventor/SoInteraction.h>")
	 (cpheader "#include <Inventor/SoSceneManager.h>")
	 (cpheader "#include <Inventor/SoPrimitiveVertex.h>")
	 (cpheader "#include <Inventor/SoPickedPoint.h>")
	 (cpheader "#include <Inventor/misc/SoByteStream.h>")
	 (cpheader "#include <Inventor/misc/SoTranscribe.h>")
	 (cpheader "#include <Inventor/engines/SoEngines.h>")
	 (cpheader "#include <Inventor/errors/SoErrors.h>")
	 (cpheader "#include <Inventor/details/SoDetails.h>")
	 (cpheader "#include <Inventor/details/SoNodeKitDetail.h>")
	 (cpheader "#include <Inventor/actions/SoActions.h>")
	 (cpheader "#include <Inventor/actions/SoBoxHighlightRenderAction.h>")
	 (cpheader "#include <Inventor/actions/SoLineHighlightRenderAction.h>")
	 (cpheader "#include <Inventor/nodes/SoAntiSquish.h>")
	 (cpheader "#include <Inventor/nodes/SoSelection.h>")
	 (cpheader "#include <Inventor/nodes/SoSurroundScale.h>")
	 (cpheader "#include <Inventor/nodekits/SoAppearanceKit.h>")
	 (cpheader "#include <Inventor/nodekits/SoNodeKit.h>")
	 (cpheader "#include <Inventor/nodekits/SoCameraKit.h>")
	 (cpheader "#include <Inventor/nodekits/SoInteractionKit.h>")
	 (cpheader "#include <Inventor/nodekits/SoLightKit.h>")
	 (cpheader "#include <Inventor/nodekits/SoNodeKit.h>")
	 (cpheader "#include <Inventor/nodekits/SoSceneKit.h>")
	 (cpheader "#include <Inventor/nodekits/SoSeparatorKit.h>")
	 (cpheader "#include <Inventor/nodekits/SoShapeKit.h>")
	 (cpheader "#include <Inventor/nodekits/SoWrapperKit.h>")
	 (cpheader "#include <Inventor/draggers/SoCenterballDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoDirectionalLightDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoDragPointDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoHandleBoxDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoJackDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoPointLightDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoRotateCylindricalDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoRotateDiscDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoRotateSphericalDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoScale1Dragger.h>")
	 (cpheader "#include <Inventor/draggers/SoScale2Dragger.h>")
	 (cpheader "#include <Inventor/draggers/SoScale2UniformDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoScaleUniformDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoSpotLightDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoTabBoxDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoTabPlaneDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoTrackballDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoTransformBoxDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoTransformerDragger.h>")
	 (cpheader "#include <Inventor/draggers/SoTranslate1Dragger.h>")
	 (cpheader "#include <Inventor/draggers/SoTranslate2Dragger.h>")
	 (cpheader "#include <Inventor/manips/SoCenterballManip.h>")
	 (cpheader "#include <Inventor/manips/SoDirectionalLightManip.h>")
	 (cpheader "#include <Inventor/manips/SoHandleBoxManip.h>")
	 (cpheader "#include <Inventor/manips/SoJackManip.h>")
	 (cpheader "#include <Inventor/manips/SoPointLightManip.h>")
	 (cpheader "#include <Inventor/manips/SoSpotLightManip.h>")
	 (cpheader "#include <Inventor/manips/SoTabBoxManip.h>")
	 (cpheader "#include <Inventor/manips/SoTrackballManip.h>")
	 (cpheader "#include <Inventor/manips/SoTransformBoxManip.h>")
	 (cpheader "#include <Inventor/manips/SoTransformerManip.h>")
	 (cpheader "#include <Inventor/manips/SoTransformManip.h>") ) )

  ;; load libraries
  ;; THIS IS COMPLETELY WRONG
  ;; THE INTERFACE SHOULD USE DHC-MAKE-WITH-LIBS INSTEAD OF THIS HACK
  
  (mod-load inventor-libinventor)
  (setq inventor-libinventor-loaded t)

)
