#*********************************************************************
#
# File:          Makefile
#
# Project:       Device Servers in C++
#
# Description:   GNU Makefile for the OregonMaxe class implemented in C++
#
# Author(s):     Andy Gotz
#
# Original:	 March 1999
#
#
# $Revision: 1.3 $
# $Date: 1997/05/20 14:42:11 $
#
# $Author: goetz $
#
# $Log$
#
# README :	To use this OregonMaxe GNU Makefile call GNU make (gmake) with the 
#		appropiate flags defined depending on your system e.g. 
#		gmake unix=1 linux=1.
#
#		The following flags are used in this Makefile :
#
#			unix 		- for Unix (i.e. HPUX, Solaris, Linux)
#			__hpux		- for HPUX
#			_hp9000s700 	- for HPUX on HP9000/700
#			_UCC		- for OS9 Ultra-C++
#			_solaris	- for Solaris
#			linux		- for Linux
# 
# Copyright (c) 1998 by European Synchrotron Radiation Facility,
#                       Grenoble, France
#
#                       All Rights Reserved
#
#**********************************************************************

#---------------------------------------------------------------------
# Home Directories
#
#
#       The variables DSHOME is passed to the Makefile
#       as input arguments or via the environment.
#
# external variable DSHOME
DS_HOME   =   	$(DSHOME)
LOHOME    =	`pwd`


ifdef linux
CC	=	gcc
ifdef x86
CXX	=	g++
else
#CXX     = 	/usr/bin/m68k-linux-g++
CXX     = 	g++
endif # x86
endif # linux

ifdef __hpux
CC	=	cc
endif # __hpux

ifdef _UCC
CXX	=	xcc
endif # _UCC

#               ... and his Flags
#
#                Includes
#

ifdef linux
ifdef x86
INCLDIRS=       -I../include \
		-I../oms/include \
		-I/segfs/linux/drivers/oms/v2.2 \
		-I$(DS_HOME)/include \
		-I$(DS_HOME)/include++ \
		-I$(DS_HOME)/include/private
else
INCLDIRS=       -I../include \
		-I../oms/include \
		-I/segfs/linux/drivers/oms/v2.2 \
		-I$(DS_HOME)/include \
		-I$(DS_HOME)/include++ \
		-I$(DS_HOME)/include/private \
		-I/usr/include/m68k-linux
endif # x86
endif # linux

ifdef __hpux
INCLDIRS=       -I../include \
		-I../oms/include \
		-I/segfs/linux/drivers/oms/v2.2 \
		-I$(DS_HOME)/include \
		-I$(DS_HOME)/include++ \
		-I$(DS_HOME)/include/private
endif # __hpux

#                       Libraries
#               No link phase - ergo no libraries to include

NAME    =       -o

#                       ANSI standard
ifdef __hpux
CFLAGS	=	-g -Dunix -D__STDC__ -D_HPUX_SOURCE -Aa -c
endif # __hpux
ifdef _solaris
CFLAGS	=	-g -Dunix -D__STDC__ -c
endif # solaris
ifdef linux
ifdef x86
CFLAGS	=	-g -Dunix -D__STDC__ -DPC68 -DOMS_DS_DEBUG -D_REENTRANT -c
else
CFLAGS	=	-g -Dunix -D__STDC__ -DVME58 -DOMS_DS_DEBUG -D_REENTRANT -c
endif # x86
endif # linux
ifdef _UCC
CFLAGS  =       -mode=c89 -qp -to osk -tp 020 -x il -e as=. -a=warn \
		$(INCLDIRS) -DDEBUG
endif # _UCC

CXXFLAGS =	$(CFLAGS) $(INCLDIRS)

ifdef unix
ifdef linux
LIBS	=	-ldsapig++ -ldbapi -ldsxdr_all -lpthread -lm
else
LIBS	=	-ldsapi -ldbapi -ldsxdr_all -lm
endif # linux
endif # unix
ifdef _UCC
LIBS = 		-l dsclass++ \
		-l dsapi++ \
		-l dbapi \
		-l dsapi++ \
		-l dsxdr \
		-l cplib.l \
                -l dataport \
		-l os9esrfa.l \
		-l rpclib.l \
		-l netdb_small.l \
		-l unix.l \
		-l socklib.l \
		-l sys_clib020.l
endif # _UCC

ifdef __hpux
LFLAGS	=	-L$(DSHOME)/lib/hpux10.2 -Wl,-a,archive 
endif # __hpux
ifdef _solaris
LFLAGS	=	-L$(DSHOME)/lib/solaris
endif # _solaris
ifdef linux
ifdef x86
LFLAGS	=	-L$(DSHOME)/lib/linux/x86 -static
else
LFLAGS	=	-L$(DSHOME)/lib/linux/68k -static
endif # x86
endif # linux
ifdef _UCC
LFLAGS  =	-mode=c89 -b -Wl,-a -Wl,-M=20k \
		-L$(DSHOME)/lib/os9 -L/usr/local/os9/dd/LIB
endif # _UCC

ifdef __hp9000s700
INSTALL_HOME =	$(DSHOME)/lib/s700
endif # __hp9000s700
ifdef _solaris
INSTALL_HOME =	$(DSHOME)/lib/solaris
endif # _solaris
ifdef linux
ifdef x86
INSTALL_HOME =	$(DSHOME)/lib/linux/x86
else
INSTALL_HOME =	$(DSHOME)/lib/linux/68k
endif # x86
endif # linux
ifdef _UCC
INSTALL_HOME =	$(DSHOME)/lib/os9
endif # _UCC

#---------------------------------------------------------------------
# RCS options
#
#               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 library
#
#	File list for RCS control
#               all include files
CLASS_INCL =	OregonMaxe.h

#               source files
CLASS_SRC =	OregonMaxe.cpp 

#--------------------------------------------------------------------
# What has to be made
#
#               Names of the include files in the 
#		installation directories
#
INCL_INST  = 	../include/OregonMaxe.h

SERVER = OregonMaxeds

CLIENT = 

ifdef unix
LIBNAME	=	libdsclassg++.a
endif # unix
ifdef _UCC
LIBNAME =	libdsclass++.a
endif # _UCC

#---------------------------------------------------------------------
# Build server
#

all:	$(SERVER) $(CLIENT)

OregonMaxe.o : OregonMaxe.cpp ../include/OregonMaxe.h \
		../oms/include/Oms.h ../oms/src/Oms.o 
	$(CXX) $(CXXFLAGS) OregonMaxe.cpp

startup.o : startup.cpp ../include/OregonMaxe.h 
	$(CXX) $(CXXFLAGS) startup.cpp

$(SERVER) : startup.o OregonMaxe.o ../oms/src/Oms.o
	$(CXX)  startup.o OregonMaxe.o ../oms/src/Oms.o \
	$(LFLAGS) $(LIBS) /segfs/linux/drivers/oms/v2.2/omslib.o\
	-o OregonMaxeds \

motor_bench.o : motor_bench.c ../include/OregonMaxe.h 
	$(CXX) $(CXXFLAGS) motor_bench.c

motor_bench : motor_bench.o 
	$(CXX) motor_bench.o -o motor_bench $(LFLAGS) $(LIBS)

#---------------------------------------------------------------------
# Build client
#


#---------------------------------------------------------------------
# Build library
#

$(LIBNAME): OregonMaxe.o
	cp $(INSTALL_HOME)/$(LIBNAME) .
ifdef unix
	ar rv $(LIBNAME) OregonMaxe.o
endif # unix
ifdef _UCC
	libgen OregonMaxe.o -co=$(LIBNAME)
endif # _UCC

install : $(LIBNAME)
	cp -f ../include/OregonMaxe.h $(DSHOME)/include++
	chmod 664 $(DSHOME)/include++/OregonMaxe.h
	cp $(LIBNAME) $(INSTALL_HOME)

clean :
		rm -rf *.o
ifdef _UCC
		rm -rf *.dbg *.stb
endif # _UCC


clobber:	clean
		rm -rf	$(LIBNAME)


lock:
		$(RCSLOCK) $(CLASS_SRC)
		cd ../include; $(RCSLOCK) $(CLASS_INCL)
		cd $(LOHOME)

co:
		$(RCSCO) $(CLASS_SRC)
		cd ../include; $(RCSCO) $(CLASS_INCL)
		cd $(LOHOME)

ci:
		$(RCSCI) $(CLASS_SRC)
		cd ../include; $(RCSCI) $(CLASS_INCL)
		cd $(LOHOME)
	

