#
# Makefile
#

TOPLEVEL=../../..
CRYPTOTOP=..
OBJDIRNAME = obj

# Chip used for compilation
# (can be overriden by adding CHIP=chip to the command-line)
CHIP  = at91sam7xc512

include $(CRYPTOTOP)/common.mk

# Input and output files for this subdirectory
LIBSRC=	cryptlib.c mem.c mem_clr.c mem_dbg.c cversion.c o_str.c ex_data.c
LIB= $(LIBDIR)/libcrypto.a

#
# Where to put the output binaries from this build
#
OUTPUTDIR = $(LIBDIR)

# Search paths (none for this project)
VPATH =

.PHONY: dobuild all clean cleanobjs

all: dobuild $(LIB)

SOURCE_FILES = $(LIBSRC)

DEPENDS = $(patsubst %.c, $(OBJDIR)/%.d, $(SOURCE_FILES))

COBJS = $(patsubst %.c, $(OBJDIR)/%.o, $(SOURCE_FILES))

OBJS = $(COBJS)

# Include the various dependancy files.
ifneq ($(MAKECMDGOALS), clean)
 ifneq ($(MAKECMDGOALS), cleanobjs)
  -include $(DEPENDS)
 endif # cleanobjs
endif # clean

buildinf.h: Makefile
	( echo "#ifndef MK1MF_BUILD"; \
	echo '  /* auto-generated for crypto/common/cversion.c */'; \
	echo '  #define CFLAGS "$(CC) $(CFLAG)"'; \
	echo '#endif' ) >buildinf.h

# Ensure that buildinf.h is created first
cversion.c: buildinf.h

$(LIB):	buildinf.h $(OBJS)
	$(AR) r $(LIB) $(OBJS)
	$(RANLIB) $(LIB) || echo Never mind.

clean: cleanobjs
	rm -f buildinf.h lib tags core .pure .nfs* *.old *.bak

cleanobjs:
	rm -f $(OBJDIR)/*.*
