[PATCH] rsh.c env and quoting cleanup, take 2
[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#
5bdac8b3
PB
12# Define PPC_SHA1 environment variable when running make to make use of
13# a bundled SHA1 routine optimized for PowerPC.
597c9cc5
JH
14#
15# Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).
f0ebff0d 16#
597c9cc5 17# Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).
f0ebff0d
PM
18#
19# Define NEEDS_SOCKET if linking with libc is not enough (SunOS,
20# Patrick Mauritz).
21#
22# Define NO_GETDOMAINNAME if your library lack it (SunOS, Patrick Mauritz).
23#
5bdac8b3
PB
24# Define COLLISION_CHECK below if you believe that SHA1's
25# 1461501637330902918203684832716283019655932542976 hashes do not give you
26# sufficient guarantee that no collisions between objects will ever happen.
27
28# DEFINES += -DCOLLISION_CHECK
29
30# Define USE_NSEC below if you want git to care about sub-second file mtimes
31# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
32# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
33# randomly break unless your underlying filesystem supports those sub-second
34# times (my ext3 doesn't).
35
36# DEFINES += -DUSE_NSEC
37
38# Define USE_STDEV below if you want git to care about the underlying device
39# change being considered an inode change from the update-cache perspective.
40
41# DEFINES += -DUSE_STDEV
42
09661fdb 43GIT_VERSION = 0.99.6
a9db2974 44
b05701c5 45CFLAGS = -g -O2 -Wall
f0ebff0d 46ALL_CFLAGS = $(CFLAGS) $(PLATFORM_DEFINES) $(DEFINES)
29c2cce4 47
b05701c5
PR
48prefix = $(HOME)
49bindir = $(prefix)/bin
50template_dir = $(prefix)/share/git-core/templates/
720d150c 51GIT_PYTHON_DIR = $(prefix)/share/git-core/python
a682ef9f 52# DESTDIR=
5c2a7fbc 53
b05701c5
PR
54CC = gcc
55AR = ar
56INSTALL = install
57RPMBUILD = rpmbuild
e83c5163 58
44c9e859
LT
59# sparse is architecture-neutral, which means that we need to tell it
60# explicitly what architecture to check for. Fix this up for yours..
b05701c5 61SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
44c9e859 62
28818ffa
PB
63
64
65### --- END CONFIGURATION SECTION ---
66
215a7ad1
JH
67SCRIPT_SH = \
68 git-add.sh git-bisect.sh git-branch.sh git-checkout.sh \
69 git-cherry.sh git-clone.sh git-commit.sh \
70 git-count-objects.sh git-diff.sh git-fetch.sh \
71 git-format-patch.sh git-log.sh git-ls-remote.sh \
72 git-merge-one-file.sh git-octopus.sh git-parse-remote.sh \
73 git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
74 git-repack.sh git-request-pull.sh git-reset.sh \
75 git-resolve.sh git-revert.sh git-sh-setup.sh git-status.sh \
76 git-tag.sh git-verify-tag.sh git-whatchanged.sh git.sh \
91063bbc 77 git-applymbox.sh git-applypatch.sh \
2276aa6c 78 git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
f22cc3fc 79 git-merge-resolve.sh git-grep.sh
215a7ad1
JH
80
81SCRIPT_PERL = \
82 git-archimport.perl git-cvsimport.perl git-relink.perl \
03d98d39 83 git-rename.perl git-shortlog.perl
60036a41 84
720d150c 85SCRIPT_PYTHON = \
e4cf17ce 86 git-merge-recursive.py
720d150c 87
597c9cc5
JH
88# The ones that do not have to link with lcrypto nor lz.
89SIMPLE_PROGRAMS = \
90 git-get-tar-commit-id git-mailinfo git-mailsplit git-stripspace \
91 git-daemon git-var
92
93# ... and all the rest
215a7ad1 94PROGRAMS = \
0f56479d 95 git-apply git-cat-file \
215a7ad1
JH
96 git-checkout-index git-clone-pack git-commit-tree \
97 git-convert-objects git-diff-files \
98 git-diff-helper git-diff-index git-diff-stages \
99 git-diff-tree git-export git-fetch-pack git-fsck-objects \
100 git-hash-object git-init-db \
101 git-local-fetch git-ls-files git-ls-tree git-merge-base \
102 git-merge-index git-mktag git-pack-objects git-patch-id \
103 git-peek-remote git-prune-packed git-read-tree \
104 git-receive-pack git-rev-list git-rev-parse \
105 git-rev-tree git-send-pack git-show-branch \
0f56479d 106 git-show-index git-ssh-fetch \
215a7ad1
JH
107 git-ssh-upload git-tar-tree git-unpack-file \
108 git-unpack-objects git-update-index git-update-server-info \
109 git-upload-pack git-verify-pack git-write-tree \
597c9cc5 110 $(SIMPLE_PROGRAMS)
e83c5163 111
720d150c
JH
112PYMODULES = \
113 gitMergeCommon.py
114
90bc118f 115ifdef WITH_SEND_EMAIL
215a7ad1 116 SCRIPT_PERL += git-send-email.perl
90bc118f
JH
117endif
118
b2c0bd65 119ifndef NO_CURL
215a7ad1 120 PROGRAMS += git-http-fetch
b2c0bd65
JS
121endif
122
0a02ce72 123LIB_FILE=libgit.a
8f3f9b09 124
215a7ad1
JH
125LIB_H = \
126 blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
127 diff.h epoch.h object.h pack.h pkt-line.h quote.h refs.h \
0f56479d 128 run-command.h strbuf.h tag.h tree.h
b1bf95bb 129
215a7ad1
JH
130DIFF_OBJS = \
131 diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
132 diffcore-pickaxe.o diffcore-rename.o
d1df5743 133
215a7ad1
JH
134LIB_OBJS = \
135 blob.o commit.o connect.o count-delta.o csum-file.o \
a9ab586a 136 date.o diff-delta.o entry.o ident.o index.o \
215a7ad1 137 object.o pack-check.o patch-delta.o path.o pkt-line.o \
0f56479d 138 quote.o read-cache.o refs.o run-command.o \
215a7ad1
JH
139 server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
140 tag.o tree.o usage.o $(DIFF_OBJS)
d19938ab 141
cc1ad5c8
LT
142LIBS = $(LIB_FILE)
143LIBS += -lz
cef661fc 144
597c9cc5
JH
145ifeq ($(shell uname -s),Darwin)
146 NEEDS_SSL_WITH_CRYPTO = YesPlease
147 NEEDS_LIBICONV = YesPlease
148endif
f0ebff0d
PM
149ifeq ($(shell uname -s),SunOS)
150 NEEDS_SOCKET = YesPlease
151 PLATFORM_DEFINES += -DNO_GETDOMAINNAME=1
152endif
597c9cc5 153
bc6146d2
JH
154ifndef SHELL_PATH
155 SHELL_PATH = /bin/sh
156endif
157ifndef PERL_PATH
158 PERL_PATH = /usr/bin/perl
159endif
720d150c
JH
160ifndef PYTHON_PATH
161 PYTHON_PATH = /usr/bin/python
162endif
bc6146d2 163
dd53c7ab
PB
164ifndef NO_OPENSSL
165 LIB_OBJS += epoch.o
215a7ad1 166 OPENSSL_LIBSSL = -lssl
dd53c7ab 167else
b05701c5 168 DEFINES += '-DNO_OPENSSL'
215a7ad1
JH
169 MOZILLA_SHA1 = 1
170 OPENSSL_LIBSSL =
dd53c7ab 171endif
597c9cc5
JH
172ifdef NEEDS_SSL_WITH_CRYPTO
173 LIB_4_CRYPTO = -lcrypto -lssl
174else
175 LIB_4_CRYPTO = -lcrypto
176endif
177ifdef NEEDS_LIBICONV
178 LIB_4_ICONV = -liconv
179else
180 LIB_4_ICONV =
181endif
cef661fc 182ifdef MOZILLA_SHA1
215a7ad1 183 SHA1_HEADER = "mozilla-sha1/sha1.h"
3e386508 184 LIB_OBJS += mozilla-sha1/sha1.o
a6ef3518 185else
3e386508 186 ifdef PPC_SHA1
215a7ad1 187 SHA1_HEADER = "ppc/sha1.h"
3e386508
PB
188 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
189 else
215a7ad1 190 SHA1_HEADER = <openssl/sha.h>
597c9cc5 191 LIBS += $(LIB_4_CRYPTO)
3e386508 192 endif
bfb15365 193endif
f0ebff0d
PM
194ifdef NEEDS_SOCKET
195 LIBS += -lsocket
196 SIMPLE_LIB += -lsocket
197endif
cef661fc 198
b05701c5 199DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
cc1ad5c8 200
bc6146d2 201SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
720d150c
JH
202 $(patsubst %.perl,%,$(SCRIPT_PERL)) \
203 $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
204 gitk
44c9e859 205
28818ffa
PB
206### Build rules
207
bc6146d2 208all: $(PROGRAMS) $(SCRIPTS)
89967023 209
d3af621b
JH
210all:
211 $(MAKE) -C templates
b05701c5 212
bc6146d2 213git: git.sh Makefile
6a2e50f9 214 rm -f $@+ $@
bc6146d2 215 sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' <$@.sh >$@+
6a2e50f9
JH
216 chmod +x $@+
217 mv $@+ $@
218
bc6146d2
JH
219$(filter-out git,$(patsubst %.sh,%,$(SCRIPT_SH))) : % : %.sh
220 rm -f $@
221 sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' $@.sh >$@
222 chmod +x $@
223
224$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
225 rm -f $@
226 sed -e '1s|#!.*perl|#!$(PERL_PATH)|' $@.perl >$@
227 chmod +x $@
228
720d150c
JH
229$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
230 rm -f $@
231 sed -e '1s|#!.*python|#!$(PYTHON_PATH)|' \
232 -e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR)|g' \
233 $@.py >$@
234 chmod +x $@
235
b05701c5
PR
236%.o: %.c
237 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
238%.o: %.S
239 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
a310d434 240
623c8a14 241git-%: %.o $(LIB_FILE)
b05701c5 242 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
623c8a14 243
597c9cc5
JH
244git-mailinfo : SIMPLE_LIB += $(LIB_4_ICONV)
245$(SIMPLE_PROGRAMS) : $(LIB_FILE)
246$(SIMPLE_PROGRAMS) : git-% : %.o
247 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIB_FILE) $(SIMPLE_LIB)
248
215a7ad1
JH
249git-http-fetch: fetch.o
250git-local-fetch: fetch.o
251git-ssh-fetch: rsh.o fetch.o
252git-ssh-upload: rsh.o
a3df1801 253
215a7ad1 254git-http-fetch: LIBS += -lcurl
9e95049b 255git-rev-list: LIBS += $(OPENSSL_LIBSSL)
a3df1801 256
d3af621b 257init-db.o: init-db.c
b05701c5
PR
258 $(CC) -c $(ALL_CFLAGS) \
259 -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
d3af621b 260
e468305a 261$(LIB_OBJS): $(LIB_H)
215a7ad1 262$(patsubst git-%,%.o,$(PROGRAMS)): $(LIB_H)
e468305a 263$(DIFF_OBJS): diffcore.h
e83c5163 264
28818ffa
PB
265$(LIB_FILE): $(LIB_OBJS)
266 $(AR) rcs $@ $(LIB_OBJS)
267
268doc:
269 $(MAKE) -C Documentation all
270
271
28818ffa
PB
272### Testing rules
273
274test: all
275 $(MAKE) -C t/ all
276
277test-date: test-date.c date.o
b05701c5 278 $(CC) $(ALL_CFLAGS) -o $@ test-date.c date.o
28818ffa
PB
279
280test-delta: test-delta.c diff-delta.o patch-delta.o
b05701c5 281 $(CC) $(ALL_CFLAGS) -o $@ $^
28818ffa
PB
282
283check:
b05701c5 284 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
28818ffa
PB
285
286
287
288### Installation rules
289
215a7ad1 290install: $(PROGRAMS) $(SCRIPTS)
53764ee4 291 $(INSTALL) -d -m755 $(DESTDIR)$(bindir)
bc6146d2
JH
292 $(INSTALL) $(PROGRAMS) $(SCRIPTS) $(DESTDIR)$(bindir)
293 $(INSTALL) git-revert $(DESTDIR)$(bindir)/git-cherry-pick
215a7ad1 294 sh ./cmd-rename.sh $(DESTDIR)$(bindir)
8d5afef0 295 $(MAKE) -C templates install
53764ee4 296 $(INSTALL) -d -m755 $(DESTDIR)$(GIT_PYTHON_DIR)
720d150c 297 $(INSTALL) $(PYMODULES) $(DESTDIR)$(GIT_PYTHON_DIR)
28818ffa
PB
298
299install-doc:
300 $(MAKE) -C Documentation install
301
302
303
304
305### Maintainer's dist rules
306
78d9d414 307git-core.spec: git-core.spec.in Makefile
a9db2974
CW
308 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
309
f85639c3
LT
310GIT_TARNAME=git-core-$(GIT_VERSION)
311dist: git-core.spec git-tar-tree
b1de9de2 312 ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
a9db2974 313 @mkdir -p $(GIT_TARNAME)
f85639c3
LT
314 @cp git-core.spec $(GIT_TARNAME)
315 tar rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git-core.spec
a9db2974 316 @rm -rf $(GIT_TARNAME)
9dce3c06 317 gzip -f -9 $(GIT_TARNAME).tar
a9db2974
CW
318
319rpm: dist
d7b8a164 320 $(RPMBUILD) -ta git-core-$(GIT_VERSION).tar.gz
a9db2974 321
7a590132 322deb: dist
f29eaed1
JH
323 rm -rf $(GIT_TARNAME)
324 tar zxf $(GIT_TARNAME).tar.gz
5a571cdd 325 dpkg-source -b $(GIT_TARNAME)
f29eaed1 326 cd $(GIT_TARNAME) && fakeroot debian/rules binary
28818ffa
PB
327
328### Cleaning rules
87a81c83 329
e83c5163 330clean:
215a7ad1 331 rm -f *.o mozilla-sha1/*.o ppc/*.o $(PROGRAMS) $(LIB_FILE)
bc6146d2
JH
332 rm -f $(filter-out gitk,$(SCRIPTS))
333 rm -f git-core.spec
f29eaed1 334 rm -rf $(GIT_TARNAME)
5a571cdd
JH
335 rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
336 rm -f git-core_$(GIT_VERSION)-*.deb git-core_$(GIT_VERSION)-*.dsc
337 rm -f git-tk_$(GIT_VERSION)-*.deb
ca67f002 338 $(MAKE) -C Documentation/ clean
8d5afef0 339 $(MAKE) -C templates/ clean
4b7581f0 340 $(MAKE) -C t/ clean