Thread (6 messages) flat view 6 messages, 2 authors, 2016-06-15

Re: [PATCH resend] Makefile: Use computed header dependencies if the compiler supports it

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:51:48

Hi,

Fredrik Kuivinen wrote:
Previously you had to manually define COMPUTE_HEADER_DEPENDENCIES to
enable this feature. It seemed a bit sad that such a useful feature
had to be enabled manually.
Yes!  Thanks for this.

I have a few thoughts about the implementation:
quoted hunk ↗ jump to hunk
--- a/Makefile
+++ b/Makefile
[...]
quoted hunk ↗ jump to hunk
@@ -1236,6 +1232,15 @@ endif
 ifdef CHECK_HEADER_DEPENDENCIES
 COMPUTE_HEADER_DEPENDENCIES =
 USE_COMPUTED_HEADER_DEPENDENCIES =
+else
+dep_check = $(shell sh -c \
+	': > ++empty.c; \
+	$(CC) -c -MF /dev/null -MMD -MP ++empty.c -o /dev/null 2>&1; \
+	echo $$?; \
+	$(RM) ++empty.c')
+ifeq ($(dep_check),0)
+COMPUTE_HEADER_DEPENDENCIES=YesPlease
+endif
This causes "make foo" to run gcc and create a temporary file
unconditionally, regardless of what foo is.  In an ideal world:

 - the autodetection would only happen when building targets that
   care about it

 - the detection would happen once (creating some file to store the
   result) and not be repeated with each invocation of "make"

 - (maybe) there would be a way to override the detection with
   either a "yes" or "no" result, for those who really care to
   save a little time.

I was about to say that the GIT_VERSION variable has some of these
properties, but now that I check, from the point of view of the
Makefile it doesn't.  ./GIT-VERSION-GEN is just very fast. :)

I wonder if we can make do with a faster check, like

	$(CC) -c -MF /dev/null -MMD -MP git.c --help >/dev/null 2>&1

What do you think?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help