]> gitweb.ps.run Git - ps-cgit/blob - Makefile
Don't hardcode urls when SCRIPT_NAME is available
[ps-cgit] / Makefile
1 CGIT_VERSION = 0.4
2
3 prefix = /var/www/htdocs/cgit
4
5 SHA1_HEADER = <openssl/sha.h>
6 CACHE_ROOT = /var/cache/cgit
7 CGIT_CONFIG = /etc/cgitrc
8 CGIT_SCRIPT_NAME = cgit.cgi
9
10 EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto
11 OBJECTS = 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
15 CFLAGS += -Wall
16
17 ifdef DEBUG
18         CFLAGS += -g
19 endif
20
21 CFLAGS += -Igit
22 CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)'
23 CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"'
24 CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"'
25 CFLAGS += -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 #
33 GITVER = $(shell git version 2>/dev/null || echo nogit)
34 ifeq ($(GITVER),nogit)
35 GITURL = http://hjemli.net/git/git/snapshot/?id=v1.5.2-rc2
36 INITGIT = test -e git/git.c || (curl "$(GITURL)" > tmp.zip && unzip tmp.zip)
37 else
38 INITGIT = ./submodules.sh -i
39 endif
40
41
42 #
43 # basic build rules
44 #
45 all: cgit
46
47 cgit: cgit.c cgit.h $(OBJECTS)
48         $(CC) $(CFLAGS) cgit.c -o cgit $(OBJECTS) $(EXTLIBS)
49
50 $(OBJECTS): cgit.h git/libgit.a
51
52 git/libgit.a:
53         $(INITGIT)
54         $(MAKE) -C git
55
56 #
57 # phony targets
58 #
59 install: all clean-cache
60         mkdir -p $(prefix)
61         install cgit $(prefix)/$(CGIT_SCRIPT_NAME)
62         install cgit.css $(prefix)/cgit.css
63         install add.png del.png $(prefix)/
64
65 clean-cgit:
66         rm -f cgit *.o
67
68 distclean-cgit: clean-cgit
69         git clean -d -x
70
71 clean-sub:
72         $(MAKE) -C git clean
73
74 distclean-sub: clean-sub
75         $(shell cd git && git clean -d -x)
76
77 clean-cache:
78         rm -rf $(CACHE_ROOT)/*
79
80 clean: clean-cgit clean-sub
81
82 distclean: distclean-cgit distclean-sub
83
84 .PHONY: all install clean clean-cgit clean-sub clean-cache \
85         distclean distclean-cgit distclean-sub