# $Id: Makefile,v 1.19 1994/08/17 02:27:17 pturner Exp pturner $
#
# Makefile for xmgr Release 3.01
#

# Step 1.

# you may need to change the following
# BINDIR - location of the ACE/gr (xmgr) executable
# APPDEFAULTS - directory to put the ACE/gr application defaults file.
# HELPFILE - if not defined, then "ACEgr.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='"ACEgr.html"'
HELPVIEWER = -DGR_HELPVIEWER='"netscape"'
#HELPVIEWER = -DGR_HELPVIEWER='"Mosaic"'
#HELPVIEWER = -DGR_HELPVIEWER='"xterm -e lynx"'
#HELPVIEWER = -DGR_HELPVIEWER='"mosaic"'
#HELPVIEWER = -DGR_HELPVIEWER='"xmosaic"'
#HELPVIEWER = -DGR_HELPVIEWER='"netscape"'

# Step 2.

# You need to select the machine type
# uncomment one of the following, make sure the
# others are commented out
##################################

### 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 X11R6/Motif 1.2
LIBS = -L/usr/X11R6/lib -lXm -lXt -lX11 -lm
INCLUDES = -I/usr/X11R6/include
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

### Sun - Solaris 2.4 and 2.5 - Motif 1.2.2/X11R5
#LIBS = -L/usr/openwin/lib -L/usr/dt/lib -lXm -lXt -lX11 -lm  -R/usr/openwin/lib -R/usr/dt/lib
#INCLUDES = -I/usr/openwin/include -I/usr/dt/include
#CC = cc -O -DSOLARIS
### End Sun Solaris

### Solaris 2.3
#LIBS = -L/usr/openwin/lib -L/opt/SUNWmotif/lib -lXm -lXt -lX11 -lm -lgen -R/usr/openwin/lib -R/opt/SUNWmotif/lib
#INCLUDES = -I/usr/openwin/include -I/opt/SUNWmotif/include
#CC = cc -O -DSOLARIS

### SGI
#LIBS = -lXm -lXt -lX11 -lPW -lm
#
# alternate LIBS for log10 bug (if autoscaling does not work, try this)
#LIBS = -lXm_s -lXt_s -lX11_s -lPW -lm43 -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 3.01/400 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/include
#NETCDFLIBS = -L/usr/local/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.

# Xmgr uses 4 scratch arrays, designated in the function that
# interprets expressions as a, b, c, and d. MAXARR is the amount
# of memory that will be allocated for these arrays and at present
# there is no provision for dynamically extending the length of these 
# arrays. This sets a limit on the length of a set inasmuch
# as no operation between sets and the scratch arrays should exceed 
# this amount. MAXARR does NOT set a limit on the size of a set, on our 
# Sun4 (32Mb) we run MAXARR = 60000, I've plotted data sets in excess 
# of 700k points.
#
MAXARR = -DMAXARR=20480

###############################
# End installation parameters #
###############################

# Under construction, unless you are interested in development
# leave the following 3 lines commented out;
#HAS_XBAE = -DHAS_XBAE
#XBAE_LIBS = -lXbae
#XBAE_INCLUDES = 

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

# 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\
	plotone.c\
	files.c\
	utils.c\
	drawticks.c\
	lmdif1.c\
	fit.c\
	fourier.c\
	io.c\
	graphutils.c\
	graphutils2.c\
	setutils.c\
	setprops.c\
	regionutils.c\
	objutils.c\
	computils.c\
	defaults.c\
	checkon.c\
	params.c\
	getparms.c\
	compute.c\
	xvlib.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\
	plotone.o\
	files.o\
	utils.o\
	drawticks.o\
	lmdif1.o\
	fit.o\
	fourier.o\
	io.o\
	graphutils.o\
	graphutils2.o\
	setutils.o\
	setprops.o\
	regionutils.o\
	objutils.o\
	computils.o\
	defaults.o\
	checkon.o\
	params.o\
	getparms.o\
	compute.o\
	xvlib.o\
	image_f_io.o\
	draw.o\
	ps.o\
	mif.o\
	leaf.o\
	hp.o\
	chersh.o\
	pars.o\
	motifutils.o

D3DINCS = defs.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 bitmaps.h patterns.h patchlevel.h
HERSHINCS = hersh.h symdef.h special.h
DISTDIR = xmgr-3.01
HELPFILES = doc/ACEgr.html\
	doc/README.html\
	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)

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
graphutils.o: defines.h globals.h
graphutils2.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 Makefile.top $(DISTDIR)/Makefile
	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

tarfile:
	tar cvf $(DISTDIR).tar $(DISTDIR)
	compress $(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 Makefile.top Imakefile README patchlevel.h pars.yacc $(SRCS) $(INCS)
	ci -l $?
	touch rcs

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

