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.
5#
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.
8#
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#
12# Define CURLDIR=/foo/bar if your curl header and library files are in
13# /foo/bar/include and /foo/bar/lib directories.
14#
15# Define NO_STRCASESTR if you don't have strcasestr.
16#
17# Define PPC_SHA1 environment variable when running make to make use of
18# a bundled SHA1 routine optimized for PowerPC.
19#
20# Define ARM_SHA1 environment variable when running make to make use of
21# a bundled SHA1 routine optimized for ARM.
22#
23# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
24#
25# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
26#
27# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
28# Patrick Mauritz).
29#
30# Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
31#
32# Define COLLISION_CHECK below if you believe that SHA1's
33# 1461501637330902918203684832716283019655932542976 hashes do not give you
34# sufficient guarantee that no collisions between objects will ever happen.
35
36# DEFINES += -DCOLLISION_CHECK
37
38# Define USE_NSEC below if you want git to care about sub-second file mtimes
39# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
40# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
41# randomly break unless your underlying filesystem supports those sub-second
42# times (my ext3 doesn't).
43
44# DEFINES += -DUSE_NSEC
45
46# Define USE_STDEV below if you want git to care about the underlying device
47# change being considered an inode change from the update-cache perspective.
48
49# DEFINES += -DUSE_STDEV
50
51GIT_VERSION = 0.99.7.GIT
52
53CFLAGS = -g -O2 -Wall
54ALL_CFLAGS = $(CFLAGS) $(PLATFORM_DEFINES) $(DEFINES)
55
56prefix = $(HOME)
57bindir = $(prefix)/bin
58template_dir = $(prefix)/share/git-core/templates/
59GIT_PYTHON_DIR = $(prefix)/share/git-core/python
60# DESTDIR=
61
62CC = gcc
63AR = ar
64TAR = tar
65INSTALL = install
66RPMBUILD = rpmbuild
67
68# sparse is architecture-neutral, which means that we need to tell it
69# explicitly what architecture to check for. Fix this up for yours..
70SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
71
72
73
74### --- END CONFIGURATION SECTION ---
75
76SCRIPT_SH = \
77 git-add.sh git-bisect.sh git-branch.sh git-checkout.sh \
78 git-cherry.sh git-clone.sh git-commit.sh \
79 git-count-objects.sh git-diff.sh git-fetch.sh \
80 git-format-patch.sh git-log.sh git-ls-remote.sh \
81 git-merge-one-file.sh git-octopus.sh git-parse-remote.sh \
82 git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
83 git-repack.sh git-request-pull.sh git-reset.sh \
84 git-resolve.sh git-revert.sh git-sh-setup.sh git-status.sh \
85 git-tag.sh git-verify-tag.sh git-whatchanged.sh git.sh \
86 git-applymbox.sh git-applypatch.sh \
87 git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
88 git-merge-resolve.sh git-grep.sh
89
90SCRIPT_PERL = \
91 git-archimport.perl git-cvsimport.perl git-relink.perl \
92 git-rename.perl git-shortlog.perl git-fmt-merge-msg.perl
93
94SCRIPT_PYTHON = \
95 git-merge-recursive.py
96
97# The ones that do not have to link with lcrypto nor lz.
98SIMPLE_PROGRAMS = \
99 git-get-tar-commit-id git-mailinfo git-mailsplit git-stripspace \
100 git-daemon git-var
101
102# ... and all the rest
103PROGRAMS = \
104 git-apply git-cat-file \
105 git-checkout-index git-clone-pack git-commit-tree \
106 git-convert-objects git-diff-files \
107 git-diff-index git-diff-stages \
108 git-diff-tree git-fetch-pack git-fsck-objects \
109 git-hash-object git-init-db \
110 git-local-fetch git-ls-files git-ls-tree git-merge-base \
111 git-merge-index git-mktag git-pack-objects git-patch-id \
112 git-peek-remote git-prune-packed git-read-tree \
113 git-receive-pack git-rev-list git-rev-parse \
114 git-send-pack git-show-branch \
115 git-show-index git-ssh-fetch \
116 git-ssh-upload git-tar-tree git-unpack-file \
117 git-unpack-objects git-update-index git-update-server-info \
118 git-upload-pack git-verify-pack git-write-tree \
119 $(SIMPLE_PROGRAMS)
120
121# Backward compatibility -- to be removed in 0.99.8
122PROGRAMS += git-ssh-pull git-ssh-push
123
124PYMODULES = \
125 gitMergeCommon.py
126
127ifdef WITH_OWN_SUBPROCESS_PY
128 PYMODULES += compat/subprocess.py
129endif
130
131ifdef WITH_SEND_EMAIL
132 SCRIPT_PERL += git-send-email.perl
133endif
134
135LIB_FILE=libgit.a
136
137LIB_H = \
138 blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
139 diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
140 run-command.h strbuf.h tag.h tree.h
141
142DIFF_OBJS = \
143 diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
144 diffcore-pickaxe.o diffcore-rename.o
145
146LIB_OBJS = \
147 blob.o commit.o connect.o count-delta.o csum-file.o \
148 date.o diff-delta.o entry.o ident.o index.o \
149 object.o pack-check.o patch-delta.o path.o pkt-line.o \
150 quote.o read-cache.o refs.o run-command.o \
151 server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
152 tag.o tree.o usage.o $(DIFF_OBJS)
153
154LIBS = $(LIB_FILE)
155LIBS += -lz
156
157#
158# Platform specific tweaks
159#
160ifeq ($(shell uname -s),Darwin)
161 NEEDS_SSL_WITH_CRYPTO = YesPlease
162 NEEDS_LIBICONV = YesPlease
163endif
164ifeq ($(shell uname -s),SunOS)
165 NEEDS_SOCKET = YesPlease
166 NEEDS_NSL = YesPlease
167 SHELL_PATH = /bin/bash
168 NO_STRCASESTR = YesPlease
169 CURLDIR = /opt/sfw
170 INSTALL = ginstall
171 TAR = gtar
172 PLATFORM_DEFINES += -D__EXTENSIONS__
173endif
174ifneq (,$(findstring arm,$(shell uname -m)))
175 ARM_SHA1 = YesPlease
176endif
177
178ifndef NO_CURL
179 ifdef CURLDIR
180 # This is still problematic -- gcc does not want -R.
181 CFLAGS += -I$(CURLDIR)/include
182 CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
183 else
184 CURL_LIBCURL = -lcurl
185 endif
186 PROGRAMS += git-http-fetch
187endif
188
189ifndef SHELL_PATH
190 SHELL_PATH = /bin/sh
191endif
192ifndef PERL_PATH
193 PERL_PATH = /usr/bin/perl
194endif
195ifndef PYTHON_PATH
196 PYTHON_PATH = /usr/bin/python
197endif
198
199ifndef NO_OPENSSL
200 LIB_OBJS += epoch.o
201 OPENSSL_LIBSSL = -lssl
202else
203 DEFINES += '-DNO_OPENSSL'
204 MOZILLA_SHA1 = 1
205 OPENSSL_LIBSSL =
206endif
207ifdef NEEDS_SSL_WITH_CRYPTO
208 LIB_4_CRYPTO = -lcrypto -lssl
209else
210 LIB_4_CRYPTO = -lcrypto
211endif
212ifdef NEEDS_LIBICONV
213 LIB_4_ICONV = -liconv
214else
215 LIB_4_ICONV =
216endif
217ifdef NEEDS_SOCKET
218 LIBS += -lsocket
219 SIMPLE_LIB += -lsocket
220endif
221ifdef NEEDS_NSL
222 LIBS += -lnsl
223 SIMPLE_LIB += -lnsl
224endif
225ifdef NO_STRCASESTR
226 DEFINES += -Dstrcasestr=gitstrcasestr
227 LIB_OBJS += compat/strcasestr.o
228endif
229
230ifdef PPC_SHA1
231 SHA1_HEADER = "ppc/sha1.h"
232 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
233else
234ifdef ARM_SHA1
235 SHA1_HEADER = "arm/sha1.h"
236 LIB_OBJS += arm/sha1.o arm/sha1_arm.o
237else
238ifdef MOZILLA_SHA1
239 SHA1_HEADER = "mozilla-sha1/sha1.h"
240 LIB_OBJS += mozilla-sha1/sha1.o
241else
242 SHA1_HEADER = <openssl/sha.h>
243 LIBS += $(LIB_4_CRYPTO)
244endif
245endif
246endif
247
248DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
249
250SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
251 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
252 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
253 gitk
254
255export TAR INSTALL DESTDIR
256### Build rules
257
258all: $(PROGRAMS) $(SCRIPTS)
259
260all:
261 $(MAKE) -C templates
262
263git: git.sh Makefile
264 rm -f $@+ $@
265 sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' \
266 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' <$@.sh >$@+
267 chmod +x $@+
268 mv $@+ $@
269
270$(filter-out git,$(patsubst %.sh,%,$(SCRIPT_SH))) : % : %.sh
271 rm -f $@
272 sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' $@.sh >$@
273 chmod +x $@
274
275$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
276 rm -f $@
277 sed -e '1s|#!.*perl|#!$(PERL_PATH)|' $@.perl >$@
278 chmod +x $@
279
280$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
281 rm -f $@
282 sed -e '1s|#!.*python|#!$(PYTHON_PATH)|' \
283 -e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR)|g' \
284 $@.py >$@
285 chmod +x $@
286
287%.o: %.c
288 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
289%.o: %.S
290 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
291
292git-%: %.o $(LIB_FILE)
293 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
294
295git-mailinfo : SIMPLE_LIB += $(LIB_4_ICONV)
296$(SIMPLE_PROGRAMS) : $(LIB_FILE)
297$(SIMPLE_PROGRAMS) : git-% : %.o
298 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIB_FILE) $(SIMPLE_LIB)
299
300git-http-fetch: fetch.o
301git-local-fetch: fetch.o
302git-ssh-fetch: rsh.o fetch.o
303git-ssh-upload: rsh.o
304git-ssh-pull: rsh.o fetch.o
305git-ssh-push: rsh.o
306
307git-http-fetch: LIBS += $(CURL_LIBCURL)
308git-rev-list: LIBS += $(OPENSSL_LIBSSL)
309
310init-db.o: init-db.c
311 $(CC) -c $(ALL_CFLAGS) \
312 -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
313
314$(LIB_OBJS): $(LIB_H)
315$(patsubst git-%,%.o,$(PROGRAMS)): $(LIB_H)
316$(DIFF_OBJS): diffcore.h
317
318$(LIB_FILE): $(LIB_OBJS)
319 $(AR) rcs $@ $(LIB_OBJS)
320
321doc:
322 $(MAKE) -C Documentation all
323
324
325### Testing rules
326
327test: all
328 $(MAKE) -C t/ all
329
330test-date: test-date.c date.o
331 $(CC) $(ALL_CFLAGS) -o $@ test-date.c date.o
332
333test-delta: test-delta.c diff-delta.o patch-delta.o
334 $(CC) $(ALL_CFLAGS) -o $@ $^
335
336check:
337 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
338
339
340
341### Installation rules
342
343install: $(PROGRAMS) $(SCRIPTS)
344 $(INSTALL) -d -m755 $(DESTDIR)$(bindir)
345 $(INSTALL) $(PROGRAMS) $(SCRIPTS) $(DESTDIR)$(bindir)
346 $(INSTALL) git-revert $(DESTDIR)$(bindir)/git-cherry-pick
347 $(MAKE) -C templates install
348 $(INSTALL) -d -m755 $(DESTDIR)$(GIT_PYTHON_DIR)
349 $(INSTALL) $(PYMODULES) $(DESTDIR)$(GIT_PYTHON_DIR)
350
351install-doc:
352 $(MAKE) -C Documentation install
353
354
355
356
357### Maintainer's dist rules
358
359git-core.spec: git-core.spec.in Makefile
360 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
361
362GIT_TARNAME=git-core-$(GIT_VERSION)
363dist: git-core.spec git-tar-tree
364 ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
365 @mkdir -p $(GIT_TARNAME)
366 @cp git-core.spec $(GIT_TARNAME)
367 $(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git-core.spec
368 @rm -rf $(GIT_TARNAME)
369 gzip -f -9 $(GIT_TARNAME).tar
370
371rpm: dist
372 $(RPMBUILD) -ta git-core-$(GIT_VERSION).tar.gz
373
374deb: dist
375 rm -rf $(GIT_TARNAME)
376 $(TAR) zxf $(GIT_TARNAME).tar.gz
377 dpkg-source -b $(GIT_TARNAME)
378 cd $(GIT_TARNAME) && fakeroot debian/rules binary
379
380### Cleaning rules
381
382clean:
383 rm -f *.o mozilla-sha1/*.o ppc/*.o compat/*.o $(PROGRAMS) $(LIB_FILE)
384 rm -f $(filter-out gitk,$(SCRIPTS))
385 rm -f git-core.spec *.pyc *.pyo
386 rm -rf $(GIT_TARNAME)
387 rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
388 rm -f git-core_$(GIT_VERSION)-*.deb git-core_$(GIT_VERSION)-*.dsc
389 rm -f git-tk_$(GIT_VERSION)-*.deb
390 $(MAKE) -C Documentation/ clean
391 $(MAKE) -C templates clean
392 $(MAKE) -C t/ clean