##############################################################################
#           Makefile for use by LiveData developers                          #
##############################################################################
#
#
#  To compile with debug, use the env var CPP_DEBUG:
#
# setenv CPP_DEBUG -g
#

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

EXAMPLES = forceUV.plugin meshUV.plugin \
			adjTexCoord.plugin selectPolys.plugin \
			uTagPolys.plugin tagPolys.plugin chkGameTag.plugin \
			showTexGrp.plugin \
			snippet.plugin \
            load_char.plugin dump_char.plugin \
	VRML2GUILib.o \
	VRML2Comment.o \
	VRML2Billboard.plugin \
	VRML2Collision.plugin \
	VRML2Link.plugin \
	VRML2Primitive.plugin


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

#
# 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)
CPLUSPLUSFLAGS = $(CFLAGS)
PLUGINFLAGS = -shared -all

# 
# 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
LFLAGS=-r

# Utility files
# We have chosen to store the scm files in a parallel directory to
#   the library plugins(which in in ./lib).  The plug_util.o file
# contains a function for finding the scheme file directory.
UTIL_OBJECT = plugin_util.o

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

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

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

.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

default: $(EXAMPLES)

#
# Rules for building specific plugins.
#
#adjTexCoord.plugin: adjTexCoord.plugin.o
#	$(CPLUSPLUS) $(PLUGINFLAGS) -o $@ adjTexCoord.plugin.o

VRML2Billboard.plugin: VRML2Billboard.o VRML2GUILib.o VRML2Comment.o $(UTIL_OBJECT)
	$(CPLUSPLUS) $(PLUGINFLAGS) -o $@ VRML2GUILib.o VRML2Comment.o VRML2Billboard.o $(UTIL_OBJECT)

VRML2Collision.plugin: VRML2Collision.o VRML2GUILib.o VRML2Comment.o $(UTIL_OBJECT)
	$(CPLUSPLUS) $(PLUGINFLAGS) -o $@ VRML2GUILib.o VRML2Comment.o VRML2Collision.o $(UTIL_OBJECT)

VRML2Link.plugin: VRML2Link.o VRML2GUILib.o VRML2Comment.o $(UTIL_OBJECT)
	$(CPLUSPLUS) $(PLUGINFLAGS) -o $@ VRML2GUILib.o VRML2Comment.o VRML2Link.o $(UTIL_OBJECT)

VRML2Primitive.plugin: VRML2Primitive.o VRML2GUILib.o VRML2Comment.o $(UTIL_OBJECT)
	$(CPLUSPLUS) $(PLUGINFLAGS) -o $@ VRML2GUILib.o VRML2Comment.o VRML2Primitive.o $(UTIL_OBJECT)
