#
# Copyright (c) 1987 University of Maryland Department of Computer Science.
# All rights reserved.  Permission to copy for any purpose is hereby granted
# so long as this copyright notice remains intact.
#
# $Header: Makefile,v 1.3 87/06/16 17:13:19 chris Exp $
#
# Makefile for device conversion programs
#
# You must run "make conf" to set up Makefile.local if you do not want
# the default `all' configuration (see the file "conf.sh").  Remember to
# use `make update'!
DESTDIR=
CFLAGS=	-O -R -I../h
MAKE=	make

# these are intended to be overridden by the definitions in ../Makefile
# but just in case, they are here too
BINDIR=	${DESTDIR}/usr/local/bin
MANDIR=	${DESTDIR}/usr/local/man

# Make options
OPTS=	BINDIR=${BINDIR} MANDIR=${MANDIR} DESTDIR=${DESTDIR} CC="${CC}" \
	CFLAGS="${CFLAGS}" ${MFLAGS}

SRCS=	imagen1.c verser1.c verser2.c

# First, the main entry used in the original Makefile.
# It is also enabled by a `conf none'; this is just so that the
# configurer will disable it in Makefile.local.
# Whenever you run `make' afterward, this entry will run
# make on your local Makefile.

# conf none
first:
	@if [ -f Makefile.local ]; then :; else \
		echo "You should run \`make conf' first!"; \
		echo \
"I will give you the default \`all' configuration for now."; \
		sh conf.sh all; \
	fi
	@${MAKE} -f Makefile.local ${OPTS}
# endconf none

# In Makefile.local, this is the default (if you just say `make').
# The `make' invocation will be commented out there.
all:
# conf none
	@${MAKE} -f Makefile.local ${OPTS} $@
# endconf none

# Likewise, but for `make install'.
install:
# conf none
	@${MAKE} -f Makefile.local ${OPTS} $@
# endconf none

# conf imagen
# all: imagen1
# install: inst-iptex inst-imagen1
# endconf imagen

# conf versatec
# all: verser1 verser2
# install: inst-dvipr inst-verser1 inst-verser2
# endconf versatec

# The rest of these are copied to Makefile.local, though many are
# unused.
conf:
	@sh conf.sh
	@echo "Remember to use \`make update' if you change the Makefile!"

clean:
	rm -f core *.o verser1 verser2 imagen1

depend: ${SRCS}
	cc -M ${CFLAGS} ${SRCS} |\
	    awk '{ if ($$1 != prev) { if (rec != "") print rec;\
		rec = $$0; prev = $$1; }\
		else { if (length(rec $$2) > 78) { print rec; rec = $$0; }\
		else rec = rec " " $$2 } }\
		END { print rec }' >makedep
	echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
	echo '$$r makedep' >>eddep
	echo 'w' >>eddep
	cp Makefile Makefile.bak
	ed - Makefile <eddep
	rm eddep makedep
	echo '# DEPENDENCIES MUST END AT END OF FILE' >>Makefile
	echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >>Makefile
	echo '# see make depend above' >>Makefile
	sh conf.sh update

update:
	@sh conf.sh update

inst-dvipr:
	install -c dvipr.sh ${BINDIR}/dvipr
	install -c -m 444 ../man/dvipr.1 ${MANDIR}/man1/dvipr.1
inst-verser1: verser1
	install -s verser1 ${BINDIR}/verser1
inst-verser2: verser2
	install -s verser2 ${BINDIR}/verser2

inst-iptex:
	install -c iptex.sh ${BINDIR}/iptex
	install -c -m 444 ../man/iptex.1 ${MANDIR}/man1/iptex.1
inst-imagen1: imagen1
	install -s imagen1 ${BINDIR}/imagen1

lint: ${SRCS}
	lint -hbxuL ../lib/llib-lib imagen1.c
	lint -hbxuL ../lib/llib-lib verser1.c
	lint -hbxuL ../lib/llib-lib verser2.c

dist:
	rm -f Makefile.bak Makefile.local Makefile.l.bak
	sh conf.sh all

imagen1: imagen1.o
verser1: verser1.o
verser2: verser2.o

imagen1 verser1 verser2: ../lib/lib.a
	${CC} ${CFLAGS} -o $@ $@.o ../lib/lib.a

# DO NOT DELETE THIS LINE -- make depend uses it

imagen1.o: imagen1.c /usr/include/stdio.h ../h/types.h ../h/conv.h ../h/dvi.h
imagen1.o: ../h/dviclass.h ../h/dvicodes.h ../h/fio.h ../h/font.h
imagen1.o: ../h/postamble.h ../h/search.h ../h/imagen.h ../h/imPcodes.h
verser1.o: verser1.c /usr/include/stdio.h ../h/types.h ../h/conv.h ../h/dvi.h
verser1.o: ../h/dviclass.h ../h/dvicodes.h ../h/fio.h ../h/font.h
verser1.o: ../h/postamble.h ../h/search.h ../h/verser.h
verser2.o: verser2.c /usr/include/errno.h /usr/include/setjmp.h
verser2.o: /usr/include/stdio.h /usr/include/sys/vcmd.h
verser2.o: /usr/include/sys/ioctl.h /usr/include/sys/ttychars.h
verser2.o: /usr/include/sys/ttydev.h ../h/types.h ../h/conv.h ../h/fio.h
verser2.o: ../h/font.h ../h/verser.h
# DEPENDENCIES MUST END AT END OF FILE
# IF YOU PUT STUFF HERE IT WILL GO AWAY
# see make depend above