Update the m3build templates for FreeBSD-2.1 and later.

Index: m3/m3build/templates/COMMON
--- COMMON.orig	Fri Feb  9 14:23:04 1996
+++ COMMON	Fri Oct 25 13:48:57 1996
@@ -998,7 +998,7 @@
   if HAVE_PKGTOOLS
     _install_file (src, dest, "0755", "T")
   else
-    local target = format ("%s%s%s%s%s%s%s", PKG_USE, SL, BUILD_PACKAGE,
+    local target = format ("%s%s%s%s%s%s%s", LIB_TO_PKG, SL, BUILD_PACKAGE,
                                              SL, BUILD_DIR, SL, src)
     local link = format ("%s%s%s", dest, SL, src)
     >> M3SHIP_FILE in
Index: m3/m3build/templates/FreeBSD2
--- FreeBSD2.orig	Thu Jun 20 12:17:07 1996
+++ FreeBSD2	Fri Oct 25 13:47:16 1996
@@ -8,8 +8,9 @@
 %      Modified On Thu Apr  8 13:45:49 PDT 1993 by muller
 %
 %      Sun Nov 27 20:19:31 MET 1994 by ow
+%      Fri Feb  2 15:04:50 PST 1996 by jdp@polstra.com
 %
-% FreeBSD 2.0 configuration (with shared library support in comments)
+% FreeBSD 2.1 and 2.2 configuration, with shared library support
 %
 
 %-------------------------------------------------- compilation environment ---
@@ -44,6 +45,8 @@
 MAN_INSTALL   = INSTALL_ROOT & "man"                % man pages
 HTML_INSTALL  = INSTALL_ROOT & "lib/m3/www"         % public hypertext
 
+WDROOT = $HOME & "/m3/pkg"		% handy default for overrides
+
 % The manual pages normally go in subdirectories man{1,...8} of
 % the MAN_INSTALL directory.  If you prefer to have them all in
 % a single section, define MAN_SECTION to be that section's name.
@@ -56,7 +59,12 @@
 LIB_USE   = LIB_INSTALL
 PKG_USE   = PKG_INSTALL
 
-readonly INSTALL_IMPLS = "TRUE"
+% This is a relative path from LIB_USE to PKG_USE, so that we can avoid
+% installing absolute symbolic links.  If you cannot support such relative
+% links, then make it the same as PKG_USE.
+LIB_TO_PKG = "../pkg"
+
+readonly INSTALL_IMPLS = ""
 % "TRUE"
 %    => save all source files during the install
 %    => makes debugging easier and browsing more fruitful
@@ -90,15 +98,17 @@
 % "import_TCP" is called from the tcp package.
 
 readonly proc import_X11R4() is
-  import_lib("Xaw",  "/usr/X386/lib")
-  import_lib("Xmu",  "/usr/X386/lib")
-  import_lib("Xext", "/usr/X386/lib")
-  import_lib("Xt",   "/usr/X386/lib")
-  import_lib("X11",  "/usr/X386/lib")
+  import_lib("Xaw",    "/usr/X11R6/lib")
+  import_lib("Xmu",    "/usr/X11R6/lib")
+  import_lib("Xt",     "/usr/X11R6/lib")
+  import_lib("SM",     "/usr/X11R6/lib")
+  import_lib("ICE",    "/usr/X11R6/lib")
+  import_lib("Xext",   "/usr/X11R6/lib")
+  import_lib("X11",    "/usr/X11R6/lib")
 end
 
 readonly proc import_Motif() is
-  import_lib("Xm",   "/usr/X386/lib")
+  import_lib("Xm",   "/usr/X11R6/lib")
 end
 
 readonly proc import_DECPEX() is
@@ -128,9 +138,9 @@
 % entire function.  Note, the distributed code assumes gnuemacs version 19
 % or later.
 
-readonly proc emacs_compile (el) is
-  exec ("emacs -batch -f batch-byte-compile", el)
-end
+%readonly proc emacs_compile (el) is
+%  exec ("emacs -batch -f batch-byte-compile", el)
+%end
 
 %---------------------------------------------------- C compiler and linker ---
 % The following definitions are used to compile and link C modules.
@@ -142,33 +152,27 @@
 % The actual definitions must be kept on one line due to finicky details
 % of the bootstrap process.
 
-
-%% The versions of ar and ranlib shipped with FreeBSD 2.0
-%% definitelty do not work with the Modula-3 archives.
-%% ar sometimes complains about `too many open files' and
-%% ranlib often says `inappropriate file type for object'.
-%% I haven't looked into this further, since newer versions
-%% of the GNU binutils package work quite well. - Olaf Wagner 2/13/95
-
-
-CC = _ifdef ("CC", CC, [ "gcc" ])
+CC = _ifdef ("CC", CC, [ "cc", "-fpic" ])
 %--- C compiler with flags for compiling a single ".c" file
-% ------ FOR SHARED LIBS, add -fPIC 
 
-LINK = _ifdef ("LINK", LINK, [ "gcc" ])
+LINK = _ifdef ("LINK", LINK, [ "ld", "-e", "start", "-dc", "-dp", "/usr/lib/crt0.o" ])
 %--- C compiler with flags for linking
-% ------ FOR SHARED LIBS, add -Xlinker -Bdynamic
 
-MAKELIB = _ifdef ("MAKELIB", MAKELIB, [ "/usr/bin/ar", "cru" ])
+MAKELIB = _ifdef ("MAKELIB", MAKELIB, [ "ar", "cru" ])
 %--- program to build library archives
 
 RANLIB = _ifdef ("RANLIB", RANLIB, [ "ranlib" ])
 %--- program to index libraries
 
-ASM = _ifdef ("ASM", ASM, [ "/usr/bin/as" ])
+ASM = _ifdef ("ASM", ASM, [ "as", "-k" ])
 %--- assembler
-% ------ FOR SHARED LIBS with /usr/bin/as from the FreeBSD distribution,
-%        add -k -W
+
+BOOT_LINK = _ifdef ("BOOT_LINK", BOOT_LINK, [ "cc" ])
+%--- C compiler with flags for linking, used during the bootstrap process.
+% We have to use "cc" for the bootstrap, because the "-z2" option
+% ("libraries systematically linked with all programs") doesn't get used
+% during the bootstrap process.  If we use "ld", then the C library isn't
+% linked in.
 
 %------------------------------------------------------------- GNU variants ---
 % The two large pieces of GNU software used by the Modula-3 system
@@ -179,9 +183,9 @@
 % To use the GNU defaults for CC and CFLAGS, specify "*".
 %
 
-GNU_CC     = _ifdef ("GNU_CC",     GNU_CC,     "*")
-GNU_CFLAGS = _ifdef ("GNU_CFLAGS", GNU_CFLAGS, "*")
-GNU_MAKE   = _ifdef ("GNU_MAKE",   GNU_MAKE,   "gmake")
+GNU_CC     = _ifdef ("GNU_CC",     GNU_CC,     "cc")
+GNU_CFLAGS = _ifdef ("GNU_CFLAGS", GNU_CFLAGS, "-O")
+GNU_MAKE   = _ifdef ("GNU_MAKE",   GNU_MAKE,   "make")
 
 %-------------------------------------------------------- Modula-3 compiler ---
 % The syntax for the values passed to most of the M3_CONFIG options is
@@ -192,7 +196,8 @@
 M3 = LIB_USE & "/m3"
 
 % What are the standard flags?
-M3OPTIONS = [ "-w1", "-why", "-g" ]
+M3OPTIONS = [ "-w1", "-why", "-O" ]
+% ------ FOR DEBUGGING INFO, add "-g"
 
 M3_CONFIG = [
    "-Y1" & _pack_args (CC),
@@ -201,11 +206,11 @@
    "-Y4" & _pack_args (RANLIB),
    "-Y7" & _pack_args (ASM),
 
-   "-Y6@" & LIB_USE & "/m3cgc1@-quiet@",
+   "-Y6@" & LIB_USE & "/m3cgc1@-quiet@-fpic@",
    % --- the Modula-3 IL to assembly language pass
-   % ------ FOR SHARED LIBS, add -fPIC
 
-   "-z2@-lm@",  % --- libraries systematically linked with all programs
+   "-z2@-lm@/usr/lib/libgcc.a@-lc@/usr/lib/libgcc.a@",
+   % --- libraries systematically linked with all programs
 
    "-z3" & LIB_USE & SL & "report_coverage.o",
    % --- library linked in programs compiled with "-Z" coverage option
@@ -248,7 +253,7 @@
    % passes in a file and then deletes the file, unless "-keep" or
    % "-verbose" is specified.
 
-   "-zK0",
+   "-zK1",
    % --- Set the value of "-zK" to "1" if you want the m3 driver to
    %     supply -Bdynamic/-Bstatic options to the linker, "0" otherwise.
 
@@ -263,9 +268,9 @@
 
 proc build_standalone() is
    % --- reset the linker to avoid shared libraries.
-   M3_CONFIG += "-Y2@cc@-static@"
    M3_CONFIG += "-Y6@" & LIB_USE & "/m3cgc1@-quiet@"
-   M3_CONFIG += "-Y7@/usr/bin/as@"
+   M3_CONFIG += "-Y7@as@"
+   M3_CONFIG += "-Bstatic"
 end
 
 proc build_shared() is
@@ -282,7 +287,7 @@
 
 proc after_library_hooks(x) is
   local lib_a  = format ("lib%s.a", x)
-  local lib_so = format ("lib%s.so.1.1", x)
+  local lib_so = format ("lib%s.so.5.0", x)
   local dest = format ("%s%s%s%s%s", PKG_INSTALL, SL, BUILD_PACKAGE,
                                                       SL, BUILD_DIR)
 
@@ -291,7 +296,7 @@
       write ("missing ", lib_a, ": not building ", lib_so, CR)
     else
       if stale (lib_so, lib_a)
-        exec ("/usr/bin/ld -Bshareable -assert pure-text -o",
+        exec ("ld -Bshareable -assert pure-text -o",
                  lib_so, COMPILE_OBJECTS)
       end
       install_derived (lib_so)
