#sccs	"@(#)tam:Makefile	1.16"
include $(MAKEINC)/Makepre.h

LIBNAME= libtam.a
LCFLAGS=-DSYS5

TSOURCES=ansi.c layer.c mvcur.c refresh.c touch.c target.c \
	walloc.c wborder.c wclear.c wcreate.c wcurses.c wdata.c wdelete.c \
	wexec.c wget.c winit.c winter.c wmouse.c wnl.c wnoise.c wnmap.c wphys.c \
	wprintf.c wput.c wselect.c wsave.c wstat.c wtty.c

TPROGS=ansi.o layer.o longname.o mvcur.o refresh.o touch.o target.o \
	walloc.o wborder.o wclear.o wcreate.o wcurses.o wdata.o wdelete.o \
	wexec.o wget.o winit.o winter.o wmouse.o wnl.o wnoise.o wnmap.o wphys.o \
	wprintf.o wput.o wselect.o wsave.o wstat.o wtty.o

ESOURCES=form.c menu.c track.c wind.c wrastop.c wpattern.c

EPROGS=form.o menu.o track.o wind.o wrastop.o wpattern.o

JSOURCES=pbf.c message.c eprintf.c wicon.c

JPROGS=pbf.o message.o eprintf.o wicon.o

HD_INST= /usr/include

INC_FILES =	\
	$(HD_INST)/form.h	\
	$(HD_INST)/kcodes.h	\
	$(HD_INST)/menu.h	\
	$(HD_INST)/message.h	\
	$(HD_INST)/pbf.h	\
	$(HD_INST)/tam.h	\
	$(HD_INST)/track.h	\
	$(HD_INST)/wind.h	\
	$(HD_INST)/status.h

# These are hear although not used by Makefile.
LOC_INCS = tamwin.h \
	   touch.h	


KMAPS = kmap.5410 kmap.5420 kmap.5425 kmap.5620 kmap.hp kmap.s4 kmap.tvi925 kmap.vt100 kmap.510a kmap.510d kmap.610

DEPENDLIST = ansi.c \
	eprintf.c \
	form.c \
	form.h \
	kcodes.h \
	layer.c \
	longname.c \
	makemap.c \
	menu.c \
	menu.h \
	message.c \
	message.h \
	mvcur.c \
	pbf.c \
	pbf.h \
	refresh.c \
	status.h \
	tam.h \
	tamwin.h \
	touch.c \
	touch.h \
	track.c \
	track.h \
	walloc.c \
	wborder.c \
	wclear.c \
	wcreate.c \
	wcurses.c \
	wdata.c \
	wdelete.c \
	wexec.c \
	wget.c \
	wicon.c \
	wind.c \
	wind.h \
	winit.c \
	winter.c \
	wmouse.c \
	wnl.c \
	wnmap.c \
	wnoise.c \
	wpattern.c \
	wphys.c \
	wprintf.c \
	wput.c \
	wrastop.c \
	wsave.c \
	wselect.c \
	wstat.c \
	wtty.c

all:	Makeincludes $(LIBNAME)

hdr_install: announce $(INC_FILES)

announce:
	echo "Installing public header files in $(HD_INST)"

$(INC_FILES)::	$$(@F)
	rm -f $(@)
	cp $(@F) $(@)

Makeincludes: $(DEPENDLIST) default_map
	$(INCCMD) $(DEPENDLIST) | $(SORT) | $(FILTER) > Makeincludes
	$(MAKE)

includes: $(DEPENDLIST) default_map
	$(INCCMD) $(DEPENDLIST) | $(SORT) | $(FILTER) > Makeincludes

$(LIBNAME): $(JPROGS) $(EPROGS) $(TPROGS)
	$(AR) rvu $(LIBNAME) $?

default_map: makemap keynames keymap kmap.s4
	makemap default > default_map
	makemap s4 kmap.s4 >> default_map

makemap: makemap.c
	$(CC) -s -o makemap makemap.c

install: $(INC_FILES)
	@for I in $(INC_FILES); do echo installing `basename $$I`...; \
		$(INSTALL) -i$(EXITFLAG) `basename $$I` $(INSDIR) $(PROTOFILE); \
	done
	@for I in $(LIBNAME) keymap keynames $(KMAPS); do \
		echo installing $$I...; \
		$(INSTALL) -i$(EXITFLAG) $$I $(INSDIR) $(PROTOFILE); \
	done
	chown bin $(LIBNAME)
	chgrp bin $(LIBNAME)
	chmod 644 $(LIBNAME)
	echo $(LIBNAME) | cpio -pumv $(USRLIB)
	rm -f $(USRLIB)/ua/tam.a; ln $(USRLIB)/$(LIBNAME) $(USRLIB)/ua/tam.a

clean:
	rm -f $(TPROGS) $(EPROGS) $(JPROGS)

clobber: clean
	rm -f $(LIBNAME) default_map

populate:
	getunit

include Makeincludes
include $(MAKEINC)/Makepost.h
