#*************************************************************************
# Copyright (c) 2002 The University of Chicago, as Operator of Argonne
# National Laboratory.
# Copyright (c) 2002 The Regents of the University of California, as
# Operator of Los Alamos National Laboratory.
# This file is distributed subject to a Software License Agreement found
# in the file LICENSE that is included with this distribution. 
#*************************************************************************
#
# $Id: Makefile,v 1.3 2004-04-08 16:56:01 soliday Exp $
#

TOP=../../../..
include $(TOP)/configure/CONFIG

LIBRARY = tclCa
SHARED_LIBRARIES = YES

LIBSRCS = tclCa.c tclCaHash.c tclCaCmd.c

ifdef WIN32
USR_LIBS = ca Com tclstub86
else
USR_LIBS = ca Com

ifeq ($(EPICS_HOST_ARCH),linux-x86_64)
OAGTCL = $(notdir $(wildcard /usr/local/oag/ActiveTcl/linux-x86_64.ActiveTcl8.6.13/include/tcl.h))
ifeq ($(OAGTCL) , tcl.h) 
TCL_INC = /usr/local/oag/ActiveTcl/linux-x86_64.ActiveTcl8.6.13/include
TCL_LIB = /usr/local/oag/ActiveTcl/linux-x86_64.ActiveTcl8.6.13/lib
TK_INC = $(TCL_INC)
TK_LIB = $(TCL_LIB)
endif

OAGTCL = $(notdir $(wildcard /lustre/3rdPartySoftware/ActiveTcl/linux-x86_64.ActiveTcl8.6.13.custom/include/tcl.h))
ifeq ($(OAGTCL) , tcl.h) 
TCL_INC = /lustre/3rdPartySoftware/ActiveTcl/linux-x86_64.ActiveTcl8.6.13.custom/include
TCL_LIB = /lustre/3rdPartySoftware/ActiveTcl/linux-x86_64.ActiveTcl8.6.13.custom/lib
endif
endif

ifeq ($(EPICS_HOST_ARCH),darwin-x86)
OAGTCL = $(notdir $(wildcard /Library/Frameworks/Tcl.framework/Headers/tcl.h))
ifeq ($(OAGTCL) , tcl.h) 
TCL_INC = /Library/Frameworks/Tcl.framework/Headers
TCL_LIB = /Library/Frameworks/Tcl.framework
TK_INC = /Library/Frameworks/Tk.framework/Headers
TK_LIB = /Library/Frameworks/Tk.framework
endif
endif

ifeq ($(EPICS_HOST_ARCH),darwin-aarch64)
OAGTCL = $(notdir $(wildcard /opt/local/include/tcl.h))
ifeq ($(OAGTCL) , tcl.h) 
TCL_INC = /opt/local/include
TCL_LIB = /opt/local/lib
TK_INC = /opt/local/include
TK_LIB = /opt/local/lib
endif
endif

TCLVERSION = $(notdir $(firstword $(wildcard $(TCL_LIB)/libtclstub8.6.a $(TCL_LIB)/libtclstub8.5.a $(TCL_LIB)/libtclstub8.4.a $(TCL_LIB)/libtclstub8.3.a $(TCL_LIB)/libtclstub.a)))
ifeq ($(TCLVERSION),libtclstub8.6.a)
USR_LIBS += tclstub8.6
endif
ifeq ($(TCLVERSION),libtclstub8.5.a)
USR_LIBS += tclstub8.5
endif
ifeq ($(TCLVERSION),libtclstub8.4.a)
USR_LIBS += tclstub8.4
endif
ifeq ($(TCLVERSION),libtclstub8.3.a)
USR_LIBS += tclstub8.3
endif
ifeq ($(TCLVERSION),libtclstub.a)
USR_LIBS += tclstub
endif
endif


USR_CFLAGS += -DUSE_TCL_STUBS
ifneq ($(TCL_INC) , /usr/include) 
USR_CFLAGS += -I$(TCL_INC)
endif
ifneq ($(TK_INC) , /usr/include) 
USR_CFLAGS += -I$(TK_INC)
endif

USR_CFLAGS_solaris = -D__EXTENSIONS__

tclstub8.6_DIR = $(TCL_LIB)
tclstub86_DIR = $(TCL_LIB)
tclstub8.5_DIR = $(TCL_LIB)
tclstub85_DIR = $(TCL_LIB)
tclstub8.4_DIR = $(TCL_LIB)
tclstub84_DIR = $(TCL_LIB)
tclstub8.3_DIR = $(TCL_LIB)
tclstub_DIR = $(TCL_LIB)

include $(TOP)/configure/RULES
