USERFLAGS = -I$(EXTLIBDIR)/Include/FitsIO -DWITH_SOPHYA
include $(DPCBASEREP)/Include/MakefileUser.h

ALIB := ./$(MACHDIR)/
AOBJ := ./$(MACHDIR)/

$(AOBJ)%.o:%.cc
	$(COMPILE.cc) $(USERFLAGS) -o $@ $<
$(AOBJ)%.o:%.c
	$(COMPILE.c) $(CFLAGS) $(USERFLAGS) -o $@ $<

LIBOLIST := $(AOBJ)asciitoiwtr.o $(AOBJ)fitstoirdr.o $(AOBJ)fitstoiwtr.o \
            $(AOBJ)toi.o $(AOBJ)toimanager.o $(AOBJ)toiprocessor.o $(AOBJ)genwproc.o \
            $(AOBJ)toisqfilter.o $(AOBJ)toiregwindow.o $(AOBJ)toiseqbuff.o \
            $(AOBJ)simtoipr.o $(AOBJ)map2toi.o $(AOBJ)toi2map.o $(AOBJ)nooppr.o
EXEOLIST := $(AOBJ)fits2asc.o $(AOBJ)tsttoi.o $(AOBJ)tsttoi2.o $(AOBJ)simtst.o \
            $(AOBJ)tstrztoi.o $(AOBJ)rztoi.o \
            $(AOBJ)fits2ascii.o $(AOBJ)tstmap2toi.o $(AOBJ)tsttoi2map.o 
EXELIST := $(AOBJ)sfftc $(AOBJ)simtst $(AOBJ)mesovh $(AOBJ)tstrztoi $(AOBJ)fits2asc $(AOBJ)tsttoi \
           $(AOBJ)tsttoi2 $(AOBJ)fits2ascii $(AOBJ)tstmap2toi $(AOBJ)tsttoi2map

INCLIST := asciitoiwtr.h fitstoirdr.h fitstoiwtr.h toi.h config.h conf.h \
           toiprocessor.h genwproc.h toimanager.h toiseqbuff.h toiregwindow.h \
           simtoipr.h map2toi.h toi2map.h nooppr.h

all : $(EXELIST) 
lib : $(LIBOLIST)

clean:
	rm -f  $(LIBOLIST)
	rm -f  $(EXEOLIST)
	rm -f  $(EXELIST)

LIBF =  $(SLB)libsophya.so $(SLB)libextsophya.so 
LIBS =  -L$(SLB) -lextsophya -lsophya -lpthread -lm
ifeq ($(MACHEROS),OSF1)
LIBS := $(LIBS) -lfor
endif


$(AOBJ)tstrztoi: $(AOBJ)tstrztoi.o $(AOBJ)rztoi.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)
$(AOBJ)sfftc: $(AOBJ)sfftc.o  $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)
$(AOBJ)mesovh: $(AOBJ)mesovh.o  $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)
$(AOBJ)simtst: $(AOBJ)simtst.o  $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)
$(AOBJ)fits2asc: $(AOBJ)fits2asc.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)
$(AOBJ)tsttoi: $(AOBJ)tsttoi.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)
$(AOBJ)tsttoi2: $(AOBJ)tsttoi2.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)
$(AOBJ)fits2ascii: $(AOBJ)fits2ascii.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)
$(AOBJ)tstmap2toi: $(AOBJ)tstmap2toi.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)
$(AOBJ)tsttoi2map: $(AOBJ)tsttoi2map.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)

$(AOBJ)simtst.o: simtst.cc $(INCLIST)
$(AOBJ)sfftc.o: sfftc.cc $(INCLIST)
$(AOBJ)mesovh.o: mesovh.cc $(INCLIST)
$(AOBJ)tstrztoi.o: tstrztoi.cc rztoi.h $(INCLIST)
$(AOBJ)rztoi.o: rztoi.cc rztoi.h $(INCLIST)
$(AOBJ)fits2asc.o: fits2asc.cc $(INCLIST)
$(AOBJ)tsttoi.o: tsttoi.cc $(INCLIST)
$(AOBJ)tsttoi2.o: tsttoi2.cc $(INCLIST)
$(AOBJ)fits2ascii.o: fits2ascii.cc $(INCLIST)
$(AOBJ)tstmap2toi.o: tstmap2toi.cc $(INCLIST)
$(AOBJ)tsttoi2map.o: tsttoi2map.cc $(INCLIST)

$(AOBJ)asciitoiwtr.o: asciitoiwtr.cc asciitoiwtr.h toi.h config.h conf.h \
                      toiprocessor.h toimanager.h 
$(AOBJ)fitstoirdr.o: fitstoirdr.cc fitstoirdr.h toiprocessor.h config.h conf.h
$(AOBJ)fitstoiwtr.o: fitstoiwtr.cc fitstoiwtr.h toi.h config.h conf.h
$(AOBJ)toi.o: toi.cc toiprocessor.h config.h conf.h toi.h 
$(AOBJ)toimanager.o: toimanager.cc toimanager.h
$(AOBJ)toiprocessor.o: toiprocessor.cc toiprocessor.h config.h conf.h toi.h \
                       toimanager.h
$(AOBJ)genwproc.o: genwproc.h toiprocessor.h toimanager.h
$(AOBJ)toisqfilter.o: toisqfilter.cc toisqfilter.h toiprocessor.h config.h \
                      conf.h toi.h toimanager.h
$(AOBJ)toiseqbuff.o: toiseqbuff.cc toiprocessor.h config.h conf.h toi.h \
                     toiseqbuff.h 
$(AOBJ)toiregwindow.o: toiregwindow.cc toiprocessor.h config.h conf.h toi.h \
                     toiregwindow.h 
$(AOBJ)simtoipr.o: simtoipr.cc toiprocessor.h config.h conf.h toi.h \
                   simtoipr.h 
$(AOBJ)map2toi.o: map2toi.cc map2toi.h 
$(AOBJ)toi2map.o: toi2map.cc toi2map.h 
$(AOBJ)nooppr.o: nooppr.cc nooppr.h 
