#
#	Makefile for ASN.1 '88 parser
#
#  compiles the snacc ASN.1 compiler and moves the binary to the 
#  BINDIR
#
# Mike Sample
# 1992
#


# some CLFAG options:
#  -DYYDEBUG use for yacc/lex debug info
#  -DDEBUG use to get general debug info
#  -DFLEX use this if you use flex instead of lex -DFLEX
CC = gcc
CFLAGS = -O -I$(C_TOOL_DIR) -I$(CPP_TOOL_DIR) -DFLEX


# LEX can be "lex" or "flex"
# remember to set use -DFLEX in CFLAGS if you use flex
# if you use lex, you may need the -Nc10000 option.
# also with lex, the YYLMAX (in lex.yy.c) should be set 
# to at least 2048 (from the 200 or whatever measly default
# value it has)
#
LEX = flex

# YACC can be "yacc" or "bison -y"
YACC = bison -y

BINDIR = ../bin

C_TOOL_DIR = back_ends/c_gen
C_TOOL_OBJS =  $(C_TOOL_DIR)/type_info.o\
               $(C_TOOL_DIR)/str_util.o\
               $(C_TOOL_DIR)/util.o\
               $(C_TOOL_DIR)/rules.o\
               $(C_TOOL_DIR)/tag_util.o\
               $(C_TOOL_DIR)/gen_c_code.o\
               $(C_TOOL_DIR)/gen_c_type.o\
               $(C_TOOL_DIR)/gen_c_enc.o\
               $(C_TOOL_DIR)/gen_c_dec.o\
               $(C_TOOL_DIR)/gen_c_vals.o\
               $(C_TOOL_DIR)/gen_c_free.o\
               $(C_TOOL_DIR)/gen_c_print.o\
               $(C_TOOL_DIR)/gen_c_any.o\
               $(C_TOOL_DIR)/c_kwd.o\
               $(C_TOOL_DIR)/cpp_kwd.o


CPP_TOOL_DIR = back_ends/c++_gen
CPP_TOOL_OBJS =  $(CPP_TOOL_DIR)/cpp_types.o\
                 $(CPP_TOOL_DIR)/cpp_rules.o\
                 $(CPP_TOOL_DIR)/gen_cpp_code.o\
                 $(CPP_TOOL_DIR)/gen_cpp_vals.o\
                 $(CPP_TOOL_DIR)/gen_cpp_any.o




SNACC_OBJS = y.tab.o lex.yy.o link_types.o exports.o snacc_util.o\
           dependency.o lib_types.o mem.o print.o do_macros.o\
           oid.o list.o link_values.o normalize.o val_parser.o\
           err_chk.o define.o recursive.o snacc.o 

all: snacc

snacc:    $(SNACC_OBJS) $(C_TOOL_OBJS) $(CPP_TOOL_OBJS) makefile
	 $(CC) $(CFLAGS) $(SNACC_OBJS) $(C_TOOL_OBJS) $(CPP_TOOL_OBJS)\
         -ll -o snacc
	mv snacc $(BINDIR)

y.tab.c:  asn1.yacc makefile
	$(YACC) -d asn1.yacc

lex.yy.c: asn1.lex makefile
	$(LEX) asn1.lex



$(C_TOOL_OBJS): asn1module.h snacc_config.h basetypes.h list.h ber.h snacc_util.h $(C_TOOL_DIR)/makefile
	cd $(C_TOOL_DIR); make

$(CPP_TOOL_OBJS): asn1module.h snacc_config.h basetypes.h list.h ber.h snacc_util.h $(CPP_TOOL_DIR)/makefile
	cd $(CPP_TOOL_DIR); make

backup:
	cp makefile asn1.yacc asn1.lex *.c *.h bak

depend:
	makedepend -I$(C_TOOL_DIR) -I$(CPP_TOOL_DIR) *.c *.yacc *.lex 

clean:
	rm -f *.o y.tab.c y.tab.h lex.yy.c y.output .emacs* *~ core *.bak\
        yacc.tmp yacc.acts yacc.debug
	cd $(C_TOOL_DIR); make clean
	cd $(CPP_TOOL_DIR); make clean


# DO NOT DELETE THIS LINE -- make depend depends on it.

define.o: snacc_config.h mem.h define.h makefile
dependency.o: snacc_config.h mem.h basetypes.h ber.h
dependency.o: list.h asn1module.h snacc_util.h makefile
do_macros.o: snacc_config.h mem.h
do_macros.o: ber.h basetypes.h list.h asn1module.h define.h makefile
do_macros.o: back_ends/c_gen/str_util.h normalize.h snacc_util.h
err_chk.o: snacc_config.h mem.h ber.h basetypes.h list.h
err_chk.o: asn1module.h snacc_util.h define.h makefile
exports.o:  snacc_config.h ber.h basetypes.h list.h
exports.o: asn1module.h snacc_util.h exports.h makefile
lib_types.o: snacc_config.h ber.h basetypes.h list.h asn1module.h lib_types.h
lib_types.o: makefile
link_types.o: snacc_config.h
link_types.o: basetypes.h ber.h list.h asn1module.h mem.h snacc_util.h
link_types.o: link_types.h makefile
link_values.o: snacc_config.h
link_values.o: basetypes.h ber.h list.h asn1module.h mem.h snacc_util.h
link_values.o: link_values.h makefile
list.o: snacc_config.h mem.h list.h makefile
mem.o: snacc_config.h makefile
normalize.o: snacc_config.h mem.h ber.h basetypes.h
normalize.o: list.h oid.h asn1module.h lib_types.h snacc_util.h normalize.h
normalize.o: makefile
oid.o:  snacc_config.h basetypes.h makefile
print.o:  snacc_config.h basetypes.h ber.h list.h
print.o: asn1module.h lib_types.h print.h makefile
recursive.o:  snacc_config.h basetypes.h list.h
recursive.o: asn1module.h makefile
snacc.o: snacc_config.h basetypes.h ber.h list.h
snacc.o: mem.h asn1module.h exports.h parser.h dependency.h link_types.h
snacc.o: link_values.h err_chk.h print.h recursive.h define.h normalize.h
snacc.o: do_macros.h back_ends/c_gen/rules.h back_ends/c_gen/str_util.h
snacc.o: back_ends/c_gen/type_info.h back_ends/c_gen/gen_c_code.h
snacc.o: back_ends/c++_gen/cpp_rules.h back_ends/c++_gen/cpp_types.h
snacc.o: back_ends/c++_gen/gen_cpp_code.h makefile
snacc_util.o:  snacc_config.h ber.h mem.h basetypes.h
snacc_util.o: list.h asn1module.h lib_types.h define.h snacc_util.h makefile
typetbl.o: snacc_config.h ber.h basetypes.h list.h asn1module.h lib_types.h
typetbl.o: makefile
val_parser.o:  snacc_config.h
val_parser.o: basetypes.h ber.h list.h asn1module.h mem.h snacc_util.h oid.h
val_parser.o: makefile
y.tab.o:  snacc_config.h ber.h mem.h basetypes.h
y.tab.o: list.h asn1module.h lib_types.h snacc_util.h exports.h parser.h
y.tab.o: lex_stuff.h makefile
lex.yy.o: snacc_config.h ber.h mem.h basetypes.h
lex.yy.o: list.h asn1module.h snacc_util.h exports.h parser.h
lex.yy.o: lex_stuff.h y.tab.h makefile
