#
# @(#)Makefile  3.0 11/2/95
#	Many thanks to Ulf Moeller for almost
#	completely rewriting this makefile and
#	bringing it in from the dark ages.
#	Compiling Mixmaster should be much easier now.
#
# @(#)Makefile  2.1 10/27/95
#

MIXPATH=$(HOME)/Mix
#MIXPATH=/usr/spool/mixmaster
#MIXPATH=C:\\MIX

RSAREFDIR= ../../rsaref/Mix/

#Use the other CFLAGS if you want debugging information
#in the object code.
#CFLAGS = -g -static $(OPT) -DSPOOL='"$(MIXPATH)"' -DPASSPHRASE='"$(PASS)"'
CFLAGS = -O2 -static $(OPT) -DSPOOL='"$(MIXPATH)"' -DPASSPHRASE='"$(PASS)"'

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

LIB=ar
RANLIB=ranlib

#MAKE=make


all: mixmaster

linux:
	$(MAKE) all PASS=$(PASS)

sunos:
	$(MAKE) all PASS=$(PASS)

#some debuging code checks for this flag being defined.
debug:
	$(MAKE) all OPT=-DDEBUGING PASS=$(PASS)

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

solaris:
	$(MAKE) all LDFLAGS="-L/usr/ucblib -lucb" RANLIB=test PASS=$(PASS)

hpux:
	$(MAKE) all  PASS=$(PASS)

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

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

dos:
	$(MAKE) mixmastr.exe CC=go32gcc LIB=go32-ar RANLIB=go32-ranlib OPT=-DSHORTNAMES PASS=$(PASS)

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

OFILES = main.o random.o util.o send.o buffers.o \
        type1.o type2.o getfrom.o stats.o keymgt.o

#
# Following provides automatic dependencies on SunOS
#

.KEEP_STATE:

#
# Actually do the compilation...
#

clean:
	-rm -f *.o mixmaster core

allclean: clean
	-rm -f rsaref.a
	cd $(RSAREFDIR); make clean

mixmaster:      $(OFILES) rsaref.a
	$(RANLIB) rsaref.a
	$(CC) $(CFLAGS) $(OFILES) rsaref.a -o mixmaster $(LDFLAGS)
	chmod 4711 mixmaster
	cp mixmaster ../mixmaster

mixmastr.exe:   $(OFILES) dos.o rsaref.a
	$(RANLIB) rsaref.a
	$(CC) $(CFLAGS) $(OFILES) dos.o rsaref.a -o mixmaster $(LDFLAGS)
	cat /usr/local/go32/bin/go32.exe mixmaster >../mixmastr.exe

main.o:         main.c mixmaster.h crypt.h buffers.h def.h
		$(CC) -c main.c -o main.o $(CPPFLAGS) $(CFLAGS)

random.o:       random.c mixmaster.h crypt.h buffers.h def.h
		$(CC) -c random.c -o random.o $(CPPFLAGS) $(CFLAGS)

util.o:         util.c mixmaster.h crypt.h buffers.h def.h
		$(CC) -c util.c -o util.o $(CPPFLAGS) $(CFLAGS)

send.o:         send.c mixmaster.h crypt.h buffers.h def.h
		$(CC) -c send.c -o send.o $(CPPFLAGS) $(CFLAGS)

buffers.o:      buffers.c buffers.h def.h
		$(CC) -c buffers.c -o buffers.o $(CPPFLAGS) $(CFLAGS)

type1.o:        type1.c mixmaster.h
		$(CC) -c type1.c -o type1.o $(CPPFLAGS) $(CFLAGS)

type2.o:        type2.c mixmaster.h crypt.h buffers.h def.h
		$(CC) -c type2.c -o type2.o $(CPPFLAGS) $(CFLAGS)

getfrom.o:      getfrom.c mixmaster.h crypt.h buffers.h def.h
		$(CC) -c getfrom.c -o getfrom.o $(CPPFLAGS) $(CFLAGS)

stats.o:        stats.c mixmaster.h crypt.h buffers.h def.h
		$(CC) -c stats.c -o stats.o $(CPPFLAGS) $(CFLAGS)

keymgt.o:       keymgt.c mixmaster.h crypt.h buffers.h def.h
		$(CC) -c keymgt.c -o keymgt.o $(CPPFLAGS) $(CFLAGS)

rsaref.a:
	cd $(RSAREFDIR); make rsaref.a CC=$(CC) LIB=$(LIB) RANLIB=$(RANLIB)
	cp $(RSAREFDIR)/rsaref.a .
	touch rsaref.a

