Subject: Re: Makefile checks for DarwinPorts / Fink

From: Shawn Pearce <[email-masked]>
Date: Sat, 22 Jul 2006 12:19:14 -0400

Junio C Hamano <[email-masked]> wrote:
> "Stefan Pfetzing" <[email-masked]> writes:
> 
> > while I was updating the DarwinPorts Portfile for git, I saw some
> > really suspicious lines in the Makefile of Git for DarwinPorts/Fink.
> >
> > --- snip ---
> >        ## fink
> >        ifeq ($(shell test -d /sw/lib && echo y),y)
> >                ALL_CFLAGS += -I/sw/include
> >                ALL_LDFLAGS += -L/sw/lib
> >        endif
> >        ## darwinports
> >        ifeq ($(shell test -d /opt/local/lib && echo y),y)
> >                ALL_CFLAGS += -I/opt/local/include
> >                ALL_LDFLAGS += -L/opt/local/lib
> >        endif
> > --- snap ---
> >
> > IMHO, Git should definetely not include /sw/include and /sw/lib, just
> > if it *exists*.
[snip]
> But I suspect that the "official" portfile (or whatever it is
> called in the Darwin world) should be able to override whatever
> is done in there --- otherwise we would need to remove them or
> comment them out, but I am hoping it does not have to come to
> that; I think they serve as good hint to help people who are
> building from the source.

The quoted section of the Makefile was mostly my fault.  GIT used
to build only against Fink but when I switched to DarwinPorts it
was first not even looking for them and second when I removed Fink
the Mac OS X linker was warning about /sw/lib not existing.

I completely agree that its incorrect to be doing this all of the
time as a higher-level build driver (e.g. Portfile) should be able
to have more direct control CFLAGS and LDFLAGS.  Perhaps something
like this?

diff --git a/Makefile b/Makefile
index a1666e2..0a48c32 100644
--- a/Makefile
+++ b/Makefile
@@ -268,14 +268,18 @@ ifeq ($(uname_S),Darwin)
 	NEEDS_LIBICONV = YesPlease
 	NO_STRLCPY = YesPlease
 	## fink
-	ifeq ($(shell test -d /sw/lib && echo y),y)
-		BASIC_CFLAGS += -I/sw/include
-		BASIC_LDFLAGS += -L/sw/lib
+	ifndef NO_FINK
+		ifeq ($(shell test -d /sw/lib && echo y),y)
+			BASIC_CFLAGS += -I/sw/include
+			BASIC_LDFLAGS += -L/sw/lib
+		endif
 	endif
+	ifndef NO_DARWIN_PORTS
 	## darwinports
-	ifeq ($(shell test -d /opt/local/lib && echo y),y)
-		BASIC_CFLAGS += -I/opt/local/include
-		BASIC_LDFLAGS += -L/opt/local/lib
+		ifeq ($(shell test -d /opt/local/lib && echo y),y)
+			BASIC_CFLAGS += -I/opt/local/include
+			BASIC_LDFLAGS += -L/opt/local/lib
+		endif
 	endif
 endif
 ifeq ($(uname_S),SunOS)

-- 
Shawn.