#!/bin/ksh
set -e
rm -f libgcc.a
for name in _mulsi3 _udivsi3 _divsi3 _umodsi3 _modsi3 _lshrsi3 \
	_lshlsi3 _ashrsi3 _ashlsi3 _divdf3 _muldf3 _negdf2 _adddf3 \
	_subdf3 _fixdfsi _fixsfsi _floatsidf _floatsisf _truncdfsf2 \
	_extendsfdf2 _addsf3 _negsf2 _subsf3 _mulsf3 _divsf3 _eqdf2 \
	_nedf2 _gtdf2 _gedf2 _ltdf2 _ledf2 _eqsf2 _nesf2 _gtsf2 \
	_gesf2 _ltsf2 _lesf2
do 
	echo ${name}
	rm -f ${name}.o
	m68k -O -I. -I. -I./config -c -DL${name} ./libgcc1.c
	mv libgcc1.o ${name}.o
	ar qc libgcc.a ${name}.o
	rm -f ${name}.o
done
	
for name in _muldi3 _divdi3 _moddi3 _udivdi3 _umoddi3 _negdi2 _lshrdi3 \
	_lshldi3 _ashldi3 _ashrdi3 _ffsdi2 _udiv_w_sdiv _udivmoddi4 \
	_cmpdi2 _ucmpdi2 _floatdidf _floatdisf _fixunsdfsi _fixunssfsi \
	_fixunsdfdi _fixdfdi _fixunssfdi _fixsfdi _fixxfdi _fixunsxfdi \
	_floatdixf _fixunsxfsi _fixtfdi _fixunstfdi _floatditf \
	__gcc_bcmp _varargs _eprintf _op_new _op_vnew _new_handler \
	_op_delete _op_vdel _bb _shtab _clear_cache _trampoline \
	__main _exit _ctors
do 
	echo ${name}
	rm -f ${name}.o
	m68k -O -I. -I. -I./config -c -DL${name} ./libgcc2.c
	mv libgcc2.o ${name}.o
	ar qc libgcc.a ${name}.o
	rm -f ${name}.o
done

/usr/local/m68k/bin/ranlib libgcc.a
mv libgcc.a /usr/local/m68k/lib
