Makefile (view raw)
1CGIT_VERSION = v0.8.3.3
2CGIT_SCRIPT_NAME = cgit.cgi
3CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
4CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
5CGIT_CONFIG = /etc/cgitrc
6CACHE_ROOT = /var/cache/cgit
7prefix = /usr
8docdir = $(prefix)/share/doc/cgit
9htmldir = $(docdir)
10pdfdir = $(docdir)
11mandir = $(prefix)/share/man
12SHA1_HEADER = <openssl/sha.h>
13GIT_VER = 1.7.3
14GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
15INSTALL = install
16MAN5_TXT = $(wildcard *.5.txt)
17MAN_TXT = $(MAN5_TXT)
18DOC_MAN5 = $(patsubst %.txt,%,$(MAN5_TXT))
19DOC_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
20DOC_PDF = $(patsubst %.txt,%.pdf,$(MAN_TXT))
21
22# Define NO_STRCASESTR if you don't have strcasestr.
23#
24# Define NO_OPENSSL to disable linking with OpenSSL and use bundled SHA1
25# implementation (slower).
26#
27# Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin).
28#
29# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
30# do not support the 'size specifiers' introduced by C99, namely ll, hh,
31# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
32# some C compilers supported these specifiers prior to C99 as an extension.
33#
34
35#-include config.mak
36
37#
38# Platform specific tweaks
39#
40
41uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
42uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
43uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
44
45ifeq ($(uname_O),Cygwin)
46 NO_STRCASESTR = YesPlease
47 NEEDS_LIBICONV = YesPlease
48endif
49
50#
51# Let the user override the above settings.
52#
53-include cgit.conf
54
55#
56# Define a way to invoke make in subdirs quietly, shamelessly ripped
57# from git.git
58#
59QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
60QUIET_SUBDIR1 =
61
62ifneq ($(findstring $(MAKEFLAGS),w),w)
63PRINT_DIR = --no-print-directory
64else # "make -w"
65NO_SUBDIR = :
66endif
67
68ifndef V
69 QUIET_CC = @echo ' ' CC $@;
70 QUIET_MM = @echo ' ' MM $@;
71 QUIET_SUBDIR0 = +@subdir=
72 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
73 $(MAKE) $(PRINT_DIR) -C $$subdir
74endif
75
76#
77# Define a pattern rule for automatic dependency building
78#
79%.d: %.c
80 $(QUIET_MM)$(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@
81
82#
83# Define a pattern rule for silent object building
84#
85%.o: %.c
86 $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $<
87
88
89EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lpthread
90OBJECTS =
91OBJECTS += cache.o
92OBJECTS += cgit.o
93OBJECTS += cmd.o
94OBJECTS += configfile.o
95OBJECTS += html.o
96OBJECTS += parsing.o
97OBJECTS += scan-tree.o
98OBJECTS += shared.o
99OBJECTS += ui-atom.o
100OBJECTS += ui-blob.o
101OBJECTS += ui-clone.o
102OBJECTS += ui-commit.o
103OBJECTS += ui-diff.o
104OBJECTS += ui-log.o
105OBJECTS += ui-patch.o
106OBJECTS += ui-plain.o
107OBJECTS += ui-refs.o
108OBJECTS += ui-repolist.o
109OBJECTS += ui-shared.o
110OBJECTS += ui-snapshot.o
111OBJECTS += ui-ssdiff.o
112OBJECTS += ui-stats.o
113OBJECTS += ui-summary.o
114OBJECTS += ui-tag.o
115OBJECTS += ui-tree.o
116
117ifdef NEEDS_LIBICONV
118 EXTLIBS += -liconv
119endif
120
121
122.PHONY: all libgit test install uninstall clean force-version get-git \
123 doc clean-doc install-doc install-man install-html install-pdf \
124 uninstall-doc uninstall-man uninstall-html uninstall-pdf
125
126all: cgit
127
128VERSION: force-version
129 @./gen-version.sh "$(CGIT_VERSION)"
130-include VERSION
131
132
133CFLAGS += -g -Wall -Igit
134CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)'
135CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"'
136CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"'
137CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"'
138CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"'
139
140ifdef NO_ICONV
141 CFLAGS += -DNO_ICONV
142endif
143ifdef NO_STRCASESTR
144 CFLAGS += -DNO_STRCASESTR
145endif
146ifdef NO_C99_FORMAT
147 CFLAGS += -DNO_C99_FORMAT
148endif
149ifdef NO_OPENSSL
150 CFLAGS += -DNO_OPENSSL
151 GIT_OPTIONS += NO_OPENSSL=1
152else
153 EXTLIBS += -lcrypto
154endif
155
156cgit: $(OBJECTS) libgit
157 $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS)
158
159cgit.o: VERSION
160
161ifneq "$(MAKECMDGOALS)" "clean"
162 -include $(OBJECTS:.o=.d)
163endif
164
165libgit:
166 $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) libgit.a
167 $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) xdiff/lib.a
168
169test: all
170 $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all
171
172install: all
173 $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_SCRIPT_PATH)
174 $(INSTALL) -m 0755 cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
175 $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_DATA_PATH)
176 $(INSTALL) -m 0644 cgit.css $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css
177 $(INSTALL) -m 0644 cgit.png $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png
178
179install-doc: install-man install-html install-pdf
180
181install-man: doc-man
182 $(INSTALL) -m 0755 -d $(DESTDIR)$(mandir)/man5
183 $(INSTALL) -m 0644 $(DOC_MAN5) $(DESTDIR)$(mandir)/man5
184
185install-html: doc-html
186 $(INSTALL) -m 0755 -d $(DESTDIR)$(htmldir)
187 $(INSTALL) -m 0644 $(DOC_HTML) $(DESTDIR)$(htmldir)
188
189install-pdf: doc-pdf
190 $(INSTALL) -m 0755 -d $(DESTDIR)$(pdfdir)
191 $(INSTALL) -m 0644 $(DOC_PDF) $(DESTDIR)$(pdfdir)
192
193uninstall:
194 rm -f $(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
195 rm -f $(CGIT_DATA_PATH)/cgit.css
196 rm -f $(CGIT_DATA_PATH)/cgit.png
197
198uninstall-doc: uninstall-man uninstall-html uninstall-pdf
199
200uninstall-man:
201 @for i in $(DOC_MAN5); do \
202 rm -fv $(DESTDIR)$(mandir)/man5/$$i; \
203 done
204
205uninstall-html:
206 @for i in $(DOC_HTML); do \
207 rm -fv $(DESTDIR)$(htmldir)/$$i; \
208 done
209
210uninstall-pdf:
211 @for i in $(DOC_PDF); do \
212 rm -fv $(DESTDIR)$(pdfdir)/$$i; \
213 done
214
215doc: doc-man doc-html doc-pdf
216doc-man: doc-man5
217doc-man5: $(DOC_MAN5)
218doc-html: $(DOC_HTML)
219doc-pdf: $(DOC_PDF)
220
221%.5 : %.5.txt
222 a2x -f manpage $<
223
224$(DOC_HTML): %.html : %.txt
225 a2x -f xhtml --stylesheet=cgit-doc.css $<
226
227$(DOC_PDF): %.pdf : %.txt
228 a2x -f pdf cgitrc.5.txt
229
230clean: clean-doc
231 rm -f cgit VERSION *.o *.d
232
233clean-doc:
234 rm -f cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo
235
236get-git:
237 curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git