#
# Makefile for vogle
#
# Usage: make os
#
# You might have to set:
#
#       DEVICES
#       FONTLIB
#       OS
#       RANLIB
#       CFLAGS
#       FLOATING_POINT
#       F77                     <== If you want the f77 examples
#       FFLAGS                      "   "   "    "   "     "
#       PAS                     <== If you want the SUN Pascal examples
#       PFLAGS                      "   "   "    "   "    "       "
#
############################################################
#
# The Devices you want compiled into the library.
# (Note the "make sun" automatically includes -DSUN later on)
#
DEVICES = -DPOSTSCRIPT -DDXY -DHPGL -DTEK
#
# Where the fonts a going to live
#
FONTLIB = /usr/local/lib/hershey/
#FONTLIB = /tmp/

#
# You can set -DBSD or -DSYS5 here
#
#OS = -DBSD

RANLIB = ranlib
# If you set -DSYS5 then set RANLIB = "ar ts" or maybe "echo" in later versions
#RANLIB = echo

#
# Set your floating point options here...
#
FLOATING_POINT = /usr/lib/libm.il -f68881
#
# For most machines...
#FLOATING_POINT =

#
# Global CFLAGS can be set here. These are the ones we use on a sun.
#
CFLAGS = $(OS) -O4 -fsingle

#
# For SUNOS 3.5 set -DSUN_3_5
#
#CFLAGS = $(OS) -O4 -DSUN_3_5

#
# For SGI's
#
#CFLAGS = $(OS) -O -float

#
# Or on an apollo... (-Wp make it use the 'other cpp')
#CFLAGS = $(OS) -O -Wp -M3000

#
# Or on a Decstation (running Ultrix of course)
#CFLAGS = -O $(OS) -f

#
# Or an IBM RS6000
#
#CFLAGS = $(OS) -O -Q

#
# Define F77 if you want the f77 examples.
# You also define your f77 flags here too. These are the ones we used on sun
#
F77 = f77
FFLAGS = -g
#
# Or on an apollo (We didn't have ftn)
#F77 =
#FFLAGS =

#
# Or on an IBM RS6000
#
#F77 = xlf
#FFLAGS = -O -qextname

#
# Define PAS if you want the SUN pascal examples.
# You also define your Pascal Compiler flags here too.
#
#PAS = pc
#PFLAGS = -O -f68881
#
# The name of the library to install and where to put it.
#
LIB = libvogle.a
DEST = /usr/local/lib

#
# Some dork machines made /bin/csh the default shell and didn't change`
# the man page for make did they now....
#
SHELL = /bin/sh

#
# Any other libraries that are needed go here
#

SUNLIBS = -lsuntool -lsunwindow -lpixrect
X11LIBS = -lX11
UNIXLIBS =
APOLLOLIBS =

MCFLAGS = $(CFLAGS) $(FLOATING_POINT)
MFFLAGS = $(FFLAGS) $(FLOATING_POINT)
MPFLAGS = $(PFLAGS)

all:
        @echo "Usage: 'make sun' or 'make X11' or 'make sun-X11' or 'make dec-X11' or 'make unix' or 'make apollo'"

install:
        cp src/$(LIB) $(DEST)
        chmod 644 $(DEST)/$(LIB)
        $(RANLIB) $(DEST)/$(LIB)

installgcc:
        copy src/libvogle.a lib:

intstalldcc:
        copy src/vogle.lib dlib:

sun:
        cd src; make -f Makefile \
                        DEVICES="$(DEVICES) -DSUN" \
                        FONTLIB="$(FONTLIB)" \
                        MCFLAGS="$(MCFLAGS)" \
                        DOBJS="../drivers/sun.o"\
                        RANLIB="$(RANLIB)"

        cd examples; make -f Makefile \
                        MCFLAGS="$(MCFLAGS)" \
                        LIBS="$(SUNLIBS)"


        cd hershey/src; make -f Makefile \
                        FONTLIB="$(FONTLIB)" \
                        MCFLAGS="$(MCFLAGS)" \
                        LIBS="$(SUNLIBS)"

        if test -n "$(F77)" ; \
        then cd examples; make -f Makefile.f77 \
                        LIBS="$(SUNLIBS)" \
                        MFFLAGS="$(MFFLAGS)" \
                        F77="$(F77)" ; \
        fi ; exit 0

        if test -n "$(PAS)" ; \
        then cd examples; make -f Makefile.pas \
                        LIBS="$(SUNLIBS)" \
                        MPFLAGS="$(MPFLAGS)" \
                        PAS="$(PAS)" ; \
        fi ; exit 0

X11:
        cd src; make -f Makefile \
                        DEVICES="$(DEVICES) -DX11" \
                        FONTLIB="$(FONTLIB)" \
                        MCFLAGS="$(MCFLAGS)" \
                        DOBJS="../drivers/X11.o" \
                        RANLIB="$(RANLIB)"

        cd examples; make -f Makefile \
                        MCFLAGS="$(MCFLAGS)" \
                        LIBS="$(X11LIBS)"

        cd hershey/src; make -f Makefile \
                        FONTLIB="$(FONTLIB)" \
                        MCFLAGS="$(MCFLAGS)" \
                        LIBS="$(X11LIBS)"

        if test -n "$(F77)" ; \
        then cd examples; make -f Makefile.f77 \
                        LIBS="$(X11LIBS)" \
                        MFFLAGS="$(MFFLAGS)" \
                        F77="$(F77)" ; \
        fi ; exit 0

        if test -n "$(PAS)" ; \
        then cd examples; make -f Makefile.pas \
                        LIBS="$(X11LIBS)" \
                        MPFLAGS="$(MPFLAGS)" \
                        PAS="$(PAS)" ; \
        fi ; exit 0

sun-X11:
        cd src; make -f Makefile \
                        DEVICES="$(DEVICES) -DX11 -DSUN" \
                        FONTLIB="$(FONTLIB)" \
                        MCFLAGS="$(MCFLAGS)" \
                        DOBJS="../drivers/X11.o ../drivers/sun.o" \
                        RANLIB="$(RANLIB)"

        cd examples; make -f Makefile \
                        MCFLAGS="$(MCFLAGS)" \
                        LIBS="$(X11LIBS) $(SUNLIBS)"

        cd hershey/src; make -f Makefile \
                        FONTLIB="$(FONTLIB)" \
                        MCFLAGS="$(MCFLAGS)" \
                        LIBS="$(X11LIBS) $(SUNLIBS)"

        if test -n "$(F77)" ; \
        then cd examples; make -f Makefile.f77 \
                        LIBS="$(X11LIBS) $(SUNLIBS)" \
                        MFFLAGS="$(MFFLAGS)" \
                        F77="$(F77)" ; \
        fi ; exit 0

        if test -n "$(PAS)" ; \
        then cd examples; make -f Makefile.pas \
                        LIBS="$(X11LIBS) $(SUNLIBS)"
                        MPFLAGS="$(MPFLAGS)" \
                        PAS="$(PAS)" ; \
        fi ; exit 0

dec-X11:
        cd src; make -f Makefile \
                        DEVICES="$(DEVICES) -DX11 -DDECX11" \
                        FONTLIB="$(FONTLIB)" \
                        MCFLAGS="$(MCFLAGS)" \
                        DOBJS="../drivers/X11.o ../drivers/decX11.o"
                        RANLIB="$(RANLIB)"

        cd examples; make -f Makefile \
                        MCFLAGS="$(MCFLAGS)" \
                        LIBS="$(X11LIBS)"


        cd hershey/src; make -f Makefile \
                        FONTLIB="$(FONTLIB)" \
                        MCFLAGS="$(MCFLAGS)" \
                        LIBS="$(X11LIBS)"

        if test -n "$(F77)" ; \
        then cd examples; make -f Makefile.f77 \
                        LIBS="$(X11LIBS)" \
                        MFFLAGS="$(MFFLAGS)" \
                        F77="$(F77)" ; \
        fi ; exit 0

apollo:
        cd src; make -f Makefile \
                        DEVICES="$(DEVICES) -DAPOLLO" \
                        FONTLIB="$(FONTLIB)" \
                        MCFLAGS="$(MCFLAGS)" \
                        DOBJS="../drivers/apollo.o"
                        RANLIB="$(RANLIB)"

        cd examples; make -f Makefile \
                        LIBS="$(APOLLOLIBS)" \
                        MCFLAGS="$(MCFLAGS)"


        cd hershey/src; make -f Makefile \
                        FONTLIB="$(FONTLIB)" \
                        LIBS="$(APOLLOLIBS)" \
                        MCFLAGS="$(MCFLAGS)"

        if test -n "$(F77)" ; \
        then cd examples; make -f Makefile.f77 \
                        MFFLAGS="$(MFFLAGS)" \
                        LIBS="$(APOLLOLIBS)" \
                        F77="$(F77)" ; \
        fi ; exit 0

unix:
        cd src; make -f Makefile \
                        DEVICES="$(DEVICES)" \
                        FONTLIB="$(FONTLIB)" \
                        MCFLAGS="$(MCFLAGS)" \
                        DOBJS=""\
                        RANLIB="$(RANLIB)"

        cd examples; make -f Makefile \
                        MCFLAGS="$(MCFLAGS)" \
                        LIBS="$(UNIXLIBS)"


        cd hershey/src; make -f Makefile \
                        FONTLIB="$(FONTLIB)" \
                        MCFLAGS="$(MCFLAGS)" \
                        LIBS="$(UNIXLIBS)"

        if test -n "$(F77)" ; \
        then cd examples; make -f Makefile.f77 \
                        LIBS="$(UNIXLIBS)" \
                        MFFLAGS="$(MFFLAGS)" \
                        F77="$(F77)" ; \
        fi ; exit 0

gcc:
        cd src
        make -f Makefile.gcc
        cd /examples
        make -f Makefile.gcc
        cd /hershey/src
        make -f Makefile.gcc
        cd //

dcc:
        cd src
        make -f Makefile.dcc
        cd /examples
        make -f Makefile.dcc
        cd /hershey/src
        make -f Makefile.dcc
        cd //

clean:
        cd src; make clean
        cd hershey/src; make clean
        cd drivers; make clean
        cd examples; make clean
        cd examples; make -f Makefile.f77 clean
        cd examples; make -f Makefile.pas clean

clobber:
        cd src; make clobber
        cd hershey/src; make clobber
        cd drivers; make clobber
        cd examples; make clobber
        cd examples; make -f Makefile.f77 clobber
        cd examples; make -f Makefile.pas clobber
