# VRML/PROGS/vrmlview/Makefile
############################################################################

# use same configuration parameters as in parent directory
include ../../Config.common
include ../../Config.site

POOLSDIR = ../../POOLS
INCLUDIR = ../../include
LIBDIR = ../../lib
BINDIR = ../../bin

# filter support compile flags and libraries to link with
ifeq ($(PLY),ply)
PLYFLAGS = -DPLY
PLYFILTLIB = -lply2xrml $(PLYLIBS)
endif

MGFFLAGS = -DMGF
MGFFILTLIB = -lxrml2mgf

NFFFLAGS = -DNFF
NFFFILTLIB = -lxrml2nff

CSOFLAGS = -DCSO
CSOFILTLIB = -lxrml2cso

FILTFLAGS = $(PLYFLAGS) $(MGFFLAGS) $(NFFFLAGS) $(CSOFLAGS)
FILTLIBS = $(PLYFILTLIB) $(MGFFILTLIB) $(NFFFILTLIB) $(CSOFILTLIB)

############################################################################
# No need to change anything below here
############################################################################
# the source files in this directory
CXXSOURCES = \
	main.C \
	oglrenderer.C \
	ui_render.C
CSOURCES = \
	ui_main.c \
	ui_file.c \
	ui_camera.c \
	ui_help.c \
	ui_defaults.c \
	uit.c \
	canvas.c \
	render.c \
	rendercommon.c \
	bounds.c \
	camera.c \
	transform.c \
	error.c \
	options.c
SOURCES = $(CXXSOURCES) $(CSOURCES)
OBJECTS = ${CXXSOURCES:.C=.o} ${CSOURCES:.c=.o} 

THISDIRFLAGS = $(FILTFLAGS) -I$(INCLUDIR) -I$(POOLSDIR) \
	$(XINCLUDES) $(MOTIFINCLUDES) $(DRIVERFLAGS) $(TIMERFLAGS) -I.

#default target: make the vv (ViewVRML or VRMLView as you like) executable
all: vv

# generate source file dependencies
depend:
	$(MAKEDEPEND) $(MKDEPFLAGS) $(SOURCES) > deps

# automatically create a C file containing fallback resources from 
# the application defaults in the file 'RenderPark'
ui_defaults.c: ViewVRML
	echo "/* ui_defaults.c: automatically generated from the application defaults file 'ViewVRML' */" > ui_defaults.c
	echo "" >> ui_defaults.c
	echo "char *fallback_resources[] = {" >> ui_defaults.c
	sh ad2c.script < ViewVRML >> ui_defaults.c
	echo "(char *)0" >> ui_defaults.c
	echo "};" >> ui_defaults.c

vv: $(OBJECTS)
	$(CXX) $(LDFLAGS) -o vv $(OBJECTS)  \
		-L$(LIBDIR) $(FILTLIBS) -lxrml \
		-L$(POOLSDIR) -lpools \
		$(DRIVERLIBS) $(MOTIFLIBS) $(XLIBS) $(DLLIB) \
		$(DLLIB) -lm
	-ln -sf `pwd`/vv $(BINDIR)

cleanhere: cleangen
	-${RM} vv

clean: cleanhere

distclean: cleanhere

###############################################################################
# dependencies --- automatically generated with make depend !!
###############################################################################
-include deps
