#*********************************************************************
#
# File:          Makefile
#
# Project:       Device Servers in C++
#
# Description:   Makefile for the AGPowerSupply class implemented in C++
#
# Author(s):     Emmanuel Taurel, Andy Gotz
#
# Original:	 May 1997
#
#
# $Revision: 1.3 $
# $Date: 97/05/20 14:42:11 $
#
# $Author: goetz $
#
# $Log:	Makefile,v $
# Revision 1.3  97/05/20  14:42:11  14:42:11  goetz (Andy Goetz)
# added multi-platform support (HPUX, Solaris, OS9 and Linux)
# 
# 
# Copyright (c) 1997 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 unix
CXX	=	g++
endif # unix

ifdef _UCC
CXX	=	xcc
endif # _UCC

#               ... and his Flags
#
#                Includes
#

INCLDIRS=       -I../include \
		-I../../include \
		-I$(DS_HOME)/include \
		-I$(DS_HOME)/include++ \
		-I$(DS_HOME)/include/private

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

NAME    =       -o

#                       Optimizer or ANSI standart?
ifdef __hpux
CFLAGS	=	-g -Dunix -D__STDC__ -D_HPUX_SOURCE -c
endif # __hpux
ifdef _solaris
CFLAGS	=	-g -Dunix -D__STDC__ -c
endif # solaris
ifdef linux
CFLAGS	=	-g -Dunix -D__STDC__ -c
endif # linux
ifdef _UCC
CFLAGS  =       -mode=c89 -qp -to osk -tp 020 -x il -e as=. -a=warn \
		$(INCLDIRS)
endif # _UCC

CXXFLAGS =	$(CFLAGS) $(INCLDIRS)

ifdef linux
LIBS	=	-ldsapig++ -ldbapi -ldsxdr -lm
endif
ifdef _solaris
ifdef NATIVE
LIBS	=	-ldsapi++ -ldbapi -ldsxdr -lm -lnsl -lsocket -ldl -lrt
else
LIBS	=	-ldsapig++ -ldbapi -ldsxdr -lm -lnsl -lsocket -ldl -lrt
endif # NATIVE
endif # solaris
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
endif # __hpux
ifdef _solaris
LFLAGS	=	-L$(DSHOME)/lib/solaris
endif # _solaris
ifdef linux
LFLAGS	=	-L$(DSHOME)/lib/linux/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
INSTALL_HOME =	$(DSHOME)/lib/linux
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 =	AGPowerSupply.H

#               source files
CLASS_SRC =	AGPowerSupply.cpp \
		startup.cpp

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

SERVER = AGPSpp

CLIENT = ps_menu

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

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

all:	$(SERVER) $(CLIENT)

$(SERVER) : 	startup.o AGPowerSupply.o
	$(CXX) startup.o AGPowerSupply.o ../../src/PowerSupply.o \
	$(LFLAGS) $(LIBS) -o $(SERVER)

$(CLIENT) : 	ps_menu.o
	$(CXX) ps_menu.o $(LFLAGS) $(LIBS) -o $(CLIENT)

startup.o : startup.cpp
	$(CXX) $(CXXFLAGS) startup.cpp

AGPowerSupply.o : AGPowerSupply.cpp
	$(CXX) $(CXXFLAGS) AGPowerSupply.cpp

ps_menu.o : ps_menu.cpp
	$(CXX) $(CXXFLAGS) ps_menu.cpp

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

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

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

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


clobber:	clean


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)
	

