# $Id: makefile,v 1.1 1998/04/22 21:11:21 um Exp um $

MIXPATH=.

#Set these definitions according to the libraries you want to use:
DEF=-DUSE_ZLIB -DSHORTNAMES -DUSE_BSAFE
INC=-Izlib -Irsaref/source -Ibsafe
LIBS=zlib/libz.a bsafe/libbsafe.a ssleay/crypto.a
LDFLAGS=-lm

#Use the other CFLAGS if you want debugging information
#in the object code.
#CFLAGS = -O2 -static
CFLAGS = -O2 -Wall -static

ALL_CFLAGS=$(INC) $(DEF) $(OPT) $(CFLAGS)

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

LIB=ar
RANLIB=ranlib
#MAKE=make

all: mixmaster

aix: all
hpux: all
linux: all
sunos: all
solaris: all
bsd/os: all

#some debuging code checks for this flag being defined.

# Dec Alpha Computers have strange variable sizes.
alpha:
	$(MAKE) all OPT=-DDECALPHA

freebsd:
	$(MAKE) all OPT="-I /usr/include -I/usr/include/sys"

##########################################################################

OFILES = main.o random.o util.o send.o buffers.o \
        type1.o type2.o chain2.o stats.o keymgt.o \
        compress.o # sockio.o client.o server.o

#
# Following provides automatic dependencies on SunOS
#

.KEEP_STATE:

#
# Actually do the compilation...
#

clean:
	-rm -f *.o mixmaster mixmaster.exe core

allclean: clean
	cd rsaref/install/unix; rm -f *.o *.a rdemo
	cd zlib; make clean
	cd rx; make clean

newpass:
	-rm -f keymgt.o mixmaster

mixmaster:     $(OFILES) $(LIBS)
	$(CC) $(OFILES) $(LIBS) -o mixmaster $(LDFLAGS)
	chmod 4711 mixmaster
#	cp mixmaster ../mixmaster

main.o:         main.c mix.h
		$(CC) -c main.c -o main.o $(ALL_CFLAGS) -DSPOOL='"$(MIXPATH)"'

random.o:       random.c mix.h
		$(CC) -c random.c -o random.o $(ALL_CFLAGS)

util.o:         util.c mix.h
		$(CC) -c util.c -o util.o $(ALL_CFLAGS)

send.o:         send.c mix.h
		$(CC) -c send.c -o send.o $(ALL_CFLAGS)

buffers.o:      buffers.c
		$(CC) -c buffers.c -o buffers.o $(ALL_CFLAGS)

type1.o:        type1.c mix.h
		$(CC) -c type1.c -o type1.o $(ALL_CFLAGS)

type2.o:        type2.c mix.h
		$(CC) -c type2.c -o type2.o $(ALL_CFLAGS)

chain2.o:       chain2.c mix.h
		$(CC) -c chain2.c -o chain2.o $(ALL_CFLAGS)

stats.o:        stats.c mix.h
		$(CC) -c stats.c -o stats.o $(ALL_CFLAGS)

keymgt.o:       keymgt.c mix.h
		$(CC) -c keymgt.c -o keymgt.o $(ALL_CFLAGS) -DPASSPHRASE='"$(PASS)"'

compress.o:     compress.c mix.h zlib/zlib.h
		$(CC) -c compress.c -o compress.o $(ALL_CFLAGS)

sockio.o:       sockio.c mix.h
		$(CC) -c sockio.c -o sockio.o $(ALL_CFLAGS)

client.o:       client.c mix.h
		$(CC) -c client.c -o client.o $(ALL_CFLAGS)

server.o:       server.c mix.h
		$(CC) -c server.c -o server.o $(ALL_CFLAGS)


rsaref/install/unix/rsaref.a:
	cd rsaref/install/unix; $(MAKE) rsaref.a CC=$(CC) LIB=$(LIB) RANLIB=$(RANLIB)

zlib/libz.a:
	cd zlib; $(MAKE) libz.a

rx/librx.a:
	cd rx; $(MAKE) librx.a

bsafe/libbsafe.a:
	cd bsafe; $(MAKE) libbsafe.a
