1# -DCOLLISION_CHECK if you believe that SHA1's
2# 1461501637330902918203684832716283019655932542976 hashes do not give you
3# enough guarantees about no collisions between objects ever hapenning.
4#
5# -DUSE_NSEC if you want git to care about sub-second file mtimes and ctimes.
6# -DUSE_STDEV if you want git to care about st_dev changing
7#
8# Note that you need some new glibc (at least >2.2.4) for this, and it will
9# BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely randomly
10# break unless your underlying filesystem supports those sub-second times
11# (my ext3 doesn't).
12GIT_VERSION=0.99
13
14COPTS=-O2
15CFLAGS=-g $(COPTS) -Wall
16
17prefix=$(HOME)
18bin=$(prefix)/bin
19# dest=
20
21CC=gcc
22AR=ar
23INSTALL=install
24
25#
26# sparse is architecture-neutral, which means that we need to tell it
27# explicitly what architecture to check for. Fix this up for yours..
28#
29SPARSE_FLAGS=-D__BIG_ENDIAN__ -D__powerpc__
30
31SCRIPTS=git git-apply-patch-script git-merge-one-file-script git-prune-script \
32 git-pull-script git-tag-script git-resolve-script git-whatchanged \
33 git-fetch-script git-status-script git-commit-script \
34 git-log-script git-shortlog git-cvsimport-script git-diff-script \
35 git-reset-script git-add-script git-checkout-script git-clone-script \
36 gitk git-cherry git-rebase-script git-relink-script git-repack-script \
37 git-format-patch-script git-sh-setup-script git-push-script
38
39PROG= git-update-cache git-diff-files git-init-db git-write-tree \
40 git-read-tree git-commit-tree git-cat-file git-fsck-cache \
41 git-checkout-cache git-diff-tree git-rev-tree git-ls-files \
42 git-check-files git-ls-tree git-merge-base git-merge-cache \
43 git-unpack-file git-export git-diff-cache git-convert-cache \
44 git-http-pull git-ssh-push git-ssh-pull git-rev-list git-mktag \
45 git-diff-helper git-tar-tree git-local-pull git-hash-object \
46 git-get-tar-commit-id git-apply git-stripspace \
47 git-diff-stages git-rev-parse git-patch-id git-pack-objects \
48 git-unpack-objects git-verify-pack git-receive-pack git-send-pack \
49 git-prune-packed git-fetch-pack git-upload-pack git-clone-pack \
50 git-show-index
51
52all: $(PROG)
53
54install: $(PROG) $(SCRIPTS)
55 $(INSTALL) -m755 -d $(dest)$(bin)
56 $(INSTALL) $(PROG) $(SCRIPTS) $(dest)$(bin)
57
58LIB_OBJS=read-cache.o sha1_file.o usage.o object.o commit.o tree.o blob.o \
59 tag.o date.o index.o diff-delta.o patch-delta.o entry.o path.o \
60 epoch.o refs.o csum-file.o pack-check.o pkt-line.o connect.o
61LIB_FILE=libgit.a
62LIB_H=cache.h object.h blob.h tree.h commit.h tag.h delta.h epoch.h csum-file.h \
63 pack.h pkt-line.h refs.h
64
65LIB_H += strbuf.h
66LIB_OBJS += strbuf.o
67
68LIB_H += quote.h
69LIB_OBJS += quote.o
70
71LIB_H += diff.h count-delta.h
72LIB_OBJS += diff.o diffcore-rename.o diffcore-pickaxe.o diffcore-pathspec.o \
73 count-delta.o diffcore-break.o diffcore-order.o
74
75LIB_OBJS += gitenv.o
76
77LIBS = $(LIB_FILE)
78LIBS += -lz
79
80ifdef MOZILLA_SHA1
81 SHA1_HEADER="mozilla-sha1/sha1.h"
82 LIB_OBJS += mozilla-sha1/sha1.o
83else
84ifdef PPC_SHA1
85 SHA1_HEADER="ppc/sha1.h"
86 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
87else
88 SHA1_HEADER=<openssl/sha.h>
89 LIBS += -lcrypto
90endif
91endif
92
93CFLAGS += '-DSHA1_HEADER=$(SHA1_HEADER)'
94
95$(LIB_FILE): $(LIB_OBJS)
96 $(AR) rcs $@ $(LIB_OBJS)
97
98check:
99 for i in *.c; do sparse $(CFLAGS) $(SPARSE_FLAGS) $$i; done
100
101test-date: test-date.c date.o
102 $(CC) $(CFLAGS) -o $@ test-date.c date.o
103
104test-delta: test-delta.c diff-delta.o patch-delta.o
105 $(CC) $(CFLAGS) -o $@ $^
106
107git-%: %.c $(LIB_FILE)
108 $(CC) $(CFLAGS) -o $@ $(filter %.c,$^) $(LIBS)
109
110git-update-cache: update-cache.c
111git-diff-files: diff-files.c
112git-init-db: init-db.c
113git-write-tree: write-tree.c
114git-read-tree: read-tree.c
115git-commit-tree: commit-tree.c
116git-cat-file: cat-file.c
117git-fsck-cache: fsck-cache.c
118git-checkout-cache: checkout-cache.c
119git-diff-tree: diff-tree.c
120git-rev-tree: rev-tree.c
121git-ls-files: ls-files.c
122git-check-files: check-files.c
123git-ls-tree: ls-tree.c
124git-merge-base: merge-base.c
125git-merge-cache: merge-cache.c
126git-unpack-file: unpack-file.c
127git-export: export.c
128git-diff-cache: diff-cache.c
129git-convert-cache: convert-cache.c
130git-http-pull: http-pull.c pull.c
131git-local-pull: local-pull.c pull.c
132git-ssh-push: rsh.c
133git-ssh-pull: rsh.c pull.c
134git-rev-list: rev-list.c
135git-mktag: mktag.c
136git-diff-helper: diff-helper.c
137git-tar-tree: tar-tree.c
138git-hash-object: hash-object.c
139git-stripspace: stripspace.c
140git-diff-stages: diff-stages.c
141git-rev-parse: rev-parse.c
142git-patch-id: patch-id.c
143git-pack-objects: pack-objects.c
144git-unpack-objects: unpack-objects.c
145git-verify-pack: verify-pack.c
146git-receive-pack: receive-pack.c
147git-send-pack: send-pack.c
148git-prune-packed: prune-packed.c
149git-fetch-pack: fetch-pack.c
150
151git-http-pull: LIBS += -lcurl
152git-rev-list: LIBS += -lssl
153
154# Library objects..
155blob.o: $(LIB_H)
156tree.o: $(LIB_H)
157commit.o: $(LIB_H)
158tag.o: $(LIB_H)
159object.o: $(LIB_H)
160read-cache.o: $(LIB_H)
161sha1_file.o: $(LIB_H)
162usage.o: $(LIB_H)
163strbuf.o: $(LIB_H)
164gitenv.o: $(LIB_H)
165entry.o: $(LIB_H)
166diff.o: $(LIB_H) diffcore.h
167diffcore-rename.o : $(LIB_H) diffcore.h
168diffcore-pathspec.o : $(LIB_H) diffcore.h
169diffcore-pickaxe.o : $(LIB_H) diffcore.h
170diffcore-break.o : $(LIB_H) diffcore.h
171diffcore-order.o : $(LIB_H) diffcore.h
172epoch.o: $(LIB_H)
173
174git.spec: git.spec.in
175 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
176
177GIT_TARNAME=git-$(GIT_VERSION)
178dist: git.spec
179 git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
180 @mkdir -p $(GIT_TARNAME)
181 @cp git.spec $(GIT_TARNAME)
182 tar rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git.spec
183 @rm -rf $(GIT_TARNAME)
184 gzip -9 $(GIT_TARNAME).tar
185
186rpm: dist
187 rpmbuild -ta git-$(GIT_VERSION).tar.gz
188
189test: all
190 $(MAKE) -C t/ all
191
192clean:
193 rm -f *.o mozilla-sha1/*.o ppc/*.o $(PROG) $(LIB_FILE)
194 $(MAKE) -C Documentation/ clean
195
196backup: clean
197 cd .. ; tar czvf dircache.tar.gz dir-cache