documentation: git-tag
[git/mingw.git] / Makefile
blob45db357cc2698f5820838c52bb07339f61a8ca13
1 # The default target of this Makefile is...
2 all:
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.
9 # Define NO_OPENSSL environment variable if you do not have OpenSSL. You will
10 # miss out git-rev-list --merge-order. This also implies MOZILLA_SHA1.
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.
16 # Define CURLDIR=/foo/bar if your curl header and library files are in
17 # /foo/bar/include and /foo/bar/lib directories.
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.
22 # Define NO_STRCASESTR if you don't have strcasestr.
24 # Define PPC_SHA1 environment variable when running make to make use of
25 # a bundled SHA1 routine optimized for PowerPC.
27 # Define ARM_SHA1 environment variable when running make to make use of
28 # a bundled SHA1 routine optimized for ARM.
30 # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
32 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
34 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
35 # Patrick Mauritz).
37 # Define NO_MMAP if you want to avoid mmap.
39 # Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
41 # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
43 # Define COLLISION_CHECK below if you believe that SHA1's
44 # 1461501637330902918203684832716283019655932542976 hashes do not give you
45 # sufficient guarantee that no collisions between objects will ever happen.
47 # Define USE_NSEC below if you want git to care about sub-second file mtimes
48 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
49 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
50 # randomly break unless your underlying filesystem supports those sub-second
51 # times (my ext3 doesn't).
53 # Define USE_STDEV below if you want git to care about the underlying device
54 # change being considered an inode change from the update-cache perspective.
56 GIT_VERSION = 0.99.9.GIT
58 # CFLAGS and LDFLAGS are for the users to override from the command line.
60 CFLAGS = -g -O2 -Wall
61 LDFLAGS =
62 ALL_CFLAGS = $(CFLAGS)
63 ALL_LDFLAGS = $(LDFLAGS)
65 prefix = $(HOME)
66 bindir = $(prefix)/bin
67 template_dir = $(prefix)/share/git-core/templates/
68 GIT_PYTHON_DIR = $(prefix)/share/git-core/python
69 # DESTDIR=
71 CC = gcc
72 AR = ar
73 TAR = tar
74 INSTALL = install
75 RPMBUILD = rpmbuild
77 # sparse is architecture-neutral, which means that we need to tell it
78 # explicitly what architecture to check for. Fix this up for yours..
79 SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
83 ### --- END CONFIGURATION SECTION ---
85 SCRIPT_SH = \
86 git-add.sh git-bisect.sh git-branch.sh git-checkout.sh \
87 git-cherry.sh git-clone.sh git-commit.sh \
88 git-count-objects.sh git-diff.sh git-fetch.sh \
89 git-format-patch.sh git-log.sh git-ls-remote.sh \
90 git-merge-one-file.sh git-octopus.sh git-parse-remote.sh \
91 git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
92 git-repack.sh git-request-pull.sh git-reset.sh \
93 git-resolve.sh git-revert.sh git-sh-setup.sh git-status.sh \
94 git-tag.sh git-verify-tag.sh git-whatchanged.sh \
95 git-applymbox.sh git-applypatch.sh git-am.sh \
96 git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
97 git-merge-resolve.sh git-merge-ours.sh git-grep.sh \
98 git-lost-found.sh
100 SCRIPT_PERL = \
101 git-archimport.perl git-cvsimport.perl git-relink.perl \
102 git-shortlog.perl git-fmt-merge-msg.perl \
103 git-svnimport.perl git-mv.perl git-cvsexportcommit.perl
105 SCRIPT_PYTHON = \
106 git-merge-recursive.py
108 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
109 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
110 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
111 gitk git-cherry-pick
113 # The ones that do not have to link with lcrypto nor lz.
114 SIMPLE_PROGRAMS = \
115 git-get-tar-commit-id$X git-mailinfo$X git-mailsplit$X \
116 git-stripspace$X git-daemon$X
118 # ... and all the rest
119 PROGRAMS = \
120 git-apply$X git-cat-file$X \
121 git-checkout-index$X git-clone-pack$X git-commit-tree$X \
122 git-convert-objects$X git-diff-files$X \
123 git-diff-index$X git-diff-stages$X \
124 git-diff-tree$X git-fetch-pack$X git-fsck-objects$X \
125 git-hash-object$X git-index-pack$X git-init-db$X \
126 git-local-fetch$X git-ls-files$X git-ls-tree$X git-merge-base$X \
127 git-merge-index$X git-mktag$X git-pack-objects$X git-patch-id$X \
128 git-peek-remote$X git-prune-packed$X git-read-tree$X \
129 git-receive-pack$X git-rev-list$X git-rev-parse$X \
130 git-send-pack$X git-show-branch$X git-shell$X \
131 git-show-index$X git-ssh-fetch$X \
132 git-ssh-upload$X git-tar-tree$X git-unpack-file$X \
133 git-unpack-objects$X git-update-index$X git-update-server-info$X \
134 git-upload-pack$X git-verify-pack$X git-write-tree$X \
135 git-update-ref$X git-symbolic-ref$X git-check-ref-format$X \
136 git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X
138 # what 'all' will build and 'install' will install.
139 ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS) git$X
141 # Backward compatibility -- to be removed after 1.0
142 PROGRAMS += git-ssh-pull$X git-ssh-push$X
144 # Set paths to tools early so that they can be used for version tests.
145 ifndef SHELL_PATH
146 SHELL_PATH = /bin/sh
147 endif
148 ifndef PERL_PATH
149 PERL_PATH = /usr/bin/perl
150 endif
151 ifndef PYTHON_PATH
152 PYTHON_PATH = /usr/bin/python
153 endif
155 PYMODULES = \
156 gitMergeCommon.py
158 LIB_FILE=libgit.a
160 LIB_H = \
161 blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
162 diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
163 run-command.h strbuf.h tag.h tree.h
165 DIFF_OBJS = \
166 diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
167 diffcore-pickaxe.o diffcore-rename.o tree-diff.o
169 LIB_OBJS = \
170 blob.o commit.o connect.o count-delta.o csum-file.o \
171 date.o diff-delta.o entry.o ident.o index.o \
172 object.o pack-check.o patch-delta.o path.o pkt-line.o \
173 quote.o read-cache.o refs.o run-command.o \
174 server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
175 tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
176 $(DIFF_OBJS)
178 LIBS = $(LIB_FILE)
179 LIBS += -lz
181 # Shell quote;
182 # Result of this needs to be placed inside ''
183 shq = $(subst ','\'',$(1))
184 # This has surrounding ''
185 shellquote = '$(call shq,$(1))'
188 # Platform specific tweaks
191 # We choose to avoid "if .. else if .. else .. endif endif"
192 # because maintaining the nesting to match is a pain. If
193 # we had "elif" things would have been much nicer...
194 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
195 uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
196 uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
198 ifeq ($(uname_S),Darwin)
199 NEEDS_SSL_WITH_CRYPTO = YesPlease
200 NEEDS_LIBICONV = YesPlease
201 ## fink
202 ALL_CFLAGS += -I/sw/include
203 ALL_LDFLAGS += -L/sw/lib
204 ## darwinports
205 ALL_CFLAGS += -I/opt/local/include
206 ALL_LDFLAGS += -L/opt/local/lib
207 endif
208 ifeq ($(uname_S),SunOS)
209 NEEDS_SOCKET = YesPlease
210 NEEDS_NSL = YesPlease
211 NEEDS_LIBICONV = YesPlease
212 SHELL_PATH = /bin/bash
213 NO_STRCASESTR = YesPlease
214 INSTALL = ginstall
215 TAR = gtar
216 ALL_CFLAGS += -D__EXTENSIONS__
217 endif
218 ifeq ($(uname_O),Cygwin)
219 NO_STRCASESTR = YesPlease
220 NEEDS_LIBICONV = YesPlease
221 # There are conflicting reports about this.
222 # On some boxes NO_MMAP is needed, and not so elsewhere.
223 # Try uncommenting this if you see things break -- YMMV.
224 # NO_MMAP = YesPlease
225 NO_IPV6 = YesPlease
226 X = .exe
227 ALL_CFLAGS += -DUSE_SYMLINK_HEAD=0
228 endif
229 ifeq ($(uname_S),OpenBSD)
230 NO_STRCASESTR = YesPlease
231 NEEDS_LIBICONV = YesPlease
232 ALL_CFLAGS += -I/usr/local/include
233 ALL_LDFLAGS += -L/usr/local/lib
234 endif
235 ifeq ($(uname_S),NetBSD)
236 NEEDS_LIBICONV = YesPlease
237 ALL_CFLAGS += -I/usr/pkg/include
238 ALL_LDFLAGS += -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib
239 endif
240 ifneq (,$(findstring arm,$(uname_M)))
241 ARM_SHA1 = YesPlease
242 endif
244 -include config.mak
246 ifdef WITH_OWN_SUBPROCESS_PY
247 PYMODULES += compat/subprocess.py
248 else
249 ifneq ($(shell $(PYTHON_PATH) -c 'import subprocess;print"OK"' 2>/dev/null),OK)
250 PYMODULES += compat/subprocess.py
251 endif
252 endif
254 ifdef WITH_SEND_EMAIL
255 SCRIPT_PERL += git-send-email.perl
256 endif
258 ifndef NO_CURL
259 ifdef CURLDIR
260 # This is still problematic -- gcc does not always want -R.
261 ALL_CFLAGS += -I$(CURLDIR)/include
262 CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
263 else
264 CURL_LIBCURL = -lcurl
265 endif
266 PROGRAMS += git-http-fetch$X
267 curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
268 ifeq "$(curl_check)" "070908"
269 ifndef NO_EXPAT
270 EXPAT_LIBEXPAT = -lexpat
271 PROGRAMS += git-http-push$X
272 endif
273 endif
274 endif
276 ifndef NO_OPENSSL
277 LIB_OBJS += epoch.o
278 OPENSSL_LIBSSL = -lssl
279 ifdef OPENSSLDIR
280 # Again this may be problematic -- gcc does not always want -R.
281 ALL_CFLAGS += -I$(OPENSSLDIR)/include
282 OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
283 else
284 OPENSSL_LINK =
285 endif
286 else
287 ALL_CFLAGS += -DNO_OPENSSL
288 MOZILLA_SHA1 = 1
289 OPENSSL_LIBSSL =
290 endif
291 ifdef NEEDS_SSL_WITH_CRYPTO
292 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
293 else
294 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
295 endif
296 ifdef NEEDS_LIBICONV
297 ifdef ICONVDIR
298 # Again this may be problematic -- gcc does not always want -R.
299 ALL_CFLAGS += -I$(ICONVDIR)/include
300 ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
301 else
302 ICONV_LINK =
303 endif
304 LIB_4_ICONV = $(ICONV_LINK) -liconv
305 else
306 LIB_4_ICONV =
307 endif
308 ifdef NEEDS_SOCKET
309 LIBS += -lsocket
310 SIMPLE_LIB += -lsocket
311 endif
312 ifdef NEEDS_NSL
313 LIBS += -lnsl
314 SIMPLE_LIB += -lnsl
315 endif
316 ifdef NO_STRCASESTR
317 ALL_CFLAGS += -Dstrcasestr=gitstrcasestr -DNO_STRCASESTR=1
318 LIB_OBJS += compat/strcasestr.o
319 endif
320 ifdef NO_MMAP
321 ALL_CFLAGS += -Dmmap=gitfakemmap -Dmunmap=gitfakemunmap -DNO_MMAP
322 LIB_OBJS += compat/mmap.o
323 endif
324 ifdef NO_IPV6
325 ALL_CFLAGS += -DNO_IPV6 -Dsockaddr_storage=sockaddr_in
326 endif
328 ifdef PPC_SHA1
329 SHA1_HEADER = "ppc/sha1.h"
330 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
331 else
332 ifdef ARM_SHA1
333 SHA1_HEADER = "arm/sha1.h"
334 LIB_OBJS += arm/sha1.o arm/sha1_arm.o
335 else
336 ifdef MOZILLA_SHA1
337 SHA1_HEADER = "mozilla-sha1/sha1.h"
338 LIB_OBJS += mozilla-sha1/sha1.o
339 else
340 SHA1_HEADER = <openssl/sha.h>
341 LIBS += $(LIB_4_CRYPTO)
342 endif
343 endif
344 endif
346 ALL_CFLAGS += -DSHA1_HEADER=$(call shellquote,$(SHA1_HEADER))
348 export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
349 ### Build rules
351 all: $(ALL_PROGRAMS)
353 all:
354 $(MAKE) -C templates
356 # Only use $(CFLAGS). We don't need anything else.
357 git$(X): git.c Makefile
358 $(CC) -DGIT_EXEC_PATH='"$(bindir)"' -DGIT_VERSION='"$(GIT_VERSION)"' \
359 $(CFLAGS) $< -o $@
361 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
362 rm -f $@
363 sed -e '1s|#!.*/sh|#!$(call shq,$(SHELL_PATH))|' \
364 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
365 $@.sh >$@
366 chmod +x $@
368 $(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
369 rm -f $@
370 sed -e '1s|#!.*perl|#!$(call shq,$(PERL_PATH))|' \
371 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
372 $@.perl >$@
373 chmod +x $@
375 $(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
376 rm -f $@
377 sed -e '1s|#!.*python|#!$(call shq,$(PYTHON_PATH))|' \
378 -e 's|@@GIT_PYTHON_PATH@@|$(call shq,$(GIT_PYTHON_DIR))|g' \
379 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
380 $@.py >$@
381 chmod +x $@
383 git-cherry-pick: git-revert
384 cp $< $@
386 %.o: %.c
387 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
388 %.o: %.S
389 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
391 git-%$X: %.o $(LIB_FILE)
392 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
394 git-mailinfo$X : SIMPLE_LIB += $(LIB_4_ICONV)
395 $(SIMPLE_PROGRAMS) : $(LIB_FILE)
396 $(SIMPLE_PROGRAMS) : git-%$X : %.o
397 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
398 $(LIB_FILE) $(SIMPLE_LIB)
400 git-http-fetch$X: fetch.o http.o
401 git-http-push$X: http.o
402 git-local-fetch$X: fetch.o
403 git-ssh-fetch$X: rsh.o fetch.o
404 git-ssh-upload$X: rsh.o
405 git-ssh-pull$X: rsh.o fetch.o
406 git-ssh-push$X: rsh.o
408 git-http-fetch$X: LIBS += $(CURL_LIBCURL)
409 git-http-push$X: LIBS += $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
410 git-rev-list$X: LIBS += $(OPENSSL_LIBSSL)
412 init-db.o: init-db.c
413 $(CC) -c $(ALL_CFLAGS) \
414 -DDEFAULT_GIT_TEMPLATE_DIR=$(call shellquote,"$(template_dir)") $*.c
416 $(LIB_OBJS): $(LIB_H)
417 $(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H)
418 $(DIFF_OBJS): diffcore.h
420 $(LIB_FILE): $(LIB_OBJS)
421 $(AR) rcs $@ $(LIB_OBJS)
423 doc:
424 $(MAKE) -C Documentation all
427 ### Testing rules
429 test: all
430 $(MAKE) -C t/ all
432 test-date$X: test-date.c date.o ctype.o
433 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) test-date.c date.o ctype.o
435 test-delta$X: test-delta.c diff-delta.o patch-delta.o
436 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $^
438 check:
439 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
443 ### Installation rules
445 install: all
446 $(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(bindir))
447 $(INSTALL) $(ALL_PROGRAMS) $(call shellquote,$(DESTDIR)$(bindir))
448 $(MAKE) -C templates install
449 $(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
450 $(INSTALL) $(PYMODULES) $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
452 install-doc:
453 $(MAKE) -C Documentation install
458 ### Maintainer's dist rules
460 git.spec: git.spec.in Makefile
461 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
463 GIT_TARNAME=git-$(GIT_VERSION)
464 dist: git.spec git-tar-tree
465 ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
466 @mkdir -p $(GIT_TARNAME)
467 @cp git.spec $(GIT_TARNAME)
468 $(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git.spec
469 @rm -rf $(GIT_TARNAME)
470 gzip -f -9 $(GIT_TARNAME).tar
472 rpm: dist
473 $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
475 deb: dist
476 rm -rf $(GIT_TARNAME)
477 $(TAR) zxf $(GIT_TARNAME).tar.gz
478 dpkg-source -b $(GIT_TARNAME)
479 cd $(GIT_TARNAME) && fakeroot debian/rules binary
481 ### Cleaning rules
483 clean:
484 rm -f *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o $(LIB_FILE)
485 rm -f $(PROGRAMS) $(SIMPLE_PROGRAMS) git$X
486 rm -f $(filter-out gitk,$(SCRIPTS))
487 rm -f *.spec *.pyc *.pyo
488 rm -rf $(GIT_TARNAME)
489 rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
490 rm -f git-core_$(GIT_VERSION)-*.dsc
491 rm -f git-*_$(GIT_VERSION)-*.deb
492 $(MAKE) -C Documentation/ clean
493 $(MAKE) -C templates clean
494 $(MAKE) -C t/ clean