#---------------------------------------------------------------------------
# Makefile for the TECS Client library and TecsServer
#
# Markus Zolliker, March 2000
# may now be used on different systems without change M.Z.01.2002
#--------------------------------------------------------------------------
#------------ for DigitalUnix (add -DFORTIFY to CC_... for fortified version)
CC_alpha_osf1=cc -std1 -g -warnprotos -I../ -I. -I../hardsup
FOR_alpha_osf1=f77 -u -g
TECS_PLOT_alpha_osf1=f90 -c -u -g -free tecs_plot.f
TECLI_LIB_alpha_osf1=-L/data/lnslib/lib -lpgplot -lX11 -lXm -so_archive
SYS_FILE_alpha_osf1=sys_aunix
#CFLAGS_alpha_osf1= -std1 -g -warnprotos -I../ -I. -I../hardsup -DFORTIFY 

#---------- for Redhat linux
CC_i386_linux= gcc -I/usr/local/include -I. -I../ -I../hardsup -DLINUX   -g 
FOR_i386_linux= g77 -u -fvxt -g
TECS_PLOT_i386_linux=g77 -c -u -g -ff90 -ffree-form tecs_plot.f
SYS_FILE_i386_linux=sys_linux
TECLI_LIB_i386_linux=pgplot/libpgplot.a -L/usr/X11R6/lib -lX11
#------------

CC=$(CC_$(MACHTYPE)_$(OSTYPE))
FOR=$(FOR_$(MACHTYPE)_$(OSTYPE))
TECS_PLOT=$(TECS_PLOT_$(MACHTYPE)_$(OSTYPE))
TECLI_LIB=$(TECLI_LIB_$(MACHTYPE)_$(OSTYPE))
SYS_FILE=$(SYS_FILE_$(MACHTYPE)_$(OSTYPE))

LIBR_OBJ= coc_util.o myc_err.o myc_str.o myc_buf.o myc_time.o
SERV_OBJ= tecs.o coc_server.o tecs_lsc.o tecs_serial.o coc_logfile.o tecs_data.o $(LIBR_OBJ)
CLI_OBJ= tecs_cli.o coc_client.o $(LIBR_OBJ)
TCLI_OBJ= $(SYS_FILE).o $(SYS_FILE)_c.o $(CLI_OBJ)
TECLI_OBJ= tecs_client.o tecs_plot.o sys_util.o str.o instr_hosts.o $(TCLI_OBJ)


.f.o:
	$(FOR) -c $*.f

.c.o:
	$(CC) -c $*.c

libtecsl.a: $(CLI_OBJ)
	- rm libtecsl.a
	ar cr libtecsl.a $(CLI_OBJ)
	ranlib libtecsl.a

all: libtecsl.a bin/TecsServer bin/TecsClient bin/keep_running

tecs_plot.o: tecs_plot.f
	$(TECS_PLOT)

bin/TecsServer: $(SERV_OBJ)
	- rm bin/TecsServer
	$(CC) -o bin/TecsServer $(SERV_OBJ) -lm -L../hardsup -lhlib

bin/TecsClient: $(TECLI_OBJ)
	$(FOR) -o bin/TecsClient $(TECLI_OBJ) \
           $(TECLI_LIB) -lreadline -ltermcap

bin/libtecs.so: tecs_c.c $(CLI_OBJ)
	$(CC) -shared -o bin/libtecs.so tecs_c.c $(CLI_OBJ)

six: six.c term.c sys_select.c libtecsl.a
	$(CC) -o six six.c term.c sys_select.c libtecsl.a

rstart: rstart.c myc_str.o myc_err.o instr_hosts.o
	$(CC) -o rstart rstart.c myc_str.o myc_err.o instr_hosts.o

bin/keep_running: keep_running.c
	$(CC) -o bin/keep_running keep_running.c        

clean:
	- rm *.o
	- rm *.a
	- rm bin/TecsServer
	- rm bin/TecsClient
