threads / discuss / 1735

patches

Subject: patches

## tl;dr

5 messages between Sep 5, 2005 and Sep 12, 2005.

replies: 4people: 3as markdown or json

Patrick Mauritz· Sep 5, 2005, 23:24 UTC · lore
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· Sep 8, 2005, 02:06 UTC · re: Patrick Mauritz · lore

Re: patches

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

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

Show 9 quoted lines
> 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.
Show 18 quoted lines
> 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.

Show 12 quoted lines
> --- 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.
Show 5 quoted lines
> +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· Sep 8, 2005, 10:11 UTC · re: Junio C Hamano · lore

Re: patches

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· Sep 9, 2005, 22:25 UTC · re: Patrick Mauritz · lore

Re: patches

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· Sep 12, 2005, 05:39 UTC · re: Jason Riedy · lore

[PATCH] getdomainname should be usable on SunOS with -lnsl

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;

← back to recent threads