]> asedeno.scripts.mit.edu Git - git.git/blob - Makefile
NO_TCLTK
[git.git] / Makefile
1 # The default target of this Makefile is...
2 all::
3
4 # Define V=1 to have a more verbose compile.
5 #
6 # Define NO_OPENSSL environment variable if you do not have OpenSSL.
7 # This also implies MOZILLA_SHA1.
8 #
9 # Define NO_CURL if you do not have curl installed.  git-http-pull and
10 # git-http-push are not built, and you cannot use http:// and https://
11 # transports.
12 #
13 # Define CURLDIR=/foo/bar if your curl header and library files are in
14 # /foo/bar/include and /foo/bar/lib directories.
15 #
16 # Define NO_EXPAT if you do not have expat installed.  git-http-push is
17 # not built, and you cannot push using http:// and https:// transports.
18 #
19 # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
20 #
21 # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
22 # d_type in struct dirent (latest Cygwin -- will be fixed soonish).
23 #
24 # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
25 # do not support the 'size specifiers' introduced by C99, namely ll, hh,
26 # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
27 # some C compilers supported these specifiers prior to C99 as an extension.
28 #
29 # Define NO_STRCASESTR if you don't have strcasestr.
30 #
31 # Define NO_STRLCPY if you don't have strlcpy.
32 #
33 # Define NO_STRTOUMAX if you don't have strtoumax in the C library.
34 # If your compiler also does not support long long or does not have
35 # strtoull, define NO_STRTOULL.
36 #
37 # Define NO_SETENV if you don't have setenv in the C library.
38 #
39 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
40 # Enable it on Windows.  By default, symrefs are still used.
41 #
42 # Define NO_SVN_TESTS if you want to skip time-consuming SVN interoperability
43 # tests.  These tests take up a significant amount of the total test time
44 # but are not needed unless you plan to talk to SVN repos.
45 #
46 # Define NO_FINK if you are building on Darwin/Mac OS X, have Fink
47 # installed in /sw, but don't want GIT to link against any libraries
48 # installed there.  If defined you may specify your own (or Fink's)
49 # include directories and library directories by defining CFLAGS
50 # and LDFLAGS appropriately.
51 #
52 # Define NO_DARWIN_PORTS if you are building on Darwin/Mac OS X,
53 # have DarwinPorts installed in /opt/local, but don't want GIT to
54 # link against any libraries installed there.  If defined you may
55 # specify your own (or DarwinPort's) include directories and
56 # library directories by defining CFLAGS and LDFLAGS appropriately.
57 #
58 # Define PPC_SHA1 environment variable when running make to make use of
59 # a bundled SHA1 routine optimized for PowerPC.
60 #
61 # Define ARM_SHA1 environment variable when running make to make use of
62 # a bundled SHA1 routine optimized for ARM.
63 #
64 # Define MOZILLA_SHA1 environment variable when running make to make use of
65 # a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
66 # on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
67 # choice) has very fast version optimized for i586.
68 #
69 # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
70 #
71 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
72 #
73 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
74 # Patrick Mauritz).
75 #
76 # Define NO_MMAP if you want to avoid mmap.
77 #
78 # Define NO_PREAD if you have a problem with pread() system call (e.g.
79 # cygwin.dll before v1.5.22).
80 #
81 # Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
82 # generally faster on your platform than accessing the working directory.
83 #
84 # Define NO_TRUSTABLE_FILEMODE if your filesystem may claim to support
85 # the executable mode bit, but doesn't really do so.
86 #
87 # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
88 #
89 # Define NO_SOCKADDR_STORAGE if your platform does not have struct
90 # sockaddr_storage.
91 #
92 # Define NO_ICONV if your libc does not properly support iconv.
93 #
94 # Define OLD_ICONV if your library has an old iconv(), where the second
95 # (input buffer pointer) parameter is declared with type (const char **).
96 #
97 # Define NO_R_TO_GCC if your gcc does not like "-R/path/lib" that
98 # tells runtime paths to dynamic libraries; "-Wl,-rpath=/path/lib"
99 # is used instead.
100 #
101 # Define USE_NSEC below if you want git to care about sub-second file mtimes
102 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
103 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
104 # randomly break unless your underlying filesystem supports those sub-second
105 # times (my ext3 doesn't).
106 #
107 # Define USE_STDEV below if you want git to care about the underlying device
108 # change being considered an inode change from the update-cache perspective.
109 #
110 # Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
111 # MakeMaker (e.g. using ActiveState under Cygwin).
112 #
113 # Define NO_TCLTK if you do not want Tcl/Tk GUI.
114 #
115
116 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
117         @$(SHELL_PATH) ./GIT-VERSION-GEN
118 -include GIT-VERSION-FILE
119
120 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
121 uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
122 uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
123 uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
124 uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
125
126 # CFLAGS and LDFLAGS are for the users to override from the command line.
127
128 CFLAGS = -g -O2 -Wall
129 LDFLAGS =
130 ALL_CFLAGS = $(CFLAGS)
131 ALL_LDFLAGS = $(LDFLAGS)
132 STRIP ?= strip
133
134 prefix = $(HOME)
135 bindir = $(prefix)/bin
136 gitexecdir = $(bindir)
137 template_dir = $(prefix)/share/git-core/templates/
138 ETC_GITCONFIG = $(prefix)/etc/gitconfig
139 # DESTDIR=
140
141 # default configuration for gitweb
142 GITWEB_CONFIG = gitweb_config.perl
143 GITWEB_HOME_LINK_STR = projects
144 GITWEB_SITENAME =
145 GITWEB_PROJECTROOT = /pub/git
146 GITWEB_EXPORT_OK =
147 GITWEB_STRICT_EXPORT =
148 GITWEB_BASE_URL =
149 GITWEB_LIST =
150 GITWEB_HOMETEXT = indextext.html
151 GITWEB_CSS = gitweb.css
152 GITWEB_LOGO = git-logo.png
153 GITWEB_FAVICON = git-favicon.png
154 GITWEB_SITE_HEADER =
155 GITWEB_SITE_FOOTER =
156
157 export prefix bindir gitexecdir template_dir
158
159 CC = gcc
160 AR = ar
161 TAR = tar
162 INSTALL = install
163 RPMBUILD = rpmbuild
164
165 # sparse is architecture-neutral, which means that we need to tell it
166 # explicitly what architecture to check for. Fix this up for yours..
167 SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
168
169
170
171 ### --- END CONFIGURATION SECTION ---
172
173 # Those must not be GNU-specific; they are shared with perl/ which may
174 # be built by a different compiler. (Note that this is an artifact now
175 # but it still might be nice to keep that distinction.)
176 BASIC_CFLAGS =
177 BASIC_LDFLAGS =
178
179 SCRIPT_SH = \
180         git-bisect.sh git-checkout.sh \
181         git-clean.sh git-clone.sh git-commit.sh \
182         git-fetch.sh \
183         git-ls-remote.sh \
184         git-merge-one-file.sh git-mergetool.sh git-parse-remote.sh \
185         git-pull.sh git-rebase.sh \
186         git-repack.sh git-request-pull.sh git-reset.sh \
187         git-sh-setup.sh \
188         git-tag.sh git-verify-tag.sh \
189         git-applymbox.sh git-applypatch.sh git-am.sh \
190         git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
191         git-merge-resolve.sh git-merge-ours.sh \
192         git-lost-found.sh git-quiltimport.sh
193
194 SCRIPT_PERL = \
195         git-add--interactive.perl \
196         git-archimport.perl git-cvsimport.perl git-relink.perl \
197         git-cvsserver.perl git-remote.perl \
198         git-svnimport.perl git-cvsexportcommit.perl \
199         git-send-email.perl git-svn.perl
200
201 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
202           $(patsubst %.perl,%,$(SCRIPT_PERL)) \
203           git-status git-instaweb
204
205 # ... and all the rest that could be moved out of bindir to gitexecdir
206 PROGRAMS = \
207         git-convert-objects$X git-fetch-pack$X git-fsck$X \
208         git-hash-object$X git-index-pack$X git-local-fetch$X \
209         git-fast-import$X \
210         git-merge-base$X \
211         git-daemon$X \
212         git-merge-index$X git-mktag$X git-mktree$X git-patch-id$X \
213         git-peek-remote$X git-receive-pack$X \
214         git-send-pack$X git-shell$X \
215         git-show-index$X git-ssh-fetch$X \
216         git-ssh-upload$X git-unpack-file$X \
217         git-update-server-info$X \
218         git-upload-pack$X git-verify-pack$X \
219         git-pack-redundant$X git-var$X \
220         git-merge-tree$X git-imap-send$X \
221         git-merge-recursive$X \
222         $(EXTRA_PROGRAMS)
223
224 # Empty...
225 EXTRA_PROGRAMS =
226
227 BUILT_INS = \
228         git-format-patch$X git-show$X git-whatchanged$X git-cherry$X \
229         git-get-tar-commit-id$X git-init$X git-repo-config$X \
230         git-fsck-objects$X git-cherry-pick$X \
231         $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
232
233 # what 'all' will build and 'install' will install, in gitexecdir
234 ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
235
236 # what 'all' will build but not install in gitexecdir
237 OTHER_PROGRAMS = git$X gitweb/gitweb.cgi
238 ifndef NO_TCLTK
239 OTHER_PROGRAMS += gitk
240 endif
241
242 # Backward compatibility -- to be removed after 1.0
243 PROGRAMS += git-ssh-pull$X git-ssh-push$X
244
245 # Set paths to tools early so that they can be used for version tests.
246 ifndef SHELL_PATH
247         SHELL_PATH = /bin/sh
248 endif
249 ifndef PERL_PATH
250         PERL_PATH = /usr/bin/perl
251 endif
252
253 export PERL_PATH
254
255 LIB_FILE=libgit.a
256 XDIFF_LIB=xdiff/lib.a
257
258 LIB_H = \
259         archive.h blob.h cache.h commit.h csum-file.h delta.h grep.h \
260         diff.h object.h pack.h pkt-line.h quote.h refs.h list-objects.h sideband.h \
261         run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
262         tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \
263         utf8.h reflog-walk.h
264
265 DIFF_OBJS = \
266         diff.o diff-lib.o diffcore-break.o diffcore-order.o \
267         diffcore-pickaxe.o diffcore-rename.o tree-diff.o combine-diff.o \
268         diffcore-delta.o log-tree.o
269
270 LIB_OBJS = \
271         blob.o commit.o connect.o csum-file.o cache-tree.o base85.o \
272         date.o diff-delta.o entry.o exec_cmd.o ident.o \
273         interpolate.o \
274         lockfile.o \
275         object.o pack-check.o patch-delta.o path.o pkt-line.o sideband.o \
276         reachable.o reflog-walk.o \
277         quote.o read-cache.o refs.o run-command.o dir.o object-refs.o \
278         server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
279         tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
280         revision.o pager.o tree-walk.o xdiff-interface.o \
281         write_or_die.o trace.o list-objects.o grep.o \
282         alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \
283         color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \
284         convert.o
285
286 BUILTIN_OBJS = \
287         builtin-add.o \
288         builtin-annotate.o \
289         builtin-apply.o \
290         builtin-archive.o \
291         builtin-blame.o \
292         builtin-branch.o \
293         builtin-bundle.o \
294         builtin-cat-file.o \
295         builtin-checkout-index.o \
296         builtin-check-ref-format.o \
297         builtin-commit-tree.o \
298         builtin-count-objects.o \
299         builtin-describe.o \
300         builtin-diff.o \
301         builtin-diff-files.o \
302         builtin-diff-index.o \
303         builtin-diff-tree.o \
304         builtin-fetch--tool.o \
305         builtin-fmt-merge-msg.o \
306         builtin-for-each-ref.o \
307         builtin-fsck.o \
308         builtin-gc.o \
309         builtin-grep.o \
310         builtin-init-db.o \
311         builtin-log.o \
312         builtin-ls-files.o \
313         builtin-ls-tree.o \
314         builtin-mailinfo.o \
315         builtin-mailsplit.o \
316         builtin-merge-base.o \
317         builtin-merge-file.o \
318         builtin-mv.o \
319         builtin-name-rev.o \
320         builtin-pack-objects.o \
321         builtin-prune.o \
322         builtin-prune-packed.o \
323         builtin-push.o \
324         builtin-read-tree.o \
325         builtin-reflog.o \
326         builtin-config.o \
327         builtin-rerere.o \
328         builtin-rev-list.o \
329         builtin-rev-parse.o \
330         builtin-revert.o \
331         builtin-rm.o \
332         builtin-runstatus.o \
333         builtin-shortlog.o \
334         builtin-show-branch.o \
335         builtin-stripspace.o \
336         builtin-symbolic-ref.o \
337         builtin-tar-tree.o \
338         builtin-unpack-objects.o \
339         builtin-update-index.o \
340         builtin-update-ref.o \
341         builtin-upload-archive.o \
342         builtin-verify-pack.o \
343         builtin-write-tree.o \
344         builtin-show-ref.o \
345         builtin-pack-refs.o
346
347 GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
348 EXTLIBS = -lz
349
350 #
351 # Platform specific tweaks
352 #
353
354 # We choose to avoid "if .. else if .. else .. endif endif"
355 # because maintaining the nesting to match is a pain.  If
356 # we had "elif" things would have been much nicer...
357
358 ifeq ($(uname_S),Linux)
359         NO_STRLCPY = YesPlease
360 endif
361 ifeq ($(uname_S),GNU/kFreeBSD)
362         NO_STRLCPY = YesPlease
363 endif
364 ifeq ($(uname_S),Darwin)
365         NEEDS_SSL_WITH_CRYPTO = YesPlease
366         NEEDS_LIBICONV = YesPlease
367         NO_STRLCPY = YesPlease
368 endif
369 ifeq ($(uname_S),SunOS)
370         NEEDS_SOCKET = YesPlease
371         NEEDS_NSL = YesPlease
372         SHELL_PATH = /bin/bash
373         NO_STRCASESTR = YesPlease
374         ifeq ($(uname_R),5.8)
375                 NEEDS_LIBICONV = YesPlease
376                 NO_UNSETENV = YesPlease
377                 NO_SETENV = YesPlease
378                 NO_C99_FORMAT = YesPlease
379                 NO_STRTOUMAX = YesPlease
380         endif
381         ifeq ($(uname_R),5.9)
382                 NO_UNSETENV = YesPlease
383                 NO_SETENV = YesPlease
384                 NO_C99_FORMAT = YesPlease
385                 NO_STRTOUMAX = YesPlease
386         endif
387         INSTALL = ginstall
388         TAR = gtar
389         BASIC_CFLAGS += -D__EXTENSIONS__
390 endif
391 ifeq ($(uname_O),Cygwin)
392         NO_D_TYPE_IN_DIRENT = YesPlease
393         NO_D_INO_IN_DIRENT = YesPlease
394         NO_STRCASESTR = YesPlease
395         NO_SYMLINK_HEAD = YesPlease
396         NEEDS_LIBICONV = YesPlease
397         NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
398         NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
399         # There are conflicting reports about this.
400         # On some boxes NO_MMAP is needed, and not so elsewhere.
401         # Try commenting this out if you suspect MMAP is more efficient
402         NO_MMAP = YesPlease
403         NO_IPV6 = YesPlease
404         X = .exe
405 endif
406 ifeq ($(uname_S),FreeBSD)
407         NEEDS_LIBICONV = YesPlease
408         BASIC_CFLAGS += -I/usr/local/include
409         BASIC_LDFLAGS += -L/usr/local/lib
410 endif
411 ifeq ($(uname_S),OpenBSD)
412         NO_STRCASESTR = YesPlease
413         NEEDS_LIBICONV = YesPlease
414         BASIC_CFLAGS += -I/usr/local/include
415         BASIC_LDFLAGS += -L/usr/local/lib
416 endif
417 ifeq ($(uname_S),NetBSD)
418         ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
419                 NEEDS_LIBICONV = YesPlease
420         endif
421         BASIC_CFLAGS += -I/usr/pkg/include
422         BASIC_LDFLAGS += -L/usr/pkg/lib
423         ALL_LDFLAGS += -Wl,-rpath,/usr/pkg/lib
424 endif
425 ifeq ($(uname_S),AIX)
426         NO_STRCASESTR=YesPlease
427         NO_STRLCPY = YesPlease
428         NEEDS_LIBICONV=YesPlease
429 endif
430 ifeq ($(uname_S),IRIX64)
431         NO_IPV6=YesPlease
432         NO_SETENV=YesPlease
433         NO_STRCASESTR=YesPlease
434         NO_STRLCPY = YesPlease
435         NO_SOCKADDR_STORAGE=YesPlease
436         SHELL_PATH=/usr/gnu/bin/bash
437         BASIC_CFLAGS += -DPATH_MAX=1024
438         # for now, build 32-bit version
439         BASIC_LDFLAGS += -L/usr/lib32
440 endif
441 ifneq (,$(findstring arm,$(uname_M)))
442         ARM_SHA1 = YesPlease
443 endif
444
445 -include config.mak.autogen
446 -include config.mak
447
448 ifeq ($(uname_S),Darwin)
449         ifndef NO_FINK
450                 ifeq ($(shell test -d /sw/lib && echo y),y)
451                         BASIC_CFLAGS += -I/sw/include
452                         BASIC_LDFLAGS += -L/sw/lib
453                 endif
454         endif
455         ifndef NO_DARWIN_PORTS
456                 ifeq ($(shell test -d /opt/local/lib && echo y),y)
457                         BASIC_CFLAGS += -I/opt/local/include
458                         BASIC_LDFLAGS += -L/opt/local/lib
459                 endif
460         endif
461 endif
462
463 ifdef NO_R_TO_GCC_LINKER
464         # Some gcc does not accept and pass -R to the linker to specify
465         # the runtime dynamic library path.
466         CC_LD_DYNPATH = -Wl,-rpath=
467 else
468         CC_LD_DYNPATH = -R
469 endif
470
471 ifndef NO_CURL
472         ifdef CURLDIR
473                 # Try "-Wl,-rpath=$(CURLDIR)/lib" in such a case.
474                 BASIC_CFLAGS += -I$(CURLDIR)/include
475                 CURL_LIBCURL = -L$(CURLDIR)/lib $(CC_LD_DYNPATH)$(CURLDIR)/lib -lcurl
476         else
477                 CURL_LIBCURL = -lcurl
478         endif
479         PROGRAMS += git-http-fetch$X
480         curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
481         ifeq "$(curl_check)" "070908"
482                 ifndef NO_EXPAT
483                         PROGRAMS += git-http-push$X
484                 endif
485         endif
486         ifndef NO_EXPAT
487                 EXPAT_LIBEXPAT = -lexpat
488         endif
489 endif
490
491 ifndef NO_OPENSSL
492         OPENSSL_LIBSSL = -lssl
493         ifdef OPENSSLDIR
494                 BASIC_CFLAGS += -I$(OPENSSLDIR)/include
495                 OPENSSL_LINK = -L$(OPENSSLDIR)/lib $(CC_LD_DYNPATH)$(OPENSSLDIR)/lib
496         else
497                 OPENSSL_LINK =
498         endif
499 else
500         BASIC_CFLAGS += -DNO_OPENSSL
501         MOZILLA_SHA1 = 1
502         OPENSSL_LIBSSL =
503 endif
504 ifdef NEEDS_SSL_WITH_CRYPTO
505         LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
506 else
507         LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
508 endif
509 ifdef NEEDS_LIBICONV
510         ifdef ICONVDIR
511                 BASIC_CFLAGS += -I$(ICONVDIR)/include
512                 ICONV_LINK = -L$(ICONVDIR)/lib $(CC_LD_DYNPATH)$(ICONVDIR)/lib
513         else
514                 ICONV_LINK =
515         endif
516         EXTLIBS += $(ICONV_LINK) -liconv
517 endif
518 ifdef NEEDS_SOCKET
519         EXTLIBS += -lsocket
520 endif
521 ifdef NEEDS_NSL
522         EXTLIBS += -lnsl
523 endif
524 ifdef NO_D_TYPE_IN_DIRENT
525         BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT
526 endif
527 ifdef NO_D_INO_IN_DIRENT
528         BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
529 endif
530 ifdef NO_C99_FORMAT
531         BASIC_CFLAGS += -DNO_C99_FORMAT
532 endif
533 ifdef NO_SYMLINK_HEAD
534         BASIC_CFLAGS += -DNO_SYMLINK_HEAD
535 endif
536 ifdef NO_STRCASESTR
537         COMPAT_CFLAGS += -DNO_STRCASESTR
538         COMPAT_OBJS += compat/strcasestr.o
539 endif
540 ifdef NO_STRLCPY
541         COMPAT_CFLAGS += -DNO_STRLCPY
542         COMPAT_OBJS += compat/strlcpy.o
543 endif
544 ifdef NO_STRTOUMAX
545         COMPAT_CFLAGS += -DNO_STRTOUMAX
546         COMPAT_OBJS += compat/strtoumax.o
547 endif
548 ifdef NO_STRTOULL
549         COMPAT_CFLAGS += -DNO_STRTOULL
550 endif
551 ifdef NO_SETENV
552         COMPAT_CFLAGS += -DNO_SETENV
553         COMPAT_OBJS += compat/setenv.o
554 endif
555 ifdef NO_UNSETENV
556         COMPAT_CFLAGS += -DNO_UNSETENV
557         COMPAT_OBJS += compat/unsetenv.o
558 endif
559 ifdef NO_MMAP
560         COMPAT_CFLAGS += -DNO_MMAP
561         COMPAT_OBJS += compat/mmap.o
562 endif
563 ifdef NO_PREAD
564         COMPAT_CFLAGS += -DNO_PREAD
565         COMPAT_OBJS += compat/pread.o
566 endif
567 ifdef NO_FAST_WORKING_DIRECTORY
568         BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
569 endif
570 ifdef NO_TRUSTABLE_FILEMODE
571         BASIC_CFLAGS += -DNO_TRUSTABLE_FILEMODE
572 endif
573 ifdef NO_IPV6
574         BASIC_CFLAGS += -DNO_IPV6
575 endif
576 ifdef NO_SOCKADDR_STORAGE
577 ifdef NO_IPV6
578         BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
579 else
580         BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6
581 endif
582 endif
583 ifdef NO_INET_NTOP
584         LIB_OBJS += compat/inet_ntop.o
585 endif
586 ifdef NO_INET_PTON
587         LIB_OBJS += compat/inet_pton.o
588 endif
589
590 ifdef NO_ICONV
591         BASIC_CFLAGS += -DNO_ICONV
592 endif
593
594 ifdef OLD_ICONV
595         BASIC_CFLAGS += -DOLD_ICONV
596 endif
597
598 ifdef PPC_SHA1
599         SHA1_HEADER = "ppc/sha1.h"
600         LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
601 else
602 ifdef ARM_SHA1
603         SHA1_HEADER = "arm/sha1.h"
604         LIB_OBJS += arm/sha1.o arm/sha1_arm.o
605 else
606 ifdef MOZILLA_SHA1
607         SHA1_HEADER = "mozilla-sha1/sha1.h"
608         LIB_OBJS += mozilla-sha1/sha1.o
609 else
610         SHA1_HEADER = <openssl/sha.h>
611         EXTLIBS += $(LIB_4_CRYPTO)
612 endif
613 endif
614 endif
615 ifdef NO_PERL_MAKEMAKER
616         export NO_PERL_MAKEMAKER
617 endif
618
619 QUIET_SUBDIR0  = $(MAKE) -C # space to separate -C and subdir
620 QUIET_SUBDIR1  =
621
622 ifneq ($(findstring $(MAKEFLAGS),w),w)
623 PRINT_DIR = --no-print-directory
624 else # "make -w"
625 NO_SUBDIR = :
626 endif
627
628 ifneq ($(findstring $(MAKEFLAGS),s),s)
629 ifndef V
630         QUIET_CC       = @echo '   ' CC $@;
631         QUIET_AR       = @echo '   ' AR $@;
632         QUIET_LINK     = @echo '   ' LINK $@;
633         QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
634         QUIET_GEN      = @echo '   ' GEN $@;
635         QUIET_SUBDIR0  = @subdir=
636         QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
637                          $(MAKE) $(PRINT_DIR) -C $$subdir
638         export V
639         export QUIET_GEN
640         export QUIET_BUILT_IN
641 endif
642 endif
643
644 # Shell quote (do not use $(call) to accommodate ancient setups);
645
646 SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
647 ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
648
649 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
650 bindir_SQ = $(subst ','\'',$(bindir))
651 gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
652 template_dir_SQ = $(subst ','\'',$(template_dir))
653 prefix_SQ = $(subst ','\'',$(prefix))
654
655 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
656 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
657
658 LIBS = $(GITLIBS) $(EXTLIBS)
659
660 BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
661         -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' $(COMPAT_CFLAGS)
662 LIB_OBJS += $(COMPAT_OBJS)
663
664 ALL_CFLAGS += $(BASIC_CFLAGS)
665 ALL_LDFLAGS += $(BASIC_LDFLAGS)
666
667 export prefix gitexecdir TAR INSTALL DESTDIR SHELL_PATH template_dir
668
669
670 ### Build rules
671
672 all:: $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS)
673 ifneq (,$X)
674         $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), rm -f '$p';)
675 endif
676
677 all::
678 ifndef NO_TCLTK
679         $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) all
680 endif
681         $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
682         $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
683
684 strip: $(PROGRAMS) git$X
685         $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
686
687 git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS) GIT-CFLAGS
688         $(QUIET_LINK)$(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
689                 $(ALL_CFLAGS) -o $@ $(filter %.c,$^) \
690                 $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
691
692 help.o: common-cmds.h
693
694 $(BUILT_INS): git$X
695         $(QUIET_BUILT_IN)rm -f $@ && ln git$X $@
696
697 common-cmds.h: Documentation/git-*.txt
698         $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
699
700 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
701         $(QUIET_GEN)rm -f $@ $@+ && \
702         sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
703             -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
704             -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
705             -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
706             $@.sh >$@+ && \
707         chmod +x $@+ && \
708         mv $@+ $@
709
710 $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
711
712 perl/perl.mak: GIT-CFLAGS
713         $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
714
715 $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
716         $(QUIET_GEN)rm -f $@ $@+ && \
717         INSTLIBDIR=`$(MAKE) -C perl -s --no-print-directory instlibdir` && \
718         sed -e '1{' \
719             -e '        s|#!.*perl|#!$(PERL_PATH_SQ)|' \
720             -e '        h' \
721             -e '        s=.*=use lib (split(/:/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
722             -e '        H' \
723             -e '        x' \
724             -e '}' \
725             -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
726             -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
727             $@.perl >$@+ && \
728         chmod +x $@+ && \
729         mv $@+ $@
730
731 git-status: git-commit
732         $(QUIET_GEN)cp $< $@+ && mv $@+ $@
733
734 gitweb/gitweb.cgi: gitweb/gitweb.perl
735         $(QUIET_GEN)rm -f $@ $@+ && \
736         sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
737             -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
738             -e 's|++GIT_BINDIR++|$(bindir)|g' \
739             -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
740             -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
741             -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
742             -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
743             -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
744             -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
745             -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
746             -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \
747             -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \
748             -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
749             -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
750             -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
751             -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
752             -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
753             $< >$@+ && \
754         chmod +x $@+ && \
755         mv $@+ $@
756
757 git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
758         $(QUIET_GEN)rm -f $@ $@+ && \
759         sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
760             -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
761             -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
762             -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
763             -e '/@@GITWEB_CGI@@/d' \
764             -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
765             -e '/@@GITWEB_CSS@@/d' \
766             $@.sh > $@+ && \
767         chmod +x $@+ && \
768         mv $@+ $@
769
770 configure: configure.ac
771         $(QUIET_GEN)rm -f $@ $<+ && \
772         sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
773             $< > $<+ && \
774         autoconf -o $@ $<+ && \
775         rm -f $<+
776
777 # These can record GIT_VERSION
778 git$X git.spec \
779         $(patsubst %.sh,%,$(SCRIPT_SH)) \
780         $(patsubst %.perl,%,$(SCRIPT_PERL)) \
781         : GIT-VERSION-FILE
782
783 %.o: %.c GIT-CFLAGS
784         $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
785 %.o: %.S
786         $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
787
788 exec_cmd.o: exec_cmd.c GIT-CFLAGS
789         $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
790 builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
791         $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
792
793 http.o: http.c GIT-CFLAGS
794         $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
795
796 ifdef NO_EXPAT
797 http-fetch.o: http-fetch.c http.h GIT-CFLAGS
798         $(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
799 endif
800
801 git-%$X: %.o $(GITLIBS)
802         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
803
804 ssh-pull.o: ssh-fetch.c
805 ssh-push.o: ssh-upload.c
806 git-local-fetch$X: fetch.o
807 git-ssh-fetch$X: rsh.o fetch.o
808 git-ssh-upload$X: rsh.o
809 git-ssh-pull$X: rsh.o fetch.o
810 git-ssh-push$X: rsh.o
811
812 git-imap-send$X: imap-send.o $(LIB_FILE)
813
814 http.o http-fetch.o http-push.o: http.h
815 git-http-fetch$X: fetch.o http.o http-fetch.o $(GITLIBS)
816         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
817                 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
818
819 git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
820         $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
821                 $(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
822
823 $(LIB_OBJS) $(BUILTIN_OBJS) fetch.o: $(LIB_H)
824 $(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
825 $(DIFF_OBJS): diffcore.h
826
827 $(LIB_FILE): $(LIB_OBJS)
828         $(QUIET_AR)rm -f $@ && $(AR) rcs $@ $(LIB_OBJS)
829
830 XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
831         xdiff/xmerge.o
832 $(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
833         xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
834
835 $(XDIFF_LIB): $(XDIFF_OBJS)
836         $(QUIET_AR)rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)
837
838
839 perl/Makefile: perl/Git.pm perl/Makefile.PL GIT-CFLAGS
840         (cd perl && $(PERL_PATH) Makefile.PL \
841                 PREFIX='$(prefix_SQ)')
842
843 doc:
844         $(MAKE) -C Documentation all
845
846 TAGS:
847         rm -f TAGS
848         find . -name '*.[hcS]' -print | xargs etags -a
849
850 tags:
851         rm -f tags
852         find . -name '*.[hcS]' -print | xargs ctags -a
853
854 ### Detect prefix changes
855 TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
856              $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
857
858 GIT-CFLAGS: .FORCE-GIT-CFLAGS
859         @FLAGS='$(TRACK_CFLAGS)'; \
860             if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \
861                 echo 1>&2 "    * new build flags or prefix"; \
862                 echo "$$FLAGS" >GIT-CFLAGS; \
863             fi
864
865 ### Testing rules
866
867 # GNU make supports exporting all variables by "export" without parameters.
868 # However, the environment gets quite big, and some programs have problems
869 # with that.
870
871 export NO_SVN_TESTS
872
873 test: all test-chmtime$X
874         $(MAKE) -C t/ all
875
876 test-date$X: test-date.c date.o ctype.o
877         $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) test-date.c date.o ctype.o
878
879 test-delta$X: test-delta.o diff-delta.o patch-delta.o $(GITLIBS)
880         $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
881
882 test-dump-cache-tree$X: dump-cache-tree.o $(GITLIBS)
883         $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
884
885 test-sha1$X: test-sha1.o $(GITLIBS)
886         $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
887
888 test-chmtime$X: test-chmtime.c
889         $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $<
890
891 check-sha1:: test-sha1$X
892         ./test-sha1.sh
893
894 check: common-cmds.h
895         for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done
896
897
898
899 ### Installation rules
900
901 install: all
902         $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(bindir_SQ)'
903         $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
904         $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
905         $(INSTALL) git$X '$(DESTDIR_SQ)$(bindir_SQ)'
906         $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
907         $(MAKE) -C perl prefix='$(prefix_SQ)' install
908 ifndef NO_TCLTK
909         $(INSTALL) gitk '$(DESTDIR_SQ)$(bindir_SQ)'
910         $(MAKE) -C git-gui install
911 endif
912         if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
913         then \
914                 ln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
915                         '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' || \
916                 cp '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
917                         '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'; \
918         fi
919         $(foreach p,$(BUILT_INS), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
920 ifneq (,$X)
921         $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p';)
922 endif
923
924 install-doc:
925         $(MAKE) -C Documentation install
926
927 quick-install-doc:
928         $(MAKE) -C Documentation quick-install
929
930
931
932 ### Maintainer's dist rules
933
934 git.spec: git.spec.in
935         sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
936         mv $@+ $@
937
938 GIT_TARNAME=git-$(GIT_VERSION)
939 dist: git.spec git-archive
940         ./git-archive --format=tar \
941                 --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
942         @mkdir -p $(GIT_TARNAME)
943         @cp git.spec $(GIT_TARNAME)
944         @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
945         @$(MAKE) -C git-gui TARDIR=../$(GIT_TARNAME)/git-gui dist-version
946         $(TAR) rf $(GIT_TARNAME).tar \
947                 $(GIT_TARNAME)/git.spec \
948                 $(GIT_TARNAME)/version \
949                 $(GIT_TARNAME)/git-gui/version
950         @rm -rf $(GIT_TARNAME)
951         gzip -f -9 $(GIT_TARNAME).tar
952
953 rpm: dist
954         $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
955
956 htmldocs = git-htmldocs-$(GIT_VERSION)
957 manpages = git-manpages-$(GIT_VERSION)
958 dist-doc:
959         rm -fr .doc-tmp-dir
960         mkdir .doc-tmp-dir
961         $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc
962         cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar .
963         gzip -n -9 -f $(htmldocs).tar
964         :
965         rm -fr .doc-tmp-dir
966         mkdir .doc-tmp-dir .doc-tmp-dir/man1 .doc-tmp-dir/man7
967         $(MAKE) -C Documentation DESTDIR=./ \
968                 man1dir=../.doc-tmp-dir/man1 \
969                 man7dir=../.doc-tmp-dir/man7 \
970                 install
971         cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar .
972         gzip -n -9 -f $(manpages).tar
973         rm -fr .doc-tmp-dir
974
975 ### Cleaning rules
976
977 clean:
978         rm -f *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \
979                 test-chmtime$X $(LIB_FILE) $(XDIFF_LIB)
980         rm -f $(ALL_PROGRAMS) $(BUILT_INS) git$X
981         rm -f *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags
982         rm -rf autom4te.cache
983         rm -f configure config.log config.mak.autogen config.mak.append config.status config.cache
984         rm -rf $(GIT_TARNAME) .doc-tmp-dir
985         rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
986         rm -f $(htmldocs).tar.gz $(manpages).tar.gz
987         rm -f gitweb/gitweb.cgi
988         $(MAKE) -C Documentation/ clean
989         $(MAKE) -C perl clean
990         $(MAKE) -C templates/ clean
991         $(MAKE) -C t/ clean
992 ifndef NO_TCLTK
993         $(MAKE) -C git-gui clean
994 endif
995         rm -f GIT-VERSION-FILE GIT-CFLAGS
996
997 .PHONY: all install clean strip
998 .PHONY: .FORCE-GIT-VERSION-FILE TAGS tags .FORCE-GIT-CFLAGS
999
1000 ### Check documentation
1001 #
1002 check-docs::
1003         @for v in $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk; \
1004         do \
1005                 case "$$v" in \
1006                 git-merge-octopus | git-merge-ours | git-merge-recursive | \
1007                 git-merge-resolve | git-merge-stupid | \
1008                 git-add--interactive | git-fsck-objects | git-init-db | \
1009                 git-repo-config | git-fetch--tool | \
1010                 git-ssh-pull | git-ssh-push ) continue ;; \
1011                 esac ; \
1012                 test -f "Documentation/$$v.txt" || \
1013                 echo "no doc: $$v"; \
1014                 sed -e '1,/^__DATA__/d' Documentation/cmd-list.perl | \
1015                 grep -q "^$$v[  ]" || \
1016                 case "$$v" in \
1017                 git) ;; \
1018                 *) echo "no link: $$v";; \
1019                 esac ; \
1020         done | sort
1021
1022 ### Make sure built-ins do not have dups and listed in git.c
1023 #
1024 check-builtins::
1025         ./check-builtins.sh