# Makefile for the MPEG Library (based on the Berkeley decoder/player for X11).


# Step 1:
#	Set CC to the C compiler you want to use.  To compile the library
#	itself, this must be an ANSI-compliant compiler such as gcc.
#       (However, if you already have the library compiled and just need
#       to use it in another program, an ANSI compiler is not required.)

CC            = mwcc
AR            = mwld
ARFLAGS       = -nodefaults -xml -o 

#
# Step 2:
#	Set CFLAGS.  Below are def's for some machines.  Uncomment the
#	appropriate one or make one of your own.  Note that some compilers
#       (in particular the MIPS cc, in its default "ANSI + extensions" mode)
#       may not define __STDC__ even if they accept prototypes.  Hence, you
#       might want to explicitly define __STDC__ as is done here.
#
#       One #define that needs some explanation is FULL_COLOR_ONLY.  If 
#       this is defined, then movies will be decoded to 24-bit RGB only.
#       (In this case, the you should make sure that $(DITHER_SRC) is
#       not included in $(SRC) below; this is the default.)  Without 
#       FULL_COLOR_ONLY defined, any of a large number of dithering
#       options is available at the cost of increased code size.
#       

# Be flags
CFLAGS = -O2 -DNO_LRAND48 -DRISC -DFULL_COLOR_ONLY
CPPFLAGS = -O2 -DNO_LRAND48 -DRISC -DFULL_COLOR_ONLY

#
# Step 3:
#	Set DEST to pathname of final destination of library...
#
DEST	      = .

#
# Step 4: 
#        Decide which source files you want to build the library from.
#        If you only want movies decoded to 24-bit RGB (well, it's
#        really 32-bit but one byte is unused), then compile with
#        -DFULL_COLOR_ONLY and do NOT include $(DITHER_SRC) in SRC =.
#        If you want the full range of dithering options, then take
#        out -DFULL_COLOR_ONLY and uncomment $(DITHER_SRC).
#

DITHER_SRC    = 2x2.cpp fs2.cpp fs2fast.cpp fs4.cpp hybrid.cpp hybriderr.cpp gray.cpp \
		mono.cpp ordered.cpp ordered2.cpp mb_ordered.cpp

DECODE_SRC		= 24bit.cpp decoders.cpp gdith.cpp globals.cpp \
	jrevdct.cpp motionvector.cpp parseblock.cpp util.cpp vidstrm.cpp \
	efbitmap.cpp wrapper.cpp 

SRC = $(DECODE_SRC)

#
# That's it!  The rest of this shouldn't need any modifications...
#
HDRS	      = util.h vidstrm.h decoders.h dither.h fs2.h fs4.h \
                proto.h globals.h mpeg.h 24bit.h efbitmap.h

INSTALL	      = cp
SHELL	      = /bin/sh
MAKEFILE      = Makefile

OBJS = $(SRC:.cpp=.o)

BASEOBJS	      = \
	24bit.o	\
	decoders.o	\
	efbitmap.o	\
	gdith.o		\
	globals.o	\
	jrevdct.o	\
	motionvector.o	\
	parseblock.o	\
	util.o			\
	vidstrm.o		\
	wrapper.o

DITHEROBJS =	2x2.o	\
	fs2.o	\
	fs2fast.o	\
	fs4.o	\
	hybrid.o	\
	hybriderr.o	\
	gray.o		\
	mono.o		\
	ordered.o	\
	ordered2.o	\
	mb_ordered.o
	

LIBRARY       = libmpeg.a

.SUFFIXES:.cpp $(SUFFIXES)

.cpp.o:
	$(CC) $(CPPFLAGS) -c $<
	
# Targets...

all:		$(LIBRARY) bempeg

$(LIBRARY) : $(OBJS)
		$(AR) $(ARFLAGS) $(LIBRARY) $(OBJS)

clean:;		rm -f $(OBJS) $(LIBRARY) bempeg core
 
install:	$(LIBRARY)
		@echo Installing $(LIBRARY) in $(DEST)
		@if [ $(DEST) != . ]; then \
		(rm -f $(DEST)/$(LIBRARY); $(INSTALL) -f $(DEST)/$(LIBRARY)); fi

# easympeg is a short 'n simple MPEG player that requires the SGI Graphics
# LIbrary; this won't work on non-SGI platforms

bempeg:       bempeg.o mpeg.h $(LIBRARY)
		mwld -o bempeg bempeg.o libmpeg.a

bempeg.o : bempeg.cpp
		$(CC) $(CFLAGS) -c bempeg.cpp 

easympeg:       easympeg.c mpeg.h $(LIBRARY)
		$(CC) -O2 easympeg.c -L. -lmpeg -lgl_s -o easympeg

# Dependencies between source and header files

#24bit.o: vidstrm.h dither.h proto.h 
#2x2.o: vidstrm.h dither.h proto.h 
#decoders.o: decoders.h util.h vidstrm.h proto.h 
#decoders.h: util.h 
#fs2.o: vidstrm.h dither.h fs2.h proto.h 
#fs2fast.o: vidstrm.h proto.h dither.h 
#fs4.o: fs4.h vidstrm.h proto.h dither.h 
#gdith.o: dither.h globals.h 
#globals.o: vidstrm.h globals.h 
#globals.h: mpeg.h 
#gray.o: vidstrm.h proto.h dither.h 
#hybrid.o: vidstrm.h proto.h dither.h 
#hybriderr.o: vidstrm.h proto.h dither.h 
#jrevdct.o: vidstrm.h proto.h 
#mb_ordered.o: vidstrm.h proto.h dither.h 
#mono.o: vidstrm.h proto.h dither.h 
#motionvector.o: vidstrm.h proto.h util.h 
#ordered.o: vidstrm.h proto.h dither.h 
#ordered2.o: vidstrm.h proto.h dither.h 
#parseblock.o: vidstrm.h proto.h decoders.h 
#proto.h: globals.h 
#util.o: vidstrm.h proto.h util.h 
#vidstrm.o : globals.h decoders.h vidstrm.h util.h proto.h 
#vidstrm.h : mpeg.h
#wrapper.o : vidstrm.h proto.h util.h dither.h globals.h 


