OpenBSD needs the strcasestr replacement.
[git/git.git] / Makefile
CommitLineData
5bdac8b3
PB
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.
bdd4da59 5#
5bdac8b3
PB
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.
2cb45e95 8#
b2c0bd65
JS
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#
6d9bbc50
PM
12# Define CURLDIR=/foo/bar if your curl header and library files are in
13# /foo/bar/include and /foo/bar/lib directories.
14#
ef34af24
LT
15# Define NO_STRCASESTR if you don't have strcasestr.
16#
5bdac8b3
PB
17# Define PPC_SHA1 environment variable when running make to make use of
18# a bundled SHA1 routine optimized for PowerPC.
597c9cc5 19#
7c6ef2f2
NP
20# Define ARM_SHA1 environment variable when running make to make use of
21# a bundled SHA1 routine optimized for ARM.
22#
597c9cc5 23# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
f0ebff0d 24#
597c9cc5 25# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
f0ebff0d
PM
26#
27# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
28# Patrick Mauritz).
29#
343d35c9
JH
30# Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
31#
5bdac8b3
PB
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.
35
36# DEFINES += -DCOLLISION_CHECK
37
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).
43
44# DEFINES += -DUSE_NSEC
45
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.
48
49# DEFINES += -DUSE_STDEV
50
91dd674e 51GIT_VERSION = 0.99.8
a9db2974 52
b05701c5 53CFLAGS = -g -O2 -Wall
f0ebff0d 54ALL_CFLAGS = $(CFLAGS) $(PLATFORM_DEFINES) $(DEFINES)
29c2cce4 55
b05701c5
PR
56prefix = $(HOME)
57bindir = $(prefix)/bin
58template_dir = $(prefix)/share/git-core/templates/
720d150c 59GIT_PYTHON_DIR = $(prefix)/share/git-core/python
a682ef9f 60# DESTDIR=
5c2a7fbc 61
b05701c5
PR
62CC = gcc
63AR = ar
229a7ed7 64TAR = tar
b05701c5
PR
65INSTALL = install
66RPMBUILD = rpmbuild
e83c5163 67
44c9e859
LT
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..
b05701c5 70SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
44c9e859 71
28818ffa
PB
72
73
74### --- END CONFIGURATION SECTION ---
75
215a7ad1
JH
76SCRIPT_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 \
91063bbc 86 git-applymbox.sh git-applypatch.sh \
2276aa6c 87 git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
f22cc3fc 88 git-merge-resolve.sh git-grep.sh
215a7ad1
JH
89
90SCRIPT_PERL = \
91 git-archimport.perl git-cvsimport.perl git-relink.perl \
c8b48ba4 92 git-rename.perl git-shortlog.perl git-fmt-merge-msg.perl
60036a41 93
720d150c 94SCRIPT_PYTHON = \
e4cf17ce 95 git-merge-recursive.py
720d150c 96
597c9cc5
JH
97# The ones that do not have to link with lcrypto nor lz.
98SIMPLE_PROGRAMS = \
99 git-get-tar-commit-id git-mailinfo git-mailsplit git-stripspace \
100 git-daemon git-var
101
102# ... and all the rest
215a7ad1 103PROGRAMS = \
0f56479d 104 git-apply git-cat-file \
215a7ad1
JH
105 git-checkout-index git-clone-pack git-commit-tree \
106 git-convert-objects git-diff-files \
5cfcd07c 107 git-diff-index git-diff-stages \
0fe51391 108 git-diff-tree git-fetch-pack git-fsck-objects \
215a7ad1
JH
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 \
9dcc829f 114 git-send-pack git-show-branch \
0f56479d 115 git-show-index git-ssh-fetch \
215a7ad1
JH
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 \
8098a178 119 git-update-ref git-symbolic-ref \
597c9cc5 120 $(SIMPLE_PROGRAMS)
e83c5163 121
894a8a8b 122# Backward compatibility -- to be removed after 1.0
f71a69ab
JH
123PROGRAMS += git-ssh-pull git-ssh-push
124
0842acff
JH
125GIT_LIST_TWEAK =
126
720d150c
JH
127PYMODULES = \
128 gitMergeCommon.py
129
343d35c9
JH
130ifdef WITH_OWN_SUBPROCESS_PY
131 PYMODULES += compat/subprocess.py
132endif
133
90bc118f 134ifdef WITH_SEND_EMAIL
215a7ad1 135 SCRIPT_PERL += git-send-email.perl
0842acff
JH
136else
137 GIT_LIST_TWEAK += -e '/^send-email$$/d'
90bc118f
JH
138endif
139
0a02ce72 140LIB_FILE=libgit.a
8f3f9b09 141
215a7ad1
JH
142LIB_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 \
0f56479d 145 run-command.h strbuf.h tag.h tree.h
b1bf95bb 146
215a7ad1
JH
147DIFF_OBJS = \
148 diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
149 diffcore-pickaxe.o diffcore-rename.o
d1df5743 150
215a7ad1
JH
151LIB_OBJS = \
152 blob.o commit.o connect.o count-delta.o csum-file.o \
a9ab586a 153 date.o diff-delta.o entry.o ident.o index.o \
215a7ad1 154 object.o pack-check.o patch-delta.o path.o pkt-line.o \
0f56479d 155 quote.o read-cache.o refs.o run-command.o \
215a7ad1
JH
156 server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
157 tag.o tree.o usage.o $(DIFF_OBJS)
d19938ab 158
cc1ad5c8
LT
159LIBS = $(LIB_FILE)
160LIBS += -lz
cef661fc 161
229a7ed7
JH
162#
163# Platform specific tweaks
164#
597c9cc5
JH
165ifeq ($(shell uname -s),Darwin)
166 NEEDS_SSL_WITH_CRYPTO = YesPlease
167 NEEDS_LIBICONV = YesPlease
168endif
f0ebff0d
PM
169ifeq ($(shell uname -s),SunOS)
170 NEEDS_SOCKET = YesPlease
5a90d4ac 171 NEEDS_NSL = YesPlease
229a7ed7
JH
172 SHELL_PATH = /bin/bash
173 NO_STRCASESTR = YesPlease
174 CURLDIR = /opt/sfw
175 INSTALL = ginstall
176 TAR = gtar
5a90d4ac 177 PLATFORM_DEFINES += -D__EXTENSIONS__
f0ebff0d 178endif
7c6ef2f2
NP
179ifneq (,$(findstring arm,$(shell uname -m)))
180 ARM_SHA1 = YesPlease
181endif
18c5a525 182ifeq ($(shell uname -s),OpenBSD)
5fb41e8a 183 NO_STRCASESTR = YesPlease
18c5a525
HB
184 NEEDS_LIBICONV = YesPlease
185 PLATFORM_DEFINES += -I/usr/local/include -L/usr/local/lib
186endif
597c9cc5 187
229a7ed7
JH
188ifndef 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
197endif
198
bc6146d2
JH
199ifndef SHELL_PATH
200 SHELL_PATH = /bin/sh
201endif
202ifndef PERL_PATH
203 PERL_PATH = /usr/bin/perl
204endif
720d150c
JH
205ifndef PYTHON_PATH
206 PYTHON_PATH = /usr/bin/python
207endif
bc6146d2 208
dd53c7ab
PB
209ifndef NO_OPENSSL
210 LIB_OBJS += epoch.o
215a7ad1 211 OPENSSL_LIBSSL = -lssl
455a7f32
JH
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
dd53c7ab 219else
b05701c5 220 DEFINES += '-DNO_OPENSSL'
215a7ad1
JH
221 MOZILLA_SHA1 = 1
222 OPENSSL_LIBSSL =
dd53c7ab 223endif
597c9cc5 224ifdef NEEDS_SSL_WITH_CRYPTO
455a7f32 225 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto -lssl
597c9cc5 226else
455a7f32 227 LIB_4_CRYPTO = $(OPENSSL_LINK) -lcrypto
597c9cc5
JH
228endif
229ifdef NEEDS_LIBICONV
455a7f32
JH
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
597c9cc5
JH
238else
239 LIB_4_ICONV =
240endif
f0ebff0d
PM
241ifdef NEEDS_SOCKET
242 LIBS += -lsocket
243 SIMPLE_LIB += -lsocket
244endif
5a90d4ac
JH
245ifdef NEEDS_NSL
246 LIBS += -lnsl
247 SIMPLE_LIB += -lnsl
248endif
ef34af24 249ifdef NO_STRCASESTR
e1e9c254 250 DEFINES += -Dstrcasestr=gitstrcasestr -DNO_STRCASESTR=1
ef34af24
LT
251 LIB_OBJS += compat/strcasestr.o
252endif
cef661fc 253
7c6ef2f2
NP
254ifdef PPC_SHA1
255 SHA1_HEADER = "ppc/sha1.h"
256 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
257else
258ifdef ARM_SHA1
259 SHA1_HEADER = "arm/sha1.h"
260 LIB_OBJS += arm/sha1.o arm/sha1_arm.o
261else
262ifdef MOZILLA_SHA1
263 SHA1_HEADER = "mozilla-sha1/sha1.h"
264 LIB_OBJS += mozilla-sha1/sha1.o
265else
266 SHA1_HEADER = <openssl/sha.h>
267 LIBS += $(LIB_4_CRYPTO)
268endif
269endif
270endif
271
b05701c5 272DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
cc1ad5c8 273
bc6146d2 274SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
720d150c
JH
275 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
276 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
277 gitk
44c9e859 278
edde7a8b 279export TAR INSTALL DESTDIR SHELL_PATH
28818ffa
PB
280### Build rules
281
bc6146d2 282all: $(PROGRAMS) $(SCRIPTS)
89967023 283
d3af621b
JH
284all:
285 $(MAKE) -C templates
b05701c5 286
bc6146d2 287git: git.sh Makefile
6a2e50f9 288 rm -f $@+ $@
229a7ed7 289 sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' \
0842acff
JH
290 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
291 $(GIT_LIST_TWEAK) <$@.sh >$@+
6a2e50f9
JH
292 chmod +x $@+
293 mv $@+ $@
294
bc6146d2
JH
295$(filter-out git,$(patsubst %.sh,%,$(SCRIPT_SH))) : % : %.sh
296 rm -f $@
297 sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' $@.sh >$@
298 chmod +x $@
299
300$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
301 rm -f $@
302 sed -e '1s|#!.*perl|#!$(PERL_PATH)|' $@.perl >$@
303 chmod +x $@
304
720d150c
JH
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 $@
311
b05701c5
PR
312%.o: %.c
313 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
314%.o: %.S
315 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
a310d434 316
623c8a14 317git-%: %.o $(LIB_FILE)
b05701c5 318 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
623c8a14 319
597c9cc5
JH
320git-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)
324
215a7ad1
JH
325git-http-fetch: fetch.o
326git-local-fetch: fetch.o
327git-ssh-fetch: rsh.o fetch.o
328git-ssh-upload: rsh.o
f71a69ab
JH
329git-ssh-pull: rsh.o fetch.o
330git-ssh-push: rsh.o
a3df1801 331
6d9bbc50 332git-http-fetch: LIBS += $(CURL_LIBCURL)
9e95049b 333git-rev-list: LIBS += $(OPENSSL_LIBSSL)
a3df1801 334
d3af621b 335init-db.o: init-db.c
b05701c5
PR
336 $(CC) -c $(ALL_CFLAGS) \
337 -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
d3af621b 338
e468305a 339$(LIB_OBJS): $(LIB_H)
215a7ad1 340$(patsubst git-%,%.o,$(PROGRAMS)): $(LIB_H)
e468305a 341$(DIFF_OBJS): diffcore.h
e83c5163 342
28818ffa
PB
343$(LIB_FILE): $(LIB_OBJS)
344 $(AR) rcs $@ $(LIB_OBJS)
345
346doc:
347 $(MAKE) -C Documentation all
348
349
28818ffa
PB
350### Testing rules
351
352test: all
353 $(MAKE) -C t/ all
354
355test-date: test-date.c date.o
b05701c5 356 $(CC) $(ALL_CFLAGS) -o $@ test-date.c date.o
28818ffa
PB
357
358test-delta: test-delta.c diff-delta.o patch-delta.o
b05701c5 359 $(CC) $(ALL_CFLAGS) -o $@ $^
28818ffa
PB
360
361check:
b05701c5 362 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
28818ffa
PB
363
364
365
366### Installation rules
367
215a7ad1 368install: $(PROGRAMS) $(SCRIPTS)
53764ee4 369 $(INSTALL) -d -m755 $(DESTDIR)$(bindir)
bc6146d2
JH
370 $(INSTALL) $(PROGRAMS) $(SCRIPTS) $(DESTDIR)$(bindir)
371 $(INSTALL) git-revert $(DESTDIR)$(bindir)/git-cherry-pick
894a8a8b 372 sh ./cmd-rename.sh $(DESTDIR)$(bindir)
8d5afef0 373 $(MAKE) -C templates install
53764ee4 374 $(INSTALL) -d -m755 $(DESTDIR)$(GIT_PYTHON_DIR)
720d150c 375 $(INSTALL) $(PYMODULES) $(DESTDIR)$(GIT_PYTHON_DIR)
28818ffa
PB
376
377install-doc:
378 $(MAKE) -C Documentation install
379
380
381
382
383### Maintainer's dist rules
384
78d9d414 385git-core.spec: git-core.spec.in Makefile
a9db2974
CW
386 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
387
f85639c3
LT
388GIT_TARNAME=git-core-$(GIT_VERSION)
389dist: git-core.spec git-tar-tree
b1de9de2 390 ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
a9db2974 391 @mkdir -p $(GIT_TARNAME)
f85639c3 392 @cp git-core.spec $(GIT_TARNAME)
229a7ed7 393 $(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git-core.spec
a9db2974 394 @rm -rf $(GIT_TARNAME)
9dce3c06 395 gzip -f -9 $(GIT_TARNAME).tar
a9db2974
CW
396
397rpm: dist
d7b8a164 398 $(RPMBUILD) -ta git-core-$(GIT_VERSION).tar.gz
a9db2974 399
7a590132 400deb: dist
f29eaed1 401 rm -rf $(GIT_TARNAME)
229a7ed7 402 $(TAR) zxf $(GIT_TARNAME).tar.gz
5a571cdd 403 dpkg-source -b $(GIT_TARNAME)
f29eaed1 404 cd $(GIT_TARNAME) && fakeroot debian/rules binary
28818ffa
PB
405
406### Cleaning rules
87a81c83 407
e83c5163 408clean:
a5579767 409 rm -f *.o mozilla-sha1/*.o ppc/*.o compat/*.o $(PROGRAMS) $(LIB_FILE)
bc6146d2 410 rm -f $(filter-out gitk,$(SCRIPTS))
a5579767 411 rm -f git-core.spec *.pyc *.pyo
f29eaed1 412 rm -rf $(GIT_TARNAME)
5a571cdd
JH
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
ca67f002 416 $(MAKE) -C Documentation/ clean
229a7ed7 417 $(MAKE) -C templates clean
4b7581f0 418 $(MAKE) -C t/ clean