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