]> git.cameronkatri.com Git - cgit.git/blob - Makefile
Generalize doc generation
[cgit.git] / 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 SHA1_HEADER = <openssl/sha.h>
8 GIT_VER = 1.7.3
9 GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
10 INSTALL = install
11 MAN5_TXT = $(wildcard *.5.txt)
12 MAN_TXT = $(MAN5_TXT)
13 DOC_MAN5 = $(patsubst %.txt,%,$(MAN5_TXT))
14 DOC_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
15 DOC_PDF = $(patsubst %.txt,%.pdf,$(MAN_TXT))
16
17 # Define NO_STRCASESTR if you don't have strcasestr.
18 #
19 # Define NO_OPENSSL to disable linking with OpenSSL and use bundled SHA1
20 # implementation (slower).
21 #
22 # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin).
23 #
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.
28 #
29
30 #-include config.mak
31
32 #
33 # Platform specific tweaks
34 #
35
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')
39
40 ifeq ($(uname_O),Cygwin)
41 NO_STRCASESTR = YesPlease
42 NEEDS_LIBICONV = YesPlease
43 endif
44
45 #
46 # Let the user override the above settings.
47 #
48 -include cgit.conf
49
50 #
51 # Define a way to invoke make in subdirs quietly, shamelessly ripped
52 # from git.git
53 #
54 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
55 QUIET_SUBDIR1 =
56
57 ifneq ($(findstring $(MAKEFLAGS),w),w)
58 PRINT_DIR = --no-print-directory
59 else # "make -w"
60 NO_SUBDIR = :
61 endif
62
63 ifndef V
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
69 endif
70
71 #
72 # Define a pattern rule for automatic dependency building
73 #
74 %.d: %.c
75 $(QUIET_MM)$(CC) $(CFLAGS) -MM $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@
76
77 #
78 # Define a pattern rule for silent object building
79 #
80 %.o: %.c
81 $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $<
82
83
84 EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lpthread
85 OBJECTS =
86 OBJECTS += cache.o
87 OBJECTS += cgit.o
88 OBJECTS += cmd.o
89 OBJECTS += configfile.o
90 OBJECTS += html.o
91 OBJECTS += parsing.o
92 OBJECTS += scan-tree.o
93 OBJECTS += shared.o
94 OBJECTS += ui-atom.o
95 OBJECTS += ui-blob.o
96 OBJECTS += ui-clone.o
97 OBJECTS += ui-commit.o
98 OBJECTS += ui-diff.o
99 OBJECTS += ui-log.o
100 OBJECTS += ui-patch.o
101 OBJECTS += ui-plain.o
102 OBJECTS += ui-refs.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
109 OBJECTS += ui-tag.o
110 OBJECTS += ui-tree.o
111
112 ifdef NEEDS_LIBICONV
113 EXTLIBS += -liconv
114 endif
115
116
117 .PHONY: all libgit test install uninstall clean force-version get-git \
118 doc clean-doc
119
120 all: cgit
121
122 VERSION: force-version
123 @./gen-version.sh "$(CGIT_VERSION)"
124 -include VERSION
125
126
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)"'
133
134 ifdef NO_ICONV
135 CFLAGS += -DNO_ICONV
136 endif
137 ifdef NO_STRCASESTR
138 CFLAGS += -DNO_STRCASESTR
139 endif
140 ifdef NO_C99_FORMAT
141 CFLAGS += -DNO_C99_FORMAT
142 endif
143 ifdef NO_OPENSSL
144 CFLAGS += -DNO_OPENSSL
145 GIT_OPTIONS += NO_OPENSSL=1
146 else
147 EXTLIBS += -lcrypto
148 endif
149
150 cgit: $(OBJECTS) libgit
151 $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS)
152
153 cgit.o: VERSION
154
155 ifneq "$(MAKECMDGOALS)" "clean"
156 -include $(OBJECTS:.o=.d)
157 endif
158
159 libgit:
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
162
163 test: all
164 $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all
165
166 install: 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
172
173 uninstall:
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
177
178 doc: doc-man doc-html doc-pdf
179 doc-man: doc-man5
180 doc-man5: $(DOC_MAN5)
181 doc-html: $(DOC_HTML)
182 doc-pdf: $(DOC_PDF)
183
184 %.5 : %.5.txt
185 a2x -f manpage $<
186
187 $(DOC_HTML): %.html : %.txt
188 a2x -f xhtml --stylesheet=cgit-doc.css $<
189
190 $(DOC_PDF): %.pdf : %.txt
191 a2x -f pdf cgitrc.5.txt
192
193 clean: clean-doc
194 rm -f cgit VERSION *.o *.d
195
196 clean-doc:
197 rm -f cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo
198
199 get-git:
200 curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git