# (c) Copyright 1993 by Panagiotis Tsirigotis
# All rights reserved.  The file named COPYRIGHT specifies the terms 
# and conditions for redistribution.

#
# $Id: Makefile,v 1.10 1993/04/10 19:59:30 panos Exp $
#

#
# Based on Program makefile template: *Revision: 1.19 *
#

#
# Available entries:
#		$(NAME)		--> create the program (this is the default target)
#		install		--> install the program
#		install.man --> install man page
#		uninstall	--> uninstall the program (and man page)
#		clean			--> cleanup
#		spotless		--> clean + uninstall
# 		lint			--> lints a specific file (usage: make lint MODULE=foo.c)
#		lintall		--> lint all files
#		tags			--> creates a tags file
#		checkout 	--> checkout all files
#

NAME					= pstext
VERSION				= 1.0.6

DEFS					=
DEBUG					= -g
LIBDIR				= ../lib
LDFLAGS				= -L$(LIBDIR)
LIBS					= -lsio -lstr

OPT					= options.opt
OPT_HEADER			= options.h
OPT_SOURCE			= options.c
OPT_OBJECT			= options.o

SRCS					= dvi.c main.c common.c dit.c wp.c groff.c
HDRS					= defs.h
OBJS					= dvi.o main.o common.o dit.o wp.o groff.o

SOURCES				= $(SRCS) $(OPT_SOURCE)
HEADERS				= $(HDRS) $(OPT_HEADER)
OBJECTS				= $(OBJS) $(OPT_OBJECT)


INCLUDEDIR			= -I$(INCDIR)
#MANPATHDIR			= $(HOME)/.links/manpages
INSTALLDIR			= $(BINDIR)


#
# You may modify the following variables but you probably don't need to.
#

PROGRAM				= $(NAME)
MANSECTION			= 1
MANSUBSECTION		=						# like V,X,l
MANFILE				= $(PROGRAM).man
MANPAGE				= $(PROGRAM).$(MANSECTION)$(MANSUBSECTION)
#MANDIR				= $(MANPATHDIR)/man$(MANSECTION)

CC						= cc			# used for compiler-specific options
CC_FLAGS				= $(DEBUG)	# used for generic options

XMODE					= -s -m 755				# mode for executables
FMODE					= -m 644				# mode for anything but executables
INSTALL				= install  -c

LINT_FLAGS			= -hbux
PAGER					= less

CPP_DEFS				= $(VERSION_DEF) $(DEFS)

#
# The following variables do not need to be changed
#

VERSION_DEF			= -DVERSION=\"$(PROGRAM)\ Version\ $(VERSION)\"
CPP_FLAGS			= $(CPP_DEFS) $(INCLUDEDIR)
CFLAGS				= $(CPP_FLAGS) $(CC_FLAGS)

$(PROGRAM): $(OBJECTS)
	$(CC) $(DEBUG) -o $@ $(OBJECTS) $(LDFLAGS) $(LIBS) || rm -f $(PROGRAM)

tags: $(HEADERS) $(SOURCES)
	ctags -w $(HEADERS) $(SOURCES)

checkout:

lint:
	lint $(LINT_FLAGS) $(CPP_FLAGS) $(MODULE) 2>&1 | $(PAGER)

lintall:
	lint $(LINT_FLAGS) $(CPP_FLAGS) $(SOURCES) 2>&1 | $(PAGER)

clean:
	rm -f $(OBJECTS) $(PROGRAM) core

xclean: clean
	rm -f $(OPT_HEADER) $(OPT_SOURCE)

install: $(PROGRAM)
	$(INSTALL) $(XMODE) $(PROGRAM) $(INSTALLDIR)

install.man:
	if test "$(MANFILE)" -a "$(MANDIR)" ; then $(INSTALL) $(FMODE) $(MANFILE) $(MANDIR)/$(MANPAGE) ; fi

uninstall:
	a=`pwd` ; cd $(INSTALLDIR) ;\
	if test $$a != `pwd` ; then rm -f $(PROGRAM) ; fi
	a=`pwd` ; cd $(MANDIR) ;\
	if test $$a != `pwd` ; then rm -f $(MANPAGE) ; fi

#
# Distribution section
# This section contains the 2 targets for distribution support: dist, dirs
# "dist" checks out all files to be distributed
# "dirs" prints a list of directories to be included in the distribution.
# These directories should have a Makefile with a "dist" target
#
DISTRIBUTION_FILES	= $(SRCS) $(HDRS) $(MANFILE) COPYRIGHT CHANGELOG README
DIRS						=

dist1:

dist: dist1 $(OPT_SOURCE)
	-co -q $(DISTRIBUTION_FILES)

dirs:
	@echo $(DIRS)

#
# This part of the file shows how to make $(OBJECTS) 
#

$(OPT_OBJECT): $(OPT_HEADER)
main.o: $(OPT_HEADER) defs.h
dvi.o: defs.h
common.o: defs.h
dit.o: defs.h
wp.o: defs.h
