-src = $(wildcard src/*.c)\r
-obj = $(src:.c=.o)\r
-bin = rawdisktest\r
-\r
-CFLAGS = -pedantic -Wall -g\r
-LDFLAGS = -lsetupapi -luuid\r
-\r
-$(bin): $(obj)\r
- $(CC) -o $(bin) $(obj) $(LDFLAGS)\r
-\r
-.PHONY: clean\r
-clean:\r
- rm -f $(obj) $(bin)\r
+src = $(wildcard src/*.c)
+obj = $(src:.c=.o)
+bin = rawdisktest.exe
+
+CFLAGS = -pedantic -Wall -g
+LDFLAGS = -lsetupapi -luuid
+
+ifneq ($(shell uname -s | sed 's/MINGW.*/mingw/'), mingw)
+ CC = i686-w64-mingw32-gcc
+endif
+
+$(bin): $(obj)
+ $(CC) -o $(bin) $(obj) $(LDFLAGS)
+
+.PHONY: clean
+clean:
+ rm -f $(obj) $(bin)