[PATCH] Better error reporting for "git status"
[git/dscho.git] / Makefile
blobe7f3d1ffca1bba7736202cc3c02a8d99e22b51b3
1 # Define MOZILLA_SHA1 environment variable when running make to make use of
2 # a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
3 # on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
4 # choice) has very fast version optimized for i586.
6 # Define NO_OPENSSL environment variable if you do not have OpenSSL. You will
7 # miss out git-rev-list --merge-order. This also implies MOZILLA_SHA1.
9 # Define NO_CURL if you do not have curl installed. git-http-pull is not
10 # built, and you cannot use http:// and https:// transports.
12 # Define CURLDIR=/foo/bar if your curl header and library files are in
13 # /foo/bar/include and /foo/bar/lib directories.
15 # Define NO_STRCASESTR if you don't have strcasestr.
17 # Define PPC_SHA1 environment variable when running make to make use of
18 # a bundled SHA1 routine optimized for PowerPC.
20 # Define ARM_SHA1 environment variable when running make to make use of
21 # a bundled SHA1 routine optimized for ARM.
23 # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
25 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
27 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
28 # Patrick Mauritz).
30 # Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
32 # Define COLLISION_CHECK below if you believe that SHA1's
33 # 1461501637330902918203684832716283019655932542976 hashes do not give you
34 # sufficient guarantee that no collisions between objects will ever happen.
36 # DEFINES += -DCOLLISION_CHECK
38 # Define USE_NSEC below if you want git to care about sub-second file mtimes
39 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
40 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
41 # randomly break unless your underlying filesystem supports those sub-second
42 # times (my ext3 doesn't).
44 # DEFINES += -DUSE_NSEC
46 # Define USE_STDEV below if you want git to care about the underlying device
47 # change being considered an inode change from the update-cache perspective.
49 # DEFINES += -DUSE_STDEV
51 GIT_VERSION = 0.99.7.GIT
53 CFLAGS = -g -O2 -Wall
54 ALL_CFLAGS = $(CFLAGS) $(PLATFORM_DEFINES) $(DEFINES)
56 prefix = $(HOME)
57 bindir = $(prefix)/bin
58 template_dir = $(prefix)/share/git-core/templates/
59 GIT_PYTHON_DIR = $(prefix)/share/git-core/python
60 # DESTDIR=
62 CC = gcc
63 AR = ar
64 TAR = tar
65 INSTALL = install
66 RPMBUILD = rpmbuild
68 # sparse is architecture-neutral, which means that we need to tell it
69 # explicitly what architecture to check for. Fix this up for yours..
70 SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
74 ### --- END CONFIGURATION SECTION ---
76 SCRIPT_SH = \
77 git-add.sh git-bisect.sh git-branch.sh git-checkout.sh \
78 git-cherry.sh git-clone.sh git-commit.sh \
79 git-count-objects.sh git-diff.sh git-fetch.sh \
80 git-format-patch.sh git-log.sh git-ls-remote.sh \
81 git-merge-one-file.sh git-octopus.sh git-parse-remote.sh \
82 git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
83 git-repack.sh git-request-pull.sh git-reset.sh \
84 git-resolve.sh git-revert.sh git-sh-setup.sh git-status.sh \
85 git-tag.sh git-verify-tag.sh git-whatchanged.sh git.sh \
86 git-applymbox.sh git-applypatch.sh \
87 git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
88 git-merge-resolve.sh git-grep.sh
90 SCRIPT_PERL = \
91 git-archimport.perl git-cvsimport.perl git-relink.perl \
92 git-rename.perl git-shortlog.perl git-fmt-merge-msg.perl
94 SCRIPT_PYTHON = \
95 git-merge-recursive.py
97 # The ones that do not have to link with lcrypto nor lz.
98 SIMPLE_PROGRAMS = \
99 git-get-tar-commit-id git-mailinfo git-mailsplit git-stripspace \
100 git-daemon git-var
102 # ... and all the rest
103 PROGRAMS = \
104 git-apply git-cat-file \
105 git-checkout-index git-clone-pack git-commit-tree \
106 git-convert-objects git-diff-files \
107 git-diff-index git-diff-stages \
108 git-diff-tree git-fetch-pack git-fsck-objects \
109 git-hash-object git-init-db \
110 git-local-fetch git-ls-files git-ls-tree git-merge-base \
111 git-merge-index git-mktag git-pack-objects git-patch-id \
112 git-peek-remote git-prune-packed git-read-tree \
113 git-receive-pack git-rev-list git-rev-parse \
114 git-send-pack git-show-branch \
115 git-show-index git-ssh-fetch \
116 git-ssh-upload git-tar-tree git-unpack-file \
117 git-unpack-objects git-update-index git-update-server-info \
118 git-upload-pack git-verify-pack git-write-tree \
119 git-update-ref git-symbolic-ref \
120 $(SIMPLE_PROGRAMS)
122 # Backward compatibility -- to be removed after 1.0
123 PROGRAMS += git-ssh-pull git-ssh-push
125 PYMODULES = \
126 gitMergeCommon.py
128 ifdef WITH_OWN_SUBPROCESS_PY
129 PYMODULES += compat/subprocess.py
130 endif
132 ifdef WITH_SEND_EMAIL
133 SCRIPT_PERL += git-send-email.perl
134 endif
136 LIB_FILE=libgit.a
138 LIB_H = \
139 blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
140 diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
141 run-command.h strbuf.h tag.h tree.h
143 DIFF_OBJS = \
144 diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
145 diffcore-pickaxe.o diffcore-rename.o
147 LIB_OBJS = \
148 blob.o commit.o connect.o count-delta.o csum-file.o \
149 date.o diff-delta.o entry.o ident.o index.o \
150 object.o pack-check.o patch-delta.o path.o pkt-line.o \
151 quote.o read-cache.o refs.o run-command.o \
152 server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
153 tag.o tree.o usage.o $(DIFF_OBJS)
155 LIBS = $(LIB_FILE)
156 LIBS += -lz
159 # Platform specific tweaks
161 ifeq ($(shell uname -s),Darwin)
162 NEEDS_SSL_WITH_CRYPTO = YesPlease
163 NEEDS_LIBICONV = YesPlease
164 endif
165 ifeq ($(shell uname -s),SunOS)
166 NEEDS_SOCKET = YesPlease
167 NEEDS_NSL = YesPlease
168 SHELL_PATH = /bin/bash
169 NO_STRCASESTR = YesPlease
170 CURLDIR = /opt/sfw
171 INSTALL = ginstall
172 TAR = gtar
173 PLATFORM_DEFINES += -D__EXTENSIONS__
174 endif
175 ifneq (,$(findstring arm,$(shell uname -m)))
176 ARM_SHA1 = YesPlease
177 endif
179 ifndef NO_CURL
180 ifdef CURLDIR
181 # This is still problematic -- gcc does not want -R.
182 CFLAGS += -I$(CURLDIR)/include
183 CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
184 else
185 CURL_LIBCURL = -lcurl
186 endif
187 PROGRAMS += git-http-fetch
188 endif
190 ifndef SHELL_PATH
191 SHELL_PATH = /bin/sh
192 endif
193 ifndef PERL_PATH
194 PERL_PATH = /usr/bin/perl
195 endif
196 ifndef PYTHON_PATH
197 PYTHON_PATH = /usr/bin/python
198 endif
200 ifndef NO_OPENSSL
201 LIB_OBJS += epoch.o
202 OPENSSL_LIBSSL = -lssl
203 ifdef OPENSSLDIR
204 # Again this may be problematic -- gcc does not always want -R.
205 CFLAGS += -I$(OPENSSLDIR)/include
206 OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
207 else
208 OPENSSL_LINK =
209 endif
210 else
211 DEFINES += '-DNO_OPENSSL'
212 MOZILLA_SHA1 = 1
213 OPENSSL_LIBSSL =
214 endif
215 ifdef NEEDS_SSL_WITH_CRYPTO
216 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
217 else
218 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
219 endif
220 ifdef NEEDS_LIBICONV
221 ifdef ICONVDIR
222 # Again this may be problematic -- gcc does not always want -R.
223 CFLAGS += -I$(ICONVDIR)/include
224 ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
225 else
226 ICONV_LINK =
227 endif
228 LIB_4_ICONV = $(ICONV_LINK) -liconv
229 else
230 LIB_4_ICONV =
231 endif
232 ifdef NEEDS_SOCKET
233 LIBS += -lsocket
234 SIMPLE_LIB += -lsocket
235 endif
236 ifdef NEEDS_NSL
237 LIBS += -lnsl
238 SIMPLE_LIB += -lnsl
239 endif
240 ifdef NO_STRCASESTR
241 DEFINES += -Dstrcasestr=gitstrcasestr
242 LIB_OBJS += compat/strcasestr.o
243 endif
245 ifdef PPC_SHA1
246 SHA1_HEADER = "ppc/sha1.h"
247 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
248 else
249 ifdef ARM_SHA1
250 SHA1_HEADER = "arm/sha1.h"
251 LIB_OBJS += arm/sha1.o arm/sha1_arm.o
252 else
253 ifdef MOZILLA_SHA1
254 SHA1_HEADER = "mozilla-sha1/sha1.h"
255 LIB_OBJS += mozilla-sha1/sha1.o
256 else
257 SHA1_HEADER = <openssl/sha.h>
258 LIBS += $(LIB_4_CRYPTO)
259 endif
260 endif
261 endif
263 DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
265 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
266 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
267 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
268 gitk
270 export TAR INSTALL DESTDIR SHELL_PATH
271 ### Build rules
273 all: $(PROGRAMS) $(SCRIPTS)
275 all:
276 $(MAKE) -C templates
278 git: git.sh Makefile
279 rm -f $@+ $@
280 sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' \
281 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' <$@.sh >$@+
282 chmod +x $@+
283 mv $@+ $@
285 $(filter-out git,$(patsubst %.sh,%,$(SCRIPT_SH))) : % : %.sh
286 rm -f $@
287 sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' $@.sh >$@
288 chmod +x $@
290 $(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
291 rm -f $@
292 sed -e '1s|#!.*perl|#!$(PERL_PATH)|' $@.perl >$@
293 chmod +x $@
295 $(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
296 rm -f $@
297 sed -e '1s|#!.*python|#!$(PYTHON_PATH)|' \
298 -e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR)|g' \
299 $@.py >$@
300 chmod +x $@
302 %.o: %.c
303 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
304 %.o: %.S
305 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
307 git-%: %.o $(LIB_FILE)
308 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
310 git-mailinfo : SIMPLE_LIB += $(LIB_4_ICONV)
311 $(SIMPLE_PROGRAMS) : $(LIB_FILE)
312 $(SIMPLE_PROGRAMS) : git-% : %.o
313 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIB_FILE) $(SIMPLE_LIB)
315 git-http-fetch: fetch.o
316 git-local-fetch: fetch.o
317 git-ssh-fetch: rsh.o fetch.o
318 git-ssh-upload: rsh.o
319 git-ssh-pull: rsh.o fetch.o
320 git-ssh-push: rsh.o
322 git-http-fetch: LIBS += $(CURL_LIBCURL)
323 git-rev-list: LIBS += $(OPENSSL_LIBSSL)
325 init-db.o: init-db.c
326 $(CC) -c $(ALL_CFLAGS) \
327 -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
329 $(LIB_OBJS): $(LIB_H)
330 $(patsubst git-%,%.o,$(PROGRAMS)): $(LIB_H)
331 $(DIFF_OBJS): diffcore.h
333 $(LIB_FILE): $(LIB_OBJS)
334 $(AR) rcs $@ $(LIB_OBJS)
336 doc:
337 $(MAKE) -C Documentation all
340 ### Testing rules
342 test: all
343 $(MAKE) -C t/ all
345 test-date: test-date.c date.o
346 $(CC) $(ALL_CFLAGS) -o $@ test-date.c date.o
348 test-delta: test-delta.c diff-delta.o patch-delta.o
349 $(CC) $(ALL_CFLAGS) -o $@ $^
351 check:
352 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
356 ### Installation rules
358 install: $(PROGRAMS) $(SCRIPTS)
359 $(INSTALL) -d -m755 $(DESTDIR)$(bindir)
360 $(INSTALL) $(PROGRAMS) $(SCRIPTS) $(DESTDIR)$(bindir)
361 $(INSTALL) git-revert $(DESTDIR)$(bindir)/git-cherry-pick
362 sh ./cmd-rename.sh $(DESTDIR)$(bindir)
363 $(MAKE) -C templates install
364 $(INSTALL) -d -m755 $(DESTDIR)$(GIT_PYTHON_DIR)
365 $(INSTALL) $(PYMODULES) $(DESTDIR)$(GIT_PYTHON_DIR)
367 install-doc:
368 $(MAKE) -C Documentation install
373 ### Maintainer's dist rules
375 git-core.spec: git-core.spec.in Makefile
376 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
378 GIT_TARNAME=git-core-$(GIT_VERSION)
379 dist: git-core.spec git-tar-tree
380 ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
381 @mkdir -p $(GIT_TARNAME)
382 @cp git-core.spec $(GIT_TARNAME)
383 $(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git-core.spec
384 @rm -rf $(GIT_TARNAME)
385 gzip -f -9 $(GIT_TARNAME).tar
387 rpm: dist
388 $(RPMBUILD) -ta git-core-$(GIT_VERSION).tar.gz
390 deb: dist
391 rm -rf $(GIT_TARNAME)
392 $(TAR) zxf $(GIT_TARNAME).tar.gz
393 dpkg-source -b $(GIT_TARNAME)
394 cd $(GIT_TARNAME) && fakeroot debian/rules binary
396 ### Cleaning rules
398 clean:
399 rm -f *.o mozilla-sha1/*.o ppc/*.o compat/*.o $(PROGRAMS) $(LIB_FILE)
400 rm -f $(filter-out gitk,$(SCRIPTS))
401 rm -f git-core.spec *.pyc *.pyo
402 rm -rf $(GIT_TARNAME)
403 rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
404 rm -f git-core_$(GIT_VERSION)-*.deb git-core_$(GIT_VERSION)-*.dsc
405 rm -f git-tk_$(GIT_VERSION)-*.deb
406 $(MAKE) -C Documentation/ clean
407 $(MAKE) -C templates clean
408 $(MAKE) -C t/ clean