]> git.ipfire.org Git - thirdparty/git.git/blame - Makefile
Merge with master.kernel.org:/pub/scm/git/git.git
[thirdparty/git.git] / Makefile
CommitLineData
5bdac8b3
PB
1# Define MOZILLA_SHA1 environment variable when running make to make use of
2# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
3# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
4# choice) has very fast version optimized for i586.
bdd4da59 5#
5bdac8b3
PB
6# Define NO_OPENSSL environment variable if you do not have OpenSSL. You will
7# miss out git-rev-list --merge-order. This also implies MOZILLA_SHA1.
2cb45e95 8#
b2c0bd65
JS
9# Define NO_CURL if you do not have curl installed. git-http-pull is not
10# built, and you cannot use http:// and https:// transports.
11#
6d9bbc50
PM
12# Define CURLDIR=/foo/bar if your curl header and library files are in
13# /foo/bar/include and /foo/bar/lib directories.
14#
ef34af24
LT
15# Define NO_STRCASESTR if you don't have strcasestr.
16#
5bdac8b3
PB
17# Define PPC_SHA1 environment variable when running make to make use of
18# a bundled SHA1 routine optimized for PowerPC.
597c9cc5 19#
7c6ef2f2
NP
20# Define ARM_SHA1 environment variable when running make to make use of
21# a bundled SHA1 routine optimized for ARM.
22#
597c9cc5 23# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
f0ebff0d 24#
597c9cc5 25# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
f0ebff0d
PM
26#
27# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
28# Patrick Mauritz).
29#
343d35c9
JH
30# Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
31#
49744d63
PA
32# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
33#
5bdac8b3
PB
34# Define COLLISION_CHECK below if you believe that SHA1's
35# 1461501637330902918203684832716283019655932542976 hashes do not give you
36# sufficient guarantee that no collisions between objects will ever happen.
37
38# DEFINES += -DCOLLISION_CHECK
39
40# Define USE_NSEC below if you want git to care about sub-second file mtimes
41# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
42# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
43# randomly break unless your underlying filesystem supports those sub-second
44# times (my ext3 doesn't).
45
46# DEFINES += -DUSE_NSEC
47
48# Define USE_STDEV below if you want git to care about the underlying device
49# change being considered an inode change from the update-cache perspective.
50
51# DEFINES += -DUSE_STDEV
52
baaac6a7 53GIT_VERSION = 0.99.8.GIT
a9db2974 54
b05701c5 55CFLAGS = -g -O2 -Wall
f0ebff0d 56ALL_CFLAGS = $(CFLAGS) $(PLATFORM_DEFINES) $(DEFINES)
29c2cce4 57
b05701c5
PR
58prefix = $(HOME)
59bindir = $(prefix)/bin
60template_dir = $(prefix)/share/git-core/templates/
720d150c 61GIT_PYTHON_DIR = $(prefix)/share/git-core/python
a682ef9f 62# DESTDIR=
5c2a7fbc 63
b05701c5
PR
64CC = gcc
65AR = ar
229a7ed7 66TAR = tar
b05701c5
PR
67INSTALL = install
68RPMBUILD = rpmbuild
e83c5163 69
44c9e859
LT
70# sparse is architecture-neutral, which means that we need to tell it
71# explicitly what architecture to check for. Fix this up for yours..
b05701c5 72SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
44c9e859 73
28818ffa
PB
74
75
76### --- END CONFIGURATION SECTION ---
77
215a7ad1
JH
78SCRIPT_SH = \
79 git-add.sh git-bisect.sh git-branch.sh git-checkout.sh \
80 git-cherry.sh git-clone.sh git-commit.sh \
81 git-count-objects.sh git-diff.sh git-fetch.sh \
82 git-format-patch.sh git-log.sh git-ls-remote.sh \
83 git-merge-one-file.sh git-octopus.sh git-parse-remote.sh \
84 git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
85 git-repack.sh git-request-pull.sh git-reset.sh \
86 git-resolve.sh git-revert.sh git-sh-setup.sh git-status.sh \
87 git-tag.sh git-verify-tag.sh git-whatchanged.sh git.sh \
91063bbc 88 git-applymbox.sh git-applypatch.sh \
2276aa6c 89 git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
f22cc3fc 90 git-merge-resolve.sh git-grep.sh
215a7ad1
JH
91
92SCRIPT_PERL = \
93 git-archimport.perl git-cvsimport.perl git-relink.perl \
c8b48ba4 94 git-rename.perl git-shortlog.perl git-fmt-merge-msg.perl
60036a41 95
720d150c 96SCRIPT_PYTHON = \
e4cf17ce 97 git-merge-recursive.py
720d150c 98
597c9cc5
JH
99# The ones that do not have to link with lcrypto nor lz.
100SIMPLE_PROGRAMS = \
2f29dd52
PA
101 git-get-tar-commit-id$X git-mailinfo$X git-mailsplit$X \
102 git-stripspace$X git-var$X git-daemon$X
597c9cc5
JH
103
104# ... and all the rest
215a7ad1 105PROGRAMS = \
79a9d8ea
PA
106 git-apply$X git-cat-file$X \
107 git-checkout-index$X git-clone-pack$X git-commit-tree$X \
108 git-convert-objects$X git-diff-files$X \
109 git-diff-index$X git-diff-stages$X \
110 git-diff-tree$X git-fetch-pack$X git-fsck-objects$X \
111 git-hash-object$X git-init-db$X \
112 git-local-fetch$X git-ls-files$X git-ls-tree$X git-merge-base$X \
113 git-merge-index$X git-mktag$X git-pack-objects$X git-patch-id$X \
114 git-peek-remote$X git-prune-packed$X git-read-tree$X \
115 git-receive-pack$X git-rev-list$X git-rev-parse$X \
116 git-send-pack$X git-show-branch$X \
117 git-show-index$X git-ssh-fetch$X \
118 git-ssh-upload$X git-tar-tree$X git-unpack-file$X \
119 git-unpack-objects$X git-update-index$X git-update-server-info$X \
120 git-upload-pack$X git-verify-pack$X git-write-tree$X \
121 git-update-ref$X git-symbolic-ref$X \
597c9cc5 122 $(SIMPLE_PROGRAMS)
e83c5163 123
894a8a8b 124# Backward compatibility -- to be removed after 1.0
2f29dd52 125PROGRAMS += git-ssh-pull$X git-ssh-push$X
f71a69ab 126
0842acff
JH
127GIT_LIST_TWEAK =
128
720d150c
JH
129PYMODULES = \
130 gitMergeCommon.py
131
343d35c9
JH
132ifdef WITH_OWN_SUBPROCESS_PY
133 PYMODULES += compat/subprocess.py
134endif
135
90bc118f 136ifdef WITH_SEND_EMAIL
215a7ad1 137 SCRIPT_PERL += git-send-email.perl
0842acff
JH
138else
139 GIT_LIST_TWEAK += -e '/^send-email$$/d'
90bc118f
JH
140endif
141
0a02ce72 142LIB_FILE=libgit.a
8f3f9b09 143
215a7ad1
JH
144LIB_H = \
145 blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
146 diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
0f56479d 147 run-command.h strbuf.h tag.h tree.h
b1bf95bb 148
215a7ad1
JH
149DIFF_OBJS = \
150 diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
151 diffcore-pickaxe.o diffcore-rename.o
d1df5743 152
215a7ad1
JH
153LIB_OBJS = \
154 blob.o commit.o connect.o count-delta.o csum-file.o \
a9ab586a 155 date.o diff-delta.o entry.o ident.o index.o \
215a7ad1 156 object.o pack-check.o patch-delta.o path.o pkt-line.o \
0f56479d 157 quote.o read-cache.o refs.o run-command.o \
215a7ad1
JH
158 server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
159 tag.o tree.o usage.o $(DIFF_OBJS)
d19938ab 160
cc1ad5c8
LT
161LIBS = $(LIB_FILE)
162LIBS += -lz
cef661fc 163
229a7ed7
JH
164#
165# Platform specific tweaks
166#
597c9cc5
JH
167ifeq ($(shell uname -s),Darwin)
168 NEEDS_SSL_WITH_CRYPTO = YesPlease
169 NEEDS_LIBICONV = YesPlease
170endif
f0ebff0d
PM
171ifeq ($(shell uname -s),SunOS)
172 NEEDS_SOCKET = YesPlease
5a90d4ac 173 NEEDS_NSL = YesPlease
229a7ed7
JH
174 SHELL_PATH = /bin/bash
175 NO_STRCASESTR = YesPlease
176 CURLDIR = /opt/sfw
177 INSTALL = ginstall
178 TAR = gtar
5a90d4ac 179 PLATFORM_DEFINES += -D__EXTENSIONS__
f0ebff0d 180endif
17754517
PA
181ifeq ($(shell uname -o),Cygwin)
182 NO_STRCASESTR = YesPlease
183 NEEDS_LIBICONV = YesPlease
49744d63 184 NO_IPV6 = YesPlease
a23cd8ec 185 X = .exe
17754517 186endif
7c6ef2f2
NP
187ifneq (,$(findstring arm,$(shell uname -m)))
188 ARM_SHA1 = YesPlease
189endif
18c5a525
HB
190ifeq ($(shell uname -s),OpenBSD)
191 NEEDS_LIBICONV = YesPlease
192 PLATFORM_DEFINES += -I/usr/local/include -L/usr/local/lib
193endif
597c9cc5 194
229a7ed7
JH
195ifndef NO_CURL
196 ifdef CURLDIR
197 # This is still problematic -- gcc does not want -R.
198 CFLAGS += -I$(CURLDIR)/include
199 CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
200 else
201 CURL_LIBCURL = -lcurl
202 endif
2f29dd52 203 PROGRAMS += git-http-fetch$X
229a7ed7
JH
204endif
205
bc6146d2
JH
206ifndef SHELL_PATH
207 SHELL_PATH = /bin/sh
208endif
209ifndef PERL_PATH
210 PERL_PATH = /usr/bin/perl
211endif
720d150c
JH
212ifndef PYTHON_PATH
213 PYTHON_PATH = /usr/bin/python
214endif
bc6146d2 215
dd53c7ab
PB
216ifndef NO_OPENSSL
217 LIB_OBJS += epoch.o
215a7ad1 218 OPENSSL_LIBSSL = -lssl
455a7f32
JH
219 ifdef OPENSSLDIR
220 # Again this may be problematic -- gcc does not always want -R.
221 CFLAGS += -I$(OPENSSLDIR)/include
222 OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
223 else
224 OPENSSL_LINK =
225 endif
dd53c7ab 226else
b05701c5 227 DEFINES += '-DNO_OPENSSL'
215a7ad1
JH
228 MOZILLA_SHA1 = 1
229 OPENSSL_LIBSSL =
dd53c7ab 230endif
597c9cc5 231ifdef NEEDS_SSL_WITH_CRYPTO
455a7f32 232 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
597c9cc5 233else
455a7f32 234 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
597c9cc5
JH
235endif
236ifdef NEEDS_LIBICONV
455a7f32
JH
237 ifdef ICONVDIR
238 # Again this may be problematic -- gcc does not always want -R.
239 CFLAGS += -I$(ICONVDIR)/include
240 ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
241 else
242 ICONV_LINK =
243 endif
244 LIB_4_ICONV = $(ICONV_LINK) -liconv
597c9cc5
JH
245else
246 LIB_4_ICONV =
247endif
f0ebff0d
PM
248ifdef NEEDS_SOCKET
249 LIBS += -lsocket
250 SIMPLE_LIB += -lsocket
251endif
5a90d4ac
JH
252ifdef NEEDS_NSL
253 LIBS += -lnsl
254 SIMPLE_LIB += -lnsl
255endif
ef34af24
LT
256ifdef NO_STRCASESTR
257 DEFINES += -Dstrcasestr=gitstrcasestr
258 LIB_OBJS += compat/strcasestr.o
259endif
49744d63 260ifdef NO_IPV6
6573faff 261 DEFINES += -DNO_IPV6 -Dsockaddr_storage=sockaddr_in
49744d63 262endif
cef661fc 263
7c6ef2f2
NP
264ifdef PPC_SHA1
265 SHA1_HEADER = "ppc/sha1.h"
266 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
267else
268ifdef ARM_SHA1
269 SHA1_HEADER = "arm/sha1.h"
270 LIB_OBJS += arm/sha1.o arm/sha1_arm.o
271else
272ifdef MOZILLA_SHA1
273 SHA1_HEADER = "mozilla-sha1/sha1.h"
274 LIB_OBJS += mozilla-sha1/sha1.o
275else
276 SHA1_HEADER = <openssl/sha.h>
277 LIBS += $(LIB_4_CRYPTO)
278endif
279endif
280endif
281
b05701c5 282DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
cc1ad5c8 283
bc6146d2 284SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
720d150c
JH
285 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
286 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
287 gitk
44c9e859 288
edde7a8b 289export TAR INSTALL DESTDIR SHELL_PATH
28818ffa
PB
290### Build rules
291
bb8c91d6 292all: $(PROGRAMS) $(SCRIPTS)
89967023 293
d3af621b
JH
294all:
295 $(MAKE) -C templates
b05701c5 296
bc6146d2 297git: git.sh Makefile
6a2e50f9 298 rm -f $@+ $@
229a7ed7 299 sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' \
79a9d8ea 300<<<<<<< Makefile
039c6f16
PA
301 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
302 -e 's/@@X@@/$(X)/g' <$@.sh >$@+
79a9d8ea 303=======
0842acff
JH
304 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
305 $(GIT_LIST_TWEAK) <$@.sh >$@+
79a9d8ea 306>>>>>>> .merge_file_3QHyD4
6a2e50f9
JH
307 chmod +x $@+
308 mv $@+ $@
309
bc6146d2
JH
310$(filter-out git,$(patsubst %.sh,%,$(SCRIPT_SH))) : % : %.sh
311 rm -f $@
312 sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' $@.sh >$@
313 chmod +x $@
314
315$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
316 rm -f $@
317 sed -e '1s|#!.*perl|#!$(PERL_PATH)|' $@.perl >$@
318 chmod +x $@
319
720d150c
JH
320$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
321 rm -f $@
322 sed -e '1s|#!.*python|#!$(PYTHON_PATH)|' \
323 -e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR)|g' \
324 $@.py >$@
325 chmod +x $@
326
b05701c5
PR
327%.o: %.c
328 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
329%.o: %.S
330 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
a310d434 331
2f29dd52 332git-%$X: %.o $(LIB_FILE)
b05701c5 333 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
623c8a14 334
2f29dd52 335git-mailinfo$X : SIMPLE_LIB += $(LIB_4_ICONV)
bb8c91d6 336$(SIMPLE_PROGRAMS) : $(LIB_FILE)
2f29dd52 337$(SIMPLE_PROGRAMS) : git-%$X : %.o
597c9cc5
JH
338 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIB_FILE) $(SIMPLE_LIB)
339
2f29dd52
PA
340git-http-fetch$X: fetch.o
341git-local-fetch$X: fetch.o
342git-ssh-fetch$X: rsh.o fetch.o
343git-ssh-upload$X: rsh.o
344git-ssh-pull$X: rsh.o fetch.o
345git-ssh-push$X: rsh.o
a3df1801 346
2f29dd52
PA
347git-http-fetch$X: LIBS += $(CURL_LIBCURL)
348git-rev-list$X: LIBS += $(OPENSSL_LIBSSL)
a3df1801 349
d3af621b 350init-db.o: init-db.c
b05701c5
PR
351 $(CC) -c $(ALL_CFLAGS) \
352 -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
d3af621b 353
e468305a 354$(LIB_OBJS): $(LIB_H)
2f29dd52 355$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H)
e468305a 356$(DIFF_OBJS): diffcore.h
e83c5163 357
28818ffa
PB
358$(LIB_FILE): $(LIB_OBJS)
359 $(AR) rcs $@ $(LIB_OBJS)
360
361doc:
362 $(MAKE) -C Documentation all
363
364
28818ffa
PB
365### Testing rules
366
367test: all
368 $(MAKE) -C t/ all
369
2f29dd52 370test-date$X: test-date.c date.o
b05701c5 371 $(CC) $(ALL_CFLAGS) -o $@ test-date.c date.o
28818ffa 372
2f29dd52 373test-delta$X: test-delta.c diff-delta.o patch-delta.o
b05701c5 374 $(CC) $(ALL_CFLAGS) -o $@ $^
28818ffa
PB
375
376check:
b05701c5 377 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
28818ffa
PB
378
379
380
381### Installation rules
382
bb8c91d6 383install: $(PROGRAMS) $(SCRIPTS)
53764ee4 384 $(INSTALL) -d -m755 $(DESTDIR)$(bindir)
bb8c91d6 385 $(INSTALL) $(PROGRAMS) $(SCRIPTS) $(DESTDIR)$(bindir)
bc6146d2 386 $(INSTALL) git-revert $(DESTDIR)$(bindir)/git-cherry-pick
894a8a8b 387 sh ./cmd-rename.sh $(DESTDIR)$(bindir)
8d5afef0 388 $(MAKE) -C templates install
53764ee4 389 $(INSTALL) -d -m755 $(DESTDIR)$(GIT_PYTHON_DIR)
720d150c 390 $(INSTALL) $(PYMODULES) $(DESTDIR)$(GIT_PYTHON_DIR)
28818ffa
PB
391
392install-doc:
393 $(MAKE) -C Documentation install
394
395
396
397
398### Maintainer's dist rules
399
78d9d414 400git-core.spec: git-core.spec.in Makefile
a9db2974
CW
401 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
402
f85639c3
LT
403GIT_TARNAME=git-core-$(GIT_VERSION)
404dist: git-core.spec git-tar-tree
b1de9de2 405 ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
a9db2974 406 @mkdir -p $(GIT_TARNAME)
f85639c3 407 @cp git-core.spec $(GIT_TARNAME)
229a7ed7 408 $(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git-core.spec
a9db2974 409 @rm -rf $(GIT_TARNAME)
9dce3c06 410 gzip -f -9 $(GIT_TARNAME).tar
a9db2974
CW
411
412rpm: dist
d7b8a164 413 $(RPMBUILD) -ta git-core-$(GIT_VERSION).tar.gz
a9db2974 414
7a590132 415deb: dist
f29eaed1 416 rm -rf $(GIT_TARNAME)
229a7ed7 417 $(TAR) zxf $(GIT_TARNAME).tar.gz
5a571cdd 418 dpkg-source -b $(GIT_TARNAME)
f29eaed1 419 cd $(GIT_TARNAME) && fakeroot debian/rules binary
28818ffa
PB
420
421### Cleaning rules
87a81c83 422
e83c5163 423clean:
bb8c91d6 424 rm -f *.o mozilla-sha1/*.o ppc/*.o compat/*.o $(PROGRAMS) $(LIB_FILE)
bc6146d2 425 rm -f $(filter-out gitk,$(SCRIPTS))
a5579767 426 rm -f git-core.spec *.pyc *.pyo
f29eaed1 427 rm -rf $(GIT_TARNAME)
5a571cdd
JH
428 rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
429 rm -f git-core_$(GIT_VERSION)-*.deb git-core_$(GIT_VERSION)-*.dsc
430 rm -f git-tk_$(GIT_VERSION)-*.deb
ca67f002 431 $(MAKE) -C Documentation/ clean
229a7ed7 432 $(MAKE) -C templates clean
4b7581f0 433 $(MAKE) -C t/ clean