build: remove unportable use of sed in favor of $(CXX)'s -MT

Summary:
The code being removed would invoke sed differently to work
around a portability difference in how sed -i works (different
on MacOS).  Yet performing a host-type-based ifdef fails when
the tools installed do not match.  That sed use was solely to
post-process the .d file.  Instead, generate the desired output
directly, by using the compiler's -MT<FILE> option.
* Makefile (%.d: %.cc): With the prior use of Makefile-ifdef'd
sed, when building on MacOS with gnu sed, every run of this rule
would fail with a sed usage error.  Also list each .d file as a
dependent.

Test Plan:
  Ensure that a selected .d file is the same as before both with
  g++ and with clang++.  However, note that the new .d files each
  contain a new reference to the .d file itself.

Reviewers: sdong, ljin, igor

Reviewed By: igor

Subscribers: dhruba

Differential Revision: https://reviews.facebook.net/D33369
main
Jim Meyering 10 years ago
parent e7ea51a8e7
commit b3fd162267
  1. 8
      Makefile

@ -722,12 +722,8 @@ endif
# The sed command makes sure the "target" file in the generated .d file has
# the correct path prefix.
%.d: %.cc
$(CXX) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) -MM $< -o $@
ifeq ($(PLATFORM), OS_MACOSX)
@sed -i '' -e 's,.*:,$*.o:,' $@
else
@sed -i -e 's,.*:,$*.o:,' $@
endif
$(CXX) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) \
-MM -MT'$@' -MT'$(<:.cc=.o)' "$<" -o '$@'
DEPFILES = $(filter-out util/build_version.d,$(SOURCES:.cc=.d))

Loading…
Cancel
Save