#
# 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 =  ../lib/hpux102
PYTHON_HOME  =  /segfs/bliss/depot/pythonesrf/hpux102
endif
ifdef _solaris
LIB_HOME     =  $(DSHOME)/lib/solaris
INSTALL_HOME =  ../lib/solaris7
PYTHON_HOME  =  /segfs/bliss/depot/pythonesrf/solaris
endif
ifdef linux
LIB_HOME     =  $(DSHOME)/lib/linux/x86
INSTALL_HOME =  ../lib/linux
PYTHON_HOME  =  /segfs/bliss/depot/pythonesrf/linux
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/python2.1 \
		-I $(PYTHON_HOME)/include/python2.1/Numeric

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

#                       Libraries
LIBDIRS =       -L $(LIB_HOME) \
		-ldsapinomain -ldbapi -ldsxdr_all -ldcapi

NAME =       	-o 
endif

#            	Compiler flags with ANSI standart for UNIX
ifdef __hpux
#CFLAGS = 	-g -c +Z -Ae -D_HPUX_SOURCE -DMYDEB -DNUMPY $(INCLDIRS)
CFLAGS  =       -g -c -ansi -D_HPUX_SOURCE -DMYDEB -DNUMPY -fPIC $(INCLDIRS)
LFLAGS =	+s -b $(LIBDIRS)
endif
ifdef _solaris
CFLAGS  =       -g -c -ansi -DMYDEB -DNUMPY -fPIC $(INCLDIRS)
LFLAGS =	-G -B static $(LIBDIRS) -B dynamic -lposix4
endif
ifdef linux
CFLAGS  =       -g -c -DMYDEB -DNUMPY -fPIC -Dlinux -Dunix $(INCLDIRS)
LFLAGS =	-shared -Bstatic $(LIBDIRS)
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     =	taco.h \
		python.h \
		pythonP.h

#               source files
SRC	 =	taco.c \
		taco_types.c \
		server.c \
		python.c

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

#               object files
OBJS   	 =	taco.o \
		taco_types.o \
		server.o \
		python.o

#		Module library
ifdef __hpux
SH_LIB   = 	Taco.sl
MOD_LIB  =      Server.sl
else
SH_LIB   = 	Taco.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)
		ld $(NAME) $@ $(OBJS) $(LFLAGS)

#
# 		install modules		
#
install:	$(SH_LIB)
		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)

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


clobber:	clean
		-rm -f $(SH_LIB) 


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

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

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