diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 124 | ||||
-rw-r--r-- | cgit.mk | 74 |
3 files changed, 80 insertions, 119 deletions
diff --git a/.gitignore b/.gitignore index 487728b..8011b39 100644 --- a/.gitignore +++ b/.gitignore | |||
@@ -1,6 +1,7 @@ | |||
1 | # Files I don't care to see in git-status/commit | 1 | # Files I don't care to see in git-status/commit |
2 | cgit | 2 | cgit |
3 | cgit.conf | 3 | cgit.conf |
4 | CGIT-CFLAGS | ||
4 | VERSION | 5 | VERSION |
5 | cgitrc.5 | 6 | cgitrc.5 |
6 | cgitrc.5.fo | 7 | cgitrc.5.fo |
diff --git a/Makefile b/Makefile index 1127961..8c00190 100644 --- a/Makefile +++ b/Makefile | |||
@@ -23,13 +23,6 @@ DOC_MAN5 = $(patsubst %.txt,%,$(MAN5_TXT)) | |||
23 | DOC_HTML = $(patsubst %.txt,%.html,$(MAN_TXT)) | 23 | DOC_HTML = $(patsubst %.txt,%.html,$(MAN_TXT)) |
24 | DOC_PDF = $(patsubst %.txt,%.pdf,$(MAN_TXT)) | 24 | DOC_PDF = $(patsubst %.txt,%.pdf,$(MAN_TXT)) |
25 | 25 | ||
26 | # Define NO_STRCASESTR if you don't have strcasestr. | ||
27 | # | ||
28 | # Define NO_OPENSSL to disable linking with OpenSSL and use bundled SHA1 | ||
29 | # implementation (slower). | ||
30 | # | ||
31 | # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). | ||
32 | # | ||
33 | # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.) | 26 | # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.) |
34 | # do not support the 'size specifiers' introduced by C99, namely ll, hh, | 27 | # do not support the 'size specifiers' introduced by C99, namely ll, hh, |
35 | # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t). | 28 | # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t). |
@@ -39,22 +32,12 @@ DOC_PDF = $(patsubst %.txt,%.pdf,$(MAN_TXT)) | |||
39 | #-include config.mak | 32 | #-include config.mak |
40 | 33 | ||
41 | # | 34 | # |
42 | # Platform specific tweaks | ||
43 | # | ||
44 | |||
45 | VERSION: force-version | ||
46 | @./gen-version.sh "$(CGIT_VERSION)" | ||
47 | -include VERSION | ||
48 | |||
49 | uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') | ||
50 | uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not') | ||
51 | uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not') | ||
52 | |||
53 | # | ||
54 | # Let the user override the above settings. | 35 | # Let the user override the above settings. |
55 | # | 36 | # |
56 | -include cgit.conf | 37 | -include cgit.conf |
57 | 38 | ||
39 | export CGIT_SCRIPT_NAME CGIT_SCRIPT_PATH CGIT_DATA_PATH CGIT_CONFIG CACHE_ROOT | ||
40 | |||
58 | # | 41 | # |
59 | # Define a way to invoke make in subdirs quietly, shamelessly ripped | 42 | # Define a way to invoke make in subdirs quietly, shamelessly ripped |
60 | # from git.git | 43 | # from git.git |
@@ -69,8 +52,6 @@ NO_SUBDIR = : | |||
69 | endif | 52 | endif |
70 | 53 | ||
71 | ifndef V | 54 | ifndef V |
72 | QUIET_CC = @echo ' ' CC $@; | ||
73 | QUIET_LINK = @echo ' ' LINK $@; | ||
74 | QUIET_SUBDIR0 = +@subdir= | 55 | QUIET_SUBDIR0 = +@subdir= |
75 | QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ | 56 | QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ |
76 | $(MAKE) $(PRINT_DIR) -C $$subdir | 57 | $(MAKE) $(PRINT_DIR) -C $$subdir |
@@ -78,107 +59,12 @@ ifndef V | |||
78 | export V | 59 | export V |
79 | endif | 60 | endif |
80 | 61 | ||
81 | LDFLAGS ?= | ||
82 | CFLAGS ?= -g -Wall | ||
83 | CFLAGS += -Igit | ||
84 | CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' | ||
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)"' | ||
89 | |||
90 | ifeq ($(uname_O),Cygwin) | ||
91 | NO_STRCASESTR = YesPlease | ||
92 | NEEDS_LIBICONV = YesPlease | ||
93 | endif | ||
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 | ||
101 | |||
102 | GIT_OPTIONS = prefix=/usr NO_GETTEXT=1 | ||
103 | OBJECTS = | ||
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 | |||
127 | OBJECTS += cgit.o | ||
128 | OBJECTS += cache.o | ||
129 | OBJECTS += cmd.o | ||
130 | OBJECTS += configfile.o | ||
131 | OBJECTS += html.o | ||
132 | OBJECTS += parsing.o | ||
133 | OBJECTS += scan-tree.o | ||
134 | OBJECTS += shared.o | ||
135 | OBJECTS += ui-atom.o | ||
136 | OBJECTS += ui-blob.o | ||
137 | OBJECTS += ui-clone.o | ||
138 | OBJECTS += ui-commit.o | ||
139 | OBJECTS += ui-diff.o | ||
140 | OBJECTS += ui-log.o | ||
141 | OBJECTS += ui-patch.o | ||
142 | OBJECTS += ui-plain.o | ||
143 | OBJECTS += ui-refs.o | ||
144 | OBJECTS += ui-repolist.o | ||
145 | OBJECTS += ui-shared.o | ||
146 | OBJECTS += ui-snapshot.o | ||
147 | OBJECTS += ui-ssdiff.o | ||
148 | OBJECTS += ui-stats.o | ||
149 | OBJECTS += ui-summary.o | ||
150 | OBJECTS += ui-tag.o | ||
151 | OBJECTS += ui-tree.o | ||
152 | OBJECTS += vector.o | ||
153 | |||
154 | dep_files := $(foreach f,$(OBJECTS),$(dir $f).deps/$(notdir $f).d) | ||
155 | dep_dirs := $(addsuffix .deps,$(sort $(dir $OBJECTS))) | ||
156 | |||
157 | $(dep_dirs): | ||
158 | @mkdir -p $@ | ||
159 | |||
160 | missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs)) | ||
161 | dep_file = $(dir $@).deps/$(notdir $@).d | ||
162 | dep_args = -MF $(dep_file) -MMD -MP | ||
163 | |||
164 | .SUFFIXES: | 62 | .SUFFIXES: |
165 | 63 | ||
166 | $(OBJECTS): %.o: %.c $(missing_dep_dirs) | ||
167 | $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(CFLAGS) $< | ||
168 | |||
169 | dep_files_present := $(wildcard $(dep_files)) | ||
170 | ifneq ($(dep_files_present),) | ||
171 | include $(dep_files_present) | ||
172 | endif | ||
173 | |||
174 | all:: cgit | 64 | all:: cgit |
175 | 65 | ||
176 | cgit: VERSION $(OBJECTS) libgit | 66 | cgit: |
177 | $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) $(LDLIBS) | 67 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) -f ../cgit.mk ../cgit NO_CURL=1 |
178 | |||
179 | libgit: | ||
180 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) libgit.a | ||
181 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) xdiff/lib.a | ||
182 | 68 | ||
183 | test: all | 69 | test: all |
184 | $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all | 70 | $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all |
@@ -259,7 +145,7 @@ get-git: | |||
259 | tags: | 145 | tags: |
260 | $(QUIET_TAGS)find . -name '*.[ch]' | xargs ctags | 146 | $(QUIET_TAGS)find . -name '*.[ch]' | xargs ctags |
261 | 147 | ||
262 | .PHONY: all cgit get-git libgit force-version | 148 | .PHONY: all cgit get-git |
263 | .PHONY: clean clean-doc cleanall | 149 | .PHONY: clean clean-doc cleanall |
264 | .PHONY: doc doc-html doc-man doc-pdf | 150 | .PHONY: doc doc-html doc-man doc-pdf |
265 | .PHONY: install install-doc install-html install-man install-pdf | 151 | .PHONY: install install-doc install-html install-man install-pdf |
diff --git a/cgit.mk b/cgit.mk new file mode 100644 index 0000000..4869c55 --- /dev/null +++ b/cgit.mk | |||
@@ -0,0 +1,74 @@ | |||
1 | # This Makefile is run in the "git" directory in order to re-use Git's | ||
2 | # build variables and operating system detection. Hence all files in | ||
3 | # CGit's directory must be prefixed with "../". | ||
4 | include Makefile | ||
5 | |||
6 | CGIT_PREFIX = ../ | ||
7 | |||
8 | # The CGIT_* variables are inherited when this file is called from the | ||
9 | # main Makefile - they are defined there. | ||
10 | |||
11 | $(CGIT_PREFIX)VERSION: force-version | ||
12 | @cd $(CGIT_PREFIX) && ./gen-version.sh "$(CGIT_VERSION)" | ||
13 | -include $(CGIT_PREFIX)VERSION | ||
14 | .PHONY: force-version | ||
15 | |||
16 | # CGIT_CFLAGS is a separate variable so that we can track it separately | ||
17 | # and avoid rebuilding all of Git when these variables change. | ||
18 | CGIT_CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' | ||
19 | CGIT_CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' | ||
20 | CGIT_CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' | ||
21 | CGIT_CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' | ||
22 | |||
23 | ifdef NO_C99_FORMAT | ||
24 | CFLAGS += -DNO_C99_FORMAT | ||
25 | endif | ||
26 | |||
27 | CGIT_OBJ_NAMES += cgit.o | ||
28 | CGIT_OBJ_NAMES += cache.o | ||
29 | CGIT_OBJ_NAMES += cmd.o | ||
30 | CGIT_OBJ_NAMES += configfile.o | ||
31 | CGIT_OBJ_NAMES += html.o | ||
32 | CGIT_OBJ_NAMES += parsing.o | ||
33 | CGIT_OBJ_NAMES += scan-tree.o | ||
34 | CGIT_OBJ_NAMES += shared.o | ||
35 | CGIT_OBJ_NAMES += ui-atom.o | ||
36 | CGIT_OBJ_NAMES += ui-blob.o | ||
37 | CGIT_OBJ_NAMES += ui-clone.o | ||
38 | CGIT_OBJ_NAMES += ui-commit.o | ||
39 | CGIT_OBJ_NAMES += ui-diff.o | ||
40 | CGIT_OBJ_NAMES += ui-log.o | ||
41 | CGIT_OBJ_NAMES += ui-patch.o | ||
42 | CGIT_OBJ_NAMES += ui-plain.o | ||
43 | CGIT_OBJ_NAMES += ui-refs.o | ||
44 | CGIT_OBJ_NAMES += ui-repolist.o | ||
45 | CGIT_OBJ_NAMES += ui-shared.o | ||
46 | CGIT_OBJ_NAMES += ui-snapshot.o | ||
47 | CGIT_OBJ_NAMES += ui-ssdiff.o | ||
48 | CGIT_OBJ_NAMES += ui-stats.o | ||
49 | CGIT_OBJ_NAMES += ui-summary.o | ||
50 | CGIT_OBJ_NAMES += ui-tag.o | ||
51 | CGIT_OBJ_NAMES += ui-tree.o | ||
52 | CGIT_OBJ_NAMES += vector.o | ||
53 | |||
54 | CGIT_OBJS := $(addprefix $(CGIT_PREFIX),$(CGIT_OBJ_NAMES)) | ||
55 | |||
56 | ifeq ($(wildcard $(CGIT_PREFIX).depend),) | ||
57 | missing_dep_dirs += $(CGIT_PREFIX).depend | ||
58 | endif | ||
59 | |||
60 | $(CGIT_PREFIX).depend: | ||
61 | @mkdir -p $@ | ||
62 | |||
63 | $(CGIT_PREFIX)CGIT-CFLAGS: FORCE | ||
64 | @FLAGS='$(subst ','\'',$(CGIT_CFLAGS))'; \ | ||
65 | if test x"$$FLAGS" != x"`cat ../CGIT-CFLAGS 2>/dev/null`" ; then \ | ||
66 | echo 1>&2 " * new CGit build flags"; \ | ||
67 | echo "$$FLAGS" >$(CGIT_PREFIX)CGIT-CFLAGS; \ | ||
68 | fi | ||
69 | |||
70 | $(CGIT_OBJS): %.o: %.c GIT-CFLAGS $(CGIT_PREFIX)CGIT-CFLAGS $(missing_dep_dirs) | ||
71 | $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $(CGIT_CFLAGS) $< | ||
72 | |||
73 | $(CGIT_PREFIX)cgit: $(CGIT_OBJS) GIT-LDFLAGS $(GITLIBS) | ||
74 | $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) | ||