[mw-devel] [Git][arthur/mw][master] Hide the .d files

Andrew Price welshbyte at sucs.org
Thu Apr 7 23:17:17 BST 2016


Andrew Price pushed to branch master at Justin Mitchell / mw


Commits:
cbde0b13 by Andrew Price at 2016-04-07T23:17:00+01:00
Hide the .d files

Use -MF to make gcc output the autogenerated rules into dotfiles so that
they don't clutter up listings.

- - - - -


6 changed files:

- Makefile.common
- src/Makefile
- src/client/Makefile
- src/server/Makefile
- src/utils/Makefile
- src/webclient/Makefile


Changes:

=====================================
Makefile.common
=====================================
--- a/Makefile.common
+++ b/Makefile.common
@@ -86,21 +86,26 @@ else
 MWCFLAGS += -O0 -Werror
 endif
 
-### The magic which lets us autogenerate dependencies
-CFLAGS = $(MWCFLAGS) -MMD
-LDFLAGS = $(MWLDFLAGS)
 # Let the user add some flags at the end
 CFLAGS_APPEND =
 
+CFLAGS = $(MWCFLAGS) $(CFLAGS_APPEND)
+LDFLAGS = $(MWLDFLAGS)
+
 CODE=$(wildcard *.c)
 HDRS=$(wildcard *.h)
 
 all: build
 
+# Using -MMD -MF <filename> outputs make rules for the required .o into
+# <filename> with automatically generated dependencies on the .c file and the
+# local headers included by the .c file
 %.o: %.c
-	$(CC) $(CFLAGS) $(CFLAGS_APPEND) -c -o $@ $<
+	$(CC) $(CFLAGS) -MMD -MF .$(@:.o=.d) -c -o $@ $<
 
--include $(CODE:.c=.d)
+# The generated rule for the requested .o file is then included, dependencies
+# are checked and the rule is executed without the -M* options.
+-include $(CODE:%.c=.%.d)
 
 $(JSOBJ):
 	$(MAKE) -C $(SRCROOT)/mozjs libdir=/usr/lib


=====================================
src/Makefile
=====================================
--- a/src/Makefile
+++ b/src/Makefile
@@ -27,7 +27,7 @@ install: all
 	install -d $(DESTDIR)$(STATEDIR)
 
 clean:
-	-rm -f *.o *.d nonce-def.h mw mwserv libmw.a
+	-rm -f *.o *.d .*.d nonce-def.h mw mwserv libmw.a
 
 cleanall: clean
 	$(MAKE) -C client clean


=====================================
src/client/Makefile
=====================================
--- a/src/client/Makefile
+++ b/src/client/Makefile
@@ -14,7 +14,7 @@ install: mw
 	install -D mw $(DESTDIR)$(bindir)/mw
 
 clean:
-	-rm -f *.o *.d mw
+	-rm -f *.o .*.d *.d mw
 
 ifndef TESTDIR
 test:


=====================================
src/server/Makefile
=====================================
--- a/src/server/Makefile
+++ b/src/server/Makefile
@@ -11,7 +11,7 @@ mwserv: $(CODE:.c=.o) ../libmw.a $(JSOBJ)
 	$(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
 
 clean:
-	-rm -f *.o *.d mwserv
+	-rm -f *.o .*.d *.d mwserv
 
 install: mwserv
 	install -D mwserv $(DESTDIR)$(HOMEPATH)/mwserv


=====================================
src/utils/Makefile
=====================================
--- a/src/utils/Makefile
+++ b/src/utils/Makefile
@@ -22,4 +22,4 @@ sizes: sizes.o
 	$(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
 
 clean:
-	rm -f *.o *.d listuser fixuser del_user sizes
+	rm -f *.o .*.d *.d listuser fixuser del_user sizes


=====================================
src/webclient/Makefile
=====================================
--- a/src/webclient/Makefile
+++ b/src/webclient/Makefile
@@ -6,11 +6,11 @@ CFLAGS+= -I.. -I/usr/include/postgresql
 
 build: mwpoll
 
-mwpoll: mwpoll.o import.o comms.o mwstring.o ../libmw.a 
+mwpoll: mwpoll.o import.o comms.o mwstring.o ../libmw.a
 	$(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
 
 clean:
-	-rm -f *.o *.d mwpoll
+	-rm -f *.o .*.d *.d mwpoll
 
 install: mwpoll
 	install -D mwpoll $(DESTDIR)$(HOMEPATH)/mwpoll



View it on GitLab: https://projects.sucs.org/arthur/mw/commit/cbde0b1352a8a9079d7ea75319e9cc76bb530309
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20160407/2eae5d1c/attachment-0001.html>


More information about the mw-devel mailing list