;********************************************************************************
;      __           ______ __            
;     / /          / ____// /           
;    / /  __   __ / /___ / /___ ______ __   __
;   / /  / /__/ //___  // __  // __  // /__/ /
;  / /_ /  _   /____/ // / / // /_/ //  _   /
; /___/ \_/ \_//_____//_/ /_//_____/ \_/ \_/
;
; $VER: lwShow 0.20 (September-11-1997) 
; Installer by Robert C. Reiswig 1997 
; lwShow 1997 by phase5 digital products
;
; If you wish to use any part of this installer you must ask. May not be 
; integrated/placed into any other package! Changes, suggestions or problems:
; vgr@best.com
;********************************************************************************
(set vernum1 (getversion "lwShowPPC"))
(set ver1 (/ vernum1 65536)) (set rev1 (- vernum1 (* ver1 65536) ) )
(set lwShowver (cat ver1 "." rev1))
(set where "ram:")

;********************************************************************************
; Set Defaults Strings (English)
;********************************************************************************
(if (= ver1 0) (set lwShowver ""))
(set #about (cat "\nWelcome to lwShow " lwShowver "\nthe Lightwave object viewer for CyberGL.\n\n\nPowerPC\n&\nMC68020/030/040/060 + FPU\n\n\n1997 by phase5 digital products") )
(set #needfpu "\n\nlwShow must have a FPU (Floating Point Unit) to work. The installer has not found a FPU _or_ you are running an older version of the installer that does not have the FPU check option.\n\nIf you have a FPU please press 'Proceed'.")
(set #todo-prompt "\nWhat would you like to do?\n")
(set #copybin " Install/Update lwShow Program") 
(set #copyother " Copy Objects & Reflect Dirs") 
(set #copydocs " Copy Documentation") 
(set #whereb "Where would you like to install the selected options? A directory called 'lwShow' will be created there.")
(set #askcpu "\nWhat CPU does the machine have that you are installing lwShow on? The installer has found:\n")
(set #byebye (cat "\nlwShow Install Complete!\n\n" ))

;*********************************************************************************
; German Strings
;*********************************************************************************
(if (= @language "deutsch")
(
 (set #about "Hi")
)
)

;*********************************************************************************
; Welcome Message
;*********************************************************************************
(message #about)  (welcome)
(set fpu (database "fpu")) (if (= fpu "NOFPU") (message #needfpu))

;*********************************************************************************
; Ask what to do
;*********************************************************************************
(set ToDo (askoptions (choices  #copybin #copyother #copydocs) 
                      (prompt #todo-prompt)
                      (help #todo-prompt)
                      (default whattodo)
          )
) 

;********************************************************************
; Double Check on the CPU
;********************************************************************
(if (OR (IN ToDo 0) (IN ToDo 1) )
 ( 
  (set cpu (database "cpu"))
  (if (= cpu 68000) (set #cpu 0)) (if (= cpu 68010) (set #cpu 0))
  (if (= cpu 68020) (set #cpu 0)) (if (= cpu 68030) (set #cpu 0))
  (if (= cpu 68040) (set #cpu 0)) 

  (if (= @installer-version 0)
    (if (> (exists ("libs:68060.library")) 0) (set #cpu 0) )
    (if (= cpu 68060) (set #cpu 0))
  )
 
  (if (> (exists ("libs:PPC.library")) 0) (set #cpu 1) )

  (set cpuPick (askchoice (choices "68020/68030/68040/68060 + FPU" "PowerPC - PPC")
	                  (prompt #askcpu)
	                  (help   #askcpu)
          	 	  (default #cpu)
	       )
  )

 )
); END CheckCPU

;*********************************************************************************
; Ask where to put lwShow                                                           
;*********************************************************************************
(if (OR (IN ToDo 0) (IN ToDo 1))
 (
   (set where   (askdir (prompt #whereb)
	                (help   #whereb)
 		        (default "RAM:")
		)
   )
 )
)

;********************************************************************
; Copy lwShow bin if wanted 
;********************************************************************
(if (IN ToDo 0) 
 (  
  (if (< (exists (tackon where "LWShow")) 2) (makedir (tackon where "LWShow") (infos)) )
  (set wherelwShow (tackon where "LWShow")) 

  (if (AND (exists "lwShowPPC") (= cpuPick 1))
   (copylib (source "lwShowPPC") (dest wherelwShow) (optional "nofail") (infos))
  )
  (if (= cpuPick 1) (copyfiles (source "lwShow.elf") (dest wherelwShow) (optional "nofail") (infos)) )
  
  (if (AND (exists "lwShow68k") (= cpuPick 0))
   (copylib (source "lwShow68k") (dest wherelwShow) (optional "nofail") (infos))
  )

 
 )
)

;********************************************************************
; Copy objects & reflect if wanted
;*******************************************************************
(if (IN ToDo 1) 
 (  
  (if (< (exists (tackon where "lwShow")) 2) (makedir (tackon where "lwShow") (infos)) )
  (if (< (exists (tackon where "lwShow/objects")) 2) (makedir (tackon where "lwShow/Objects") (infos)) )
  (if (< (exists (tackon where "lwShow/reflect")) 2) (makedir (tackon where "lwShow/Reflect") (infos)) )
 
  (copyfiles (source "objects") (dest (tackon where "lwShow/Objects")) (all) (infos) (optional "nofail") ) 
  (copyfiles (source "reflect") (dest (tackon where "lwShow/Reflect")) (all) (infos) (optional "nofail") ) 
 )
)

;********************************************************************
; Copy Docs if wanted
;*******************************************************************
(if (IN ToDo 2) 
 (  
  (copyfiles (source "lwShowPPC.doc") (dest where) (all) (infos) (optional "nofail") ) 

 )
)

;*********************************************************************************
; Exit                                                           
;*********************************************************************************
(set @default-dest (tackon where "lwShow"))
(if (> (exists ("c:multiview")) 0) (set #mpath "c:") )
(if (> (exists ("sys:Utilities/multiview")) 0) (set #mpath "sys:Utilities") )
(run (cat "run " #mpath "/multiview lwShowPPC.doc") )
(exit #byebye)
