host.rc
author Claus Gittinger <cg@exept.de>
Sun, 19 Jan 2020 16:28:21 +0100
changeset 1620 6437a27b72fc
parent 1523 07a68963b4cc
permissions -rw-r--r--
*** empty log message ***

"*
 * Encoding: iso8859-1
 *
 * $Header$
 *
 * ST/X startup configuration file:
 *
 * DON'T add site specific things here - use your own h_xxx.rc file instead
 * where xxx stands for your hostname(s)
 *
 * startup configuration for host specific stuff -
 * looks for a system specific h_sysType.rc init file and loads it.
 * looks for a host specific h_hostName.rc init file and loads it.
 *"
!
|sysType host domain s conf includes incDir|

sysType := OperatingSystem getSystemType.

"------------------------------------------------------------------------"
"/ printer setup
"/ Notice that this setup may be changed by an OS-specific h_xxx file
"/
"/ only reset the printer setting, if restarted
"/ on another host.

host := OperatingSystem getHostName.
(Smalltalk at:#'_ImageHostName') ~= host ifTrue:[
    sysType = 'win32' ifTrue:[
	Printer := Smalltalk at:#WinPrinterStream.
    ] ifFalse:[
	Printer := Smalltalk at:#PostscriptPrinterStream.
    ].
].

"------------------------------------------------------------------------"
"/ default compiler setup;
"/ can be rechanged in a h_xxx file.
"/

(Smalltalk wasStartedFromImage not and:[ Smalltalk isPlugin not ])
ifTrue:[
    ParserFlags stcCompilation:#default.
    ParserFlags stcCompilationOptions:'+optinline +inlineNew'.

    "/
    "/ setup for gcc (which is OK for most systems);
    "/ Notice that this setup may be changed by an OS-specific h_xxx file
    "/
    conf := Smalltalk configuration.
    (conf includesString:'gcc') ifTrue:[
	ParserFlags ccPath:'gcc'
    ] ifFalse:[
	(conf includesString:'clang') ifTrue:[
	    ParserFlags ccPath:'clang'
	] ifFalse:[
	    ParserFlags ccPath:'cc'
	].
    ].
    ParserFlags ccCompilationOptions:'-O'.

    (conf includesString:'amd64_mode32') ifTrue:[
	((ObjectFileLoader linkArgs ? '') includesString:'-m32') ifFalse:[
	    ObjectFileLoader linkArgs:((ObjectFileLoader linkArgs ? '') , ' -m32 -m elf_i386').
	].
	(ParserFlags ccCompilationOptions includesString:'-m32') ifFalse:[
	    ParserFlags ccCompilationOptions:(ParserFlags ccCompilationOptions , ' -m32').
	].
	((ParserFlags stcCompilationDefines ? '') includesString:'-D__amd64_mode32__') ifFalse:[
	    ParserFlags stcCompilationDefines:((ParserFlags stcCompilationDefines ? ''), ' -D__amd64_mode32__').
	].
    ].


    includes := ''.
    incDir := Smalltalk getSystemFileName:'include/stc.h'.
    incDir notNil ifTrue:[ incDir := incDir asFilename directoryName ].

    incDir notNil ifTrue:[
	includes := includes , '-I' , incDir asFilename pathName , ' '
    ] ifFalse:[
	('../../../stx/include' asFilename exists) ifTrue:[
	    "/ running in a development environment...
	    includes := includes , '-I../../../stx/include '.
	] ifFalse:[
	    ('../../include' asFilename exists) ifTrue:[
		"/ running in a development environment...
		includes := includes , '-I../../include '.
	    ] ifFalse:[
		"/ if this is a production program, dont care for a warning
		(Smalltalk isStandAloneApp or:[Smalltalk isHeadless])
		ifFalse:[
		    'host.rc [warning]: no >>include<< directory found along your path.' infoPrintCR.
		    'host.rc [warning]: this might affect stc-compilation from within the browser.' infoPrintCR.
		]
	    ]
	]
    ].

    ParserFlags stcCompilationIncludes:includes.

    "/
    "/ for myself: preset flags, so that we can accept GLXWorkstation code
    "/ You probably will never do this.
    "/
    (Display notNil and:[Display supportsGLDrawing]) ifTrue:[
	sysType = 'irix' ifTrue:[
	    ParserFlags stcCompilationDefines:'-DGLX'.
	] ifFalse:[
	    ParserFlags stcCompilationIncludes:'-I../../include -I../../support/VGL/vogl/src'.
	    ParserFlags stcCompilationDefines:'-DVGL'.
	]
    ].
].

"/
"/ try systemType-specific setup
"/ h_<osType>.rc
"/
(Smalltalk at:#'_ImageOSTypeName') ~= sysType ifTrue:[
    ('host.rc [info]: ') infoPrint.

    "/ ('trying host setup h_' , sysType , '.rc...') infoPrintCR.
    s := Smalltalk systemFileStreamFor:('h_' , sysType , '.rc').
    s notNil ifTrue:[
	('reading host setup h_' , sysType , '.rc...') infoPrintCR.
	s fileIn.
	s close.
    ].
    Smalltalk at:#'_ImageOSTypeName' put:sysType.
].

"/
"/ try host-specific setup
"/ h_<hostname>.rc
"/
host isNil ifTrue:[
    'host.rc [warning]: cannot determine host I am running on' errorPrintCR.
] ifFalse:[
    "if there is a corresponding file ..."

    (Smalltalk at:#'_ImageHostName') ~= host ifTrue:[
	"/ ('host.rc [info]: trying host setup h_' , host , '.rc...') infoPrintCR.

	s := Smalltalk systemFileStreamFor:('h_' , host , '.rc').
	s notNil ifTrue:[
	    ('host.rc [info]: reading host setup h_' , host , '.rc...') infoPrintCR.
	    s fileIn.
	    s close.
	].
	Smalltalk at:#'_ImageHostName' put:host.
    ]
].
!