
(defvar dc1394-libdc1394-loaded)
(defvar dc1394-libdc1394)
(defvar dc1394-lib1394)
(defvar raw1394-lib1394)
(defvar dc1394-libname "libdc1394_control")
(defvar raw1394-libname "libraw1394")
(defvar dc1394-cpheader-cmd)

(when (not dc1394-libdc1394-loaded)

  ;; find  library
  (cond
   ;; dc1394-libdc1394 was already defined, don't touch it
   (dc1394-libdc1394 t)
   ;; look for dynamic libdc1394_control.so installed
   ((progn
      (let* ((libdc (find-shared-library  dc1394-libname ))
	     (libraw (find-shared-library raw1394-libname)) )
	(when (and libdc (filep libdc)) 
	  (setq dc1394-lib1394 libdc))
	(when (and libraw (filep libraw))
	  (setq raw1394-lib1394 libraw)))))

   ;; couldn't find it, complain loudly.
   (t (printf "either the libdc1394_control.so or libraw1394.so could NOT be found\n")
      (error "cannot configure libdc1394")))

  ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  (setq dc1394-cpheader-cmd
    '(progn
       (cpheader "#include <libraw1394/raw1394.h>")
       (cpheader "#include <libdc1394/dc1394_control.h>")
       (cpheader "#define MAX_PORTS 4")
       (cpheader "#define MAX_CAMERAS 8")
       (cpheader "#define NUM_BUFFERS 1")
       (cpheader "#define DROP_FRAMES 1")
       ))

  ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (setq dc1394-libdc1394-loaded t) )
