home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 3
/
AACD03.BIN
/
AACD
/
Programming
/
sofa
/
install
< prev
next >
Wrap
Text File
|
1999-10-10
|
18KB
|
562 lines
; $VER: install 1.4 (10.10.99)
;
; An Amiga Installer script for Sofa.
;
; Written by Thomas Aglassinger <agi@sbox.tu-graz.ac.at>
; Placed in the public domain.
;
; NOTE: Start Installer from CLI with "APPNAME debug" to skip the stuff
; that copies the files and modifies the s:User-Startup.
;----------------------------------------------------------------------------
; Specify minimum installer version
;----------------------------------------------------------------------------
(debug "set version")
(set #minimum-installer-version 43)
(set #minimum-installer-revision 3)
(set #minimum-installer-id
(+ #minimum-installer-revision
(* #minimum-installer-version 65536)
)
)
(debug " minimum-installer-id = " #minimum-installer-id)
(debug " current-installer-id = " @installer-version)
;----------------------------------------------------------------------------
; Setup messages, prompts and help text
;----------------------------------------------------------------------------
(set #message-wrong-installer
(cat "You have an old version of the program `Installer' on your Amiga.\n\n"
"The installation procedure needs at least Installer "
#minimum-installer-version "." #minimum-installer-revision ".\n\n"
"Obtain a newer version and try again.\n\n"
"(Check Aminet or the WWW site of the current owner of the rights for "
"Amiga - whoever that might be right now.)"
))
(set #message-welcome
(cat "Welcome to the Amiga Installer for Sofa\n\n"
"This installs the Sofa distribution of the SmallEiffel compiler "
"on your Amiga."
;"\n\n"
;"It lets you choose you preferred C compiler to create native code, "
;"copies all required files (if you choose a target directory different "
;"from the current one), adds a few lines to your User-Startup and "
;"setups the files in the Sofa/SmallEiffel/sys directory."
))
(set #message-welcome-change-compiler
(cat "Welcome to the Amiga Installer for Sofa\n\n"
"This lets you choose a different C compiler when creating "
"native code."
))
(set #message-exit
(cat "\nSofa has been installed.\n\n"
"Please reboot before using it."
))
(set #message-exit-change-compiler
(cat "\nThe C compiler for Sofa has been changed. It will be used "
"the next time you invoke the \"compile\" command."
))
(set #prompt-ask-sofa-directory
(cat "Select where to install Sofa.\n"
"A directory named \"sofa\" is created automatically"
))
(set #prompt-ask-c-compiler
(cat "Select C compiler to be used by Sofa"
))
(set #help-ask-c-compiler
(cat "Sofa does not compile to Amiga native code directly but rather "
"translates a Eiffel source into a C source. To actually create an "
"executable, you need a C compiler.\n\n"
"The following compilers are known to work with Sofa:\n\n"
"· SAS/c - commercial but meanwhile abandoned by SAS Institute; "
"if you don't own it by now, you probably won't get it anywhere.\n"
"· EGCS/GCC - the freely distributable GNU C/C++ compiler; "
"stable, efficient code but horribly slow.\n"
;"· DICE - former commercial but meanwhile freely distributable; "
; "does not even support ANSI C, but is good enough for Sofa "
; "and very fast.\n"
"· Other - none of the above; you have to specify it manually as "
"described in the documentation.\n"
"\n"
"Naturally, the compiler selected has to be installed and within "
"the Workbench search path.\n\n"
))
(set #prompt-update-user-startup
(cat "The following lines are added to the s:User-Startup:\n\n"
))
(set #help-update-user-startup
(cat "These lines are necessary for Sofa to find its classes.\n\n"
"You can however skip this part and perform it manually later on "
"according to the documentation."
))
(set #prompt-copy-support-files "Copy additional documentation")
(set #help-copy-support-files
(cat "These files are not needed to run Sofa. Still they contain documentation "
"you might find useful."
))
(set #working-user-startup "Updating user-startup")
(set #working-set-smalleiffel "Updating SmallEiffel settings")
(set #working-extract-archive "Extracting \"%s\"\n(%s)\n\nThis may take a while.")
(set #message-manual-compiler-setup
(cat "As you did not specify a certain compiler, you have to perform some "
"steps manually.\n\n"
"In particular, the files \"compiler.Amiga\" and \"linker.Amiga\" "
"have to be set. Refer to \"man/system.txt\" in the SmallEiffel "
"directory for more information."
))
(set #message-binaries-missing
(cat "Note that the compiler binaries are available in a different "
"archive depending on your CPU. You can obtain them from Aminet, "
"look out for a file dev/lang/sofa*.lha with \"*\" "
"indicating your CPU.\n\n"
"Then simply copy the included binaries to \"%s\"."
))
(set #message-extract-failed
(cat "Cannot extract \"%s\".\n\nPlease submit the file \"%s\" to Sofa support."
))
;----------------------------------------------------------------------------
; Some global constants and defaults
;----------------------------------------------------------------------------
(set #env-appendix "sys/system.se")
(set #compiler-sas-name "SAS/c")
(set #compiler-sas-id 0)
(set #compiler-gcc-name "gcc/egcs")
(set #compiler-gcc-id 1)
;(set #compiler-dice-name "vbcc") ; TODO: Support VBCC
;(set #compiler-dice-id 2)
;(set #compiler-dice-name "Dice") ; TODO: Support DICE
;(set #compiler-dice-id 3)
(set #compiler-other-name "Other")
(set #compiler-other-id 2) ; TODO: Change to 3/4 for VBCC/DICE
;----------------------------------------------------------------------------
; Check requirements
;----------------------------------------------------------------------------
; Check installer version to piss people off and make them
; download a new one or forget about the whole thing - He he he.
; (The script should work with older versions, but how am I
; supposed to test this?)
(procedure P-check-requirements
(
(debug "check installer version")
(if (< @installer-version #minimum-installer-id)
(
(debug "installer too old")
(abort #message-wrong-installer)
)
)
))
;----------------------------------------------------------------------------
; Welcome user
;----------------------------------------------------------------------------
(procedure P-welcome
(
(debug "welcome")
(welcome #message-welcome)
))
(procedure P-welcome-change-compiler
(
(debug "welcome")
(welcome #message-welcome-change-compiler)
))
;----------------------------------------------------------------------------
; Ask for target directory where to install Sofa
;----------------------------------------------------------------------------
(procedure P-ask-sofa-directory
(
(debug "ask-sofa-directory")
(if (exists "sofa:" (noreq))
(
; Update existing installation. Use parent of "Sofa:" as default
(set #default-sofa-directory "sofa:/")
)
(
; New installation. Use parent of current directory as default
(set #default-sofa-directory "/")
)
)
(set #default-sofa-directory (expandpath #default-sofa-directory))
(set #sofa-directory
(askdir
(prompt #prompt-ask-sofa-directory)
(default #default-sofa-directory)
(help @askdir-help)
))
; Compute name of Sofa directory
(set #sofa-directory (tackon #sofa-directory "sofa"))
(debug " #sofa-directory =" #sofa-directory)
; Compute name of library directory
(set #library-directory (tackon #sofa-directory "library"))
(debug " #library-directory =" #library-directory)
; Compute name of SmallEiffel's "bin" and "sys" directory
(set #smalleiffel-directory (tackon #sofa-directory "SmallEiffel"))
(set #smalleiffel-directory-bin (tackon #smalleiffel-directory "bin"))
(set #smalleiffel-directory-sys (tackon #smalleiffel-directory "sys"))
(debug " #smalleiffel-directory =" #smalleiffel-directory)
; Set target directory used in standard message during (exit)
(set @default-dest #sofa-directory)
(debug " @default-dest =" @default-dest)
))
;----------------------------------------------------------------------------
; Ask for C compiler to use
;----------------------------------------------------------------------------
(procedure P-ask-c-compiler
(
(debug "ask-c-compiler")
; Figure out default selection of compiler: If DCC: exists, use DICE,
; if SC: exists use SAS/c, if ADE: or GG: exists, use EGCS/GCC
(set #compiler-choice #compiler-other-id)
(if (exists("sc:" (noreq)))
(set #compiler-choice #compiler-sas-id)
(if (exists("dcc:" (noreq)))
(set #compiler-choice #compiler-other-id) ; TODO: Support DICE
(if (OR (<> "" (exists("ade:" (noreq))) (<> "" (exists("gg:" (noreq))))))
(set #compiler-choice #compiler-gcc-id)
)
)
)
(debug " default compiler: " #compiler-choice)
(set #compiler-dice-name "") ; TODO: Support DICE by removing this line
(set #compiler-choice
(askchoice
(prompt #prompt-ask-c-compiler)
(help #help-ask-c-compiler)
(default #compiler-choice)
(choices
#compiler-sas-name
#compiler-gcc-name
#compiler-dice-name
#compiler-other-name
)
))
(debug " choice = " #compiler-choice)
))
;----------------------------------------------------------------------------
; Set a variable in SmallEiffel/sys
;----------------------------------------------------------------------------
(procedure P-set-smalleiffel-variable #variable #value
(
(debug " set" #variable "to" #value)
(if (<> "debug" @app-name)
(
(textfile
(dest (tackon #smalleiffel-directory-sys #variable))
(append #value)
)
)
(debug " debug-skip")
)
))
;----------------------------------------------------------------------------
; Set stuff in sofa/SmallEiffel/sys
;----------------------------------------------------------------------------
(procedure P-set-smalleiffel-sys
(
(working #working-set-smalleiffel)
(set #sys-gc "m68k-amigaos.c")
(set #sys-system "Amiga")
(select (+ 0 #compiler-choice)
(
; SAS/c
(set #sys-compiler "sc")
)
(
; gcc/egcs
(set #sys-compiler "gcc")
)
(
; DICE
(set #sys-compiler "") ; TODO: support DICE
)
(
; Other
(set #sys-compiler "")
)
)
; Reset loadpath to current directory
(set #sys-loadpath "\n")
; Add additional libraries to loadpath
(set #sys-loadpath
(cat #sys-loadpath
"${GOBO}/library/loadpath.se" "\n"
"${EXML}/compiler_specific/se/loadpath.se" "\n"
))
; Add SmallEiffel to loadpath
(set #sys-loadpath
(cat #sys-loadpath
"sofa:SmallEiffel/lib_std/" "\n"
"sofa:SmallEiffel/lib_rand/" "\n"
"sofa:SmallEiffel/lib_show/" "\n"
"sofa:SmallEiffel/lib_se/" "\n"
))
(P-set-smalleiffel-variable "system.se" #sys-system )
(P-set-smalleiffel-variable "compiler.se" #sys-compiler)
(P-set-smalleiffel-variable "gc" #sys-gc)
(P-set-smalleiffel-variable "loadpath.Amiga" #sys-loadpath)
))
;----------------------------------------------------------------------------
; Update User-Startup
;----------------------------------------------------------------------------
(procedure P-update-user-startup
(
; Simply adds a SetEnv and Path command
(debug "update user-startup")
(working #working-user-startup)
(set #command-user-startup
(cat ("Assign sofa: \"%s\"\n" #sofa-directory)
("SetEnv SmallEiffel \"%s\"\n" (tackon "sofa:SmallEiffel" #env-appendix ))
("SetEnv GOBO \"%s\"\n" "sofa:library/gobo")
("SetEnv EXML \"%s\"\n" "sofa:library/exml")
"Path Add \"sofa:SmallEiffel/bin\" \"${GOBO}/bin\"\n"
))
(debug "---")
(debug #command-user-startup)
(debug "---")
(if (<> "debug" @app-name)
(startup "Sofa"
(confirm)
(prompt (cat #prompt-update-user-startup #command-user-startup))
(help #help-update-user-startup)
(command #command-user-startup)
)
(debug " debug-skip")
)
))
;----------------------------------------------------------------------------
; Create directories
;----------------------------------------------------------------------------
(procedure P-create-directories
(
; Create Sofa directory and SmallEiffel/bin because they are needed in any case
(makedir #sofa-directory (safe))
(copyfiles
(source "/sofa.info")
(dest (tackon #sofa-directory "/"))
)
(makedir #library-directory (safe))
(makedir #smalleiffel-directory (safe))
(makedir #smalleiffel-directory-bin (safe))
(makedir #smalleiffel-directory-sys)
))
;----------------------------------------------------------------------------
; Check if current directory is target directory
;----------------------------------------------------------------------------
(procedure P-check-already-in-sofa
(
(debug "P-check-already-in-sofa")
; Check, if target directory is current directory. If so, no files have
; to be copied later on
(set #expanded-current (expandpath ""))
(set #expanded-sofa (expandpath #sofa-directory))
(debug " expanded-current = " #expanded-current)
(debug " expanded-sofa = " #expanded-sofa)
(set #already-in-sofa (= #expanded-current #expanded-sofa))
(debug " already-in-sofa = " #already-in-sofa)
))
;----------------------------------------------------------------------------
; Copy support files (Readme etc)
;----------------------------------------------------------------------------
(procedure P-copy-support-files
(
(debug "copy-support-files")
; Copy all files in the root directory
(if (<> "debug" @app-name)
(
(debug " copy files")
(copyfiles
(prompt #prompt-copy-support-files)
(help #help-copy-support-files)
(source "")
(choices "Readme" "Welcome.html" "SmallEiffel" "library")
(dest #sofa-directory)
(infos)
)
)
(debug " debug-skip")
)
))
;----------------------------------------------------------------------------
; Copy generic files
;----------------------------------------------------------------------------
(procedure P-copy-generic-files
(
(debug "copy-generic-files")
; template to fill in for more stuff to copy
))
;----------------------------------------------------------------------------
; Extract lha archive to relative target directory using c/lhex
;----------------------------------------------------------------------------
(procedure P-extract-archive #archive-name #relative-target #description (
(working (#working-extract-archive #archive-name #description))
(set #script-name "t:sofa-lhex.bat")
(set #lhex (expandpath "c/lhex"))
(set #expanded-target (expandpath (tackon #sofa-directory #relative-target)))
(set #expanded-archive (expandpath (tackon "archive" #archive-name)))
(set #command-extract-archive
(cat ("cd \"%s\"\n" #expanded-target)
("\"%s\" >\"con:///100/Extract %s/AUTO\" -qaf x \"%s\"\n" #lhex #archive-name #expanded-archive)
))
(debug "---")
(debug #command-extract-archive)
(debug "---")
(textfile
(dest #script-name)
(append #command-extract-archive)
)
(set #execute-result (execute #script-name))
(if (= 0 #execute_result)
(
; extracted successfully
(delete #script-name)
)
(
; error during extraction
(abort (#message-extract-failed #archive-name #script-name))
)
)
))
;----------------------------------------------------------------------------
; Exit
;----------------------------------------------------------------------------
(procedure P-exit
(
(debug "exit")
; If no specific compiler was specified, give the user a hint
(if (= #compiler-other-id #compiler-choice)
(message #message-manual-compiler-setup)
)
; If no binaries have been found, tell the user where he can get them from
; (complete 95)
; (if (= 0 (exists(tackon #target-directory-bin "compile")))
; (message (#message-binaries-missing #target-directory-bin) (all))
; )
; Say "good bye"
(complete 100)
(message (#message-exit) (all))
(exit (quiet))
))
(procedure P-exit-change-compiler
(
(debug "exit")
; Just say "good bye"
(message (#message-exit-change-compiler) (all))
(exit (quiet))
))
;----------------------------------------------------------------------------
; Do it!
;----------------------------------------------------------------------------
(complete 0) (P-check-requirements)
(if (<> @app-name "Settings")
(
; Install the package
(complete 0) (P-welcome)
(complete 20) (P-ask-sofa-directory)
(complete 30) (P-ask-c-compiler)
; (complete 35) (P-check-already-in-sofa)
(complete 35) (P-create-directories)
(complete 40) (P-copy-support-files)
(complete 50) (P-extract-archive "SmallEiffel.lha" "" "Compiler and base library")
(complete 60) (P-extract-archive "gobo.lha" "library" "Portable kernal, data structures library and parser tools")
(complete 70) (P-extract-archive "exml.lha" "library" "XML parsing library")
(complete 75) (P-extract-archive "other.lha" "" "Various other material")
(complete 77) (P-extract-archive "developer.lha" "" "Sofa Team developer material")
(complete 80) (P-update-user-startup)
(complete 85) (P-set-smalleiffel-sys)
(complete 90) (P-exit)
)
(
; Only change the C compiler used by Sofa
(complete 0) (P-welcome-change-compiler)
(set #sofa-directory (expandpath ""))
(set #smalleiffel-directory (expandpath "SmallEiffel"))
(set #smalleiffel-directory-bin (tackon #smalleiffel-directory "bin"))
(set #smalleiffel-directory-sys (tackon #smalleiffel-directory "sys"))
(complete 30) (P-ask-c-compiler)
(complete 60) (P-set-smalleiffel-sys)
(complete 100) (P-exit-change-compiler)
)
)