patches
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:)
convert-cache.c +1 -0
@@ -1,4 +1,5 @@#define _XOPEN_SOURCE/* glibc2 needs this */ +#define __EXTENSIONS__/* solaris needs this */ #include <time.h> #include <ctype.h> #include "cache.h"
ident.c +2 -1
@@ -36,12 +36,13 @@memcpy (real_email, pw->pw_name, len); real_email[len++] ='@' ;gethostname (real_email + len,sizeof (real_email) - len); +#ifndef __sunif (!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 ;
Makefile renamed from Makefile~ +4 -0
@@ -146,7 +146,11 @@ endif endif endif +ifeq ($(shell uname -s),SunOS) + LIBS += -lsocket +endif + DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
Makefile renamed from Makefile~ +12 -1
@@ -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
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
PATCH 1/1 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.
---
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
Makefile +5 -1
@@ -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)'
ident.c +0 -2
@@ -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 ;
Patrick Mauritz <[email protected]> writes:
I would have appreciated if you said "Solaris portability patch" or somesuch on the subject line.
convert-cache.c line 5
Quoted 9 lines
diff -ur
git-core-0.99.4.orig/convert-cache.cgit-core-0.99.4/convert-cache.cconvert-cache.c +1
-0@@ -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.
Quoted 8 lines
diff -ur
git-core-0.99.4.orig/ident.cgit-core-0.99.4/ident.cident.c +1
-0@@ -36,12 +36,13 @@memcpy (real_email, pw->pw_name, len); real_email[len++] ='@' ;gethostname (real_email + len,sizeof (real_email) - len); +#ifndef __sun
ident.c line 48
Quoted 10 lines
ident.c +1
-1if (!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.
Makefile line 154
Quoted 12 lines
Makefile renamed from Makefile~ +4
-0@@ -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.
Makefile line 186
Quoted 5 lines
Makefile renamed from Makefile~ +4
-0+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.
Quoted 2 lines · Junio C Hamano
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)
Quoted 1 line
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
Quoted 3 lines
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