#
# RcsID = " $Header: /segfs/dserver/classes/vacuum/valves/bl_valves/src/RCS/Makefile,v 3.6 2001/05/10 15:49:36 goetz Exp goetz $ ";
#
#*********************************************************************
#
# File:          Makefile 
#
# Project:       Beamline Vacuum device server for Linux
#
# Description:   Makefile for Rga device server
#
# Author(s):     Andy Gotz
#
# Original:   	 24/2/2002
#
#
# Copyright (c) 2002 by European Synchrotron Radiation Facility,
#                       Grenoble, France
#
#**********************************************************************
#       Makefile Generated by the Automatic Class Generation Tool,  2.4 
#                                       Wed Aug  9 08:39:31 1995.
#

#---------------------------------------------------------------------
#
#       The variables DSHOME is passed to the Makefile
#       as input argument or via the environment.
#
#	For UltraC use the settings for the environment variables:
#	MWOS	 =	/usr/local/MWOS 
#   	PATH     =	$PATH:$MWOS/UNIX/bin/hp97k 
#   	CDEF 	 =	$MWOS/OS9/SRC/DEFS 
#   	CDEFESRF =	/usr/local/os9/dd/DEFS 
#   	CLIB 	 =	$MWOS/OS9/LIB 
#   	CLIBESRF =	/usr/local/os9/dd/LIB 
#
#
# Home Directories
#

ifdef _UCC
LIB_HOME     =  $(DSHOME)/lib/os9/
OBJS_HOME    =  $(DSHOME)/lib/os9/objs
INSTALL_HOME =  $(DSHOME)/bin/os9/
ESRF_LIB     =  /usr/local/os9/dd/LIB
endif # _UCC
ifdef linux
SUSE    = 	$(shell /csadmin/common/scripts/get_os)
LIB_HOME     =  $(DSHOME)/lib/$(SUSE)
INSTALL_HOME =  $(DSHOME)/bin/$(SUSE)
endif # linux


#---------------------------------------------------------------------
# All include file and standard library pathes
#
#		make sure to get always the new include files 
#		under ../include
#

INCLDIRS =  	-I ../include \
		-I $(DSHOME)/include \
		-I $(DSHOME)/include++ \
		-I $(DSHOME)/include/private
		
#---------------------------------------------------------------------
# All necessary compiler flags for UNIX and OS9
#
ifdef _UCC
#               The C Compiler for OS9
CC =       	/usr/local/MWOS/UNIX/bin/hp97k/xcc

#                	Libraries

LIBDIRS =       -L $(LIB_HOME) -L $(CLIB) -L $(ESRF_LIB)

LFLAGS =   	$(LIBDIRS) \
			-l dsapi\
			-l dsclass \
			-l dbapi \
			-l dsxdr \						
			-l os9esrfa.l \
			-l rpclib.l \
			-l netdb_small.l \
			-l socklib.l \
			-l unix.l \
			-l sys_clib.l

ICODE_LFLAGS = 	$(LIBDIRS) \
                -Wi,-l=$(LIB_HOME)/libdsapi.il \
                -Wi,-l=$(LIB_HOME)/libdsxdr.il \
                -Wi,-l=$(LIB_HOME)/libdbapi.il \
                -l dsapi \
                -l csutil \
                -l rpclib.l \
                -l netdb.l \
                -l socklib.l \
				-l cls.l \
                -l sys_clib.l

#               	Compiler Flags
CFLAGS =        -mode=c89 -to osk -DRINT -DBUG -tp 020ld $(INCLDIRS) -Wl,-M=5k
NAME =       	-o $@
endif # _UCC

ifdef linux
CC =       	g++

#                       Libraries
LIBDIRS =       -L $(LIB_HOME)
LFLAGS = 	$(LIBDIRS) -ldsapig++ -ldbapi -ldsxdr_all

NAME =       	-o 
endif # linux

#            		Optimizer and ANSI standart for UNIX
ifdef linux
#CFLAGS = 	-Dlinux -Dunix $(INCLDIRS) -D__cplusplus -g -DDEBUG_PRINT
CFLAGS = 	-Dlinux -Dunix $(INCLDIRS) -D__cplusplus -g 
#LFLAGS = 	-static $(LIBDIRS) -ldmallocxx -ldsclass -ldsapig++ -ldbapi -ldsxdr_all 
LFLAGS = 	$(LIBDIRS) -ldsclass -ldsapig++ -ldbapi -ldsxdr 
endif # linux


#---------------------------------------------------------------------
# RCS options to lock and check out a version.
# Or to check in a new version.
#
#               RCS lock options
RCSLOCK =      	co -l -r$(VERSION)
#               RCS check out options
RCSCO   =      	co -r$(VERSION)
#               RCS check in options
RCSCI   =      	ci -u -f -s"Rel" -r$(VERSION) -m"$(LOCKMSG)"

#---------------------------------------------------------------------
# Class library
# The object file representing the class has
# to be added to the class library.
#
CLASS_LIB = libdsclass.a
CLASS_OBJS = Rga.o

#
#---------------------------------------------------------------------
# All Files needed for the Server and the client
#
#               all include files
INCL     =	RgaP.h \
		Rga.h

#               source files
SRC	 =	Rga.c \
		Rga_menu.c \
		startup.c

#               object files
SVC_OBJS =	Rga.o \
		startup.o 

SVC_ICODE =	Rga.i \
		startup.i 

CLN_OBJS =	Rga_menu.o

#---------------------------------------------------------------------
# What has to be made
#
#		Names of executables in the home directory
SERVER	 = 	Rga
CLIENT	 = 	Rga_menu

#		Names of executables 
#		and include files in the installation directories
SVC_INST   = 	$(SERVER)
CLN_INST   = 	$(CLIENT)
INCL_INST  =	Rga.h
INCLP_INST = 	RgaP.h


#---------------------------------------------------------------------
# build server and client
#

ifdef _UCC
#               Rule for making OS-9 relocatable files
.SUFFIXES: .i .c
.c.i:
	
	
all:		$(SERVER)

$(SERVER):  	$(SVC_OBJS)
		$(CC) $(CFLAGS) $(NAME) $(SVC_OBJS) $(LFLAGS)

$(CLIENT):  	$(CLN_OBJS)
		$(CC) $(CFLAGS) $(NAME) $(CLN_OBJS) $(LFLAGS)

icode:		$(SVC_ICODE)
		echo Linking BLValves with icode libraries!
		$(CC) $(CFLAGS) -o $(SERVER) $(SVC_ICODE) $(ICODE_LFLAGS)

$(SVC_ICODE):
		$(CC) $(CFLAGS) -P $? -o $@
endif


ifdef linux
all:		$(SERVER) $(CLIENT) 

$(SERVER):  	$(SVC_OBJS) 
		$(CC) $(CFLAGS) $(NAME) $@ $(SVC_OBJS) \
		MDSSignal.o DSSignal.o $(LFLAGS)

$(CLIENT):  	$(CLN_OBJS) 
		$(CC) $(CFLAGS) $(NAME) $@ $(CLN_OBJS) $(LFLAGS)
endif # linux


# 		Add object file representing the class
#		to the class library.
#
$(CLASS_LIB):	$(CLASS_OBJS) 
ifdef _UCC
#		For os9 all object files are kept are
#		kept in a special directory, because
#		the library has to be built by a cat
#		of all object files.
#
		cp $(CLASS_OBJS) $(OBJS_HOME)
		libgen -c $(OBJS_HOME)/?*.o -o=$(OBJS_HOME)/$(CLASS_LIB)
		cp $(OBJS_HOME)/$(CLASS_LIB) $(LIB_HOME)
		rm -rf $(OBJS_HOME)/$(CLASS_LIB)
endif # _UCC
ifdef linux
		ar rv $(LIB_HOME)/$(CLASS_LIB) $(CLASS_OBJS)
endif # linux


#
# 		install executables		
#
ifdef _UCC
#install:	$(SERVER) $(CLIENT) $(CLASS_LIB)
install:	$(SERVER) 
		cp $(SERVER) $(INSTALL_HOME)/$(SVC_INST)
		cp $(CLIENT) $(INSTALL_HOME)/$(CLN_INST)
endif # _UCC
ifdef linux
install:	$(SERVER)
		cp $(SERVER) $(INSTALL_HOME)
endif # linux
#
#		install include files
#
		rm -f $(DSHOME)/include/$(INCL_INST)
		cp ../include/$(INCL_INST) $(DSHOME)/include
		chmod 664 $(DSHOME)/include/$(INCL_INST)
		rm -f $(DSHOME)/include/private/$(INCLP_INST)
		cp ../include/$(INCLP_INST) $(DSHOME)/include/private
		chmod 664 $(DSHOME)/include/private/$(INCLP_INST)


clean:	
		-rm -f $(SVC_OBJS) 
		-rm -f $(CLN_OBJS) 
		-rm -f $(SVC_ICODE)
		-rm -f *.ic


clobber:	clean
		-rm -f $(SERVER) 
		-rm -f $(CLIENT) 


lock:
		$(RCSLOCK) $(SRC)
		cd ../include; $(RCSLOCK) $(INCL); cd ../src

co:
		$(RCSCO) $(SRC)
		cd ../include; $(RCSCO) $(INCL); cd ../src

ci:
		$(RCSCI) $(SRC)
		cd ../include; $(RCSCI) $(INCL); cd ../src
#
#
