# This file is a product of Sun Microsystems, Inc. and is provided for
# unrestricted use provided that this legend is included on all tape
# media and as a part of the software program in whole or part.  Users
# may copy or modify this file without charge, but are not authorized to
# license or distribute it to anyone else except as part of a product
# or program developed by the user.
# 
# THIS FILE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
# WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
# PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
# 
# This file is provided with no support and without any obligation on the
# part of Sun Microsystems, Inc. to assist in its use, correction,
# modification or enhancement.
# 
# SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
# INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS FILE
# OR ANY PART THEREOF.
# 
# In no event will Sun Microsystems, Inc. be liable for any lost revenue
# or profits or other special, indirect and consequential damages, even
# if Sun has been advised of the possibility of such damages.
# 
# Sun Microsystems, Inc.
# 2550 Garcia Avenue
# Mountain View, California  94043
#
# @(#)Makefile.NeWS 9.3 88/01/19 
#
# Copyright (c) 1987 by Sun Microsystems, Inc.
#

# --- Installation and Build Directores ---
INSDIR=/usr/NeWS
BINDIR=${INSDIR}/bin
DEMODIR=${INSDIR}/demo
LIBDIR=${INSDIR}/lib
INCLUDEDIR=${INSDIR}/include
INCLUDE=../../include

# --- Global macro definitions ---
OPT=-O
TARGET_ARCH=
OSI=SUN
VER=SUNREF
SYSV_NETWORK=
BYTES=

COPTS=${BYTES}

# --- Sun Specific Src ---
SUNSPECIFICSRC=
SUNSPECIFICOBJ=
SUNSPECIFICHRD=
SUNSPECIFICPROG=
#

CFLAGS=${OPT} ${COPTS} -I${INCLUDE} -D${OSI} -D${VER} -D${SYSV_NETWORK}

PROG= cps
CPSLIB= libcps.a
VERCPSLIB= ${VER}CPSlib

PROGSRCS=	cps.c

PROGOBJS=	cps.o

PROGHDRS=

CPSSRCS=	psio.c \
		psiofprntf.c \
		ctops.c \
		pstoc.c \
		defs.c

CPSOBJS=	psio.o \
		psiofprntf.o \
		ctops.o \
		pstoc.o \
		defs.o

CPSHDRS=

SRCS= ${PROGSRCS} ${CPSSRCS}
OBJS= ${PROGOBJS} ${CPSOBJS}
HDRS= ${PROGHDRS} ${CPSHDRS}



all: 	${VERCPSLIB} ${PROG}

SUNREFCPSlib: ${CPSOBJS}
	ar uv ${CPSLIB} $?
	ranlib ${CPSLIB}

VXSREFCPSlib: ${CPSOBJS}
	ar uv ${CPSLIB} $?
	ranlib ${CPSLIB}

SYSVREFCPSlib: ${CPSOBJS}
	ar -cr ${CPSLIB} `lorder ${CPSOBJS} | tsort`


${PROG}: ${PROGOBJS}
	cc ${CFLAGS} -o cps cps.o

systoklst.h: ${INCLUDE}/systokenlist
	sed <${INCLUDE}/systokenlist >systoklst.h 's/^.\(.*\)/"\1",/'

${INCLUDE}/systokenlist: ${INCLUDE}/Makefile
	cd ${INCLUDE}; make systokenlist

${INCLUDE}/encoding.h: ${INCLUDE}/Makefile
	cd ${INCLUDE}; make encoding.h

${INCLUDE}/psio.h: ${INCLUDE}/Makefile
	cd ${INCLUDE}; make psio.h

${INCLUDE}/Makefile:
	(cd ${INCLUDE}; ${GET} -GMakefile SCCS/s.Makefile)
	@echo ${INCLUDE}/Makefile retrieved...

cps0:	cps0.o
	cc ${CFLAGS} -o cps0 cps0.o

cps0.o:	${INCLUDE}/encoding.h cps0.c systoklst.h
	cc ${CFLAGS} -DNOHEADER -c cps0.c

cps0.c: cps.c
	-rm -f cps0.c
	ln cps.c cps0.c

defs.incl: defs.h
	sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/.*/"&",/' <defs.h >defs.incl

defs.c defs.h: defs.cps cps0
	cps0 -i -n defs.cps

pstoctable.h: mkpstoctbl
	mkpstoctbl>pstoctable.h

mkpstoctbl: mkpstoctbl.o
	cc ${CFLAGS} mkpstoctbl.o -o mkpstoctbl

depend:	../../makedepend ${HDRS} ${SRCS} defs.incl pstoctable.h systoklst.h
	rm -f cps0.c cps0.o cps0
	../../makedepend ${INCLUDE}

clean:
	rm -f *.o *.a cps0 csp0.c *.BAK pstoctable.h defs.incl defs.h mkpstoctbl cps

install: all bininstall ${VER}libinstall hdrinstall

bininstall: ${PROG}
	(cd ${BINDIR}; rm -f ${PROG})
	cp ${PROG} ${BINDIR}

SUNREFlibinstall: ${CPSLIB}
	(cd ${LIBDIR}; rm -f ${CPSLIB})
	cp ${CPSLIB} ${LIBDIR}/${CPSLIB}; ranlib ${LIBDIR}/${CPSLIB}

VXSREFlibinstall: ${CPSLIB}
	(cd ${LIBDIR}; rm -f ${CPSLIB})
	cp ${CPSLIB} ${LIBDIR}/${CPSLIB}; ranlib ${LIBDIR}/${CPSLIB}

SYSVREFlibinstall: ${CPSLIB}
	(cd ${LIBDIR}; rm -f ${CPSLIB})
	cp ${CPSLIB} ${LIBDIR}/${CPSLIB}

hdrinstall: defs.h ${INCLUDE}/psio.h
	rm -f ${INCLUDEDIR}/defs.h ${INCLUDEDIR}/psio.h
	cp defs.h ${INCLUDEDIR}/defs.h
	cp ${INCLUDE}/psio.h ${INCLUDEDIR}/psio.h


# START OF AUTOMATICALLY GENERATED DEPENDENCIES 
cps.o: ../../include/encoding.h cps.c defs.incl systoklst.h
ctops.o: ../../include/encoding.h ../../include/psio.h ctops.c
defs.o: defs.c
mkpstoctbl.o: ../../include/encoding.h mkpstoctbl.c
psio.o: ../../include/psio.h psio.c
psiofprntf.o: ../../include/psio.h psiofprntf.c
pstoc.o: ../../include/encoding.h ../../include/psio.h pstoc.c pstoctable.h
