summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--.gitignore1
-rw-r--r--Makefile11
2 files changed, 11 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index aa36ff7..1e016e5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
# Files I don't care to see in git-status/commit
cgit
cgit.conf
VERSION
*.o
+*.d
diff --git a/Makefile b/Makefile
index d1950cb..faf7b98 100644
--- a/Makefile
+++ b/Makefile
@@ -10,12 +10,19 @@ GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
#
# Let the user override the above settings.
#
-include cgit.conf
+#
+# Define a pattern rule for automatic dependency building
+#
+%.d: %.c
+ $(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@
+
+
EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto
OBJECTS =
OBJECTS += cache.o
OBJECTS += cgit.o
OBJECTS += cmd.o
OBJECTS += html.o
@@ -58,12 +65,14 @@ CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"'
cgit: $(OBJECTS)
$(CC) $(CFLAGS) -o cgit $(OBJECTS) $(EXTLIBS)
$(OBJECTS): git/xdiff/lib.a git/libgit.a VERSION
+-include $(OBJECTS:.o=.d)
+
git/xdiff/lib.a: | git
git/libgit.a: | git
git:
cd git && $(MAKE) xdiff/lib.a
@@ -81,13 +90,13 @@ install: all
uninstall:
rm -f $(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
rm -f $(CGIT_SCRIPT_PATH)/cgit.css
rm -f $(CGIT_SCRIPT_PATH)/cgit.png
clean:
- rm -f cgit VERSION *.o
+ rm -f cgit VERSION *.o *.d
cd git && $(MAKE) clean
distclean: clean
git clean -d -x
cd git && git clean -d -x