##############################################################################
#           Makefile for use by API developers                               #
##############################################################################

#
# If the location of the Alias libraries and header files are
# different from $ALIAS_LOCATION, set it here.
#
ALIAS_LOCATION=/usr/aw/alias
GAMES_LOCATION=$(ALIAS_LOCATION)/ODS/Games
SHELL=/bin/sh

DTFILES = DtLayer.o cnetwork.o doShape.o doMaterial.o doLight.o doCamera.o node.o 

#  SITEROOT defines the "Site" directory of the development tree.
#  It is a relative path from this current directory. All other
#  variables in this Makefile should be relative to SITEROOT.
#
INCDIR      = $(GAMES_LOCATION)/include
LIBDIR		= $(GAMES_LOCATION)/lib

CC = cc
CPLUSPLUS = CC
INCLUDES = -I. -I$(ALIAS_LOCATION)/ODS/Common/include -I$(INCDIR) 

#
# Some code is conditionally compiled because it produces a lot of output.
# (see AlPrint.c++ for example) Uncomment the following line if you would
# like to see all the output.
#
# COPIOUS_OUTPUT = -DCOPIOUS_OUTPUT

#
# the -prototypes flag causes a warning message to be displayed on 
# IRIX 5.3 machines, but doesn't affect the plugins in any way.
#
# CFLAGS = ${CPP_DEBUG} -xansi -signed -prototypes $(INCLUDES) $(COPIOUS_OUTPUT)
CFLAGS = ${CPP_DEBUG} -xansi -signed $(INCLUDES) $(COPIOUS_OUTPUT)
CPLUSPLUSFLAGS = $(CFLAGS)

#
# The 'libLiveData.so' tells the linker to check the DSO for the Alias api
# symbols.  If you do not specify this, you will see all of the references
# to the Alias api symbols.  This is not harmful, since these symbols are
# resolved when the plugin is loaded.
#
PLUGINFLAGS = -shared -all $(ALIAS_LOCATION)/lib/libLiveData.so
PLUGINSLFLAGS=-r

#
# Note that with Alias OpenModel is supplied as ELF
# static library and dynamic library (DSO).
#
LIBS = -lalias_api -lapi_memory -lapi_image -lgen -lm -lsun -lXm -lXt -lX11

CLIBS = $(LIBS)

#
# Rules for building.
#
.SUFFIXES: .plugin .o .c++ .c

.c++.plugin:
	$(CPLUSPLUS) -c $(CPLUSPLUSFLAGS) $<
	$(CPLUSPLUS) $(PLUGINFLAGS) -o $*.plugin $*.o

.o.plugin:
	$(CPLUSPLUS) $(PLUGINFLAGS) -o $*.plugin $<

.c++.o:
	$(CPLUSPLUS) -c $(CPLUSPLUSFLAGS) $*.c++

.c.o:
	$(CC) -c $(CFLAGS) $*.c

.o:
	$(CPLUSPLUS) $(LFLAGS) -o $@ $? $(CLIBS)

.c.i:
	 $(CC) -E $(CFLAGS) $*.c | sed -e '/^[    ]*$$/d' > $*.i

.c++.i:
	$(CPLUSPLUS) -E $(CPLUSPLUSFLAGS) $*.c++ | sed -e '/^[  ]*$$/d' > $*.i

#
# Build the Dt OpenModel dso.
#

TARGETS = libDtOMio.so
 
default: $(TARGETS)

#
# Rules for building the C++ executables.
#

#
#	make the dso for the Open Model Dt API interface
#
libDtOMio.so: $(DTFILES)
	@echo "\nLinking $@"
	ld -shared -soname libDtOMio.so -o $@ $(DTFILES)
