/**/
address command

call pragma('S', 100000)

targetdir='Work:Ccomeau'
rexx='ARexx30'
c='c30'
include='include30'
lib='lib30'
lcheaders='work:lc/compiler_headers'

rexx=targetdir'/'rexx
c=targetdir'/'c
include=targetdir'/'include
lib=targetdir'/'lib

parse arg thearg

call getversion

call doio 0, 640, 74, 'THANK YOU!!'

say
say 'Thank you for purchasing Comeau C++ 3.0 With Templates for AmigaDOS.'
say 'This product will work with AmigaDOS 1.3 or 2.0.'
say 'TAKE YOUR TIME AND READ ALL TEXT AND EVERY PROMPT THAT APPEARS!!!!'
if version ~= "2.0" then do
    say
    say 'Under 1.3, note that you may find the need to click on a window asking input.'
end

call changeio 0, 640, 200, 'Check your disk space'

say
say 'Ensuring space...'
say

do forever
    say 'You will need --> 2000 <-- free blocks to install'
    say 'Comeau C++ 3.0 With Templates for AmigaDOS'
    info
    say
    options prompt "Ok to continue (y or n)? "
    pull ok
    if ok = y then
        leave
    else if ok = n then
        exit
end

call changeio 0, 640, 100, 'Double check the directories'

say
say 'Ensuring directories...'
do forever
    say
    say 'Main Amiga Comeau C++ drawer -->' targetdir
    say 'Drawer for binaries -->         ' c
    say 'Drawer for include files -->    ' include
    say 'Drawer for libraries -->        ' lib
    say 'Drawer for Arexx routines -->   ' rexx
    say
    options prompt "Ok to continue (y or n)? "
    pull ok
    if ok = y then
        leave

    call change 'targetdir', targetdir 
    call change 'c', c
    call change 'include', include
    call change 'lib', lib
    call change 'rexx', rexx
end

if thearg = '-d' then do
    call changeio 0, 640, 400, 'Deleting...'
    'delete' targetdir'/#? all'
    'list' targetdir
end

call changeio 160, 320, 50, 'Making directories'

say
say 'Making directories....'
say

say 'ADD CODE HERE TO CHECK IF DIR EXISTS'
'makedir' targetdir
'makedir' rexx
'makedir' c
'makedir' include
'makedir' lib

call changeio 160, 320, 100, 'Copying files'

say
say 'Copying files...'

'copy rexx/#?' rexx
'copy c/#?' c
'copy lib/#?' lib
'copy cctest#?.c' targetdir

call changeio 160, 320, 100, 'Still copying files'

say
say "Please remove Disk I and replace it with Disk II"
parse pull anything

say 'Copying more files....'

'copy c/#?' c

call changeio 70, 500, 100, 'DICE C Preprocessor'

say
say 'We strongly suggest that you use "dcpp" (the C Preprocessor'
say "that is supplied with Matt Dillon's DICE C) when you use"
say 'Comeau C++.  We CAN install dcpp now if you would like'
say '(note that DICE C, in whole or in part, is NOT part of,'
say 'or affliated with, Comeau C++).'
say
options prompt "Would you like to install dcpp (y or n)? "
parse pull ok
if ok = "n" then do
    say
    say 'dcpp, not installed.  You may obtain it later from'
    say 'df0:dice/dcpp'
    say
end
else do
    say
    say 'installing dcpp...'
    'copy dice/#?dcpp.doc' targetdir
    'copy dice/#?dcpp' c
    say
end

call changeio 0, 640, 400, 'Building header files'

say
say 'Making include headers....'
say

if version = '2.0' then do
    lcheaders=lcheaders'_2.0'
    say
    say '******* GOING TO USE 2.0 HEADERS *******'
    say
end

say 'This step is very chattery and lots of file names shall spew forth'
say

/*
if version = "2.0" then
c'/include' include lcheaders
else
say c'/include' include lcheaders
*/
'echo > ram:return ""'
c'/include < ram:return' include lcheaders
'delete ram:return quiet'

call changeio 160, 320, 150, 'Copying header files'

say
say 'Copying constant header files...'
say

'copy include/#?' include

call changeio 160, 320, 50, 'For S: file'

say
say 'Creating file for S: inclusion....'
say

'echo > 'targetdir'/forS "Assign CC:' targetdir'"'
'echo >> 'targetdir'/forS "Assign CC30Lib:' lib'"' 
'echo >> 'targetdir'/forS "Assign CC30include:' include'"'
'echo >> 'targetdir'/forS "Assign CC30c:' c'"'
'echo >> 'targetdir'/forS "Assign CC30Rexx:' rexx'"'

'echo >> 'targetdir'/forS "assign dice: CC30c:"' /**/
'echo >> 'targetdir'/forS "assign rexx: CC30rexx:"' /**/

'echo >> 'targetdir'/forS "copy CC30c:cfront ram:cfront"' /**/

'echo >> 'targetdir'/forS "stack 100000"' /**/

call changeio 0, 640, 400, 'PLEASE READ THIS NOW!!!'

'more readme'

call changeio 100, 440, 100, 'Installation Complete'

say
say 'Please consider the changes you should make to S:.'
say 'The file "'targetdir'/forS" should prove helpful.'
say '(Write this file name down now.)'
say
say 'Installation is now complete.'
say
say 'After setting up, reboot and try to compile the'
say '.c files in "'targetdir'".'
say
options prompt "Hit <return> to continue."
parse pull anything

exit

doio:
    parse arg xpos, xlen, ylen, coninfo
    if version = "2.0" then
        ypos=(400 - ylen)/2
    else do
        if ylen >= 400 then
            ylen = 200
        ypos=(200 - ylen)/2
    end
    coninfo=xpos'/'ypos'/'xlen'/'ylen'/'coninfo
    if version = "2.0" then
        coninfo=coninfo'/CLOSE'
    call close STDOUT
    if ~open(STDOUT, 'con:'coninfo, 'RW') then
        exit 1
    call close STDIN
    if ~open(STDIN, '*') then
        exit 2
return

changeio:
    parse arg xpos, xlen, ylen, coninfo
    options prompt "Hit <return> to continue."
    parse pull anything
    call doio xpos, xlen, ylen, coninfo
return

change:
    parse arg id, value
    options prompt 'Change' value' to (<return> to keep):'
    parse pull newvalue
    if newvalue ~= '' then
        interpret id'=newvalue'
return

getversion:
    'version >ram:vV'
    if ~open(v, 'ram:vV', 'R') then
        exit 3
    version=readln(v)
    call close v
    'delete ram:vV QUIET'
    parse var version d '.' d '.' d d version '.' d
    if version < 36 then
        version='not 2.0'
    else
        version='2.0'
return
