TOP = ../..
include $(TOP)/configure/CONFIG
#----------------------------------------
#  ADD MACRO DEFINITIONS AFTER THIS LINE

# default main (+m option)
INC += seqMain.c

#  snc product
PROD_HOST += snc

#CFLAGS += -Wconversion -Wextra

snc_OBJS += lexer.o         # generated by re2c from snl.re
snc_OBJS += snl.o           # generated by lemon from snl.lem

snc_SRCS += main.c          # main program
snc_SRCS += node.c          # syntax node operations
snc_SRCS += var_types.c     # declarations
snc_SRCS += analysis.c      # analysis routines
snc_SRCS += gen_code.c      # code generation
snc_SRCS += gen_ss_code.c   # code generation (state sets)
snc_SRCS += gen_tables.c    # code generation (tables)
snc_SRCS += sym_table.c     # symbol table
snc_SRCS += builtin.c       # builtin constants and functions
snc_SRCS += type_check.c    # rudimentary type checker

snc_LIBS += Com

HTMLS += Syntax.txt

LEMON = $(abspath $(INSTALL_HOST_BIN)/lemon$(HOSTEXE))

HDEPENDS_METHOD = MKMF

include $(TOP)/configure/RULES
#----------------------------------------
#  ADD RULES AFTER THIS LINE

vpath %.lem ..
vpath %.lt ..
vpath %.txt $(COMMON_DIR)

%.c %.h: %.lem %.lt $(LEMON)
	$(LEMON) o=. $<

vpath %.re ..

# this ifdef needed for 3.14.8 compatibility
ifdef T_A
lexer.c: snl.re
	$(RE2C) -s -b -o $@ $<
endif

$(COMMON_DIR)/snl.bnf: snl.lem
	$(LEMON) o=. -g $< > $(@F).tmp
	$(MV) $(@F).tmp $@

$(COMMON_DIR)/Syntax.txt: ../bnf2txt.pl snl.re $(COMMON_DIR)/snl.bnf
	$(PERL) $^ > $@

ifeq ($(BASE_3_14),YES)
%$(DEP): %.c
	@-$(MKMF) $(HDEPENDS_FLAGS) -m $*$(DEP) $(HDEPENDS_INCLUDES) $*$(OBJ) $<
endif

CLEANS += lexer.c lexer$(DEP) snl.c snl$(DEP) snl.h

# there is no rule like this in base 3.14
ifeq ($(BASE_3_14),YES)
ifdef T_A
clean::
	@$(RM) $(CLEANS)
endif
endif

# this ifdef needed for 3.14.8 compatibility
ifdef T_A
-include lexer$(DEP) snl$(DEP)
endif
