Subject: Yet another patch for XFree-2.0 for shared libraries
To: None <xfree86-beta@physics.su.oz.au>
From: John Brezak <brezak@ch.hp.com>
List: current-users
Date: 11/15/1993 15:07:53
Since I haven't seen what should be the *right* patch for XFree-2.0 NetBSD shared
libraries, I'll add this one to the maze. All of the others are *flawed* IMHO 'cause
they fell back to the Sun shlib behavior or were plain broken.

Features of this patch:

- No source code changes - Just config/x386.cf and lib/Xmu/Imakefile
- Add new shlib type - config/netbsdLib.{tmpl,rules}
- No libxx.sa's needed
- libXt based apps work
- libXmu only apps work
- Tested with netbsd-current 11/14/93
- Started verison numbers at 5.0 (for most things)
- Added a -DBSDSHLIB (not used) for just in case...

*** config/x386.cf.orig	Mon Nov 15 14:56:02 1993
--- config/x386.cf	Mon Nov 15 14:56:05 1993
***************
*** 978,983 ****
--- 978,988 ----
  # define CppCmd			/usr/libexec/cpp
  #endif
  
+ #ifdef i386NetBsd
+ # define ForceNormalLib YES
+ # include <netbsdLib.rules>
+ #endif
+ 
  #if HasGcc
  # define AnsiCCOptions		/**/
  # if HasGcc2
*** /dev/null	Mon Nov 15 02:34:33 1993
--- config/netbsdLib.rules	Fri Nov 12 07:43:50 1993
***************
*** 0 ****
--- 1,72 ----
+ XCOMM $XConsortium: sunLib.rules,v 1.7 91/12/20 11:19:47 rws Exp $
+ 
+ /*
+  * NetBSD shared library rules
+  */
+ 
+ #ifndef HasSharedLibraries
+ #define HasSharedLibraries YES
+ #endif
+ #ifndef SharedDataSeparation
+ #define SharedDataSeparation NO
+ #endif
+ #ifndef SharedCodeDef
+ #define SharedCodeDef
+ #endif
+ #ifndef SharedLibraryDef
+ #define SharedLibraryDef -DBSDSHLIB
+ #endif
+ #ifndef ShLibIncludeFile
+ #define ShLibIncludeFile <netbsdLib.tmpl>
+ #endif
+ #ifndef SharedLibraryLoadFlags
+ #define SharedLibraryLoadFlags -Bshareable -assert pure-text
+ #endif
+ #ifndef PositionIndependentCFlags
+ #define PositionIndependentCFlags -fpic
+ #endif
+ 
+ /*
+  * InstallSharedLibrary - generate rules to install the shared library.
+  */
+ #ifndef InstallSharedLibrary
+ #define	InstallSharedLibrary(libname,rev,dest)				@@\
+ install:: Concat(lib,libname.so.rev) 					@@\
+ 	MakeDir($(DESTDIR)dest)						@@\
+ 	$(INSTALL) -c $(INSTLIBFLAGS) Concat(lib,libname.so.rev) $(DESTDIR)dest @@\
+ 
+ #endif /* InstallSharedLibrary */
+ 
+ /*
+  * InstallSharedLibraryData - generate rules to install the shared library data
+  */
+ #ifndef InstallSharedLibraryData
+ #define	InstallSharedLibraryData(libname,rev,dest)
+ #endif /* InstallSharedLibraryData */
+ 
+ /*
+  * NormalSharedLibraryTarget - generate rules to create a shared library;
+  * build it into a different name so that the we do not hose people by having
+  * the library gone for long periods.
+  */
+ #ifndef SharedLibraryTarget
+ #define SharedLibraryTarget(libname,rev,solist,down,up)			@@\
+ AllTarget(Concat(lib,libname.so.rev))					@@\
+ 									@@\
+ Concat(lib,libname.so.rev):  solist					@@\
+ 	$(RM) $@~							@@\
+ 	(cd down; $(LD) -o up/$@~ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS)) @@\
+ 	$(RM) $@ 							@@\
+ 	$(MV) $@~ $@							@@\
+ 									@@\
+ clean::									@@\
+ 	$(RM) Concat(lib,libname.so.rev)
+ 
+ #endif /* SharedLibraryTarget */
+ 
+ /*
+  * SharedLibraryDataTarget - generate rules to create shlib data file;
+  */
+ #ifndef SharedLibraryDataTarget
+ #define SharedLibraryDataTarget(libname,rev,salist)
+ #endif /* SharedLibraryDataTarget */
*** /dev/null	Mon Nov 15 02:34:33 1993
--- config/netbsdLib.tmpl	Mon Nov 15 15:00:37 1993
***************
*** 0 ****
--- 1,81 ----
+ XCOMM $XConsortium: sunLib.tmpl,v 1.14.1.2 92/11/11 09:55:02 rws Exp $
+ 
+ /*
+  * NetBSD shared library template
+  */
+ 
+ #ifndef SharedXlibRev
+ #define SharedXlibRev 5.0
+ #endif
+ #ifndef SharedOldXRev
+ #define SharedOldXRev 5.0
+ #endif
+ #ifndef SharedXtRev
+ #define SharedXtRev 5.0
+ #endif
+ #ifndef SharedXawRev
+ #define SharedXawRev 5.0
+ #endif
+ #ifndef SharedXmuRev
+ #define SharedXmuRev 5.0
+ #endif
+ #ifndef SharedXextRev
+ #define SharedXextRev 5.0
+ #endif
+ #ifndef SharedXinputRev
+ #define SharedXinputRev 5.0
+ #endif
+ #ifndef SharedXTrapRev
+ #define SharedXTrapRev 1.0
+ #endif
+ #ifndef SharedPexRev
+ #define SharedPexRev 1.0
+ #endif
+ 
+ SHLIBLDFLAGS = SharedLibraryLoadFlags
+ PICFLAGS = PositionIndependentCFlags
+ 
+ /*
+  * and now a little bit of magic for using imake without source tree; if we
+  * are using shared libraries, we really do not need to depend on anything
+  */
+ #if SharedLibXpm
+         DEPXPMLIB = 
+            XPMLIB = _Use(-lXpm,-L$(XPMSRC)/lib -lXpm)
+ #endif
+ #if SharedLibXext
+   DEPEXTENSIONLIB = 
+      EXTENSIONLIB = _Use(-lXext,-L$(EXTENSIONSRC)/lib -lXext)
+ #endif
+ #if SharedLibX
+           DEPXLIB = $(DEPEXTENSIONLIB)
+              XLIB = $(EXTENSIONLIB) _Use(-lX11,-L$(XLIBSRC) -lX11)
+ #endif
+ #if SharedLibXmu
+         DEPXMULIB = 
+        XMULIBONLY = _Use(-lXmu,-L$(XMUSRC) -lXmu)
+            XMULIB = _Use(-lXmu,-L$(XMUSRC) -lXmu -L$(TOOLKITSRC) -L$(EXTENSIONSRC)/lib -L$(XLIBSRC))
+ #if !defined(UseInstalled) && !defined(XawClientLibs)
+ #define XawClientLibs $(XAWLIB) $(XMULIBONLY) $(XTOOLLIB) $(XLIB)
+ #endif
+ #endif
+ #if SharedOldLibX
+        DEPOLDXLIB = 
+           OLDXLIB = _Use(-loldX,-L$(OLDXLIBSRC) -loldX)
+ #endif
+ #if SharedLibXt
+       DEPXTOOLLIB = 
+          XTOOLLIB = _Use(-lXt,-L$(TOOLKITSRC) -lXt)
+ #endif
+ #if SharedLibXaw
+         DEPXAWLIB = 
+            XAWLIB = _Use(-lXaw,-L$(AWIDGETSRC) -lXaw)
+ #endif
+ #if SharedLibXinput
+         DEPXILIB = 
+            XILIB = _Use(-lXi,-L$(XILIBSRC) -lXi)
+ #endif
+ #if SharedLibPex
+         DEPPEXLIB = 
+            PEXLIB = _Use(-lPEX5,-L$(PEXLIBSRC) -lPEX5)
+ #endif
*** lib/Xmu/Imakefile.orig	Mon Nov 15 14:56:35 1993
--- lib/Xmu/Imakefile	Sun Nov 14 16:11:03 1993
***************
*** 11,17 ****
  #define DoProfileLib ProfileLibXmu
  #include <Library.tmpl>
  
! #if defined(RsArchitecture) || SunPost411FCSLd
  #if DoNormalLib
  REQUIREDLIBS = -L../$(TOOLKITSRC) -lXt -L../$(EXTENSIONSRC)/lib -lXext -L../$(XLIBSRC) -lX11
  #else
--- 11,17 ----
  #define DoProfileLib ProfileLibXmu
  #include <Library.tmpl>
  
! #if defined(RsArchitecture) || SunPost411FCSLd || defined(i386NetBsd)
  #if DoNormalLib
  REQUIREDLIBS = -L../$(TOOLKITSRC) -lXt -L../$(EXTENSIONSRC)/lib -lXext -L../$(XLIBSRC) -lX11
  #else

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 John Brezak                    UUCP:     uunet!apollo.hp!brezak
 Hewlett Packard/Apollo         Internet: brezak@ch.hp.com
 300 Apollo Drive               Phone:    (508) 436-4915
 Chelmsford, Massachusetts      Fax:      (508) 436-5103

------------------------------------------------------------------------------