Makefile 12.9 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 \
M
Martin Langhoff 已提交
97
	git-svnimport.perl git-mv.perl git-cvsexportcommit.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 \
L
Lukas_Sandström 已提交
125
	git-name-rev$X git-pack-intersect$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
	NEEDS_SSL_WITH_CRYPTO = YesPlease
	NEEDS_LIBICONV = YesPlease
188 189 190 191
	## fink
	ALL_CFLAGS += -I/sw/include -L/sw/lib
	## darwinports
	ALL_CFLAGS += -I/opt/local/include -L/opt/local/lib
192
endif
193
ifeq ($(uname_S),SunOS)
194
	NEEDS_SOCKET = YesPlease
195
	NEEDS_NSL = YesPlease
196
	NEEDS_LIBICONV = YesPlease
197 198 199 200
	SHELL_PATH = /bin/bash
	NO_STRCASESTR = YesPlease
	INSTALL = ginstall
	TAR = gtar
201
	ALL_CFLAGS += -D__EXTENSIONS__
202
endif
203
ifeq ($(uname_O),Cygwin)
H
hpa 已提交
204 205
	NO_STRCASESTR = YesPlease
	NEEDS_LIBICONV = YesPlease
206
	NO_IPV6 = YesPlease
P
Peter Anvin 已提交
207
	X = .exe
208
	ALL_CFLAGS += -DUSE_SYMLINK_HEAD=0
H
hpa 已提交
209
endif
210
ifeq ($(uname_S),OpenBSD)
211
	NO_STRCASESTR = YesPlease
H
Han Boetes 已提交
212
	NEEDS_LIBICONV = YesPlease
213
	ALL_CFLAGS += -I/usr/local/include -L/usr/local/lib
H
Han Boetes 已提交
214
endif
215 216 217
ifneq (,$(findstring arm,$(uname_M)))
	ARM_SHA1 = YesPlease
endif
218

219 220
-include config.mak

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

236 237 238 239 240 241
ifndef SHELL_PATH
	SHELL_PATH = /bin/sh
endif
ifndef PERL_PATH
	PERL_PATH = /usr/bin/perl
endif
242 243 244
ifndef PYTHON_PATH
	PYTHON_PATH = /usr/bin/python
endif
245

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

298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
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

316
ALL_CFLAGS += -DSHA1_HEADER=$(call shellquote,$(SHA1_HEADER))
317

318
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
319 320
	  $(patsubst %.perl,%,$(SCRIPT_PERL)) \
	  $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
321
	  gitk git-cherry-pick
322

T
Tom Prince 已提交
323
export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
P
Petr Baudis 已提交
324 325
### Build rules

326
all: $(PROGRAMS) $(SCRIPTS)
327

328 329
all:
	$(MAKE) -C templates
330

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

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

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

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

362 363 364
git-cherry-pick: git-revert
	cp $< $@

365 366 367 368
%.o: %.c
	$(CC) -o $*.o -c $(ALL_CFLAGS) $<
%.o: %.S
	$(CC) -o $*.o -c $(ALL_CFLAGS) $<
369

370
git-%$X: %.o $(LIB_FILE)
371
	$(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
372

373
git-mailinfo$X : SIMPLE_LIB += $(LIB_4_ICONV)
374
$(SIMPLE_PROGRAMS) : $(LIB_FILE)
375
$(SIMPLE_PROGRAMS) : git-%$X : %.o
376 377
	$(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIB_FILE) $(SIMPLE_LIB)

378 379 380 381 382 383
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
384

385
git-http-fetch$X: LIBS += $(CURL_LIBCURL)
386
git-http-push$X: LIBS += $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
387
git-rev-list$X: LIBS += $(OPENSSL_LIBSSL)
388

389
init-db.o: init-db.c
390
	$(CC) -c $(ALL_CFLAGS) \
391
		-DDEFAULT_GIT_TEMPLATE_DIR=$(call shellquote,"$(template_dir)") $*.c
392

393
$(LIB_OBJS): $(LIB_H)
394
$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H)
395
$(DIFF_OBJS): diffcore.h
396

P
Petr Baudis 已提交
397 398 399 400 401 402 403 404 405 406 407 408
$(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 已提交
409 410
test-date$X: test-date.c date.o ctype.o
	$(CC) $(ALL_CFLAGS) -o $@ test-date.c date.o ctype.o
P
Petr Baudis 已提交
411

412
test-delta$X: test-delta.c diff-delta.o patch-delta.o
413
	$(CC) $(ALL_CFLAGS) -o $@ $^
P
Petr Baudis 已提交
414 415

check:
416
	for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
P
Petr Baudis 已提交
417 418 419 420 421



### Installation rules

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

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




### Maintainer's dist rules

437
git-core.spec: git-core.spec.in Makefile
438 439
	sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@

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

rpm: dist
450
	$(RPMBUILD) -ta git-core-$(GIT_VERSION).tar.gz
451

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

### Cleaning rules
459

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