Simplify CFLAGS/DEFINES in Makefile
I think the original intention was to make CFLAGS overridable from the make command line, but somehow we ended up accumulating conditional makefile sections that wrongly appends values to CFLAGs. These assignments do not work when the user actually override them from the make command line! DEFINES are handled the same way; it was seemingly overridable, but the makefile sections had assignments, which meant overriding it from the command line broke things. This simplifies things by limiting the internal futzing to ALL_CFLAGS, and by removing DEFINES altogether. Overriding CFLAGS from the command line should start working with this change. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Nov 4, 2005 at 23:50 UTC
12aa7456c937f758df9aafcc0123395ed7660fca
1 file changed
+14
-18
Makefile
+14
-18
@@ -37,25 +37,21 @@
37
# 1461501637330902918203684832716283019655932542976 hashes do not give you
38
# sufficient guarantee that no collisions between objects will ever happen.
39
40
-# DEFINES += -DCOLLISION_CHECK
41
-
40
# Define USE_NSEC below if you want git to care about sub-second file mtimes
41
# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
42
# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
43
# randomly break unless your underlying filesystem supports those sub-second
44
# times (my ext3 doesn't).
45
48
-# DEFINES += -DUSE_NSEC
49
-
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
53
-# DEFINES += -DUSE_STDEV
54
-
49
GIT_VERSION = 0.99.9.GIT
50
51
+# CFLAGS is for the users to override from the command line.
52
+
53
CFLAGS = -g -O2 -Wall
58
-ALL_CFLAGS = $(CFLAGS) $(PLATFORM_DEFINES) $(DEFINES)
54
+ALL_CFLAGS = $(CFLAGS)
55
56
prefix = $(HOME)
57
bindir = $(prefix)/bin
@@ -194,19 +190,19 @@ ifeq ($(uname_S),SunOS)
190
NO_STRCASESTR = YesPlease
191
INSTALL = ginstall
192
TAR = gtar
197
- PLATFORM_DEFINES += -D__EXTENSIONS__
193
+ ALL_CFLAGS += -D__EXTENSIONS__
194
endif
195
ifeq ($(uname_O),Cygwin)
196
NO_STRCASESTR = YesPlease
197
NEEDS_LIBICONV = YesPlease
198
NO_IPV6 = YesPlease
199
X = .exe
204
- PLATFORM_DEFINES += -DUSE_SYMLINK_HEAD=0
200
+ ALL_CFLAGS += -DUSE_SYMLINK_HEAD=0
201
endif
202
ifeq ($(uname_S),OpenBSD)
203
NO_STRCASESTR = YesPlease
204
NEEDS_LIBICONV = YesPlease
209
- PLATFORM_DEFINES += -I/usr/local/include -L/usr/local/lib
205
+ ALL_CFLAGS += -I/usr/local/include -L/usr/local/lib
206
endif
207
ifneq (,$(findstring arm,$(uname_M)))
208
ARM_SHA1 = YesPlease
@@ -217,7 +213,7 @@ endif
213
ifndef NO_CURL
214
ifdef CURLDIR
215
# This is still problematic -- gcc does not want -R.
220
- CFLAGS += -I$(CURLDIR)/include
216
+ ALL_CFLAGS += -I$(CURLDIR)/include
217
CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
218
else
219
CURL_LIBCURL = -lcurl
@@ -240,13 +236,13 @@ ifndef NO_OPENSSL
236
OPENSSL_LIBSSL = -lssl
237
ifdef OPENSSLDIR
238
# Again this may be problematic -- gcc does not always want -R.
243
- CFLAGS += -I$(OPENSSLDIR)/include
239
+ ALL_CFLAGS += -I$(OPENSSLDIR)/include
240
OPENSSL_LINK = -L$(OPENSSLDIR)/lib -R$(OPENSSLDIR)/lib
241
else
242
OPENSSL_LINK =
243
endif
244
else
249
- DEFINES += -DNO_OPENSSL
245
+ ALL_CFLAGS += -DNO_OPENSSL
246
MOZILLA_SHA1 = 1
247
OPENSSL_LIBSSL =
248
endif
@@ -258,7 +254,7 @@ endif
254
ifdef NEEDS_LIBICONV
255
ifdef ICONVDIR
256
# Again this may be problematic -- gcc does not always want -R.
261
- CFLAGS += -I$(ICONVDIR)/include
257
+ ALL_CFLAGS += -I$(ICONVDIR)/include
258
ICONV_LINK = -L$(ICONVDIR)/lib -R$(ICONVDIR)/lib
259
else
260
ICONV_LINK =
@@ -276,15 +272,15 @@ ifdef NEEDS_NSL
272
SIMPLE_LIB += -lnsl
273
endif
274
ifdef NO_STRCASESTR
279
- DEFINES += -Dstrcasestr=gitstrcasestr -DNO_STRCASESTR=1
275
+ ALL_CFLAGS += -Dstrcasestr=gitstrcasestr -DNO_STRCASESTR=1
276
LIB_OBJS += compat/strcasestr.o
277
endif
278
ifdef NO_MMAP
283
- DEFINES += -Dmmap=gitfakemmap -Dmunmap=gitfakemunmap -DNO_MMAP
279
+ ALL_CFLAGS += -Dmmap=gitfakemmap -Dmunmap=gitfakemunmap -DNO_MMAP
280
LIB_OBJS += compat/mmap.o
281
endif
282
ifdef NO_IPV6
287
- DEFINES += -DNO_IPV6 -Dsockaddr_storage=sockaddr_in
283
+ ALL_CFLAGS += -DNO_IPV6 -Dsockaddr_storage=sockaddr_in
284
endif
285
286
ifdef PPC_SHA1
@@ -305,7 +301,7 @@ endif
301
endif
302
endif
303
308
-DEFINES += -DSHA1_HEADER=$(call shellquote,$(SHA1_HEADER))
304
+ALL_CFLAGS += -DSHA1_HEADER=$(call shellquote,$(SHA1_HEADER))
305
306
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
307
$(patsubst %.perl,%,$(SCRIPT_PERL)) \