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
7 SHA1_HEADER = <openssl/sha.h>
9 GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
11 MAN5_TXT = $(wildcard *.5.txt)
13 DOC_MAN5 = $(patsubst %.txt,%,$(MAN5_TXT))
14 DOC_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
15 DOC_PDF = $(patsubst %.txt,%.pdf,$(MAN_TXT))
17 # Define NO_STRCASESTR if you don't have strcasestr.
19 # Define NO_OPENSSL to disable linking with OpenSSL and use bundled SHA1
20 # implementation (slower).
22 # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin).
24 # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
25 # do not support the 'size specifiers' introduced by C99, namely ll, hh,
26 # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
27 # some C compilers supported these specifiers prior to C99 as an extension.
33 # Platform specific tweaks
36 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
37 uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
38 uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
40 ifeq ($(uname_O),Cygwin)
41 NO_STRCASESTR = YesPlease
42 NEEDS_LIBICONV = YesPlease
46 # Let the user override the above settings.
51 # Define a way to invoke make in subdirs quietly, shamelessly ripped
54 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
57 ifneq ($(findstring $(MAKEFLAGS),w),w)
58 PRINT_DIR = --no-print-directory
64 QUIET_CC = @echo ' ' CC $@;
65 QUIET_MM = @echo ' ' MM $@;
66 QUIET_SUBDIR0 = +@subdir=
67 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
68 $(MAKE) $(PRINT_DIR) -C $$subdir
72 # Define a pattern rule for automatic dependency building
75 $(QUIET_MM)$(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@
78 # Define a pattern rule for silent object building
81 $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $<
84 EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lpthread
89 OBJECTS += configfile.o
92 OBJECTS += scan-tree.o
97 OBJECTS += ui-commit.o
100 OBJECTS += ui-patch.o
101 OBJECTS += ui-plain.o
103 OBJECTS += ui-repolist.o
104 OBJECTS += ui-shared.o
105 OBJECTS += ui-snapshot.o
106 OBJECTS += ui-ssdiff.o
107 OBJECTS += ui-stats.o
108 OBJECTS += ui-summary.o
117 .PHONY: all libgit test install uninstall clean force-version get-git \
122 VERSION: force-version
123 @./gen-version.sh "$(CGIT_VERSION)"
127 CFLAGS += -g -Wall -Igit
128 CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)'
129 CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"'
130 CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"'
131 CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"'
132 CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"'
138 CFLAGS += -DNO_STRCASESTR
141 CFLAGS += -DNO_C99_FORMAT
144 CFLAGS += -DNO_OPENSSL
145 GIT_OPTIONS += NO_OPENSSL=1
150 cgit: $(OBJECTS) libgit
151 $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS)
155 ifneq "$(MAKECMDGOALS)" "clean"
156 -include $(OBJECTS:.o=.d)
160 $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) libgit.a
161 $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) xdiff/lib.a
164 $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all
167 $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_SCRIPT_PATH)
168 $(INSTALL) -m 0755 cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
169 $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_DATA_PATH)
170 $(INSTALL) -m 0644 cgit.css $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css
171 $(INSTALL) -m 0644 cgit.png $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png
174 rm -f $(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
175 rm -f $(CGIT_DATA_PATH)/cgit.css
176 rm -f $(CGIT_DATA_PATH)/cgit.png
178 doc: doc-man doc-html doc-pdf
180 doc-man5: $(DOC_MAN5)
181 doc-html: $(DOC_HTML)
187 $(DOC_HTML): %.html : %.txt
188 a2x -f xhtml --stylesheet=cgit-doc.css $<
190 $(DOC_PDF): %.pdf : %.txt
191 a2x -f pdf cgitrc.5.txt
194 rm -f cgit VERSION *.o *.d
197 rm -f cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo
200 curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git