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