-CPPDEPS = -MT$@ -MF`echo $@ | sed -e 's,\.o$$,.d,'` -MD
-RENDER_CXXFLAGS = -I. $(WX_CXXFLAGS) $(CPPFLAGS) $(CXXFLAGS)
+CPPDEPS = -MT$@ -MF`echo $@ | sed -e 's,\.o$$,.d,'` -MD -MP
+WX_VERSION_MAJOR = $(shell echo $(WX_VERSION) | cut -c1,1)
+WX_VERSION_MINOR = $(shell echo $(WX_VERSION) | cut -c2,2)
+WX_CONFIG_FLAGS = $(WX_CONFIG_DEBUG_FLAG) $(WX_CONFIG_UNICODE_FLAG) \
+ $(WX_CONFIG_SHARED_FLAG) --toolkit=$(WX_PORT) \
+ --version=$(WX_VERSION_MAJOR).$(WX_VERSION_MINOR)
+RENDER_CXXFLAGS = -I. `$(WX_CONFIG) --cxxflags $(WX_CONFIG_FLAGS)` $(CPPFLAGS) \
+ $(CXXFLAGS)