1# The default target of this Makefile is...
2all:
3
4# Define MOZILLA_SHA1 environment variable when running make to make use of
5# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
6# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
7# choice) has very fast version optimized for i586.
8#
9# Define NO_OPENSSL environment variable if you do not have OpenSSL.
10# This also implies MOZILLA_SHA1.
11#
12# Define NO_CURL if you do not have curl installed. git-http-pull and
13# git-http-push are not built, and you cannot use http:// and https://
14# transports.
15#
16# Define CURLDIR=/foo/bar if your curl header and library files are in
17# /foo/bar/include and /foo/bar/lib directories.
18#
19# Define NO_EXPAT if you do not have expat installed. git-http-push is
20# not built, and you cannot push using http:// and https:// transports.
21#
22# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
23#
24# Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
25# d_type in struct dirent (latest Cygwin -- will be fixed soonish).
26#
27# Define NO_STRCASESTR if you don't have strcasestr.
28#
29# Define NO_STRLCPY if you don't have strlcpy.
30#
31# Define NO_SETENV if you don't have setenv in the C library.
32#
33# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
34# Enable it on Windows. By default, symrefs are still used.
35#
36# Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
37# tests. These tests take up a significant amount of the total test time
38# but are not needed unless you plan to talk to SVN repos.
39#
40# Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
41# installed in /sw, but don't want GIT to link against any libraries
42# installed there. If defined you may specify your own (or Fink's)
43# include directories and library directories by defining CFLAGS
44# and LDFLAGS appropriately.
45#
46# Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
47# have DarwinPorts installed in /opt/local, but don't want GIT to
48# link against any libraries installed there. If defined you may
49# specify your own (or DarwinPort's) include directories and
50# library directories by defining CFLAGS and LDFLAGS appropriately.
51#
52# Define PPC_SHA1 environment variable when running make to make use of
53# a bundled SHA1 routine optimized for PowerPC.
54#
55# Define ARM_SHA1 environment variable when running make to make use of
56# a bundled SHA1 routine optimized for ARM.
57#
58# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
59#
60# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
61#
62# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
63# Patrick Mauritz).
64#
65# Define NO_MMAP if you want to avoid mmap.
66#
67# Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
68#
69# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
70#
71# Define NO_SOCKADDR_STORAGE if your platform does not have struct
72# sockaddr_storage.
73#
74# Define NO_ICONV if your libc does not properly support iconv.
75#
76# Define NO_ACCURATE_DIFF if your diff program at least sometimes misses
77# a missing newline at the end of the file.
78#
79# Define NO_PYTHON if you want to lose all benefits of the recursive merge.
80#
81# Define COLLISION_CHECK below if you believe that SHA1's
82# 1461501637330902918203684832716283019655932542976 hashes do not give you
83# sufficient guarantee that no collisions between objects will ever happen.
84
85# Define USE_NSEC below if you want git to care about sub-second file mtimes
86# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
87# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
88# randomly break unless your underlying filesystem supports those sub-second
89# times (my ext3 doesn't).
90
91# Define USE_STDEV below if you want git to care about the underlying device
92# change being considered an inode change from the update-cache perspective.
93
94GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
95 @$(SHELL_PATH) ./GIT-VERSION-GEN
96-include GIT-VERSION-FILE
97
98uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
99uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
100uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
101uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
102uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
103
104# CFLAGS and LDFLAGS are for the users to override from the command line.
105
106CFLAGS = -g -O2 -Wall
107LDFLAGS =
108ALL_CFLAGS = $(CFLAGS)
109ALL_LDFLAGS = $(LDFLAGS)
110STRIP ?= strip
111
112prefix = $(HOME)
113bindir = $(prefix)/bin
114gitexecdir = $(bindir)
115template_dir = $(prefix)/share/git-core/templates/
116GIT_PYTHON_DIR = $(prefix)/share/git-core/python
117# DESTDIR=
118
119CC = gcc
120AR = ar
121TAR = tar
122INSTALL = install
123RPMBUILD = rpmbuild
124
125# sparse is architecture-neutral, which means that we need to tell it
126# explicitly what architecture to check for. Fix this up for yours..
127SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
128
129
130
131### --- END CONFIGURATION SECTION ---
132
133SCRIPT_SH = \
134 git-bisect.sh git-branch.sh git-checkout.sh \
135 git-cherry.sh git-clean.sh git-clone.sh git-commit.sh \
136 git-fetch.sh \
137 git-ls-remote.sh \
138 git-merge-one-file.sh git-parse-remote.sh \
139 git-pull.sh git-rebase.sh \
140 git-repack.sh git-request-pull.sh git-reset.sh \
141 git-resolve.sh git-revert.sh git-sh-setup.sh \
142 git-tag.sh git-verify-tag.sh \
143 git-applymbox.sh git-applypatch.sh git-am.sh \
144 git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
145 git-merge-resolve.sh git-merge-ours.sh \
146 git-lost-found.sh git-quiltimport.sh
147
148SCRIPT_PERL = \
149 git-archimport.perl git-cvsimport.perl git-relink.perl \
150 git-shortlog.perl git-rerere.perl \
151 git-annotate.perl git-cvsserver.perl \
152 git-svnimport.perl git-mv.perl git-cvsexportcommit.perl \
153 git-send-email.perl git-svn.perl
154
155SCRIPT_PYTHON = \
156 git-merge-recursive.py
157
158SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
159 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
160 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
161 git-cherry-pick git-status git-instaweb
162
163# The ones that do not have to link with lcrypto, lz nor xdiff.
164SIMPLE_PROGRAMS = \
165 git-daemon$X
166
167# ... and all the rest that could be moved out of bindir to gitexecdir
168PROGRAMS = \
169 git-checkout-index$X \
170 git-convert-objects$X git-fetch-pack$X git-fsck-objects$X \
171 git-hash-object$X git-index-pack$X git-local-fetch$X \
172 git-merge-base$X \
173 git-merge-index$X git-mktag$X git-mktree$X git-pack-objects$X git-patch-id$X \
174 git-peek-remote$X git-prune-packed$X git-receive-pack$X \
175 git-send-pack$X git-shell$X \
176 git-show-index$X git-ssh-fetch$X \
177 git-ssh-upload$X git-unpack-file$X \
178 git-unpack-objects$X git-update-server-info$X \
179 git-upload-pack$X git-verify-pack$X \
180 git-symbolic-ref$X \
181 git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \
182 git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
183
184BUILT_INS = git-log$X git-whatchanged$X git-show$X git-update-ref$X \
185 git-count-objects$X git-diff$X git-push$X git-mailsplit$X \
186 git-grep$X git-add$X git-rm$X git-rev-list$X git-stripspace$X \
187 git-check-ref-format$X git-rev-parse$X git-mailinfo$X \
188 git-init-db$X git-tar-tree$X git-upload-tar$X git-format-patch$X \
189 git-ls-files$X git-ls-tree$X git-get-tar-commit-id$X \
190 git-read-tree$X git-commit-tree$X git-write-tree$X \
191 git-apply$X git-show-branch$X git-diff-files$X git-update-index$X \
192 git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X \
193 git-fmt-merge-msg$X git-prune$X
194
195# what 'all' will build and 'install' will install, in gitexecdir
196ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
197
198# Backward compatibility -- to be removed after 1.0
199PROGRAMS += git-ssh-pull$X git-ssh-push$X
200
201# Set paths to tools early so that they can be used for version tests.
202ifndef SHELL_PATH
203 SHELL_PATH = /bin/sh
204endif
205ifndef PERL_PATH
206 PERL_PATH = /usr/bin/perl
207endif
208ifndef PYTHON_PATH
209 PYTHON_PATH = /usr/bin/python
210endif
211
212PYMODULES = \
213 gitMergeCommon.py
214
215LIB_FILE=libgit.a
216XDIFF_LIB=xdiff/lib.a
217
218LIB_H = \
219 blob.h cache.h commit.h csum-file.h delta.h \
220 diff.h object.h pack.h pkt-line.h quote.h refs.h \
221 run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
222 tree-walk.h log-tree.h dir.h
223
224DIFF_OBJS = \
225 diff.o diff-lib.o diffcore-break.o diffcore-order.o \
226 diffcore-pickaxe.o diffcore-rename.o tree-diff.o combine-diff.o \
227 diffcore-delta.o log-tree.o
228
229LIB_OBJS = \
230 blob.o commit.o connect.o csum-file.o cache-tree.o base85.o \
231 date.o diff-delta.o entry.o exec_cmd.o ident.o lockfile.o \
232 object.o pack-check.o patch-delta.o path.o pkt-line.o \
233 quote.o read-cache.o refs.o run-command.o dir.o object-refs.o \
234 server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
235 tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
236 fetch-clone.o revision.o pager.o tree-walk.o xdiff-interface.o \
237 alloc.o merge-file.o $(DIFF_OBJS)
238
239BUILTIN_OBJS = \
240 builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \
241 builtin-grep.o builtin-add.o builtin-rev-list.o builtin-check-ref-format.o \
242 builtin-rm.o builtin-init-db.o builtin-rev-parse.o \
243 builtin-tar-tree.o builtin-upload-tar.o builtin-update-index.o \
244 builtin-ls-files.o builtin-ls-tree.o builtin-write-tree.o \
245 builtin-read-tree.o builtin-commit-tree.o builtin-mailinfo.o \
246 builtin-apply.o builtin-show-branch.o builtin-diff-files.o \
247 builtin-diff-index.o builtin-diff-stages.o builtin-diff-tree.o \
248 builtin-cat-file.o builtin-mailsplit.o builtin-stripspace.o \
249 builtin-update-ref.o builtin-fmt-merge-msg.o builtin-prune.o
250
251GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
252LIBS = $(GITLIBS) -lz
253
254#
255# Platform specific tweaks
256#
257
258# We choose to avoid "if .. else if .. else .. endif endif"
259# because maintaining the nesting to match is a pain. If
260# we had "elif" things would have been much nicer...
261
262ifeq ($(uname_S),Linux)
263 NO_STRLCPY = YesPlease
264endif
265ifeq ($(uname_S),Darwin)
266 NEEDS_SSL_WITH_CRYPTO = YesPlease
267 NEEDS_LIBICONV = YesPlease
268 NO_STRLCPY = YesPlease
269 ifndef NO_FINK
270 ifeq ($(shell test -d /sw/lib && echo y),y)
271 ALL_CFLAGS += -I/sw/include
272 ALL_LDFLAGS += -L/sw/lib
273 endif
274 endif
275 ifndef NO_DARWIN_PORTS
276 ifeq ($(shell test -d /opt/local/lib && echo y),y)
277 ALL_CFLAGS += -I/opt/local/include
278 ALL_LDFLAGS += -L/opt/local/lib
279 endif
280 endif
281endif
282ifeq ($(uname_S),SunOS)
283 NEEDS_SOCKET = YesPlease
284 NEEDS_NSL = YesPlease
285 SHELL_PATH = /bin/bash
286 NO_STRCASESTR = YesPlease
287 NO_STRLCPY = YesPlease
288 ifeq ($(uname_R),5.8)
289 NEEDS_LIBICONV = YesPlease
290 NO_UNSETENV = YesPlease
291 NO_SETENV = YesPlease
292 endif
293 ifeq ($(uname_R),5.9)
294 NO_UNSETENV = YesPlease
295 NO_SETENV = YesPlease
296 endif
297 INSTALL = ginstall
298 TAR = gtar
299 ALL_CFLAGS += -D__EXTENSIONS__
300endif
301ifeq ($(uname_O),Cygwin)
302 NO_D_TYPE_IN_DIRENT = YesPlease
303 NO_D_INO_IN_DIRENT = YesPlease
304 NO_STRCASESTR = YesPlease
305 NO_STRLCPY = YesPlease
306 NO_SYMLINK_HEAD = YesPlease
307 NEEDS_LIBICONV = YesPlease
308 # There are conflicting reports about this.
309 # On some boxes NO_MMAP is needed, and not so elsewhere.
310 # Try uncommenting this if you see things break -- YMMV.
311 # NO_MMAP = YesPlease
312 NO_IPV6 = YesPlease
313 X = .exe
314endif
315ifeq ($(uname_S),FreeBSD)
316 NEEDS_LIBICONV = YesPlease
317 ALL_CFLAGS += -I/usr/local/include
318 ALL_LDFLAGS += -L/usr/local/lib
319endif
320ifeq ($(uname_S),OpenBSD)
321 NO_STRCASESTR = YesPlease
322 NEEDS_LIBICONV = YesPlease
323 ALL_CFLAGS += -I/usr/local/include
324 ALL_LDFLAGS += -L/usr/local/lib
325endif
326ifeq ($(uname_S),NetBSD)
327 ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
328 NEEDS_LIBICONV = YesPlease
329 endif
330 ALL_CFLAGS += -I/usr/pkg/include
331 ALL_LDFLAGS += -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib
332endif
333ifeq ($(uname_S),AIX)
334 NO_STRCASESTR=YesPlease
335 NO_STRLCPY = YesPlease
336 NEEDS_LIBICONV=YesPlease
337endif
338ifeq ($(uname_S),IRIX64)
339 NO_IPV6=YesPlease
340 NO_SETENV=YesPlease
341 NO_STRCASESTR=YesPlease
342 NO_STRLCPY = YesPlease
343 NO_SOCKADDR_STORAGE=YesPlease
344 SHELL_PATH=/usr/gnu/bin/bash
345 ALL_CFLAGS += -DPATH_MAX=1024
346 # for now, build 32-bit version
347 ALL_LDFLAGS += -L/usr/lib32
348endif
349ifneq (,$(findstring arm,$(uname_M)))
350 ARM_SHA1 = YesPlease
351endif
352
353-include config.mak
354
355ifdef WITH_OWN_SUBPROCESS_PY
356 PYMODULES += compat/subprocess.py
357else
358 ifeq ($(NO_PYTHON),)
359 ifneq ($(shell $(PYTHON_PATH) -c 'import subprocess;print"OK"' 2>/dev/null),OK)
360 PYMODULES += compat/subprocess.py
361 endif
362 endif
363endif
364
365ifndef NO_CURL
366 ifdef CURLDIR
367 # This is still problematic -- gcc does not always want -R.
368 ALL_CFLAGS += -I$(CURLDIR)/include
369 CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
370 else
371 CURL_LIBCURL = -lcurl
372 endif
373 PROGRAMS += git-http-fetch$X
374 curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
375 ifeq "$(curl_check)" "070908"
376 ifndef NO_EXPAT
377 PROGRAMS += git-http-push$X
378 endif
379 endif
380 ifndef NO_EXPAT
381 EXPAT_LIBEXPAT = -lexpat
382 endif
383endif
384
385ifndef NO_OPENSSL
386 OPENSSL_LIBSSL = -lssl
387 ifdef OPENSSLDIR
388 # Again this may be problematic -- gcc does not always want -R.
389 ALL_CFLAGS += -I$(OPENSSLDIR)/include
390 OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
391 else
392 OPENSSL_LINK =
393 endif
394else
395 ALL_CFLAGS += -DNO_OPENSSL
396 MOZILLA_SHA1 = 1
397 OPENSSL_LIBSSL =
398endif
399ifdef NEEDS_SSL_WITH_CRYPTO
400 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
401else
402 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
403endif
404ifdef NEEDS_LIBICONV
405 ifdef ICONVDIR
406 # Again this may be problematic -- gcc does not always want -R.
407 ALL_CFLAGS += -I$(ICONVDIR)/include
408 ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
409 else
410 ICONV_LINK =
411 endif
412 LIBS += $(ICONV_LINK) -liconv
413endif
414ifdef NEEDS_SOCKET
415 LIBS += -lsocket
416 SIMPLE_LIB += -lsocket
417endif
418ifdef NEEDS_NSL
419 LIBS += -lnsl
420 SIMPLE_LIB += -lnsl
421endif
422ifdef NO_D_TYPE_IN_DIRENT
423 ALL_CFLAGS += -DNO_D_TYPE_IN_DIRENT
424endif
425ifdef NO_D_INO_IN_DIRENT
426 ALL_CFLAGS += -DNO_D_INO_IN_DIRENT
427endif
428ifdef NO_SYMLINK_HEAD
429 ALL_CFLAGS += -DNO_SYMLINK_HEAD
430endif
431ifdef NO_STRCASESTR
432 COMPAT_CFLAGS += -DNO_STRCASESTR
433 COMPAT_OBJS += compat/strcasestr.o
434endif
435ifdef NO_STRLCPY
436 COMPAT_CFLAGS += -DNO_STRLCPY
437 COMPAT_OBJS += compat/strlcpy.o
438endif
439ifdef NO_SETENV
440 COMPAT_CFLAGS += -DNO_SETENV
441 COMPAT_OBJS += compat/setenv.o
442endif
443ifdef NO_SETENV
444 COMPAT_CFLAGS += -DNO_UNSETENV
445 COMPAT_OBJS += compat/unsetenv.o
446endif
447ifdef NO_MMAP
448 COMPAT_CFLAGS += -DNO_MMAP
449 COMPAT_OBJS += compat/mmap.o
450endif
451ifdef NO_IPV6
452 ALL_CFLAGS += -DNO_IPV6
453endif
454ifdef NO_SOCKADDR_STORAGE
455ifdef NO_IPV6
456 ALL_CFLAGS += -Dsockaddr_storage=sockaddr_in
457else
458 ALL_CFLAGS += -Dsockaddr_storage=sockaddr_in6
459endif
460endif
461ifdef NO_INET_NTOP
462 LIB_OBJS += compat/inet_ntop.o
463endif
464
465ifdef NO_ICONV
466 ALL_CFLAGS += -DNO_ICONV
467endif
468
469ifdef PPC_SHA1
470 SHA1_HEADER = "ppc/sha1.h"
471 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
472else
473ifdef ARM_SHA1
474 SHA1_HEADER = "arm/sha1.h"
475 LIB_OBJS += arm/sha1.o arm/sha1_arm.o
476else
477ifdef MOZILLA_SHA1
478 SHA1_HEADER = "mozilla-sha1/sha1.h"
479 LIB_OBJS += mozilla-sha1/sha1.o
480else
481 SHA1_HEADER = <openssl/sha.h>
482 LIBS += $(LIB_4_CRYPTO)
483endif
484endif
485endif
486ifdef NO_ACCURATE_DIFF
487 ALL_CFLAGS += -DNO_ACCURATE_DIFF
488endif
489
490# Shell quote (do not use $(call) to accommodate ancient setups);
491
492SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
493
494DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
495bindir_SQ = $(subst ','\'',$(bindir))
496gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
497template_dir_SQ = $(subst ','\'',$(template_dir))
498prefix_SQ = $(subst ','\'',$(prefix))
499
500SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
501PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
502PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
503GIT_PYTHON_DIR_SQ = $(subst ','\'',$(GIT_PYTHON_DIR))
504
505ALL_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
506LIB_OBJS += $(COMPAT_OBJS)
507export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
508### Build rules
509
510all: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk
511
512all:
513 $(MAKE) -C templates
514
515strip: $(PROGRAMS) git$X
516 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
517
518git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS) GIT-CFLAGS
519 $(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
520 $(ALL_CFLAGS) -o $@ $(filter %.c,$^) \
521 $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
522
523builtin-help.o: common-cmds.h
524
525$(BUILT_INS): git$X
526 rm -f $@ && ln git$X $@
527
528common-cmds.h: Documentation/git-*.txt
529 ./generate-cmdlist.sh > $@+
530 mv $@+ $@
531
532$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
533 rm -f $@ $@+
534 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
535 -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
536 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
537 -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
538 -e 's/@@NO_PYTHON@@/$(NO_PYTHON)/g' \
539 $@.sh >$@+
540 chmod +x $@+
541 mv $@+ $@
542
543$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
544 rm -f $@ $@+
545 sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
546 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
547 $@.perl >$@+
548 chmod +x $@+
549 mv $@+ $@
550
551$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py GIT-CFLAGS
552 rm -f $@ $@+
553 sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
554 -e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR_SQ)|g' \
555 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
556 $@.py >$@+
557 chmod +x $@+
558 mv $@+ $@
559
560git-cherry-pick: git-revert
561 cp $< $@+
562 mv $@+ $@
563
564git-status: git-commit
565 cp $< $@+
566 mv $@+ $@
567
568git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
569 rm -f $@ $@+
570 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
571 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
572 -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
573 -e 's/@@NO_PYTHON@@/$(NO_PYTHON)/g' \
574 -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
575 -e '/@@GITWEB_CGI@@/d' \
576 -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
577 -e '/@@GITWEB_CSS@@/d' \
578 $@.sh > $@+
579 chmod +x $@+
580 mv $@+ $@
581
582# These can record GIT_VERSION
583git$X git.spec \
584 $(patsubst %.sh,%,$(SCRIPT_SH)) \
585 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
586 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
587 : GIT-VERSION-FILE
588
589%.o: %.c GIT-CFLAGS
590 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
591%.o: %.S
592 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
593
594exec_cmd.o: exec_cmd.c GIT-CFLAGS
595 $(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
596builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
597 $(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
598
599http.o: http.c GIT-CFLAGS
600 $(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
601
602ifdef NO_EXPAT
603http-fetch.o: http-fetch.c http.h GIT-CFLAGS
604 $(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
605endif
606
607git-%$X: %.o $(GITLIBS)
608 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
609
610$(SIMPLE_PROGRAMS) : $(LIB_FILE)
611$(SIMPLE_PROGRAMS) : git-%$X : %.o
612 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
613 $(LIB_FILE) $(SIMPLE_LIB)
614
615git-local-fetch$X: fetch.o
616git-ssh-fetch$X: rsh.o fetch.o
617git-ssh-upload$X: rsh.o
618git-ssh-pull$X: rsh.o fetch.o
619git-ssh-push$X: rsh.o
620
621git-imap-send$X: imap-send.o $(LIB_FILE)
622
623http.o http-fetch.o http-push.o: http.h
624git-http-fetch$X: fetch.o http.o http-fetch.o $(GITLIBS)
625 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
626 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
627
628git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
629 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
630 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
631
632$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
633$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
634$(DIFF_OBJS): diffcore.h
635
636$(LIB_FILE): $(LIB_OBJS)
637 rm -f $@ && $(AR) rcs $@ $(LIB_OBJS)
638
639XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o
640
641$(XDIFF_LIB): $(XDIFF_OBJS)
642 rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)
643
644
645doc:
646 $(MAKE) -C Documentation all
647
648TAGS:
649 rm -f TAGS
650 find . -name '*.[hcS]' -print | xargs etags -a
651
652tags:
653 rm -f tags
654 find . -name '*.[hcS]' -print | xargs ctags -a
655
656### Detect prefix changes
657TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):$(GIT_PYTHON_DIR_SQ):\
658 $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
659
660GIT-CFLAGS: .FORCE-GIT-CFLAGS
661 @FLAGS='$(TRACK_CFLAGS)'; \
662 if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
663 echo 1>&2 " * new build flags or prefix"; \
664 echo "$$FLAGS" >GIT-CFLAGS; \
665 fi
666
667### Testing rules
668
669# GNU make supports exporting all variables by "export" without parameters.
670# However, the environment gets quite big, and some programs have problems
671# with that.
672
673export NO_PYTHON
674export NO_SVN_TESTS
675
676test: all
677 $(MAKE) -C t/ all
678
679test-date$X: test-date.c date.o ctype.o
680 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) test-date.c date.o ctype.o
681
682test-delta$X: test-delta.c diff-delta.o patch-delta.o
683 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $^
684
685test-dump-cache-tree$X: dump-cache-tree.o $(GITLIBS)
686 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
687
688test-sha1$X: test-sha1.o $(GITLIBS)
689 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
690
691check-sha1:: test-sha1$X
692 ./test-sha1.sh
693
694check:
695 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done
696
697
698
699### Installation rules
700
701install: all
702 $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(bindir_SQ)'
703 $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
704 $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
705 $(INSTALL) git$X gitk '$(DESTDIR_SQ)$(bindir_SQ)'
706 $(MAKE) -C templates install
707 $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
708 $(INSTALL) $(PYMODULES) '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
709 if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
710 then \
711 ln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
712 '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' || \
713 cp '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
714 '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'; \
715 fi
716 $(foreach p,$(BUILT_INS), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
717
718install-doc:
719 $(MAKE) -C Documentation install
720
721
722
723
724### Maintainer's dist rules
725
726git.spec: git.spec.in
727 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
728 mv $@+ $@
729
730GIT_TARNAME=git-$(GIT_VERSION)
731dist: git.spec git-tar-tree
732 ./git-tar-tree HEAD^{tree} $(GIT_TARNAME) > $(GIT_TARNAME).tar
733 @mkdir -p $(GIT_TARNAME)
734 @cp git.spec $(GIT_TARNAME)
735 @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
736 $(TAR) rf $(GIT_TARNAME).tar \
737 $(GIT_TARNAME)/git.spec $(GIT_TARNAME)/version
738 @rm -rf $(GIT_TARNAME)
739 gzip -f -9 $(GIT_TARNAME).tar
740
741rpm: dist
742 $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
743
744htmldocs = git-htmldocs-$(GIT_VERSION)
745manpages = git-manpages-$(GIT_VERSION)
746dist-doc:
747 rm -fr .doc-tmp-dir
748 mkdir .doc-tmp-dir
749 $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
750 cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
751 gzip -n -9 -f $(htmldocs).tar
752 :
753 rm -fr .doc-tmp-dir
754 mkdir .doc-tmp-dir .doc-tmp-dir/man1 .doc-tmp-dir/man7
755 $(MAKE) -C Documentation DESTDIR=./ \
756 man1=../.doc-tmp-dir/man1 \
757 man7=../.doc-tmp-dir/man7 \
758 install
759 cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
760 gzip -n -9 -f $(manpages).tar
761 rm -fr .doc-tmp-dir
762
763### Cleaning rules
764
765clean:
766 rm -f *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \
767 $(LIB_FILE) $(XDIFF_LIB)
768 rm -f $(ALL_PROGRAMS) $(BUILT_INS) git$X
769 rm -f *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags
770 rm -rf $(GIT_TARNAME) .doc-tmp-dir
771 rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
772 rm -f $(htmldocs).tar.gz $(manpages).tar.gz
773 $(MAKE) -C Documentation/ clean
774 $(MAKE) -C templates clean
775 $(MAKE) -C t/ clean
776 rm -f GIT-VERSION-FILE GIT-CFLAGS
777
778.PHONY: all install clean strip
779.PHONY: .FORCE-GIT-VERSION-FILE TAGS tags .FORCE-GIT-CFLAGS
780
781### Check documentation
782#
783check-docs::
784 @for v in $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk; \
785 do \
786 case "$$v" in \
787 git-merge-octopus | git-merge-ours | git-merge-recursive | \
788 git-merge-resolve | git-merge-stupid | \
789 git-ssh-pull | git-ssh-push ) continue ;; \
790 esac ; \
791 test -f "Documentation/$$v.txt" || \
792 echo "no doc: $$v"; \
793 grep -q "^gitlink:$$v\[[0-9]\]::" Documentation/git.txt || \
794 case "$$v" in \
795 git) ;; \
796 *) echo "no link: $$v";; \
797 esac ; \
798 done | sort