Makefile (view raw)
1CGIT_VERSION = 0.4
2
3prefix = /var/www/htdocs/cgit
4
5SHA1_HEADER = <openssl/sha.h>
6CACHE_ROOT = /var/cache/cgit
7CGIT_CONFIG = /etc/cgitrc
8CGIT_SCRIPT_NAME = cgit.cgi
9
10EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto
11OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \
12 ui-summary.o ui-log.o ui-view.o ui-tree.o ui-commit.o ui-diff.o \
13 ui-snapshot.o ui-blob.o
14
15CFLAGS += -Wall
16
17ifdef DEBUG
18 CFLAGS += -g
19endif
20
21CFLAGS += -Igit
22CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)'
23CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"'
24CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"'
25CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"'
26
27
28#
29# If make is run on a nongit platform, we need to get the git sources as a tarball.
30# But there is currently no recent enough tarball available on kernel.org, so download
31# a zipfile from hjemli.net instead
32#
33GITVER = $(shell git version 2>/dev/null || echo nogit)
34ifeq ($(GITVER),nogit)
35GITURL = http://hjemli.net/git/git/snapshot/?id=v1.5.2-rc2
36INITGIT = test -e git/git.c || (curl "$(GITURL)" > tmp.zip && unzip tmp.zip)
37else
38INITGIT = ./submodules.sh -i
39endif
40
41
42#
43# basic build rules
44#
45all: cgit
46
47cgit: cgit.c cgit.h $(OBJECTS)
48 $(CC) $(CFLAGS) cgit.c -o cgit $(OBJECTS) $(EXTLIBS)
49
50$(OBJECTS): cgit.h git/libgit.a
51
52git/libgit.a:
53 $(INITGIT)
54 $(MAKE) -C git
55
56#
57# phony targets
58#
59install: all clean-cache
60 mkdir -p $(prefix)
61 install cgit $(prefix)/$(CGIT_SCRIPT_NAME)
62 install cgit.css $(prefix)/cgit.css
63
64clean-cgit:
65 rm -f cgit *.o
66
67distclean-cgit: clean-cgit
68 git clean -d -x
69
70clean-sub:
71 $(MAKE) -C git clean
72
73distclean-sub: clean-sub
74 $(shell cd git && git clean -d -x)
75
76clean-cache:
77 rm -rf $(CACHE_ROOT)/*
78
79clean: clean-cgit clean-sub
80
81distclean: distclean-cgit distclean-sub
82
83.PHONY: all install clean clean-cgit clean-sub clean-cache \
84 distclean distclean-cgit distclean-sub