# ******************************************************************************
# * Makefile.aix :     This is the platform specific Makefile for aix.
# *
# * Externals        : This Makefile relies on the developer defining the 
# *                    following external definitions...
# *
# *                   CDEV      : The base directory of the CDEV distribution
# ******************************************************************************
TARGET          = aix
OS_MAJOR       := $(shell uname -v)
OS_MAJOR_NUM   := $(shell awk 'BEGIN {VAL=$(OS_MAJOR); print VAL; exit; }')
OS_MINOR       := $(shell uname -r)
OS_MINOR_NUM   := $(shell awk 'BEGIN {VAL=$(OS_MINOR); print VAL; exit; }')
OS_VERSION_DEF := -D_OS_MAJOR_=$(OS_MAJOR_NUM) -D_OS_MINOR_=$(OS_MINOR_NUM)

include $(CDEV)/extensions/cdevGenericServer/include/makeinclude/Makefile.common

# ******************************************************************************
# * Platform specific compile and link options.
# ******************************************************************************

# ******************************************************************************
# * Only specify the DEBUGFLAG if the DEBUG variable has been set.
# ******************************************************************************
ifdef DEBUG
DEBUGFLAG     = -g
endif

CXX           = xlC
CC            = xlC
CXXFLAGS      = $(CXXEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) \
                $(BASEINCLUDES) $(OS_VERSION_DEF) $(DEBUGFLAG) -DAIX -qNOro
CFLAGS        = $(CCEXTRA) $(CXXINCLUDES) $(CDEVINCLUDES) \
                $(BASEINCLUDES) $(OS_VERSION_DEF) $(DEBUGFLAG) -DAIX -qNOro 
AR            = ar
ARFLAGS       = ruv
RANLIB        = true
OSLIBS        = -L/lib -lm

# ******************************************************************************
# * Platform specific compile and link macros.
# ******************************************************************************
COMPILE.cc    = $(QUIET)$(CXX_CMD_ECHO)rm -rf $@;\
		mkdir -p $(@D);\
		$(CXX) -c $(CXXFLAGS) $^ -o $@
COMPILE.cc.so = $(QUIET)$(CXX_CMD_ECHO)rm -rf $@;\
		mkdir -p $(@D);\
		@echo "Shared objects not supported on AIX"
COMPILE.c     = $(QUIET)$(CC_CMD_ECHO)rm -rf $@;\
		mkdir -p $(@D);\
		$(CC) -c $(CFLAGS) $^ -o $@
COMPILE.c.so  = $(QUIET)$(CC_CMD_ECHO)rm -rf $@;\
		mkdir -p $(@D);\
		@echo "Shared objects not supported on AIX"
LINK.cc       = $(QUIET)$(LINK_CMD_ECHO)rm -rf $@;\
		mkdir -p $(@D);\
		$(CXX) $(CXXFLAGS)
LINK.a        = $(QUIET)$(AR_CMD_ECHO)rm -rf $@;\
		mkdir -p $(@D);\
		$(AR)  $(ARFLAGS)


#Note on the -qNOro option

#  The AIX compiler by default allocates memory for string literals in the
#  read only area. As result, CLIP clients crash with segmentation fault 
#  when cdevClientRequestObj cleans up constant message strings passed by
#  the user (in the code below "message" points directly to the user string)
