-CXXFLAGS = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui -I$(QTDIR)/include/QtWidgets
-QTLDLIBS = -L$(QTDIR)/lib -lQt5Core -lQt5Gui -lQt5Widgets
-MOC = $(QTDIR)/bin/moc
-LUAPLATFORM = mingw
+ 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