blob: 18738095b0eaa5f6d85c753738020f17fed05c09 [file] [log] [blame]
Lars Hjemlie0327612012-03-18 10:16:27 +00001CGIT_VERSION = v0.9.0.3
Lars Hjemliea2831f2007-05-15 00:48:31 +02002CGIT_SCRIPT_NAME = cgit.cgi
Lars Hjemlie8920b52007-09-03 21:52:14 +02003CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
Todd Zullingerd529c6f2009-01-11 18:23:59 -05004CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
Lars Hjemlie8920b52007-09-03 21:52:14 +02005CGIT_CONFIG = /etc/cgitrc
6CACHE_ROOT = /var/cache/cgit
Todd Zullinger0c3130d2010-09-06 09:31:23 -04007prefix = /usr
Todd Zullinger6d10c132010-09-06 09:31:24 -04008libdir = $(prefix)/lib
9filterdir = $(libdir)/cgit/filters
Todd Zullinger0c3130d2010-09-06 09:31:23 -040010docdir = $(prefix)/share/doc/cgit
11htmldir = $(docdir)
12pdfdir = $(docdir)
13mandir = $(prefix)/share/man
Lars Hjemlie8920b52007-09-03 21:52:14 +020014SHA1_HEADER = <openssl/sha.h>
Lars Hjemli286c4c02011-02-19 13:55:43 +010015GIT_VER = 1.7.4
Ferry Huberts633a66c2012-11-03 17:49:45 -060016GIT_URL = https://github.com/git/git/archive/v$(GIT_VER).tar.gz
Todd Zullinger4ac89ec2009-01-11 18:23:52 -050017INSTALL = install
Todd Zullinger679f7ef2010-09-06 09:31:22 -040018MAN5_TXT = $(wildcard *.5.txt)
19MAN_TXT = $(MAN5_TXT)
20DOC_MAN5 = $(patsubst %.txt,%,$(MAN5_TXT))
21DOC_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
22DOC_PDF = $(patsubst %.txt,%.pdf,$(MAN_TXT))
Lars Hjemli9ecde652007-05-14 23:09:49 +020023
Ramsay Jones97fdac12008-11-15 18:26:32 +000024# Define NO_STRCASESTR if you don't have strcasestr.
25#
Mikhail Gusarov59310ab2009-10-29 03:39:55 +060026# Define NO_OPENSSL to disable linking with OpenSSL and use bundled SHA1
27# implementation (slower).
28#
Ramsay Jones97fdac12008-11-15 18:26:32 +000029# Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin).
30#
Mark Lodatoe4ddc8f2010-09-04 11:30:18 -040031# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
32# do not support the 'size specifiers' introduced by C99, namely ll, hh,
33# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
34# some C compilers supported these specifiers prior to C99 as an extension.
35#
Ramsay Jones97fdac12008-11-15 18:26:32 +000036
37#-include config.mak
38
39#
40# Platform specific tweaks
41#
42
43uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
44uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
45uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
46
47ifeq ($(uname_O),Cygwin)
48 NO_STRCASESTR = YesPlease
49 NEEDS_LIBICONV = YesPlease
50endif
51
Jason A. Donenfelda58d8a12012-10-17 21:55:48 +020052ifeq ($(uname_S),$(filter $(uname_S),FreeBSD OpenBSD))
53 # Apparantly libiconv is installed in /usr/local on BSD
Jason A. Donenfeld28536922012-10-17 18:30:08 +020054 LDFLAGS ?= -L/usr/local/lib
55 CFLAGS ?= -I/usr/local/include
56 NEEDS_LIBICONV = yes
57endif
58
Lars Hjemlic60781d2008-03-25 01:41:10 +010059#
Lars Hjemlia5e899e2008-12-05 18:47:16 +010060# Let the user override the above settings.
61#
62-include cgit.conf
63
64#
Lars Hjemlic60781d2008-03-25 01:41:10 +010065# Define a way to invoke make in subdirs quietly, shamelessly ripped
66# from git.git
67#
68QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
69QUIET_SUBDIR1 =
70
71ifneq ($(findstring $(MAKEFLAGS),w),w)
72PRINT_DIR = --no-print-directory
73else # "make -w"
74NO_SUBDIR = :
75endif
76
77ifndef V
78 QUIET_CC = @echo ' ' CC $@;
79 QUIET_MM = @echo ' ' MM $@;
80 QUIET_SUBDIR0 = +@subdir=
81 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
82 $(MAKE) $(PRINT_DIR) -C $$subdir
Jamie Couture6419c9b2012-10-08 13:12:17 -040083 QUIET_TAGS = @echo ' ' TAGS $@;
Lars Hjemlic60781d2008-03-25 01:41:10 +010084endif
Lars Hjemlif6925032007-06-18 09:42:10 +020085
Lars Hjemlidf90b512008-03-24 23:01:44 +010086#
87# Define a pattern rule for automatic dependency building
88#
89%.d: %.c
Lars Hjemli5807fb72010-11-07 16:13:49 +010090 $(QUIET_MM)$(CC) $(CFLAGS) -MM -MP $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@
Lars Hjemlic60781d2008-03-25 01:41:10 +010091
92#
93# Define a pattern rule for silent object building
94#
95%.o: %.c
96 $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $<
Lars Hjemlidf90b512008-03-24 23:01:44 +010097
Lars Hjemlif6925032007-06-18 09:42:10 +020098
Lars Hjemli6d7552b2010-08-22 13:29:57 +020099EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lpthread
Lars Hjemli27181862008-03-24 20:49:41 +0100100OBJECTS =
101OBJECTS += cache.o
102OBJECTS += cgit.o
103OBJECTS += cmd.o
Lars Hjemli20a33542008-03-28 00:09:11 +0100104OBJECTS += configfile.o
Lars Hjemli27181862008-03-24 20:49:41 +0100105OBJECTS += html.o
106OBJECTS += parsing.o
Lars Hjemli93397a72008-09-15 00:07:12 +0200107OBJECTS += scan-tree.o
Lars Hjemli27181862008-03-24 20:49:41 +0100108OBJECTS += shared.o
Lars Hjemlib2a3d312008-05-21 08:17:54 +0200109OBJECTS += ui-atom.o
Lars Hjemli27181862008-03-24 20:49:41 +0100110OBJECTS += ui-blob.o
Lars Hjemli02a545e2008-08-06 01:20:24 +0200111OBJECTS += ui-clone.o
Lars Hjemli27181862008-03-24 20:49:41 +0100112OBJECTS += ui-commit.o
113OBJECTS += ui-diff.o
114OBJECTS += ui-log.o
115OBJECTS += ui-patch.o
Lars Hjemlie5da4bc2008-08-06 10:53:50 +0200116OBJECTS += ui-plain.o
Lars Hjemli27181862008-03-24 20:49:41 +0100117OBJECTS += ui-refs.o
118OBJECTS += ui-repolist.o
119OBJECTS += ui-shared.o
120OBJECTS += ui-snapshot.o
Ragnar Ouchterlony40e174d2009-09-13 19:36:35 +0200121OBJECTS += ui-ssdiff.o
Lars Hjemlif86a23f2008-12-06 17:38:19 +0100122OBJECTS += ui-stats.o
Lars Hjemli27181862008-03-24 20:49:41 +0100123OBJECTS += ui-summary.o
124OBJECTS += ui-tag.o
125OBJECTS += ui-tree.o
Lars Hjemli958a95b2010-11-09 19:57:18 +0100126OBJECTS += vector.o
Lars Hjemli0d169ad2006-12-09 15:18:17 +0100127
Lars Hjemli1ae41a02007-11-06 09:35:07 +0100128ifdef NEEDS_LIBICONV
129 EXTLIBS += -liconv
130endif
131
132
Lars Hjemli5e57cb22009-02-12 10:53:31 +0100133.PHONY: all libgit test install uninstall clean force-version get-git \
Todd Zullinger0c3130d2010-09-06 09:31:23 -0400134 doc clean-doc install-doc install-man install-html install-pdf \
Jamie Couture6419c9b2012-10-08 13:12:17 -0400135 uninstall-doc uninstall-man uninstall-html uninstall-pdf tags
Lars Hjemli447025f2007-01-17 01:13:05 +0100136
Lars Hjemlibb7485e2008-07-22 19:30:06 +0200137all: cgit
Lars Hjemlie8920b52007-09-03 21:52:14 +0200138
139VERSION: force-version
140 @./gen-version.sh "$(CGIT_VERSION)"
141-include VERSION
142
143
144CFLAGS += -g -Wall -Igit
Lars Hjemli9ecde652007-05-14 23:09:49 +0200145CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)'
146CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"'
Lars Hjemli152c5e22007-09-08 18:38:10 +0200147CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"'
Lars Hjemliea2831f2007-05-15 00:48:31 +0200148CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"'
Lars Hjemli152c5e22007-09-08 18:38:10 +0200149CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"'
Lars Hjemli61c3ca92007-05-08 22:40:59 +0200150
Lars Hjemli53f487d2010-11-09 18:08:38 +0100151GIT_OPTIONS = prefix=/usr
152
Lars Hjemliefaccb32008-10-11 20:21:06 +0200153ifdef NO_ICONV
154 CFLAGS += -DNO_ICONV
155endif
Ramsay Jones97fdac12008-11-15 18:26:32 +0000156ifdef NO_STRCASESTR
157 CFLAGS += -DNO_STRCASESTR
158endif
Mark Lodatoe4ddc8f2010-09-04 11:30:18 -0400159ifdef NO_C99_FORMAT
160 CFLAGS += -DNO_C99_FORMAT
161endif
Mikhail Gusarov59310ab2009-10-29 03:39:55 +0600162ifdef NO_OPENSSL
163 CFLAGS += -DNO_OPENSSL
164 GIT_OPTIONS += NO_OPENSSL=1
165else
166 EXTLIBS += -lcrypto
167endif
Lars Hjemlicc1dbd12007-05-10 11:25:12 +0200168
Lars Hjemli8c2a1362008-08-06 18:52:27 +0200169cgit: $(OBJECTS) libgit
Harley Laue06e14dc2008-09-18 21:06:18 -0500170 $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS)
Lars Hjemlicc1dbd12007-05-10 11:25:12 +0200171
Lars Hjemli92908af2008-03-24 23:10:59 +0100172cgit.o: VERSION
Lars Hjemlicc1dbd12007-05-10 11:25:12 +0200173
Lynn Linab610292010-07-15 14:38:06 +0800174ifneq "$(MAKECMDGOALS)" "clean"
175 -include $(OBJECTS:.o=.d)
176endif
Lars Hjemlicc1dbd12007-05-10 11:25:12 +0200177
Lars Hjemli8c2a1362008-08-06 18:52:27 +0200178libgit:
Mikhail Gusarov59310ab2009-10-29 03:39:55 +0600179 $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) libgit.a
180 $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) xdiff/lib.a
Lars Hjemlia1266ed2008-08-01 01:25:51 +0200181
Lars Hjemlib4649fc2007-11-11 00:40:58 +0100182test: all
Lars Hjemlic60781d2008-03-25 01:41:10 +0100183 $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all
Lars Hjemlib4649fc2007-11-11 00:40:58 +0100184
Lars Hjemlie8920b52007-09-03 21:52:14 +0200185install: all
Todd Zullinger4ac89ec2009-01-11 18:23:52 -0500186 $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_SCRIPT_PATH)
187 $(INSTALL) -m 0755 cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
Todd Zullingerd529c6f2009-01-11 18:23:59 -0500188 $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_DATA_PATH)
189 $(INSTALL) -m 0644 cgit.css $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css
190 $(INSTALL) -m 0644 cgit.png $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png
Todd Zullinger6d10c132010-09-06 09:31:24 -0400191 $(INSTALL) -m 0755 -d $(DESTDIR)$(filterdir)
192 $(INSTALL) -m 0755 filters/* $(DESTDIR)$(filterdir)
Lars Hjemlicc1dbd12007-05-10 11:25:12 +0200193
Todd Zullinger0c3130d2010-09-06 09:31:23 -0400194install-doc: install-man install-html install-pdf
195
196install-man: doc-man
197 $(INSTALL) -m 0755 -d $(DESTDIR)$(mandir)/man5
198 $(INSTALL) -m 0644 $(DOC_MAN5) $(DESTDIR)$(mandir)/man5
199
200install-html: doc-html
201 $(INSTALL) -m 0755 -d $(DESTDIR)$(htmldir)
202 $(INSTALL) -m 0644 $(DOC_HTML) $(DESTDIR)$(htmldir)
203
204install-pdf: doc-pdf
205 $(INSTALL) -m 0755 -d $(DESTDIR)$(pdfdir)
206 $(INSTALL) -m 0644 $(DOC_PDF) $(DESTDIR)$(pdfdir)
Lars Hjemlicc1dbd12007-05-10 11:25:12 +0200207
Lars Hjemlie8920b52007-09-03 21:52:14 +0200208uninstall:
Ferry Huberts96f05012011-07-18 12:45:56 +0200209 rm -f $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
210 rm -f $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css
211 rm -f $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png
Lars Hjemlicc1dbd12007-05-10 11:25:12 +0200212
Todd Zullinger0c3130d2010-09-06 09:31:23 -0400213uninstall-doc: uninstall-man uninstall-html uninstall-pdf
Lars Hjemli5e57cb22009-02-12 10:53:31 +0100214
Todd Zullinger0c3130d2010-09-06 09:31:23 -0400215uninstall-man:
216 @for i in $(DOC_MAN5); do \
217 rm -fv $(DESTDIR)$(mandir)/man5/$$i; \
218 done
Lars Hjemli5e57cb22009-02-12 10:53:31 +0100219
Todd Zullinger0c3130d2010-09-06 09:31:23 -0400220uninstall-html:
221 @for i in $(DOC_HTML); do \
222 rm -fv $(DESTDIR)$(htmldir)/$$i; \
223 done
Lars Hjemli5e57cb22009-02-12 10:53:31 +0100224
Todd Zullinger0c3130d2010-09-06 09:31:23 -0400225uninstall-pdf:
226 @for i in $(DOC_PDF); do \
227 rm -fv $(DESTDIR)$(pdfdir)/$$i; \
228 done
229
Todd Zullinger679f7ef2010-09-06 09:31:22 -0400230doc: doc-man doc-html doc-pdf
231doc-man: doc-man5
232doc-man5: $(DOC_MAN5)
233doc-html: $(DOC_HTML)
234doc-pdf: $(DOC_PDF)
Lars Hjemli5e57cb22009-02-12 10:53:31 +0100235
Todd Zullinger679f7ef2010-09-06 09:31:22 -0400236%.5 : %.5.txt
237 a2x -f manpage $<
Lars Hjemli5e57cb22009-02-12 10:53:31 +0100238
Todd Zullinger679f7ef2010-09-06 09:31:22 -0400239$(DOC_HTML): %.html : %.txt
240 a2x -f xhtml --stylesheet=cgit-doc.css $<
Lars Hjemli5e57cb22009-02-12 10:53:31 +0100241
Todd Zullinger679f7ef2010-09-06 09:31:22 -0400242$(DOC_PDF): %.pdf : %.txt
Lars Hjemli5e57cb22009-02-12 10:53:31 +0100243 a2x -f pdf cgitrc.5.txt
244
245clean: clean-doc
Jamie Couture2b675d22012-10-31 19:43:12 -0400246 rm -f cgit VERSION *.o *.d tags
Lars Hjemlicc1dbd12007-05-10 11:25:12 +0200247
Lars Hjemli5e57cb22009-02-12 10:53:31 +0100248clean-doc:
Lars Hjemli290c2a72009-03-15 09:27:54 +0100249 rm -f cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo
Lars Hjemli5e57cb22009-02-12 10:53:31 +0100250
Lars Hjemli95eaf272007-09-03 22:42:54 +0200251get-git:
Ferry Huberts633a66c2012-11-03 17:49:45 -0600252 curl -L $(GIT_URL) | tar -xzf - && rm -rf git && mv git-$(GIT_VER) git
Jamie Couture6419c9b2012-10-08 13:12:17 -0400253
254tags:
255 $(QUIET_TAGS)find . -name '*.[ch]' | xargs ctags