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 NO_IPV6 if you lack IPv6 support and getaddrinfo().
33#
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
53GIT_VERSION = 0.99.8.GIT
54
55CFLAGS = -g -O2 -Wall
56ALL_CFLAGS = $(CFLAGS) $(PLATFORM_DEFINES) $(DEFINES)
57
58prefix = $(HOME)
59bindir = $(prefix)/bin
60template_dir = $(prefix)/share/git-core/templates/
61GIT_PYTHON_DIR = $(prefix)/share/git-core/python
62# DESTDIR=
63
64CC = gcc
65AR = ar
66TAR = tar
67INSTALL = install
68RPMBUILD = rpmbuild
69
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..
72SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
73
74
75
76### --- END CONFIGURATION SECTION ---
77
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 \
88 git-applymbox.sh git-applypatch.sh \
89 git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
90 git-merge-resolve.sh git-grep.sh
91
92SCRIPT_PERL = \
93 git-archimport.perl git-cvsimport.perl git-relink.perl \
94 git-rename.perl git-shortlog.perl git-fmt-merge-msg.perl \
95 git-svnimport.perl
96
97SCRIPT_PYTHON = \
98 git-merge-recursive.py
99
100# The ones that do not have to link with lcrypto nor lz.
101SIMPLE_PROGRAMS = \
102 git-get-tar-commit-id$X git-mailinfo$X git-mailsplit$X \
103 git-stripspace$X git-var$X git-daemon$X
104
105# ... and all the rest
106PROGRAMS = \
107 git-apply$X git-cat-file$X \
108 git-checkout-index$X git-clone-pack$X git-commit-tree$X \
109 git-convert-objects$X git-diff-files$X \
110 git-diff-index$X git-diff-stages$X \
111 git-diff-tree$X git-fetch-pack$X git-fsck-objects$X \
112 git-hash-object$X git-init-db$X \
113 git-local-fetch$X git-ls-files$X git-ls-tree$X git-merge-base$X \
114 git-merge-index$X git-mktag$X git-pack-objects$X git-patch-id$X \
115 git-peek-remote$X git-prune-packed$X git-read-tree$X \
116 git-receive-pack$X git-rev-list$X git-rev-parse$X \
117 git-send-pack$X git-show-branch$X \
118 git-show-index$X git-ssh-fetch$X \
119 git-ssh-upload$X git-tar-tree$X git-unpack-file$X \
120 git-unpack-objects$X git-update-index$X git-update-server-info$X \
121 git-upload-pack$X git-verify-pack$X git-write-tree$X \
122 git-update-ref$X git-symbolic-ref$X \
123 $(SIMPLE_PROGRAMS)
124
125# Backward compatibility -- to be removed after 1.0
126PROGRAMS += git-ssh-pull$X git-ssh-push$X
127
128GIT_LIST_TWEAK =
129
130PYMODULES = \
131 gitMergeCommon.py
132
133ifdef WITH_OWN_SUBPROCESS_PY
134 PYMODULES += compat/subprocess.py
135endif
136
137ifdef WITH_SEND_EMAIL
138 SCRIPT_PERL += git-send-email.perl
139else
140 GIT_LIST_TWEAK += -e '/^send-email$$/d'
141endif
142
143LIB_FILE=libgit.a
144
145LIB_H = \
146 blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
147 diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
148 run-command.h strbuf.h tag.h tree.h
149
150DIFF_OBJS = \
151 diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
152 diffcore-pickaxe.o diffcore-rename.o
153
154LIB_OBJS = \
155 blob.o commit.o connect.o count-delta.o csum-file.o \
156 date.o diff-delta.o entry.o ident.o index.o \
157 object.o pack-check.o patch-delta.o path.o pkt-line.o \
158 quote.o read-cache.o refs.o run-command.o \
159 server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
160 tag.o tree.o usage.o $(DIFF_OBJS)
161
162LIBS = $(LIB_FILE)
163LIBS += -lz
164
165#
166# Platform specific tweaks
167#
168ifeq ($(shell uname -s),Darwin)
169 NEEDS_SSL_WITH_CRYPTO = YesPlease
170 NEEDS_LIBICONV = YesPlease
171endif
172ifeq ($(shell uname -s),SunOS)
173 NEEDS_SOCKET = YesPlease
174 NEEDS_NSL = YesPlease
175 SHELL_PATH = /bin/bash
176 NO_STRCASESTR = YesPlease
177 CURLDIR = /opt/sfw
178 INSTALL = ginstall
179 TAR = gtar
180 PLATFORM_DEFINES += -D__EXTENSIONS__
181endif
182ifeq ($(shell uname -o),Cygwin)
183 NO_STRCASESTR = YesPlease
184 NEEDS_LIBICONV = YesPlease
185 NO_IPV6 = YesPlease
186 X = .exe
187 PLATFORM_DEFINES += -DUSE_SYMLINK_HEAD=0
188endif
189ifneq (,$(findstring arm,$(shell uname -m)))
190 ARM_SHA1 = YesPlease
191endif
192ifeq ($(shell uname -s),OpenBSD)
193 NEEDS_LIBICONV = YesPlease
194 PLATFORM_DEFINES += -I/usr/local/include -L/usr/local/lib
195endif
196
197ifndef NO_CURL
198 ifdef CURLDIR
199 # This is still problematic -- gcc does not want -R.
200 CFLAGS += -I$(CURLDIR)/include
201 CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
202 else
203 CURL_LIBCURL = -lcurl
204 endif
205 PROGRAMS += git-http-fetch$X
206endif
207
208ifndef SHELL_PATH
209 SHELL_PATH = /bin/sh
210endif
211ifndef PERL_PATH
212 PERL_PATH = /usr/bin/perl
213endif
214ifndef PYTHON_PATH
215 PYTHON_PATH = /usr/bin/python
216endif
217
218ifndef NO_OPENSSL
219 LIB_OBJS += epoch.o
220 OPENSSL_LIBSSL = -lssl
221 ifdef OPENSSLDIR
222 # Again this may be problematic -- gcc does not always want -R.
223 CFLAGS += -I$(OPENSSLDIR)/include
224 OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
225 else
226 OPENSSL_LINK =
227 endif
228else
229 DEFINES += '-DNO_OPENSSL'
230 MOZILLA_SHA1 = 1
231 OPENSSL_LIBSSL =
232endif
233ifdef NEEDS_SSL_WITH_CRYPTO
234 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
235else
236 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
237endif
238ifdef NEEDS_LIBICONV
239 ifdef ICONVDIR
240 # Again this may be problematic -- gcc does not always want -R.
241 CFLAGS += -I$(ICONVDIR)/include
242 ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
243 else
244 ICONV_LINK =
245 endif
246 LIB_4_ICONV = $(ICONV_LINK) -liconv
247else
248 LIB_4_ICONV =
249endif
250ifdef NEEDS_SOCKET
251 LIBS += -lsocket
252 SIMPLE_LIB += -lsocket
253endif
254ifdef NEEDS_NSL
255 LIBS += -lnsl
256 SIMPLE_LIB += -lnsl
257endif
258ifdef NO_STRCASESTR
259 DEFINES += -Dstrcasestr=gitstrcasestr
260 LIB_OBJS += compat/strcasestr.o
261endif
262ifdef NO_IPV6
263 DEFINES += -DNO_IPV6 -Dsockaddr_storage=sockaddr_in
264endif
265
266ifdef PPC_SHA1
267 SHA1_HEADER = "ppc/sha1.h"
268 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
269else
270ifdef ARM_SHA1
271 SHA1_HEADER = "arm/sha1.h"
272 LIB_OBJS += arm/sha1.o arm/sha1_arm.o
273else
274ifdef MOZILLA_SHA1
275 SHA1_HEADER = "mozilla-sha1/sha1.h"
276 LIB_OBJS += mozilla-sha1/sha1.o
277else
278 SHA1_HEADER = <openssl/sha.h>
279 LIBS += $(LIB_4_CRYPTO)
280endif
281endif
282endif
283
284DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
285
286SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
287 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
288 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
289 gitk
290
291export TAR INSTALL DESTDIR SHELL_PATH
292### Build rules
293
294all: $(PROGRAMS) $(SCRIPTS)
295
296all:
297 $(MAKE) -C templates
298
299git: git.sh Makefile
300 rm -f $@+ $@
301 sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' \
302 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
303 -e 's/@@X@@/$(X)/g' \
304 $(GIT_LIST_TWEAK) <$@.sh >$@+
305 chmod +x $@+
306 mv $@+ $@
307
308$(filter-out git,$(patsubst %.sh,%,$(SCRIPT_SH))) : % : %.sh
309 rm -f $@
310 sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' \
311 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
312 $@.sh >$@
313 chmod +x $@
314
315$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
316 rm -f $@
317 sed -e '1s|#!.*perl|#!$(PERL_PATH)|' \
318 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
319 $@.perl >$@
320 chmod +x $@
321
322$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
323 rm -f $@
324 sed -e '1s|#!.*python|#!$(PYTHON_PATH)|' \
325 -e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR)|g' \
326 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
327 $@.py >$@
328 chmod +x $@
329
330%.o: %.c
331 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
332%.o: %.S
333 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
334
335git-%$X: %.o $(LIB_FILE)
336 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
337
338git-mailinfo$X : SIMPLE_LIB += $(LIB_4_ICONV)
339$(SIMPLE_PROGRAMS) : $(LIB_FILE)
340$(SIMPLE_PROGRAMS) : git-%$X : %.o
341 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIB_FILE) $(SIMPLE_LIB)
342
343git-http-fetch$X: fetch.o
344git-local-fetch$X: fetch.o
345git-ssh-fetch$X: rsh.o fetch.o
346git-ssh-upload$X: rsh.o
347git-ssh-pull$X: rsh.o fetch.o
348git-ssh-push$X: rsh.o
349
350git-http-fetch$X: LIBS += $(CURL_LIBCURL)
351git-rev-list$X: LIBS += $(OPENSSL_LIBSSL)
352
353init-db.o: init-db.c
354 $(CC) -c $(ALL_CFLAGS) \
355 -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
356
357$(LIB_OBJS): $(LIB_H)
358$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H)
359$(DIFF_OBJS): diffcore.h
360
361$(LIB_FILE): $(LIB_OBJS)
362 $(AR) rcs $@ $(LIB_OBJS)
363
364doc:
365 $(MAKE) -C Documentation all
366
367
368### Testing rules
369
370test: all
371 $(MAKE) -C t/ all
372
373test-date$X: test-date.c date.o
374 $(CC) $(ALL_CFLAGS) -o $@ test-date.c date.o
375
376test-delta$X: test-delta.c diff-delta.o patch-delta.o
377 $(CC) $(ALL_CFLAGS) -o $@ $^
378
379check:
380 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
381
382
383
384### Installation rules
385
386install: $(PROGRAMS) $(SCRIPTS)
387 $(INSTALL) -d -m755 $(DESTDIR)$(bindir)
388 $(INSTALL) $(PROGRAMS) $(SCRIPTS) $(DESTDIR)$(bindir)
389 $(INSTALL) git-revert $(DESTDIR)$(bindir)/git-cherry-pick
390 sh ./cmd-rename.sh $(DESTDIR)$(bindir)
391 $(MAKE) -C templates install
392 $(INSTALL) -d -m755 $(DESTDIR)$(GIT_PYTHON_DIR)
393 $(INSTALL) $(PYMODULES) $(DESTDIR)$(GIT_PYTHON_DIR)
394
395install-doc:
396 $(MAKE) -C Documentation install
397
398
399
400
401### Maintainer's dist rules
402
403git-core.spec: git-core.spec.in Makefile
404 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
405
406GIT_TARNAME=git-core-$(GIT_VERSION)
407dist: git-core.spec git-tar-tree
408 ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
409 @mkdir -p $(GIT_TARNAME)
410 @cp git-core.spec $(GIT_TARNAME)
411 $(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git-core.spec
412 @rm -rf $(GIT_TARNAME)
413 gzip -f -9 $(GIT_TARNAME).tar
414
415rpm: dist
416 $(RPMBUILD) -ta git-core-$(GIT_VERSION).tar.gz
417
418deb: dist
419 rm -rf $(GIT_TARNAME)
420 $(TAR) zxf $(GIT_TARNAME).tar.gz
421 dpkg-source -b $(GIT_TARNAME)
422 cd $(GIT_TARNAME) && fakeroot debian/rules binary
423
424### Cleaning rules
425
426clean:
427 rm -f *.o mozilla-sha1/*.o ppc/*.o compat/*.o $(PROGRAMS) $(LIB_FILE)
428 rm -f $(filter-out gitk,$(SCRIPTS))
429 rm -f git-core.spec *.pyc *.pyo
430 rm -rf $(GIT_TARNAME)
431 rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
432 rm -f git-core_$(GIT_VERSION)-*.deb git-core_$(GIT_VERSION)-*.dsc
433 rm -f git-tk_$(GIT_VERSION)-*.deb
434 $(MAKE) -C Documentation/ clean
435 $(MAKE) -C templates clean
436 $(MAKE) -C t/ clean