#
# $RCSfile: Makefile.solaris,v $
#
# x-kernel v3.3
#
# Copyright (c) 1996,1993,1991,1990  Arizona Board of Regents
#
# $Log: Makefile.solaris,v $
# Revision 1.7  1997/07/29 22:58:45  llp
# fixed ar path name
#
# Revision 1.6  1996/12/09 18:06:15  slm
# Removed comment from -lthread on solaris_LIBS definition.
#
# Revision 1.5  1996/06/13  23:49:50  slm
# Changed name of executable from xkernel to xsim.
#
# Revision 1.4  1996/06/05  16:45:16  slm
# Updated version & copyright.
#
# Revision 1.3  1996/02/01  15:44:18  slm
# Cosmetic changes.
#
# Revision 1.2  1995/10/17  20:31:49  slm
# Create
#
# Revision 1.1  1995/07/28  22:32:14  slm
# Initial revision
#
# Revision 1.1  1994/11/22  21:11:37  hkaram
# Initial revision
#
# -----------------------------------------------------------------
# Build-directory Makefile for the solaris/sparc platform.
#
# There are many variables defined here that may vary from site to site.  If
# you are the first person at your site to build an x-kernel, look over the
# definitions carefully and determine what the appropriate values should be
# for your site.

XPLATFORM = solaris
MACHINE = sparc
XK_TYPE = SIM
XK_TYPE_DIR = simulator
XK_BIN_TYPE := $(XPLATFORM)-$(MACHINE)

XK_VIEW = TRUE
XK_UTILS = ALL

# HOWTOCOMPILE controls optimization flags and tracing routines.
# It should be set to either DEBUG or OPTIMIZE

HOWTOCOMPILE = DEBUG
#HOWTOCOMPILE = OPTIMIZE

HOW := $(XK_TYPE)-$(HOWTOCOMPILE)-$(XK_BIN_TYPE)
HOWUTIL := $(HOWTOCOMPILE)-$(XK_BIN_TYPE)

# If XK_BYPASS_RCS is defined (to anything), RCS consistency checks will be
# disabled.  This can make a build run significantly faster.

XK_BYPASS_RCS = blurp

# Compiler-related flags.  If you decide to change compilers, some of these
# flags may also have to change.
#
# Both gcc and the Sun native cc seem to work ok.
# but watch the "make dependencies" switch in makefile.local: cc uses -xM

CC = gcc

ifeq ($(CC),gcc)

DEBUGWARNINGS = -Wunused
OPTIMIZEWARNINGS = -Wuninitialized
WARNINGS = -Wreturn-type -Wimplicit -Wswitch -Wchar-subscripts    \
           -Wshadow -Wmissing-prototypes -Winline -Wpointer-arith \
           $($(HOWTOCOMPILE)WARNINGS)
CC_SPECIFIC_FLAGS = -fwritable-strings # -D_REENTRANT -DMULTIPROCESSOR	# needed for multithread Solaris
DEBUGCFLAGS = -g
OPTIMIZECFLAGS = -O
LDFLAGS = $(LIBPATH)

else	# native cc

CC_SPECIFIC_FLAGS = # -D_REENTRANT -DMULTIPROCESSOR	# needed for multithread Solaris
DEBUGCFLAGS = -g
OPTIMIZECFLAGS = -O
LDFLAGS = $(LIBPATH)

endif

# Libraries.  Some of these libraries are labeled 'optional', indicating that
# they are only used by some protocols.  Names and locations of libraries may
# be site-specific.

LIBPATH = -L$(XRT)/lib -L$(XRT)/lib/$(XK_BIN_TYPE)
solaris_LIBS = -lposix4 -lsocket -lnsl -lthread	# required
LIB_GNUMP = -lgmp	# GNU multi-precision library, optional
LIB_PTHREADS = -lpthreads
LIB_TCPLIB = -ltcp

SED = sed
MAKE = make
REALCC = /opt/SUNWspro/bin/cc
RANLIB = echo RANLIB is disabled:	# no ranlib in Solaris
AR = /usr/ccs/bin/ar

# XRT names a path to the top of the x-kernel source tree

XRT = ../../..

# TMP_CPPFLAGS and TMP_CFLAGS apply to the build directory only, and won't be
# propagated to compilation in other x-kernel directories.

# TMP_CPPFLAGS =
# TMP_CFLAGS =

# When compiling private versions of x-kernel utilities in your build area,
# you may need to add include paths.  Add these to the TMP_INCLUDES variable.

TMP_INCLUDES = $(COMPOSE_INCLUDES)

MAKEFILE = Makefile
MAKEFLAGS += --no-print-directory

OPTIMIZECPPFLAGS =
DEBUGCPPFLAGS = -DXK_DEBUG -DXSIM_DEBUG
BUILD_CPPFLAGS := $($(HOWTOCOMPILE)CPPFLAGS) -DX_SOLARIS -DXK_TRACE_LOCKING
BUILD_CFLAGS = $($(HOWTOCOMPILE)CFLAGS)

all: xsim

# The COMPOSE_MAKEFILE is generated from graph.comp when 'make compose' is run.

COMPOSE_MAKEFILE = Makefile.local
COMPOSEFLAGS = -f -m $(COMPOSE_MAKEFILE) -s sim_protocols.c
include $(COMPOSE_MAKEFILE)

$(COMPOSE_MAKEFILE):
	@touch $(COMPOSE_MAKEFILE)

# If you compile source code in your build area which isn't associated with a
# particular protocol, add the source names to PRIVSRC and the object names
# (e.g., ./OBJS/$(HOW)/foo.o) to PRIVOBJ.

#PRIVSRC = \
#PRIVOBJ = \

include $(XRT)/$(XK_TYPE_DIR)/build/Template/Makefile.common

# Include Makefile.nolibs to compile without libraries

include $(XRT)/$(XK_TYPE_DIR)/build/Template/Makefile.nolibs

xsim: $(OBJ) $(XLIBS)
	@echo linking xsim ...
	@$(CC) $(LDFLAGS) -o xsim $(OBJ) $(XLIBS) $(COMPOSE_LIBS) \
	    $(LIB_PTHREADS) $(LIB_TCPLIB) $($(XPLATFORM)_LIBS) -lm

include DEPS/Makedep.$(HOW)
