{"thread":{"id":"15023","subject":"[PATCH] Makefile: building git in cygwin 1.7.0","startedAt":"2008-08-15T15:01:03Z","lastAt":"2008-08-15T15:01:03Z","messageCount":1,"participants":["Eric Blake"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"87315","messageId":"loom.20080815T143926-715@post.gmane.org","threadId":"15023","inReplyTo":null,"subject":"[PATCH] Makefile: building git in cygwin 1.7.0","fromName":"Eric Blake","fromEmail":"ebb9@byu.net","sentAt":"2008-08-15T15:01:03Z","receivedAt":"2008-08-15T15:01:03Z","isPatch":true,"sender":{"key":"eblake@redhat.com","avatar":"https://avatars.githubusercontent.com/u/32933908?v=4"},"body":"On platforms with $X, make removes any leftover scripts 'a' from\nearlier builds if a new binary 'a.exe' is now built.  However, on\ncygwin 1.7.0, 'git' and 'git.exe' now consistently name the same file.\nTest for file equality before attempting a remove, in order to avoid\nnuking just-built binaries.\n\nSigned-off-by: Eric Blake <ebb9@byu.net>\n---\n\nOn cygwin 1.5.x, a script 'a' and binary 'a.exe' could co-exist in the same \ndirectory, and exec'ing 'a' tended to favor the script over the binary - \nproblematic for the case where incremental building in an existing git checkout \npicks up a switch from a script to a builtin.  Likewise, 'rm -f a' refused to \nremove 'a.exe', so it was a no-op if there was no script 'a', hence the \naddition of a $X-specific rule to nuke those stale scripts.\n\nBut the .exe handling will change in cygwin 1.7.0 (to be released later this \nyear), where it is much harder to create 'a' and 'a.exe' as distinct files ('a' \nis automatically removed if 'a.exe' is created); and 'rm -f a' now succeeds at \nremoving 'a.exe' if there is no 'a'.  But this means Makefile's $X-specific \nrule to kill old scripts now nukes the just built binary files:\n\n$ make\n...\n    BUILTIN git-status.exe\n    BUILTIN git-whatchanged.exe\nrm -f 'git-fast-import';  ... rm -f 'git-status';  rm -f 'git-whatchanged';  \nrm -f 'git';\n    SUBDIR git-gui\n...\n$ ls git\nls: cannot access git: No such file or directory\n\nand all the hard work of building is lost, on every attempt to build.  All \nplatforms that have $X should have a test(1) that understands -ef.\n\n\n Makefile |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex fcff2a4..ca418fc 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1071,7 +1071,7 @@ SHELL = $(SHELL_PATH)\n \n all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) \nGIT-BUILD-OPTIONS\n ifneq (,$X)\n-\t$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) \ngit$X)), $(RM) '$p';)\n+\t$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) \ngit$X)), test '$p' -ef '$p$X' || $(RM) '$p';)\n endif\n \n all::\n-- \n1.5.6.4\n"}]}