Skip to contentSkip to conversation

Let GCC generate deps with -MD.

PATCH In review Johan Rydberg 3 participants 4 messages Aug 12, 2006 – Aug 15, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Let GCC generate deps with -MD.

Hi,

Instead of generating the dependencies separately it can be done the first time a file is compiled, with the -MD option to GCC.

Comments?

2006-08-12 Johan Rydberg <[email protected]>

* genmk.rb: Let GCC generate dependenceies the first time it compiles a file; using the -MD option.

Index: genmk.rb
===================================================================
RCS file: /sources/grub/grub2/genmk.rb,v
retrieving revision 1.25

genmk.rb +4 -32
diff -u -r1.25 genmk.rb
@@ -71,14 +71,7 @@
       dir = File.dirname(src)
       
       "#{obj}: #{src}
-	$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -c -o $@ $<
-
-#{dep}: #{src}
-	set -e; \
-	  $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -M $< \
-	  | sed 's,#{Regexp.quote(fake_obj)}[ :]*,#{obj} $@ : ,g' > $@; \
-	  [ -s $@ ] || rm -f $@
-
+	$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $<
 -include #{dep}
 
 "
@@ -153,14 +146,7 @@
       dir = File.dirname(src)
 
       "#{obj}: #{src}
-	$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) $(TARGET_#{flag}) $(#{prefix}_#{flag}) -c -o $@ $<
-
-#{dep}: #{src}
-	set -e; \
-	  $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) $(TARGET_#{flag}) $(#{prefix}_#{flag}) -M $< \
-	  | sed 's,#{Regexp.quote(fake_obj)}[ :]*,#{obj} $@ : ,g' > $@; \
-	  [ -s $@ ] || rm -f $@
-
+	$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $<
 -include #{dep}
 
 CLEANFILES += #{command} #{fs}
@@ -213,14 +199,7 @@
       dir = File.dirname(src)
 
       "#{obj}: #{src}
-	$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -c -o $@ $<
-
-#{dep}: #{src}
-	set -e; \
-	  $(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -M $< \
-	  | sed 's,#{Regexp.quote(fake_obj)}[ :]*,#{obj} $@ : ,g' > $@; \
-	  [ -s $@ ] || rm -f $@
-
+	$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -MD -c -o $@ $<
 -include #{dep}
 
 "
@@ -258,14 +237,7 @@
       dir = File.dirname(src)
 
       "#{obj}: #{src}
-	$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -c -o $@ $<
-
-#{dep}: #{src}
-	set -e; \
-	  $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -M $< \
-	  | sed 's,#{Regexp.quote(fake_obj)}[ :]*,#{obj} $@ : ,g' > $@; \
-	  [ -s $@ ] || rm -f $@
-
+	$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -MD -c -o $@ $<
 -include #{dep}
 
 "
#1 lore raw
Quoted 3 lines · Johan Rydberg

Instead of generating the dependencies separately it can be done the first time a file is compiled, with the -MD option to GCC.

Just curious... does this solve the problem that occurs when you delete a .c file?

-Hollis

#2 lore raw
In reply to Johan Rydberg
Quoted 2 lines · Johan Rydberg

Instead of generating the dependencies separately it can be done the first time a file is compiled, with the -MD option to GCC.

That sounds good to me.

Thanks,
Okuji

#3 lore raw
Quoted 5 lines · Yoshinori K. Okuji
Quoted 2 lines · Johan Rydberg

Instead of generating the dependencies separately it can be done the first time a file is compiled, with the -MD option to GCC.

That sounds good to me.

Committed, with the *.mk files regenerated.

Thanks,
Johan.