#
# Warning: the cpp used on this machine replaces
# all newlines and multiple tabs/spaces in a macro
# expansion with a single space.  Imake tries to
# compensate for this, but is not always
# successful.
#

#
# This makefile is automatically generated by imake... do not modify
# or you may lose your changes when imake generates makefiles again.
# Ignore this message if you are not using imake.
#

            TOP = ../..
             AS = as

              CC = cc
            CPP = /lib/cpp
             LD = ld
           LINT = lint
        INSTALL = install
           TAGS = ctags
             RM = rm -f
             MV = mv
             LN = ln -s
         RANLIB = ranlib
             AR = ar clq
             LS = ls
       LINTOPTS = -axz
    LINTLIBFLAG = -C
           MAKE = make
    STD_DEFINES =

      CDEBUGFLAGS = -O
        DESTDIR =

        PATHSEP = /
         DEPEND = $(DEPENDSRC)/makedepend
          IMAKE = $(IMAKESRC)/imake
            RGB = $(RGBSRC)/rgb
         CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
      LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
        LDFLAGS = $(CDEBUGFLAGS) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
   INSTUIDFLAGS = -m 4755
   INSTLIBFLAGS = -m 0664
   INSTINCFLAGS = -m 0444
   INSTMANFLAGS = -m 0444
   INSTAPPFLAGS = -m 0444

      USRLIBDIR = /ai/lib/X11
         BINDIR = /ai/bin/X11
         LIBDIR = /ai/share/X11
     LINTLIBDIR = $(LIBDIR)/lint
         INCDIR = $(LIBDIR)/include
        FONTDIR = $(LIBDIR)/fonts
         UWMDIR = $(LIBDIR)/uwm
         MANDIR = /ai/man/manx
    XAPPLOADDIR = $(LIBDIR)/app-defaults
         ADMDIR = /var/log/X11

      CLIENTSRC = $(TOP)/clients
        DEMOSRC = $(TOP)/demos
         LIBSRC = $(TOP)/lib
        FONTSRC = $(TOP)/fonts
     INCLUDESRC = $(TOP)/X11
      SERVERSRC = $(TOP)/server
        UTILSRC = $(TOP)/util
     EXAMPLESRC = $(TOP)/examples
     CONTRIBSRC = $(TOP)/contrib
         DOCSRC = $(TOP)/doc
      DEPENDSRC = $(UTILSRC)/makedepend
       IMAKESRC = $(UTILSRC)/imake
       IRULESRC = $(UTILSRC)/imake.includes
         RGBSRC = $(UTILSRC)/rgb
        XLIBSRC = $(LIBSRC)/X
     TOOLKITSRC = $(LIBSRC)/Xt
     AWIDGETSRC = $(LIBSRC)/Xaw
     OLDXLIBSRC = $(LIBSRC)/oldX
   EXTENSIONSRC = $(TOP)/extensions
        XMANSRC = $(DOCSRC)/Xlib/Xman
   EXTENSIONLIB = $(EXTENSIONSRC)/lib/libXext.a
           XLIB = $(XLIBSRC)/libX11.a
        OLDXLIB = $(OLDXLIBSRC)/liboldX.a
       XTOOLLIB = $(TOOLKITSRC)/libXt.a
         XAWLIB = $(AWIDGETSRC)/libXaw.a
       LINTXLIB = $(XLIBSRC)/llib-lX11.ln
      LINTXTOOL = $(TOOLKITSRC)/llib-lXt.ln
        LINTXAW = $(AWIDGETSRC)/llib-lXaw.ln
       INCLUDES = -I$(TOP)
      MACROFILE = Sun.macros
      IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl \
			-I$(NEWTOP)$(IRULESRC) \
			-s Makefile
         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
			tags TAGS make.log

XPICLIBDIR=$(LIBDIR)/xpic
# The documents go in $(DOCDIR)/xpic - see the install target.
# At CSRI, we use a logical link to the source, so we don't
# install this. You must still keep this accurate, because
# it's put into the man page. Change the install target appropriately.
#DOCDIR=/nfs/church/csri5/doc/local
DOCDIR=/ai/doc/X11
# the directory in which xpic saves the current buffer
# in case it dies on a signal
DUMPDIR=/tmp
#############################################################
# -DXPIC is used by the filename completion code.
# -DMAGIC will include code that puts a '#! $(BINDIR)/xpic'
# header on the saved xpic files, and make them executable, so
# you can just execute the saved xpic file and it starts up
# xpic.
# -DDEBUG turns on debugging output - do you really want that?!
# -DDRAWBBOX is also for debugging - it draws the bounding box
# of all gels.
# -DGRAB should be defined if XtAddGrab and XtRemoveGrab can be
# made to work in Minibuf.c and input.c - I can't seem to get them
# to work.
# -DTYPEOUT includes the typeout code - this is still not used by
# xpic - not much point defining it.
#DEFINES = -DXPIC -DMAGIC -DDEBUG
DEFINES = -DXPIC -DMAGIC
#############################################################
CDEBUGFLAGS = -g
#CDEBUGFLAGS = -O
INCLUDES =  -I$(TOOLKITSRC) -I$(TOP) -Ibitmaps
CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
#############################################################
VPATH = bitmaps
#############################################################
# Note - You need the HP widgets (Xw) for the X11 Toolkit
# These should be defined in an Imake.tmpl - except that the
# normal Imake.tmpl insists on these being compiled in the
# X directory tree.
XWLIB=$(USRLIBDIR)/libXw.a
XTOOLLIB=$(USRLIBDIR)/libXt.a
XLIB=$(USRLIBDIR)/libX11.a
# Sigh - we use sin(), cos(), atan2() for arrow.
MATHLIB=-lm
#############################################################
# /usr/lib/debug/malloc.o is Sun's debugging malloc() - it
# provides the malloc_debug() and malloc_verify() calls.
# malloc.o is a first-fit malloc with debugging ASSERTs. Finds
# heap corruption fast. Not defining this will use libc.
#MALLOC = /usr/lib/debug/malloc.o
#MALLOC = malloc.o
MALLOC =
#############################################################
MYXTSTUFF = Form.o PButton.o
#############################################################
OBJS1 = main.o windows.o xpic.o handlers.o input.o  \
		event.o grid.o error.o spline.o arrow.o newfonts.o \
		util.o gels.o null.o obj_line.o obj_spline.o obj_text.o \
		obj_box.o obj_circ.o obj_ell.o obj_block.o obj_elem.o \
		updown.o text.o isqrt.o ask.o xtypeout.o Minibuf.o Window.o
#############################################################
SRCS1 = main.c windows.c xpic.c handlers.c input.c  \
		event.c grid.c error.c spline.c arrow.c newfonts.c \
		util.c gels.c null.c obj_line.c obj_spline.c obj_text.c \
		obj_box.c obj_circ.c obj_ell.c obj_block.c obj_elem.c \
		updown.c text.c isqrt.c ask.c xtypeout.c Minibuf.c Window.c
#############################################################
OBJS2 = x2pic.o hash.o
SRCS2 = x2pic.c hash.c
#############################################################
OBJS3 = x2ps.o hash.o
SRCS3 = x2ps.c hash.c
#############################################################
PROGRAMS = xpic x2ps x2pic

.SUFFIXES: .manX .man

.manX.man:
	sed -e 's?DOCDIR?$(DOCDIR)/xpic?g'\
	    -e 's?XPICLIBDIR?$(XPICLIBDIR)?g' $*.manX > $*.man

 OBJS = $(OBJS1) $(OBJS2) $(OBJS3)
 SRCS = $(SRCS1) $(SRCS2) $(SRCS3)

all:: $(PROGRAMS)

xpic: $(OBJS1) $(MYXTSTUFF) $(MALLOC) $(XWLIB) $(XTOOLLIB) $(XLIB)
	$(RM) $@
	$(CC) -o $@ $(OBJS1) $(MYXTSTUFF) $(MALLOC) $(XWLIB) $(XTOOLLIB) $(XLIB) $(LDFLAGS) $(MATHLIB)

install:: xpic
	$(INSTALL) -c $(INSTALLFLAGS) xpic $(BINDIR)

install:: xpic.man
	$(INSTALL) -c $(INSTMANFLAGS) xpic.man $(MANDIR)/xpic.x
relink::
	$(RM) $(PROGRAMS)
	$(MAKE) $(MFLAGS) $(PROGRAMS)

depend:: $(DEPEND)

depend::
	$(DEPEND) -s "# DO NOT DELETE" $(CFLAGS) $(SRCS)

$(DEPEND):
	@echo "making $(DEPENDSRC)"; \
	cd $(DEPENDSRC); $(MAKE)

clean::
	$(RM) $(PROGRAMS)

x2pic: $(OBJS2) $(MALLOC)
	$(RM) $@
	$(CC) -o $@ $(OBJS2) $(MALLOC)  $(LDFLAGS)

relink::
	$(RM) x2pic
	$(MAKE) $(MFLAGS) x2pic

clean::
	$(RM) x2pic

install:: x2ps
	$(INSTALL) -c $(INSTALLFLAGS) x2ps  $(BINDIR)

install:: x2ps.man
	$(INSTALL) -c $(INSTMANFLAGS) x2ps.man  $(MANDIR)/x2ps.x

x2ps: $(OBJS3) $(MALLOC)
	$(RM) $@
	$(CC) -o $@ $(OBJS3) $(MALLOC)  $(LDFLAGS) $(MATHLIB)

relink::
	$(RM) x2ps
	$(MAKE) $(MFLAGS) x2ps

clean::
	$(RM) x2ps

install:: x2pic
	$(INSTALL) -c $(INSTALLFLAGS) x2pic  $(BINDIR)

install:: x2pic.man
	$(INSTALL) -c $(INSTMANFLAGS) x2pic.man  $(MANDIR)/x2pic.x

lint:
	lint -abz $(SRCS1) $(LDFLAGS) -lXw -lXt -lX11 -lm $(LINTFLAGS)
	lint -abz $(SRCS2) $(LDFLAGS) $(LINTFLAGS)
	lint -abz $(SRCS3) $(LDFLAGS) -lm $(LINTFLAGS)

clean::
	$(RM) tune.h.new xpic.man x2ps.man x2pic.man
#	cd fontstuff/vfontscale; make clean

id: tags
	mkid *.[ch]

install::
	-mkdir $(XPICLIBDIR)
	$(INSTALL) $(INSTAPPFLAGS) x2ps.pro $(XPICLIBDIR)
	$(INSTALL) $(INSTAPPFLAGS) x2ps.tra $(XPICLIBDIR)
	-mkdir $(XPICLIBDIR)/fontdesc
	$(INSTALL) $(INSTAPPFLAGS) fontdesc/xpic $(XPICLIBDIR)/fontdesc
	$(INSTALL) $(INSTAPPFLAGS) fontdesc/x2pic $(XPICLIBDIR)/fontdesc
	$(INSTALL) $(INSTAPPFLAGS) fontdesc/x2ps $(XPICLIBDIR)/fontdesc

install::
#	rm -r $(DOCDIR)/xpic
#	cp -r doc $(DOCDIR)/xpic
#	-mkdir $(FONTDIR)
#	cp -r fontstuff/sunfonts.* $(FONTDIR)

tar:
	cd ..; tar cvfX - xpic/ExcludeFiles xpic | compress > xpic.tar.Z

tune.h: Makefile
	echo \#define LIBDIR \"$(XPICLIBDIR)\" > tune.h.new
	echo \#define PROGRAMNAME \"$(BINDIR)/xpic\" >> tune.h.new
	echo \#define DUMPDIR \"$(DUMPDIR)\" >> tune.h.new
	-cmp -s tune.h.new tune.h || cp tune.h.new tune.h

clean::
	$(RM_CMD) \#*

Makefile:: $(IMAKE)

Makefile:: Imakefile \
	$(IRULESRC)/Imake.tmpl \
	$(IRULESRC)/Imake.rules \
	$(IRULESRC)/$(MACROFILE)
	-$(RM) Makefile.bak; $(MV) Makefile Makefile.bak
	$(IMAKE_CMD) -DTOPDIR=$(TOP)

$(IMAKE):
	@echo "making $(IMAKESRC)"; \
	cd $(IMAKESRC); $(MAKE)

tags::
	$(TAGS) -w *.[ch]
	$(TAGS) -xw *.[ch] > TAGS

install::
	@echo "install done"

Makefiles::

