Index: goldencheetah/src/DataFilter.l
===================================================================
--- goldencheetah.orig/src/DataFilter.l
+++ goldencheetah/src/DataFilter.l
@@ -22,6 +22,17 @@
 // need to get rid of this and use a string...
 #include <stdio.h>
 
+#ifdef YY_FLEX_SUBMINOR_VERSION
+# define YY_FLEX_VERSION               \
+  (YY_FLEX_MAJOR_VERSION) * 1000000 \
++ (YY_FLEX_MINOR_VERSION) * 1000    \
++ (YY_FLEX_SUBMINOR_VERSION)
+#else
+# define YY_FLEX_VERSION               \
+  (YY_FLEX_MAJOR_VERSION) * 1000000 \
++ (YY_FLEX_MINOR_VERSION) * 1000
+#endif
+
 // tokens
 #include "DataFilter_yacc.h"/* generated by the scanner */
 
@@ -100,7 +111,7 @@ int DataFiltercolumn = 1;
 
 // Older versions of flex (prior to 2.5.9) do not have the destroy function
 // Or We're not using GNU flex then we also won't have a destroy function
-#if !defined(FLEX_SCANNER) || (YY_FLEX_SUBMINOR_VERSION < 9)
+#if !defined(FLEX_SCANNER) || (YY_FLEX_VERSION < 2005009)
 int DataFilterlex_destroy(void) { return 0; }
 #endif
 
Index: goldencheetah/src/JsonRideFile.l
===================================================================
--- goldencheetah.orig/src/JsonRideFile.l
+++ goldencheetah/src/JsonRideFile.l
@@ -161,7 +161,7 @@ void JsonRideFilefree (void * ptr , yysc
 
 // Older versions of flex (prior to 2.5.9) do not have the destroy function
 // Or We're not using GNU flex then we also won't have a destroy function
-#if !defined(FLEX_SCANNER) || (YY_FLEX_SUBMINOR_VERSION < 9)
+#if !defined(FLEX_SCANNER) || (YY_FLEX_MINOR_VERSION < 6 && YY_FLEX_SUBMINOR_VERSION < 9)
 int JsonRideFilelex_destroy(void*) { return 0; }
 #endif
 
Index: goldencheetah/src/RideDB.l
===================================================================
--- goldencheetah.orig/src/RideDB.l
+++ goldencheetah/src/RideDB.l
@@ -114,7 +114,7 @@ void RideDBfree (void * ptr , yyscan_t /
 
 // Older versions of flex (prior to 2.5.9) do not have the destroy function
 // Or We're not using GNU flex then we also won't have a destroy function
-#if !defined(FLEX_SCANNER) || (YY_FLEX_SUBMINOR_VERSION < 9)
+#if !defined(FLEX_SCANNER) || (YY_FLEX_MINOR_VERSION < 6 && YY_FLEX_SUBMINOR_VERSION < 9)
 int RideDBlex_destroy(void*) { return 0; }
 #endif
 
