From patchwork Mon Mar 2 13:15:54 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 5377 Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by open-mesh.net (8.14.3/8.13.4/Debian-3sarge3) with SMTP id n22DKejU027438 for ; Mon, 2 Mar 2009 13:20:41 GMT Received: (qmail invoked by alias); 02 Mar 2009 13:15:58 -0000 Received: from unknown (EHLO localhost) [89.246.218.200] by mail.gmx.net (mp034) with SMTP; 02 Mar 2009 14:15:58 +0100 X-Authenticated: #15668376 X-Provags-ID: V01U2FsdGVkX1/3VdpAxQX3ZVYirMBZFDNAT+vEGRadRu1HJaLdTt ETn+TQR5a7zJKg From: Sven Eckelmann To: b.a.t.m.a.n@open-mesh.net Date: Mon, 2 Mar 2009 14:15:54 +0100 Message-Id: <1235999754-6552-1-git-send-email-sven.eckelmann@gmx.de> X-Mailer: git-send-email 1.6.1.3 X-Y-GMX-Trusted: 0 X-FuHaFi: 0.49 Subject: [B.A.T.M.A.N.] [PATCH] Generate source dependency informations on the fly X-BeenThere: b.a.t.m.a.n@open-mesh.net X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Mar 2009 13:20:41 -0000 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 --- 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 *~