#
# Use this makefile with the command
#   c:\mingw\bin\mingw32-make
#
# This GNU makefile assumes that the file C:\vcvars32.bat exits
#
CC = cl
CFLAGS = /c /Od /Zi /W1 /nologo /FAsc /Fa$*.asm /Fd$*.pdb /MDd $<
LINK = link
LINKFLAGS = /nologo /subsystem:console /debug /pdb:none

# This special target is needed because obj is not a "known suffix" in Unix.
.SUFFIXES: .obj

EXECUTABLES = calling-conventions.exe \
              parameter-passing-a.exe \
              test-stack-frame.exe \
              calling-conventions2a.exe

all = $(EXECUTABLES)

calling-conventions.exe: calling-conventions.obj
	cmd.exe /c "C:\vcvars32.bat && $(LINK) $(LINKFLAGS) $<"

parameter-passing-a.exe: parameter-passing-a.obj \
                         parameter-passing-b.obj
	cmd.exe /c "C:\vcvars32.bat && $(LINK) $(LINKFLAGS) $^"

test-stack-frame.exe: test-stack-frame.obj
	cmd.exe /c "C:\vcvars32.bat && $(LINK) $(LINKFLAGS) $<"

calling-conventions2a.exe: calling-conventions2a.obj \
                           calling-conventions2b.obj
	cmd.exe /c "C:\vcvars32.bat && $(LINK) $(LINKFLAGS) $^"

# Use a simple suffix rule to make the obj files.
# See Section 11.7 of "GNU Make Manual"
# 08 July 2002, GNU make Version 3.80.
.c.obj:
	cmd.exe /c "C:\vcvars32.bat && $(CC) $(CFLAGS)"

# delete only the files that we made
clean:
	cmd /c del calling-conventions??.obj
	cmd /c del calling-conventions??.asm
	cmd /c del calling-conventions??.pdb
	cmd /c del parameter-passing-?.obj
	cmd /c del parameter-passing-?.asm
	cmd /c del parameter-passing-?.pdb
	cmd /c del test-stack-frame.obj
	cmd /c del test-stack-frame.asm
	cmd /c del test-stack-frame.pdb
	cmd /c del $(EXECUTABLES)
