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)toisegment.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)sfftc.o $(AOBJ)mesovh.o \
            $(AOBJ)fits2ascii.o $(AOBJ)tgenw.o $(AOBJ)tstmap2toi.o $(AOBJ)tsttoi2map.o \
            $(AOBJ)tstflag.o $(AOBJ)tstdemopipe.o
EXELIST := $(AOBJ)sfftc $(AOBJ)simtst $(AOBJ)mesovh $(AOBJ)tstrztoi $(AOBJ)fits2asc $(AOBJ)tsttoi \
           $(AOBJ)tsttoi2 $(AOBJ)fits2ascii $(AOBJ)tgenw $(AOBJ)tstmap2toi $(AOBJ)tsttoi2map \
           $(AOBJ)tstflag $(AOBJ)tstdemopipe

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 toisegment.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

########################################
#### Les Executables des Programmes ####
########################################
tstrztoi: $(AOBJ)tstrztoi
	@echo done
$(AOBJ)tstrztoi: $(AOBJ)tstrztoi.o $(AOBJ)rztoi.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)

sfftc: $(AOBJ)sfftc
	@echo done
$(AOBJ)sfftc: $(AOBJ)sfftc.o  $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)

mesovh: $(AOBJ)mesovh
	@echo done
$(AOBJ)mesovh: $(AOBJ)mesovh.o  $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)

simtst: $(AOBJ)simtst
	@echo done
$(AOBJ)simtst: $(AOBJ)simtst.o  $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)

fits2asc: $(AOBJ)fits2asc
	@echo done
$(AOBJ)fits2asc: $(AOBJ)fits2asc.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)

tsttoi: $(AOBJ)tsttoi
	@echo done
$(AOBJ)tsttoi: $(AOBJ)tsttoi.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)

tsttoi2: $(AOBJ)tsttoi2
	@echo done
$(AOBJ)tsttoi2: $(AOBJ)tsttoi2.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)

fits2ascii: $(AOBJ)fits2ascii
	@echo done
$(AOBJ)fits2ascii: $(AOBJ)fits2ascii.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)

tgenw: $(AOBJ)tgenw
	@echo done
$(AOBJ)tgenw: $(AOBJ)tgenw.o  $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)

tstmap2toi: $(AOBJ)tstmap2toi
	@echo done
$(AOBJ)tstmap2toi: $(AOBJ)tstmap2toi.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)

tsttoi2map: $(AOBJ)tsttoi2map
	@echo done
$(AOBJ)tsttoi2map: $(AOBJ)tsttoi2map.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)

tstflag: $(AOBJ)tstflag
	@echo done
$(AOBJ)tstflag: $(AOBJ)tstflag.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)

tstdemopipe: $(AOBJ)tstdemopipe
	@echo done
$(AOBJ)tstdemopipe: $(AOBJ)tstdemopipe.o $(LIBOLIST)
	$(LINK.cc)  -o $@ $^ $(LIBS)

################################################
#### Compilation des Sources des Programmes ####
################################################
$(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)tgenw.o: tgenw.cc $(INCLIST)
$(AOBJ)tstmap2toi.o: tstmap2toi.cc $(INCLIST)
$(AOBJ)tsttoi2map.o: tsttoi2map.cc $(INCLIST)
$(AOBJ)tstflag.o: tstflag.cc $(INCLIST)
$(AOBJ)tstdemopipe.o: tstdemopipe.cc $(INCLIST)


################################################
#### Compilation des Sources des Librairies ####
################################################
$(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 
$(AOBJ)toisegment.o: toisegment.cc toiprocessor.h config.h conf.h toi.h
