Subject: Solaris/DHX/dlopen fixes

From: Wes Hardaker <[email-masked]>
Date: 10 Mar 2000 15:55:38 -0800

After much munging around today I've solved the shared object loading
problem that people have been seeing with the recent pre releases of
2.1.4-37b+ on solaris.  Basically, its just a linking problem with
respect to command line flags.  The patch below is not even entirely
complete (I'm done for the day, sorry), and it only fixes afpd and
atalkd but the rest can be fixed extrapolation quickly (remove
CFLAGS from the object link lines in the Makefiles or else the
applications will segfault).

Combined with this patch and pam_afs support for Solaris, I now have a 
secure mac->afs connection without requiring a plugin to be installed
on the mac side.  Thanks to whoever contributed to the DHX support for 
netatalk.

(this patch is against pre-asun2.1.4-38b_test)

diff -r -c ../patches/netatalk-1.4b2+asun2.1.4/etc/afpd/Makefile ./etc/afpd/Makefile
*** ../patches/netatalk-1.4b2+asun2.1.4/etc/afpd/Makefile	Mon Dec 13 22:29:26 1999
--- ./etc/afpd/Makefile	Fri Mar 10 14:10:27 2000
***************
*** 74,80 ****
  FRC:
  
  afpd : ${OBJ} ../../libatalk/libatalk.a
! 	${CC} ${CFLAGS} ${LDFLAGS_EXPORT} -o afpd ${OBJ} ${LIBDIRS} ${LIBS}
  
  afp_options.o : afp_options.c
  	${CC} ${CFLAGS} \
--- 74,80 ----
  FRC:
  
  afpd : ${OBJ} ../../libatalk/libatalk.a
! 	${CC} ${LDFLAGS_EXPORT} -o afpd ${OBJ} ${LIBDIRS} ${LIBS}
  
  afp_options.o : afp_options.c
  	${CC} ${CFLAGS} \
diff -r -c ../patches/netatalk-1.4b2+asun2.1.4/etc/atalkd/Makefile ./etc/atalkd/Makefile
*** ../patches/netatalk-1.4b2+asun2.1.4/etc/atalkd/Makefile	Fri Jun  4 15:05:45 1999
--- ./etc/atalkd/Makefile	Fri Mar 10 14:11:07 2000
***************
*** 12,18 ****
  all : atalkd
  
  atalkd : ${OBJ} ../../libatalk/libatalk.a
! 	${CC} ${CFLAGS} -o atalkd ${OBJ} ${LIBDIRS} ${LIBS}
  
  main.o : main.c
  	${CC} ${CFLAGS} -DVERSION=\"`cat ../../VERSION`\" \
--- 12,18 ----
  all : atalkd
  
  atalkd : ${OBJ} ../../libatalk/libatalk.a
! 	${CC} -o atalkd ${OBJ} ${LIBDIRS} ${LIBS}
  
  main.o : main.c
  	${CC} ${CFLAGS} -DVERSION=\"`cat ../../VERSION`\" \
diff -r -c ../patches/netatalk-1.4b2+asun2.1.4/etc/papd/Makefile ./etc/papd/Makefile
*** ../patches/netatalk-1.4b2+asun2.1.4/etc/papd/Makefile	Fri Jun  4 15:05:22 1999
--- ./etc/papd/Makefile	Fri Mar 10 14:11:38 2000
***************
*** 48,54 ****
  FRC:
  
  papd : ${OBJ} ../../libatalk/libatalk.a
! 	${CC} ${CFLAGS} ${LDFLAGS} -o papd ${OBJ} ${LIBDIRS} ${LIBS}
  
  main.o : main.c
  	${CC} ${CFLAGS} -D_PATH_PAPDCONF=\"${ETCDIR}/papd.conf\" \
--- 48,54 ----
  FRC:
  
  papd : ${OBJ} ../../libatalk/libatalk.a
! 	${CC} ${LDFLAGS} -o papd ${OBJ} ${LIBDIRS} ${LIBS}
  
  main.o : main.c
  	${CC} ${CFLAGS} -D_PATH_PAPDCONF=\"${ETCDIR}/papd.conf\" \
diff -r -c ../patches/netatalk-1.4b2+asun2.1.4/sys/solaris/Makefile ./sys/solaris/Makefile
*** ../patches/netatalk-1.4b2+asun2.1.4/sys/solaris/Makefile	Mon Jan  3 18:07:01 2000
--- ./sys/solaris/Makefile	Fri Mar 10 13:53:30 2000
***************
*** 11,20 ****
  # use gcc (gcc-2.95 on 64-bit sparc)
  CC=		gcc
  KCFLAGS=	-D_KERNEL -Wall -Wstrict-prototypes ${KGCCFLAGS} # -mcpu=ultrasparc
! OPTOPTS=	-O
! CSHAREDFLAGS=   -fPIC
  LDSHARED=	gcc
  LDSHAREDFLAGS=  -shared
  
  # use Sun CC (for a 64-bit kernel, uncomment " -xarch=v9 -xregs=no%appl ") 
  #CC=		cc
--- 11,21 ----
  # use gcc (gcc-2.95 on 64-bit sparc)
  CC=		gcc
  KCFLAGS=	-D_KERNEL -Wall -Wstrict-prototypes ${KGCCFLAGS} # -mcpu=ultrasparc
! OPTOPTS=	-O2 -g -fPIC -shared
! CSHAREDFLAGS=   -fPIC -shared
  LDSHARED=	gcc
  LDSHAREDFLAGS=  -shared
+ LDFLAGS_EXPORT= -export-dynamic
  
  # use Sun CC (for a 64-bit kernel, uncomment " -xarch=v9 -xregs=no%appl ") 
  #CC=		cc
***************
*** 30,36 ****
  # -D_ISOC9X_SOURCE is handled by OSVERSION. basically, it's not needed
  # with 2.5.1.
  # add -DHAVE_IFNAMEINDEX if you're using solaris 8.
! DEFS=	-DNO_STRUCT_TM_GMTOFF -D__svr4__ -DSOLARIS -I../../sys/generic \
  	${OSDEFS} ${MACHINEDEFS}
  INSTALL=	/usr/ucb/install
  AFPLIBS=
--- 31,37 ----
  # -D_ISOC9X_SOURCE is handled by OSVERSION. basically, it's not needed
  # with 2.5.1.
  # add -DHAVE_IFNAMEINDEX if you're using solaris 8.
! DEFS=	-fPIC -DNO_STRUCT_TM_GMTOFF -D__svr4__ -DSOLARIS -I../../sys/generic \
  	${OSDEFS} ${MACHINEDEFS}
  INSTALL=	/usr/ucb/install
  AFPLIBS=

-- 
Wes Hardaker
Distributed Computing Analysis and Support
University of California at Davis