From eaa65913f4ea447664d51d8d6f72cb9521b35901 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Wed, 19 Mar 2025 08:39:47 +0100
Subject: [PATCH] CONFIG: combine flex/flex++ rules (minor cleanup)

- generate .cc (instead of .C) intermediate files, consistent with how
  we manage other generated code and makes them less case sensitive
---
 wmake/rules/General/bison    |  8 ++++++--
 wmake/rules/General/flex     | 19 ++++++++++++++++++-
 wmake/rules/General/flex++   | 11 -----------
 wmake/rules/General/lemon    |  3 +++
 wmake/rules/General/standard |  1 -
 5 files changed, 27 insertions(+), 15 deletions(-)
 delete mode 100644 wmake/rules/General/flex++

diff --git a/wmake/rules/General/bison b/wmake/rules/General/bison
index 21aab6a4af0..cc9fedb837a 100644
--- a/wmake/rules/General/bison
+++ b/wmake/rules/General/bison
@@ -1,17 +1,21 @@
+#------------------------------------------------------------------------------
 SUFFIXES += .Y .y .yy .yy-m4
 
+# Bison, compile with C
 ytoo = $E $(call QUIET_MESSAGE,bison,$(<F)) \
     bison -v -d -y $< && \
     mv y.tab.c $(@D)/$(<F).c && \
     mv y.tab.h $(@D)/$(<F).h && \
     $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $(@D)/$(<F).c -o $@
 
+# Bison, compile with C++
 Ytoo = $E $(call QUIET_MESSAGE,bison,$(<F)) \
     bison -v -d -y $< && \
-    mv y.tab.c $(@D)/$(<F).C && \
+    mv y.tab.c $(@D)/$(<F).cc && \
     mv y.tab.h $(@D)/$(<F).H && \
-    $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $(@D)/$(<F).C -o $@
+    $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $(@D)/$(<F).cc -o $@
 
+# Bison via wrapper, compile with C++
 yytoo = $E $(call QUIET_MESSAGE,bison,$(<F)) \
     $(WM_SCRIPTS)/wrap-bison -output=$(@D)/$(*F).tab.cc -v -d $< && \
     $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $(@D)/$(*F).tab.cc -o $@
diff --git a/wmake/rules/General/flex b/wmake/rules/General/flex
index afff022c5ab..f84955f8ec3 100644
--- a/wmake/rules/General/flex
+++ b/wmake/rules/General/flex
@@ -1,5 +1,22 @@
-SUFFIXES += .l
+#------------------------------------------------------------------------------
+SUFFIXES += .L .l .ll
 
+# Regular flex, compile with C
 ltoo = $E $(call QUIET_MESSAGE,flex,$(<F)) \
     flex -f -o $(@D)/$(<F).c $< && \
     $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $(@D)/$(<F).c -o $@
+
+## # Regular flex, compile with C++
+## ll-cctoo = $E $(call QUIET_MESSAGE,flex,$(<F)) \
+##     flex -f -o $(@D)/$(<F).cc $< && \
+##     $(WM_SCHEDULER) $(CC) $(c++FLAGS) $(c++LESSWARN) -c $(@D)/$(<F).cc -o $@
+
+# C++-aware flex, compile with C++
+lltoo = $E $(call QUIET_MESSAGE,flex++,$(<F)) \
+    flex -+ -f -o $(@D)/$(<F).cc $< && \
+    $(WM_SCHEDULER) $(CC) $(c++FLAGS) $(c++LESSWARN) -c $(@D)/$(<F).cc -o $@
+
+# C++-aware flex, compile with C++
+Ltoo  = $(lltoo)
+
+#------------------------------------------------------------------------------
diff --git a/wmake/rules/General/flex++ b/wmake/rules/General/flex++
deleted file mode 100644
index f5484188ede..00000000000
--- a/wmake/rules/General/flex++
+++ /dev/null
@@ -1,11 +0,0 @@
-SUFFIXES += .L .ll
-
-# Use C++-aware Flex
-Ltoo = $E $(call QUIET_MESSAGE,flex++,$(<F)) \
-    flex -+ -f -o $(@D)/$(<F).C $< && \
-    $(WM_SCHEDULER) $(CC) $(c++FLAGS) $(c++LESSWARN) -c $(@D)/$(<F).C -o $@
-
-# Use regular (C) Flex, but compile result as C++
-lltoo = $E $(call QUIET_MESSAGE,flex,$(<F)) \
-    flex -f -o $(@D)/$(<F).cc $< && \
-    $(WM_SCHEDULER) $(CC) $(c++FLAGS) $(c++LESSWARN) -c $(@D)/$(<F).cc -o $@
diff --git a/wmake/rules/General/lemon b/wmake/rules/General/lemon
index 8f4e944506c..aa243f9e206 100644
--- a/wmake/rules/General/lemon
+++ b/wmake/rules/General/lemon
@@ -1,9 +1,12 @@
+#------------------------------------------------------------------------------
 SUFFIXES += .ly .lyy .lyy-m4
 
+# Lemon via wrapper, compile with C
 lytoo = $E $(call QUIET_MESSAGE,lemon,$(<F)) \
     $(WM_SCRIPTS)/wrap-lemon -d$(@D) $< && \
     $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $(@D)/$(*F).c -o $@
 
+# Lemon via wrapper, compile with C++
 lyytoo = $E $(call QUIET_MESSAGE,lemon,$(<F)) \
     $(WM_SCRIPTS)/wrap-lemon -d$(@D) -ecc $< && \
     $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $(@D)/$(*F).cc -o $@
diff --git a/wmake/rules/General/standard b/wmake/rules/General/standard
index 083190c91f5..f964b35ccd3 100644
--- a/wmake/rules/General/standard
+++ b/wmake/rules/General/standard
@@ -4,7 +4,6 @@ SUFFIXES=
 
 include $(GENERAL_RULES)/version
 include $(GENERAL_RULES)/flex
-include $(GENERAL_RULES)/flex++
 ## include $(GENERAL_RULES)/byacc
 ## include $(GENERAL_RULES)/btyacc++
 include $(GENERAL_RULES)/bison
-- 
GitLab