-CPPFLAGS = $(XINCLUDE) $(INC) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRACPPFLAGS) $(EXTRADLLFLAGS)
-CFLAGS = $(XINCLUDE) $(INC) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRACFLAGS) -DWIN32_LEAN_AND_MEAN
-WINDOWSLDFLAGS=-Wl,--subsystem,windows -mwindows
-LDFLAGS = $(WINDOWSLDFLAGS) -L$(WXDIR)/lib $(EXTRALDFLAGS)
+CPPFLAGS = $(XINCLUDE) $(INC) $(COMMON_THREADFLAGS) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRACPPFLAGS) $(EXTRADLLFLAGS)
+CFLAGS = $(XINCLUDE) $(INC) $(COMMON_THREADFLAGS) $(OPTIONS) $(GUI) $(DEBUGFLAGS) $(WARN) $(OPT) $(EXTRACFLAGS) -DWIN32_LEAN_AND_MEAN
+ifeq ($(wxUSE_GUI),1)
+ WINDOWSLDFLAGS=-Wl,--subsystem,windows -mwindows
+endif
+LDFLAGS = $(WINDOWSLDFLAGS) $(COMMON_THREADFLAGS) -L$(WXDIR)/lib -L$(WXDIR)/contrib/lib $(EXTRALDFLAGS)
+
+.SUFFIXES: .rc .$(RESSUFF) .$(RSCSUFF) .cpp .cxx .cc .c
+
+.c.o:
+ $(CC) -c $(CFLAGS) -o $@ $*.c
+
+.cc.o:
+ $(CC) -c $(CPPFLAGS) -o $@ $*.cc