# Makefile for the edit library.

# @(#)Makefile	1.9 04 Jun 1995 (UKC)

# Optional multi-architecture support
D = ${OBJDIR}${SLASH}
S = ${SRCDIR}${SLASH}
LIBSRC = ..
LIBOBJDIR = $D
L = ${LIBOBJDIR}

LIBNAME = edit
HDRNAME = ${LIBNAME}
LIBDIRNAME = ${LIBNAME}
LINTLIBS = -lwn

MTRLIB = ${LIBSRC}/libmtrprog/$Llibmtrprog.a	# Development mtrprog library
UKCLIB = ${LIBSRC}/libukcprog/$Llibukcprog.a	# Development ukcprog library
X11WNLIB = ${LIBSRC}/libx11wn/$LX11/libwn.a	# Development X11 wn library
X11LIB = -lX11					# Installed X11 Xlib library.

TESTSRCS =  testedit.c
TESTLIBDEPS = ${MTRLIB} ${UKCLIB} ${X11WNLIB}
TESTLIBS = ${TESTLIBDEPS} ${X11LIB}

LIBSRCS =   edit.c   display.c   simplebuf.c   win.c  lbuf.c   filebuf.c  \
            props.c   util.c   version.c   flines.c   sline.c   render.c  \
	    keymap.c

   OBJS = $Dedit.o $Ddisplay.o $Dsimplebuf.o $Dwin.o $Dlbuf.o $Dfilebuf.o \
	  $Dprops.o $Dutil.o $Dversion.o $Dflines.o $Dsline.o $Drender.o  \
	  $Dkeymap.o $Dsccsdata.o

HDRS = display.h edit.h filebuf.h lbuf.h sccsdata.h simplebuf.h \
       win.h props.h textbuf.h render.h

DOCS = README

SCCSCHECK_DIRS = ../libukcprog ../libmtrprog

# Begin common part of Makefile
target: $Dlib${LIBNAME}.a

MAKE_LIBRARY = ar cq

# These values can be overridden by the top level Makefile
RANLIB = :
CFLAGS = -g
INSTALL = ucbinstall

INCLUDE = /usr/include/local
LIB = /usr/local/lib

# Flags for cc.
DEPS_DEVELHDRS = -Idevelhdrs
DEVELHDRS = -I$Sdevelhdrs
CCFLAGS = ${DEVELHDRS} ${INCLUDEDIRS} ${ARCH_CFLAGS} ${CFLAGS} ${MORE_CFLAGS}

CCLINE = ${IN_OBJDIR}${CC} -c ${CCFLAGS} $S

SRCS = ${LIBSRCS} ${TESTSRCS}
FILES = ${SRCS} ${HDRS} ${DOCS} Makefile

# Use $D/. so we don't get a null target when $D is undefined.
# We say sh -c to avoid exit status problems from the || construct.
$D/.:
	sh -c 'IFS=/; for i in $D; do test -d $$i || mkdir $$i; cd $$i; done'

$Dtest${LIBNAME}: $D/. $Dlib${LIBNAME}.a $Dtest${LIBNAME}.o ${TESTLIBDEPS}
	${CC} ${CFLAGS} ${LINKFLAGS} -o $Dtest${LIBNAME} $Dtest${LIBNAME}.o $Dlib${LIBNAME}.a ${TESTLIBS} ${STDLIBS}

$Dlib${LIBNAME}.a: $D/. ${OBJS}
	rm -f $@
	${MAKE_LIBRARY} $@ ${OBJS}
	${IN_OBJDIR}${RANLIB} lib${LIBNAME}.a

all: $Dlib${LIBNAME}.a

TAGS: ${SRCS} ${HDRS}
	etags ${SRCS} ${HDRS}

list:
	@echo ${FILES} sccsdata.c | tr ' ' '\012'

count:
	wc ${HDRS} ${SRCS}

SCCS_CHECK = sccsinfo ${SCCSCHECK_DIRS} ${FILES} && newer sccsdata.c ${FILES}

sccs_check:
	@${SCCS_CHECK}

sccssnapshot:
	@mksccs -changefile CHANGES -wh -c t_snapshot.c -h t_snapshot.h ${LIBNAME} ${FILES}

sccsfile:
	@sccsinfo ${SCCSCHECK_DIRS} ${FILES}
	@checklist
	@newer CHANGES ${FILES}
	@sccs edit sccsdata.c
	@mksccs -changefile CHANGES -wh ${LIBNAME} ${FILES}
	@sccs delget sccsdata.c


install: $Dinstall

$Dinstall: ${LIB}/lib${LIBNAME}.a ${INCLUDE}/${HDRNAME}.h

${LIB}/lib${LIBNAME}.a: $Dlib${LIBNAME}.a
	${SCCS_CHECK}
	${INSTALL} -c -m 644 -o root $? $@
	cd ${LIB}; ranlib $@

${INCLUDE}/${HDRNAME}.h: ${HDRNAME}.h
	${SCCS_CHECK}
	${INSTALL} -c -m 644 -o root $? $@

clean:
	rm -f ${OBJS} $Dlib${LIBNAME}.a $Dllib-l${LIBNAME}.ln core

veryclean: clean
	rm -f TAGS
	sccs clean

lintf:
	lint ${LINTFLAGS} ${ARCH_CFLAGS} ${SRCS} ${LINTLIBS} | .lintf > t_lintf

llib: $Dllib-l${LIBNAME}.ln

$Dllib-l${LIBNAME}.ln: ${LIBSRCS}
	lint -C${LIBNAME} ${ARCH_CFLAGS} ${LIBSRCS}
	mv llib-l${LIBNAME}.ln $@

install_lint: ${LIB}/lint/llib-l${LIBNAME}.ln

${LIB}/lint/llib-l${LIBNAME}.ln: $Dllib-l${LIBNAME}.ln
	${SCCS_CHECK}
	${INSTALL} -c -m 644 -o root $? $@

deps: ${SRCS} sccsdata.c
	@deps ${DEPS_DEVELHDRS} ${SRCS} sccsdata.c

# End common part of Makefile

# Machine generated .o file dependencies
$Dedit.o: edit.c edit.h textbuf.h display.h 
	${CCLINE}edit.c
$Ddisplay.o: display.c edit.h textbuf.h display.h props.h 
	${CCLINE}display.c
$Dsimplebuf.o: simplebuf.c textbuf.h simplebuf.h 
	${CCLINE}simplebuf.c
$Dwin.o: win.c edit.h win.h 
	${CCLINE}win.c
$Dlbuf.o: lbuf.c textbuf.h lbuf.h 
	${CCLINE}lbuf.c
$Dfilebuf.o: filebuf.c textbuf.h lbuf.h filebuf.h 
	${CCLINE}filebuf.c
$Dprops.o: props.c edit.h textbuf.h display.h props.h 
	${CCLINE}props.c
$Dutil.o: util.c edit.h 
	${CCLINE}util.c
$Dversion.o: version.c edit.h sccsdata.h 
	${CCLINE}version.c
$Dflines.o: flines.c edit.h display.h props.h render.h 
	${CCLINE}flines.c
$Dsline.o: sline.c edit.h display.h props.h render.h 
	${CCLINE}sline.c
$Drender.o: render.c edit.h display.h props.h render.h 
	${CCLINE}render.c
$Dtestedit.o: testedit.c edit.h textbuf.h simplebuf.h lbuf.h filebuf.h win.h 
	${CCLINE}testedit.c
$Dkeymap.o: keymap.c edit.h 
	${CCLINE}keymap.c
$Dsccsdata.o: sccsdata.c sccsdata.h 
	${CCLINE}sccsdata.c
