diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 152 |
1 files changed, 82 insertions, 70 deletions
@@ -1,3 +1,5 @@ | |||
1 | all:: | ||
2 | |||
1 | CGIT_VERSION = v0.9.1 | 3 | CGIT_VERSION = v0.9.1 |
2 | CGIT_SCRIPT_NAME = cgit.cgi | 4 | CGIT_SCRIPT_NAME = cgit.cgi |
3 | CGIT_SCRIPT_PATH = /var/www/htdocs/cgit | 5 | CGIT_SCRIPT_PATH = /var/www/htdocs/cgit |
@@ -12,8 +14,8 @@ htmldir = $(docdir) | |||
12 | pdfdir = $(docdir) | 14 | pdfdir = $(docdir) |
13 | mandir = $(prefix)/share/man | 15 | mandir = $(prefix)/share/man |
14 | SHA1_HEADER = <openssl/sha.h> | 16 | SHA1_HEADER = <openssl/sha.h> |
15 | GIT_VER = 1.7.4 | 17 | GIT_VER = 1.7.12.4 |
16 | GIT_URL = https://github.com/git/git/archive/v$(GIT_VER).tar.gz | 18 | GIT_URL = https://git-core.googlecode.com/files/git-$(GIT_VER).tar.gz |
17 | INSTALL = install | 19 | INSTALL = install |
18 | MAN5_TXT = $(wildcard *.5.txt) | 20 | MAN5_TXT = $(wildcard *.5.txt) |
19 | MAN_TXT = $(MAN5_TXT) | 21 | MAN_TXT = $(MAN5_TXT) |
@@ -40,22 +42,14 @@ DOC_PDF = $(patsubst %.txt,%.pdf,$(MAN_TXT)) | |||
40 | # Platform specific tweaks | 42 | # Platform specific tweaks |
41 | # | 43 | # |
42 | 44 | ||
45 | VERSION: force-version | ||
46 | @./gen-version.sh "$(CGIT_VERSION)" | ||
47 | -include VERSION | ||
48 | |||
43 | uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') | 49 | uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') |
44 | uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not') | 50 | uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not') |
45 | uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not') | 51 | uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not') |
46 | 52 | ||
47 | ifeq ($(uname_O),Cygwin) | ||
48 | NO_STRCASESTR = YesPlease | ||
49 | NEEDS_LIBICONV = YesPlease | ||
50 | endif | ||
51 | |||
52 | ifeq ($(uname_S),$(filter $(uname_S),FreeBSD OpenBSD)) | ||
53 | # Apparantly libiconv is installed in /usr/local on BSD | ||
54 | LDFLAGS ?= -L/usr/local/lib | ||
55 | CFLAGS ?= -I/usr/local/include | ||
56 | NEEDS_LIBICONV = yes | ||
57 | endif | ||
58 | |||
59 | # | 53 | # |
60 | # Let the user override the above settings. | 54 | # Let the user override the above settings. |
61 | # | 55 | # |
@@ -76,30 +70,62 @@ endif | |||
76 | 70 | ||
77 | ifndef V | 71 | ifndef V |
78 | QUIET_CC = @echo ' ' CC $@; | 72 | QUIET_CC = @echo ' ' CC $@; |
79 | QUIET_MM = @echo ' ' MM $@; | 73 | QUIET_LINK = @echo ' ' LINK $@; |
80 | QUIET_SUBDIR0 = +@subdir= | 74 | QUIET_SUBDIR0 = +@subdir= |
81 | QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ | 75 | QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ |
82 | $(MAKE) $(PRINT_DIR) -C $$subdir | 76 | $(MAKE) $(PRINT_DIR) -C $$subdir |
83 | QUIET_TAGS = @echo ' ' TAGS $@; | 77 | QUIET_TAGS = @echo ' ' TAGS $@; |
78 | export V | ||
84 | endif | 79 | endif |
85 | 80 | ||
86 | # | 81 | LDFLAGS ?= |
87 | # Define a pattern rule for automatic dependency building | 82 | CFLAGS ?= -g -Wall |
88 | # | 83 | CFLAGS += -Igit |
89 | %.d: %.c | 84 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' |
90 | $(QUIET_MM)$(CC) $(CFLAGS) -MM -MP $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@ | 85 | CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' |
86 | CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' | ||
87 | CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' | ||
88 | CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' | ||
91 | 89 | ||
92 | # | 90 | ifeq ($(uname_O),Cygwin) |
93 | # Define a pattern rule for silent object building | 91 | NO_STRCASESTR = YesPlease |
94 | # | 92 | NEEDS_LIBICONV = YesPlease |
95 | %.o: %.c | 93 | endif |
96 | $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $< | ||
97 | 94 | ||
95 | ifeq ($(uname_S),$(filter $(uname_S),FreeBSD OpenBSD)) | ||
96 | # Apparantly libiconv is installed in /usr/local on BSD | ||
97 | LDFLAGS += -L/usr/local/lib | ||
98 | CFLAGS += -I/usr/local/include | ||
99 | NEEDS_LIBICONV = yes | ||
100 | endif | ||
98 | 101 | ||
99 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lpthread | 102 | GIT_OPTIONS = prefix=/usr |
100 | OBJECTS = | 103 | OBJECTS = |
101 | OBJECTS += cache.o | 104 | |
105 | ifdef NO_ICONV | ||
106 | CFLAGS += -DNO_ICONV | ||
107 | endif | ||
108 | ifdef NO_STRCASESTR | ||
109 | CFLAGS += -DNO_STRCASESTR | ||
110 | endif | ||
111 | ifdef NO_C99_FORMAT | ||
112 | CFLAGS += -DNO_C99_FORMAT | ||
113 | endif | ||
114 | ifdef NO_OPENSSL | ||
115 | CFLAGS += -DNO_OPENSSL | ||
116 | GIT_OPTIONS += NO_OPENSSL=1 | ||
117 | else | ||
118 | LDLIBS += -lcrypto | ||
119 | endif | ||
120 | |||
121 | ifdef NEEDS_LIBICONV | ||
122 | LDLIBS += -liconv | ||
123 | endif | ||
124 | |||
125 | LDLIBS += git/libgit.a git/xdiff/lib.a -lz -lpthread | ||
126 | |||
102 | OBJECTS += cgit.o | 127 | OBJECTS += cgit.o |
128 | OBJECTS += cache.o | ||
103 | OBJECTS += cmd.o | 129 | OBJECTS += cmd.o |
104 | OBJECTS += configfile.o | 130 | OBJECTS += configfile.o |
105 | OBJECTS += html.o | 131 | OBJECTS += html.o |
@@ -125,55 +151,30 @@ OBJECTS += ui-tag.o | |||
125 | OBJECTS += ui-tree.o | 151 | OBJECTS += ui-tree.o |
126 | OBJECTS += vector.o | 152 | OBJECTS += vector.o |
127 | 153 | ||
128 | ifdef NEEDS_LIBICONV | 154 | dep_files := $(foreach f,$(OBJECTS),$(dir $f).deps/$(notdir $f).d) |
129 | EXTLIBS += -liconv | 155 | dep_dirs := $(addsuffix .deps,$(sort $(dir $OBJECTS))) |
130 | endif | ||
131 | 156 | ||
157 | $(dep_dirs): | ||
158 | @mkdir -p $@ | ||
132 | 159 | ||
133 | .PHONY: all libgit test install uninstall clean force-version get-git \ | 160 | missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs)) |
134 | doc clean-doc install-doc install-man install-html install-pdf \ | 161 | dep_file = $(dir $@).deps/$(notdir $@).d |
135 | uninstall-doc uninstall-man uninstall-html uninstall-pdf tags | 162 | dep_args = -MF $(dep_file) -MMD -MP |
136 | 163 | ||
137 | all: cgit | 164 | .SUFFIXES: |
138 | 165 | ||
139 | VERSION: force-version | 166 | $(OBJECTS): %.o: %.c $(missing_dep_dirs) |
140 | @./gen-version.sh "$(CGIT_VERSION)" | 167 | $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(CFLAGS) $< |
141 | -include VERSION | ||
142 | 168 | ||
143 | 169 | dep_files_present := $(wildcard $(dep_files)) | |
144 | CFLAGS += -g -Wall -Igit | 170 | ifneq ($(dep_files_present),) |
145 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' | 171 | include $(dep_files_present) |
146 | CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' | ||
147 | CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' | ||
148 | CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' | ||
149 | CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' | ||
150 | |||
151 | GIT_OPTIONS = prefix=/usr | ||
152 | |||
153 | ifdef NO_ICONV | ||
154 | CFLAGS += -DNO_ICONV | ||
155 | endif | 172 | endif |
156 | ifdef NO_STRCASESTR | ||
157 | CFLAGS += -DNO_STRCASESTR | ||
158 | endif | ||
159 | ifdef NO_C99_FORMAT | ||
160 | CFLAGS += -DNO_C99_FORMAT | ||
161 | endif | ||
162 | ifdef NO_OPENSSL | ||
163 | CFLAGS += -DNO_OPENSSL | ||
164 | GIT_OPTIONS += NO_OPENSSL=1 | ||
165 | else | ||
166 | EXTLIBS += -lcrypto | ||
167 | endif | ||
168 | |||
169 | cgit: $(OBJECTS) libgit | ||
170 | $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS) | ||
171 | 173 | ||
172 | cgit.o: VERSION | 174 | all:: cgit |
173 | 175 | ||
174 | ifneq "$(MAKECMDGOALS)" "clean" | 176 | cgit: VERSION $(OBJECTS) libgit |
175 | -include $(OBJECTS:.o=.d) | 177 | $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) $(LDLIBS) |
176 | endif | ||
177 | 178 | ||
178 | libgit: | 179 | libgit: |
179 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) libgit.a | 180 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) libgit.a |
@@ -243,13 +244,24 @@ $(DOC_PDF): %.pdf : %.txt | |||
243 | a2x -f pdf cgitrc.5.txt | 244 | a2x -f pdf cgitrc.5.txt |
244 | 245 | ||
245 | clean: clean-doc | 246 | clean: clean-doc |
246 | rm -f cgit VERSION *.o *.d tags | 247 | $(RM) cgit VERSION *.o tags |
248 | $(RM) -r .deps | ||
249 | |||
250 | cleanall: clean | ||
251 | $(MAKE) -C git clean | ||
247 | 252 | ||
248 | clean-doc: | 253 | clean-doc: |
249 | rm -f cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo | 254 | $(RM) cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo |
250 | 255 | ||
251 | get-git: | 256 | get-git: |
252 | curl -L $(GIT_URL) | tar -xzf - && rm -rf git && mv git-$(GIT_VER) git | 257 | curl -L $(GIT_URL) | tar -xzf - && rm -rf git && mv git-$(GIT_VER) git |
253 | 258 | ||
254 | tags: | 259 | tags: |
255 | $(QUIET_TAGS)find . -name '*.[ch]' | xargs ctags | 260 | $(QUIET_TAGS)find . -name '*.[ch]' | xargs ctags |
261 | |||
262 | .PHONY: all cgit get-git libgit force-version | ||
263 | .PHONY: clean clean-doc cleanall | ||
264 | .PHONY: doc doc-html doc-man doc-pdf | ||
265 | .PHONY: install install-doc install-html install-man install-pdf | ||
266 | .PHONY: tags test | ||
267 | .PHONY: uninstall uninstall-doc uninstall-html uninstall-man uninstall-pdf | ||