#
# 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 = /Od /Zi /W1 /nologo /FAsc /Fa$*.asm /Fd$*.pdb /MDd $<
LINKFLAGS = /link /subsystem:console /debug /pdb:none

# This special target is needed because exe is not a "known suffix" in Unix.
.SUFFIXES: .exe

# See Section 5.4.3 of "GNU Make Manual"
# 08 July 2002, GNU make Version 3.80.
all: $(patsubst %.c,%.exe,$(wildcard *.c))

# Use a simple suffix rule to compile any c file.
# See Section 11.7 of "GNU Make Manual"
# 08 July 2002, GNU make Version 3.80.
.c.exe:
	cmd.exe /c "C:\vcvars32.bat && $(CC) $(CFLAGS) $(LINKFLAGS)"

# delete only the files that we made
clean:
	cmd /c del $(patsubst %.c,%.obj,$(wildcard *.c))
	cmd /c del $(patsubst %.c,%.asm,$(wildcard *.c))
	cmd /c del $(patsubst %.c,%.pdb,$(wildcard *.c))
	cmd /c del $(patsubst %.c,%.exe,$(wildcard *.c))
