more msvc trash in .gitignore
[miniglut] / Makefile
index 79c0895..accf05a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,12 +2,32 @@ src = miniglut.c test.c
 obj = $(src:.c=.o)
 bin = test
 
-CFLAGS = -pedantic -Wall -g -DMINIGLUT_USE_LIBC
-LDFLAGS = -lX11 -lGL -lm
+CFLAGS = -pedantic -Wall -g
+
+sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/')
+ifeq ($(sys), mingw)
+       obj = $(src:.c=.w32.o)
+       bin = test.exe
+
+       LDFLAGS = -mconsole -lopengl32 -lgdi32 -lwinmm
+else
+       LDFLAGS = -lX11 -lGL
+endif
 
 $(bin): $(obj)
        $(CC) -o $@ $(obj) $(LDFLAGS)
 
+%.w32.o: %.c
+       $(CC) -o $@ $(CFLAGS) -c $<
+
 .PHONY: clean
 clean:
        rm -f $(obj) $(bin)
+
+.PHONY: cross
+cross:
+       $(MAKE) CC=i686-w64-mingw32-gcc sys=mingw
+
+.PHONY: cross-clean
+cross-clean:
+       $(MAKE) CC=i686-w64-mingw32-gcc sys=mingw clean