# This is a makefile for UNIX
# If you need to change anything, most likely it'll be:
#
#   CC, which should probably be cc, gcc, acc, or (for AIX) xlc.
#   CFLAGS, which may need -O or -O3 (for instance).
#           RSAREF does benefit from optimization, so it's worth it to get
#           the optimization option right.

# commands
CC = cc
LIB = ar
RANLIB = ranlib

# Normal C flags.
CFLAGS = -O4 -c $(INCL) -DPROTOTYPES=0
MFLAGS = -I. -I$(SRCDIR)

# extension for object files
O = o

# name of temporary library script
TEMPFILE = $(TEMP)\temp.mak

# standard include directory
STDINCDIR=/usr/include

# The places to look for include files (in order).
INCL =  -I. -I$(SRCDIR) -I$(STDINCDIR)

# name of main executable to build
PROG = rdemo

# The location of the common source directory.
SRCDIR = ../source/
SRCLIB = rsaref.a

# The location of the demo source directory.
RDEMODIR = ../rdemo/

target: $(SRCLIB)

rdemo : rdemo.$(O) $(SRCLIB)
	$(CC) $(CFLAGS) -o $@ rdemo.$(O) $(SRCLIB)

$(SRCLIB) : desc.$(O) digit.$(O) md2c.$(O) md5c.$(O) nn.$(O) prime.$(O)\
  rsa.$(O) r_encode.$(O) r_enhanc.$(O) r_keygen.$(O) r_random.$(O)\
  r_stdlib.$(O)
	$(LIB) r $@ $?
	$(RANLIB) $@

rdemo.$(O) : $(RDEMODIR)rdemo.c global.h $(SRCDIR)rsaref.h
	$(CC) $(CFLAGS) -c $(RDEMODIR)rdemo.c

include $(SRCDIR)targets.mak
