all repos — cgit @ 679f7ef4f3f31dca8c8ac5536c3e18a5188e051a

a hyperfast web frontend for git written in c

Makefile (view raw)

  1CGIT_VERSION = v0.8.3.3
  2CGIT_SCRIPT_NAME = cgit.cgi
  3CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
  4CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
  5CGIT_CONFIG = /etc/cgitrc
  6CACHE_ROOT = /var/cache/cgit
  7SHA1_HEADER = <openssl/sha.h>
  8GIT_VER = 1.7.3
  9GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2
 10INSTALL = install
 11MAN5_TXT = $(wildcard *.5.txt)
 12MAN_TXT  = $(MAN5_TXT)
 13DOC_MAN5 = $(patsubst %.txt,%,$(MAN5_TXT))
 14DOC_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
 15DOC_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
 36uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
 37uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
 38uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
 39
 40ifeq ($(uname_O),Cygwin)
 41	NO_STRCASESTR = YesPlease
 42	NEEDS_LIBICONV = YesPlease
 43endif
 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#
 54QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
 55QUIET_SUBDIR1  =
 56
 57ifneq ($(findstring $(MAKEFLAGS),w),w)
 58PRINT_DIR = --no-print-directory
 59else # "make -w"
 60NO_SUBDIR = :
 61endif
 62
 63ifndef 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
 69endif
 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
 84EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lpthread
 85OBJECTS =
 86OBJECTS += cache.o
 87OBJECTS += cgit.o
 88OBJECTS += cmd.o
 89OBJECTS += configfile.o
 90OBJECTS += html.o
 91OBJECTS += parsing.o
 92OBJECTS += scan-tree.o
 93OBJECTS += shared.o
 94OBJECTS += ui-atom.o
 95OBJECTS += ui-blob.o
 96OBJECTS += ui-clone.o
 97OBJECTS += ui-commit.o
 98OBJECTS += ui-diff.o
 99OBJECTS += ui-log.o
100OBJECTS += ui-patch.o
101OBJECTS += ui-plain.o
102OBJECTS += ui-refs.o
103OBJECTS += ui-repolist.o
104OBJECTS += ui-shared.o
105OBJECTS += ui-snapshot.o
106OBJECTS += ui-ssdiff.o
107OBJECTS += ui-stats.o
108OBJECTS += ui-summary.o
109OBJECTS += ui-tag.o
110OBJECTS += ui-tree.o
111
112ifdef NEEDS_LIBICONV
113	EXTLIBS += -liconv
114endif
115
116
117.PHONY: all libgit test install uninstall clean force-version get-git \
118	doc clean-doc
119
120all: cgit
121
122VERSION: force-version
123	@./gen-version.sh "$(CGIT_VERSION)"
124-include VERSION
125
126
127CFLAGS += -g -Wall -Igit
128CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)'
129CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"'
130CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"'
131CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"'
132CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"'
133
134ifdef NO_ICONV
135	CFLAGS += -DNO_ICONV
136endif
137ifdef NO_STRCASESTR
138	CFLAGS += -DNO_STRCASESTR
139endif
140ifdef NO_C99_FORMAT
141	CFLAGS += -DNO_C99_FORMAT
142endif
143ifdef NO_OPENSSL
144	CFLAGS += -DNO_OPENSSL
145	GIT_OPTIONS += NO_OPENSSL=1
146else
147	EXTLIBS += -lcrypto
148endif
149
150cgit: $(OBJECTS) libgit
151	$(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS)
152
153cgit.o: VERSION
154
155ifneq "$(MAKECMDGOALS)" "clean"
156  -include $(OBJECTS:.o=.d)
157endif
158
159libgit:
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
163test: all
164	$(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all
165
166install: 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
173uninstall:
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
178doc: doc-man doc-html doc-pdf
179doc-man: doc-man5
180doc-man5: $(DOC_MAN5)
181doc-html: $(DOC_HTML)
182doc-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
193clean: clean-doc
194	rm -f cgit VERSION *.o *.d
195
196clean-doc:
197	rm -f cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo
198
199get-git:
200	curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git