
LIBNAME = libac3.a

include ../config.mak

SRCS    = bit_allocate.c bitstream.c coeff.c crc.c debug.c decode.c dither.c exponent.c imdct.c parse.c rematrix.c sanity_check.c srfft.c stats.c
OBJS    = bit_allocate.o bitstream.o coeff.o crc.o debug.o decode.o dither.o exponent.o imdct.o parse.o rematrix.o sanity_check.o srfft.o stats.o
# OBJS	= $(SRCS:.c=.o)
CFLAGS  = $(OPTFLAGS) -I. -I.. $(EXTRA_INC) -DHAVE_CONFIG_H

ifeq ($(TARGET_ARCH_X86),yes)
ifeq ($(TARGET_SSE),yes)
SRCS += downmix/downmix_kni.S mmx/imdct512_kni.S mmx/srfft_kni.S
OBJS += downmix/downmix_kni.o mmx/imdct512_kni.o mmx/srfft_kni.o
else
ifeq ($(TARGET_3DNOW),yes)
SRCS += downmix/downmix_3dnow.S
OBJS += downmix/downmix_3dnow.o
else
ifeq ($(BINUTILS),yes)
SRCS +=downmix/downmix_i386.S
OBJS +=downmix/downmix_i386.o
else
SRCS +=downmix/downmix.c
OBJS +=downmix/downmix.o
endif
endif
endif
else
SRCS +=downmix/downmix.c
OBJS +=downmix/downmix.o
endif
.SUFFIXES: .c .o

# .PHONY: all clean

.c.o:
	$(CC) -c $(CFLAGS) -o $@ $<

$(LIBNAME):	$(OBJS)
	$(AR) r $(LIBNAME) $(OBJS)

test2:        $(LIBNAME) test2.c
	$(CC) $(CFLAGS) test2.c -o test2 -L. -lac3 

all:	$(LIBNAME)

clean:
	rm -f *.o *.a *~ downmix/*.o downmix/*~

distclean:
	rm -f Makefile.bak *.o *.a *~ downmix/*.o downmix/*~ .depend

dep:    depend

depend:
	$(CC) -MM $(CFLAGS) $(SRCS) 1>.depend

#
# include dependency files if they exist
#
ifneq ($(wildcard .depend),)
include .depend
endif
