# Makefile for glmpeg_play.  By default, just builds the executable
# in the current directory.  Other targets:
#   man - build the man page (must have nroff, groff, or something like it)
#   clean - deletes *.o, core, *~


# The location of the MPEG library (this is NOT just the original
# Berkeley decoder, but rather a library with the Berkeley decoding
# engine and a useful, documented front end developed in conjunction
# with glmpeg_play)

MPEG_LIB_DIR = ../mpeg_lib

# You may wish to change these, but it shouldn't be necessary

CC      = cc
LD      = ld
NROFF   = groff
SHELL   = /bin/sh

CFLAGS  = -g -I$(MPEG_LIB_DIR)#             compiler switches for normal case
OPTFLAGS= -O4 -g0 -I$(MPEG_LIB_DIR)#        switches for optimised executable
LDFLAGS = -L$(MPEG_LIB_DIR) -lmalloc -lmpeg -lgl_s -lm
NROFFFLAGS = -man -T ascii


# Everything after this point shouldn't have to be changed

PROGRAM = glmpeg_play

MANSRC  = $(PROGRAM).man

MANPAGE = $(PROGRAM).1

SRC     = gl_mpeg.c parseargs.c buffers.c display.c interface.c help.c ParseArgv.c

HEADERS = gl_mpeg.h ParseArgv.h

OBJ     = $(SRC:.c=.o)

UCODE   = $(SRC:.c=.u)


# Explicit rules to build the program, man page, etc.

$(PROGRAM)    : $(OBJ)
		$(CC) -o $(PROGRAM) $(OBJ) $(LDFLAGS)

all           : $(PROGRAM) $(MANPAGE)

optimize      : $(UCODE)
		$(CC) $(OPTFLAGS) $(SRC) $(LDFLAGS) -o $(PROGRAM)
		strip $(PROGRAM)

man           : $(MANPAGE)

$(MANPAGE)    : $(MANSRC)
		$(NROFF) $(NROFFFLAGS) $(MANSRC) > $(MANPAGE)

clean         : 
		rm -f *.o *.u *~ core

# Source/header dependencies (identical cases for .o and .u files)

ParseArgv.o: ParseArgv.h
buffers.o: gl_mpeg.h
display.o: ../mpeg_lib/mpeg.h gl_mpeg.h
gl_mpeg.o: ../mpeg_lib/mpeg.h gl_mpeg.h
gl_mpeg.h: ../mpeg_lib/mpeg.h
help.o: gl_mpeg.h
interface.o: gl_mpeg.h
parseargs.o: ParseArgv.h ../mpeg_lib/mpeg.h gl_mpeg.h

ParseArgv.u: ParseArgv.h
buffers.u: gl_mpeg.h
display.u: ../mpeg_lib/mpeg.h gl_mpeg.h
gl_mpeg.u: ../mpeg_lib/mpeg.h gl_mpeg.h
gl_mpeg.h: ../mpeg_lib/mpeg.h
help.u: gl_mpeg.h
interface.u: gl_mpeg.h
parseargs.u: ParseArgv.h ../mpeg_lib/mpeg.h gl_mpeg.h



