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