#! /bin/csh -f
#$Header:crt0.ex 12.0$
#$ACIS:crt0.ex 12.0$
#$Source: /ibm/acis/usr/src/lib/libc/ca/csu/RCS/crt0.ex,v $
#
# 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1986,1988
# LICENSED MATERIALS - PROPERTY OF IBM
# REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
#
# decide which compiler is used  
switch (`egrep 'globl.*(oVpcc|oVhc1|oVhc2)' $1 | awk '{print substr($2,4,3)}'`)

case pcc:

	ex - $1 <<"+"
"	Massage output of compiler for crt0 to generate an NCS crt0.o	"
"	for pcc
g/.globl/s/_.start/start/
1,$s/_.start/.start/
1s/LL0:/start:	j	.start/
1a
.short	1
.long	1
.long	_start
.
/D_COMMON/s/07/03/
s/D_COMMON/D_START/
/.globl _start/s/.globl/ #.globl/
g/_.mcount/s//mcount/
w
q
"+"
	breaksw

case hc1:

	ex - $1 <<"+"
"	Massage output of compiler for crt0 to generate an NCS crt0.o	"
"	for hc   							"
g/.globl/s/_.start/start/
1,$s/_.start/.start/
g/.globl[ 	]*_start/s/^/ #/
1a
start: j  .start
.short	1
.long	1
.long	_start
.
/DF07/s/07/03/
s/$/ D_START/
/.globl[ 	]*_.mcount/s/_.mcount/mcount/
/_.mcount/,/br[ 	]*r15/d
i
mcount: br r15
.
" indicate no stack for dummy routine 					"
/DF07/s/07/02/
g/.globl[ 	]*_mcount/s/^/#/
w
q
"+"
	breaksw

case hc2:

	ex - $1 <<"+"
"	Massage output of compiler for crt0 to generate an NCS crt0.o	"
"	for hc2   							"
g/.globl/s/_.start/start/
1,$s/_.start/.start/
g/.globl[ 	]*_start/s/^/#/
1a
start: j  .start
.short	1
.long	1
.long	_start
.
/0x07/s/07/03/
s/$/ D_START/
1,$s/_.mcount/mcount/
g/.globl[ 	]*_mcount/s/^/#/
w
q
"+"
	breaksw
endsw
