@if exist patches goto start
@echo The current working directory must be \emx\gnu
@goto end
:start
if not "%1"=="" goto %1
:tar
gzip -cd<texinfo-3.1.tar.gz|tar xf -
if "%2"=="tar" goto end
:move
if exist texinfo.dis goto end
if exist info goto end
if exist makeinfo goto end
if exist libtxi goto end
if exist texindex goto end
ren texinfo-3.1 texinfo.dis
ren texinfo-.31 texinfo.dis
md info
md libtxi
md makeinfo
md texindex
move texinfo.dis\libtxi\getopt.c libtxi
move texinfo.dis\libtxi\getopt.h libtxi
move texinfo.dis\libtxi\getopt1.c libtxi
move texinfo.dis\info\echo_area.c info\echo_are.c
move texinfo.dis\info\echo_area.h info\echo_are.h
move texinfo.dis\info\footnotes.c info\footnote.c
move texinfo.dis\info\footnotes.h info\footnote.h
move texinfo.dis\info\info-utils.c info\info-uti.c
move texinfo.dis\info\info-utils.h info\info-uti.h
move texinfo.dis\info\variables.c info\variable.c
move texinfo.dis\info\variables.h info\variable.h
move texinfo.dis\info\*.c info
move texinfo.dis\info\*.h info
move texinfo.dis\makeinfo\makeinfo.c makeinfo
move texinfo.dis\util\texindex.c texindex
if "%2"=="move" goto end
:config
copy patches\info-pc.c libtxi\pc.c
copy patches\info-pc.h libtxi\pc.h
sed -f patches\infoemx1.sed texinfo.dis\info\Makefile.in >info\Makefile
sed -f patches\infoemx2.sed texinfo.dis\libtxi\Makefile.in >libtxi\Makefile
sed -f patches\infoemx3.sed texinfo.dis\makeinfo\Makefile.in >makeinfo\Makefile
sed -f patches\infoemx4.sed texinfo.dis\util\Makefile.in >texindex\Makefile
if "%2"=="config" goto end
if "%2"=="no-patch" goto end
:patch
setlocal
set tmp=
lwpatch -p0 <patches\info-emx.pat
endlocal
if "%2"=="patch" goto end
:end
