# Makefile for the med3 binary.

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

# Optional multi-architecture support
D = ${OBJDIR}${SLASH}
S = ${SRCDIR}${SLASH}

BINNAME = med3
HDRNAME = med3
LIBDIRNAME = med3
LINTLIBS = 

LIBSRCS = bmdiv.c box.c cursor.c menu.c rw.c bmenu.c coords.c fonts.c mhole.c sccsdata.c bmstack.c cpats.c med3.c rvals.c strings.c
OBJS = $Dbmdiv.c $Dbox.c $Dcursor.c $Dmenu.c $Drw.c $Dbmenu.c $Dcoords.c $Dfonts.c $Dmhole.c $Dsccsdata.c $Dbmstack.c $Dcpats.c $Dmed3.c $Drvals.c $Dstrings.c

HDRS = bmenu.h cursors.h font.h layout.h med3.h menu_priv.h

DOCS = 

LIBSRC = ..
WNLIB = ${LIBSRC}/libx11wn/X11/$Dlibwn.a	# Development ukcprog library
TESTLIBDEPS = ${WNLIB}
TESTLIBS = ${WNLIB}

SCCSCHECK_DIRS =

# Begin common part of Makefile
target: ${BINNAME}

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

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

DOCS = doc/Mchange.l doc/Mclear.l doc/Mclose.l doc/Mdisplay.l doc/Mdup.l \
       doc/Menus.l doc/Mfmodes.l doc/Mfonts.l doc/Minsert.l doc/Mmake.l \
       doc/Mnonsel.l doc/Mopen.l doc/Mperror.l doc/Mplace.l doc/Mpushsu.l \
       doc/Mredraw.l doc/Mremove.l doc/Mreset.l doc/Mrvalue.l doc/Mselect.l \
       doc/Msize.l doc/Mstdfont.l doc/appendix_a doc/med3.l doc/paper

# 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}
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${BINNAME}: $D/. $Dtest${BINNAME}.o ${TESTLIBDEPS}
	${CC} ${CFLAGS} ${LINKFLAGS} -o $Dtest${BINNAME} $Dtest${BINNAME}.o ${BINNAME} ${TESTLIBS}


OBJ=med3.o mhole.o rvals.o fonts.o strings.o bmenu.o cursor.o bmdiv.o \
	box.o bmstack.o menu.o rw.o coords.o cpats.o

${BINNAME}: $(OBJ)
	${CC} ${CCFLAGS} -o med3 ${OBJ} ../lib/libMen3/libMen3wn.a ../lib/libx11wn/X11/libwn.a -lX11 -lsocket

list:
	@echo README ${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 ${BINNAME} ${FILES}

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


install: $Dinstall

$Dinstall: ${LIB}/${BINNAME} ${INCLUDE}/${HDRNAME}.h

${LIB}/${BINNAME}: ${BINNAME}
	${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} ${BINNAME} ${BINNAME}.ln core

veryclean: clean
	rm -f tags
	sccs clean

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

llib: ${BINNAME}.ln

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

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

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

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

# End common part of Makefile

