;
; $VER: Plugin Setup 2.0 (20.03.26)
;
; Done by Andreas Falkenhahn
;

(set #hwPlugFile "pdf.hwp")
(set #hwPlugName "PDF Plugin")
(set #hwPlugVersion "2.0")
(set #hwPlugAuthor "Andreas Falkenhahn")
(set #hwPlugCopyrightYear "2013-2026")
(set #hwPlugDescription "Create and Render PDFs with Hollywood")

(message (cat "\nWelcome to the Setup utility for\n\n" #hwPlugName " " #hwPlugVersion "\n\nCopyright (C) " #hwPlugCopyrightYear " by " #hwPlugAuthor "\n\n" #hwPlugDescription))

(welcome)

(set defaultplat 0)

(if (exists "SYS:MorphOS/C/Assign") (
	(set defaultplat 4)
) (
	(if (exists "SYS:System/GrimReaper") (
		(set defaultplat 2)
	))
))

(set whichver
	(askchoice
		(prompt  "Please select your platform")
		(help    @askoptions-help)
		(choices "AmigaOS 3 (m68k)" "AmigaOS 3 (m68k/m881)" "AmigaOS 4 (ppc)" "AROS (x86)" "MorphOS (ppc)")		
		(default defaultplat)
	)
)

(set #platform "m68k-amigaos")

(if (= whichver 1) (
	(set #platform "m881-amigaos")
))

(if (= whichver 2) (
	(set #platform "ppc-amigaos")
))

(if (= whichver 3) (
	(set #platform "x86-aros")
))

(if (= whichver 4) (
	(set #platform "ppc-morphos")
))

(makedir "LIBS:Hollywood")

(if (<> whichver 3) (

	(copylib
		(source (cat "Platforms/" #platform "/" #hwPlugFile))
		(dest   "LIBS:Hollywood")
		(prompt #hwPlugFile)
		(help @copylib-help)
		(optional "nofail" "force" "askuser")
		(confirm)
	)
))

(copylib
	(source (cat "Platforms/" #platform "/pdf-lite.hwp"))
	(dest   "LIBS:Hollywood")
	(prompt "pdf-lite.hwp")
	(help @copylib-help)
	(optional "nofail" "force" "askuser")
	(confirm)
)

(if (exists "Hollywood:Examples" (noreq)) (

	(copyfiles
		(source "Examples")
		(dest   "Hollywood:Examples")
		(all)
		(optional "nofail" "force" "askuser")
	)
))

(if (exists "Hollywood:LinkerPlugins" (noreq)) (

	(copyfiles
		(source "Platforms")
		(dest   "Hollywood:LinkerPlugins")
		(all)
		(optional "nofail" "force" "askuser")
	)
))

(set havehw (exists "Hollywood:GUI" (noreq)))
(if (= havehw 1) (
	
	; Hollywood:Docs only exists since Hollywood 11, so let's use makedir to
	; be compatible with older Hollywood versions
	(makedir "Hollywood:Docs")
	
	(copyfiles
		(source "Docs/PDF.guide")
	        (dest   "Hollywood:Docs")
		(optional "nofail" "force" "askuser")
	)	
))
	
(if (= (exists "ReadMe") 1) (
	(run ("Sys:Utilities/MultiView ReadMe"))
))

(message (cat "\n" #hwPlugName " has been successfully installed on your system."))

(exit (quiet))

