AsciiDoc fixes for the git-svnimport manpage
[git/jrn.git] / Makefile
bloba291bb157ec9eb14037bcc2a2f7b238527dc7adb
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 NO_SETENV if you don't have setenv in the C library.
26 # Define USE_SYMLINK_HEAD if you want .git/HEAD to be a symbolic link.
27 # Don't enable it on Windows.
29 # Define PPC_SHA1 environment variable when running make to make use of
30 # a bundled SHA1 routine optimized for PowerPC.
32 # Define ARM_SHA1 environment variable when running make to make use of
33 # a bundled SHA1 routine optimized for ARM.
35 # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
37 # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
39 # Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
40 # Patrick Mauritz).
42 # Define NO_MMAP if you want to avoid mmap.
44 # Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
46 # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
48 # Define COLLISION_CHECK below if you believe that SHA1's
49 # 1461501637330902918203684832716283019655932542976 hashes do not give you
50 # sufficient guarantee that no collisions between objects will ever happen.
52 # Define USE_NSEC below if you want git to care about sub-second file mtimes
53 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
54 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
55 # randomly break unless your underlying filesystem supports those sub-second
56 # times (my ext3 doesn't).
58 # Define USE_STDEV below if you want git to care about the underlying device
59 # change being considered an inode change from the update-cache perspective.
61 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
62 @sh ./GIT-VERSION-GEN
63 -include GIT-VERSION-FILE
65 # CFLAGS and LDFLAGS are for the users to override from the command line.
67 CFLAGS = -g -O2 -Wall
68 LDFLAGS =
69 ALL_CFLAGS = $(CFLAGS)
70 ALL_LDFLAGS = $(LDFLAGS)
71 STRIP ?= strip
73 prefix = $(HOME)
74 bindir = $(prefix)/bin
75 gitexecdir = $(prefix)/bin
76 template_dir = $(prefix)/share/git-core/templates/
77 GIT_PYTHON_DIR = $(prefix)/share/git-core/python
78 # DESTDIR=
80 CC = gcc
81 AR = ar
82 TAR = tar
83 INSTALL = install
84 RPMBUILD = rpmbuild
86 # sparse is architecture-neutral, which means that we need to tell it
87 # explicitly what architecture to check for. Fix this up for yours..
88 SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
92 ### --- END CONFIGURATION SECTION ---
94 SCRIPT_SH = \
95 git-add.sh git-bisect.sh git-branch.sh git-checkout.sh \
96 git-cherry.sh git-clone.sh git-commit.sh \
97 git-count-objects.sh git-diff.sh git-fetch.sh \
98 git-format-patch.sh git-log.sh git-ls-remote.sh \
99 git-merge-one-file.sh git-parse-remote.sh \
100 git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
101 git-repack.sh git-request-pull.sh git-reset.sh \
102 git-resolve.sh git-revert.sh git-sh-setup.sh git-status.sh \
103 git-tag.sh git-verify-tag.sh git-whatchanged.sh \
104 git-applymbox.sh git-applypatch.sh git-am.sh \
105 git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
106 git-merge-resolve.sh git-merge-ours.sh git-grep.sh \
107 git-lost-found.sh
109 SCRIPT_PERL = \
110 git-archimport.perl git-cvsimport.perl git-relink.perl \
111 git-shortlog.perl git-fmt-merge-msg.perl \
112 git-svnimport.perl git-mv.perl git-cvsexportcommit.perl
114 SCRIPT_PYTHON = \
115 git-merge-recursive.py
117 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
118 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
119 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
120 git-cherry-pick
122 # The ones that do not have to link with lcrypto nor lz.
123 SIMPLE_PROGRAMS = \
124 git-get-tar-commit-id$X git-mailinfo$X git-mailsplit$X \
125 git-stripspace$X git-daemon$X
127 # ... and all the rest that could be moved out of bindir to gitexecdir
128 PROGRAMS = \
129 git-apply$X git-cat-file$X \
130 git-checkout-index$X git-clone-pack$X git-commit-tree$X \
131 git-convert-objects$X git-diff-files$X \
132 git-diff-index$X git-diff-stages$X \
133 git-diff-tree$X git-fetch-pack$X git-fsck-objects$X \
134 git-hash-object$X git-index-pack$X git-init-db$X \
135 git-local-fetch$X git-ls-files$X git-ls-tree$X git-merge-base$X \
136 git-merge-index$X git-mktag$X git-pack-objects$X git-patch-id$X \
137 git-peek-remote$X git-prune-packed$X git-read-tree$X \
138 git-receive-pack$X git-rev-list$X git-rev-parse$X \
139 git-send-pack$X git-show-branch$X git-shell$X \
140 git-show-index$X git-ssh-fetch$X \
141 git-ssh-upload$X git-tar-tree$X git-unpack-file$X \
142 git-unpack-objects$X git-update-index$X git-update-server-info$X \
143 git-upload-pack$X git-verify-pack$X git-write-tree$X \
144 git-update-ref$X git-symbolic-ref$X git-check-ref-format$X \
145 git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \
146 git-describe$X
148 # what 'all' will build and 'install' will install, in gitexecdir
149 ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
151 # Backward compatibility -- to be removed after 1.0
152 PROGRAMS += git-ssh-pull$X git-ssh-push$X
154 # Set paths to tools early so that they can be used for version tests.
155 ifndef SHELL_PATH
156 SHELL_PATH = /bin/sh
157 endif
158 ifndef PERL_PATH
159 PERL_PATH = /usr/bin/perl
160 endif
161 ifndef PYTHON_PATH
162 PYTHON_PATH = /usr/bin/python
163 endif
165 PYMODULES = \
166 gitMergeCommon.py
168 LIB_FILE=libgit.a
170 LIB_H = \
171 blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
172 diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
173 run-command.h strbuf.h tag.h tree.h git-compat-util.h
175 DIFF_OBJS = \
176 diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
177 diffcore-pickaxe.o diffcore-rename.o tree-diff.o
179 LIB_OBJS = \
180 blob.o commit.o connect.o count-delta.o csum-file.o \
181 date.o diff-delta.o entry.o exec_cmd.o ident.o index.o \
182 object.o pack-check.o patch-delta.o path.o pkt-line.o \
183 quote.o read-cache.o refs.o run-command.o \
184 server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
185 tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
186 fetch-clone.o \
187 $(DIFF_OBJS)
189 LIBS = $(LIB_FILE)
190 LIBS += -lz
192 # Shell quote;
193 # Result of this needs to be placed inside ''
194 shq = $(subst ','\'',$(1))
195 # This has surrounding ''
196 shellquote = '$(call shq,$(1))'
199 # Platform specific tweaks
202 # We choose to avoid "if .. else if .. else .. endif endif"
203 # because maintaining the nesting to match is a pain. If
204 # we had "elif" things would have been much nicer...
205 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
206 uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
207 uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
208 uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
210 ifeq ($(uname_S),Darwin)
211 NEEDS_SSL_WITH_CRYPTO = YesPlease
212 NEEDS_LIBICONV = YesPlease
213 ## fink
214 ALL_CFLAGS += -I/sw/include
215 ALL_LDFLAGS += -L/sw/lib
216 ## darwinports
217 ALL_CFLAGS += -I/opt/local/include
218 ALL_LDFLAGS += -L/opt/local/lib
219 endif
220 ifeq ($(uname_S),SunOS)
221 NEEDS_SOCKET = YesPlease
222 NEEDS_NSL = YesPlease
223 NEEDS_LIBICONV = YesPlease
224 SHELL_PATH = /bin/bash
225 NO_STRCASESTR = YesPlease
226 ifeq ($(uname_R),5.8)
227 NO_SETENV = YesPlease
228 endif
229 INSTALL = ginstall
230 TAR = gtar
231 ALL_CFLAGS += -D__EXTENSIONS__
232 endif
233 ifeq ($(uname_O),Cygwin)
234 NO_STRCASESTR = YesPlease
235 NEEDS_LIBICONV = YesPlease
236 # There are conflicting reports about this.
237 # On some boxes NO_MMAP is needed, and not so elsewhere.
238 # Try uncommenting this if you see things break -- YMMV.
239 # NO_MMAP = YesPlease
240 NO_IPV6 = YesPlease
241 X = .exe
242 endif
243 ifeq ($(uname_S),OpenBSD)
244 NO_STRCASESTR = YesPlease
245 NEEDS_LIBICONV = YesPlease
246 ALL_CFLAGS += -I/usr/local/include
247 ALL_LDFLAGS += -L/usr/local/lib
248 endif
249 ifeq ($(uname_S),NetBSD)
250 NEEDS_LIBICONV = YesPlease
251 ALL_CFLAGS += -I/usr/pkg/include
252 ALL_LDFLAGS += -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib
253 endif
254 ifeq ($(uname_S),AIX)
255 NO_STRCASESTR=YesPlease
256 NEEDS_LIBICONV=YesPlease
257 endif
258 ifneq (,$(findstring arm,$(uname_M)))
259 ARM_SHA1 = YesPlease
260 endif
262 -include config.mak
264 ifdef WITH_OWN_SUBPROCESS_PY
265 PYMODULES += compat/subprocess.py
266 else
267 ifneq ($(shell $(PYTHON_PATH) -c 'import subprocess;print"OK"' 2>/dev/null),OK)
268 PYMODULES += compat/subprocess.py
269 endif
270 endif
272 ifdef WITH_SEND_EMAIL
273 SCRIPT_PERL += git-send-email.perl
274 endif
276 ifndef NO_CURL
277 ifdef CURLDIR
278 # This is still problematic -- gcc does not always want -R.
279 ALL_CFLAGS += -I$(CURLDIR)/include
280 CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
281 else
282 CURL_LIBCURL = -lcurl
283 endif
284 PROGRAMS += git-http-fetch$X
285 curl_check := $(shell (echo 070908; curl-config --vernum) | sort -r | sed -ne 2p)
286 ifeq "$(curl_check)" "070908"
287 ifndef NO_EXPAT
288 EXPAT_LIBEXPAT = -lexpat
289 PROGRAMS += git-http-push$X
290 endif
291 endif
292 endif
294 ifndef NO_OPENSSL
295 LIB_OBJS += epoch.o
296 OPENSSL_LIBSSL = -lssl
297 ifdef OPENSSLDIR
298 # Again this may be problematic -- gcc does not always want -R.
299 ALL_CFLAGS += -I$(OPENSSLDIR)/include
300 OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
301 else
302 OPENSSL_LINK =
303 endif
304 else
305 ALL_CFLAGS += -DNO_OPENSSL
306 MOZILLA_SHA1 = 1
307 OPENSSL_LIBSSL =
308 endif
309 ifdef NEEDS_SSL_WITH_CRYPTO
310 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
311 else
312 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
313 endif
314 ifdef NEEDS_LIBICONV
315 ifdef ICONVDIR
316 # Again this may be problematic -- gcc does not always want -R.
317 ALL_CFLAGS += -I$(ICONVDIR)/include
318 ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
319 else
320 ICONV_LINK =
321 endif
322 LIB_4_ICONV = $(ICONV_LINK) -liconv
323 else
324 LIB_4_ICONV =
325 endif
326 ifdef NEEDS_SOCKET
327 LIBS += -lsocket
328 SIMPLE_LIB += -lsocket
329 endif
330 ifdef NEEDS_NSL
331 LIBS += -lnsl
332 SIMPLE_LIB += -lnsl
333 endif
334 ifdef NO_STRCASESTR
335 COMPAT_CFLAGS += -DNO_STRCASESTR
336 COMPAT_OBJS += compat/strcasestr.o
337 endif
338 ifdef NO_SETENV
339 COMPAT_CFLAGS += -DNO_SETENV
340 COMPAT_OBJS += compat/setenv.o
341 endif
342 ifdef NO_MMAP
343 COMPAT_CFLAGS += -DNO_MMAP
344 COMPAT_OBJS += compat/mmap.o
345 endif
346 ifdef NO_IPV6
347 ALL_CFLAGS += -DNO_IPV6 -Dsockaddr_storage=sockaddr_in
348 endif
350 ifdef PPC_SHA1
351 SHA1_HEADER = "ppc/sha1.h"
352 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
353 else
354 ifdef ARM_SHA1
355 SHA1_HEADER = "arm/sha1.h"
356 LIB_OBJS += arm/sha1.o arm/sha1_arm.o
357 else
358 ifdef MOZILLA_SHA1
359 SHA1_HEADER = "mozilla-sha1/sha1.h"
360 LIB_OBJS += mozilla-sha1/sha1.o
361 else
362 SHA1_HEADER = <openssl/sha.h>
363 LIBS += $(LIB_4_CRYPTO)
364 endif
365 endif
366 endif
368 ALL_CFLAGS += -DSHA1_HEADER=$(call shellquote,$(SHA1_HEADER)) $(COMPAT_CFLAGS)
369 LIB_OBJS += $(COMPAT_OBJS)
370 export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
371 ### Build rules
373 all: $(ALL_PROGRAMS) git$X gitk
375 all:
376 $(MAKE) -C templates
378 strip: $(PROGRAMS) git$X
379 $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
381 git$X: git.c $(LIB_FILE)
382 $(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
383 $(CFLAGS) $(COMPAT_CFLAGS) -o $@ $(filter %.c,$^) $(LIB_FILE)
385 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
386 rm -f $@
387 sed -e '1s|#!.*/sh|#!$(call shq,$(SHELL_PATH))|' \
388 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
389 $@.sh >$@
390 chmod +x $@
392 $(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
393 rm -f $@
394 sed -e '1s|#!.*perl|#!$(call shq,$(PERL_PATH))|' \
395 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
396 $@.perl >$@
397 chmod +x $@
399 $(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
400 rm -f $@
401 sed -e '1s|#!.*python|#!$(call shq,$(PYTHON_PATH))|' \
402 -e 's|@@GIT_PYTHON_PATH@@|$(call shq,$(GIT_PYTHON_DIR))|g' \
403 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
404 $@.py >$@
405 chmod +x $@
407 git-cherry-pick: git-revert
408 cp $< $@
410 # These can record GIT_VERSION
411 git$X git.spec \
412 $(patsubst %.sh,%,$(SCRIPT_SH)) \
413 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
414 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
415 : GIT-VERSION-FILE
417 %.o: %.c
418 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
419 %.o: %.S
420 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
422 exec_cmd.o: ALL_CFLAGS += -DGIT_EXEC_PATH=\"$(gitexecdir)\"
424 git-%$X: %.o $(LIB_FILE)
425 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
427 git-mailinfo$X : SIMPLE_LIB += $(LIB_4_ICONV)
428 $(SIMPLE_PROGRAMS) : $(LIB_FILE)
429 $(SIMPLE_PROGRAMS) : git-%$X : %.o
430 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
431 $(LIB_FILE) $(SIMPLE_LIB)
433 git-http-fetch$X: fetch.o http.o
434 git-http-push$X: http.o
435 git-local-fetch$X: fetch.o
436 git-ssh-fetch$X: rsh.o fetch.o
437 git-ssh-upload$X: rsh.o
438 git-ssh-pull$X: rsh.o fetch.o
439 git-ssh-push$X: rsh.o
441 git-http-fetch$X: LIBS += $(CURL_LIBCURL)
442 git-http-push$X: LIBS += $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
443 git-rev-list$X: LIBS += $(OPENSSL_LIBSSL)
445 init-db.o: init-db.c
446 $(CC) -c $(ALL_CFLAGS) \
447 -DDEFAULT_GIT_TEMPLATE_DIR=$(call shellquote,"$(template_dir)") $*.c
449 $(LIB_OBJS): $(LIB_H)
450 $(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H)
451 $(DIFF_OBJS): diffcore.h
453 $(LIB_FILE): $(LIB_OBJS)
454 $(AR) rcs $@ $(LIB_OBJS)
456 doc:
457 $(MAKE) -C Documentation all
460 ### Testing rules
462 test: all
463 $(MAKE) -C t/ all
465 test-date$X: test-date.c date.o ctype.o
466 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) test-date.c date.o ctype.o
468 test-delta$X: test-delta.c diff-delta.o patch-delta.o
469 $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $^
471 check:
472 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done
476 ### Installation rules
478 install: all
479 $(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(bindir))
480 $(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(gitexecdir))
481 $(INSTALL) $(ALL_PROGRAMS) $(call shellquote,$(DESTDIR)$(gitexecdir))
482 $(INSTALL) git$X gitk $(call shellquote,$(DESTDIR)$(bindir))
483 $(MAKE) -C templates install
484 $(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
485 $(INSTALL) $(PYMODULES) $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
487 install-doc:
488 $(MAKE) -C Documentation install
493 ### Maintainer's dist rules
495 git.spec: git.spec.in
496 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
498 GIT_TARNAME=git-$(GIT_VERSION)
499 dist: git.spec git-tar-tree
500 ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
501 @mkdir -p $(GIT_TARNAME)
502 @cp git.spec $(GIT_TARNAME)
503 @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
504 $(TAR) rf $(GIT_TARNAME).tar \
505 $(GIT_TARNAME)/git.spec $(GIT_TARNAME)/version
506 @rm -rf $(GIT_TARNAME)
507 gzip -f -9 $(GIT_TARNAME).tar
509 rpm: dist
510 $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz
512 ### Cleaning rules
514 clean:
515 rm -f *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o $(LIB_FILE)
516 rm -f $(ALL_PROGRAMS) git$X
517 rm -f *.spec *.pyc *.pyo */*.pyc */*.pyo
518 rm -rf $(GIT_TARNAME)
519 rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
520 $(MAKE) -C Documentation/ clean
521 $(MAKE) -C templates clean
522 $(MAKE) -C t/ clean
523 rm -f GIT-VERSION-FILE
525 .PHONY: all install clean strip
526 .PHONY: .FORCE-GIT-VERSION-FILE