3ae3d3b4603ca8f1b43d38f67205bdfd2268a20d
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.
36 # DEFINES += -DCOLLISION_CHECK
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).
44 # DEFINES += -DUSE_NSEC
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.
49 # DEFINES += -DUSE_STDEV
51 GIT_VERSION = 0.99.8c
53 CFLAGS = -g -O2 -Wall
54 ALL_CFLAGS = $(CFLAGS) $(PLATFORM_DEFINES) $(DEFINES)
56 prefix = $(HOME)
57 bindir = $(prefix)/bin
58 template_dir = $(prefix)/share/git-core/templates/
59 GIT_PYTHON_DIR = $(prefix)/share/git-core/python
60 # DESTDIR=
62 CC = gcc
63 AR = ar
64 TAR = tar
65 INSTALL = install
66 RPMBUILD = rpmbuild
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..
70 SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
74 ### --- END CONFIGURATION SECTION ---
76 SCRIPT_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
90 SCRIPT_PERL = \
91 git-archimport.perl git-cvsimport.perl git-relink.perl \
92 git-rename.perl git-shortlog.perl git-fmt-merge-msg.perl
94 SCRIPT_PYTHON = \
95 git-merge-recursive.py
97 # The ones that do not have to link with lcrypto nor lz.
98 SIMPLE_PROGRAMS = \
99 git-get-tar-commit-id git-mailinfo git-mailsplit git-stripspace \
100 git-daemon git-var
102 # ... and all the rest
103 PROGRAMS = \
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 git-update-ref git-symbolic-ref git-check-ref-format \
120 $(SIMPLE_PROGRAMS)
122 # Backward compatibility -- to be removed after 1.0
123 PROGRAMS += git-ssh-pull git-ssh-push
125 GIT_LIST_TWEAK =
127 PYMODULES = \
128 gitMergeCommon.py
130 ifdef WITH_OWN_SUBPROCESS_PY
131 PYMODULES += compat/subprocess.py
132 endif
134 ifdef WITH_SEND_EMAIL
135 SCRIPT_PERL += git-send-email.perl
136 else
137 GIT_LIST_TWEAK += -e '/^send-email$$/d'
138 endif
140 LIB_FILE=libgit.a
142 LIB_H = \
143 blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
144 diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
145 run-command.h strbuf.h tag.h tree.h
147 DIFF_OBJS = \
148 diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
149 diffcore-pickaxe.o diffcore-rename.o
151 LIB_OBJS = \
152 blob.o commit.o connect.o count-delta.o csum-file.o \
153 date.o diff-delta.o entry.o ident.o index.o \
154 object.o pack-check.o patch-delta.o path.o pkt-line.o \
155 quote.o read-cache.o refs.o run-command.o \
156 server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
157 tag.o tree.o usage.o $(DIFF_OBJS)
159 LIBS = $(LIB_FILE)
160 LIBS += -lz
162 #
163 # Platform specific tweaks
164 #
165 ifeq ($(shell uname -s),Darwin)
166 NEEDS_SSL_WITH_CRYPTO = YesPlease
167 NEEDS_LIBICONV = YesPlease
168 endif
169 ifeq ($(shell uname -s),SunOS)
170 NEEDS_SOCKET = YesPlease
171 NEEDS_NSL = YesPlease
172 SHELL_PATH = /bin/bash
173 NO_STRCASESTR = YesPlease
174 CURLDIR = /opt/sfw
175 INSTALL = ginstall
176 TAR = gtar
177 PLATFORM_DEFINES += -D__EXTENSIONS__
178 endif
179 ifneq (,$(findstring arm,$(shell uname -m)))
180 ARM_SHA1 = YesPlease
181 endif
182 ifeq ($(shell uname -s),OpenBSD)
183 NO_STRCASESTR = YesPlease
184 NEEDS_LIBICONV = YesPlease
185 PLATFORM_DEFINES += -I/usr/local/include -L/usr/local/lib
186 endif
188 ifndef NO_CURL
189 ifdef CURLDIR
190 # This is still problematic -- gcc does not want -R.
191 CFLAGS += -I$(CURLDIR)/include
192 CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
193 else
194 CURL_LIBCURL = -lcurl
195 endif
196 PROGRAMS += git-http-fetch
197 endif
199 ifndef SHELL_PATH
200 SHELL_PATH = /bin/sh
201 endif
202 ifndef PERL_PATH
203 PERL_PATH = /usr/bin/perl
204 endif
205 ifndef PYTHON_PATH
206 PYTHON_PATH = /usr/bin/python
207 endif
209 ifndef NO_OPENSSL
210 LIB_OBJS += epoch.o
211 OPENSSL_LIBSSL = -lssl
212 ifdef OPENSSLDIR
213 # Again this may be problematic -- gcc does not always want -R.
214 CFLAGS += -I$(OPENSSLDIR)/include
215 OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
216 else
217 OPENSSL_LINK =
218 endif
219 else
220 DEFINES += '-DNO_OPENSSL'
221 MOZILLA_SHA1 = 1
222 OPENSSL_LIBSSL =
223 endif
224 ifdef NEEDS_SSL_WITH_CRYPTO
225 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
226 else
227 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
228 endif
229 ifdef NEEDS_LIBICONV
230 ifdef ICONVDIR
231 # Again this may be problematic -- gcc does not always want -R.
232 CFLAGS += -I$(ICONVDIR)/include
233 ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
234 else
235 ICONV_LINK =
236 endif
237 LIB_4_ICONV = $(ICONV_LINK) -liconv
238 else
239 LIB_4_ICONV =
240 endif
241 ifdef NEEDS_SOCKET
242 LIBS += -lsocket
243 SIMPLE_LIB += -lsocket
244 endif
245 ifdef NEEDS_NSL
246 LIBS += -lnsl
247 SIMPLE_LIB += -lnsl
248 endif
249 ifdef NO_STRCASESTR
250 DEFINES += -Dstrcasestr=gitstrcasestr -DNO_STRCASESTR=1
251 LIB_OBJS += compat/strcasestr.o
252 endif
254 ifdef PPC_SHA1
255 SHA1_HEADER = "ppc/sha1.h"
256 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
257 else
258 ifdef ARM_SHA1
259 SHA1_HEADER = "arm/sha1.h"
260 LIB_OBJS += arm/sha1.o arm/sha1_arm.o
261 else
262 ifdef MOZILLA_SHA1
263 SHA1_HEADER = "mozilla-sha1/sha1.h"
264 LIB_OBJS += mozilla-sha1/sha1.o
265 else
266 SHA1_HEADER = <openssl/sha.h>
267 LIBS += $(LIB_4_CRYPTO)
268 endif
269 endif
270 endif
272 DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
274 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
275 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
276 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
277 gitk
279 export TAR INSTALL DESTDIR SHELL_PATH
280 ### Build rules
282 all: $(PROGRAMS) $(SCRIPTS)
284 all:
285 $(MAKE) -C templates
287 git: git.sh Makefile
288 rm -f $@+ $@
289 sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' \
290 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
291 $(GIT_LIST_TWEAK) <$@.sh >$@+
292 chmod +x $@+
293 mv $@+ $@
295 $(filter-out git,$(patsubst %.sh,%,$(SCRIPT_SH))) : % : %.sh
296 rm -f $@
297 sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' $@.sh >$@
298 chmod +x $@
300 $(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
301 rm -f $@
302 sed -e '1s|#!.*perl|#!$(PERL_PATH)|' $@.perl >$@
303 chmod +x $@
305 $(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
306 rm -f $@
307 sed -e '1s|#!.*python|#!$(PYTHON_PATH)|' \
308 -e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR)|g' \
309 $@.py >$@
310 chmod +x $@
312 %.o: %.c
313 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
314 %.o: %.S
315 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
317 git-%: %.o $(LIB_FILE)
318 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
320 git-mailinfo : SIMPLE_LIB += $(LIB_4_ICONV)
321 $(SIMPLE_PROGRAMS) : $(LIB_FILE)
322 $(SIMPLE_PROGRAMS) : git-% : %.o
323 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIB_FILE) $(SIMPLE_LIB)
325 git-http-fetch: fetch.o
326 git-local-fetch: fetch.o
327 git-ssh-fetch: rsh.o fetch.o
328 git-ssh-upload: rsh.o
329 git-ssh-pull: rsh.o fetch.o
330 git-ssh-push: rsh.o
332 git-http-fetch: LIBS += $(CURL_LIBCURL)
333 git-rev-list: LIBS += $(OPENSSL_LIBSSL)
335 init-db.o: init-db.c
336 $(CC) -c $(ALL_CFLAGS) \
337 -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
339 $(LIB_OBJS): $(LIB_H)
340 $(patsubst git-%,%.o,$(PROGRAMS)): $(LIB_H)
341 $(DIFF_OBJS): diffcore.h
343 $(LIB_FILE): $(LIB_OBJS)
344 $(AR) rcs $@ $(LIB_OBJS)
346 doc:
347 $(MAKE) -C Documentation all
350 ### Testing rules
352 test: all
353 $(MAKE) -C t/ all
355 test-date: test-date.c date.o
356 $(CC) $(ALL_CFLAGS) -o $@ test-date.c date.o
358 test-delta: test-delta.c diff-delta.o patch-delta.o
359 $(CC) $(ALL_CFLAGS) -o $@ $^
361 check:
362 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
366 ### Installation rules
368 install: $(PROGRAMS) $(SCRIPTS)
369 $(INSTALL) -d -m755 $(DESTDIR)$(bindir)
370 $(INSTALL) $(PROGRAMS) $(SCRIPTS) $(DESTDIR)$(bindir)
371 $(INSTALL) git-revert $(DESTDIR)$(bindir)/git-cherry-pick
372 sh ./cmd-rename.sh $(DESTDIR)$(bindir)
373 $(MAKE) -C templates install
374 $(INSTALL) -d -m755 $(DESTDIR)$(GIT_PYTHON_DIR)
375 $(INSTALL) $(PYMODULES) $(DESTDIR)$(GIT_PYTHON_DIR)
377 install-doc:
378 $(MAKE) -C Documentation install
383 ### Maintainer's dist rules
385 git-core.spec: git-core.spec.in Makefile
386 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
388 GIT_TARNAME=git-core-$(GIT_VERSION)
389 dist: git-core.spec git-tar-tree
390 ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
391 @mkdir -p $(GIT_TARNAME)
392 @cp git-core.spec $(GIT_TARNAME)
393 $(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git-core.spec
394 @rm -rf $(GIT_TARNAME)
395 gzip -f -9 $(GIT_TARNAME).tar
397 rpm: dist
398 $(RPMBUILD) -ta git-core-$(GIT_VERSION).tar.gz
400 deb: dist
401 rm -rf $(GIT_TARNAME)
402 $(TAR) zxf $(GIT_TARNAME).tar.gz
403 dpkg-source -b $(GIT_TARNAME)
404 cd $(GIT_TARNAME) && fakeroot debian/rules binary
406 ### Cleaning rules
408 clean:
409 rm -f *.o mozilla-sha1/*.o ppc/*.o compat/*.o $(PROGRAMS) $(LIB_FILE)
410 rm -f $(filter-out gitk,$(SCRIPTS))
411 rm -f git-core.spec *.pyc *.pyo
412 rm -rf $(GIT_TARNAME)
413 rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
414 rm -f git-core_$(GIT_VERSION)-*.deb git-core_$(GIT_VERSION)-*.dsc
415 rm -f git-tk_$(GIT_VERSION)-*.deb
416 $(MAKE) -C Documentation/ clean
417 $(MAKE) -C templates clean
418 $(MAKE) -C t/ clean