-CXXFLAGS = -ansi -pedantic -Wall $(opt) -Isrc/3dengfx/src -MMD `sdl-config --cflags`
-CFLAGS = -std=c89 -pedantic -Wall $(opt) -MMD `sdl-config --cflags`
-libs = src/3dengfx/lib3dengfx.a `sdl-config --libs` -lGL -lvorbisfile -ljpeg -lpng -lz
+incdir = -Isrc/3dengfx/src -Ilibs -Ilibs/png -Ilibs/jpeglib -Ilibs/ogg -Ilibs/vorbis
+CXXFLAGS = -ansi -pedantic -Wall $(opt) $(incdir) -MMD `sdl-config --cflags`
+CFLAGS = -std=c89 -pedantic -Wall $(opt) $(incdir) -MMD `sdl-config --cflags`
+libs = $(libdir) $(libsys) src/3dengfx/lib3dengfx.a `sdl-config --libs` $(libgl) \
+ -lvorbis -logg -ljpeg -lpng -lz -l3ds $(libc)
+
+sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/')
+ifeq ($(sys), mingw)
+ obj = $(src:.cpp=.w32.o) $(csrc:.c=.w32.o)
+ bin = sumhack-thelab.exe
+ libdir = -Llibs/w32
+ libgl = -lopengl32
+ libsys = -lmingw32 -lgdi32 -mconsole
+ libc = -lm
+
+else
+ libdir = -Llibs
+ libgl = -lGL
+ libc = -lm
+endif
+