Hi

This removes the need to "make clean" after editing a header file.
All C files that need recompiling are automatically rebuilt.

- Lauri
>From ed8385d51e7c1cdb52b619afcd2819647b03b690 Mon Sep 17 00:00:00 2001
From: Lauri Kasanen <[email protected]>
Date: Thu, 17 May 2012 22:20:04 +0300
Subject: [PATCH] Build system: Automatic dependencies for the header files

This removes the need to "make clean" after editing a header file.
All C files that need recompiling are automatically rebuilt.

Signed-off-by: Lauri Kasanen <[email protected]>
---
 .gitignore                     |    2 +-
 configure                      |    5 ++++-
 plugins/auth/Makefile.in       |    5 ++++-
 plugins/cheetah/Makefile.in    |    5 ++++-
 plugins/dirlisting/Makefile.in |    5 ++++-
 plugins/liana/Makefile.in      |    5 ++++-
 plugins/liana_ssl/Makefile.in  |    5 ++++-
 plugins/logger/Makefile.in     |    5 ++++-
 plugins/mandril/Makefile.in    |    5 ++++-
 plugins/palm/Makefile.in       |    5 ++++-
 plugins/patas/Makefile.in      |    5 ++++-
 plugins/websockets/Makefile.in |    5 ++++-
 12 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/.gitignore b/.gitignore
index c46f74b..dfef0db 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-*.[ao]
+*.[aod]
 *~
 *.so
 *.pyc
diff --git a/configure b/configure
index 9ec3671..c624ca1 100755
--- a/configure
+++ b/configure
@@ -421,6 +421,8 @@ OBJ = monkey.o mk_method.o mk_mimetype.o mk_request.o \\
 
 all: ../bin/monkey
 
+-include \$(OBJ:.o=.d)
+
 ../bin/monkey: \$(OBJ)
        @echo
        @echo "Compiling Monkey"
@@ -428,7 +430,7 @@ all: ../bin/monkey
        \$(CC) \$(CFLAGS) \$(DEFS) \$(LDFLAGS) -o \$@ \$(OBJ) $mod_obj \$(LIBS)
 
 clean:
-       rm -rf *.o
+       rm -rf *.[od]
        rm -rf ../bin/monkey
 
 distclean:
@@ -439,6 +441,7 @@ distclean:
 
 .c.o:
        \$(CC) -c \$(CFLAGS) \$(DEFS) -I\$(INCDIR) \$<
+       \$(CC) -MM -MP \$(CFLAGS) \$(DEFS) -I\$(INCDIR) \$*.c > \$*.d
 EOF
 }
 
diff --git a/plugins/auth/Makefile.in b/plugins/auth/Makefile.in
index 76e8acd..21badb9 100644
--- a/plugins/auth/Makefile.in
+++ b/plugins/auth/Makefile.in
@@ -7,11 +7,14 @@ OBJECTS = sha1.o base64.o conf.o auth.o
 
 all: monkey-auth.so
 
+-include $(OBJECTS:.o=.d)
+
 monkey-auth.so: $(OBJECTS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -shared -o $@ $^ -lc
 
 .c.o: $(SOURCES)
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -I$(INCDIR) -fPIC -c $<
+       $(CC) -MM -MP $(CFLAGS) $(DEFS) $(LDFLAGS) -I$(INCDIR) $*.c > $*.d
 
 clean:
-       rm -rf *.o *.*~ *.*so*
+       rm -rf *.[od] *.*~ *.*so*
diff --git a/plugins/cheetah/Makefile.in b/plugins/cheetah/Makefile.in
index 0dd252c..7eff6b1 100644
--- a/plugins/cheetah/Makefile.in
+++ b/plugins/cheetah/Makefile.in
@@ -7,10 +7,13 @@ CHEETAH_OBJECTS = cheetah.o loop.o cmd.o cutils.o
 
 all: monkey-cheetah.so
 
+-include $(CHEETAH_OBJECTS:.o=.d)
+
 monkey-cheetah.so: $(CHEETAH_OBJECTS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -shared -o $@ $^ -lc
 
 .c.o:
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -I$(INCDIR) -fPIC -c $<
+       $(CC) -MM -MP $(CFLAGS) $(DEFS) $(LDFLAGS) -I$(INCDIR) $*.c > $*.d
 clean:
-       rm -rf *.o *~ *.*so*
+       rm -rf *.[od] *~ *.*so*
diff --git a/plugins/dirlisting/Makefile.in b/plugins/dirlisting/Makefile.in
index a139e8f..a3449ee 100644
--- a/plugins/dirlisting/Makefile.in
+++ b/plugins/dirlisting/Makefile.in
@@ -7,11 +7,14 @@ DIRLISTING_OBJECTS = dirlisting.o
 
 all: monkey-dirlisting.so
 
+-include $(DIRLISTING_OBJECTS:.o=.d)
+
 monkey-dirlisting.so: $(DIRLISTING_OBJECTS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -shared -o $@ $^ -lc
 
 .c.o:
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -I$(INCDIR) -fPIC -c $<
+       $(CC) -MM -MP $(CFLAGS) $(DEFS) $(LDFLAGS) -I$(INCDIR) $*.c > $*.d
 
 clean:
-       rm -rf *.o *~ *.*so*
+       rm -rf *.[od] *~ *.*so*
diff --git a/plugins/liana/Makefile.in b/plugins/liana/Makefile.in
index 799133a..b807601 100644
--- a/plugins/liana/Makefile.in
+++ b/plugins/liana/Makefile.in
@@ -7,11 +7,14 @@ LIANA_OBJECTS = liana.o
 
 all: monkey-liana.so
 
+-include $(LIANA_OBJECTS:.o=.d)
+
 monkey-liana.so: $(LIANA_OBJECTS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -shared -o $@ $^ -lc
 
 .c.o:
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -I$(INCDIR) -fPIC -c $<
+       $(CC) -MM -MP $(CFLAGS) $(DEFS) $(LDFLAGS) -I$(INCDIR) $*.c > $*.d
 
 clean:
-       rm -rf *.o *~ *.*so*
+       rm -rf *.[od] *~ *.*so*
diff --git a/plugins/liana_ssl/Makefile.in b/plugins/liana_ssl/Makefile.in
index 4457091..c982174 100644
--- a/plugins/liana_ssl/Makefile.in
+++ b/plugins/liana_ssl/Makefile.in
@@ -8,11 +8,14 @@ MATRIX_HEADERS = /usr/include/matrixssl/
 
 all: monkey-liana_ssl.so
 
+-include $(OBJECTS:.o=.d)
+
 monkey-liana_ssl.so: $(OBJECTS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -shared -o $@ $^ -lmatrixssl
 
 .c.o:
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) $(INCDIR) -I$(MATRIX_HEADERS) -fPIC 
-c $<
+       $(CC) -MM -MP $(CFLAGS) $(DEFS) $(LDFLAGS) -I$(INCDIR) $*.c > $*.d
 
 clean:
-       rm -rf *.o *.*~ *.*so*
+       rm -rf *.[od] *.*~ *.*so*
diff --git a/plugins/logger/Makefile.in b/plugins/logger/Makefile.in
index 144445e..d7d3119 100644
--- a/plugins/logger/Makefile.in
+++ b/plugins/logger/Makefile.in
@@ -7,11 +7,14 @@ LOGGER_OBJECTS = pointers.o logger.o
 
 all: monkey-logger.so
 
+-include $(LOGGER_OBJECTS:.o=.d)
+
 monkey-logger.so: $(LOGGER_OBJECTS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -shared -o $@ $^ -lc
 
 .c.o:
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -I$(INCDIR) -fPIC -c $<
+       $(CC) -MM -MP $(CFLAGS) $(DEFS) $(LDFLAGS) -I$(INCDIR) $*.c > $*.d
 clean:
-       rm -rf *.o *~
+       rm -rf *.[od] *~
        rm -rf *.*so*
diff --git a/plugins/mandril/Makefile.in b/plugins/mandril/Makefile.in
index a8e1f37..10d28a2 100644
--- a/plugins/mandril/Makefile.in
+++ b/plugins/mandril/Makefile.in
@@ -7,12 +7,15 @@ MANDRIL_OBJECTS = mandril.o
 
 all: monkey-mandril.so
 
+-include $(MANDRIL_OBJECTS:.o=.d)
+
 monkey-mandril.so: $(MANDRIL_OBJECTS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -shared -o $@ $^ -lc
 
 .c.o:
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -I$(INCDIR) -fPIC -c $<
+       $(CC) -MM -MP $(CFLAGS) $(DEFS) $(LDFLAGS) -I$(INCDIR) $*.c > $*.d
 
 clean:
-       rm -rf *.o
+       rm -rf *.[od]
        rm -rf *.*so*
diff --git a/plugins/palm/Makefile.in b/plugins/palm/Makefile.in
index 2b1fb10..5a32853 100644
--- a/plugins/palm/Makefile.in
+++ b/plugins/palm/Makefile.in
@@ -8,11 +8,14 @@ OBJECTS = palm.o protocol.o cgi.o request.o
 
 all: monkey-palm.so
 
+-include $(OBJECTS:.o=.d)
+
 monkey-palm.so: $(OBJECTS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -shared -o $@ $^ -lc
 
 .c.o: $(SOURCES)
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -I$(INCDIR) -fPIC -c $<
+       $(CC) -MM -MP $(CFLAGS) $(DEFS) $(LDFLAGS) -I$(INCDIR) $*.c > $*.d
 
 clean:
-       rm -rf *.o *.*~ *.*so*
+       rm -rf *.[od] *.*~ *.*so*
diff --git a/plugins/patas/Makefile.in b/plugins/patas/Makefile.in
index fb4e06b..2c2bd00 100644
--- a/plugins/patas/Makefile.in
+++ b/plugins/patas/Makefile.in
@@ -7,10 +7,13 @@ PATAS_OBJECTS = patas.o connection.o
 
 all: monkey-patas.so
 
+-include $(PATAS_OBJECTS:.o=.d)
+
 monkey-patas.so: $(PATAS_OBJECTS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -shared -o $@ $^ -lc
 
 .c.o:
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -I$(INCDIR) -fPIC -c $<
+       $(CC) -MM -MP $(CFLAGS) $(DEFS) $(LDFLAGS) -I$(INCDIR) $*.c > $*.d
 clean:
-       rm -rf *.o *~ *.*so*
+       rm -rf *.[od] *~ *.*so*
diff --git a/plugins/websockets/Makefile.in b/plugins/websockets/Makefile.in
index be3db31..e0cb3ed 100644
--- a/plugins/websockets/Makefile.in
+++ b/plugins/websockets/Makefile.in
@@ -7,10 +7,13 @@ WS_OBJECTS = ws.o request.o base64.o sha1.o echo.o
 
 all: monkey-websockets.so
 
+-include $(WS_OBJECTS:.o=.d)
+
 monkey-websockets.so: $(WS_OBJECTS)
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -shared -o $@ $^ -lc
 
 .c.o:
        $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -I$(INCDIR) -fPIC -c $<
+       $(CC) -MM -MP $(CFLAGS) $(DEFS) $(LDFLAGS) -I$(INCDIR) $*.c > $*.d
 clean:
-       rm -rf *.o *~ *.*so*
+       rm -rf *.[od] *~ *.*so*
-- 
1.7.2.1

_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey

Reply via email to