RM_F    = @rm_f@
PERL    = @perl@
PARROT  = ../../parrot@exe@
PBC_MERGE = ../../pbc_merge@exe@

LIBPATH  = lib
BUILD   = $(PERL) @build_dir@/tools/build/dynpmc.pl
DESTDIR = @build_dir@/runtime/parrot/dynext
O       = @o@
CLASSDIR = pmc
LOAD_EXT = @load_ext@

PMCS = \
    pugsany \
    pugsbit \
    pugsbool \
    pugscode \
    pugscapture \
    pugsint \
    pugsmapping \
    pugsnum \
    pugsmodule \
    pugsstr \
    pugstuple \
    pugsundef

PBCS =

all: pmcs $(PBCS)

pmcs:
	@cd $(CLASSDIR) && $(BUILD) generate $(PMCS)
	@cd $(CLASSDIR) && $(BUILD) compile $(PMCS)
	@cd $(CLASSDIR) && $(BUILD) linklibs $(PMCS)
	@cd $(CLASSDIR) && $(BUILD) copy "--destination=$(DESTDIR)" $(PMCS)

test:   all
	cd .. && $(PERL) -I../lib -Ipugs/t pugs/t/harness

CLEANERS = \
"t/lib/*.pir" \
"t/pmc/*.pir" \
"t/*.pir" \
"t/*.p6" \
"t/*.orig_out" \
"t/*.parrot_out" \
"$(CLASSDIR)/*.dump" \
"$(CLASSDIR)/*.c" \
"$(CLASSDIR)/*.h" \
"$(CLASSDIR)/*$(LOAD_EXT)" \
"$(CLASSDIR)/*$(O)" \
"$(LIBPATH)/*.pbc"

clean:
	$(RM_F) $(CLEANERS)

distclean: clean
	$(RM_F) Makefile
