#
#  Makefile for mp, the PostScript pretty printer.
#
#  @(#)Makefile 1.10 95/08/25
#
#  Copyright (c) Steve Holden and Rich Burridge.
#                All rights reserved.
#
#  Permission is given to distribute these sources, as long as the
#  copyright messages are not removed, and no monies are exchanged.
#
#  No responsibility is taken for any errors inherent either
#  to the comments or the code of this program, but if reported
#  to me then an attempt will be made to fix them.
#
#=====================================================================
#  In order to get mptool to link successfully on your system, you might
#  need to define extra libraries to link against. If this is the case,
#  then the following entry should be uncommented and set appropriately.
#
#  For Solaris 1.x (SunOS 4.1.x), this option needs to be set to:
#  EXTRALIBS = -lXext
#
#  For Solaris 2.x, this option needed to be set to:
#  EXTRALIBS = -lsocket -lnsl -lgen
#
#EXTRALIBS       = -lsocket -lnsl -lgen
#---------------------------------------------------------------------
#  Mptool uses Motif. If you are compiling mptool you will need to
#  uncomment the following two lines and set appropriately.
#
#MOTIFINCDIR     = -I$(MOTIFHOME)/include
#MOTIFLIBDIR     = -L$(MOTIFHOME)/lib
#---------------------------------------------------------------------
#  Mptool runs under X11. If you are compiling mptool you will need to
#  uncomment the following two lines and set appropriately.
#
#X11INCDIR       = -I$(OPENWINHOME)/include
#X11LIBDIR       = -L$(OPENWINHOME)/lib
#=====================================================================
#
#  Default locations where mp files will be installed.
#  You might wish to alter these values.
#
MPPATH     = /usr/local
MPBINDIR   = $(MPPATH)/bin
MPLIBDIR   = $(MPPATH)/lib
MPMANDIR   = $(MPPATH)/man/man$(MPMANSECT)
MPMANSECT  = l
#---------------------------------------------------------------------
#  Compilation flags and standard macro definitions.
#
CDEFS	 = $(MOTIFINCDIR) $(X11INCDIR)  -I../common
CCOMP	 = -O

CC       = gcc

CFLAGS   = $(CCOMP) $(CDEFS)

LDFLAGS  = $(X11LIBDIR) $(MOTIFLIBDIR)
LIBS     = -lXm -lXt -lXmu -lX11 $(EXTRALIBS)

#=================================================================

.KEEP_STATE:

SRCS    = mptool.c mptool_ui.c tu_runtime.c ../common/option.c \
	  base.c callbacks.c header.c help.c input.c output.c \
	  print.c text.c toolfuns.c user.c util.c xutil.c
OBJS    = mptool.o mptool_ui.o tu_runtime.o option.o \
	  base.o callbacks.o header.o help.o input.o output.o \
	  print.o text.o toolfuns.o user.o util.o xutil.o
HDRS    = base.h header.h help.h input.h mptool.h output.h print.h \
	  text.h tu_runtime.h user.h util.h widgetindex.h xutil.h
MPAGES  = mptool.man mptool.man.text

mptool:  $(OBJS) mptool.man
	$(CC) $(CFLAGS) -o mptool $(OBJS) $(LDFLAGS) $(LIBS)
	-sed -e s,LIBDIR,$(MPLIBDIR),g \
	     -e s,BINDIR,$(MPBINDIR),g mptool.man > mptool.1

option.o: ../common/option.c ../common/option.h ../common/patchlevel.h
	$(CC) -c $(CFLAGS) ../common/option.c

tu_runtime.o: tu_runtime.c tu_runtime.h
	$(CC) -c  $(CFLAGS) -DSYSV -g -I. tu_runtime.c

SHELL = /bin/sh

install:
#                                                         mptool
	   -if [ -f mptool ]; then \
		cp mptool $(MPBINDIR); \
		chmod 751 $(MPBINDIR)/mptool; \
		strip $(MPBINDIR)/mptool; \
	   fi
#                                                         mptool.1
	   -if [ -f mptool ]; then \
		cp mptool.1 $(MPMANDIR)/mptool.$(MPMANSECT); \
		chmod 644 $(MPMANDIR)/mptool.$(MPMANSECT); \
	   fi

clean:
	rm -rf *.Z *.uu mptool.1 mptool *.o core

create:    SCCS
	-sccs create $(SRCS) $(HDRS) $(MPAGES)

lint:
	lint $(CDEFS) $(SRCS)

saber:
	#load $(CDEFS) $(SRCS)

SCCS:
	mkdir SCCS
	chmod 755 SCCS

mptool.o:       tu_runtime.h
mptool_ui.o:    tu_runtime.h widgetindex.h

base.o:         mptool.h text.h widgetindex.h
callbacks.o:    widgetindex.h
header.o:       mptool.h text.h widgetindex.h
help.o:         mptool.h text.h widgetindex.h
input.o:        mptool.h text.h widgetindex.h
output.o:       mptool.h text.h widgetindex.h
print.o:        mptool.h text.h widgetindex.h
text.o:         text.h
toolfuns.o:     mptool.h text.h widgetindex.h
user.o:         mptool.h text.h widgetindex.h
util.o:         mptool.h text.h widgetindex.h
xutil.o:        mptool.h text.h widgetindex.h
