#
# Use this makefile with the command
#   C:\mingw\bin\mingw32-make.exe
#
CC = C:\MinGW\bin\gcc
CPP = C:\MinGW\bin\g++
CFLAGS = -g -Wall -fverbose-asm -Wa,-a,-adhlns=$*.asm
CPPFLAGS = -g -Wall -fverbose-asm -Wa,-a,-adhlns=$*.asm

# 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)) $(patsubst %.cpp,%.exe,$(wildcard *.cpp))

# Use simple suffix rules to build all c and cpp files.
# See Section 11.7 of "GNU Make Manual"
# 08 July 2002, GNU make Version 3.80.
.c.exe:
	$(CC) $(CFLAGS) -o $@ $< pthread.lib
.cpp.exe:
	$(CPP) $(CPPFLAGS) -o $@ $< pthread.lib

# delete only the files that we made
clean:
	rm -fv $(patsubst %.c,%.exe,$(wildcard *.c))
	rm -fv $(patsubst %.c,%.asm,$(wildcard *.c))
	rm -fv $(patsubst %.cpp,%.exe,$(wildcard *.cpp))
	rm -fv $(patsubst %.cpp,%.asm,$(wildcard *.cpp))
