# $Id: Makefile,v 1.7 1995/07/01 04:54:17 pturner Exp pturner $
#
# Makefile for xmgr Release 4.00
#

# Step 1.

# you may need to change the following
# BINDIR - location of the xmgr executable
# APPDEFAULTS - directory to put the xmgr application defaults file.
# HELPFILE - if not defined, then "xmgr.html" (shouldn't need to change this).
# HELPVIEWER - if not defined, "Mosaic" - others should work.
##################################
BINDIR = /usr/local/bin
APPDEFAULTS = /usr/lib/X11/app-defaults

#HELPFILE = -DGR_HELPFILE='"xmgr.html"'
#HELPVIEWER = -DGR_HELPVIEWER='"xterm -e lynx"'
#HELPVIEWER = -DGR_HELPVIEWER='"mosaic"'
#HELPVIEWER = -DGR_HELPVIEWER='"xmosaic"'
#HELPVIEWER = -DGR_HELPVIEWER='"netscape"'
HELPVIEWER = -DGR_HELPVIEWER='"Mosaic"'

# Step 2.

# You need to select the machine type
# uncomment one of the following, make sure the
# others are commented out - the default is for Linux
##################################

### IBM RS6000 AIX 3.2 w X11R4/Motif 1.1 or X11R5/Motif 1.2
#LIBS = -lXm -lXt -lX11 -lm
#INCLUDES = 
#CC = xlc -D_POSIX_SOURCE
### End IBM AIX 3.2 w X11R4/Motif 1.1 or X11R5/Motif 1.2 

### Linux w X11R5/Motif 1.2
LIBS = -L./gd -lgd -L/usr/X386/lib -lXm -lXt -lX11 -lm
#LIBS = -L/usr/X386/lib -lXm -lXt  -lSM -lICE  -lX11 -lm
INCLUDES = -I/usr/X386/include -I./gd
CC = gcc -D_POSIX_SOURCE
### End Linux

# SUN
# NOTE: for Sun 3's use the -J option to compile pars.c
# Should work for SunOS < 5.0 X11R4/R5 Motif 1.1/1.2
### Sun - Motif
#LIBS = -lXm -lXt -lX11 -lm
#INCLUDES =
#CC = gcc -O

### various local Sun configs
### Sun - Motif
#LIBS = -L/usr/local/motif -lXm -lXt -lX11 -lm
#INCLUDES = -I/usr/local/motif
#CC = cc -O

### Sun - SunOS 4.1.x Motif 1.1/X11R4
#
#LIBS = -L/amb2.data/ese/local/motif -lXm -lXt -lX11 -lm
#INCLUDES = -I/amb2.data/ese/local/X11/include -I/amb2.data/ese/local/motif
#CC = gcc -O
#CC = acc -O 

### Sun - Solaris 2.2 & 2.3 - Motif 1.2.2/X11R5
#LIBS = -L/home/pjt/tmp/openwin/lib -lXm -lXt -lX11 -lm
#INCLUDES = -I/home/pjt/tmp/openwin/include -I../tmp/motif.1.2.2/X11
#CC = acc -g -DSOLARIS
LIBS = -L/usr/openwin/lib -L/opt/unbundled/SUNWmotif/lib -Bstatic -lXm -lXt -lX11 -Bdynamic -lw -lsocket -ldl -lgen -lnsl -lm -R/usr/openwin/lib -R/opt/unbundled/SUNWmotif/lib
INCLUDES = -I/usr/openwin/include -I/opt/unbundled/SUNWmotif/include
CC = cc -DSOLARIS

### End Sun

### SGI
#LIBS = -lXm -lXt -lX11 -lPW -lm
#INCLUDES =
#CC = cc -D_POSIX_SOURCE
#CC = gcc  -D_POSIX_SOURCE
### End SGI

### HP9000 - HP/UX 8.0
# 300 series
#LIBS = -L/usr/lib/X11R4 -L/usr/lib/Motif1.1  -lXm -lXt -lX11 -lm -lc -lPW
# 700 series
#LIBS = -L/usr/lib/X11R4 -L/usr/lib/Motif1.1 -lXm -lXt -lX11 -lm /lib/libp/libc.a  -lPW
#INCLUDES = -I/usr/include/Motif1.1 -I/usr/include/X11R4
### End HP9000  - HP/UX 8.0

### HP9000 - HP/UX 9.x
# 700 series
#CC = cc -Aa -D_HPUX_SOURCE
#LIBS = -L/usr/lib/X11R5 -L/usr/lib/Motif1.2 -lXm -lXt -lX11 -lm
#INCLUDES = -I/usr/include/X11R5 -I/usr/include/Motif1.2
### End HP9000  - HP/UX 9.x

### DECstation - Ultrix 4.2a Motif 1.1
# Note: DEC compilers seem to have problems
# compiling several modules, gcc seems to work 
# without trouble.
#LIBS = -lXm -lXt -lX11 -lm
#INCLUDES =
#CC = cc -Wf,-XNg1000 -Olimit 2000 -DHAS_TOLOWER
# also, pars.c may need special treatment
# do the following from the shell
# cc -Wf,-XNg1000 -c pars.c
### End DECstation

### DEC Alpha Motif 1.1 OSF1 1.3
#LIBS = -lXm -lXt -lX11 -lm
#INCLUDES =
#CC = cc -Wf,-XNg1000 -Olimit 2000 -DHAS_TOLOWER
### End Alpha

# Step 3.

# Limited NetCDF/HDF support
#################################
# support for netCDF -> implemented
# Uncomment the following 3 defines for netCDF support
# adjust paths to suit local conditions
#
#NETCDF = -DHAVE_NETCDF
#NETCDFINCLUDES = -I/usr/local/netcdf/include
#NETCDFLIBS = -L/usr/local/netcdf/lib -lnetcdf

# if using the NCSA combined libs then use the following
#
#MFHDF = -DHAVE_MFHDF
#NETCDFINCLUDES = -I/usr/local/hdf/include
#NETCDFLIBS = -L/usr/local/hdf/lib -lnetcdf -ldf
#
## end netCDF support

#
# support for HDF -> not implemented, but the combined version
# works fine, so this may never be implemented
#
#HDF = -DHAVE_HDF
#HDFINCLUDES = -I/usr/local/hdf/include
#HDFLIBS = -L/usr/local/lib  -lhdf
## end HDF support
#################################

# Step 4.

# Install a printer
#################################
#
# The default is PostScript landscape using "lpr -h" to spool
#
#
# To install the default hardcopy device uncomment ONE of the
# following (HARDCOPYDEV lines), the hardcopy device can also 
# be set using environment variables, and on the command line:
#
# PostScript landscape [device number 1]
HARDCOPYDEV = -DHDEV=GR_PS_L 
#
# PostScript portrait [device number 2]
#HARDCOPYDEV = -DHDEV=GR_PS_P 
#
# FrameMaker MIF landscape [device number 3]
#HARDCOPYDEV = -DHDEV=GR_MIF_L 
#
# FrameMaker MIF landscape [device number 4]
#HARDCOPYDEV = -DHDEV=GR_MIF_P 
#
#  HP 8.5x11 landscape [device number 5]
#HARDCOPYDEV = -DHDEV=GR_HPGL_L
#
#  HP 8.5x11 Portrait [device number 6]
#HARDCOPYDEV = -DHDEV=GR_HPGL_P
#
# InterLeaf landscape [device number 7]
#HARDCOPYDEV = -DHDEV=GR_LEAF_L
#
# InterLeaf portrait [device number 8]
#HARDCOPYDEV = -DHDEV=GR_LEAF_P

# Step 5.

# To install the printer for the hardcopy devices above
# set the following to the appropriate value for your site.
# These can also be set by environment variables. The current
# definitions of these variables are the same as the definitions
# found in ps.c (PostScript), and mif.c (Maker Interchange format).
#
# NOTE: if you use lp (as on Solaris 2.x, IRIX, and other System V systems),
#       add the -c option or xmgr will erase the temporary file
#       before lp can spool it -> "lp -c "
# 
# For Postscript
# 
PS_PRSTR = -DPS_PRSTR='"lpr -h "'
# 
# For FrameMaker MIF format (really goes to a file)
# 
#MIF_PRSTR = -DMIF_PRSTR='"cat >xmgr.mif < "'
# 
#
# For HPGL
# The driver will work for most (probably all) HPGL devices
#
#HP_PRSTR1 = -DHP_PRSTR1='"/usr/ucb/lpr -Php -h"'
#
# For InterLeaf format (really goes to a file)
#
#LEAF_PRSTR = -DLEAF_PRSTR='"cat >xmgr.leaf < "'

# Step 6.

# Add support for the matrix widget - allows a semi-spreadsheet
# view of a set. You need the Xbae widget set version 4.0 to
# build this.
###############################
#HAS_XBAE = -DHAS_XBAE
#XBAE_LIBS = -lXbae
#XBAE_INCLUDES =
#XBAE_LIBS = -L./Xbae.4.0/src -lXbae
#XBAE_LIBS = -L/usr/local/lib -lXbae
#XBAE_INCLUDES = -I/usr/local/include/Xbae
###############################

###############################
# End installation parameters - you shouldn't 
# need to edit anything below this line
###############################

VERSION = -DMOTIF

###############################
# This turns on DragnDrop, if you don't have Motif 1.2
# don't bother. Even if you have 1.2, it is not likely to work.
#TEST = -DTEST
###############################

###############################
# for building a version that runs without linking to X
#
#GRLIBS = -lm
#INCLUDES = 
#VERSION = -DGR
###############################

CFLAGS = $(VERSION) $(XBAE_INCLUDES) $(INCLUDES) $(HARDCOPYDEV) \
	$(PS_PRSTR) $(MIF_PRSTR) $(HP_PRSTR1) \
	$(LEAF_PRSTR) $(NETCDF) $(MFHDF) \
	$(NETCDFINCLUDES) \
	$(HELPFILE) $(HELPVIEWER) $(HAS_XBAE) $(TEST)

# pars.c is now built outside this Makefile
# YFLAGS = -yt

SRCS =  main.c xmgr.c events.c malerts.c fileswin.c blockwin.c\
	eblockwin.c printwin.c drawwin.c comwin.c compwin.c\
	setwin.c hotwin.c ptswin.c editpwin.c regionwin.c\
	statuswin.c symwin.c tickwin.c graphwin.c worldwin.c\
	strwin.c labelwin.c locatewin.c framewin.c pagewin.c\
	monwin.c helpwin.c nonlwin.c miscwin.c stubs.c\
	misc.c plotone.c files.c utils.c drawticks.c\
	lmdif1.c as274c.c fit.c fourier.c io.c\
	binio.c graphu1.c graphu2.c setutils.c setprops.c\
	regionutils.c objutils.c computils.c defaults.c checkon.c\
	params.c getparms.c compute.c xvlib.c rotated.c\
	image_f_io.c draw.c ps.c mif.c leaf.c\
	hp.c chersh.c pars.c motifutils.c

OBJS =  main.o xmgr.o events.o malerts.o fileswin.o blockwin.o\
	eblockwin.o printwin.o drawwin.o comwin.o compwin.o\
	setwin.o hotwin.o ptswin.o editpwin.o regionwin.o\
	statuswin.o symwin.o tickwin.o graphwin.o worldwin.o\
	strwin.o labelwin.o locatewin.o framewin.o pagewin.o\
	monwin.o helpwin.o nonlwin.o miscwin.o stubs.o\
	misc.o plotone.o files.o utils.o drawticks.o\
	lmdif1.o as274c.o fit.o fourier.o io.o\
	binio.o graphu1.o graphu2.o setutils.o setprops.o\
	regionutils.o objutils.o computils.o defaults.o checkon.o\
	params.o getparms.o compute.o xvlib.o rotated.o\
	image_f_io.o draw.o ps.o mif.o leaf.o\
	hp.o chersh.o pars.o motifutils.o

# The following are for a version that does not link to
# the X libraries.
#
# non-X version sources
#
GRSRCS =  main.c stubs.c misc.c plotone.c files.c utils.c drawticks.c\
	lmdif1.c as274c.c fit.c fourier.c io.c\
	binio.c graphu1.c graphu2.c setutils.c setprops.c\
	regionutils.c objutils.c computils.c defaults.c checkon.c\
	params.c getparms.c compute.c\
	draw.c ps.c mif.c leaf.c\
	hp.c chersh.c pars.c

GROBJS =  main.o stubs.o misc.o plotone.o files.o utils.o drawticks.o\
	lmdif1.o as274c.o fit.o fourier.o io.o\
	binio.o graphu1.o graphu2.o setutils.o setprops.o\
	regionutils.o objutils.o computils.o defaults.o checkon.o\
	params.o getparms.o compute.o\
	draw.o ps.o mif.o leaf.o\
	hp.o chersh.o pars.o

GRINCS = defines.h externs.h globals.h pars.h symdefs.h\
	 noxprotos.h draw.h f2c.h as274c.h patchlevel.h hersh.h\
	 symdef.h special.h

# for printing and making a distribution
#
INCS = defines.h externs.h globals.h motifinc.h pars.h xmgr_icon.h symdefs.h\
	 xprotos.h noxprotos.h draw.h f2c.h as274c.h bitmaps.h patterns.h\
	 patchlevel.h rotated.h
HERSHINCS = hersh.h symdef.h special.h
DISTDIR = xmgr-4.00
HELPFILES = doc/xmgr.html\
	doc/README\
	doc/FAQ\
	doc/TODO\
	doc/graphs.html\
	doc/points.html\
	doc/trans.html\
	doc/commands.html\
	doc/main.html\
	doc/regions.html\
	doc/view.html\
	doc/graphops.html\
	doc/page.html\
	doc/status.html\
	doc/sets.html

xmgr: $(OBJS)
	$(CC) $(OBJS) -o xmgr $(NETCDFLIBS) $(XBAE_LIBS) $(LIBS)

gr: $(GROBJS)
	$(CC) $(GROBJS) -o gr $(NETCDFLIBS) $(GRLIBS)

local: $(OBJS) viswin.o visutils.o
	$(CC) $(OBJS) viswin.o visutils.o -o xmgr $(NETCDFLIBS) $(LIBS) 

main.o: Makefile defines.h globals.h
xmgr.o: defines.h globals.h
pars.o: pars.c defines.h globals.h
calc.o: defines.h globals.h
compute.o: defines.h globals.h
fit.o: defines.h
files.o: defines.h globals.h
io.o: defines.h

params.o: defines.h globals.h 
getparams.o: defines.h globals.h 

plotone.o: defines.h globals.h symdefs.h
drawticks.o: defines.h globals.h 

utils.o: defines.h globals.h
setutils.o: defines.h globals.h
setprops.o: defines.h globals.h
regionutils.o: defines.h globals.h
graphu1.o: defines.h globals.h
graphu2.o: defines.h globals.h
objutils.o: defines.h globals.h 
stubs.o: defines.h globals.h

checkon.o: defines.h globals.h 

#
# user interface
#
graphwin.o: defines.h globals.h
compwin.o: defines.h globals.h
setwin.o: defines.h globals.h
framewin.o: defines.h globals.h
blockwin.o: defines.h globals.h
eblockwin.o: defines.h globals.h
strwin.o: defines.h globals.h
worldwin.o: defines.h globals.h
symwin.o: defines.h globals.h
ptswin.o: defines.h globals.h
editpwin.o: defines.h globals.h
drawwin.o: defines.h globals.h
statuswin.o: defines.h globals.h patchlevel.h
printwin.o: defines.h globals.h
labelwin.o: defines.h globals.h
locatewin.o: defines.h globals.h
fileswin.o: defines.h globals.h
parmsiowin.o: defines.h globals.h
comwin.o: defines.h globals.h

defaults.o: defines.h globals.h

#
# graphics drivers
#
chersh.o: hersh.h special.h symdef.h
draw.o: symdefs.h
mif.o: externs.h
hp.o: externs.h
ps.o: externs.h
xvlib.o: externs.h

globals.h: pars.h

pars.h:
	yacc -dt pars.y
	/bin/mv y.tab.h pars.h

install:
	install -s -m 751 xmgr $(BINDIR)
	install -c -m 644 XMgr.ad $(APPDEFAULTS)/XMgr
	-rm $(BINDIR)/grbatch
	ln -s $(BINDIR)/xmgr $(BINDIR)/grbatch

lint:
	lint  $(INCLUDES) $(SRCS)

clean: 
	/bin/rm xmgr $(OBJS)

distrib:
	/bin/rm -rf $(DISTDIR)
	mkdir $(DISTDIR)
	mkdir $(DISTDIR)/src
	mkdir $(DISTDIR)/aux
	mkdir $(DISTDIR)/contrib
	mkdir $(DISTDIR)/examples
	mkdir $(DISTDIR)/doc
	cp -p INSTALL README COPYRIGHT $(DISTDIR)
	cp -p Imakefile Makefile $(SRCS) pars.yacc $(INCS) $(HERSHINCS) $(DISTDIR)/src
	cp -p Makefile $(DISTDIR)/src/Makefile.orig
	cp -p XMgr.ad $(DISTDIR)/src/XMgr.ad
	cp -rp examples $(DISTDIR)
	cp -p aux/jul2greg.c $(DISTDIR)/aux/jul2greg.c
	cp -p aux/greg2jul.c $(DISTDIR)/aux/greg2jul.c
	cp -p aux/cnvparm.c $(DISTDIR)/aux/cnvparm.c
	cp -p $(HELPFILES) $(DISTDIR)/doc
	cp -rp contrib/npipe $(DISTDIR)/contrib
	cp -p contrib/README.EPS $(DISTDIR)/contrib
	cp -p contrib/README $(DISTDIR)/contrib

localdistrib:
	mkdir $(DISTDIR)
	mkdir $(DISTDIR)/src
	mkdir $(DISTDIR)/bin
	cp -p Imakefile Makefile xmgr.man $(SRCS) pars.yacc $(INCS) $(HERSHINCS) $(DISTDIR)/src
	cp -p Makefile $(DISTDIR)/src/Makefile.orig
	cp -p XMgr.ad $(DISTDIR)/src/XMgr.ad

grdistrib:
	tar cvf gr.tar Makefile $(GRSRCS) pars.yacc $(GRINCS)

tarfile:
	tar cvf $(DISTDIR).tar $(DISTDIR)
	gzip $(DISTDIR).tar

vi:
	vi Makefile README $(SRCS) $(INCS) hersh.h special.h symdef.h

wc:
	wc Makefile README $(SRCS) $(INCS) hersh.h special.h symdef.h

rcs: Makefile Imakefile README patchlevel.h pars.yacc $(SRCS) $(INCS)
	ci -l $?
	touch rcs

protos: $(SRCS)
	cextract $(SRCS) >> prototypes.h

