# Makefile for the Computer Graphics Metafile (CGM) backend to XGKS
#
# $Id: Makefile,v 1.6 1991/10/18 14:10:28 steve Exp $

# Anticipated, changeable macros (others might not work):
COPTS	= -O
DESTDIR	= /usr/local/ldm#	assumed to contain "bin", "include",
#				"lib", and "man" subdirectories
LIBTYPE	= sharable#		"nonsharable" or "sharable"
OS	= sunos_4.1.1
RANLIB	= ranlib

# End of anticipated macros

# The following macro is for passing the above, "anticipated" macros to
# make(1)s invoked by this makefile (i.e. recursive make(1)s).
# 
# There is, however, a problem.  The placement of macro re-definitions on
# a make(1) command-line is significant: when more than one definition
# for a given macro is given, the one that takes effect depends on the
# peculiarities of the particular make(1).  For example, the SunOS 4.1
# make(1) takes the last re-definition, whereas the 4.0.3 make(1) takes
# the first.  Consequently, those actions in this makefile that need to
# redefine certain macros, do not use the macro MY_MFLAGS; instead
# they explicitly reproduce the following list.  Therefore, if you add or
# remove macros from this list, be sure to do the same to those actions
# just mentioned.  Also, don't attempt to redefine any of the following
# macros on a make(1) command-line if you also use the MY_MFLAGS macro on
# the command-line.
#
MY_MFLAGS	= \
		COPTS="$(COPTS)" \
		DESTDIR="$(DESTDIR)" \
		LIBTYPE="$(LIBTYPE)" \
		OS="$(OS)" \
		RANLIB="$(RANLIB)"

# Directories:
X11_INCDIR	= $${OPENWINHOME-/usr}/include
UNICOS_INC	= `case $(OS) in unicos*) echo -I/usr/include/stdc;; esac`
INCLUDES	= -I.. -I$(DESTDIR)/include/udposix -I$(X11_INCDIR) \
		  $(UNICOS_INC)
DEFINES		=
CPPOPTS		= $(INCLUDES) $(DEFINES)
CFLAGS		= $(CPPOPTS) $(COPTS)
SHELL		= /bin/sh

CSRCS		= cgmi.c cgmo.c

LNS		= cgmi.ln cgmo.ln

HSRCS		= cgm.h cgm_implem.h

SOURCES		= $(CSRCS) $(HSRCS) Makefile

OBJECTS		= cgmi.o cgmo.o

.PHONY:         all install clean

all:		$(LIBTYPE)_lib

install:

clean:
	rm -f core *.o *.log *.ln

nonsharable_lib:
	@$(MAKE) $(MFLAGS) $(MY_MFLAGS) $(OBJECTS)

sharable_lib:
	@case "$(OS)" in \
	    sunos*) \
		$(MAKE) $(MFLAGS) \
		    COPTS="$(COPTS) -pic" \
		    DESTDIR="$(DESTDIR)" \
		    LIBTYPE="$(LIBTYPE)" \
		    OS="$(OS)" \
		    RANLIB="$(RANLIB)" \
		    $(OBJECTS);; \
	    *) \
		$(MAKE) $(MFLAGS) $(MY_MFLAGS) $(OBJECTS);; \
	esac

lint:		$(LNS)
	lint -nuz $(LNS) -lansic -lposix 2>&1

.SUFFIXES:	.ln .c

.c.ln:
	lint -nuz $(CPPOPTS) -c $< -lansic -lposix 2>&1

tags:
	ctags -t $(CSRCS) $(HSRCS)

.DEFAULT:
	co $@

cgmi.ln: cgm.h
cgmi.o: cgmi.c
cgmi.o: ../gks_implem.h
cgmi.o: ../xgks.h
cgmi.o: ../gks_defines.h
cgmi.o: ../primitive.h
cgmi.o: ../input.h
cgmi.o: ../wdt.h
cgmi.o: ../wslist.h
cgmi.o: ../gkslist.h
cgmi.o: ../gks_errors.h
cgmi.o: ../event.h
cgmi.o: cgm.h
cgmi.o: cgm_implem.h
cgmo.ln: cgm.h
cgmo.o: cgmo.c
cgmo.o: ../gks_implem.h
cgmo.o: ../xgks.h
cgmo.o: ../gks_defines.h
cgmo.o: ../primitive.h
cgmo.o: ../input.h
cgmo.o: ../wdt.h
cgmo.o: ../wslist.h
cgmo.o: ../gkslist.h
cgmo.o: ../gks_errors.h
cgmo.o: ../event.h
cgmo.o: cgm.h
cgmo.o: cgm_implem.h
