Makefile 12.8 KB
Newer Older
1 2 3 4
# Define MOZILLA_SHA1 environment variable when running make to make use of
# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast
# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default
# choice) has very fast version optimized for i586.
5
#
6 7
# Define NO_OPENSSL environment variable if you do not have OpenSSL. You will
# miss out git-rev-list --merge-order. This also implies MOZILLA_SHA1.
8
#
9 10 11
# Define NO_CURL if you do not have curl installed.  git-http-pull and
# git-http-push are not built, and you cannot use http:// and https://
# transports.
12
#
P
Patrick Mauritz 已提交
13 14 15
# Define CURLDIR=/foo/bar if your curl header and library files are in
# /foo/bar/include and /foo/bar/lib directories.
#
16 17 18
# Define NO_EXPAT if you do not have expat installed.  git-http-push is
# not built, and you cannot push using http:// and https:// transports.
#
19 20
# Define NO_STRCASESTR if you don't have strcasestr.
#
21 22
# Define PPC_SHA1 environment variable when running make to make use of
# a bundled SHA1 routine optimized for PowerPC.
23
#
24 25 26
# Define ARM_SHA1 environment variable when running make to make use of
# a bundled SHA1 routine optimized for ARM.
#
27
# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
28
#
29
# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
30 31 32 33
#
# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
# Patrick Mauritz).
#
34 35
# Define NO_MMAP if you want to avoid mmap.
#
36 37
# Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
#
38 39
# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
#
40 41 42 43 44 45 46 47 48 49 50 51 52
# Define COLLISION_CHECK below if you believe that SHA1's
# 1461501637330902918203684832716283019655932542976 hashes do not give you
# sufficient guarantee that no collisions between objects will ever happen.

# Define USE_NSEC below if you want git to care about sub-second file mtimes
# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
# randomly break unless your underlying filesystem supports those sub-second
# times (my ext3 doesn't).

# Define USE_STDEV below if you want git to care about the underlying device
# change being considered an inode change from the update-cache perspective.

J
Junio C Hamano 已提交
53
GIT_VERSION = 0.99.9.GIT
54

55 56
# CFLAGS is for the users to override from the command line.

57
CFLAGS = -g -O2 -Wall
58
ALL_CFLAGS = $(CFLAGS)
59

60 61 62
prefix = $(HOME)
bindir = $(prefix)/bin
template_dir = $(prefix)/share/git-core/templates/
63
GIT_PYTHON_DIR = $(prefix)/share/git-core/python
64
# DESTDIR=
65

66 67
CC = gcc
AR = ar
68
TAR = tar
69 70
INSTALL = install
RPMBUILD = rpmbuild
71

72 73
# sparse is architecture-neutral, which means that we need to tell it
# explicitly what architecture to check for. Fix this up for yours..
74
SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
75

P
Petr Baudis 已提交
76 77 78 79


### --- END CONFIGURATION SECTION ---

J
Junio C Hamano 已提交
80 81 82 83 84 85 86 87 88 89
SCRIPT_SH = \
	git-add.sh git-bisect.sh git-branch.sh git-checkout.sh \
	git-cherry.sh git-clone.sh git-commit.sh \
	git-count-objects.sh git-diff.sh git-fetch.sh \
	git-format-patch.sh git-log.sh git-ls-remote.sh \
	git-merge-one-file.sh git-octopus.sh git-parse-remote.sh \
	git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
	git-repack.sh git-request-pull.sh git-reset.sh \
	git-resolve.sh git-revert.sh git-sh-setup.sh git-status.sh \
	git-tag.sh git-verify-tag.sh git-whatchanged.sh git.sh \
90
	git-applymbox.sh git-applypatch.sh git-am.sh \
91
	git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
J
Junio C Hamano 已提交
92
	git-merge-resolve.sh git-merge-ours.sh git-grep.sh
J
Junio C Hamano 已提交
93 94 95

SCRIPT_PERL = \
	git-archimport.perl git-cvsimport.perl git-relink.perl \
M
Martin Langhoff 已提交
96
	git-rename.perl git-shortlog.perl git-fmt-merge-msg.perl \
P
Petr Baudis 已提交
97
	git-svnimport.perl git-mv.perl
98

99
SCRIPT_PYTHON = \
100
	git-merge-recursive.py
101

102 103
# The ones that do not have to link with lcrypto nor lz.
SIMPLE_PROGRAMS = \
104 105
	git-get-tar-commit-id$X git-mailinfo$X git-mailsplit$X \
	git-stripspace$X git-var$X git-daemon$X
106 107

# ... and all the rest
J
Junio C Hamano 已提交
108
PROGRAMS = \
109 110 111 112 113
	git-apply$X git-cat-file$X \
	git-checkout-index$X git-clone-pack$X git-commit-tree$X \
	git-convert-objects$X git-diff-files$X \
	git-diff-index$X git-diff-stages$X \
	git-diff-tree$X git-fetch-pack$X git-fsck-objects$X \
S
Sergey Vlasov 已提交
114
	git-hash-object$X git-index-pack$X git-init-db$X \
115 116 117 118
	git-local-fetch$X git-ls-files$X git-ls-tree$X git-merge-base$X \
	git-merge-index$X git-mktag$X git-pack-objects$X git-patch-id$X \
	git-peek-remote$X git-prune-packed$X git-read-tree$X \
	git-receive-pack$X git-rev-list$X git-rev-parse$X \
L
Linus Torvalds 已提交
119
	git-send-pack$X git-show-branch$X git-shell$X \
120 121 122 123
	git-show-index$X git-ssh-fetch$X \
	git-ssh-upload$X git-tar-tree$X git-unpack-file$X \
	git-unpack-objects$X git-update-index$X git-update-server-info$X \
	git-upload-pack$X git-verify-pack$X git-write-tree$X \
124
	git-update-ref$X git-symbolic-ref$X git-check-ref-format$X \
J
Johannes Schindelin 已提交
125
	git-name-rev$X $(SIMPLE_PROGRAMS)
126

127
# Backward compatibility -- to be removed after 1.0
128
PROGRAMS += git-ssh-pull$X git-ssh-push$X
129

130 131
GIT_LIST_TWEAK =

132 133 134
PYMODULES = \
	gitMergeCommon.py

135 136 137 138
ifdef WITH_OWN_SUBPROCESS_PY
	PYMODULES += compat/subprocess.py
endif

139
ifdef WITH_SEND_EMAIL
J
Junio C Hamano 已提交
140
	SCRIPT_PERL += git-send-email.perl
141 142
else
	GIT_LIST_TWEAK += -e '/^send-email$$/d'
143 144
endif

L
Linus Torvalds 已提交
145
LIB_FILE=libgit.a
J
Junio C Hamano 已提交
146

J
Junio C Hamano 已提交
147 148 149
LIB_H = \
	blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
	diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
J
Junio C Hamano 已提交
150
	run-command.h strbuf.h tag.h tree.h
151

J
Junio C Hamano 已提交
152 153
DIFF_OBJS = \
	diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
154
	diffcore-pickaxe.o diffcore-rename.o tree-diff.o
155

J
Junio C Hamano 已提交
156 157
LIB_OBJS = \
	blob.o commit.o connect.o count-delta.o csum-file.o \
158
	date.o diff-delta.o entry.o ident.o index.o \
J
Junio C Hamano 已提交
159
	object.o pack-check.o patch-delta.o path.o pkt-line.o \
J
Junio C Hamano 已提交
160
	quote.o read-cache.o refs.o run-command.o \
J
Junio C Hamano 已提交
161
	server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
162
	tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
L
Linus Torvalds 已提交
163
	$(DIFF_OBJS)
J
Junio C Hamano 已提交
164

165 166
LIBS = $(LIB_FILE)
LIBS += -lz
167

168 169 170 171 172 173
# Shell quote;
# Result of this needs to be placed inside ''
shq = $(subst ','\'',$(1))
# This has surrounding ''
shellquote = '$(call shq,$(1))'

174 175 176
#
# Platform specific tweaks
#
177 178 179 180 181 182 183 184 185

# We choose to avoid "if .. else if .. else .. endif endif"
# because maintaining the nesting to match is a pain.  If
# we had "elif" things would have been much nicer...
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')

ifeq ($(uname_S),Darwin)
186 187 188
	NEEDS_SSL_WITH_CRYPTO = YesPlease
	NEEDS_LIBICONV = YesPlease
endif
189
ifeq ($(uname_S),SunOS)
190
	NEEDS_SOCKET = YesPlease
191
	NEEDS_NSL = YesPlease
192
	NEEDS_LIBICONV = YesPlease
193 194 195 196
	SHELL_PATH = /bin/bash
	NO_STRCASESTR = YesPlease
	INSTALL = ginstall
	TAR = gtar
197
	ALL_CFLAGS += -D__EXTENSIONS__
198
endif
199
ifeq ($(uname_O),Cygwin)
H
hpa 已提交
200 201
	NO_STRCASESTR = YesPlease
	NEEDS_LIBICONV = YesPlease
202
	NO_IPV6 = YesPlease
P
Peter Anvin 已提交
203
	X = .exe
204
	ALL_CFLAGS += -DUSE_SYMLINK_HEAD=0
H
hpa 已提交
205
endif
206
ifeq ($(uname_S),OpenBSD)
207
	NO_STRCASESTR = YesPlease
H
Han Boetes 已提交
208
	NEEDS_LIBICONV = YesPlease
209
	ALL_CFLAGS += -I/usr/local/include -L/usr/local/lib
H
Han Boetes 已提交
210
endif
211 212 213
ifneq (,$(findstring arm,$(uname_M)))
	ARM_SHA1 = YesPlease
endif
214

215 216
-include config.mak

217 218 219
ifndef NO_CURL
	ifdef CURLDIR
		# This is still problematic -- gcc does not want -R.
220
		ALL_CFLAGS += -I$(CURLDIR)/include
221 222 223 224
		CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
	else
		CURL_LIBCURL = -lcurl
	endif
225
	PROGRAMS += git-http-fetch$X
226 227 228 229
	ifndef NO_EXPAT
		EXPAT_LIBEXPAT = -lexpat
		PROGRAMS += git-http-push$X
	endif
230 231
endif

232 233 234 235 236 237
ifndef SHELL_PATH
	SHELL_PATH = /bin/sh
endif
ifndef PERL_PATH
	PERL_PATH = /usr/bin/perl
endif
238 239 240
ifndef PYTHON_PATH
	PYTHON_PATH = /usr/bin/python
endif
241

P
Petr Baudis 已提交
242 243
ifndef NO_OPENSSL
	LIB_OBJS += epoch.o
J
Junio C Hamano 已提交
244
	OPENSSL_LIBSSL = -lssl
J
Junio C Hamano 已提交
245 246
	ifdef OPENSSLDIR
		# Again this may be problematic -- gcc does not always want -R.
247
		ALL_CFLAGS += -I$(OPENSSLDIR)/include
J
Junio C Hamano 已提交
248 249 250 251
		OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
	else
		OPENSSL_LINK =
	endif
P
Petr Baudis 已提交
252
else
253
	ALL_CFLAGS += -DNO_OPENSSL
J
Junio C Hamano 已提交
254 255
	MOZILLA_SHA1 = 1
	OPENSSL_LIBSSL =
P
Petr Baudis 已提交
256
endif
257
ifdef NEEDS_SSL_WITH_CRYPTO
J
Junio C Hamano 已提交
258
	LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
259
else
J
Junio C Hamano 已提交
260
	LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
261 262
endif
ifdef NEEDS_LIBICONV
J
Junio C Hamano 已提交
263 264
	ifdef ICONVDIR
		# Again this may be problematic -- gcc does not always want -R.
265
		ALL_CFLAGS += -I$(ICONVDIR)/include
J
Junio C Hamano 已提交
266 267 268 269 270
		ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
	else
		ICONV_LINK =
	endif
	LIB_4_ICONV = $(ICONV_LINK) -liconv
271 272 273
else
	LIB_4_ICONV =
endif
274 275 276 277
ifdef NEEDS_SOCKET
	LIBS += -lsocket
	SIMPLE_LIB += -lsocket
endif
278 279 280 281
ifdef NEEDS_NSL
	LIBS += -lnsl
	SIMPLE_LIB += -lnsl
endif
282
ifdef NO_STRCASESTR
283
	ALL_CFLAGS += -Dstrcasestr=gitstrcasestr -DNO_STRCASESTR=1
284 285
	LIB_OBJS += compat/strcasestr.o
endif
286
ifdef NO_MMAP
287
	ALL_CFLAGS += -Dmmap=gitfakemmap -Dmunmap=gitfakemunmap -DNO_MMAP
288 289
	LIB_OBJS += compat/mmap.o
endif
290
ifdef NO_IPV6
291
	ALL_CFLAGS += -DNO_IPV6 -Dsockaddr_storage=sockaddr_in
292
endif
293

294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
ifdef PPC_SHA1
	SHA1_HEADER = "ppc/sha1.h"
	LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
else
ifdef ARM_SHA1
	SHA1_HEADER = "arm/sha1.h"
	LIB_OBJS += arm/sha1.o arm/sha1_arm.o
else
ifdef MOZILLA_SHA1
	SHA1_HEADER = "mozilla-sha1/sha1.h"
	LIB_OBJS += mozilla-sha1/sha1.o
else
	SHA1_HEADER = <openssl/sha.h>
	LIBS += $(LIB_4_CRYPTO)
endif
endif
endif

312
ALL_CFLAGS += -DSHA1_HEADER=$(call shellquote,$(SHA1_HEADER))
313

314
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
315 316
	  $(patsubst %.perl,%,$(SCRIPT_PERL)) \
	  $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
317
	  gitk git-cherry-pick
318

T
Tom Prince 已提交
319
export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
P
Petr Baudis 已提交
320 321
### Build rules

322
all: $(PROGRAMS) $(SCRIPTS)
323

324 325
all:
	$(MAKE) -C templates
326

327
git: git.sh Makefile
328
	rm -f $@+ $@
329
	sed -e '1s|#!.*/sh|#!$(call shq,$(SHELL_PATH))|' \
330
	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
331
	    -e 's/@@X@@/$(X)/g' \
332
	    $(GIT_LIST_TWEAK) <$@.sh >$@+
333 334 335
	chmod +x $@+
	mv $@+ $@

336 337
$(filter-out git,$(patsubst %.sh,%,$(SCRIPT_SH))) : % : %.sh
	rm -f $@
338
	sed -e '1s|#!.*/sh|#!$(call shq,$(SHELL_PATH))|' \
339 340
	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
	    $@.sh >$@
341 342 343 344
	chmod +x $@

$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
	rm -f $@
345
	sed -e '1s|#!.*perl|#!$(call shq,$(PERL_PATH))|' \
346 347
	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
	    $@.perl >$@
348 349
	chmod +x $@

350 351
$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
	rm -f $@
352 353
	sed -e '1s|#!.*python|#!$(call shq,$(PYTHON_PATH))|' \
	    -e 's|@@GIT_PYTHON_PATH@@|$(call shq,$(GIT_PYTHON_DIR))|g' \
354 355
	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
	    $@.py >$@
356 357
	chmod +x $@

358 359 360
git-cherry-pick: git-revert
	cp $< $@

361 362 363 364
%.o: %.c
	$(CC) -o $*.o -c $(ALL_CFLAGS) $<
%.o: %.S
	$(CC) -o $*.o -c $(ALL_CFLAGS) $<
365

366
git-%$X: %.o $(LIB_FILE)
367
	$(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
368

369
git-mailinfo$X : SIMPLE_LIB += $(LIB_4_ICONV)
370
$(SIMPLE_PROGRAMS) : $(LIB_FILE)
371
$(SIMPLE_PROGRAMS) : git-%$X : %.o
372 373
	$(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIB_FILE) $(SIMPLE_LIB)

374 375 376 377 378 379
git-http-fetch$X: fetch.o
git-local-fetch$X: fetch.o
git-ssh-fetch$X: rsh.o fetch.o
git-ssh-upload$X: rsh.o
git-ssh-pull$X: rsh.o fetch.o
git-ssh-push$X: rsh.o
380

381
git-http-fetch$X: LIBS += $(CURL_LIBCURL)
382
git-http-push$X: LIBS += $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
383
git-rev-list$X: LIBS += $(OPENSSL_LIBSSL)
384

385
init-db.o: init-db.c
386
	$(CC) -c $(ALL_CFLAGS) \
387
		-DDEFAULT_GIT_TEMPLATE_DIR=$(call shellquote,"$(template_dir)") $*.c
388

389
$(LIB_OBJS): $(LIB_H)
390
$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H)
391
$(DIFF_OBJS): diffcore.h
392

P
Petr Baudis 已提交
393 394 395 396 397 398 399 400 401 402 403 404
$(LIB_FILE): $(LIB_OBJS)
	$(AR) rcs $@ $(LIB_OBJS)

doc:
	$(MAKE) -C Documentation all


### Testing rules

test: all
	$(MAKE) -C t/ all

J
Junio C Hamano 已提交
405 406
test-date$X: test-date.c date.o ctype.o
	$(CC) $(ALL_CFLAGS) -o $@ test-date.c date.o ctype.o
P
Petr Baudis 已提交
407

408
test-delta$X: test-delta.c diff-delta.o patch-delta.o
409
	$(CC) $(ALL_CFLAGS) -o $@ $^
P
Petr Baudis 已提交
410 411

check:
412
	for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
P
Petr Baudis 已提交
413 414 415 416 417



### Installation rules

418
install: $(PROGRAMS) $(SCRIPTS)
419 420
	$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(bindir))
	$(INSTALL) $(PROGRAMS) $(SCRIPTS) $(call shellquote,$(DESTDIR)$(bindir))
J
Junio C Hamano 已提交
421
	$(MAKE) -C templates install
422 423
	$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
	$(INSTALL) $(PYMODULES) $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
P
Petr Baudis 已提交
424 425 426 427 428 429 430 431 432

install-doc:
	$(MAKE) -C Documentation install




### Maintainer's dist rules

433
git-core.spec: git-core.spec.in Makefile
434 435
	sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@

436 437
GIT_TARNAME=git-core-$(GIT_VERSION)
dist: git-core.spec git-tar-tree
C
Chris Wright 已提交
438
	./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
439
	@mkdir -p $(GIT_TARNAME)
440
	@cp git-core.spec $(GIT_TARNAME)
441
	$(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git-core.spec
442
	@rm -rf $(GIT_TARNAME)
443
	gzip -f -9 $(GIT_TARNAME).tar
444 445

rpm: dist
446
	$(RPMBUILD) -ta git-core-$(GIT_VERSION).tar.gz
447

J
Junio C Hamano 已提交
448
deb: dist
449
	rm -rf $(GIT_TARNAME)
450
	$(TAR) zxf $(GIT_TARNAME).tar.gz
451
	dpkg-source -b $(GIT_TARNAME)
452
	cd $(GIT_TARNAME) && fakeroot debian/rules binary
P
Petr Baudis 已提交
453 454

### Cleaning rules
455

456
clean:
457
	rm -f *.o mozilla-sha1/*.o ppc/*.o compat/*.o $(PROGRAMS) $(LIB_FILE)
458
	rm -f $(filter-out gitk,$(SCRIPTS))
459
	rm -f git-core.spec *.pyc *.pyo
460
	rm -rf $(GIT_TARNAME)
461
	rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
J
Junio C Hamano 已提交
462 463
	rm -f git-core_$(GIT_VERSION)-*.dsc
	rm -f git-*_$(GIT_VERSION)-*.deb
464
	$(MAKE) -C Documentation/ clean
465
	$(MAKE) -C templates clean
466
	$(MAKE) -C t/ clean