; SecondSpin Installer - Rev0022 - 03/10/99
; Install script (C) Kristian Van Der Vliet 1999
;
; Note to anyone reading this: Do not change this script. Do not copy wholesale
; from it. Do not even think about it. Email me (In the docs) if you want some
; help with installer scripts.
;
; Expert users: There is no expert mode. Sorry. Still, i cant think it would get
; much harder as it stands anyway....

(set @app-name
(cat "SecondSpin"
))

(set #welcome
(cat "Welcome to the Installer for SecondSpin.\nInstaller script ©1999 Kristian Van Der Vliet\n\nPlease make sure you have obtained both archives!"
))

(set @default-dest
(cat "Work:"
))

(welcome #welcome)

; We need to be sure that Processor archive has been installed too!

 (set encoderdir
(cat "encoders"
))

(if (NOT (exists encoderdir))
	(ABORT "\nUnable to locate Processor archive files.\n\nPlease reinstall it!")

)

; First we want a proper destination dir for the main files

(set @default-dest
	(askdir
		(prompt "Please select a destination directory for the Installation\nof SecondSpin. A directory called SecondSpin will be created there")
		(help "No help as yet")
		(newpath)
		(default "Work:")
	)
)

(set @default-dest
	(tackon @default-dest "SecondSpin")
)

; Ask which CPU the user has 

(set #cpu-version
(askchoice 
	(prompt "Please select the CPU version of SecondSpin you would like to install.")
	(help "In order to provide the best speed when handling MPEG Audio, SecondSpin offers several different executables for different processors. If your machine does have an FPU, it's better to use one. If you have a 68000/68010, please upgrade your machine! If the encoder crashes violently, you might have installed FPU version, although your cpu doesn't have a FPU unit, or it isn't working properly.")
	(choices "PPC" "060 with FPU" "040 with FPU" "030 with FPU" "030 without FPU" "020 with FPU" "020 without FPU")
))

; Now we need a few configuration details to set the ENV: labels
; First the device name

(set #cd-device
(askstring
	(prompt "Please enter the AmigaDOS device name for your CD-Rom drive.")
	(help "You should enter the AmigaDOS device name for the interface that your CD-Rom drive is connected to I.E scsi.device")
	(default "scsi.device")
))

; Now the device unit

(set #cd-unit
(asknumber
	(prompt "Please enter the Unit number for your CD-Rom drive.")
	(help "You should enter the Unit number for your CD-Rom drive. For an IDE/ATAPI drive this may be 0 or 1, SCSI drives will typically be in the range 0-7.")
	(default 0)
	(range 0 15)
))

; Finally the CD-Rom type (for cdda_plan)

(set #cd-type
(askchoice
	(prompt "Please select your CD-Rom type from the list below.")
	(help "The CD-DA ripper that SecondSpin uses works slightly diferently depending on the make of CD-Rom drive. If you have an IDE/ATAPI drive you should select either 'ATAPI' or 'Old ATAPI' from the list. SCSI drive users should consult their manual, but 'ATAPI' might work fine with most SCSI devices.\n\nNote: Not all CD-Rom drives support CD-DA sampling. If you have such a drive, you may find that the Audio CD-DA quality is poor, or the drive gives eratic results when sampling. This is not caused by SecondSpin.")
	(choices "Sony CDU 8003 and compatible" "Toshiba XM3401TA and compatible" "NEC 2X and 3X" "Some Grundig & Toshiba CD-ROM's" "Standard ATAPI / SCSI" "Old ATAPI" "None of the above")
))

; Do the bits here to check #cd-type and set #cd-plan acordingly

(select #cd-type
	(set #cd-plan "a")
	(set #cd-plan "b")
	(set #cd-plan "c")
	(set #cd-plan "d")
	(set #cd-plan "e")
	(set #cd-plan "f")
	(set #cd-plan "n")
)

; Now we can start copying our files about
; Make the main dir & copy the files needed.

(makedir @default-dest
	(prompt "Creating directory " @default-dest)
	(help "No help as yet")
	(infos)
)

; Now we can copy the remaining main files


(copyfiles
	(source "bin/")
	(dest @default-dest)		; Copy the main files to the dest-dir
	(all)
	(infos)
)

(copyfiles
	(source "")
	(pattern "SecondSpin.guide#?")
	(dest @default-dest)
)

(set #tables-dest
(cat @default-dest "/mpeg_tables"	; We also need a sub-dir "mpeg_tables"
))

(makedir #tables-dest)

(copyfiles
	(prompt "Copying the MPEG Tables to " #tables-dest)
	(source "mpeg_tables/")
	(dest #tables-dest)
	(all)
)

; Do the C: S: and LIBS: files

(set #cmd-dest
(cat @default-dest "/external_commands"	; We need an external_commands directory
))

(set #docs-dest
(cat @default-dest "/docs"	; We need a docs directory
))

(set #catalogs-dest
(cat @default-dest "/Catalogs"	; We need a catalog directory (Now who changed this? Wasn't me, i would have got it right the first time ;) )
))

(makedir #cmd-dest)
(makedir #catalogs-dest)

(copyfiles
	(source "external_commands")
	(dest #cmd-dest)
	(all)
)

(copyfiles
	(source "Catalogs")
	(dest #catalogs-dest)
	(all)
)


; Now copy the correct CPU version of the encoder
; Note that this is a little bit neater than the older Installers ;)

(set #lamer-dest
(cat @default-dest "/external_commands/"
))

(select #cpu-version

	(copyfiles
		(source "encoders/SecondSpin_encoder.elf")
		(dest #lamer-dest)
		(newname "SecondSpin_encoder")
	)
	
	(copyfiles
		(source "encoders/SecondSpin_encoder.060fpu")
		(dest #lamer-dest)
		(newname "SecondSpin_encoder")
	)

	(copyfiles
		(source "encoders/SecondSpin_encoder.040fpu")
		(dest #lamer-dest)
		(newname "SecondSpin_encoder")
	)

	(copyfiles
		(source "encoders/SecondSpin_encoder.030fpu")
		(dest #lamer-dest)
		(newname "SecondSpin_encoder")
	)

	(copyfiles
		(source "encoders/SecondSpin_encoder.030")
		(dest #lamer-dest)
		(newname "SecondSpin_encoder")
	)

	(copyfiles
		(source "encoders/SecondSpin_encoder.020fpu")
		(dest #lamer-dest)
		(newname "SecondSpin_encoder")
	)

	(copyfiles
		(source "encoders/SecondSpin_encoder.020")
		(dest #lamer-dest)
		(newname "SecondSpin_encoder")
	)

)

; Now the mpega-libs to libs:

(set #mpega-dest
	(cat "Libs:"
))

(if (NOT (exists encoderdir))

(select #cpu-version

	((copyfiles
		(source "libs-mpega/mpegaPPC.library")			; PPC
		(dest #mpega-dest)
		(newname "mpega.library")
	)

	(copyfiles
		(source "libs-mpega/mpegappcFPU_library.elf")		; And another PPC library
		(dest #mpega-dest)
		(newname "mpega.library.elf")
	))

	(copyfiles
		(source "libs-mpega/mpega060FPU.library")		; 060
		(dest #mpega-dest)
		(newname "mpega.library")
	)

	(copyfiles
		(source "libs-mpega/mpega040FPU.library")		; 040
		(dest #mpega-dest)
		(newname "mpega.library")
	)

	(copyfiles
		(source "libs-mpega/mpega020FPU.library")		; 030 fpu
		(dest #mpega-dest)
		(newname "mpega.library")
	)

	(copyfiles
		(source "libs-mpega/mpega020.library")			; 030 no fpu
		(dest #mpega-dest)
		(newname "mpega.library")
	)

)

; Note to any 030 users reading this, sorry, but mpega only comes in 020
; versions, however the SecondSpin_Encoder DOES, so you do have some advantages
; over 020 users...

	(copyfiles
		(source "libs-mpega/mpega020FPU.library")		; 020 fpu
		(dest #mpega-dest)
		(newname "mpega.library")
	)

	(copyfiles
		(source "libs-mpega/mpega020.library")			; 020 no fpu
		(dest #mpega-dest)
		(newname "mpega.library")
	)

)

; Now the docs

(makedir #docs-dest)

(copyfiles
   (source "docs")
   (dest #docs-dest)
   (all)
)

(copyfiles
   (source "docs.info")
   (dest @default-dest)
   (nogauge)
)

; Now we copy all of the required libs

(copylib
   (source "libs/reqtools.library")
   (dest "LIBS:")
)

(copylib
   (source "libs/rexxreqtools.library")
   (dest "LIBS:")
)

(copylib
   (source "libs/rexxtricks.library")
   (dest "LIBS:")
)

(copylib
   (source "libs/triton.library")
   (dest "LIBS:")
)

(copylib
   (source "libs/tritonrexx.library")
   (dest "LIBS:")
)

(copylib
   (source "libs/ixemul.library")
   (dest "LIBS:")
)

(copylib
   (source "libs/2ndspin.library")
   (dest "LIBS:")
)

; Bet it didn't copy that library, did it?
; It'll have to be a filecopy instead, for now.

(copyfiles
   (source "libs/2ndspin.library")
   (dest "LIBS:")
   (nogauge)
)


; Now create the ENV: labels needed for the CDDA ripper

(textfile
	(dest "ENVARC:cdda_device")
	(append #cd-device)
)

(textfile
	(dest "ENVARC:cdda_unit")
	(append #cd-unit)
)

; Check to see if we need a cd-plan before we set it

(if (<> #cd-type 6)
	(textfile
		(dest "ENVARC:cdda_plan")
		(append #cd-plan)
	)
)

; Copy the env labels into ENV: to avoid the reboot

(copyfiles
	(source "ENVARC:")
     (dest "ENV:")
	(pattern "cdda#?")
)

; Now put the SecondSpin: assign in user-startup

(startup "SecondSpin"
	(prompt "Adding assign to your user-startup sequence")
	(help "No help as yet.")
	(command "Assign SecondSpin: " @default-dest)
)

; That's all the work done. Ta da!
