Make 'git diff --cached' synonymous to 'git diff --cached HEAD'.
[alt-git.git] / Makefile
blobf83c4951bc0c7b71d17d3244f33a41bbde8c119e
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 NO_STRCASESTR if you don't have strcasestr.
14 # Define PPC_SHA1 environment variable when running make to make use of
15 # a bundled SHA1 routine optimized for PowerPC.
17 # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
19 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
21 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
22 # Patrick Mauritz).
24 # Define NO_GETDOMAINNAME if your library lack it (SunOS, Patrick Mauritz).
26 # Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
28 # Define COLLISION_CHECK below if you believe that SHA1's
29 # 1461501637330902918203684832716283019655932542976 hashes do not give you
30 # sufficient guarantee that no collisions between objects will ever happen.
32 # DEFINES += -DCOLLISION_CHECK
34 # Define USE_NSEC below if you want git to care about sub-second file mtimes
35 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
36 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
37 # randomly break unless your underlying filesystem supports those sub-second
38 # times (my ext3 doesn't).
40 # DEFINES += -DUSE_NSEC
42 # Define USE_STDEV below if you want git to care about the underlying device
43 # change being considered an inode change from the update-cache perspective.
45 # DEFINES += -DUSE_STDEV
47 GIT_VERSION = 0.99.7
49 CFLAGS = -g -O2 -Wall
50 ALL_CFLAGS = $(CFLAGS) $(PLATFORM_DEFINES) $(DEFINES)
52 prefix = $(HOME)
53 bindir = $(prefix)/bin
54 template_dir = $(prefix)/share/git-core/templates/
55 GIT_PYTHON_DIR = $(prefix)/share/git-core/python
56 # DESTDIR=
58 CC = gcc
59 AR = ar
60 INSTALL = install
61 RPMBUILD = rpmbuild
63 # sparse is architecture-neutral, which means that we need to tell it
64 # explicitly what architecture to check for. Fix this up for yours..
65 SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
69 ### --- END CONFIGURATION SECTION ---
71 SCRIPT_SH = \
72 git-add.sh git-bisect.sh git-branch.sh git-checkout.sh \
73 git-cherry.sh git-clone.sh git-commit.sh \
74 git-count-objects.sh git-diff.sh git-fetch.sh \
75 git-format-patch.sh git-log.sh git-ls-remote.sh \
76 git-merge-one-file.sh git-octopus.sh git-parse-remote.sh \
77 git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
78 git-repack.sh git-request-pull.sh git-reset.sh \
79 git-resolve.sh git-revert.sh git-sh-setup.sh git-status.sh \
80 git-tag.sh git-verify-tag.sh git-whatchanged.sh git.sh \
81 git-applymbox.sh git-applypatch.sh \
82 git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
83 git-merge-resolve.sh git-grep.sh
85 SCRIPT_PERL = \
86 git-archimport.perl git-cvsimport.perl git-relink.perl \
87 git-rename.perl git-shortlog.perl
89 SCRIPT_PYTHON = \
90 git-merge-recursive.py
92 # The ones that do not have to link with lcrypto nor lz.
93 SIMPLE_PROGRAMS = \
94 git-get-tar-commit-id git-mailinfo git-mailsplit git-stripspace \
95 git-daemon git-var
97 # ... and all the rest
98 PROGRAMS = \
99 git-apply git-cat-file \
100 git-checkout-index git-clone-pack git-commit-tree \
101 git-convert-objects git-diff-files \
102 git-diff-helper git-diff-index git-diff-stages \
103 git-diff-tree git-export git-fetch-pack git-fsck-objects \
104 git-hash-object git-init-db \
105 git-local-fetch git-ls-files git-ls-tree git-merge-base \
106 git-merge-index git-mktag git-pack-objects git-patch-id \
107 git-peek-remote git-prune-packed git-read-tree \
108 git-receive-pack git-rev-list git-rev-parse \
109 git-rev-tree git-send-pack git-show-branch \
110 git-show-index git-ssh-fetch \
111 git-ssh-upload git-tar-tree git-unpack-file \
112 git-unpack-objects git-update-index git-update-server-info \
113 git-upload-pack git-verify-pack git-write-tree \
114 $(SIMPLE_PROGRAMS)
116 # Backward compatibility -- to be removed in 0.99.8
117 PROGRAMS += git-ssh-pull git-ssh-push
119 PYMODULES = \
120 gitMergeCommon.py
122 ifdef WITH_OWN_SUBPROCESS_PY
123 PYMODULES += compat/subprocess.py
124 endif
126 ifdef WITH_SEND_EMAIL
127 SCRIPT_PERL += git-send-email.perl
128 endif
130 ifndef NO_CURL
131 PROGRAMS += git-http-fetch
132 endif
134 LIB_FILE=libgit.a
136 LIB_H = \
137 blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
138 diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
139 run-command.h strbuf.h tag.h tree.h
141 DIFF_OBJS = \
142 diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
143 diffcore-pickaxe.o diffcore-rename.o
145 LIB_OBJS = \
146 blob.o commit.o connect.o count-delta.o csum-file.o \
147 date.o diff-delta.o entry.o ident.o index.o \
148 object.o pack-check.o patch-delta.o path.o pkt-line.o \
149 quote.o read-cache.o refs.o run-command.o \
150 server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
151 tag.o tree.o usage.o $(DIFF_OBJS)
153 LIBS = $(LIB_FILE)
154 LIBS += -lz
156 ifeq ($(shell uname -s),Darwin)
157 NEEDS_SSL_WITH_CRYPTO = YesPlease
158 NEEDS_LIBICONV = YesPlease
159 endif
160 ifeq ($(shell uname -s),SunOS)
161 NEEDS_SOCKET = YesPlease
162 NEEDS_NSL = YesPlease
163 PLATFORM_DEFINES += -D__EXTENSIONS__
164 endif
166 ifndef SHELL_PATH
167 SHELL_PATH = /bin/sh
168 endif
169 ifndef PERL_PATH
170 PERL_PATH = /usr/bin/perl
171 endif
172 ifndef PYTHON_PATH
173 PYTHON_PATH = /usr/bin/python
174 endif
176 ifndef NO_OPENSSL
177 LIB_OBJS += epoch.o
178 OPENSSL_LIBSSL = -lssl
179 else
180 DEFINES += '-DNO_OPENSSL'
181 MOZILLA_SHA1 = 1
182 OPENSSL_LIBSSL =
183 endif
184 ifdef NEEDS_SSL_WITH_CRYPTO
185 LIB_4_CRYPTO = -lcrypto -lssl
186 else
187 LIB_4_CRYPTO = -lcrypto
188 endif
189 ifdef NEEDS_LIBICONV
190 LIB_4_ICONV = -liconv
191 else
192 LIB_4_ICONV =
193 endif
194 ifdef MOZILLA_SHA1
195 SHA1_HEADER = "mozilla-sha1/sha1.h"
196 LIB_OBJS += mozilla-sha1/sha1.o
197 else
198 ifdef PPC_SHA1
199 SHA1_HEADER = "ppc/sha1.h"
200 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
201 else
202 SHA1_HEADER = <openssl/sha.h>
203 LIBS += $(LIB_4_CRYPTO)
204 endif
205 endif
206 ifdef NEEDS_SOCKET
207 LIBS += -lsocket
208 SIMPLE_LIB += -lsocket
209 endif
210 ifdef NEEDS_NSL
211 LIBS += -lnsl
212 SIMPLE_LIB += -lnsl
213 endif
214 ifdef NO_STRCASESTR
215 DEFINES += -Dstrcasestr=gitstrcasestr
216 LIB_OBJS += compat/strcasestr.o
217 endif
219 DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
221 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
222 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
223 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
224 gitk
226 ### Build rules
228 all: $(PROGRAMS) $(SCRIPTS)
230 all:
231 $(MAKE) -C templates
233 git: git.sh Makefile
234 rm -f $@+ $@
235 sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' <$@.sh >$@+
236 chmod +x $@+
237 mv $@+ $@
239 $(filter-out git,$(patsubst %.sh,%,$(SCRIPT_SH))) : % : %.sh
240 rm -f $@
241 sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' $@.sh >$@
242 chmod +x $@
244 $(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
245 rm -f $@
246 sed -e '1s|#!.*perl|#!$(PERL_PATH)|' $@.perl >$@
247 chmod +x $@
249 $(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
250 rm -f $@
251 sed -e '1s|#!.*python|#!$(PYTHON_PATH)|' \
252 -e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR)|g' \
253 $@.py >$@
254 chmod +x $@
256 %.o: %.c
257 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
258 %.o: %.S
259 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
261 git-%: %.o $(LIB_FILE)
262 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
264 git-mailinfo : SIMPLE_LIB += $(LIB_4_ICONV)
265 $(SIMPLE_PROGRAMS) : $(LIB_FILE)
266 $(SIMPLE_PROGRAMS) : git-% : %.o
267 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIB_FILE) $(SIMPLE_LIB)
269 git-http-fetch: fetch.o
270 git-local-fetch: fetch.o
271 git-ssh-fetch: rsh.o fetch.o
272 git-ssh-upload: rsh.o
273 git-ssh-pull: rsh.o fetch.o
274 git-ssh-push: rsh.o
276 git-http-fetch: LIBS += -lcurl
277 git-rev-list: LIBS += $(OPENSSL_LIBSSL)
279 init-db.o: init-db.c
280 $(CC) -c $(ALL_CFLAGS) \
281 -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
283 $(LIB_OBJS): $(LIB_H)
284 $(patsubst git-%,%.o,$(PROGRAMS)): $(LIB_H)
285 $(DIFF_OBJS): diffcore.h
287 $(LIB_FILE): $(LIB_OBJS)
288 $(AR) rcs $@ $(LIB_OBJS)
290 doc:
291 $(MAKE) -C Documentation all
294 ### Testing rules
296 test: all
297 $(MAKE) -C t/ all
299 test-date: test-date.c date.o
300 $(CC) $(ALL_CFLAGS) -o $@ test-date.c date.o
302 test-delta: test-delta.c diff-delta.o patch-delta.o
303 $(CC) $(ALL_CFLAGS) -o $@ $^
305 check:
306 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
310 ### Installation rules
312 install: $(PROGRAMS) $(SCRIPTS)
313 $(INSTALL) -d -m755 $(DESTDIR)$(bindir)
314 $(INSTALL) $(PROGRAMS) $(SCRIPTS) $(DESTDIR)$(bindir)
315 $(INSTALL) git-revert $(DESTDIR)$(bindir)/git-cherry-pick
316 sh ./cmd-rename.sh $(DESTDIR)$(bindir)
317 $(MAKE) -C templates install
318 $(INSTALL) -d -m755 $(DESTDIR)$(GIT_PYTHON_DIR)
319 $(INSTALL) $(PYMODULES) $(DESTDIR)$(GIT_PYTHON_DIR)
321 install-doc:
322 $(MAKE) -C Documentation install
327 ### Maintainer's dist rules
329 git-core.spec: git-core.spec.in Makefile
330 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
332 GIT_TARNAME=git-core-$(GIT_VERSION)
333 dist: git-core.spec git-tar-tree
334 ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
335 @mkdir -p $(GIT_TARNAME)
336 @cp git-core.spec $(GIT_TARNAME)
337 tar rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git-core.spec
338 @rm -rf $(GIT_TARNAME)
339 gzip -f -9 $(GIT_TARNAME).tar
341 rpm: dist
342 $(RPMBUILD) -ta git-core-$(GIT_VERSION).tar.gz
344 deb: dist
345 rm -rf $(GIT_TARNAME)
346 tar zxf $(GIT_TARNAME).tar.gz
347 dpkg-source -b $(GIT_TARNAME)
348 cd $(GIT_TARNAME) && fakeroot debian/rules binary
350 ### Cleaning rules
352 clean:
353 rm -f *.o mozilla-sha1/*.o ppc/*.o $(PROGRAMS) $(LIB_FILE)
354 rm -f $(filter-out gitk,$(SCRIPTS))
355 rm -f git-core.spec
356 rm -rf $(GIT_TARNAME)
357 rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
358 rm -f git-core_$(GIT_VERSION)-*.deb git-core_$(GIT_VERSION)-*.dsc
359 rm -f git-tk_$(GIT_VERSION)-*.deb
360 $(MAKE) -C Documentation/ clean
361 $(MAKE) -C templates/ clean
362 $(MAKE) -C t/ clean