@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<gdb-4.11.tar.gz|tar xf -
if "%2"=="tar" goto end
:move
if exist gdb-dis goto end
if exist bfd goto end
if exist glob goto end
if exist include goto end
if exist libibert goto end
if exist readline goto end
move gdb-4.11 gdb-dis
md bfd
md gdb-4.11
md gdb-4.11\config
md glob
md include
md include\aout
md include\coff
md include\elf
md libibert
md readline
move gdb-dis\bfd\aout-target.h bfd\aout-tar.h
move gdb-dis\bfd\aout32.c bfd
move gdb-dis\bfd\aoutx.h bfd
move gdb-dis\bfd\archive.c bfd
move gdb-dis\bfd\archures.c bfd
move gdb-dis\bfd\bfd.c bfd
move gdb-dis\bfd\bfd-in2.h bfd
move gdb-dis\bfd\cache.c bfd
move gdb-dis\bfd\copying bfd
move gdb-dis\bfd\coffgen.c bfd
move gdb-dis\bfd\core.c bfd
move gdb-dis\bfd\cpu-i386.c bfd
move gdb-dis\bfd\ctor.c bfd
move gdb-dis\bfd\ecoff.c bfd
move gdb-dis\bfd\elf.c bfd
move gdb-dis\bfd\elfcode.h bfd
move gdb-dis\bfd\i386aout.c bfd\emx-aout.c
move gdb-dis\bfd\format.c bfd
move gdb-dis\bfd\init.c bfd
move gdb-dis\bfd\libaout.h bfd
move gdb-dis\bfd\libbfd.c bfd
move gdb-dis\bfd\libbfd.h bfd
move gdb-dis\bfd\libcoff.h bfd
move gdb-dis\bfd\libecoff.h bfd
move gdb-dis\bfd\libelf.h bfd
move gdb-dis\bfd\makefile.in bfd
move gdb-dis\bfd\opncls.c bfd
move gdb-dis\bfd\reloc.c bfd
move gdb-dis\bfd\reloc16.c bfd
move gdb-dis\bfd\seclet.c bfd
move gdb-dis\bfd\seclet.h bfd
move gdb-dis\bfd\section.c bfd
move gdb-dis\bfd\srec.c bfd
move gdb-dis\bfd\stab-syms.c bfd\stab-sym.c
move gdb-dis\bfd\syms.c bfd
copy patches\sysdep.bfd bfd\sysdep.h
move gdb-dis\bfd\targets.c bfd
move gdb-dis\bfd\trad-core.c bfd\trad-cor.c
move gdb-dis\gdb\blockframe.c gdb-4.11\blockfra.c
move gdb-dis\gdb\breakpoint.c gdb-4.11\breakpoi.c
move gdb-dis\gdb\breakpoint.h gdb-4.11\breakpoi.h
move gdb-dis\gdb\buildsym.c gdb-4.11
move gdb-dis\gdb\buildsym.h gdb-4.11
move gdb-dis\gdb\c-exp.tab.c gdb-4.11\c-exp.c
move gdb-dis\gdb\c-exp.y gdb-4.11
move gdb-dis\gdb\c-lang.c gdb-4.11
move gdb-dis\gdb\c-lang.h gdb-4.11
move gdb-dis\gdb\c-typeprint.c gdb-4.11\c-typepr.c
move gdb-dis\gdb\c-valprint.c gdb-4.11\c-valpri.c
move gdb-dis\gdb\call-cmds.h gdb-4.11\call-cmd.h
move gdb-dis\gdb\ch-exp.y gdb-4.11
move gdb-dis\gdb\ch-exp.tab.c gdb-4.11\ch-exp.c
move gdb-dis\gdb\ch-lang.c gdb-4.11
move gdb-dis\gdb\ch-lang.h gdb-4.11
move gdb-dis\gdb\ch-typeprint.c gdb-4.11\ch-typep.c
move gdb-dis\gdb\ch-valprint.c gdb-4.11\ch-valpr.c
move gdb-dis\gdb\cp-valprint.c gdb-4.11\cp-valpr.c
move gdb-dis\gdb\command.c gdb-4.11
move gdb-dis\gdb\command.h gdb-4.11
move gdb-dis\gdb\complaints.c gdb-4.11\complain.c
move gdb-dis\gdb\complaints.h gdb-4.11\complain.h
move gdb-dis\gdb\copying gdb-4.11
move gdb-dis\gdb\copying.awk gdb-4.11
move gdb-dis\gdb\copying.c gdb-4.11
move gdb-dis\gdb\core.c gdb-4.11
move gdb-dis\gdb\coredep.c gdb-4.11
move gdb-dis\gdb\corelow.c gdb-4.11
move gdb-dis\gdb\dbxread.c gdb-4.11
move gdb-dis\gdb\dcache.c gdb-4.11
move gdb-dis\gdb\dcache.h gdb-4.11
move gdb-dis\gdb\defs.h gdb-4.11
move gdb-dis\gdb\demangle.c gdb-4.11
move gdb-dis\gdb\environ.c gdb-4.11
move gdb-dis\gdb\environ.h gdb-4.11
move gdb-dis\gdb\eval.c gdb-4.11
move gdb-dis\gdb\exec.c gdb-4.11
move gdb-dis\gdb\expprint.c gdb-4.11
move gdb-dis\gdb\expression.h gdb-4.11\expressi.h
move gdb-dis\gdb\findvar.c gdb-4.11
move gdb-dis\gdb\frame.h gdb-4.11
move gdb-dis\gdb\gdb-stabs.h gdb-4.11\gdb-stab.h
move gdb-dis\gdb\gdbcmd.h gdb-4.11
move gdb-dis\gdb\gdbcore.h gdb-4.11
move gdb-dis\gdb\gdbtypes.c gdb-4.11
move gdb-dis\gdb\gdbtypes.h gdb-4.11
move gdb-dis\gdb\i386-pinsn.c gdb-4.11\i386-pin.c
move gdb-dis\gdb\i386-tdep.c gdb-4.11\i386-tde.c
move gdb-dis\gdb\i386v-nat.c gdb-4.11\i386v-na.c
move gdb-dis\gdb\i387-tdep.c gdb-4.11\i387-tde.c
move gdb-dis\gdb\infcmd.c gdb-4.11
move gdb-dis\gdb\inferior.h gdb-4.11
move gdb-dis\gdb\inflow.c gdb-4.11
move gdb-dis\gdb\infptrace.c gdb-4.11\infptrac.c
move gdb-dis\gdb\infrun.c gdb-4.11
move gdb-dis\gdb\inftarg.c gdb-4.11
move gdb-dis\gdb\language.c gdb-4.11
move gdb-dis\gdb\language.h gdb-4.11
move gdb-dis\gdb\m2-exp.tab.c gdb-4.11\m2-exp.c
move gdb-dis\gdb\m2-exp.y gdb-4.11
move gdb-dis\gdb\m2-lang.c gdb-4.11
move gdb-dis\gdb\m2-lang.h gdb-4.11
move gdb-dis\gdb\m2-typeprint.c gdb-4.11\m2-typep.c
move gdb-dis\gdb\m2-valprint.c gdb-4.11\m2-valpr.c
move gdb-dis\gdb\main.c gdb-4.11
move gdb-dis\gdb\maint.c gdb-4.11
move gdb-dis\gdb\makefile.in gdb-4.11
move gdb-dis\gdb\mem-break.c gdb-4.11\mem-brea.c
move gdb-dis\gdb\minsyms.c gdb-4.11
copy patches\munch.cmd gdb-4.11
move gdb-dis\gdb\nlmread.c gdb-4.11
move gdb-dis\gdb\objfiles.c gdb-4.11
move gdb-dis\gdb\objfiles.h gdb-4.11
move gdb-dis\gdb\parse.c gdb-4.11
move gdb-dis\gdb\parser-defs.h gdb-4.11\parser-d.h
move gdb-dis\gdb\partial-stab.h gdb-4.11\partial-.h
move gdb-dis\gdb\printcmd.c gdb-4.11
move gdb-dis\gdb\regex.c gdb-4.11
move gdb-dis\gdb\regex.h gdb-4.11
move gdb-dis\gdb\remote.c gdb-4.11
move gdb-dis\gdb\remote-utils.c gdb-4.11\remote-u.c
move gdb-dis\gdb\remote-utils.h gdb-4.11\remote-u.h
move gdb-dis\gdb\ser-unix.c gdb-4.11
move gdb-dis\gdb\serial.c gdb-4.11
move gdb-dis\gdb\serial.h gdb-4.11
move gdb-dis\gdb\signals.h gdb-4.11
move gdb-dis\gdb\source.c gdb-4.11
move gdb-dis\gdb\stabsread.c gdb-4.11\stabsrea.c
move gdb-dis\gdb\stabsread.h gdb-4.11\stabsrea.h
move gdb-dis\gdb\stack.c gdb-4.11
move gdb-dis\gdb\symfile.c gdb-4.11
move gdb-dis\gdb\symfile.h gdb-4.11
move gdb-dis\gdb\symmisc.c gdb-4.11
move gdb-dis\gdb\symtab.c gdb-4.11
move gdb-dis\gdb\symtab.h gdb-4.11
move gdb-dis\gdb\target.c gdb-4.11
move gdb-dis\gdb\target.h gdb-4.11
move gdb-dis\gdb\terminal.h gdb-4.11
move gdb-dis\gdb\thread.c gdb-4.11
move gdb-dis\gdb\thread.h gdb-4.11
move gdb-dis\gdb\typeprint.c gdb-4.11\typeprin.c
move gdb-dis\gdb\typeprint.h gdb-4.11\typeprin.h
move gdb-dis\gdb\utils.c gdb-4.11
move gdb-dis\gdb\valarith.c gdb-4.11
move gdb-dis\gdb\valops.c gdb-4.11
move gdb-dis\gdb\valprint.c gdb-4.11
move gdb-dis\gdb\valprint.h gdb-4.11
move gdb-dis\gdb\value.h gdb-4.11
move gdb-dis\gdb\values.c gdb-4.11
move gdb-dis\gdb\config\i386\tm-i386v.h gdb-4.11\config
move gdb-dis\gdb\config\i386\xm-i386v.h gdb-4.11\config
move gdb-dis\gdb\doc\refcard.tex gdb-4.11
move gdb-dis\gdb\doc\gdb.texinfo gdb-4.11\gdb.tex
move gdb-dis\gdb\doc\gdb-cfg.texi gdb-4.11\gdb-cfg.tex
move gdb-dis\gdb\doc\GDBvn.texi gdb-4.11\GDBvn.tex
move gdb-dis\gdb\doc\gdbint.texinfo gdb-4.11\gdbint.tex
move gdb-dis\gdb\doc\remote.texi gdb-4.11\remote.tex
move gdb-dis\gdb\doc\stabs.texinfo gdb-4.11\stabs.tex
move gdb-dis\glob\tilde.c glob
move gdb-dis\libiberty\argv.c libibert
move gdb-dis\libiberty\cplus-dem.c libibert\cplus-de.c
move gdb-dis\libiberty\ieee-float.c libibert\ieee-flo.c
move gdb-dis\libiberty\getopt.c libibert
move gdb-dis\libiberty\getopt1.c libibert
move gdb-dis\libiberty\insque.c libibert
move gdb-dis\libiberty\obstack.c libibert
move gdb-dis\libiberty\concat.c libibert
move gdb-dis\libiberty\basename.c libibert
move gdb-dis\libiberty\strsignal.c libibert\strsigna.c
copy patches\libibert.mak libibert\makefile
move gdb-dis\include\ansidecl.h include
move gdb-dis\include\demangle.h include
move gdb-dis\include\dis-asm.h include
move gdb-dis\include\ieee-float.h include\ieee-flo.h
move gdb-dis\include\obstack.h include
move gdb-dis\include\fopen-bin.h include\fopen-bi.h
move gdb-dis\include\getopt.h include
move gdb-dis\include\wait.h include
move gdb-dis\include\aout\ar.h include\aout
move gdb-dis\include\aout\aout64.h include\aout
move gdb-dis\include\aout\ranlib.h include\aout
move gdb-dis\include\aout\stab_gnu.h include\aout
move gdb-dis\include\aout\stab.def include\aout
move gdb-dis\include\coff\ecoff.h include\coff
move gdb-dis\include\coff\internal.h include\coff
move gdb-dis\include\coff\symconst.h include\coff
move gdb-dis\include\coff\rs6000.h include\coff
move gdb-dis\include\coff\sym.h include\coff
move gdb-dis\include\elf\common.h include\elf
move gdb-dis\include\elf\internal.h include\elf
move gdb-dis\include\elf\external.h include\elf
copy include\aout\stab.def include
move gdb-dis\opcodes\i386-dis.c gdb-4.11
move gdb-dis\readline\chardefs.h readline
move gdb-dis\readline\emacs_keymap.c readline\emacs_ke.c
move gdb-dis\readline\funmap.c readline
move gdb-dis\readline\history.c readline
move gdb-dis\readline\history.h readline
move gdb-dis\readline\keymaps.c readline
move gdb-dis\readline\keymaps.h readline
move gdb-dis\readline\makefile.in readline\makefile.in
move gdb-dis\readline\readline.c readline
move gdb-dis\readline\readline.h readline
move gdb-dis\readline\sysdep-norm.h readline\sysdep.h
move gdb-dis\readline\vi_keymap.c readline\vi_keyma.c
move gdb-dis\readline\vi_mode.c readline
move gdb-dis\readline\doc\rluser.texinfo readline\rluser.tex
move gdb-dis\readline\doc\inc-hist.texi readline\inc-hist.tex
if "%2"=="move" goto end
:config
sed -f patches\bfd.sed bfd\makefile.in >bfd\makefile
sed -e "s/@WORDSIZE@/32/" bfd\bfd-in2.h >bfd\bfd.h
sed -f patches\readline.sed readline\makefile.in >readline\makefile
sed -f patches\gdb-emx.sed gdb-4.11\makefile.in >gdb-4.11\makefile
copy patches\gdb-emx.nm gdb-4.11\nm.h
copy patches\gdb-emx.tm gdb-4.11\tm.h
copy patches\gdb-emx.xm gdb-4.11\xm.h
copy patches\emxchild.c gdb-4.11
copy patches\gdbrx.c gdb-4.11
copy patches\gdb-emx.ver gdb-4.11\version.c
touch gdb-4.11\config.sta
touch gdb-4.11\m2-exp.c
if "%2"=="config" goto end
:duel
if exist duel goto skip-duel
if exist duel-dis goto skip-duel
md duel-dis
md duel
cd duel-dis
gzip -cd<..\duel-1.10.4.tar.Z|tar xf -
cd ..
sed -f patches\duelemx1.sed duel-dis\src\makefile >duel\makefile
move duel-dis\src\duel.c duel
move duel-dis\src\eval.c duel
move duel-dis\src\misc.c duel
move duel-dis\src\parse.y duel
move duel-dis\src\error.c duel
move duel-dis\src\evalops.c duel
move duel-dis\src\print.c duel
move duel-dis\src\output.c duel
move duel-dis\src\types.c duel
move duel-dis\src\duel.h duel
move duel-dis\src\global.h duel
move duel-dis\src\proto.h duel
move duel-dis\src\patchlevel.h duel\patchlev.h
sed -f patches\duelemx2.sed duel-dis\duelgdb.c >duel\duelgdb.c
move duel-dis\duel.1 duel
move duel-dis\README duel
:skip-duel
if "%2"=="duel" goto end
:patch
if "%2"=="no-patch" goto end
setlocal
set tmp=
lwpatch -p0 <patches\gdb-emx.pat
endlocal
if "%2"=="patch" goto end
:end
