1 CGIT_VERSION = v0.8.3.3
2 CGIT_SCRIPT_NAME = cgit.cgi
3 CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
4 CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
5 CGIT_CONFIG = /etc/cgitrc
6 CACHE_ROOT = /var/cache/cgit
8 docdir = $(prefix)/share/doc/cgit
11 mandir = $(prefix)/share/man
12 SHA1_HEADER = <openssl/sha.h>
14 GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
16 MAN5_TXT = $(wildcard *.5.txt)
18 DOC_MAN5 = $(patsubst %.txt,%,$(MAN5_TXT))
19 DOC_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
20 DOC_PDF = $(patsubst %.txt,%.pdf,$(MAN_TXT))
22 # Define NO_STRCASESTR if you don't have strcasestr.
24 # Define NO_OPENSSL to disable linking with OpenSSL and use bundled SHA1
25 # implementation (slower).
27 # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin).
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.
38 # Platform specific tweaks
41 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
42 uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
43 uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
45 ifeq ($(uname_O),Cygwin)
46 NO_STRCASESTR = YesPlease
47 NEEDS_LIBICONV = YesPlease
51 # Let the user override the above settings.
56 # Define a way to invoke make in subdirs quietly, shamelessly ripped
59 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
62 ifneq ($(findstring $(MAKEFLAGS),w),w)
63 PRINT_DIR = --no-print-directory
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
77 # Define a pattern rule for automatic dependency building
80 $(QUIET_MM)$(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@
83 # Define a pattern rule for silent object building
86 $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $<
89 EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lpthread
94 OBJECTS += configfile.o
97 OBJECTS += scan-tree.o
101 OBJECTS += ui-clone.o
102 OBJECTS += ui-commit.o
105 OBJECTS += ui-patch.o
106 OBJECTS += ui-plain.o
108 OBJECTS += ui-repolist.o
109 OBJECTS += ui-shared.o
110 OBJECTS += ui-snapshot.o
111 OBJECTS += ui-ssdiff.o
112 OBJECTS += ui-stats.o
113 OBJECTS += ui-summary.o
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
128 VERSION: force-version
129 @./gen-version.sh "$(CGIT_VERSION)"
133 CFLAGS += -g -Wall -Igit
134 CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)'
135 CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"'
136 CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"'
137 CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"'
138 CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"'
144 CFLAGS += -DNO_STRCASESTR
147 CFLAGS += -DNO_C99_FORMAT
150 CFLAGS += -DNO_OPENSSL
151 GIT_OPTIONS += NO_OPENSSL=1
156 cgit: $(OBJECTS) libgit
157 $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS)
161 ifneq "$(MAKECMDGOALS)" "clean"
162 -include $(OBJECTS:.o=.d)
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
170 $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) 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
179 install-doc: install-man install-html install-pdf
182 $(INSTALL) -m 0755 -d $(DESTDIR)$(mandir)/man5
183 $(INSTALL) -m 0644 $(DOC_MAN5) $(DESTDIR)$(mandir)/man5
185 install-html: doc-html
186 $(INSTALL) -m 0755 -d $(DESTDIR)$(htmldir)
187 $(INSTALL) -m 0644 $(DOC_HTML) $(DESTDIR)$(htmldir)
190 $(INSTALL) -m 0755 -d $(DESTDIR)$(pdfdir)
191 $(INSTALL) -m 0644 $(DOC_PDF) $(DESTDIR)$(pdfdir)
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
198 uninstall-doc: uninstall-man uninstall-html uninstall-pdf
201 @for i in $(DOC_MAN5); do \
202 rm -fv $(DESTDIR)$(mandir)/man5/$$i; \
206 @for i in $(DOC_HTML); do \
207 rm -fv $(DESTDIR)$(htmldir)/$$i; \
211 @for i in $(DOC_PDF); do \
212 rm -fv $(DESTDIR)$(pdfdir)/$$i; \
215 doc: doc-man doc-html doc-pdf
217 doc-man5: $(DOC_MAN5)
218 doc-html: $(DOC_HTML)
224 $(DOC_HTML): %.html : %.txt
225 a2x -f xhtml --stylesheet=cgit-doc.css $<
227 $(DOC_PDF): %.pdf : %.txt
228 a2x -f pdf cgitrc.5.txt
231 rm -f cgit VERSION *.o *.d
234 rm -f cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo
237 curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git