Make CFLAGS overridable from make command line.
[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.
14
15
16# Define COLLISION_CHECK below if you believe that SHA1's
17# 1461501637330902918203684832716283019655932542976 hashes do not give you
18# sufficient guarantee that no collisions between objects will ever happen.
19
20# DEFINES += -DCOLLISION_CHECK
21
22# Define USE_NSEC below if you want git to care about sub-second file mtimes
23# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
24# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
25# randomly break unless your underlying filesystem supports those sub-second
26# times (my ext3 doesn't).
27
28# DEFINES += -DUSE_NSEC
29
30# Define USE_STDEV below if you want git to care about the underlying device
31# change being considered an inode change from the update-cache perspective.
32
33# DEFINES += -DUSE_STDEV
34
b05701c5 35GIT_VERSION = 0.99.4
a9db2974 36
b05701c5
PR
37CFLAGS = -g -O2 -Wall
38ALL_CFLAGS = $(CFLAGS) $(DEFINES)
29c2cce4 39
b05701c5
PR
40prefix = $(HOME)
41bindir = $(prefix)/bin
42template_dir = $(prefix)/share/git-core/templates/
29c2cce4 43# dest=
5c2a7fbc 44
b05701c5
PR
45CC = gcc
46AR = ar
47INSTALL = install
48RPMBUILD = rpmbuild
e83c5163 49
44c9e859
LT
50# sparse is architecture-neutral, which means that we need to tell it
51# explicitly what architecture to check for. Fix this up for yours..
b05701c5 52SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
44c9e859 53
28818ffa
PB
54
55
56### --- END CONFIGURATION SECTION ---
57
58
59
e764b8e8 60SCRIPTS=git git-apply-patch-script git-merge-one-file-script git-prune-script \
e002a16b 61 git-pull-script git-tag-script git-resolve-script git-whatchanged \
c4584ae3 62 git-fetch-script git-status-script git-commit-script \
40d8cfe4 63 git-log-script git-shortlog git-cvsimport-script git-diff-script \
3f571e0b 64 git-reset-script git-add-script git-checkout-script git-clone-script \
0acfc972 65 gitk git-cherry git-rebase-script git-relink-script git-repack-script \
37f1a519 66 git-format-patch-script git-sh-setup-script git-push-script \
0fec0822 67 git-branch-script git-parse-remote git-verify-tag-script \
ab421d2c 68 git-ls-remote-script git-clone-dumb-http git-rename-script \
0f2b4c46 69 git-request-pull-script git-bisect-script
bdd4da59 70
60036a41 71SCRIPTS += git-count-objects-script
93b5fcdd 72# SCRIPTS += git-send-email-script
045f82cb 73SCRIPTS += git-revert-script
60036a41 74
a3df1801
LT
75PROG= git-update-cache git-diff-files git-init-db git-write-tree \
76 git-read-tree git-commit-tree git-cat-file git-fsck-cache \
9b23b4bc 77 git-checkout-cache git-diff-tree git-rev-tree git-ls-files \
20f66331 78 git-ls-tree git-merge-base git-merge-cache \
a3df1801 79 git-unpack-file git-export git-diff-cache git-convert-cache \
b2c0bd65 80 git-ssh-push git-ssh-pull git-rev-list git-mktag \
7672db20 81 git-diff-helper git-tar-tree git-local-pull git-hash-object \
c4584ae3 82 git-get-tar-commit-id git-apply git-stripspace \
def88e9a
LT
83 git-diff-stages git-rev-parse git-patch-id git-pack-objects \
84 git-unpack-objects git-verify-pack git-receive-pack git-send-pack \
0271611e 85 git-prune-packed git-fetch-pack git-upload-pack git-clone-pack \
8f3f9b09 86 git-show-index git-daemon git-var git-peek-remote \
0f2b4c46 87 git-update-server-info git-show-rev-cache git-build-rev-cache
e83c5163 88
b2c0bd65
JS
89ifndef NO_CURL
90PROG+= git-http-pull
91endif
92
0a02ce72 93LIB_FILE=libgit.a
f3a3214e 94LIB_H=cache.h object.h blob.h tree.h commit.h tag.h delta.h epoch.h csum-file.h \
44c9e859 95 pack.h pkt-line.h refs.h
28818ffa
PB
96LIB_OBJS=read-cache.o sha1_file.o usage.o object.o commit.o tree.o blob.o \
97 tag.o date.o index.o diff-delta.o patch-delta.o entry.o path.o \
9938af6a
JH
98 refs.o csum-file.o pack-check.o pkt-line.o connect.o ident.o \
99 sha1_name.o
0a02ce72 100
8f3f9b09
JH
101LIB_H += rev-cache.h
102LIB_OBJS += rev-cache.o
103
b1bf95bb
JW
104LIB_H += run-command.h
105LIB_OBJS += run-command.o
106
d1df5743
JH
107LIB_H += strbuf.h
108LIB_OBJS += strbuf.o
109
6fb737be
JH
110LIB_H += quote.h
111LIB_OBJS += quote.o
112
85976974 113LIB_H += diff.h count-delta.h
e468305a
PB
114DIFF_OBJS = diff.o diffcore-rename.o diffcore-pickaxe.o diffcore-pathspec.o \
115 diffcore-break.o diffcore-order.o
116LIB_OBJS += $(DIFF_OBJS) count-delta.o
86436c28 117
d19938ab 118LIB_OBJS += gitenv.o
8f3f9b09 119LIB_OBJS += server-info.o
d19938ab 120
cc1ad5c8
LT
121LIBS = $(LIB_FILE)
122LIBS += -lz
cef661fc 123
dd53c7ab
PB
124ifndef NO_OPENSSL
125 LIB_OBJS += epoch.o
9e95049b 126 OPENSSL_LIBSSL=-lssl
dd53c7ab 127else
b05701c5 128 DEFINES += '-DNO_OPENSSL'
dd53c7ab 129 MOZILLA_SHA1=1
9e95049b 130 OPENSSL_LIBSSL=
dd53c7ab 131endif
cef661fc
LT
132ifdef MOZILLA_SHA1
133 SHA1_HEADER="mozilla-sha1/sha1.h"
134 LIB_OBJS += mozilla-sha1/sha1.o
a6ef3518
PM
135else
136ifdef PPC_SHA1
137 SHA1_HEADER="ppc/sha1.h"
138 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
cef661fc
LT
139else
140 SHA1_HEADER=<openssl/sha.h>
bfb15365
JS
141ifeq ($(shell uname -s),Darwin)
142 LIBS += -lcrypto -lssl
143else
3be4b61a 144 LIBS += -lcrypto
cef661fc 145endif
a6ef3518 146endif
bfb15365 147endif
cef661fc 148
b05701c5 149DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
cc1ad5c8 150
0a02ce72 151
44c9e859 152
28818ffa
PB
153### Build rules
154
155all: $(PROG)
89967023 156
d3af621b
JH
157all:
158 $(MAKE) -C templates
b05701c5
PR
159 $(MAKE) -C tools
160
161%.o: %.c
162 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
163%.o: %.S
164 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
a310d434 165
623c8a14 166git-%: %.o $(LIB_FILE)
b05701c5 167 $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
623c8a14
PB
168
169git-http-pull: pull.o
170git-local-pull: pull.o
171git-ssh-pull: rsh.o pull.o
172git-ssh-push: rsh.o
a3df1801
LT
173
174git-http-pull: LIBS += -lcurl
9e95049b 175git-rev-list: LIBS += $(OPENSSL_LIBSSL)
a3df1801 176
d3af621b 177init-db.o: init-db.c
b05701c5
PR
178 $(CC) -c $(ALL_CFLAGS) \
179 -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
d3af621b 180
e468305a 181$(LIB_OBJS): $(LIB_H)
3c4e8a63 182$(patsubst git-%,%.o,$(PROG)): $(LIB_H)
e468305a 183$(DIFF_OBJS): diffcore.h
e83c5163 184
28818ffa
PB
185$(LIB_FILE): $(LIB_OBJS)
186 $(AR) rcs $@ $(LIB_OBJS)
187
188doc:
189 $(MAKE) -C Documentation all
190
191
192
193### Testing rules
194
195test: all
196 $(MAKE) -C t/ all
197
198test-date: test-date.c date.o
b05701c5 199 $(CC) $(ALL_CFLAGS) -o $@ test-date.c date.o
28818ffa
PB
200
201test-delta: test-delta.c diff-delta.o patch-delta.o
b05701c5 202 $(CC) $(ALL_CFLAGS) -o $@ $^
28818ffa
PB
203
204check:
b05701c5 205 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done
28818ffa
PB
206
207
208
209### Installation rules
210
211install: $(PROG) $(SCRIPTS)
212 $(INSTALL) -m755 -d $(dest)$(bindir)
9e44f898 213 $(INSTALL) $(PROG) $(SCRIPTS) $(dest)$(bindir)
8d5afef0 214 $(MAKE) -C templates install
28818ffa
PB
215
216install-tools:
217 $(MAKE) -C tools install
218
219install-doc:
220 $(MAKE) -C Documentation install
221
222
223
224
225### Maintainer's dist rules
226
78d9d414 227git-core.spec: git-core.spec.in Makefile
a9db2974
CW
228 sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
229
f85639c3
LT
230GIT_TARNAME=git-core-$(GIT_VERSION)
231dist: git-core.spec git-tar-tree
b1de9de2 232 ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
a9db2974 233 @mkdir -p $(GIT_TARNAME)
f85639c3
LT
234 @cp git-core.spec $(GIT_TARNAME)
235 tar rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git-core.spec
a9db2974 236 @rm -rf $(GIT_TARNAME)
9dce3c06 237 gzip -f -9 $(GIT_TARNAME).tar
a9db2974
CW
238
239rpm: dist
d7b8a164 240 $(RPMBUILD) -ta git-core-$(GIT_VERSION).tar.gz
a9db2974 241
7a590132 242deb: dist
f29eaed1
JH
243 rm -rf $(GIT_TARNAME)
244 tar zxf $(GIT_TARNAME).tar.gz
5a571cdd 245 dpkg-source -b $(GIT_TARNAME)
f29eaed1 246 cd $(GIT_TARNAME) && fakeroot debian/rules binary
28818ffa
PB
247
248### Cleaning rules
87a81c83 249
e83c5163 250clean:
a6ef3518 251 rm -f *.o mozilla-sha1/*.o ppc/*.o $(PROG) $(LIB_FILE)
5a571cdd 252 rm -f git-core.spec
f29eaed1 253 rm -rf $(GIT_TARNAME)
5a571cdd
JH
254 rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
255 rm -f git-core_$(GIT_VERSION)-*.deb git-core_$(GIT_VERSION)-*.dsc
256 rm -f git-tk_$(GIT_VERSION)-*.deb
8cc39306 257 $(MAKE) -C tools/ clean
ca67f002 258 $(MAKE) -C Documentation/ clean
8d5afef0 259 $(MAKE) -C templates/ clean
4b7581f0 260 $(MAKE) -C t/ clean