#
# By:Alex Theo de Jong
# Description:
# Makefile for MPEG 2 Audio player for SUN Solaris
#

# Operating System
OS        = -DSOLARIS # -DSOLARIS_PTHREAD
# Use Solaris Multi-Threading
THREADLIB = -lthread # -L/opt/pthread/lib/libpthread.a 
THREADINC = # -I/opt/pthread/include  # none

# Directories
PIDRDIR      = .
INSTLIB      = ../../../Lib
INSTINC      = ../../../Inc
INSTBIN      = ../../../Bin/Solaris2.5

# Tools
CP           = cp
RM           = rm -f
CHMOD        = chmod 666
AR           = ar
CPP          = CC # Sparc C++ Compiler # g++ -V2.7.2 # -V2.6.3
STRP         = strip

# Compiler options
DEBUG        = -g # -DDEBUG # -DTRACE # -ggdb  # -DTRACE
WARNINGS     = -w # -Wall  
OPTIMIZE     = -O # -O2 # -O6 #
CPPFLAGS     = $(DEBUG) $(WARNINGS) $(OS) $(OPTIMIZE) \
               -I$(PIDRDIR) -I$(INSTINC) $(THREADINC) 

# Linker flags
LDFLAGS      = -L$(INSTLIB)
LDLIBS       = -lmpeg -lutil $(THREADLIB)

# Things to compile
PROGRAM      = mpeg2audio
OBJECTS      = mpeg2audio.o astream.o header.o scalefactors.o subband_layer_1.o \
               subband_layer_2.o synthesis_filter.o obuffer.o crc.o
LIBRARY      = libmpeg.a

# compile lines
all: $(PROGRAM)

install: $(PROGRAM) bin

clean:
	$(RM) *.o *~ *.~?~ core $(PROGRAM)

installclean: clean

%.a: $(OBJECTS)
	$(AR) vrus $(INSTLIB)/$*.a $(OBJECTS)
	$(CP) *.hh $(INSTINC)
	$(CHMOD) $(INSTINC)/*.hh

mpeg2audio: $(LIBRARY) main.o
	$(RM) $(PROGRAM)
	$(CPP) -o $(PROGRAM) main.o $(LDFLAGS) $(LDLIBS)

bin: $(PROGRAM)
	$(CP) $(PROGRAM) $(INSTBIN)
	$(STRP) $(INSTBIN)/$(PROGRAM)

.cc.o:
	$(RM) $@
	$(CPP) $(CPPFLAGS) -c $<

# Dependencies
crc.o: crc.hh
header.o: astream.hh  header.hh crc.hh
obuffer.o: obuffer.hh  header.hh crc.hh 
scalefactors.o: scalefactors.hh 
subband_layer_1.o: subband_layer_1.hh astream.hh 
subband_layer_1.o: subband.hh header.hh crc.hh synthesis_filter.hh obuffer.hh
subband_layer_1.o: scalefactors.hh
subband_layer_2.o: subband_layer_2.hh astream.hh  subband.hh header.hh crc.hh
subband_layer_2.o: synthesis_filter.hh  obuffer.hh scalefactors.hh
synthesis_filter.o: synthesis_filter.hh obuffer.hh header.hh crc.hh
astream.o: astream.hh
mpeg2audio.o: mpeg2audio.hh