####################### GENERAL SETTINGS ############################
-
-EXTRALIBS = @EXTRA_LIBS@
-LDLIBS = ${top_builddir}/lib/@WX_TARGET_LIBRARY@ $(EXTRA_LIBS)
+# see comment near LDFLAGS at the end of file
+EXTRALIBS = @LDFLAGS@ @EXTRA_LIBS@
+OPENGLLIBS = @OPENGL_LIBS@
+LDLIBS = $(APPEXTRALIBS) ${top_builddir}/lib/@WX_TARGET_LIBRARY@ $(EXTRALIBS)
TOOLKIT = @TOOLKIT@
TOOLKITDIR = @TOOLKIT_DIR@
WXLIB = @WX_LIBRARY_NAME_STATIC@
WXSHLIB = @WX_LIBRARY_NAME_SHARED@
+EXTRADEFS="-DwxINSTALL_PREFIX=\"@prefix@\""
+
########################### VERSION #################################
WX_MAJOR_VERSION_NUMBER = @WX_MAJOR_VERSION_NUMBER@
SHARED_LD = @SHARED_LD@
+RESFLAGS = @RESFLAGS@
+RESCOMP = @RESCOMP@
+REZ = @REZ@
+REZFLAGS = @REZFLAGS@
+DEREZ = @DEREZ@
+DEREZFLAGS = @DEREZFLAGS@
+DLLTOOL = @DLLTOOL@
+
########################### Flags #################################
-CFLAGS = @TOOLKIT_DEF@ @WXDEBUG_DEFINE@ @CFLAGS@
-CPPFLAGS = @TOOLKIT_DEF@ @WXDEBUG_DEFINE@ @CXXFLAGS@ @CPPFLAGS@
+#
+# CPPFLAGS (gnu standard) is not C++ flags, but flags for the "cpp"
+# preprocessor. Unfortunately whoever wrote this now uses CPPFLAGS for
+# C++ like CFLAGS for C. :-(
+# We *must* include CPPFLAGS in both of these, to make sure that all
+# header files get found. (KB)
+
+CFLAGS = $(APPEXTRACFLAGS) $(APPEXTRACPPFLAGS) @TOOLKIT_DEF@ @CODE_GEN_FLAGS@ @WXDEBUG_DEFINE@ @CFLAGS@ @CPPFLAGS@ @CODE_GEN_FLAGS@
+CPPFLAGS = $(APPEXTRACXXFLAGS) $(APPEXTRACPPFLAGS) @TOOLKIT_DEF@ @CODE_GEN_FLAGS@ @WXDEBUG_DEFINE@ @CXXFLAGS@ @CPPFLAGS@ @CODE_GEN_FLAGS_CXX@
PICFLAGS = @PIC_FLAG@
-LDFLAGS = @LDFLAGS@
+# taking into account how SHARED_LD is defined, appending LDFLAGS to it
+# doesn't work, so we put them in the end of the linker command line in
+# EXTRALIBS instead (see above)
+# LDFLAGS = @LDFLAGS@