@matheusbsbs / matheus-bagliano / commits / 94d2331770
Fork 0

Separate LDFLAGS and CFLAGS.

Stuffing -L flag and friends meant for the linking phase into ALL_CFLAGS is not right; honor LDFLAGS and introduce ALL_LDFLAGS to separate them out. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Nov 13, 2005 at 01:46 UTC 94d2331770b08dc28faf1d950a546a0feb953323
1 file changed +20 -9
Makefile
+20 -9
@@ -52,10 +52,12 @@
52
53 GIT_VERSION = 0.99.9.GIT
54
55 -# CFLAGS is for the users to override from the command line.
55 +# CFLAGS and LDFLAGS are for the users to override from the command line.
56
57 CFLAGS = -g -O2 -Wall
58 +LDFLAGS =
59 ALL_CFLAGS = $(CFLAGS)
60 +ALL_LDFLAGS = $(LDFLAGS)
61
62 prefix = $(HOME)
63 bindir = $(prefix)/bin
@@ -187,9 +189,11 @@ ifeq ($(uname_S),Darwin)
189 NEEDS_SSL_WITH_CRYPTO = YesPlease
190 NEEDS_LIBICONV = YesPlease
191 ## fink
190 - ALL_CFLAGS += -I/sw/include -L/sw/lib
192 + ALL_CFLAGS += -I/sw/include
193 + ALL_LDFLAGS += -L/sw/lib
194 ## darwinports
192 - ALL_CFLAGS += -I/opt/local/include -L/opt/local/lib
195 + ALL_CFLAGS += -I/opt/local/include
196 + ALL_LDFLAGS += -L/opt/local/lib
197 endif
198 ifeq ($(uname_S),SunOS)
199 NEEDS_SOCKET = YesPlease
@@ -211,7 +215,13 @@ endif
215 ifeq ($(uname_S),OpenBSD)
216 NO_STRCASESTR = YesPlease
217 NEEDS_LIBICONV = YesPlease
214 - ALL_CFLAGS += -I/usr/local/include -L/usr/local/lib
218 + ALL_CFLAGS += -I/usr/local/include
219 + ALL_LDFLAGS += -L/usr/local/lib
220 +endif
221 +ifeq ($(uname_S),NetBSD)
222 + NEEDS_LIBICONV = YesPlease
223 + ALL_CFLAGS += -I/usr/pkg/include
224 + ALL_LDFLAGS += -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib
225 endif
226 ifneq (,$(findstring arm,$(uname_M)))
227 ARM_SHA1 = YesPlease
@@ -221,7 +231,7 @@ endif
231
232 ifndef NO_CURL
233 ifdef CURLDIR
224 - # This is still problematic -- gcc does not want -R.
234 + # This is still problematic -- gcc does not always want -R.
235 ALL_CFLAGS += -I$(CURLDIR)/include
236 CURL_LIBCURL = -L$(CURLDIR)/lib -R$(CURLDIR)/lib -lcurl
237 else
@@ -369,12 +379,13 @@ git-cherry-pick: git-revert
379 $(CC) -o $*.o -c $(ALL_CFLAGS) $<
380
381 git-%$X: %.o $(LIB_FILE)
372 - $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIBS)
382 + $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
383
384 git-mailinfo$X : SIMPLE_LIB += $(LIB_4_ICONV)
385 $(SIMPLE_PROGRAMS) : $(LIB_FILE)
386 $(SIMPLE_PROGRAMS) : git-%$X : %.o
377 - $(CC) $(ALL_CFLAGS) -o $@ $(filter %.o,$^) $(LIB_FILE) $(SIMPLE_LIB)
387 + $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
388 + $(LIB_FILE) $(SIMPLE_LIB)
389
390 git-http-fetch$X: fetch.o
391 git-local-fetch$X: fetch.o
@@ -408,10 +419,10 @@ test: all
419 $(MAKE) -C t/ all
420
421 test-date$X: test-date.c date.o ctype.o
411 - $(CC) $(ALL_CFLAGS) -o $@ test-date.c date.o ctype.o
422 + $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) test-date.c date.o ctype.o
423
424 test-delta$X: test-delta.c diff-delta.o patch-delta.o
414 - $(CC) $(ALL_CFLAGS) -o $@ $^
425 + $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $^
426
427 check:
428 for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i; done