b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven.eckelmann@gmx.de>
To: b.a.t.m.a.n@open-mesh.net
Subject: [B.A.T.M.A.N.] [PATCH] Generate source dependency informations on the fly
Date: Mon,  2 Mar 2009 14:15:54 +0100	[thread overview]
Message-ID: <1235999754-6552-1-git-send-email-sven.eckelmann@gmx.de> (raw)

The current way to track dependencies in batman and related tools is to
look for changes in the .c file and if it exist the .h file with the
same name. This can lead to inconsistent compilations when changes are
done in a header which is included in different .c files.
The easiest workaround is to let the compiler generate the dependency
information which is then included in the makefile to notice changes
in directly and indirectly included files. The first run is made without
these informations during the build of object files. No extra execve or
gcc startup related overhead is generated in that way and future changes
are still tracked by make.

Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman-adv-userspace/Makefile |   10 ++++------
 batman/Makefile               |    9 ++++-----
 battool/Makefile              |    7 ++++---
 vis-advanced/Makefile         |   10 ++++------
 4 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/batman-adv-userspace/Makefile b/batman-adv-userspace/Makefile
index 6e3c2dd..265799b 100644
--- a/batman-adv-userspace/Makefile
+++ b/batman-adv-userspace/Makefile
@@ -60,11 +60,9 @@ all:
 $(BINARY_NAME):	$(SRC_O) $(SRC_H) Makefile
 	$(Q_LD)$(CC) -o $@ $(SRC_O) $(LDFLAGS)
 
-%.o: %.c %.h
-	$(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
-
-%.o: %.c
-	$(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
+.c.o:
+	$(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -MD -c $< -o $@
+-include $(SRC_C:.c=.d)
 
 sources:
 	mkdir -p $(FILE_NAME)
@@ -80,7 +78,7 @@ sources:
 	tar czvf $(FILE_NAME).tgz $(FILE_NAME)
 
 clean:
-	rm -f $(BINARY_NAME) *.o
+	rm -f $(BINARY_NAME) *.o *.d
 
 
 clean-long:
diff --git a/batman/Makefile b/batman/Makefile
index 565d75e..509217d 100644
--- a/batman/Makefile
+++ b/batman/Makefile
@@ -78,11 +78,9 @@ all:
 $(BINARY_NAME):	$(SRC_O) $(SRC_H) Makefile
 	$(Q_LD)$(CC) -o $@ $(SRC_O) $(LDFLAGS)
 
-%.o: %.c %.h
-	$(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
-
-%.o: %.c
-	$(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
+.c.o:
+	$(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -MD -c $< -o $@
+-include $(SRC_C:.c=.d)
 
 sources:
 	mkdir -p $(FILE_NAME)
@@ -99,6 +97,7 @@ sources:
 
 clean:
 	rm -f $(BINARY_NAME) *.o posix/*.o linux/*.o bsd/*.o
+	rm -f `find . -name '*.d' -print`
 
 
 clean-long:
diff --git a/battool/Makefile b/battool/Makefile
index 10d310f..4c8d497 100644
--- a/battool/Makefile
+++ b/battool/Makefile
@@ -73,8 +73,9 @@ all:		$(BINARY_NAME)
 $(BINARY_NAME):	$(SRC_O) $(SRC_H) Makefile
 	$(Q_LD)$(CC) -o $@ $(SRC_O) $(LDFLAGS)
 
-%.o: %.c
-	$(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
+.c.o:
+	$(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -MD -c $< -o $@
+-include $(SRC_C:.c=.d)
 
 sources:
 	mkdir -p $(FILE_NAME)
@@ -91,7 +92,7 @@ sources:
 	tar czvf $(FILE_NAME).tgz $(FILE_NAME)
 
 clean:
-	rm -f $(BINARY_NAME) *.o
+	rm -f $(BINARY_NAME) *.o *.d
 
 
 clean-long:
diff --git a/vis-advanced/Makefile b/vis-advanced/Makefile
index 548d85f..3eaf1eb 100644
--- a/vis-advanced/Makefile
+++ b/vis-advanced/Makefile
@@ -42,11 +42,9 @@ vis-adv:	$(SRC_O) Makefile
 vis-adv-static:	$(SRC_O) Makefile
 		$(Q_LD)$(CC) $(CFLAGS) -o $@ $(SRC_O) $(LDFLAGS_STATIC)
 
-%.o: %.c %.h
-	$(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
-
-%.o: %.c
-	$(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
+.c.o:
+	$(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -MD -c $< -o $@
+-include $(SRC_C:.c=.d)
 
 clean:
-		rm -f vis-adv vis-adv-static *.o *~
+		rm -f vis-adv vis-adv-static *.o *.d *~
-- 
1.6.1.3


                 reply	other threads:[~2009-03-02 13:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1235999754-6552-1-git-send-email-sven.eckelmann@gmx.de \
    --to=sven.eckelmann@gmx.de \
    --cc=b.a.t.m.a.n@open-mesh.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).