# patches

5 messages from 2005-09-05 to 2005-09-12. Participants: Patrick Mauritz, Junio C Hamano, Jason Riedy.
Thread: https://gitlist.dev/t/1735

## Patrick Mauritz, 2005-09-05 23:24

Subject: patches
Message-ID: <1125962642.15293.20.camel@divert>
URL: https://gitlist.dev/e/1125962642.15293.20.camel%40divert

```
Hi,

attached are two patches:
the first fixes some build issues on solaris10/x86 with sunpro (and some
that also happen with gcc), while the second adds a simple way to add
additional search and link paths for curl library and headers.


patrick mauritz
(not on the list, please Cc:)


diff -ur git-core-0.99.4.orig/convert-cache.c git-core-0.99.4/convert-cache.c
--- git-core-0.99.5.orig/convert-cache.c	Wed Aug 17 09:55:00 2005
+++ git-core-0.99.5/convert-cache.c	Wed Aug 17 09:58:48 2005
@@ -1,4 +1,5 @@
 #define _XOPEN_SOURCE /* glibc2 needs this */
+#define __EXTENSIONS__ /* solaris needs this */
 #include <time.h>
 #include <ctype.h>
 #include "cache.h"
diff -ur git-core-0.99.4.orig/ident.c git-core-0.99.4/ident.c
--- git-core-0.99.5.orig/ident.c	Wed Aug 17 09:55:00 2005
+++ git-core-0.99.5/ident.c	Wed Aug 17 09:57:54 2005
@@ -36,12 +36,13 @@
 	memcpy(real_email, pw->pw_name, len);
 	real_email[len++] = '@';
 	gethostname(real_email + len, sizeof(real_email) - len);
+#ifndef __sun
 	if (!strchr(real_email+len, '.')) {
 		len = strlen(real_email);
 		real_email[len++] = '.';
 		getdomainname(real_email+len, sizeof(real_email)-len);
 	}
-
+#endif
 	/* And set the default date */
 	datestamp(real_date, sizeof(real_date));
 	return 0;
--- git-core-0.99.5/Makefile~	Thu Aug 25 03:54:24 2005
+++ git-core-0.99.5/Makefile	Tue Sep  6 01:18:32 2005
@@ -146,7 +146,11 @@
 		endif
 	endif
 endif
+ifeq ($(shell uname -s),SunOS)
+  LIBS += -lsocket
+endif
 
+
 DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
 
 


--- git-core-0.99.5/Makefile~	Tue Sep  6 01:13:29 2005
+++ git-core-0.99.5/Makefile	Tue Sep  6 01:15:40 2005
@@ -34,7 +34,14 @@
 
 GIT_VERSION = 0.99.5
 
-CFLAGS = -g -O2 -Wall
+ifndef COPTS
+COPTS = -g -O2 -Wall
+endif
+CFLAGS = $(COPTS)
+ifdef CURLDIR
+CFLAGS+=-I$(CURLDIR)/include
+endif
+
 ALL_CFLAGS = $(CFLAGS) $(DEFINES)
 
 prefix = $(HOME)
@@ -172,7 +179,11 @@
 git-ssh-pull: rsh.o pull.o
 git-ssh-push: rsh.o
 
+ifdef CURLDIR
+git-http-pull: LIBS += -lcurl -L$(CURLDIR)/lib -R$(CURLDIR)/lib
+else
 git-http-pull: LIBS += -lcurl
+endif
 git-rev-list: LIBS += $(OPENSSL_LIBSSL)
 
 init-db.o: init-db.c

```

## Junio C Hamano, 2005-09-08 02:06

Subject: Re: patches
Message-ID: <7vr7c0xqhd.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vr7c0xqhd.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <1125962642.15293.20.camel@divert>

```
Patrick Mauritz <oxygene@studentenbude.ath.cx> writes:

I would have appreciated if you said "Solaris portability patch"
or somesuch on the subject line.

> diff -ur git-core-0.99.4.orig/convert-cache.c git-core-0.99.4/convert-cache.c
> --- git-core-0.99.5.orig/convert-cache.c	Wed Aug 17 09:55:00 2005
> +++ git-core-0.99.5/convert-cache.c	Wed Aug 17 09:58:48 2005
> @@ -1,4 +1,5 @@
>  #define _XOPEN_SOURCE /* glibc2 needs this */
> +#define __EXTENSIONS__ /* solaris needs this */
>  #include <time.h>
>  #include <ctype.h>
>  #include "cache.h"

I'll take this; thanks.

> diff -ur git-core-0.99.4.orig/ident.c git-core-0.99.4/ident.c
> --- git-core-0.99.5.orig/ident.c	Wed Aug 17 09:55:00 2005
> +++ git-core-0.99.5/ident.c	Wed Aug 17 09:57:54 2005
> @@ -36,12 +36,13 @@
>  	memcpy(real_email, pw->pw_name, len);
>  	real_email[len++] = '@';
>  	gethostname(real_email + len, sizeof(real_email) - len);
> +#ifndef __sun
>  	if (!strchr(real_email+len, '.')) {
>  		len = strlen(real_email);
>  		real_email[len++] = '.';
>  		getdomainname(real_email+len, sizeof(real_email)-len);
>  	}
> -
> +#endif
>  	/* And set the default date */
>  	datestamp(real_date, sizeof(real_date));
>  	return 0;

I'll do this slightly differently, because I do not want to have
"ifdef __platform_name" in the code when possible.

> --- git-core-0.99.5/Makefile~	Thu Aug 25 03:54:24 2005
> +++ git-core-0.99.5/Makefile	Tue Sep  6 01:18:32 2005
> @@ -146,7 +146,11 @@
>  		endif
>  	endif
>  endif
> +ifeq ($(shell uname -s),SunOS)
> +  LIBS += -lsocket
> +endif
>  
> +
>  DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'

I'll do this in the way similar to how I did -liconv for Darwin.

> +ifdef CURLDIR
> +git-http-pull: LIBS += -lcurl -L$(CURLDIR)/lib -R$(CURLDIR)/lib
> +else
>  git-http-pull: LIBS += -lcurl
> +endif

Curious.  Doesn't the order of -l and -L/-R matter these days?

I am sympathetic to the reason why you need this, but if we go
this route we should also do openssl as well.  I'd drop this
part for now.

```

## Patrick Mauritz, 2005-09-08 10:11

Subject: Re: patches
Message-ID: <1126174268.723.10.camel@divert>
URL: https://gitlist.dev/e/1126174268.723.10.camel%40divert
In-Reply-To: <7vr7c0xqhd.fsf@assigned-by-dhcp.cox.net>

```
On Thu, 2005-09-08 at 04:06, Junio C Hamano wrote:
> I would have appreciated if you said "Solaris portability patch"
> or somesuch on the subject line.
sorry, of course you're right..

the #ifndef __sun was done because getdomainname() doesn't exist on
solaris. (just for clarification)

> Curious.  Doesn't the order of -l and -L/-R matter these days?
hmm.. no idea why it worked for me, but a test case fails now: better
make that -L -R -l

> I am sympathetic to the reason why you need this, but if we go
> this route we should also do openssl as well.  I'd drop this
> part for now.
because on solaris there are lots of places where external libraries
could be found (/usr/local/lib, /opt/csw/lib, whereever people who
package themselves put them). ld.so.conf doesn't exist (same as on
*bsd), so using -L and -R is the standard way of linking external
libraries.


thanks,
patrick mauritz

```

## Jason Riedy, 2005-09-09 22:25

Subject: Re: patches
Message-ID: <25968.1126304722@lotus.CS.Berkeley.EDU>
URL: https://gitlist.dev/e/25968.1126304722%40lotus.CS.Berkeley.EDU
In-Reply-To: <1125962642.15293.20.camel@divert>

```
And Patrick Mauritz writes:
 - 
 - --- git-core-0.99.5.orig/convert-cache.c	Wed Aug 17 09:55:00 2005
 - +++ git-core-0.99.5/convert-cache.c	Wed Aug 17 09:58:48 2005
 - @@ -1,4 +1,5 @@
 -  #define _XOPEN_SOURCE /* glibc2 needs this */
 - +#define __EXTENSIONS__ /* solaris needs this */

To be honest, the right place to handle both these 
#defines is the Makefile.  AIX needs its own set of 
-Ds to turn on various standards.  ugh.  I'm sure 
HP-UX needs even more magic, IRIX needs (is?) a dead 
chicken, etc.

 - +#ifndef __sun
[...]
 -  		getdomainname(real_email+len, sizeof(real_email)-len);
[...]
 - +#endif

getdomainname isn't declared, but it is in libnsl
(on Solaris 8, Sparc) and works just fine.  Sun 
documents sysinfo (2) as its replacement, but that 
call is different on different platforms.  I'd be
shocked if getdomainname disappeared from libnsl,
especially since the C++ include files declare it.
Whoops.

 - +ifeq ($(shell uname -s),SunOS)
 - +  LIBS += -lsocket
 - +endif

Traditionally, it's -lsocket -lnsl to cover all the
bases.  Old SunOS4 -> SunOS5 porting annoyance.  That 
also lets getdomainname work.

The Makefile is generally insufficient for any platform
other than Linux with system-supplied support libraries.
Fixing that will take a good deal of work and probably
will involve putting a bunch of variable-defining makefile
fragments somewhere and including the "right" one.  With
the right variable definitions, a user can over-ride any
of them from the make command...

In the meantime, my personal coping method is just to copy
the Makefile to Makefile.platform, edit it, and use make -f 
Makefile.platform.  I could be really cool and just use a 
different git branch per platform, but I'm lazy.

Jason

```

## Junio C Hamano, 2005-09-12 05:39

Subject: [PATCH] getdomainname should be usable on SunOS with -lnsl
Message-ID: <7vmzmilu9w.fsf_-_@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vmzmilu9w.fsf_-_%40assigned-by-dhcp.cox.net
In-Reply-To: <25968.1126304722@lotus.CS.Berkeley.EDU>

```
Jason Riedy suggests that we should be able to use getdomainname
if we properly specify which libraries to link.

Signed-off-by: Junio C Hamano <junkio@cox.net>

---

 I've tried this on an ancient Solaris machine I happened to
 have access at work and it seems to link OK.  Patrick, could
 you try this and see if it works OK for you?

 Makefile |    6 +++++-
 ident.c  |    2 --
 2 files changed, 5 insertions(+), 3 deletions(-)

2b6a27b6157c6ee472d654dbcaf380aec00d6444
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -148,7 +148,7 @@ ifeq ($(shell uname -s),Darwin)
 endif
 ifeq ($(shell uname -s),SunOS)
 	NEEDS_SOCKET = YesPlease
-	PLATFORM_DEFINES += -DNO_GETDOMAINNAME=1
+	NEEDS_NSL = YesPlease
 endif
 
 ifndef SHELL_PATH
@@ -195,6 +195,10 @@ ifdef NEEDS_SOCKET
 	LIBS += -lsocket
 	SIMPLE_LIB += -lsocket
 endif
+ifdef NEEDS_NSL
+	LIBS += -lnsl
+	SIMPLE_LIB += -lnsl
+endif
 
 DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
 
diff --git a/ident.c b/ident.c
--- a/ident.c
+++ b/ident.c
@@ -36,13 +36,11 @@ int setup_ident(void)
 	memcpy(real_email, pw->pw_name, len);
 	real_email[len++] = '@';
 	gethostname(real_email + len, sizeof(real_email) - len);
-#ifndef NO_GETDOMAINNAME
 	if (!strchr(real_email+len, '.')) {
 		len = strlen(real_email);
 		real_email[len++] = '.';
 		getdomainname(real_email+len, sizeof(real_email)-len);
 	}
-#endif
 	/* And set the default date */
 	datestamp(real_date, sizeof(real_date));
 	return 0;

```
