#
# Makefile for saoimage
#
#  May 8, 1990
#
# IFLAGS: image reading code to be built into saoimage
# -DFITS - reads array files with FITS headers
# -DOIF - reads IRAF .imh/(.pix) files with detached headers
# -DIMTOOL - include code to support imtool interactions with IRAF
#
# MFLAGS - machine or library specific code
# -DSUN - sunOS temp file name, ieee floating point debug, and sun keyboard
# -DLSB - byte swap for FITS (VAX and DECstations)
# -DXV11R2 - Xlib not up to full XV11R3 standards (i.e. all DEC products)
# -DSYSV - substitutes for getdtablesize() and setrlimit() unknown on HP
# -DPSCRIPT - hard copy output to a PostScript printer (else no hardcopy)
#

# uncomment these two lines to compile with gcc (add any optimizers you wish)
#CC = gcc -finline-functions
#TARGET_ARCH =

#IFLAGS = -DFITS -DOIF
IFLAGS = -DFITS -DOIF -DIMTOOL

#MFLAGS = -DLSB -DXV11R2
MFLAGS = -DSUN -DPSCRIPT

#DFLAGS = -g -DDEBUG
DFLAGS = -O

CFLAGS = $(DFLAGS) $(MFLAGS) $(IFLAGS)

PROG = saoimage
# btnlib must be made separately
XLIB = btnlib/libbtn.a -lX11
# put additional libraries for image IO here
IOLIBS =
LIBS =	-lm $(XLIB)

HFILES = \
	hfiles/buffer.h		hfiles/cgraph.h		hfiles/cmdparse.h \
	hfiles/color.h		hfiles/colormap.h	hfiles/constant.h \
	hfiles/control.h	hfiles/coord.h		hfiles/cursor.h \
	hfiles/define.h		hfiles/edit.h		hfiles/extern.h	\
	hfiles/histeq.h		hfiles/image.h		hfiles/imtool.h \
	hfiles/magnify.h	hfiles/region.h		hfiles/rtcmd.h \
	hfiles/scale.h		hfiles/struct.h 	hfiles/window.h

DEFILES = \
	defs/btnbox.def		defs/cgraph.def		defs/circle.def \
	defs/color.def		defs/colorbox.def	defs/colormap.def \
	defs/control.def	defs/cursor.def		defs/desktop.def \
	defs/dispbox.def	defs/dither.def		defs/graphbox.def \
	defs/image.def		defs/magnibox.def	defs/magnify.def \
	defs/magnify.def	defs/mouse.def		defs/panbox.def

SRCS =	cmddisp.c	cmdimage.c	cmdnew.c	cmdparse.c \
	clralloc.c	clrctrl.c	clrhard.c	clrinit.c \
	clrmap.c	clrmenu.c	clrread.c	clrsetup.c \
	clrvary.c \
	crdinvrt.c	crdrot.c	crdset.c	crdsynth.c \
	crdtemp.c	crdtrans.c \
	csranli.c	csrarea.c	csrcoord.c	csrctrl.c \
	csrdraw.c	csrgrab.c	csrmove.c	csrpoly1.c \
	csrpoly2.c	csrpoly3.c	csrsave.c	csrshape.c \
	csrslct.c \
	ctrlcntn.c	ctrldisk.c	ctrlfile.c	ctrlgc.c \
	ctrlmbox.c	ctrlpipe.c	ctrlsckt.c \
	dispblnk.c	dispbtmp.c	dispdfse.c	dispdthr.c \
	display.c	disppsct.c	disppxmp.c \
	editctrl.c	editdraw.c	editemcs.c	editinit.c \
	editline.c	editrdrw.c \
	grphbar.c	grphbtmp.c	grphctrl.c	grphdraw.c \
	grphgrab.c	grphinit.c	grphlbl.c	grphline.c \
	grphmove.c	grpholap.c	grphpos.c	grphtext.c \
	histdist.c	histeql.c	histlist.c	histmap.c \
	histscan.c	histzero.c \
	imgcheck.c	imgflip.c	imglogo.c	imgnew.c \
	imgparam.c	imgread.c	imgrot.c	imgtrans.c \
	irafcrd.c	irafdisp.c	irafenv.c	iraffdbk.c \
	irafimtl.c	irafio.c	irafpipe.c \
	mainbffr.c	mainevnt.c	maininit.c	mainkey.c \
	mainslct.c	mainutil.c \
	menuctrl.c	menuinit.c \
	mgfyctrl.c	mgfydraw.c	mgfyinit.c	mgfymark.c \
	mgfytabl.c	mgfyval.c \
	pancopy.c	pancrsr.c	panctrl.c	panimage.c \
	panwndw.c \
	readarr.c	readfith.c	readfits.c	readint.c \
	readiraf.c	readreal.c \
	rgnanli.c	rgnctrl.c	rgndraw.c	rgndrop.c \
	rgnmake.c	rgnread.c	rgntoken.c	rgnwpros.c \
	rgnwrite.c \
	rtcmd.c		rtio.c \
	sclctrl.c	sclmap.c \
	wndwadj.c	wndwconf.c	wndwcre.c	wndwinit.c \
	wndwmaus.c

OBJS =	clralloc.o	clrctrl.o	clrhard.o	clrinit.o \
	clrmap.o	clrmenu.o	clrread.o	clrsetup.o \
	clrvary.o \
	cmddisp.o	cmdimage.o	cmdnew.o	cmdparse.o \
	crdinvrt.o	crdrot.o	crdset.o	crdsynth.o \
	crdtemp.o	crdtrans.o \
	csranli.o	csrarea.o	csrcoord.o	csrctrl.o \
	csrdraw.o	csrgrab.o	csrmove.o	csrpoly1.o \
	csrpoly2.o	csrpoly3.o	csrsave.o	csrshape.o \
	csrslct.o \
	ctrlcntn.o	ctrldisk.o	ctrlfile.o	ctrlgc.o \
	ctrlmbox.o	ctrlpipe.o	ctrlsckt.o \
	dispblnk.o	dispbtmp.o	dispdfse.o	dispdthr.o \
	display.o	disppsct.o	disppxmp.o \
	editctrl.o	editdraw.o	editemcs.o	editinit.o \
	editline.o	editrdrw.o \
	grphbar.o	grphbtmp.o	grphctrl.o	grphdraw.o \
	grphgrab.o	grphinit.o	grphlbl.o	grphline.o \
	grphmove.o	grpholap.o	grphpos.o	grphtext.o \
	histdist.o	histeql.o	histlist.o	histmap.o \
	histscan.o	histzero.o \
	imgcheck.o	imgflip.o	imglogo.o	imgnew.o \
	imgparam.o	imgread.o	imgrot.o	imgtrans.o \
	irafcrd.o	irafdisp.o	irafenv.o	iraffdbk.o \
	irafimtl.o	irafio.o	irafpipe.o \
	mainbffr.o	mainevnt.o	maininit.o	mainkey.o \
	mainslct.o	mainutil.o \
	menuctrl.o	menuinit.o	menupanl.o \
	mgfyctrl.o	mgfydraw.o	mgfyinit.o	mgfymark.o \
	mgfytabl.o	mgfyval.o \
	pancopy.o	pancrsr.o	panctrl.o	panimage.o \
	panwndw.o \
	readarr.o	readfith.o	readfits.o	readint.o \
	readiraf.o	readreal.o \
	rgnanli.o	rgnctrl.o	rgndraw.o	rgndrop.o \
	rgnmake.o	rgnread.o	rgntoken.o	rgnwpros.o \
	rgnwrite.o \
	sclctrl.o	sclmap.o \
	wndwadj.o	wndwconf.o	wndwcre.o	wndwinit.o \
	wndwmaus.o

PROGRAM =	saoimage

saoimage:	$(OBJS)
		cc $(CFLAGS) $(OBJS) -o $(PROGRAM) $(LIBS)

static:		$(OBJS)
		cc $(CFLAGS) $(OBJS) -Bstatic -o $(PROGRAM) $(LIBS)

lint:
	lint -b -DDEBUG $(MFLAGS) $(IFLAGS) $(SRCS)

tar:
	tar cfv saoimage.tar makefile.* readme.txt \
	update.* $(SRCS) $(HFILES) $(DEFILES) make.* vms/* doc/* \
	btnlib/*.c btnlib/*.h btnlib/readme btnlib/make.* btnlib/makefile \
	btnlib/tool/*.c btnlib/tool/*.h btnlib/tool/makefile \
	panel/*.c panel/*.h panel/*.mnu panel/makefile

pipe:
	tar cfv - makefile.* readme.txt \
	update.* $(SRCS) $(HFILES) $(DEFILES) make.* vms/* doc/* \
	btnlib/*.c btnlib/*.h btnlib/readme btnlib/make.* btnlib/makefile \
	btnlib/tool/*.c btnlib/tool/*.h btnlib/tool/makefile \
	panel/*.c panel/*.h panel/*.mnu panel/makefile

tape:
	tar cfv /dev/nrxt8 makefile.* readme.txt \
	update.* $(SRCS) $(HFILES) $(DEFILES) make.* vms/* doc/* \
	btnlib/*.c btnlib/*.h btnlib/readme btnlib/make.* btnlib/makefile \
	btnlib/tool/*.c btnlib/tool/*.h btnlib/tool/makefile
	panel/*.c panel/*.h panel/*.mnu panel/makefile

XLIBH = /usr/include/X11/Xlib.h /usr/include/X11/Xutil.h
STRUCT = hfiles/struct.h hfiles/buffer.h hfiles/color.h hfiles/control.h \
	 hfiles/coord.h hfiles/cursor.h hfiles/image.h hfiles/window.h
WORKS = $(XLIBH) $(STRUCT) hfiles/constant.h hfiles/extern.h

clralloc.o	: $(XLIBH) hfiles/color.h hfiles/define.h
clrbar.o	:
clrctrl.o	: $(WORKS) hfiles/cgraph.h
clrhard.o	: $(XLIBH) hfiles/color.h
clrinit.o	: $(XLIBH) hfiles/color.h hfiles/control.h
clrmap.o	: $(XLIBH) hfiles/color.h hfiles/define.h
clrmenu.o	: $(XLIBH) hfiles/color.h hfiles/colormap.h hfiles/constant.h \
		hfiles/define.h hfiles/edit.h defs/colormap.def
clrread.o	: hfiles/colormap.h hfiles/define.h
clrsetup.o	: $(XLIBH) hfiles/color.h
clrvary.o	: $(WORKS) hfiles/cgraph.h hfiles/define.h
cmddisp.o	: $(WORKS) hfiles/cmdparse.h
cmdimage.o	: $(WORKS) hfiles/cmdparse.h
cmdnew.o	: $(XLIBH) $(STRUCT) hfiles/cmdparse.h hfiles/define.h \
		hfiles/extern.h
cmdparse.o	: $(WORKS) hfiles/cmdparse.h
crdinvrt.o	: hfiles/coord.h
crdrot.o	: hfiles/coord.h
crdset.o	: hfiles/coord.h hfiles/image.h
crdsynth.o	: hfiles/coord.h
crdtemp.o	: hfiles/coord.h
crdtrans.o	: hfiles/coord.h
csranli.o	: $(XLIBH) hfiles/color.h hfiles/cursor.h
csrarea.o	: $(XLIBH) hfiles/color.h hfiles/constant.h hfiles/cursor.h
csrcoord.o	: $(XLIBH) hfiles/color.h hfiles/constant.h hfiles/coord.h \
		hfiles/cursor.h
csrctrl.o	: $(WORKS)
csrdraw.o	: $(XLIBH) hfiles/color.h hfiles/cursor.h
csrgrab.o	: $(XLIBH) hfiles/color.h hfiles/constant.h hfiles/cursor.h \
		hfiles/define.h
csrmove.o	: $(XLIBH) hfiles/color.h hfiles/constant.h hfiles/cursor.h \
		hfiles/define.h
csrpoly1.o	: $(XLIBH) hfiles/color.h hfiles/coord.h hfiles/cursor.h \
		hfiles/define.h
csrpoly2.o	: $(XLIBH) hfiles/color.h hfiles/constant.h hfiles/coord.h \
		hfiles/cursor.h
csrpoly3.o	: $(XLIBH)
csrsave.o	: $(XLIBH) hfiles/color.h hfiles/constant.h hfiles/cursor.h
csrshape.o	: $(XLIBH) hfiles/color.h hfiles/constant.h hfiles/cursor.h \
		defs/circle.def
csrslct.o	: $(WORKS)
ctrlcntn.o	: $(XLIBH) hfiles/control.h
ctrldisk.o	:
ctrlfile.o	: $(XLIBH) hfiles/edit.h
ctrlgc.o	: $(XLIBH) hfiles/color.h hfiles/define.h
ctrlmbox.o	: $(XLIBH) hfiles/control.h
ctrlpipe.o	:
ctrlsckt.o	: $(XLIBH) hfiles/control.h
dispblnk.o	: $(WORKS)
dispbtmp.o	: $(WORKS) hfiles/define.h hfiles/scale.h defs/dither.def
dispdfse.o	:
dispdthr.o	:
display.o	: $(XLIBH) $(STRUCT) hfiles/define.h hfiles/extern.h \
		hfiles/scale.h
disppsct.o	: $(WORKS) hfiles/define.h hfiles/scale.h hfiles/region.h
disppxmp.o	: hfiles/coord.h
grphbar.o	:
grphbtmp.o	: $(XLIBH) hfiles/color.h
grphctrl.o	: $(WORKS) hfiles/cgraph.h defs/cgraph.def
grphdraw.o	: $(XLIBH) hfiles/cgraph.h hfiles/color.h
grphgrab.o	: $(XLIBH) hfiles/cgraph.h hfiles/color.h
grphinit.o	: $(XLIBH) $(STRUCT) hfiles/cgraph.h hfiles/extern.h
grphlbl.o	: $(XLIBH) $(STRUCT) hfiles/cgraph.h hfiles/define.h \
		hfiles/extern.h
grphline.o	: $(XLIBH) hfiles/cgraph.h hfiles/color.h
grphmove.o	: $(XLIBH) hfiles/cgraph.h hfiles/color.h
grpholap.o	: $(XLIBH) hfiles/cgraph.h hfiles/color.h
grphpos.o	: $(XLIBH)
grphtext.o	: $(XLIBH) $(STRUCT) hfiles/cgraph.h hfiles/extern.h
editctrl.o	: $(XLIBH) hfiles/color.h hfiles/window.h hfiles/edit.h
editdraw.o	: $(XLIBH) hfiles/edit.h
editemcs.o	: $(XLIBH) hfiles/edit.h
editinit.o	: $(XLIBH) hfiles/edit.h
editline.o	: $(XLIBH) hfiles/edit.h
editrdrw.o	: $(XLIBH) hfiles/edit.h
histdist.o	: hfiles/histeq.h
histeql.o	: hfiles/histeq.h
histlist.o	: hfiles/histeq.h
histmap.o	: hfiles/histeq.h
histscan.o	: hfiles/histeq.h
histzero.o	: hfiles/histeq.h
imgcheck.o	: hfiles/cmdparse.h hfiles/constant.h hfiles/image.h
imgflip.o	:
imglogo.o	:
imgnew.o	: $(WORKS) hfiles/define.h
imgparam.o	: hfiles/coord.h hfiles/define.h hfiles/image.h
imgread.o	: $(WORKS)
imgrot.o	:
imgtrans.o	: hfiles/define.h
irafcrd.o	: $(XLIBH) $(STRUCT) hfiles/extern.h
irafdisp.o	: $(WORKS) hfiles/scale.h
irafenv.o	: hfiles/coord.h hfiles/define.h hfiles/image.h hfiles/imtool.h
iraffdbk.o	: $(WORKS)
irafimtl.o	: $(WORKS) hfiles/imtool.h
irafio.o	: $(WORKS) hfiles/control.h hfiles/imtool.h
irafpipe.o	: hfiles/imtool.h
mainbffr.o	: $(XLIBH) $(WORKS) hfiles/scale.h
mainevnt.o	: $(WORKS) hfiles/define.h
maininit.o	: $(XLIBH) $(STRUCT) hfiles/constant.h hfiles/define.h \
		defs/color.def defs/control.def defs/image.def \
		defs/dispbox.def defs/magnibox.def defs/panbox.def \
		defs/btnbox.def defs/colorbox.def defs/graphbox.def \
		defs/desktop.def defs/cursor.def
mainkey.o	: $(WORKS) /usr/include/X11/keysym.h \
		/usr/include/X11/keysymdef.h
mainslct.o	: $(WORKS)
mainutil.o	: $(XLIBH) $(STRUCT) hfiles/extern.h
menuctrl.o	: $(WORKS) btnlib/buttons.h
menuinit.o	: $(XLIBH) btnlib/buttons.h hfiles/window.h
menupanl.o	: panel/makemenu.c panel/menucmap.h panel/menuclr.h \
		panel/menucsr.h panel/menuetc.h panel/menumain.h \
		panel/menumono.h panel/menupan.h panel/menurgn.h \
		panel/menuscl.h
		cc -c $(CFLAGS) panel/makemenu.c; mv makemenu.o menupanl.o
mgfyctrl.o	: $(WORKS) hfiles/magnify.h
mgfydraw.o	: $(XLIBH) hfiles/color.h hfiles/magnify.h
mgfyinit.o	: $(XLIBH) $(STRUCT) hfiles/define.h hfiles/extern.h \
		hfiles/scale.h hfiles/magnify.h
mgfymark.o	: $(XLIBH) hfiles/color.h hfiles/magnify.h defs/magnify.def
mgfytabl.o	: $(XLIBH) $(STRUCT) hfiles/extern.h
mgfyval.o	: $(WORKS)
pancopy.o	: hfiles/define.h
pancrsr.o	: $(XLIBH) $(STRUCT) hfiles/extern.h
panctrl.o	: $(WORKS)
panimage.o	: $(XLIBH) $(STRUCT) hfiles/define.h hfiles/extern.h
panwndw.o	: $(XLIBH) $(STRUCT) hfiles/define.h hfiles/extern.h
readarr.o	: hfiles/constant.h hfiles/image.h
readfith.o	:
readfits.o	: hfiles/constant.h hfiles/image.h
readint.o	: hfiles/image.h hfiles/scale.h
readiraf.o	: hfiles/constant.h hfiles/image.h
readreal.o	: hfiles/image.h hfiles/scale.h
rgnanli.o	: $(XLIBH) hfiles/color.h hfiles/cursor.h
rgnctrl.o	: $(WORKS)
rgndraw.o	: $(WORKS) hfiles/define.h hfiles/region.h
rgndrop.o	: $(XLIBH) hfiles/constant.h hfiles/color.h hfiles/cursor.h \
		hfiles/define.h
rgnmake.o	: $(WORKS) hfiles/define.h
rgnread.o	: $(WORKS) hfiles/define.h hfiles/edit.h hfiles/region.h
rgntoken.o	: $(XLIBH) hfiles/constant.h hfiles/region.h
rgnwpros.o	: $(WORKS) hfiles/color.h hfiles/constant.h hfiles/cursor.h \
		hfiles/define.h
rgnwrite.o	: $(XLIBH) hfiles/constant.h hfiles/color.h hfiles/cursor.h \
		hfiles/define.h hfiles/edit.h hfiles/image.h
rtcmd.o		: $(WORKS) hfiles/rtcmd.h
rtio.o		: $(XLIBH) hfiles/control.h hfiles/rtcmd.h
sclctrl.o	: $(WORKS) hfiles/define.h hfiles/scale.h
sclmap.o	: $(WORKS) hfiles/scale.h
wndwadj.o	: $(XLIBH) $(STRUCT) hfiles/extern.h hfiles/cgraph.h
wndwconf.o	: $(XLIBH) $(STRUCT) hfiles/extern.h
wndwcre.o	: $(XLIBH) hfiles/window.h
wndwinit.o	: $(XLIBH) $(STRUCT) hfiles/define.h hfiles/extern.h
wndwmaus.o	: $(WORKS) defs/mouse.def
