-
-# Change this to -DWIN32 for Windows :-)
-CFLAGS = -g -I. -D__GCCUNIX__
-#CFLAGS = -g -I. -DWIN32
-
+#
+# Figure out which system we're compiling for, and set the appropriate
+# variables
+#
+SYSTYPE := __GCCUNIX__
+
+ifneq "$(CROSS)" ""
+SYSTYPE := WIN32
+else
+OSTYPE := $(shell uname -o)
+ifeq "$(findstring Msys,$(OSTYPE))" "Msys"
+SYSTYPE := WIN32
+endif
+endif
+
+CFLAGS = -g -I. -D$(SYSTYPE) -O2