#
# builds the PersonnelRecord example programs for each buffer type
#
# MS 92
# 

SNACC_DIR = ../..
SNACC = $(SNACC_DIR)/bin/snacc
ASN1_SRC_DIR = $(SNACC_DIR)/asn1specs
ASN1_CINCLUDE_DIR = $(SNACC_DIR)/c_include
ASN1_CLIB_DIR = $(SNACC_DIR)/c_lib
MBUF_ASN1_LIB = $(ASN1_CLIB_DIR)/libasn1cmbuf.a
SBUF_ASN1_LIB = $(ASN1_CLIB_DIR)/libasn1csbuf.a
EBUF_ASN1_LIB = $(ASN1_CLIB_DIR)/libasn1cebuf.a


ASN1_SRCS = $(ASN1_SRC_DIR)/p_rec.asn1
USEFUL_TYPES = $(ASN1_SRC_DIR)/useful.asn1

# the SRCS and HDRS are generated by snacc from p_rec.asn1
HDRS = p_rec.h 
SRCS = p_rec.c


CC = gcc
CFLAGS = -O -I$(ASN1_CINCLUDE_DIR)

all: genber minbuf_def minbuf_indef expbuf_def expbuf_indef sbuf_def sbuf_indef 

$(SRCS): $(SNACC) $(ASN1_SRCS)
	$(SNACC) -u $(USEFUL_TYPES) $(ASN1_SRCS) 

genber: $(SRCS) genber.c
	$(CC) $(CFLAGS) $(SRCS) genber.c $(SBUF_ASN1_LIB) -o genber

expbuf_def:  $(SRCS) expbuf_ex.c
	$(CC) $(CFLAGS) -DUSE_EXP_BUF $(SRCS) expbuf_ex.c \
        $(EBUF_ASN1_LIB) -o expbuf_def

expbuf_indef: 
	$(CC) $(CFLAGS) -DUSE_EXP_BUF -DUSE_INDEF_LEN $(SRCS) expbuf_ex.c\
        $(EBUF_ASN1_LIB) -o expbuf_indef


sbuf_def:  $(SRCS) sbuf_ex.c
	$(CC) $(CFLAGS) $(SRCS) sbuf_ex.c $(SBUF_ASN1_LIB) -o sbuf_def

sbuf_indef:
	$(CC) $(CFLAGS) -DUSE_INDEF_LEN $(SRCS) sbuf_ex.c\
         $(SBUF_ASN1_LIB) -o sbuf_indef

minbuf_def:  $(SRCS) minbuf_ex.c
	$(CC) $(CFLAGS) -DUSE_MIN_BUF $(SRCS) minbuf_ex.c\
         $(MBUF_ASN1_LIB) -o minbuf_def

minbuf_indef:
	$(CC) $(CFLAGS) -DUSE_MIN_BUF -DUSE_INDEF_LEN $(SRCS) minbuf_ex.c\
        $(MBUF_ASN1_LIB) -o minbuf_indef


clean:
	rm -f *.o *~ core .emacs* expbuf_def expbuf_indef sbuf_indef sbuf_def minbuf_def minbuf_indef genber pr.ber $(HDRS) $(SRCS) 

