# Sources

AUTOGEN_PARSERS := $(shell $(PERL) -pe'$$_="" unless /^([^\#][^:]+):/;$$_=$$1 . " "' $(DIR)properties.gen)

# Dodgy use of define/eval to bypass DIR changing
define build_gen_parser

$(BUILDDIR)/gen_parser: $(DIR)css_property_parser_gen.c
	$$(VQ)$$(ECHO) $$(ECHOFLAGS) " PREPARE: $$@"
	$$(Q)$$(BUILD_CC) -o $$@ $$^

endef

$(eval $(build_gen_parser))

define gen_prop_parser

$(DIR)autogenerated_$1.c: $(DIR)properties.gen $(BUILDDIR)/gen_parser
	$$(VQ)$$(ECHO) $$(ECHOFLAGS) "GENERATE: $$@"
	$$(Q)$$(BUILDDIR)/gen_parser -o $$@ '$(shell $(GREP) "^$1:" $(DIR)properties.gen)'

AUTOGEN_SOURCES := $$(AUTOGEN_SOURCES) autogenerated_$1.c

endef

AUTOGEN_SOURCES :=

$(eval $(foreach PROP,$(AUTOGEN_PARSERS),$(call gen_prop_parser,$(PROP))))



DIR_SOURCES :=				\
	azimuth.c			\
	background.c			\
	background_position.c		\
	border.c			\
	border_color.c			\
	border_spacing.c		\
	border_style.c			\
	border_width.c			\
	clip.c				\
	columns.c			\
	column_rule.c			\
	content.c			\
	cue.c				\
	cursor.c			\
	elevation.c			\
	font.c				\
	font_family.c			\
	font_weight.c			\
	list_style.c			\
	list_style_type.c		\
	margin.c			\
	opacity.c			\
	outline.c			\
	overflow.c			\
	padding.c			\
	pause.c				\
	play_during.c			\
	properties.c			\
	quotes.c			\
	text_decoration.c		\
	utils.c				\
	voice_family.c

DIR_SOURCES := $(DIR_SOURCES) $(AUTOGEN_SOURCES)

PRE_TARGETS := $(foreach AP,$(AUTOGEN_PARSERS),src/parse/properties/autogenerated_$(AP).c)

DISTCLEAN_ITEMS := $(foreach AP,$(AUTOGEN_PARSERS),src/parse/properties/autogenerated_$(AP).c)

include $(NSBUILD)/Makefile.subdir
