-CFLAGS = -I. -I/opt/local/include -Wall -Wno-unused-function $(COMMON_FLAGS)
-
-WINLIBS = -lgdi32 -lsetupapi
-CXXFLAGS = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null) -Wall
-QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
-
-ifeq ($(shell uname),Darwin)
-CXXFLAGS += -arch i386 -DQ_WS_MAC32
-CFLAGS += -arch i386
-QTLDLIBS += -arch i386
+CFLAGS = -std=c99 -I. -I../include -I../common -I/opt/local/include -I../liblua -Wall $(COMMON_FLAGS) -g -O4
+LUAPLATFORM = generic
+
+ifneq (,$(findstring MINGW,$(platform)))
+ CXXFLAGS = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui
+ MOC = $(QTDIR)/bin/moc
+ LUAPLATFORM = mingw
+ ifneq ($(wildcard $(QTDIR)/include/QtWidgets),)
+ CXXFLAGS += -I$(QTDIR)/include/QtWidgets
+ QTLDLIBS = -L$(QTDIR)/lib -lQt5Core -lQt5Gui -lQt5Widgets
+ else
+ QTLDLIBS = -L$(QTDIR)/lib -lQtCore4 -lQtGui4
+ endif
+else ifeq ($(platform),Darwin)
+ CXXFLAGS = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null) -Wall -O4
+ QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
+ MOC = $(shell pkg-config --variable=moc_location QtCore)
+ LUAPLATFORM = macosx
+else
+ CXXFLAGS = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null) -Wall -O4
+ QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
+ MOC = $(shell pkg-config --variable=moc_location QtCore)
+ LDLIBS += -ldl
+ # Below is a variant you can use if you have problems compiling with QT5 on ubuntu. see http://www.proxmark.org/forum/viewtopic.php?id=1661 for more info.
+ #MOC = /usr/lib/x86_64-linux-gnu/qt4/bin/moc
+ LUAPLATFORM = linux