#
# This is the makefile for ooMPEG, the Loring Holden <lsh@cs.brown.edu>
# version of the MNI MPEG wrapper around Berkeley MPEG decoder
#
#
CC=gcc
#
RM=/bin/rm

#################################################################
# Platform independent specifications
#################################################################
#
# Choose dithering or no dithering
#
# Dithering (needed for non 24-bit displays)
USEDITH=$(DITHEROBJS)
# No dithering
#DITHERDEF= -DDISABLE_DITHER
#FULLCOLORDEFINE = -DDEFAULT_FULL_COLOR


# No controls
CONTRDEF= -DNOCONTROLS

#specify library dir
LIB_DIR=.

#uncomment the following if you are using the NV library
#NVLIB=../nv/src/libnv.a
#comment the following if you use the nv library
NONV=-DNONV

# If you do not want to use multi-threading, uncomment the following,
# and comment out MTPARAM and MTOBJ
MTDEF=-DNOTHREADS
# If you want to use multi-threading, uncomment the following and comment
# MTDEF
#for solaris only
#MTPARAM=-mt
#for solaris and sgi
#MTOBJ=THREADmp.o

VARIDEFS=$(CONTRDEF) $(DITHERDEF)
USEOBJS=$(USEDITH) $(USECTRL)

# Generic options, should work on most platforms (hopefully)...

LIBS= -L/usr/lib/X11 -lXext -lX11
LD=$(CC)
DEFS=$(FULLCOLORDEFINE) -DNOFRAMECOUNT $(VARIDEFS)
HOWCOMP=-O2

#################################################################
# Platform specific specifications
#################################################################
#
# Choices for all platforms
#

#Solaris include files
#INCLUDEDIR =  -I/usr/openwin/share/include -I/usr/openwin/include

####
# Block of defines for each platform (Solaris, HP, and SGI)
####
#
# Solaris
#
# if you are using Solaris, uncomment the following and comment the 
# sections for the other platforms
#
#Where the openwindows includes are
#SOLINC = -I/usr/openwin/include
#X libraries
#LIBS= -L/usr/lib/X11 -lXext -lX11 -lgen
#
#LD=$(CC)
#DEFS= -DBSD -DNONANSI_INCLUDES -DSIG_ONE_PARAM $(FULLCOLORDEFINE) -DNOFRAMECOUNT $(VARIDEFS)
#LDFLAGS= -lgen
# compile with debugging or optimized.
#HOWCOMP=-g
#HOWCOMP=-O

#
# HP
#
# if you are using HP, uncomment the following and comment the 
# sections for the other platforms
#
#LIBS= -L/usr/lib/X11R5 -lXext -lX11
#DEFS= $(FULLCOLORDEFINE) -DNOFRAMECOUNT $(VARIDEFS) $(NONV)
#CC=cc -Aa -D_HPUX_SOURCE
#LD=cc -Aa
#HOWCOMP=-g 
#HOWCOMP=-O

#
# Silicon Graphics (SGI)
#
# if you are using SGI, uncomment the following and comment the 
# sections for the other platforms
#LD=$(CC)
#SGIFLAG= -use_cfront
#LIBS= -L/usr/lib/X11 -lXext -lX11
#DEFS =$(FULLCOLORDEFINE) -DNOFRAMECOUNT $(VARIDEFS)
#
#undefine one of the following
#
#HOWCOMP=-g -cckr
#HOWCOMP=-O2 -mips2 -cckr

#################################################################
# Compile specifications (no changes should be needed)
#################################################################
PROGRAMS=#mpeg_play testwrap testwrapobj
LIBRARY=libmpeg.a
ALLOBJS=$(OBJS) $(WRAPPEROBJS) $(DITHEROBJS) $(MTOBJ) \
	$(WRAPOBJ) testwrap.o
WRAPOBJ=testwrapobj.o $(WRAPLIBOBJ)

LIBRARY       = libmpeg.a
CFLAGS        = $(DEFS) $(INCLUDEDIR) $(DEBUG)

all:$(PROGRAMS) $(LIBRARY)
.SUFFIXES= .c

.c.o:
	$(CC) -c $(HOWCOMP) $(CFLAGS) $(IFLAGS) $<

clean:
	$(RM) -f $(ALLOBJS)  *~ $(PROGRAMS) *.cpp  $(LIBRARY) $(LIBRARY++)

OBJS         = util.o video.o parseblock.o motionvector.o decoders.o \
                floatdct.o gdith.o main.o jrevdct.o util32.o\
		16bit.o readfile.o
DITHEROBJS   = fs2.o fs2fast.o fs4.o gray.o hybrid.o hybriderr.o mb_ordered.o \
		mono.o ordered.o ordered2.o 2x2.o
BASELIBOBJS  = util.o video.o parseblock.o motionvector.o decoders.o \
                floatdct.o jrevdct.o util32.o 16bit.o gdith.o readfile.o
LIBOBJS      = $(BASELIBOBJS) $(WRAPPEROBJS)
# from MNI wrapper
WRAPPEROBJS   = wrapper.o gdithMNI.o

SHELL	      = /bin/sh

$(LIBRARY):    $(LIBOBJS) $(USEOBJS)
		ar rv $(LIBRARY) $(LIBOBJS) $(USEOBJS)
		-ranlib $(LIBRARY)

mpeg_play:	$(OBJS) $(USEOBJS)
		$(LD) $(LDFLAGS) $(OBJS) $(USEOBJS) $(LIBS) -lm -o mpeg_play
#		strip $(PROGRAM)

testwrap: testwrap.o $(LIBRARY)
	$(CC) $(HOWCOMP) $(LDFLAGS) testwrap.o -L$(LIB_DIR) -lmpeg $(LIBS) -lm -o testwrap

testwrapobj: $(LIBRARY++) testwrapobj.o
	$(CCPLUS) $(HOWCOMP) $(LDFLAGS) -L$(LIB_DIR) testwrapobj.o -lMPEG  $(NVLIB) $(LIBS) $(MTLIBS) -lm -o testwrapobj
