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

#
#  This directory builds DtExport OpenModel application
#
#  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
GAMES_LOCATION=$(ALIAS_LOCATION)/ODS/Games
SHELL=/bin/sh

API_LIBS  = -lalias_api -lapi_memory -lapi_image
GAME_LIBS = -lDtOMio -lDtIMF -lDtUt

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

#
# If you require the static library (libalias_api.a) rather than
# the dynamic library (libalias_api.so) use the following for
# LFLAGS.
# LFLAGS = -L$(ALIAS_LOCATION)/ODS/OpenModel/lib
#
LFLAGS=-L$(ALIAS_LOCATION)/lib -L$(GAMES_LOCATION)/lib

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

CLIBS = $(LIBS)

#
# 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

CFLAGS = -xansi -signed $(INCLUDES) $(COPIOUS_OUTPUT)
CPLUSPLUSFLAGS = $(CFLAGS)

#
# 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 all the Dt OpenModel dso and the example front end.
#

TARGETS = .DtExport

default: $(TARGETS)

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

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

