Subject: Re `Changes to /usr/share/mk/* for Cross-Compiling'
To: None <current-users@NetBSD.ORG>
From: Alan Peakall <alan@parsys.co.uk>
List: current-users
Date: 04/30/1996 09:19:47
Curt Sampson <curt@ca.portal>:

>>  In addition to mkdep, I've discovered a few other programs that
>>  might cause problems depending on what platform one is cross-compiling
    ...
>>  Tsort has added a -q option since 1.0. I'm inclined toward adding
>>  ${TSORT} and ${TSORTFLAGS} and putting it in the cross-compililation

Flagging `tsort' brings to mind the fact that `lorder' is hiding a use `nm'.
This is an issue that we (Parsys) have previously encountered in cross
development builds.  I have tackled it by implementing a suggestion from
a colleague that `lorder' should peek the first object module using
`file(1)' in order to determine which version of `nm(1)' to use.

The additional code is roughly as follows:

----    ----    ----    CUT HERE    ----    ----    ----
case $# in
  0)
    echo 2>&1 "usage: $prog <file> ..."
    exit 1
    ;;
  # Only one argument is a special case - just output the name twice.
  1)
    echo $1 $1
    exit 0
    ;;
  *)
    # Create a custom alternative `/etc/magic' in order that
    # the magic number list and tags are explicit in this file,
    # for maintainability.  SunOS sparc is currently done as
    # the default merely because I could not be bothered to write the
    # correct record for it.
    cat <<\+ >$M
0       short           0x8301  COFF_ALPHA
#       implement me            SUNOS_SPARC
0       long            0x7F454C46      SOLARIS_SPARC
0       short&0xFFF7    0x9970  IDRIS_T800_NONSHARED
0       short&0xFFF7    0x9960  IDRIS_T800
0       short           0x8ACE  IDRIS_T800_ACE
0       short&0xFFF7    0x9910  IDRIS_T9000_NONSHARED
0       short&0xFFF7    0x9900  IDRIS_T9000
0       short           0x9ACE  IDRIS_T9000_ACE
+
    ftype="`file -m $M $1 | sed 's,^[^  ]*:[    ]*,,'`"
    rm -f $M
    case $ftype in
      COFF_ALPHA)
	NM=/opt/gnu/alpha/cross/bin/nm
	nm_format_type=BSD
        ;;
     SOLARIS_SPARC)
	NM=/usr/ccs/bin/nm
	nm_format_type=SYSV
        ;;
. . .
----    ----    ----    CUT HERE    ----    ----    ----

The variable `nm_format_type' is tested lower in the script to
determine whether to run an `awk' script to map SYS-V style `nm'
output to BSD style so that the generic `sed/sort/sort/join' code will
cope with it.  I am not going to exhibit this code as I know
that there are plenty of people who can do this much more efficiently
in `sed' :-)

On a separate issue:

>>  Does install change enough between systems to warrant putting it
>>  into the toolset?

YES !!  On DEC OSF1V3.2 one sees:

$ ls -li /usr/ucb/install /usr/bin/install /usr/ucb/installbsd
121193 -rwxr-xr-x   1 bin      bin        21485 Feb  3  1995 /usr/bin/install
121193 -rwxr-xr-x   1 bin      bin        21485 Feb  3  1995 /usr/ucb/install
121194 -rwxr-xr-x   1 bin      bin         4636 Feb  3  1995 /usr/ucb/installbsd

ie the default `install' IN `/usr/ucb' is NOT a BSD one :-( .

Even `/usr/ucb/installbsd' removes the installed file from the current
directory which `/bin/install' on SunOS does not.