HOST = i486-linux
CPU = i386
GCC = gcc
GCCFLAGS = -O2 -fomit-frame-pointer -DHAVE_LONGLONG -DREENTRANT
LN = ln -s
RM = rm -f
SED = sed
ROFF_MAN = groff -Tascii -mandoc

all : vacall-i386.S vacall-i386-msvc.c vacall-m68k.mit.S vacall-m68k.mot.s vacall-mips.S vacall-mipsn32.S vacall-mips64.S vacall-sparc.S vacall-sparc64.S vacall-alpha.s vacall-hppa.s vacall-arm.S vacall-rs6000-aix.old.s vacall-rs6000-aix.new.s vacall-rs6000-sysv4.s vacall-m88k.s vacall-convex.s vacall-ia64.s \
      vacall_r.h.msvc config.h.msvc

vacall-i386.S : vacall-i386.c vacall_r.h.in asmi386.sh
	$(GCC) -V 2.7.2 -b i486-linuxaout $(GCCFLAGS) -D__i386__ -S vacall-i386.c -o vacall-i386.s
	(echo '#include "asmi386.h"' ; sed -e '/\.align.*,0x90$$/d' < vacall-i386.s | ./asmi386.sh) > vacall-i386.S
	$(RM) vacall-i386.s

vacall-i386-msvc.c : vacall-i386.S
	(echo '#ifdef _MSC_VER' ; echo '#include "vacall_r.h"' ; echo '#endif' ; cat vacall-i386.S) > vacall-i386-msvc.c

vacall-m68k.mit.S : vacall-m68k.c vacall_r.h.in asmm68k.sh
	$(GCC) -V 2.95.2 -b m68k-sun $(GCCFLAGS) -D__m68k__ -S vacall-m68k.c -o vacall-m68k.mit.s
	(echo '#include "asmm68k.h"' ; ./asmm68k.sh < vacall-m68k.mit.s) > vacall-m68k.mit.S
	$(RM) vacall-m68k.mit.s

vacall-m68k.mot.s : vacall-m68k.c vacall_r.h.in
	$(GCC) -V 2.95.2 -b m68k-linux $(GCCFLAGS) -D__m68k__ -S vacall-m68k.c -o vacall-m68k.mot.s

vacall-mips.S : vacall-mips.c vacall_r.h.in asmmips.sh
	$(GCC) -V 2.95.2 -b mips-sgi $(GCCFLAGS) -D__mips__ -fno-omit-frame-pointer -S vacall-mips.c -o vacall-mips.s
	(echo '#include "asmmips.h"' ; ./asmmips.sh < vacall-mips.s) > vacall-mips.S
	$(RM) vacall-mips.s

vacall-mipsn32.S : vacall-mipsn32.c vacall_r.h.in asmmips.sh
	$(GCC) -V 2.95.2 -b mips-sgi-irix6 $(GCCFLAGS) -D__mipsn32__ -S vacall-mipsn32.c -o vacall-mipsn32.s
	(echo '#include "asmmips.h"' ; $(SED) -e 's/\$$sp,\$$sp,192/$$sp,$$sp,256/' -e 's/\$$sp,192,/$$sp,256,/' < vacall-mipsn32.s | ./asmmips.sh) > vacall-mipsn32.S
	$(RM) vacall-mipsn32.s

vacall-mips64.S : vacall-mips64.c vacall_r.h.in asmmips.sh
	$(GCC) -V 2.95.2 -b mips-sgi -mips3 -mlong64 $(GCCFLAGS) -U__mips__ -D__mips64__ -S vacall-mips64.c -o vacall-mips64.s
	(echo '#include "asmmips.h"' ; ./asmmips.sh < vacall-mips64.s) > vacall-mips64.S
	$(RM) vacall-mips64.s

vacall-sparc.S : vacall-sparc.c vacall_r.h.in asmsparc.sh
	$(GCC) -V 2.95.2 -b sparc-sun $(GCCFLAGS) -D__sparc__ -S vacall-sparc.c -o vacall-sparc.s
	(echo '#include "asmsparc.h"' ; ./asmsparc.sh < vacall-sparc.s) > vacall-sparc.S
	$(RM) vacall-sparc.s

vacall-sparc64.S : vacall-sparc64.c vacall_r.h.in asmsparc.sh
	sparc64-linux-gcc -V 2.95.2 -b sparc64-linux $(GCCFLAGS) -D__sparc64__ -S vacall-sparc64.c -o vacall-sparc64.s
	(echo '#include "asmsparc.h"' ; ./asmsparc64.sh < vacall-sparc64.s) > vacall-sparc64.S
	$(RM) vacall-sparc64.s

vacall-alpha.s : vacall-alpha.c vacall_r.h.in
	$(GCC) -V 2.7.2 -b alpha-dec-osf $(GCCFLAGS) -D__alpha__ -S vacall-alpha.c -o vacall-alpha-temp.s
	$(SED) -e '/ldgp/d' < vacall-alpha-temp.s > vacall-alpha.s
	$(RM) vacall-alpha-temp.s

vacall-hppa.s : vacall-hppa.c vacall_r.h.in
	$(GCC) -V 2.6.3 -b hppa1.0-hpux $(GCCFLAGS) -D__hppa__ -S vacall-hppa.c -o vacall-hppa.s

vacall-arm.S : vacall-arm.c vacall_r.h.in asmarm.sh
	$(GCC) -V 2.6.3 -b arm-acorn-riscix $(GCCFLAGS) -D__arm__ -S vacall-arm.c -o vacall-arm.s
	(echo '#include "asmarm.h"' ; ./asmarm.sh < vacall-arm.s) > vacall-arm.S
	$(RM) vacall-arm.s

vacall-rs6000-aix.old.s : vacall-rs6000.c vacall_r.h.in
	$(GCC) -V 2.95.2 -b rs6000 -mno-power -mno-power2 -mno-powerpc -mold-mnemonics $(GCCFLAGS) -D__rs6000__ -S vacall-rs6000.c -o vacall-rs6000-aix.old.s

vacall-rs6000-aix.new.s : vacall-rs6000.c vacall_r.h.in
	$(GCC) -V 2.95.2 -b rs6000 -mno-power -mno-power2 -mno-powerpc -mnew-mnemonics $(GCCFLAGS) -D__rs6000__ -S vacall-rs6000.c -o vacall-rs6000-aix.new.s

vacall-rs6000-sysv4.s : vacall-rs6000.c vacall_r.h.in
	$(GCC) -V 2.95.2 -b ppc-linux -mno-power -mno-power2 -mno-powerpc $(GCCFLAGS) -D__rs6000__ -S vacall-rs6000.c -o vacall-rs6000-sysv4.s

vacall-m88k.s : vacall-m88k.c vacall_r.h.in
	$(GCC) -V 2.95.2 -b m88k-dgux $(GCCFLAGS) -D__m88k__ -S vacall-m88k.c -o vacall-m88k.s

vacall-convex.s : vacall-convex.c vacall_r.h.in
	$(GCC) -V 2.6.3 -b convex-c2 $(GCCFLAGS) -D__convex__ -S vacall-convex.c -o vacall-convex.s

vacall-ia64.s : vacall-ia64.c vacall_r.h.in
	$(GCC) -V 2.9-ia64-000216 -b ia64-hp-linux $(GCCFLAGS) -D__ia64__ -S vacall-ia64.c -o vacall-ia64.s

vacall_r.man : vacall_r.3
	$(ROFF_MAN) vacall_r.3 > vacall_r.man

vacall_r.h.msvc : vacall_r.h.in
	sed -e 's,^#undef __i386__$$,#define __i386__ 1,' -e 's,^#undef __SMALL_STRUCT_RETURN__$$,#define __SMALL_STRUCT_RETURN__ 1,' < vacall_r.h.in > vacall_r.h.msvc

config.h.msvc : config.h.in
	sed -e 's,^#undef RETABORTTYPE$$,#define RETABORTTYPE void,' < config.h.in > config.h.msvc


