# Copyright (C) 2005-2008, The Perl Foundation.
# $Id: /mirror/trunk/languages/regex/config/makefiles/root.in 28688 2008-06-23T00:33:41.905243Z coke  $

# Makefile for languages/regex

# Set up commands
PARROT        = ../../parrot@exe@
PERL          = @perl@
RM_F          = @rm_f@
YAPP          = yapp
PMC_DIR       = pmc
BUILD_DYNPMC  = $(PERL) @build_dir@/tools/build/dynpmc.pl
PARROT_DYNEXT = @build_dir@/runtime/parrot/dynext
RECONFIGURE   = $(PERL) @build_dir@/tools/dev/reconfigure.pl
#CONDITIONED_LINE(darwin):
#CONDITIONED_LINE(darwin):# MACOSX_DEPLOYMENT_TARGET must be defined for OS X compilation/linking
#CONDITIONED_LINE(darwin):export MACOSX_DEPLOYMENT_TARGET := @osx_version@

# Set up directories
LOAD_EXT      = @load_ext@
BUILD_DIR     = @build_dir@

# set up extensions
O             = @o@

PMCS = match matchrange

PMC_SOURCES = $(PMC_DIR)/match.pmc $(PMC_DIR)/matchrange.pmc

build : lib/Regex/Grammar.pm $(PMC_DIR)/match_group$(LOAD_EXT) regex-compiler.pbc

# regenerate the Makefile
Makefile: config/makefiles/root.in
	cd $(BUILD_DIR) && $(RECONFIGURE) --step=gen::languages --languages=regex

lib/Regex/Grammar.pm : lib/Regex/Grammar.yp
	$(YAPP) -s -m Regex::Grammar -o $@ lib/Regex/Grammar.yp

regex-compiler.pbc : regex-compiler.pir
	$(PARROT) -o regex-compiler.pbc regex-compiler.pir

$(PMC_DIR)/match_group$(LOAD_EXT): $(PARROT) $(PMC_SOURCES)
	cd $(PMC_DIR) && $(BUILD_DYNPMC) generate $(PMCS)
	cd $(PMC_DIR) && $(BUILD_DYNPMC) compile $(PMCS)
	cd $(PMC_DIR) && $(BUILD_DYNPMC) linklibs $(PMCS)
	cd $(PMC_DIR) && $(BUILD_DYNPMC) copy --destination=$(PARROT_DYNEXT) $(PMCS)

# Note: These tend to be in the order of the latest thing I've been
# working on to the oldest, so that I see the failures quicker.
.PHONY: test
test : build
	cd .. && $(PERL) t/harness --languages=regex

# This is a TODO test -- currently, it loops forever. It will require
# adding a check to the matcher that it is making progress. Or
# something. I need to look at this again.
#
#	$(PERL) test.pl t/basic/infinite.t

CLEANUPS = \
  "*.pbc" \
  $(PMC_DIR)/*.h \
  $(PMC_DIR)/*.c \
  $(PMC_DIR)/*.dump \
  $(PMC_DIR)/*$(O) \
  $(PMC_DIR)/*$(LOAD_EXT) \
  $(PMC_DIR)/*.exp \
  $(PMC_DIR)/*.ilk \
  $(PMC_DIR)/*.manifest \
  $(PMC_DIR)/*.pdb \
  $(PMC_DIR)/*.lib \
  test_regex.pir \
  test_regex.pbc

clean:
	$(RM_F) $(CLEANUPS)

realclean: clean
	$(RM_F) Makefile

distclean: realclean

