#FREEDOM = $(HOME)/freedom

# Set these definitions according to the libraries you want to use
DEF = -DUSE_RX
INC = -Ipcre
LIBS = pcre/libpcre.a

REMAILER_DEFS = -DREMAILER_DIR='"$(FREEDOM)"' $(DEF) $(INC)

#If you don't have gcc, use the following line instead
CC = gcc
#CC = cc

# Use the other CFLAGS if you want debugging information
CFLAGS = -O2
#CFLAGS = -g -Wall

# Don't use "-s" if you compile with debugging options
LDFLAGS = -s
#LDFLAGS = -static

########################################################################
# Things after this point probably don't need to be changed.
########################################################################

PGP_OBJS = idea.o md5.o randpool.o

REMAILER_OBJS = remailer.o util1.o util2.o util3.o util4.o util5.o \
		stats.o $(PGP_OBJS)

TESTCRYPT_OBJS = testcrypt.o $(PGP_OBJS)

all:		remailer testcrypt

remailer:	$(REMAILER_OBJS) $(LIBS)
		$(CC) $(LDFLAGS) -o $@ $(REMAILER_OBJS) $(LIBS)

testcrypt:	$(TESTCRYPT_OBJS)
		$(CC) $(LDFLAGS) -o $@ $(TESTCRYPT_OBJS)

remailer.o:	remailer.c freedom.h
		$(CC) $(CFLAGS) $(REMAILER_DEFS) -c $< -o $@

util1.o:	util1.c freedom.h
		$(CC) $(CFLAGS) $(REMAILER_DEFS) -c $< -o $@

util2.o:	util2.c freedom.h
		$(CC) $(CFLAGS) $(REMAILER_DEFS) -c $< -o $@

util3.o:	util3.c freedom.h
		$(CC) $(CFLAGS) $(REMAILER_DEFS) -c $< -o $@

util4.o:	util4.c freedom.h
		$(CC) $(CFLAGS) $(REMAILER_DEFS) -c $< -o $@

util5.o:	util5.c freedom.h idea.h usuals.h md5.h
		$(CC) $(CFLAGS) $(REMAILER_DEFS) -c $< -o $@

stats.o:	stats.c freedom.h
		$(CC) $(CFLAGS) $(REMAILER_DEFS) -c $< -o $@

testcrypt.o:	idea.h usuals.h md5.h

idea.o:		idea.h randpool.h usuals.h
md5.o:		md5.h
randpool.o:	randpool.h usuals.h md5.h

pcre/libpcre.a:
		cd pcre; $(MAKE) libpcre.a
.PHONY:		clean
clean:
		rm -f remailer testcrypt $(REMAILER_OBJS) $(TESTCRYPT_OBJS)

.PHONY:		allclean
allclean:
		clean
		cd pcre; $(MAKE) clean
