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