LOCATION=/usr/local
VERSION=0.1.11
CC=gcc

# PERFORMANCE RELATED FLAG SETS
#CFLAGS=-Wall -O3 -march=i686
#CFLAGS= -Wall -O3 -march=k6
CFLAGS= -Wall -g
# OLE decoding is still considered to be 'beta' mode - so it 
#	disabled in the stable release of ripMIME for now
# You can turn it on, but watch out for various office files
#	which may/probably-will break ripMIME with a segfault
#	or other strange errors.  If you do wish to test this
#	and find a dud mailpack, please send through to
#	mailpacks@pldaniels.com
#
#COMPONENTS= -DRIPOLE
COMPONENTS= 

#  DEBUGGING Related Flags
#CFLAGS= -Wall -g

OBJ=ripmime 
RIPOLE_OBJS= ripOLE/ole.o ripOLE/olestream-unwrap.o ripOLE/bytedecoders.o 
#RIPOLE_OBJS=
OFILES= mime.o ffget.o MIME_headers.o tnef/tnef.o rawget.o pldstr.o logger.o libmime-decoders.o boundary-stack.o uuencode.o filename-filters.o $(RIPOLE_OBJS)

default: tnef/tnef.o ripmime ripOLE/ole.o


ripOLE/ole.o:
	./build_ripOLE

tnef/tnef.o:
	./build_tnef

.c.o:
	${CC} ${CFLAGS} $(COMPONENTS) -c $*.c

all: ${OBJ} 


libripmime: ${OFILES} ripmime-api.o
	ar ruvs libripmime.a ${OFILES}  ripmime-api.o

ripl: ripmime.a
	${CC} ${CFLAGS} ripmime.c ripmime.a -o ripmime

sco: ${OFILES}
	${CC} ${CFLAGS} ripmime.c ${OFILES} -o ripmime -lsocket

ripmime: ${OFILES} ripmime.c
	${CC} ${CFLAGS} $(COMPONENTS) ripmime.c ${OFILES} -o ripmime

riptest: ${OFILES}
	${CC} ${CFLAGS} riptest.c ${OFILES} -o riptest

install: ${OBJ}
	strip ripmime
	cp ripmime ${LOCATION}/bin/

clean:
	rm -f *.o *core ${OBJ}
	rm -f tnef/*.o
	rm -f ripOLE/*.o

MIMEH: MIME_headers.o strlower.o
	${CC} ${CFLAGS} MIMEH_test.c MIME_headers.o strlower.o -o MIMEH_test
