# Makefile for channel access service of CDEV
# 
# channel access service
# 
# Makefile,v
# Revision 1.22  1998/08/17  14:04:46  akers
# Added 'Minor Version Number' to TARGETDIR in Makefiles
#
# Revision 1.21  1998/02/10  18:25:01  chen
# add solaris-gnu
#
# Revision 1.20  1997/12/22  18:23:05  akers
# Ongoing development of 1.6.2
#
# Revision 1.19  1997/12/17  15:06:55  akers
# *** empty log message ***
#
# Revision 1.17  1997/08/11  13:35:13  akers
# Ongoing development in support of CDEV version 1.6.1
#
# Revision 1.16  1997/03/25  22:24:33  akers
# Development in support of a new cdevDirectory
#
# Revision 1.15  1997/03/04  17:15:08  chen
# fix for Linux shared library
#
# Revision 1.14  1996/11/18  17:07:13  chen
# add support for diffrent arch for caService.so
#
# Revision 1.13  1996/09/30  15:58:47  akers
# Changed Destination Directories
#
# Revision 1.12  1996/06/26  15:54:07  akers
# Modifications to support multiple OS Versions
#
# Revision 1.11  1996/05/15  16:25:49  akers
# Changes made to support epics shared libraries
#
# Revision 1.10  1996/05/15  15:08:02  akers
# Removed old library files and started using shared libraries.
#
# Revision 1.9  1996/05/14  20:38:01  akers
# Makefile modifications
#
# Revision 1.8  1995/11/20  15:20:09  chen
# add target
#
# Revision 1.7  1995/11/14  17:20:11  chen
# new makefile
#
#
#
include ../Makefile.config

ifeq ($(SHOBJ),YES)
	OBJTYPE=.shobj/$(TARGETDIR)
else
	OBJTYPE=.obj/$(TARGETDIR)
endif

EPICSINCLUDES = -I$(EPICS)/base/include

XTRACXXFLAGS = $(EPICSINCLUDES) -D_EPICS_3_12
XTRACFLAGS = -D_NO_PROTO -DACCESS_SECURITY -I. -DUNIX $(EPICSINCLUDES)
#-D_CDEV_DEBUG
#-D_CA_SYNC_CONN
#-D_TRACE_OBJECTS

OBJS =  $(OBJTYPE)/caChannel.o \
	$(OBJTYPE)/caNameSvc.o \
	$(OBJTYPE)/caRequestObject.o \
	$(OBJTYPE)/caService.o \
	$(OBJTYPE)/caMonObj.o \
	$(OBJTYPE)/caMisc.o

ifeq ($(SHOBJ),YES)
	TARGETLIB=$(CDEVSHOBJ)/$(CDEVVERSION)/caService.so
else
	TARGETLIB=$(LIBDIR)/libcaService.a
endif

# Different machine defines different ways to build shared library for ca service
ifeq ($(TARGET), solaris)
	HOWMKCA = YES
endif

ifeq ($(TARGET), hpux)
	HOWMKCA = YES
endif

ifeq ($(TARGET), Linux)
	HOWMKCA = YES
endif

ifeq ($(TARGET), solaris-gnu)
	HOWMKCA = YES
endif

targets: $(OBJTYPE) $(TARGETLIB)

$(OBJTYPE) :
	@mkdir -p $(OBJTYPE)

$(CDEVSHOBJ)/$(CDEVVERSION)/caService.so: $(OBJS) 
	@mkdir -p $(CDEVSHOBJ)/$(CDEVVERSION)
ifdef HOWMKCA
ifeq ($(TARGET), solaris)
	$(MAKELIB) $@ $(OBJS) -L$(EPICS)/base/lib/$(TARGET) -lca -lCom
endif	
ifeq ($(TARGET), hpux)
	$(MAKELIB) $@ $(OBJS) $(HPCXX_SHLIB_PATH) -L$(EPICSLIB) -lca -lCom -lDb
endif
ifeq ($(TARGET), Linux)
	$(MAKELIB) $@ $(OBJS) -L$(EPICSLIB) -lca -lCom
endif
ifeq ($(TARGET), solaris-gnu)
	$(MAKELIB) $@ $(OBJS) -L$(EPICS)/base/lib/solaris -lca -lCom
endif	
else
	@echo "Do not know how to make shared library for channel access service"
	@echo "on your host machine."
	@echo "Please check your programmer's mannual and edit this makefile,"
	@echo "and send new makefile to cdev@cebaf.gov. Thank you."
endif

	
$(LIBDIR)/libcaService.a: $(OBJS)
	rm -f $@
	@mkdir -p $(LIBDIR)
	$(MAKELIB) $@ $(OBJS)
	$(RANLIB) $@
	
clean: clean_hail
	@rm -rf *.o *.a *~ .obj .shobj core ptrepository
