
#if 0
# $Header: /pdsrc/Local/RCS/altlib.sh,v 1.1 90/05/01 19:27:02 root Exp $
#
# $Log:	altlib.sh,v $
# Revision 1.1  90/05/01  19:27:02  root
# Initial revision
# 
#
# Script and source code for SCO Xenix gnulib compiled with GCC.
#
# SCO Xenix 386 gnulib only has three self-recursive functions and these
# can be replaced by assembly language versions whose source code is in
# this file.  Executing this file with /bin/sh (NOT csh) in the GCC
# source directory will result in the production of an alternative gnulib
# called altgnulib which is entirely compiled with GCC.
#

AR=ar
GCC=gcc
CCLIBFLAGS=-O
INCLUDES="-I. -Iconfig"

LIBFUNCS="_eprintf _builtin_new _builtin_New _builtin_del 
	_umulsi3 _mulsi3 _umodsi3 _modsi3 
	_lshrsi3 _lshlsi3 _ashrsi3 _ashlsi3 
	_divdf3 _muldf3 _negdf2 _adddf3 _subdf3 _cmpdf2 
	_fixunsdfsi _floatsidf _truncdfsf2 _extendsfdf2 
	_addsf3 _negsf2 _subsf3 _cmpsf2 _mulsf3 _divsf3"

ALIBFUNCS="_udivsi3 _divsi3 _fixdfsi"

rm -f altgnulib

for name in $LIBFUNCS
do 
	  echo Compiling $name
	  rm -f $name.c
	  cp gnulib.c $name.c
	  $GCC $CCLIBFLAGS $INCLUDES -c -DL$name $name.c 
	  $AR qc altgnulib $name.o
	  rm -f $name.[co]
done

for name in $ALIBFUNCS
do 
	  echo Assembling $name
	  rm -f $name.S
	  cp $0 $name.S
	  $GCC $CCLIBFLAGS $INCLUDES -c -DL$name $name.S
	  $AR qc altgnulib $name.o
	  rm -f $name.[So]
done

ranlib altgnulib

exit 0

#endif

#ifdef L_udivsi3
	.file	"__udivsi3.s"
.text
	.align 2
.globl ___udivsi3
___udivsi3:
	pushl %ebp
	movl %esp,%ebp
	movl 8(%ebp),%eax
	xorl %edx,%edx
	divl 12(%ebp)
	leave
	ret
#endif

#ifdef L_divsi3
	.file	"__divsi3.s"
.text
	.align 2
.globl ___divsi3
___divsi3:
	pushl %ebp
	movl %esp,%ebp
	movl 8(%ebp),%eax
	cdq
	idivl 12(%ebp)
	leave
	ret
#endif

#ifdef L_fixdfsi
	.file	"__fixdfsi.s"
.text
	.align 2
.globl ___fixdfsi
___fixdfsi:
	pushl %ebp
	movl %esp,%ebp
	subl	$12,%esp
	fstcw	-4(%ebp)  
	movw	-4(%ebp),%ax
	orw	$0x0c00,%ax  
	movw	%ax,-2(%ebp) 
	fldcw	-2(%ebp)     
	fldl	8(%ebp)
	fistpl	-12(%ebp)    
	fldcw	-4(%ebp)     
	movl	-12(%ebp),%eax
	leave
	ret
#endif
