.key lib
.def lib "FFP"

; This script makes the entire plplot library.  It should be invoked via
; "execute make-all [FFP | IEEEF | IEEED]". If FFP (the default) is
; specified then PLFLT is typedef'd to float and the fast floating point
; math routines are to be used. If IEEEF then PLFLT is still typedef'd
; to float but the IEEE math routines are to be used.  Finally if IEEED
; is specified then PLFLT is double and the IEEE math routines are to be
; used.

if not "<lib>" eq "FFP"
   if not "<lib>" eq "IEEEF"
      if not "<lib>" eq "IEEED"
            echo "usage: execute make-all [FFP | IEEEF | IEEED]"
            skip end
      endif
   endif
endif

; Make the FFP library.
if "<lib>" eq "FFP"
   ask "Are you sure you want to (re)make the complete FFP library? (y or n)"
   if not warn
      skip end
   endif

   if exists /pllibs/plpffp.lib
      delete /pllibs/plpffp.lib
   endif

   cd /src
   lmk LFLG1=-ff
   list >ofiles #?.o lformat="%s"
   oml /pllibs/plpffp.lib r @ofiles
   delete ofiles

   cd /drivers
   lmk LFLG1=-ff
   list >ofiles #?.o lformat="%s"
   oml /pllibs/plpffp.lib r @ofiles
   delete ofiles

   cd /Amiga
   lmk LFLG1=-ff
   list >ofiles #?.o lformat="%s"
   oml /pllibs/plpffp.lib r @ofiles
   delete ofiles

   cd /lattice
endif

; Create the IEEE library with "float" floating point variables.
; Unfortunately there is a bug involving prototypes and float's in Lattice 5.04.
; (The calling function promotes all float's to double's in spite of the
; prototype while the called function expects a float.) I get around this
; and still get prototyping by creating the library without prototyping in
; effect (so that the conventional C conversions occur). Prototypes can still
; be used when linking your driver to the library. This works but causes the
; library to be larger than it normally would be. (I have reported this
; bug to Lattice by the way.)
if "<lib>" eq "IEEEF"
   ask "Are you sure you want to (re)make the complete IEEEF library? (y or n)"
   if not warn
      skip end
   endif

   if exists /pllibs/plplcmf.lib
      delete /pllibs/plplcmf.lib
   endif

   cd /src
   lmk LFLG1=-dNOPROTS
   list >ofiles #?.o lformat="%s"
   oml /pllibs/plplcmf.lib r @ofiles
   delete ofiles

   cd /drivers
   lmk LFLG1=-dNOPROTS
   list >ofiles #?.o lformat="%s"
   oml /pllibs/plplcmf.lib r @ofiles
   delete ofiles

   cd /Amiga
   lmk LFLG1=-dNOPROTS
   list >ofiles #?.o lformat="%s"
   oml /pllibs/plplcmf.lib r @ofiles
   delete ofiles

   cd /lattice
endif

; Make the IEEE library with "double" floating point variables.
if "<lib>" eq "IEEED"
   ask "Are you sure you want to (re)make the complete IEEED library? (y or n)"
   if not warn
      skip end
   endif

   if exists /pllibs/plplcmd.lib
      delete /pllibs/plplcmd.lib
   endif

   cd /src
   lmk LFLG1=-dPLDBL
   list >ofiles #?.o lformat="%s"
   oml /pllibs/plplcmd.lib r @ofiles
   delete ofiles

   cd /drivers
   lmk LFLG1=-dPLDBL
   list >ofiles #?.o lformat="%s"
   oml /pllibs/plplcmd.lib r @ofiles
   delete ofiles

   cd /Amiga
   lmk LFLG1=-dPLDBL
   list >ofiles #?.o lformat="%s"
   oml /pllibs/plplcmd.lib r @ofiles
   delete ofiles

   cd /lattice
endif

lab end
