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