# @(#)IM/Makefile %I% %E% %U%"
#Copyright (C) 1992, California Institute of Technology.
#U.S. Government Sponsorship under NASA Contract NAS7-918
#is acknowledged.
RANLIB= :
# CFLAGS = -g
TGT = ../..
SRC = Makefile \
       im.3 im.3f map.3 rwc.3 images.1 subim.1 \
       card.c close.c file.c hdr.c imf.c iraftime.c misc.c open.c \
       rkey.c rpix.c setw1.c window.c wkey.c wpix.c \
       rwc.c map_string.c mapset.c mapf.c mapi.c coord.c \
       im.h irafhdr.h map_struct.h rwc.h

TGT_IM = $(TGT)/lib/libim.a
TGT_MAN_C = $(TGT)/man/man3/im.3
TGT_MAN_F77 = $(TGT)/man/man3/im.3f
TGT_MAN_IMAGES = $(TGT)/man/man1/images.1
IM = libim.a
MAN_C = im.3
MAN_F77 = im.3f
MAN_IMAGES = images.1
EXPORTDIR= ../../export/IM
SRCS = open.c close.c file.c hdr.c wkey.c rkey.c wpix.c rpix.c card.c misc.c \
       window.c setw1.c iraftime.c imf.c \
       rwc.c map_string.c mapset.c mapf.c mapi.c coord.c
       

HDRS = im.h im_proto.h irafhdr.h map_struct.h rwc.h
OBJS = open.o close.o file.o hdr.o wkey.o rkey.o wpix.o rpix.o card.o misc.o \
       window.o setw1.o iraftime.o imf.o \
       rwc.o map_string.o mapset.o mapf.o mapi.o coord.o

$(IM): $(OBJS)
	rm -f  $(IM)
	ar q   $(IM) $(OBJS)
	$(RANLIB) $(IM)

# V1.4 RWC handling moves internal to library
setw1.o: setw1.c im.h rwc.h

rwc.o: rwc.c rwc.h map_struct.h

$(OBJS): im.h

mapset.o: mapset.c map_struct.h
mapf.o: mapf.c map_struct.h
mapi.o: mapi.c map_struct.h
map_string.o: map_string.c map_struct.h

open.o misc.o wpix.o: irafhdr.h

#INSTALL_WITH_BACKUP = install $? $@ bak
INSTALL = rm -f $@; cp $? $@

tarfile:
	tar -cf libim.tar $(SRC)

#install: $(TGT_IM) $(TGT_MAN_C) $(TGT_MAN_F77) $(TGT_MAN_IMAGES)
install: $(TGT_IM)

export:
	mkdir $(EXPORTDIR)
	cp Makefile* $(SRCS) $(HDRS) $(EXPORTDIR)

$(TGT_IM): $(IM)
	if [ ! -d $(TGT)/lib ] ; then \
	    mkdir $(TGT)/lib ; else true ; \
	    fi ;
	$(INSTALL)
	$(RANLIB) $(TGT_IM)

$(TGT_MAN_C): $(MAN_C)
	$(INSTALL)

$(TGT_MAN_F77): $(MAN_F77)
	$(INSTALL)

$(TGT_MAN_IMAGES): $(MAN_IMAGES)
	$(INSTALL)

SCCS_COMMAND = deledit
sccs:
	sccs -d$(SCCS_DIR) $(SCCS_COMMAND) $(SRC)

clean:
	rm -f $(OBJS) $(IM)
