From 10fc0646fb8996c6e434bc833d191f600bd8a321 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@Germany>
Date: Thu, 9 Mar 2017 11:48:52 +0100
Subject: [PATCH] BUG: 'make clean' failed for wmake/src

- caused by the typo '@E' instead of '$E' (commit 997f1713cbd4cb23)

ENH: minor improvements for wmake/src makefile

- 'make clean' now also tries to remove the parent platforms/
  directory if possible.

- the flex intermediate build target is placed into the platforms/
  directory to avoid touching the src/ directory at all.

- suppress warnings about unused functions (GCC only)
---
 wmake/src/Makefile | 20 ++++++++++++--------
 wmake/src/wmkdep.l | 17 +++++++++--------
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/wmake/src/Makefile b/wmake/src/Makefile
index 9ced8251c99..cc679c9482a 100644
--- a/wmake/src/Makefile
+++ b/wmake/src/Makefile
@@ -1,4 +1,4 @@
-#------------------------------------------------------------------------------
+#----------------------------*- makefile-gmake -*------------------------------
 # =========                 |
 # \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 #  \\    /   O peration     |
@@ -57,22 +57,26 @@ include $(GENERAL_RULES)/general
 # Targets
 #------------------------------------------------------------------------------
 
+.PHONY: all clean
+
 all:  $(WMAKE_BIN)/dirToString $(WMAKE_BIN)/wmkdep
+	@echo built wmake-bin for $(WM_ARCH)$(WM_COMPILER)
 
 clean:
-	@E rm -f $(WMAKE_BIN)/* 2>/dev/null
+	@echo clean wmake-bin for $(WM_ARCH)$(WM_COMPILER)
+	@rm -rf $(WMAKE_BIN) 2>/dev/null
+	@rmdir $(shell dirname $(WMAKE_BIN)) 2>/dev/null || true
 
 $(WMAKE_BIN)/dirToString: dirToString.c
 	@mkdir -p $(WMAKE_BIN)
-	$(call QUIET_MESSAGE,compile,$<)
-	$E $(cc) $(cFLAGS) dirToString.c -o $(WMAKE_BIN)/dirToString
+	$(call QUIET_MESSAGE,compile,$(<F))
+	$E $(cc) $(cFLAGS) $(<F) -o $@
 
 $(WMAKE_BIN)/wmkdep: wmkdep.l
 	@mkdir -p $(WMAKE_BIN)
-	$(call QUIET_MESSAGE,lex,$<)
-	$E flex wmkdep.l; \
-	$(cc) $(cFLAGS) lex.yy.c -o $(WMAKE_BIN)/wmkdep
-	@rm -f lex.yy.c 2>/dev/null
+	$(call QUIET_MESSAGE,flex,$(<F))
+	$E flex -o $@.c $(<F) && $(cc) $(cFLAGS) $@.c -o $@
+	@rm -f $@.c 2>/dev/null
 
 
 #------------------------------------------------------------------------------
diff --git a/wmake/src/wmkdep.l b/wmake/src/wmkdep.l
index d1a7805621f..6e198bab4c2 100644
--- a/wmake/src/wmkdep.l
+++ b/wmake/src/wmkdep.l
@@ -46,19 +46,18 @@ Usage
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>  // POSIX
-#include <dirent.h>     // POSIX
-
-void nextFile(const char* fileName);
-void importFile(const char* fileName);
-void importDir(const char* dirName);
-
-#undef yywrap        /* sometimes a macro by default */
+#include <sys/types.h>  /* POSIX */
+#include <dirent.h>     /* POSIX */
 
 /* The executable name (for messages), without requiring access to argv[] */
 #define EXENAME  "wmkdep"
+#undef yywrap        /* sometimes a macro by default */
+#define YY_NO_INPUT  /* no input(), yyinput() required */
+#pragma GCC diagnostic ignored "-Wunused-function"
 
+void nextFile(const char* fileName);
 
+/*---------------------------------------------------------------------------*/
 %}
 
 %x CMNT CFNAME SCFNAME JFNAME FFNAME
@@ -80,6 +79,8 @@ void importDir(const char* dirName);
 
 %%
 
+/*---------------------------------------------------------------------------*/
+
 
 /* char* entry in hash table */
 struct HashEntry
-- 
GitLab