bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Check .exe as well when a target does not exist on OS/2


From: KO Myung-Hun
Subject: [PATCH] Check .exe as well when a target does not exist on OS/2
Date: Fri, 13 Jan 2023 22:27:43 +0900

For example,

foo: foo.c
    gcc $@ $<

This pattern is usually used on UNIX. However, on OS/2, gcc creates
foo.exe not foo when an extension is not present, and Make check foo
only. Therefore Make tries to build foo whenever called.

* src/remake.c (f_mtime) [EMX]: Check a target again by appending .exe.
---
 src/remake.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/remake.c b/src/remake.c
index 62b3d791..99285498 100644
--- a/src/remake.c
+++ b/src/remake.c
@@ -1409,6 +1409,12 @@ f_mtime (struct file *file, int search)
   else
 #endif
     {
+#ifdef __EMX__
+      const char *saved_name = file->name;
+      size_t fname_len;
+
+try_again_with_dot_exe:
+#endif
       mtime = name_mtime (file->name);
 
       if (mtime == NONEXISTENT_MTIME && search && !file->ignore_vpath)
@@ -1452,6 +1458,29 @@ f_mtime (struct file *file, int search)
                 mtime = name_mtime (name);
             }
         }
+#ifdef __EMX__
+      if (mtime == NONEXISTENT_MTIME)
+        {
+          if (stricmp (_getext2 (file->name), ".exe"))
+            {
+              fname_len = strlen (file->name);
+
+              file->name = alloca (fname_len + 4/*.exe*/ + 1);
+              memcpy ((char *)file->name, saved_name, fname_len);
+              memcpy ((char *)file->name + fname_len, ".exe", 4 + 1);
+
+              goto try_again_with_dot_exe;
+            }
+        }
+
+      fname_len = strlen (saved_name);
+
+      /* If found in VPATH, use it. Otherwise restore file->name. */
+      if (strlen (file->name) == fname_len + 4
+          && !strnicmp (file->name, saved_name, fname_len)
+          && !stricmp (file->name + fname_len, ".exe"))
+        file->name = saved_name;
+#endif
     }
 
   /* Files can have bogus timestamps that nothing newly made will be
-- 
2.30.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]