summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2008-03-24 22:01:44 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-03-24 22:27:12 (UTC)
commitdf90b51bafec24336cf30339b2978ff6df22b075 (patch) (unidiff)
tree699d232ce635dbac9222e4b9dfc22f60b1aaa788
parent271818693d6803b5df25ee87570808c2a9dbd7e7 (diff)
downloadcgit-df90b51bafec24336cf30339b2978ff6df22b075.zip
cgit-df90b51bafec24336cf30339b2978ff6df22b075.tar.gz
cgit-df90b51bafec24336cf30339b2978ff6df22b075.tar.bz2
Makefile: autobuild dependency rules
This uses gcc to generate dependency rules for each `.o` file, based on the corresponding `.c` file, into a new set of `.d` files (which are also defined to depend on the same set of source files as their `.o` files). Result: * all objectfile dependencies are correctly calculated * only the necessary dependencies are recalculated when a sourcefile is updated Inspiration for the build rules: * http://www.gnu.org/software/make/manual/make.html#Automatic-Prerequisites * http://make.paulandlesley.org/autodep.html Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (show 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 @@
1# Files I don't care to see in git-status/commit 1# Files I don't care to see in git-status/commit
2cgit 2cgit
3cgit.conf 3cgit.conf
4VERSION 4VERSION
5*.o 5*.o
6*.d
diff --git a/Makefile b/Makefile
index d1950cb..faf7b98 100644
--- a/Makefile
+++ b/Makefile
@@ -1,98 +1,107 @@
1CGIT_VERSION = v0.7.2 1CGIT_VERSION = v0.7.2
2CGIT_SCRIPT_NAME = cgit.cgi 2CGIT_SCRIPT_NAME = cgit.cgi
3CGIT_SCRIPT_PATH = /var/www/htdocs/cgit 3CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
4CGIT_CONFIG = /etc/cgitrc 4CGIT_CONFIG = /etc/cgitrc
5CACHE_ROOT = /var/cache/cgit 5CACHE_ROOT = /var/cache/cgit
6SHA1_HEADER = <openssl/sha.h> 6SHA1_HEADER = <openssl/sha.h>
7GIT_VER = 1.5.4.1 7GIT_VER = 1.5.4.1
8GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 8GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
9 9
10# 10#
11# Let the user override the above settings. 11# Let the user override the above settings.
12# 12#
13-include cgit.conf 13-include cgit.conf
14 14
15 15
16#
17# Define a pattern rule for automatic dependency building
18#
19%.d: %.c
20 $(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@
21
22
16EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto 23EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto
17OBJECTS = 24OBJECTS =
18OBJECTS += cache.o 25OBJECTS += cache.o
19OBJECTS += cgit.o 26OBJECTS += cgit.o
20OBJECTS += cmd.o 27OBJECTS += cmd.o
21OBJECTS += html.o 28OBJECTS += html.o
22OBJECTS += parsing.o 29OBJECTS += parsing.o
23OBJECTS += shared.o 30OBJECTS += shared.o
24OBJECTS += ui-blob.o 31OBJECTS += ui-blob.o
25OBJECTS += ui-commit.o 32OBJECTS += ui-commit.o
26OBJECTS += ui-diff.o 33OBJECTS += ui-diff.o
27OBJECTS += ui-log.o 34OBJECTS += ui-log.o
28OBJECTS += ui-patch.o 35OBJECTS += ui-patch.o
29OBJECTS += ui-refs.o 36OBJECTS += ui-refs.o
30OBJECTS += ui-repolist.o 37OBJECTS += ui-repolist.o
31OBJECTS += ui-shared.o 38OBJECTS += ui-shared.o
32OBJECTS += ui-snapshot.o 39OBJECTS += ui-snapshot.o
33OBJECTS += ui-summary.o 40OBJECTS += ui-summary.o
34OBJECTS += ui-tag.o 41OBJECTS += ui-tag.o
35OBJECTS += ui-tree.o 42OBJECTS += ui-tree.o
36 43
37ifdef NEEDS_LIBICONV 44ifdef NEEDS_LIBICONV
38 EXTLIBS += -liconv 45 EXTLIBS += -liconv
39endif 46endif
40 47
41 48
42.PHONY: all git test install clean distclean emptycache force-version get-git 49.PHONY: all git test install clean distclean emptycache force-version get-git
43 50
44all: cgit git 51all: cgit git
45 52
46VERSION: force-version 53VERSION: force-version
47 @./gen-version.sh "$(CGIT_VERSION)" 54 @./gen-version.sh "$(CGIT_VERSION)"
48-include VERSION 55-include VERSION
49 56
50 57
51CFLAGS += -g -Wall -Igit 58CFLAGS += -g -Wall -Igit
52CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' 59CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)'
53CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' 60CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"'
54CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' 61CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"'
55CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' 62CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"'
56CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' 63CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"'
57 64
58 65
59cgit: $(OBJECTS) 66cgit: $(OBJECTS)
60 $(CC) $(CFLAGS) -o cgit $(OBJECTS) $(EXTLIBS) 67 $(CC) $(CFLAGS) -o cgit $(OBJECTS) $(EXTLIBS)
61 68
62$(OBJECTS): git/xdiff/lib.a git/libgit.a VERSION 69$(OBJECTS): git/xdiff/lib.a git/libgit.a VERSION
63 70
71-include $(OBJECTS:.o=.d)
72
64git/xdiff/lib.a: | git 73git/xdiff/lib.a: | git
65 74
66git/libgit.a: | git 75git/libgit.a: | git
67 76
68git: 77git:
69 cd git && $(MAKE) xdiff/lib.a 78 cd git && $(MAKE) xdiff/lib.a
70 cd git && $(MAKE) libgit.a 79 cd git && $(MAKE) libgit.a
71 80
72test: all 81test: all
73 $(MAKE) -C tests 82 $(MAKE) -C tests
74 83
75install: all 84install: all
76 mkdir -p $(DESTDIR)$(CGIT_SCRIPT_PATH) 85 mkdir -p $(DESTDIR)$(CGIT_SCRIPT_PATH)
77 install cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) 86 install cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
78 install cgit.css $(DESTDIR)$(CGIT_SCRIPT_PATH)/cgit.css 87 install cgit.css $(DESTDIR)$(CGIT_SCRIPT_PATH)/cgit.css
79 install cgit.png $(DESTDIR)$(CGIT_SCRIPT_PATH)/cgit.png 88 install cgit.png $(DESTDIR)$(CGIT_SCRIPT_PATH)/cgit.png
80 89
81uninstall: 90uninstall:
82 rm -f $(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) 91 rm -f $(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
83 rm -f $(CGIT_SCRIPT_PATH)/cgit.css 92 rm -f $(CGIT_SCRIPT_PATH)/cgit.css
84 rm -f $(CGIT_SCRIPT_PATH)/cgit.png 93 rm -f $(CGIT_SCRIPT_PATH)/cgit.png
85 94
86clean: 95clean:
87 rm -f cgit VERSION *.o 96 rm -f cgit VERSION *.o *.d
88 cd git && $(MAKE) clean 97 cd git && $(MAKE) clean
89 98
90distclean: clean 99distclean: clean
91 git clean -d -x 100 git clean -d -x
92 cd git && git clean -d -x 101 cd git && git clean -d -x
93 102
94emptycache: 103emptycache:
95 rm -rf $(DESTDIR)$(CACHE_ROOT)/* 104 rm -rf $(DESTDIR)$(CACHE_ROOT)/*
96 105
97get-git: 106get-git:
98 curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git 107 curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git