2013-05-13 22:26:15 +00:00
|
|
|
D := util/topgen
|
|
|
|
|
|
|
|
# Rule to build topgen.
|
|
|
|
|
|
|
|
define build-topgen-impl
|
|
|
|
$(call reset)
|
|
|
|
$(eval cflags += -I$(OBJDIR)/$D -I$D)
|
|
|
|
|
|
|
|
$(call cfile, $D/LLlex.c)
|
|
|
|
$(call cfile, $D/hash.c)
|
|
|
|
$(call cfile, $D/main.c)
|
|
|
|
$(call cfile, $D/pattern.c)
|
|
|
|
$(call cfile, $D/symtab.c)
|
|
|
|
$(eval $q: $(OBJDIR)/$D/Lpars.h)
|
|
|
|
|
|
|
|
$(call llgen, $(OBJDIR)/$D, $D/topgen.g)
|
|
|
|
|
2015-03-22 11:09:46 +00:00
|
|
|
$(call rawfile, $(LIBASSERT))
|
|
|
|
$(call rawfile, $(LIBPRINT))
|
|
|
|
$(call rawfile, $(LIBALLOC))
|
|
|
|
$(call rawfile, $(LIBSYSTEM))
|
|
|
|
$(call rawfile, $(LIBSTRING))
|
2013-05-13 22:26:15 +00:00
|
|
|
|
|
|
|
$(call cprogram, $(BINDIR)/topgen)
|
|
|
|
TOPGEN := $o
|
|
|
|
endef
|
|
|
|
|
|
|
|
$(eval $(build-topgen-impl))
|
|
|
|
|
|
|
|
# Rule to invoke to *use* LLgen.
|
|
|
|
#
|
|
|
|
# $1: directory to put output files
|
|
|
|
# $2: input files
|
|
|
|
#
|
|
|
|
# Output files are *not* compiled (gen.c is expected to be included by
|
|
|
|
# something).
|
|
|
|
|
|
|
|
define topgen-impl
|
|
|
|
$(eval CLEANABLES += $1/gen.h $1/gen.c)
|
|
|
|
|
|
|
|
$1/gen.h: $1/gen.c
|
|
|
|
$1/gen.c: $2 $(TOPGEN)
|
|
|
|
@echo TOPGEN $$@
|
|
|
|
@mkdir -p $$(dir $$@)
|
|
|
|
$(hide) $(RM) $1/gen.h $1/gen.c
|
|
|
|
$(hide) cd $$(dir $$@) && $(abspath $(TOPGEN)) $(abspath $2)
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
topgen = $(eval $(call topgen-impl,$1,$2))
|