#
# Makefile for vogle
#
# Usage: make os
#
# You might have to set:
#
#	OS
#	RANLIB
#	MCFLAGS
#	MCFLAGS
#	F77
#	MFFLAGS
#
############################################################
#
# You can set -DBSD or -DSYS5 here
#
#OS = -DBSD

# If you set -DSYS5 then set RANLIB = "ar ts"
#RANLIB = ar ts

#
# Global CFLAGS can be set here. These are the ones we use on a sun.
#
#MCFLAGS = -g $(OS) 
MCFLAGS = $(OS) -O4 -fsingle /usr/lib/libm.il
#MCFLAGS = $(OS) -O4 -fsingle -f68881 /usr/lib/libm.il
#
# Or on an apollo... (-Wp make it use the 'other cpp')
#MCFLAGS = $(OS) -O -Wp -M3000

#
# If we have fortran we have to say so.
#
F77 = f77
# Global FFLAGS can be set here. These are the ones we use on a sun.
#
MFFLAGS = $(OS) -O4 /usr/lib/libm.il
#MFFLAGS = $(OS) -O4 -f68881 /usr/lib/libm.il

#
# The name of the library to install and where to put it.
#
LIB = libvopl.a
DEST = /usr/lib

#
# Any other libraries that are needed go here
#

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


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

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

sun:
	cd src; make -f Makefile \
			MCFLAGS="$(MCFLAGS)"

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

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

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

X11:
	cd src; make -f Makefile \
			MCFLAGS="$(MCFLAGS)" 

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

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

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

apollo:
	cd src; make -f Makefile \
			MCFLAGS="$(MCFLAGS)"

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

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

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

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

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

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

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

clean:
	cd src; make clean
	cd examples; make clean
	cd examples; make -f Makefile.f77 clean
	cd gpp; make clean

clobber:
	cd src; make clobber
	cd examples; make clobber
	cd examples; make -f Makefile.f77 clobber
	cd gpp; make clobber
