]> gitweb.ps.run Git - ps-cgit/blob - Makefile
Add Makefile targets to install/uninstall docs
[ps-cgit] / Makefile
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 prefix = /usr
8 docdir = $(prefix)/share/doc/cgit
9 htmldir = $(docdir)
10 pdfdir = $(docdir)
11 mandir = $(prefix)/share/man
12 SHA1_HEADER = <openssl/sha.h>
13 GIT_VER = 1.7.3
14 GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
15 INSTALL = install
16 MAN5_TXT = $(wildcard *.5.txt)
17 MAN_TXT  = $(MAN5_TXT)
18 DOC_MAN5 = $(patsubst %.txt,%,$(MAN5_TXT))
19 DOC_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
20 DOC_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
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')
44
45 ifeq ($(uname_O),Cygwin)
46         NO_STRCASESTR = YesPlease
47         NEEDS_LIBICONV = YesPlease
48 endif
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 #
59 QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
60 QUIET_SUBDIR1  =
61
62 ifneq ($(findstring $(MAKEFLAGS),w),w)
63 PRINT_DIR = --no-print-directory
64 else # "make -w"
65 NO_SUBDIR = :
66 endif
67
68 ifndef 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
74 endif
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
89 EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lpthread
90 OBJECTS =
91 OBJECTS += cache.o
92 OBJECTS += cgit.o
93 OBJECTS += cmd.o
94 OBJECTS += configfile.o
95 OBJECTS += html.o
96 OBJECTS += parsing.o
97 OBJECTS += scan-tree.o
98 OBJECTS += shared.o
99 OBJECTS += ui-atom.o
100 OBJECTS += ui-blob.o
101 OBJECTS += ui-clone.o
102 OBJECTS += ui-commit.o
103 OBJECTS += ui-diff.o
104 OBJECTS += ui-log.o
105 OBJECTS += ui-patch.o
106 OBJECTS += ui-plain.o
107 OBJECTS += ui-refs.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
114 OBJECTS += ui-tag.o
115 OBJECTS += ui-tree.o
116
117 ifdef NEEDS_LIBICONV
118         EXTLIBS += -liconv
119 endif
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
126 all: cgit
127
128 VERSION: force-version
129         @./gen-version.sh "$(CGIT_VERSION)"
130 -include VERSION
131
132
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)"'
139
140 ifdef NO_ICONV
141         CFLAGS += -DNO_ICONV
142 endif
143 ifdef NO_STRCASESTR
144         CFLAGS += -DNO_STRCASESTR
145 endif
146 ifdef NO_C99_FORMAT
147         CFLAGS += -DNO_C99_FORMAT
148 endif
149 ifdef NO_OPENSSL
150         CFLAGS += -DNO_OPENSSL
151         GIT_OPTIONS += NO_OPENSSL=1
152 else
153         EXTLIBS += -lcrypto
154 endif
155
156 cgit: $(OBJECTS) libgit
157         $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS)
158
159 cgit.o: VERSION
160
161 ifneq "$(MAKECMDGOALS)" "clean"
162   -include $(OBJECTS:.o=.d)
163 endif
164
165 libgit:
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
169 test: all
170         $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all
171
172 install: 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
179 install-doc: install-man install-html install-pdf
180
181 install-man: doc-man
182         $(INSTALL) -m 0755 -d $(DESTDIR)$(mandir)/man5
183         $(INSTALL) -m 0644 $(DOC_MAN5) $(DESTDIR)$(mandir)/man5
184
185 install-html: doc-html
186         $(INSTALL) -m 0755 -d $(DESTDIR)$(htmldir)
187         $(INSTALL) -m 0644 $(DOC_HTML) $(DESTDIR)$(htmldir)
188
189 install-pdf: doc-pdf
190         $(INSTALL) -m 0755 -d $(DESTDIR)$(pdfdir)
191         $(INSTALL) -m 0644 $(DOC_PDF) $(DESTDIR)$(pdfdir)
192
193 uninstall:
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
198 uninstall-doc: uninstall-man uninstall-html uninstall-pdf
199
200 uninstall-man:
201         @for i in $(DOC_MAN5); do \
202             rm -fv $(DESTDIR)$(mandir)/man5/$$i; \
203         done
204
205 uninstall-html:
206         @for i in $(DOC_HTML); do \
207             rm -fv $(DESTDIR)$(htmldir)/$$i; \
208         done
209
210 uninstall-pdf:
211         @for i in $(DOC_PDF); do \
212             rm -fv $(DESTDIR)$(pdfdir)/$$i; \
213         done
214
215 doc: doc-man doc-html doc-pdf
216 doc-man: doc-man5
217 doc-man5: $(DOC_MAN5)
218 doc-html: $(DOC_HTML)
219 doc-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
230 clean: clean-doc
231         rm -f cgit VERSION *.o *.d
232
233 clean-doc:
234         rm -f cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo
235
236 get-git:
237         curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git