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