[tkined] Compiling Scotty on SunOS

Kevin Trotman (ktrotman@ti.com)
Wed, 8 Apr 1998 12:55:03 -0500

Well, I just spent a frustrating week trying to port scotty to SunOS. And I
would like to qualify the statements that I am about to make by saying that
this is not at all a reflection on the author of the tkined/scotty package.
He obviously can't have one of every type of machine and continually test
the porting notes. In fact, I think he's done an excellent job with the
package as a whole.

But the up-to-date (ie: 2.1.8 version notes & notes postied on the scotty
web page) porting notes for SunOS are incorrect in the following ways:

FIRST:
Where it says:
" Comment out lines 101-102 by putting a # at the beginning of the line. "

This is in reference to the bind Makefile. In the bind v4.9.4 Makefile
(which is the version of bind that the author recommends in the porting
notes) lines 101 & 102 are:

.c.o:
${CC} ${CPPFLAGS} ${CFLAGS} -c $*.c

I don't think these are what he really intended to comment out at all, in
fact it'd be a flat miracle to get a compile like that. Actually, lines 101
& 102 reference blank or incorrect lines in all of the versions I've
downloaded the source for (v4.9.3, v4.9.4, and v4.9.5). The correct lines
for the bind4.9.4 Makefile are 103 & 104 or put a comment in front of these
lines (to be version independant):

# -${LDS} ld -x -r $*.o
# ${LDS} mv a.out $*.o

SECOND:
If, after copying over the .o files, you follow the recommended procedure
the author descibes in the porting notes, you will get a clean compile as
the author says but then when you try to do a "make install" or try to run
scotty you will get the following error:

ld.so: Undefined symbol: __res
*** Error code 127
make: Fatal error: Command failed for target `tnm-install-library' -- for
the "make install"

The reason for this is pretty simple. The author of the porting notes says:

>The easiest way is to add the following lines to the Makefile between
>TNM_GENERIC_OBJS and SNMP_SRCS


>RES_OBJS = gethnamaddr.o getnetent.o nsap_addr.o res_init.o \
> res_send.o getnetbyaddr.o getnetnamadr.o res_comp.o \
> res_mkquery.o sethostent.o getnetbyname.o herror.o \
> res_debug.o res_query.o

>now type make again to complete the build.

This is incorrect in a couple of ways. First of all, this will add the
variable RES_OBJS, but the author never says that you need to include that
variable in the link! You'll still get a binary that doesn't include all
the library code its supposed to. Second, the author only lists a few of
the object mods that are in the bind4.9.4/res directory. If you don't link
them all in, you'll still get undefined symbol errors for varying symbols
during install or run.

ahhhh, the frustration!

Anyway, here are my SUGGESTIONS for improving the notes:
( Barring of course any obvious human errors ;0) )

1. After untarring the scotty archive, get the bind-4.9.4 (DO NOT USE
4.9.5) package
from ftp.vix.com. It is available at ftp.vix.com. cd into the res
directory. Edit the Makefile
and add -DSPRINTF_CHAR -DSUNOS -DSUNSECURITY and -PIC to the CFLAGS line.
Comment out lines 103-104 by putting a # at the beginning of the line.
These lines should
appear like this when you're finished:

# -${LDS} ld -x -r $*.o
# ${LDS} mv a.out $*.o

(The SunPRO compiler will give errors, I reccomend gcc or the SunOS cc.)

4. You now have a group of .o files and a libresolv.a library in the
res directory, you will need to include these later in the link to produce
the tnm.so library for scotty. So, take all the .o files from the res
directory
and copy them into the scotty unix directory.

1. Configure and build normally. At the end you will get an error
linking tnm.so about mixing pic and PIC .o files.

2. Edit the Makefile and go to the lines that say:

tnm$(SHLIB_SUFFIX): $(TNM_OBJS)
$(SHLIB_LD) $(TNM_OBJS) -o tnm$(SHLIB_SUFFIX) $(LIBS)
$(OSIMIS_LIBS) $(MSQL_LIBS) $(GDMO_LIBS)

Change them to read:
tnm$(SHLIB_SUFFIX): $(TNM_OBJS)
$(SHLIB_LD) -assert pure-text -o tnm$(SHLIB_SUFFIX) $(TNM_OBJS)

Do the same with the lines that say:

tkined$(SHLIB_SUFFIX): $(TKI_GENERIC_OBJS)
$(SHLIB_LD) $(TKI_GENERIC_OBJS) -o tkined$(SHLIB_SUFFIX) $(LIBS)

and change them to say:

tkined$(SHLIB_SUFFIX): $(TKI_GENERIC_OBJS)
$(SHLIB_LD) -assert pure-text -o tkined$(SHLIB_SUFFIX)
$(TKI_GENERIC_OBJS)


Also delete the "-lresolv" word from the LIBS line in the Makefile

Find the lines which say:

3. You now need to make sure the linker also links the libraries from the
bind/res stuff. To
do this, add them to TNM_GENERIC_OBJS.

IE. Change the lines which say:

TNM_GENERIC_OBJS = tnmInit.o tnmUtil.o tnmJob.o tnmIned.o \
tnmSyslog.o tnmIcmp.o tnmDns.o tnmEvent.o \
tnmUdp.o tnmSunRpc.o tnmNtp.o tnmRpc.o tnmHttp.o \
tnmNetdb.o tnmUnixInit.o tnmUnixLog.o \
tnmUnixSocket.o tnmUnixIcmp.o \
mount_clnt.o mount_xdr.o ether_clnt.o ether_xdr.o \
rstat_clnt.o rstat_xdr.o pcnfsd_clnt.o pcnfsd_xdr.o

to read like this:

TNM_GENERIC_OBJS = tnmInit.o tnmUtil.o tnmJob.o tnmIned.o \
tnmSyslog.o tnmIcmp.o tnmDns.o tnmEvent.o \
tnmUdp.o tnmSunRpc.o tnmNtp.o tnmRpc.o tnmHttp.o \
tnmNetdb.o tnmUnixInit.o tnmUnixLog.o \
tnmUnixSocket.o tnmUnixIcmp.o herror.o \
mount_clnt.o mount_xdr.o ether_clnt.o ether_xdr.o \
rstat_clnt.o rstat_xdr.o pcnfsd_clnt.o pcnfsd_xdr.o \
gethnamaddr.o getnetbyaddr.o getnetbyname.o getnetent.o \
getnetnamadr.o hostnamelen.o inet_addr.o inet_ntop.o \
inet_pton.o nsap_addr.o res_comp.o res_data.o res_debug.o \
res_init.o res_mkquery.o res_query.o res_send.o
sethostent.o

4. Now type make again to complete the build.

5. Type "make install"

Note: Also in trying to figure out what the author of the notes meant, I
naturally consulted the tkined list archive, but found, rather to my
confusion, that the author simply referred people to the porting notes
whenever they experienced the same problems I was having. Might I suggest
to the author that if you follow your own porting notes and get the same
error that the poster gets, then the notes may be in error. In other words,
the author may need to RTFM. ;0)

----------------------------------------------------------------------------
-----
Kevin Trotman phone: 972-952-3272
System Administrator pager: 214-314-3134
Raytheon TI Systems email: ktrotman@ti.com
Beowulf was not of the land that he fought and defeated Grendel...
----------------------------------------------------------------------------
-----

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.