RM_F     = @rm_f@
PERL     = @perl@
BUILDPMC = $(PERL) @build_dir@/tools/build/dynpmc.pl
DESTDIR  = @build_dir@/runtime/parrot/dynext
O        = @o@
CLASSDIR = lib/kernel/pmc
LOAD_EXT = @load_ext@

# Order matters!
PMCS = \
 amber_default \
 amber_array \
 amber_boolean \
 amber_integer \
 amber_character \
 amber_string \
 amber_pathname \
 amber_table

# the default target
all: pmcs

# a listing of all targets that are meant to be called by users
help:
	@echo ""
	@echo "Following targets are available for the user:"
	@echo ""
	@echo "  all:               pmcs"
	@echo "                     This is the default."
	@echo "  pmcs:              PMCs for Amber's kernel types."
	@echo ""
	@echo "Cleaning:"
	@echo "  clean:             Basic cleaning up."
	@echo "  realclean:         Removes also files generated by 'Configure.pl'"
	@echo "  distclean:         Removes also anything built, in theory"
	@echo ""
	@echo "Misc:"
	@echo "  help:              Print this help message."
	@echo ""

# PMCs for Amber's kernel types
pmcs:
	@cd $(CLASSDIR) && $(BUILDPMC) generate $(PMCS)
	@cd $(CLASSDIR) && $(BUILDPMC) compile $(PMCS)
	@cd $(CLASSDIR) && $(BUILDPMC) linklibs $(PMCS)
	@cd $(CLASSDIR) && $(BUILDPMC) copy "--destination=$(DESTDIR)" $(PMCS)

CLEANERS = \
"$(CLASSDIR)/pmc_*.h" \
"$(CLASSDIR)/amber_*.h" \
"$(CLASSDIR)/*.dump" \
#CONDITIONED_LINE(ld_parrot_exe_def):"$(CLASSDIR)/*.def" \
"$(CLASSDIR)/*.c" \
"$(CLASSDIR)/*$(LOAD_EXT)" \
"$(CLASSDIR)/*$(O)"

clean:
	$(RM_F) $(CLEANERS)

realclean: clean
	$(RM_F) Makefile

distclean: realclean
