# Look for include file dependencies 
.KEEP_STATE:    

# Store your subroutine sources here
SRC_DIR = ../user_src

# Store your include files here
INC_DIR = ../user_inc	

# Store CIRTM application source files here
CIRTM_MAIN_DIR = ../cirtm_main	

# Store CIRTM subroutine source files here
CIRTM_SRC_DIR = ../cirtm_src	

# Store CIRTM subroutine include files here
CIRTM_INC_DIR = ../cirtm_inc	

TDB = /tes/tdb

# CIRTM, XView and other include files
INCS = $(CIRTM_INC_DIR) -I$(INC_DIR) -I$(TDB)/include -I$(OPENWINHOME)/include

# Libraries for XView
XLIBS = -L$(OPENWINHOME)/lib -lxview -lolgx -lX11

# Misc. Libraries for Sun
SUN_LIBS = -L/util/lang/SC1.0 -lm -lc 

# The cradlib.a
CRADLIB = $(CIRTM_SRC_DIR)/cradlib.a

# The TES Database library
TDB_LIB = $(TDB)/lib/libtdb.a

CC = gcc 

# C compiler flags, with includes
C_FLAGS =   -c -g -o $*.o -I$(INCS) 

SUN_LDFLAGS =  -g -o $@

all:	 xfunc

# Compilation rule
.c.o:	       
		$(CC) $(C_FLAGS) $<
.f.o:	       
		$(FC) $(F_FLAGS) $<

# Insert your include files here
INC_FILES =	$(INC_DIR)/your.h \
		$(INC_DIR)/your2.h

# Insert your subroutines here
LIB_FILES =   	$(SRC_DIR)/xview_func.o \
		$(SRC_DIR)/text_func.o 

$(CRADLIB):	$(CIRTM_SRC_DIR)/*.c $(CIRTM_INC_DIR)/*.h
		make -f $(CIRTM_MAIN_DIR)/makefile $(CIRTM_SRC_DIR)/cradlib.a

$(SRC_DIR)/yourlib.a:	$(LIB_FILES) $(INC_FILES)
			ar rv $(SRC_DIR)/yourlib.a $(LIB_FILES)
			ranlib $(SRC_DIR)/yourlib.a 	

xfunc:	xfunc.o $(SRC_DIR)/yourlib.a $(INC_FILES)
	$(LINK.c) $(SUN_LDFLAGS) xfunc.o \
	$(SRC_DIR)/yourlib.a \
	$(CRADLIB) \
	$(TDB_LIB) \
	$(XLIBS) \
	$(SUN_LIBS)

