#*************************************************************************
# 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.
# EPICS BASE Versions 3.13.7
# and higher are distributed subject to a Software License Agreement found
# in file LICENSE that is included with this distribution. 
#*************************************************************************
# $Revision-Id$
#
# This file contains definitions for Vx builds

#--------------------------------------------------
# operating system class (include/os/<os_class>)
OS_CLASS = vxWorks

#--------------------------------------------------
# vxWorks directory definitions

# The definitions VX_DIR, VX_GNU, GNU_DIR and GNU_LIB
# can be overridden for specific host architectures
# by creating a CONFIG_SITE.Vx.<host_arch> file with
# the override definitions.

# Tornado directory definitions
VX_INCLUDE_YES = $(VX_DIR)/target/h
VX_GNU_YES = $(VX_DIR)/host/$(WIND_HOST_TYPE)
VX_GNU_BIN_YES = $(VX_GNU)/bin
VX_GNU_LIB_YES = $(VX_GNU)/lib

# pre Torando directory definitions
VX_INCLUDE_NO = $(VX_DIR)/h
VX_GNU_BIN_NO = $(VX_GNU)/$(HOST_ARCH).$(ARCH_CLASS)/bin
VX_GNU_LIB_NO = $(VX_GNU)/$(HOST_ARCH).$(ARCH_CLASS)/lib

# directory definitions
VX_DIR = $(VX_DIR_$(TORNADO))
VX_INCLUDE = $(VX_INCLUDE_$(TORNADO))
VX_GNU = $(VX_GNU_$(TORNADO))
GNU_BIN = $(VX_GNU_BIN_$(TORNADO))
GNU_LIB = $(VX_GNU_LIB_$(TORNADO))
export GCC_EXEC_PREFIX = $(GNU_LIB)/gcc-lib/

#--------------------------------------------------
# VxWorks command definitions

GCC = $(GNU_BIN)/cc$(CMPLR_SUFFIX) -B$(GNU_LIB)/gcc-lib/ -nostdinc
AR = $(GNU_BIN)/ar$(CMPLR_SUFFIX)
CPP = $(GNU_BIN)/cc$(CMPLR_SUFFIX) -B$(GNU_LIB)/gcc-lib/ -nostdinc -x c -E
RANLIB = $(GNU_BIN)/ranlib$(CMPLR_SUFFIX)
LD = $(GNU_BIN)/ld$(CMPLR_SUFFIX) -r

#--------------------------------------------------
# Tornado C++ crosscompiler definitions

CPLUSPLUS_YES = G++
G++ = $(GNU_BIN)/cc$(CMPLR_SUFFIX) -B$(GNU_LIB)/gcc-lib/ -nostdinc
LD_G++ = $(GNU_BIN)/ld$(CMPLR_SUFFIX) -r
NM = $(GNU_BIN)/nm$(CMPLR_SUFFIX)$(HOSTEXE)

#--------------------------------------------------
# Pre Tornado C++ crosscompiler definitions
# These are pre tornado definitions for Hideos builds (defined for 68k only)

CPLUSPLUS_NO = CCC
CCC = $(GNU_DIR)/bin/sun3-g++ -B$(GNU_DIR)/lib/gcc-lib/ -nostdinc -DEXPL_TEMPL
LD_CCC = $(GNU_DIR)/bin/sun3-ld $(OLD_ARCH_DEP_LDFLAGS) -r

CCC_NORMAL = $(CCC) $(OLD_ARCH_DEP_CFLAGS)
CCC_STRICT = $(CCC) -ansi -pedantic -Wtraditional $(OLD_ARCH_DEP_CFLAGS)
CCC_TRAD = $(CCC) -traditional $(OLD_ARCH_DEP_CFLAGS)
CCC_TEMPL_INST_FLAG =
CCC_WARN_YES = -Wall
CCC_WARN_NO = -w
CCC_OPT_YES = -O2 -fstrength-reduce
CCC_OPT_NO =
CCC_DEPENDS_FLAG = -MM
CPU = 68000
OS = VXWORKS
OLD_ARCH_DEP_CFLAGS = --no-builtin -Wa,"-m68040" -DOS_EQ_$(OS) \
	-DBOARD_EQ_$(BOARD) -DCPU_EQ_$(CPU) -DBOARD=$(BOARD)
OLD_ARCH_DEP_LDFLAGS = -Ur -N -T$(EPICS_BASE_BIN)/vxldscript.MRI

#--------------------------------------------------
# C compiler definitions  
ANSI = GCC

#--------------------------------------------------
# Command definitions
CPLUSPLUS = $(CPLUSPLUS_$(TORNADO))
LD_CXX = $(LD_$(CPLUSPLUS))

#--------------------------------------------------
# Override flags in CONFIG_COMMON
GCC_DEP_CFLAGS = -D_REENTRANT
G++_DEP_CFLAGS = -D_REENTRANT
POSIX_CPPFLAGS_YES = -D_POSIX_SOURCE

#--------------------------------------------------
# Operating system flags
OP_SYS_INCLUDES = -I$(VX_INCLUDE)
OP_SYS_CFLAGS = -DvxWorks -DV5_vxWorks -fno-builtin 
OP_SYS_LDFLAGS =
OP_SYS_LDLIBS =

# Fix for vxWorks headers using macros defined in
# vxWorks.h but not including vxWorks.h
ifeq ($(TORNADO), YES)
	OP_SYS_CFLAGS += -include $(VX_INCLUDE)/vxWorks.h
endif

#--------------------------------------------------
# Optimization flag overrides
GCC_OPT_YES = -O2 -fstrength-reduce
GCC_OPT_NO = -g
G++_OPT_YES = -O2 -fstrength-reduce
G++_OPT_NO = -g

OPT_CFLAGS = $($(ANSI)_OPT_$(VX_OPT))
OPT_CXXFLAGS = $($(CPLUSPLUS)_OPT_$(VX_OPT))

#--------------------------------------------------
# Warning flag overrides
GCC_WARN_YES = -Wall
GCC_WARN_NO = -w
G++_WARN_YES = -Wall
G++_WARN_NO = -w

WARN_CFLAGS = $($(ANSI)_WARN_$(VX_WARN))
WARN_CXXFLAGS = $($(CPLUSPLUS)_WARN_$(VX_WARN))

#--------------------------------------------------
# Link definitions
LINK.c = $(LD) $(LDFLAGS) -o
LINK.cc = $(LD_CXX) $(LDFLAGS) -o


#--------------------------------------------------
# Munch definitions
MUNCH_SUFFIX=.munch
MUNCHNAME = $(LIBNAME:%=%$(MUNCH_SUFFIX))

#--------------------------------------------------
# The follow 2 exports prevent gnu cross-compiler
# from finding wrong assembler (as).
export WIND_BASE = $(VX_DIR)
export WIND_HOST_TYPE

