host.rc
author Stefan Vogel <sv@exept.de>
Tue, 26 Oct 1999 19:52:47 +0200
changeset 394 70ecff920548
parent 376 e57febe4cd37
child 405 46fe89d09123
permissions -rw-r--r--
Fix DISPLAY access for headless servers.

"*
 * $Header$
 *
 * ST/X startup configuration file:
 *
 * DONT 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 rshCommand isStupidSYSV3 conf includes incDir|

sysType := OperatingSystem getSystemType.
isStupidSYSV3 := false.

sysType = 'realIX' ifTrue:[
    "/
    "/ those people must have been brain-damaged;
    "/ They made a whole lot of trouble by renaming
    "/ 'rsh' to 'remsh' (those systems are broken in other places as well ...).
    "/ (who needs a restricted shell named 'rsh' ?)
    "/
    isStupidSYSV3 := true.
].

"------------------------------------------------------------------------"
"/ 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:[

    "/
    "/ setup the printer stuff.
    "/ the commands below will be offered in the printer-setting box
    "/
    PostscriptPrinterStream notNil ifTrue:[
	isStupidSYSV3 ifTrue:[
	    PostscriptPrinterStream 
		defaultCommands:#(
				    'lpr'
				    'cat | remsh {hostname} lpr -h'
				    'cat > preview.ps'
				    'cat > preview.ps; ghostview preview.ps'
				 ).
	] ifFalse:[
	    PostscriptPrinterStream 
		defaultCommands:#(
				    'lpr -h'
				    'cat | rsh {hostname} lpr -h'
				    'cat > preview.ps'
				    'cat > preview.ps; ghostview preview.ps'
				 ).
	].
	PostscriptPrinterStream printCommand:'lpr'.
    ].

    PrinterStream notNil ifTrue:[
	isStupidSYSV3 ifTrue:[
	    PrinterStream 
		defaultCommands:#(
				    'lpr -h'
				    'cat | remsh {hostname} lpr -h'
				    'a2ps | remsh {hostname} lpr -h'
				    'a2ps > preview.ps; ghostview preview.ps'
				 ).
	] ifFalse:[
	    PrinterStream 
		defaultCommands:#(
				    'lpr -h'
				    'cat | rsh {hostname} lpr -h'
				    'a2ps | rsh {hostname} lpr -h'
				    'a2ps > preview.ps; ghostview preview.ps'
				 ).
	].
	Printer := PrinterStream.
	PrinterStream printCommand:'lpr'.
    ].

    "/ Printer := PostscriptPrinterStream.

    "/ in our home-domain, preset the print command for remote printing
    "/ on a host called 'ibm'.
    "/ You can change this for YOUR environment and/or make it unconditional.
    "/ Consider the stuff below as an example; you should add
    "/ corresponding setup into a private h_xxxx.rc file.

    domain := OperatingSystem getDomainName.
    (domain = 'exept.de') ifTrue:[
	PostscriptPrinterStream notNil ifTrue:[
	    isStupidSYSV3 ifTrue:[
		PostscriptPrinterStream printCommand:'cat | remsh exept lpr -h'.
		PrinterStream printCommand:'cat | remsh exept lpr -h'.
		PostscriptPrinterStream defaultCommands:#(
					    'cat | remsh exept lpr -h'
					    'cat > preview.ps'
					    'cat > preview.ps; ghostview preview.ps'
				     ).
		PrinterStream defaultCommands:#(
					    'cat | remsh exept lpr -h'
					    'a2ps | remsh exept lpr -h'
					    'a2ps > preview.ps; ghostview preview.ps'
				     ).
	    ] ifFalse:[
		PostscriptPrinterStream printCommand:'cat | rsh exept lpr -h'.
		PrinterStream printCommand:'cat | rsh exept lpr -h'.
		PostscriptPrinterStream defaultCommands:#(
					    'cat | rsh exept lpr -h'
					    'cat > preview.ps'
					    'cat > preview.ps; ghostview preview.ps'
				     ).
		PrinterStream defaultCommands:#(
					    'cat | rsh exept lpr -h'
					    'a2ps | rsh exept lpr -h'
					    'a2ps > preview.ps; ghostview preview.ps'
				     ).
	    ].
	].
    ].
].

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

Compiler stcCompilation:#default.
Compiler 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:[
    Compiler ccPath:'gcc'
] ifFalse:[
    Compiler ccPath:'cc'
].
Compiler ccCompilationOptions:'-O'.

includes := ''.
('../../include' asFilename exists) ifTrue:[
    "/ running in a development environment ...
    includes := includes , '-I../../include '.
].
incDir := Smalltalk getSystemFileName:'include'.
incDir notNil ifTrue:[
    includes := includes , '-I' , incDir asFilename pathName , ' '
] ifFalse:[
    "/ running in a shared environment ...
    ('/usr/local/lib/smalltalk/include' asFilename exists) ifTrue:[
	includes := includes , '-I/usr/local/lib/smalltalk/include '.
    ] ifFalse:[
	('/opt/smalltalk/include' asFilename exists) ifTrue:[
	    includes := includes , '-I/opt/smalltalk/include '.
	] ifFalse:[
	    'private.rc [warning]: no >>include<< directory found along your path.' errorPrintCR.
	    'private.rc [warning]: this will affect stc-compilation from within the browser.' infoPrintCR.
	]
    ].
].

Compiler 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:[
	Compiler stcCompilationDefines:'-DGLX'.
    ] ifFalse:[
	Compiler stcCompilationIncludes:'-I../../include -I../../support/VGL/vogl/src'.
	Compiler stcCompilationDefines:'-DVGL'.
    ]
].

"/ specify additional link libraries.
"/ Disabled; thats the default anyway ....
"/
"/    OperatingSystem getOSType = 'linux' ifTrue:[
"/        ObjectFileLoader searchedLibraries:#('/usr/lib/libc.a')
"/    ]



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

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

"/
"/ 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:[
	    s fileIn.
	    s close.
	].
	Smalltalk at:#'_ImageHostName' put:host.
    ]
].
!