@echo off
rem CYGNUS LOCAL: configure.bat
rem The fsf version has been moved to config/msdos.

rem This batch file assumes a unix-type "sed" program
rem The h8/300 support assumes a unix-type "m4" program also

if "%1" == "go32" goto go32
if "%1" == "h8/300" goto h8300
if "%1" == "a29k" goto a29k
echo Specify one of [ go32 h8/300 a29k ] on command line
goto exit

:go32
echo Configuring GCC for go32
update config\i386\xm-dos.h config.h
update config\i386\xm-dos.h hconfig.h
update config\i386\xm-dos.h tconfig.h
update config\i386\go32.h tm.h
update config\i386\i386.md md
update config\i386\i386.c aux-output.c
update config\float.h-ieee float.h
goto finish

:h8300
echo Configuring GCC for H8/300
update config\i386\xm-dos.h config.h
update config\i386\xm-dos.h hconfig.h
update config\h8300\h8300.h tm.h
m4 < config\h8300\h8300.md | sed "s/^# /; /g" > md
update config\h8300\h8300.md md.pre_m4
update config\h8300\h8300.c aux-output.c
update config\float.h-ieee float.h
goto finish

:a29k
echo Configuring GCC for a29k
update config\i386\xm-dos.h config.h
update config\i386\xm-dos.h hconfig.h
update config\a29k\a29k.h tm.h
update config\a29k\a29k.md md
update config\a29k\a29k.c aux-output.c
update config\float.h-ieee float.h

finish:

echo # Makefile generated by "configure.bat"> Makefile
echo all.dos: cccp cc1 cc1plus cc1obj xgcc>> Makefile

if exist config.sed del config.sed

echo "/\.o[ 	]*:/ s/config.status//			">> config.sed
echo "/^target=/ c\					">> config.sed
echo "target=go32					">> config.sed
echo "/^version=/ c\					">> config.sed
sed -e "s/.*\"\([^ \"]*\)[ \"].*/version=\1/" version.c  >> config.sed
echo "s/CC = cc/CC = gcc/				">> config.sed
echo "s/:\$/: \$/g					">> config.sed
echo "s/^	\ *\.\//	go32 /			">> config.sed
echo "s/<\ *\$(srcdir)\//< $(srcdir)\\/g		">> config.sed
echo "s/^	\$(srcdir)\/move-if-change/	update/	">> config.sed
echo "s/^USE_/# USE_/					">> config.sed
echo "s/`echo \$(srcdir)\///g				">> config.sed
echo "s/ | sed 's,\^\\\.\/,,'`//g			">> config.sed
echo "s/^	cd \$(srcdir)[ 	]*;/	/		">> config.sed

echo "/^# USE_HOST_OBSTACK/ i\				">> config.sed
echo "USE_HOST_OBSTACK=obstack.o			">> config.sed

echo "/^stamp-attrtab/,/update/ {			">> config.sed
echo "  /\\/d						">> config.sed
echo "  /fi/d						">> config.sed
echo "  /update/ i\					">> config.sed
echo "	  go32 genattrtab md > t-attrtab.c		">> config.sed
echo "}							">> config.sed

echo "/^enquire[ 	]*:/ s/\$(GCC_PARTS)//g		">> config.sed
echo "/^enquire.o[ 	]*:/ s/\$(GCC_PASSES)//g	">> config.sed
echo "/^GCC_FOR_TARGET =/ c\				">> config.sed
echo "GCC_FOR_TARGET = gcc				">> config.sed

echo "s/; *@true//					">> config.sed
echo "s/stamp-/s-/g					">> config.sed
echo "s/tmp-/t-/g					">> config.sed

sed -e "s/^\"//" -e "s/\"$//" -e "s/[ 	]*$//" config.sed > config2.sed
sed -f config2.sed Makefile.in >> Makefile
del config.sed
del config2.sed

:exit
