#
# Use this makefile with the command
#   c:\mingw\bin\mingw32-make -f makefile-gcc
#
CC = c:\mingw\bin\gcc
CFLAGS = -c -g -Wall -fverbose-asm -Wa,-a,-adhlns=$*.asm

# This special target is needed because obj is not a "known suffix" in Unix.
.SUFFIXES: .obj

EXECUTABLES = calling-conventions.exe \
              calling-conventions2a.exe \
              parameter-passing-a.exe \
              test-stack-frame.exe

all = $(EXECUTABLES)

calling-conventions.exe: calling-conventions.obj
	$(CC) -o $@ $<

calling-conventions2a.exe: calling-conventions2a.obj \
                           calling-conventions2b.obj
	$(CC) -o $@ $^

parameter-passing-a.exe: parameter-passing-a.obj \
                         parameter-passing-b.obj
	$(CC) -o $@ $^

test-stack-frame.exe: test-stack-frame.obj
	$(CC) -o $@ $<

# 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:
	$(CC) $(CFLAGS) -o $@ $<

# delete only the files that we made
clean:
	cmd /c del calling-conventions??.obj
	cmd /c del calling-conventions??.asm
	cmd /c del parameter-passing-?.obj
	cmd /c del parameter-passing-?.asm
	cmd /c del test-stack-frame.obj
	cmd /c del test-stack-frame.asm
	cmd /c del $(EXECUTABLES)
