#
# RcsID = " $Header$ ";
#
#*********************************************************************
#
# File:          Makefile 
#
# Project:       <PROJECT>
#
# Description:   GNU Makefile for Template device server
#
# Author(s):     <AUTHOR>
#
# Original:   	<DATE>
#
# $Log$
#
# Copyright (c) 1996 by European Synchrotron Radiation Facility,
#                       Grenoble, France
#
#**********************************************************************
#       GNU Makefile Generated by the Automatic Class Generation Tool, <REVISION>
#                                       <GENERATIONDATE>.
#

#---------------------------------------------------------------------
#	This Makefile works with the GNU make (sometimes called gmake)
#	It makes use of the GNU make conditional statements to support
#	multiple platforms. To use this makefile for a particular platform
#	call GNU make with the appropriate symbol for that platform
#	defined e.g. "gmake __hp9000s700=1 unix=1 all". The following symbols
#	are used to identify the following platforms :
#
#	__hp9000s700	=	HPUX 9000 series 700 
#	_solaris	=	Solaris 
#	sun		=	SunOS
#	_UCC		=	OS9 Fastrak Ultra-C Compiler
#	unix		=	various unix flavours (Solaris, HPUX, Linux)
#	linux		=	Linux
#	lynx		=	LynxOS
#	
#--------------------------------------------------------------------
#
#       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 
#
#--------------------------------------------------------------------
#
# NOTE : this versions uses ARCHIVE libraries; to use SHARED libraries
#        change $LIB_HOME to point to $(DSHOME)/lib/$(OS)/shared
#
ifdef __hp9000s700
LIB_HOME     =  $(DSHOME)/lib/hpux10.2
INSTALL_HOME =  ../modules/hp10
PYTHON_HOME  =  /opt
endif
ifdef _solaris
LIB_HOME     =  $(DSHOME)/lib/solaris
INSTALL_HOME =  ../modules/solaris
PYTHON_HOME  =  /opt
endif
ifdef linux
LIB_HOME     =  $(DSHOME)/lib/linux/x86
INSTALL_HOME =  ../modules/linux
PYTHON_HOME  =  /usr
endif


#---------------------------------------------------------------------
# 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/private \
		-I $(PYTHON_HOME)/include/python

#---------------------------------------------------------------------
# All necessary compiler flags
#
ifdef unix
#               The C Compiler for UNIX
ifdef _solaris
CC      =       gcc
endif
ifdef __hpux
CC      =       /bin/cc
endif
ifdef linux
CC      =       gcc
endif

#                       Libraries
LIBDIRS =       -L $(LIB_HOME) \
		-L ../../client/src/$(INSTALL_HOME) \
		-ldsapinomain -ldbapi -ldsxdr -ltaco -lm
#		-lreadline -lm

NAME =       	-o 
endif

#            	Compiler flags with ANSI standart for UNIX
ifdef __hpux
CFLAGS = 	-c +z -Ae -D_HPUX_SOURCE $(INCLDIRS)
LFLAGS = 	+s -b $(LIBDIRS) -lcma -lreadline
endif
ifdef _solaris
CFLAGS  =       -g -c -ansi -fPIC $(INCLDIRS)
LFLAGS = 	-G $(LIBDIRS) -lpthread -lposix4
endif
ifdef linux
CFLAGS  =       -g -c -fPIC -Dlinux -Dunix $(INCLDIRS)
LFLAGS =        -G $(LIBDIRS) -lpthread
endif


#---------------------------------------------------------------------
# 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)"

#
#---------------------------------------------------------------------
# All Files needed for the Server and the client
#
#               include files
INCL     =	python.h \
		pythonP.h

#               source files
SRC	 =	Server.c \
		python.c

#		Python Modules
PY_SRC 	 =	TacoServer.py \
		DEVCMDS.py \
		DEVERRORS.py \
		DEVSTATES.py \
		DEV_XDR.py

#               object files
OBJS   	 =	Server.o \
		python.o

#		Module library
ifdef __hpux
SH_LIB   = 	libServer.sl
MOD_LIB	 = 	Server.sl
else
SH_LIB   = 	libServer.so
MOD_LIB	 = 	Server.so
endif


#---------------------------------------------------------------------
# build module library
#

all:		$(OBJS) $(SH_LIB)

$(OBJS):	$(SRC)
		$(CC) $(CFLAGS) $(SRC)

$(SH_LIB):  	$(OBJS)
		ld $(NAME) $@ $(OBJS) $(LFLAGS)

#
# 		install modules		
#
install:	$(SH_LIB) $(PY_SRC)
		cp $(SH_LIB) $(INSTALL_HOME)/$(SH_LIB)
		chmod 775 $(INSTALL_HOME)/$(SH_LIB)
		rm -f $(INSTALL_HOME)/$(MOD_LIB)
		ln -s $(SH_LIB) $(INSTALL_HOME)/$(MOD_LIB)
		cp $(PY_SRC)  $(INSTALL_HOME)
		chmod 664 $(INSTALL_HOME)/$(PY_SRC)

clean:	
		-rm -f *.o 
		-rm -f *.pyc 


clobber:	clean
		-rm -f $(SH_LIB) 


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

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

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