# Copyright (C) 2001-2008, The Perl Foundation.
# $Id: /mirror/trunk/config/gen/makefiles/root.in 35880 2009-01-21T01:07:25.482595Z chromatic  $

###############################################################################
#
# NOTE:
#
# This makefile makes use of specific .dummy targets (rather than .PHONY
# or .VIRTUAL targets) in an effort to work with various flavors of make.
#
###############################################################################

###############################################################################
#
# INSTALL CONFIGURATIONS:
#
###############################################################################

DEVEL           = @DEVEL@
VERSION         = @VERSION@$(DEVEL)
SOVERSION       = @VERSION@

# Override at least PREFIX with the install location if you're going
# to be using this outside of your build area.
BUILDPREFIX     =
PREFIX          = @prefix@
EXEC_PREFIX     = @exec_prefix@
DESTDIR         =
BIN_DIR         = @bin_dir@
LIB_DIR         = @lib_dir@
INCLUDE_DIR     = @include_dir@
DOC_DIR         = @doc_dir@


###############################################################################
#
# SOURCE CONFIGURATIONS:
#
# Set up information about directories where the sources can be found.
#
###############################################################################

# where we're building parrot from (needed for pbc_to_exe)
BUILD_DIR = @build_dir@

# directory for build tools
BUILD_TOOLS_DIR = tools/build

# current directory
CUR_DIR         = .

# directory for the intermediate code compiler
IMCC_DIR        = compilers/imcc

# directory for header files
INC_DIR         = @inc@

# directory for the IO subsystem
IO_DIR          = src/io

# directory with Parrot modules
LIBRARY_DIR     = runtime/parrot/library

# directory for *.ops file
OPS_DIR         = src/ops

# directory for packfile files
PF_DIR          = src/packfile

# source directory
SRC_DIR         = src

###############################################################################
#
# BUILD TOOL CONFIGURATIONS:
#
# DO NOT ADD C COMPILER FLAGS HERE
# Add them in Configure.pl--look for the
# comment 'ADD C COMPILER FLAGS HERE'
#
###############################################################################

RM_F             = @rm_f@
RM_RF            = @rm_rf@
AR_CR            = @ar@ @ar_flags@
RANLIB           = @ranlib@
PERL             = @perl@
CP               = @cp@
CHMOD            = @chmod@
TOUCH            = @touch@
YACC             = @yacc@
LEX              = @lex@
MKPATH           = @mkpath@
AS               = @as@
CC               = @cc@
CC_INC           = @cc_inc@
C_LIBS           = @libs@
CC_SHARED        = @cc_shared@
CFLAGS           = $(CC_INC) @ccflags@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@ $(CC_SHARED)
LINK_DYNAMIC     = @link_dynamic@
LINK             = @link@
LINKFLAGS        = @linkflags@ @link_debug@ @ld_debug@
LD               = @ld@
LDFLAGS          = @ldflags@ @ld_debug@
RECONFIGURE      = $(PERL) tools/dev/reconfigure.pl
INNO_SETUP       = iscc
JIT_BUILD_TOOL   = $(BUILD_TOOLS_DIR)/jit2c.pl
#IF(darwin):export MACOSX_DEPLOYMENT_TARGET := @osx_version@

###############################################################################
#
# file extensions and util flags
#
###############################################################################

O                = @o@
EXE              = @exe@
SHARE_EXT        = @share_ext@
LOAD_EXT         = @load_ext@
A                = @a@
LD_SHARE_FLAGS   = @ld_share_flags@
LD_LOAD_FLAGS    = @ld_load_flags@

# generated by config/init/headers.pm
NONGEN_HEADERS   = @TEMP_nongen_headers@

###############################################################################
#
# CONFIGURE_GENERATED_FILES:
#
# These files are created when Configure.pl runs.
#
# We don't delete these on 'clean'; only on 'realclean'.
# That way, we don't have to re-Configure.pl after making
# clean.
#
###############################################################################

GEN_MAKEFILES = \
    Makefile \
#IF(has_perldoc):    docs/Makefile \
    compilers/json/Makefile \
    compilers/ncigen/Makefile \
    compilers/nqp/Makefile \
    compilers/pct/Makefile \
    compilers/pge/Makefile \
    compilers/tge/Makefile \
    editor/Makefile \
    ext/Makefile \
    languages/Makefile \
    src/dynoplibs/Makefile

GEN_CONFIGS = \
    $(INC_DIR)/config.h \
    $(INC_DIR)/platform.h \
    $(INC_DIR)/platform_interface.h \
    $(INC_DIR)/platform_limits.h \
    $(INC_DIR)/has_header.h \
    $(INC_DIR)/feature.h \
    $(INC_DIR)/core_pmcs.h \
    $(SRC_DIR)/exec_dep.c \
    $(SRC_DIR)/exec_dep.h \
    lib/Parrot/Config/Generated.pm \
    lib/Parrot/PMC.pm \
    runtime/parrot/include/config.fpmc \
    $(SRC_DIR)/platform.c \
#IF(platform_asm):    $(SRC_DIR)/platform_asm.s \
#IF(has_opengl):    config/gen/call_list/opengl.in \
#IF(has_glut):    $(SRC_DIR)/glut_callbacks.c \
    $(SRC_DIR)/core_pmcs.c \
    CFLAGS \
    $(IMCC_DIR)/CFLAGS \
    config_lib.pasm \
    $(BUILD_TOOLS_DIR)/dynpmc.pl \
    $(BUILD_TOOLS_DIR)/dynoplibs.pl \
    parrot.pc \
    $(IMCC_DIR)/imcc.y.flag \
    $(OPS_DIR)/core_ops.c \
    $(OPS_DIR)/core_ops_switch.c \
    parrot_config$(EXE) parrot_config.c parrot_config.o parrot_config.pbc

# most of these are generated by config/gen/parrot_include.pm

GEN_PASM_INCLUDES = \
    runtime/parrot/include/signal.pasm \
#IF(has_opengl):    runtime/parrot/include/opengl_defines.pasm \
#IF(has_opengl):    runtime/parrot/library/OpenGL_funcs.pir \
    @TEMP_gen_pasm_includes@

CONFIGURE_GENERATED_FILES = \
    $(GEN_CONFIGS) \
    $(GEN_MAKEFILES) \
    ext/Parrot-Embed/Makefile.PL \
    myconfig  \
    $(GEN_PASM_INCLUDES) \
    $(SRC_DIR)/call_list.txt \
    MANIFEST.configure.generated \
    .configure_trace.sto \
    .parrot_current_rev


###############################################################################
#
# "FLUID" GENERATED FILES:
#
# These files are created during the build process.
#
# We *do* delete these on 'clean'.
#
###############################################################################

GEN_OPSFILES =

GEN_HEADERS = \
    $(INC_DIR)/vtable.h \
    $(INC_DIR)/oplib/core_ops.h \
    $(INC_DIR)/oplib/ops.h \
    $(INC_DIR)/oplib/core_ops_switch.h \
    $(INC_DIR)/extend_vtable.h \
    $(INC_DIR)/pbcversion.h

GEN_SOURCES = \
    $(SRC_DIR)/core_ops.c \
    $(SRC_DIR)/nci.c \
    $(SRC_DIR)/core_ops_switch.c \
    $(SRC_DIR)/jit_cpu.c \
    $(SRC_DIR)/parrot_config.c \
    $(SRC_DIR)/null_config.c \
    $(SRC_DIR)/install_config.c \
    $(SRC_DIR)/exec_cpu.c \
    $(SRC_DIR)/jit_defs.c \
    $(SRC_DIR)/extend_vtable.c

GEN_MODULES = \
    lib/Parrot/OpLib/core.pm

GEN_LIBRARY = \
    $(LIBRARY_DIR)/CGI/QueryHash.pbc \
    $(LIBRARY_DIR)/Crow.pbc \
    $(LIBRARY_DIR)/config.pbc \
    $(LIBRARY_DIR)/Config/JSON.pbc \
    $(LIBRARY_DIR)/Data/Dumper/Base.pbc \
    $(LIBRARY_DIR)/Data/Dumper/Default.pbc \
    $(LIBRARY_DIR)/Data/Dumper.pbc \
    $(LIBRARY_DIR)/Data/Escape.pbc \
    $(LIBRARY_DIR)/Data/Sort.pbc \
    $(LIBRARY_DIR)/Digest/MD5.pbc \
    $(LIBRARY_DIR)/dumper.pbc \
    $(LIBRARY_DIR)/yaml_dumper.pbc \
    $(LIBRARY_DIR)/Getopt/Obj.pbc \
    $(LIBRARY_DIR)/JSON.pbc \
    $(LIBRARY_DIR)/Math/Random/mt19937ar.pbc \
    $(LIBRARY_DIR)/MIME/Base64.pbc \
    $(LIBRARY_DIR)/NCI/call_toolkit_init.pbc \
    $(LIBRARY_DIR)/ncurses.pbc \
#IF(has_opengl):    $(LIBRARY_DIR)/OpenGL.pbc \
    $(LIBRARY_DIR)/P6object.pbc \
    $(LIBRARY_DIR)/parrotlib.pbc \
    $(LIBRARY_DIR)/pcre.pbc \
    $(LIBRARY_DIR)/Parrot/Coroutine.pbc \
    $(LIBRARY_DIR)/Parrot/Exception.pbc \
    $(LIBRARY_DIR)/PGE/Dumper.pbc \
    $(LIBRARY_DIR)/PGE/Glob.pbc \
    $(LIBRARY_DIR)/PGE/Perl6Grammar.pbc \
    $(LIBRARY_DIR)/PGE/Text.pbc \
    $(LIBRARY_DIR)/PGE/Util.pbc \
    $(LIBRARY_DIR)/Protoobject.pbc \
    $(LIBRARY_DIR)/Stream/Base.pbc \
    $(LIBRARY_DIR)/Stream/Combiner.pbc \
    $(LIBRARY_DIR)/Stream/Coroutine.pbc \
    $(LIBRARY_DIR)/Stream/Filter.pbc \
    $(LIBRARY_DIR)/Stream/Lines.pbc \
    $(LIBRARY_DIR)/Stream/ParrotIO.pbc \
    $(LIBRARY_DIR)/Stream/Replay.pbc \
    $(LIBRARY_DIR)/Stream/Sub.pbc \
    $(LIBRARY_DIR)/Stream/Writer.pbc \
    $(LIBRARY_DIR)/String/Utils.pbc \
    $(LIBRARY_DIR)/Test/Builder/Output.pbc \
    $(LIBRARY_DIR)/Test/Builder/Test.pbc \
    $(LIBRARY_DIR)/Test/Builder/Tester.pbc \
    $(LIBRARY_DIR)/Test/Builder/TestPlan.pbc \
    $(LIBRARY_DIR)/Test/Builder.pbc \
    $(LIBRARY_DIR)/Test/Class.pbc \
    $(LIBRARY_DIR)/Test/More.pbc \
    $(LIBRARY_DIR)/Tcl/Glob.pbc \
    $(LIBRARY_DIR)/uuid.pbc \
    $(LIBRARY_DIR)/YAML/Parser/Syck.pbc \
    $(LIBRARY_DIR)/STM.pbc \
    $(LIBRARY_DIR)/libpcre.pbc \
    $(LIBRARY_DIR)/Data/Replace.pbc \
    $(LIBRARY_DIR)/postgres.pbc

# the dependencies of $(SRC_DIR)/jit_emit.h are done explicitly
# including this file in GEN_HEADERS causes unnecessary recompile of all
FLUID_FILES_1 = \
    $(GEN_OPSFILES) \
    $(GEN_HEADERS) \
    $(GEN_SOURCES) \
    $(GEN_MODULES) \
    $(SRC_DIR)/jit_emit.h

FLUID_FILES_2 = \
    $(GEN_LIBRARY) \
    runtime/parrot/include/parrotlib.pbc


###############################################################################
#
# OTHER FILE GROUPS:
#
###############################################################################

# these are private to the IMCC subsystem
IMCC_H_FILES = \
    $(IMCC_DIR)/imc.h \
    $(IMCC_DIR)/cfg.h \
    $(IMCC_DIR)/instructions.h \
    $(IMCC_DIR)/debug.h \
    $(IMCC_DIR)/sets.h \
    $(IMCC_DIR)/unit.h \
    $(IMCC_DIR)/symreg.h \
    $(IMCC_DIR)/pbc.h \
    $(IMCC_DIR)/optimizer.h \
    $(IMCC_DIR)/parser.h \
    $(IMCC_DIR)/imcparser.h

IMCC_O_FILES = \
    $(IMCC_DIR)/imcparser$(O) \
    $(IMCC_DIR)/imclexer$(O) \
    $(IMCC_DIR)/imc$(O) \
    $(IMCC_DIR)/main$(O) \
    $(IMCC_DIR)/symreg$(O) \
    $(IMCC_DIR)/instructions$(O) \
    $(IMCC_DIR)/cfg$(O) \
    $(IMCC_DIR)/reg_alloc$(O) \
    $(IMCC_DIR)/sets$(O) \
    $(IMCC_DIR)/debug$(O) \
    $(IMCC_DIR)/optimizer$(O) \
    $(IMCC_DIR)/pbc$(O) \
    $(IMCC_DIR)/parser_util$(O) \
    $(IMCC_DIR)/pcc$(O)

# generated list of header files
GENERAL_H_FILES   = $(NONGEN_HEADERS) $(GEN_HEADERS) @TEMP_cg_h@

ALL_H_FILES       = $(GENERAL_H_FILES)

CHARSET_O_FILES   = @TEMP_charset_o@
CLASS_PMC_FILES   = @TEMP_pmc_classes_pmc@
CLASS_O_FILES     = @TEMP_pmc_classes_o@
CLASS_STR_FILES   = @TEMP_pmc_classes_str@
ENCODING_O_FILES  = @TEMP_encoding_o@


IO_O_FILES = \
    $(IO_DIR)/core$(O) \
    $(IO_DIR)/api$(O) \
    $(IO_DIR)/utf8$(O) \
    $(IO_DIR)/buffer$(O) \
    $(IO_DIR)/unix$(O) \
    $(IO_DIR)/win32$(O) \
    $(IO_DIR)/portable$(O) \
    $(IO_DIR)/filehandle$(O)

INTERP_O_FILES = \
    $(SRC_DIR)/string$(O) \
    \
    $(OPS_DIR)/core_ops$(O) \
    $(OPS_DIR)/core_ops_switch$(O) \
    \
#IF(i386_has_gcc_cmpxchg):    $(SRC_DIR)/atomic/gcc_x86$(O) \
    $(SRC_DIR)/byteorder$(O) \
    $(SRC_DIR)/charset$(O) \
    $(SRC_DIR)/core_pmcs$(O) \
    $(SRC_DIR)/cpu_dep$(O) \
    $(SRC_DIR)/datatypes$(O) \
    $(SRC_DIR)/debug$(O) \
    $(SRC_DIR)/dynext$(O) \
    $(SRC_DIR)/embed$(O) \
    $(SRC_DIR)/encoding$(O) \
    $(SRC_DIR)/events$(O) \
    $(SRC_DIR)/exceptions$(O) \
    $(SRC_DIR)/exit$(O) \
    $(SRC_DIR)/extend$(O) \
    $(SRC_DIR)/extend_vtable$(O) \
    $(SRC_DIR)/gc/api$(O) \
    $(SRC_DIR)/gc/generational_ms$(O) \
    $(SRC_DIR)/gc/incremental_ms$(O) \
    $(SRC_DIR)/gc/memory$(O) \
    $(SRC_DIR)/gc/pools$(O) \
    $(SRC_DIR)/gc/register$(O) \
    $(SRC_DIR)/gc/mark_sweep$(O) \
    $(SRC_DIR)/global$(O) \
    $(SRC_DIR)/global_setup$(O) \
    $(SRC_DIR)/hash$(O) \
    $(SRC_DIR)/hll$(O) \
    $(SRC_DIR)/inter_call$(O)  \
    $(SRC_DIR)/inter_cb$(O)  \
    $(SRC_DIR)/inter_create$(O)  \
    $(SRC_DIR)/inter_misc$(O)  \
    $(SRC_DIR)/interpreter$(O)  \
    $(SRC_DIR)/inter_run$(O)  \
    $(SRC_DIR)/intlist$(O) \
    $(SRC_DIR)/key$(O) \
    $(SRC_DIR)/library$(O) \
    $(SRC_DIR)/list$(O) \
    $(SRC_DIR)/longopt$(O) \
    $(SRC_DIR)/misc$(O) \
    $(SRC_DIR)/multidispatch$(O) \
    $(SRC_DIR)/nci$(O) \
    $(SRC_DIR)/oo$(O) \
    $(SRC_DIR)/packfile$(O) \
    $(SRC_DIR)/packout$(O) \
    $(SRC_DIR)/pic_jit$(O) \
    $(SRC_DIR)/pic$(O) \
    $(SRC_DIR)/platform$(O) \
    $(SRC_DIR)/pmc_freeze$(O) \
    $(SRC_DIR)/pmc$(O) \
    $(SRC_DIR)/runops_cores$(O) \
    $(SRC_DIR)/scheduler$(O) \
    $(SRC_DIR)/spf_render$(O) \
    $(SRC_DIR)/spf_vtable$(O) \
    $(SRC_DIR)/stacks$(O) \
    $(SRC_DIR)/string_primitives$(O) \
    $(SRC_DIR)/sub$(O) \
    $(SRC_DIR)/thread$(O) \
    $(SRC_DIR)/trace$(O) \
    $(SRC_DIR)/tsq$(O) \
    $(SRC_DIR)/utils$(O) \
    $(SRC_DIR)/vtables$(O) \
    $(SRC_DIR)/warnings$(O) \
    \
    $(PF_DIR)/pf_items$(O) \
    \
    @asmfun_o@ \
    @TEMP_cg_o@ \
    @TEMP_exec_o@ \
    @TEMP_atomic_o@ \
    @TEMP_jit_o@ \
    @TEMP_gc_o@ \
#IF(platform_asm):    $(SRC_DIR)/platform_asm$(O) \

O_FILES = \
    $(INTERP_O_FILES) \
    $(CHARSET_O_FILES) \
    $(IO_O_FILES) \
    $(CLASS_O_FILES) \
    $(ENCODING_O_FILES) \
    $(IMCC_O_FILES)

OPS_FILES = @ops@ $(GEN_OPSFILES)

###############################################################################
#
# BUILD TARGET CONFIGURATIONS:
#
###############################################################################

# Executables
PARROT              = $(CUR_DIR)/@test_prog@$(EXE)
MINIPARROT          = $(CUR_DIR)/miniparrot$(EXE)
DIS                 = $(CUR_DIR)/pbc_disassemble$(EXE)
PDUMP               = $(CUR_DIR)/pdump$(EXE)
PINFO               = $(CUR_DIR)/pbc_info$(EXE)
PBCMERGE            = $(CUR_DIR)/pbc_merge$(EXE)
PDB                 = $(CUR_DIR)/parrot_debugger$(EXE)
PBC_TO_EXE          = $(CUR_DIR)/pbc_to_exe$(EXE)
PARROT_CONFIG       = $(CUR_DIR)/parrot_config$(EXE)

# HLL Executables
PERL6               = $(CUR_DIR)/perl6$(EXE)

# Installable executables
INSTALLABLEPARROT   = $(CUR_DIR)/installable_parrot$(EXE)
INSTALLABLEDIS      = $(CUR_DIR)/installable_pbc_disassemble$(EXE)
INSTALLABLEPDUMP    = $(CUR_DIR)/installable_pdump$(EXE)
INSTALLABLEPINFO    = $(CUR_DIR)/installable_pbc_info$(EXE)
INSTALLABLEPBCMERGE = $(CUR_DIR)/installable_pbc_merge$(EXE)
INSTALLABLEPDB      = $(CUR_DIR)/installable_parrot_debugger$(EXE)
INSTALLABLECONFIG   = $(CUR_DIR)/installable_parrot_config$(EXE)

# Libraries
LIBPARROT_STATIC    = @blib_dir@/@libparrot_static@
#IF(darwin):export DYLD_LIBRARY_PATH := @blib_dir@:$(DYLD_LIBRARY_PATH)
#IF(win32):LIBPARROT_SHARED  = @libparrot_shared@
#ELSE:LIBPARROT_SHARED  = @blib_dir@/@libparrot_shared@

# This line controls whether a static or shared library is built
LIBPARROT           = @libparrot@

#IF(has_icu):ICU_SHARED  = @icu_shared@
ALL_PARROT_LIBS     = @libparrot_ldflags@ $(ICU_SHARED) $(C_LIBS)

# dynamic extensions
DYNEXT_DIR          = runtime/parrot/dynext
LIBNCI_TEST_SO      = $(DYNEXT_DIR)/libnci_test$(LOAD_EXT)
LIBGLUTCB_SO        = $(DYNEXT_DIR)/libglutcb$(LOAD_EXT)

###############################################################################
#
# MAKE CONFIGURATION:
#
###############################################################################

# This is set to MAKE=$make if your $make command doesn't
# do it for you.
@make_set_make@
MAKE = @make_c@

# These need to be above lines that define suffix rules to be portable
# (certainly FreeBSD make doesn't grok the pir.pbc rule otherwise)

.SUFFIXES : .c .h .pmc .dump $(O) .str .pir .pbc

# Passing an empty argument in @ARGV to cc_flags.pl to indicate where extra -Is
# (etc) should go. Otherwise it will insert them after the first space, which
# makes life go horribly wrong if $(CC) contains spaces but can't have -I
# arguments (etc) injected in the middle.
# There is probably a better way to do this, but I can't work it out right now.
.c$(O) :
	@$(PERL) tools/dev/cc_flags.pl $(CUR_DIR)/CFLAGS $(CC) "" $(CFLAGS) -I$(@D) @cc_o_out@$@ -c $<

# XXX probably should detect assembler, but right now this is only used on Sparc

.s$(O) :
	@$(PERL) tools/dev/cc_flags.pl $(CUR_DIR)/CFLAGS $(CC) "" $(CFLAGS) -I$(@D) @cc_o_out@$@ -c $<

# XXX These obviously require parrot: had trouble adding parrot as a dependency
# here, though. Ignored on Mac OS X, at least.

.pir.pbc :
	$(PARROT) -o $@ $<

.pbc$(O) :
	$(PARROT) -o $@ $<


###############################################################################
#
# USER TARGETS:
#
# These targets are supposed to be called by the user.
#
###############################################################################

all : \
    flags_dummy \
    PARROT_LIBS \
    $(PARROT) \
    runtime/parrot/include/parrotlib.pbc \
    runtime/parrot/include/config.fpmc \
    docs \
    $(LIBNCI_TEST_SO) \
#IF(has_glut):    $(LIBGLUTCB_SO) \
    $(GEN_LIBRARY) \
    dynpmc \
    dynoplibs \
    compilers \
    $(PBC_TO_EXE) \
    $(PARROT_CONFIG) \
    $(DIS) \
    $(PBCMERGE)

$(GEN_LIBRARY) : $(PARROT)

# constant string support
.c.str :
	$(PERL) $(BUILD_TOOLS_DIR)/c2str.pl $< > $@

STR_FILES = \
    $(SRC_DIR)/debug.str \
    $(SRC_DIR)/dynext.str \
    $(SRC_DIR)/events.str \
    $(SRC_DIR)/exceptions.str \
    $(SRC_DIR)/global.str \
    $(SRC_DIR)/global_setup.str \
    $(SRC_DIR)/hll.str \
    $(SRC_DIR)/inter_call.str \
    $(SRC_DIR)/inter_cb.str \
    $(SRC_DIR)/inter_create.str \
    $(SRC_DIR)/inter_misc.str \
    $(SRC_DIR)/io/api.str \
    $(SRC_DIR)/key.str \
    $(SRC_DIR)/library.str \
    $(SRC_DIR)/multidispatch.str \
    $(SRC_DIR)/nci.str \
    $(SRC_DIR)/packfile.str \
    $(SRC_DIR)/pmc.str \
    $(SRC_DIR)/pmc_freeze.str \
    $(SRC_DIR)/oo.str \
    $(SRC_DIR)/scheduler.str \
    $(SRC_DIR)/spf_render.str \
    $(SRC_DIR)/spf_vtable.str \
    $(SRC_DIR)/sub.str \
    $(SRC_DIR)/stacks.str \
    \
    $(CLASS_STR_FILES)

$(SRC_DIR)/string_private_cstring.h : $(STR_FILES) $(BUILD_TOOLS_DIR)/c2str.pl
	$(PERL) $(BUILD_TOOLS_DIR)/c2str.pl --all

# classes PMC build utils and rules
PMC2CD = $(PERL) $(BUILD_TOOLS_DIR)/pmc2c.pl --dump
PMC2CC = $(PERL) $(BUILD_TOOLS_DIR)/pmc2c.pl --c
PMC2CV = $(PERL) $(BUILD_TOOLS_DIR)/pmc2c.pl --vtable

.pmc.dump :
	$(PMC2CD) $<

.pmc.c :
	$(PMC2CC) $<

# not all makes might understand this, so the rules are generated
#src/pmc/pmc_%.h : src/pmc/%.c
#	$(PMC2CC) $<

vtable.dump : src/vtable.tbl
	$(PMC2CV)

# This is a listing of all targets meant to be called by users
help :
	@echo ""
	@echo "Following targets are available for the user:"
	@echo ""
	@echo "Executables:"
	@echo "  all:               'parrot' and the documentation."
	@echo "                     This is the default."
	@echo ""
	@echo "  world:             'all' and 'parrot_utils'."
	@echo "  installable:       same as 'world', but targets for installation"
	@echo ""
	@echo "  parrot_utils:      $(PDUMP), $(DIS), $(PINFO), $(PDB), $(PBCMERGE) and $(PBC_TO_EXE) $(PARROT_CONFIG)"
	@echo " $(PDUMP):"
	@echo "                     Parrot Dumper"
	@echo " $(DIS):"
	@echo "                     Parrot Disassembler"
	@echo " $(PINFO):"
	@echo "                     Information about Parrot Byte Code"
	@echo " $(PDB):"
	@echo "                     Parrot Debugger"
	@echo " $(PBCMERGE):"
	@echo "                     Merge bytecode files"
	@echo " $(PBC_TO_EXE):"
	@echo "                     Generate C, compile, and link bytecode files"
	@echo " $(PARROT_CONFIG):"
	@echo "                     Provide Parrot configuration information"
	@echo ""
	@echo "HLL Executables:"
	@echo " $(PERL6):"
	@echo "                     Generate C, compile, and link the Rakudo compiler"
	@echo ""
	@echo "Installation:"
	@echo "  install:           Install under '$(PREFIX)' on Unix systems"
	@echo ""
	@echo "Documentation:"
	@echo "  help:              Print this help message."
	@echo "  docs:              Generate documentation from POD in the sources."
	@echo "  html:              Generate HTML documentation from POD in the sources."
	@echo "  html-clean:        Remove the HTML documentation."
	@echo ""
	@echo "Testing:"
	@echo "  test:              Run the standard test suite."
	@echo "  coretest:          Run the minimal 'core functionality' suite."
	@echo "  codetest:          Run file metadata and coding standards tests."
	@echo "  fulltest:          Run the full test suite under many runcores."
	@echo "  test<runcore>:     Run the test suite with a specified runcore."
	@echo "                     Valid runcores are b, C, f, g, j, r, S."
	@echo "  src_tests:         Run test in C-file."
	@echo "  run_tests:         Command line and various environments."
	@echo "  perl_tests:        Test the Perl modules in the distribution."
	@echo "  codingstd_tests:   Test pdd07_codingstd."
	@echo "  testexec:          Testing the exec runcore."
	@echo "  benchmark_tests:   Run all benchmarks."
	@echo "  warnings_tests:    Run standard test suite with warnings enabled."
	@echo "  manitest:          Check for new and missing files."
	@echo "  doc_tests:         Check POD syntax of all files containing POD."
	@echo "  buildtools_tests:  Test build tool pmc2c.pl."
	@echo "  manifest_tests:    Test code underlying mk_manifest_and_skip.pl."
	@echo "  examples_tests:    Test the example scripts."
	@echo ""
	@echo "Smoke Testing:"
	@echo "  smolder_test:      Run the test suite and send report to the smolder server"
	@echo "  smoke:             Alias for smolder_test"
	@echo ""
	@echo "Benchmarks:"
	@echo "  mopsbench:         Million operations"
	@echo ""
	@echo "Cleaning:"
	@echo "  clean:             Basic cleaning up."
	@echo "  archclean:         Remove any platform dependent files."
	@echo "  realclean:         Removes also files generated by 'Configure.pl'"
	@echo "  distclean:         Removes also anything built, in theory."
	@echo "  svnclobber:        *Dangerous*: remove everything not in svn."
	@echo "  reconfig:          'clean' and redo configuration."
	@echo ""
	@echo "Dynamic PMCs:"
	@echo "  dynpmc:            Proxy for default target of src/dynpmc/Makefile"
	@echo "  dynpmc-test:       Proxy for target 'test' of src/dynpmc/Makefile"
	@echo "  dynpmc-clean:      Proxy for target 'clean' of src/dynpmc/Makefile"
	@echo ""
	@echo "Dynamic oplibs:"
	@echo "  dynoplibs:         Proxy for default target of src/dynoplibs/Makefile"
	@echo "  dynoplibs-test:    Proxy for target 'test' of src/dynoplibs/Makefile"
	@echo "  dynoplibs-clean:   Proxy for target 'clean' of src/dynoplibs/Makefile"
	@echo ""
	@echo "Language implementations:"
	@echo "  compilers:         Proxy for default target of pge and tge compilers"
	@echo "  languages:         Proxy for default target of languages/Makefile"
	@echo "  languages-test:    Proxy for target 'test' of languages/Makefile"
	@echo "  languages-test-unified:  Proxy for target 'test-unified' of languages/Makefile"
	@echo "  languages-test-separate: Proxy for target 'test-separate' of languages/Makefile"
	@echo "  languages-clean:   Proxy for target 'clean' of languages/Makefile"
	@echo ""
	@echo "Fetch from source repository:"
	@echo "  update:            svn update."
	@echo "  status:            svn status."
	@echo "  patch:             Create a patch for sending to bugs-parrot."
	@echo "  rsync:             Update with rsync."
	@echo ""
	@echo "Development:"
	@echo "  lint:              An alias for sunlint."
	@echo "  bsdlint:           Code checking with bsdlint."
	@echo "  sunlint:           Code checking with Sun Studio's sunlint."
	@echo "  splint:            Code checking with splint."
	@echo "  headerizer:        Recreate header files for C-source files"
	@echo "  apilist:           Show list of PARROT_EXPORT functions"
	@echo "  malloclist:        Show list of PARROT_MALLOC functions"
	@echo "  cover:             Run test suite coverage analysis."
	@echo "  tags-vi:           Create tags for the vi editor."
	@echo "  tags-emacs:        Create tags for the EMACS editor."
	@echo "  perlcritic:        Check Perl code with Perl::Critic."
	@echo ""
	@echo "Release:"
	@echo "  release:           Create a tarball."
	@echo "  rpms:              Create RPMs."
	@echo "  win32-inno-installer:  Create MSWin32 setup."
	@echo ""
	@echo "Examples:"
	@echo "  hello:             'Hello World' as an executable."
	@echo ""

world : all parrot_utils

parrot_utils : $(PDUMP) $(DIS) $(PINFO) $(PDB) $(PBCMERGE) $(PBC_TO_EXE) $(PARROT_CONFIG)

installable: all $(INSTALLABLEPARROT) $(INSTALLABLEPDUMP) $(INSTALLABLEDIS) $(INSTALLABLEPINFO) $(INSTALLABLEPDB) $(INSTALLABLEPBCMERGE) $(INSTALLABLECONFIG)


flags_dummy :
	@echo "Compiling with:"
	@$(PERL) tools/dev/cc_flags.pl $(CUR_DIR)/CFLAGS echo $(CC) $(CFLAGS) -I$(@D) @cc_o_out@ xx$(O) -c xx.c

runtime/parrot/include/parrotlib.pbc: runtime/parrot/library/parrotlib.pir $(PARROT)
	$(PARROT) -o $@ runtime/parrot/library/parrotlib.pir

runtime/parrot/include/config.fpmc : myconfig config_lib.pasm $(MINIPARROT)
	@cygchkdll@
	@echo Invoking Parrot to generate runtime/parrot/include/config.fpmc --cross your fingers
	$(MINIPARROT) config_lib.pasm > $@

$(PARROT) : $(SRC_DIR)/main$(O) $(GEN_HEADERS) $(LIBPARROT) CFLAGS \
    lib/Parrot/OpLib/core.pm $(SRC_DIR)/parrot_config$(O) \
    $(MINIPARROT)
	$(LINK) @ld_out@$@ \
	$(SRC_DIR)/main$(O) $(SRC_DIR)/parrot_config$(O) \
	@rpath_blib@ $(ALL_PARROT_LIBS) $(LINKFLAGS) $(LINK_DYNAMIC)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1

pbc_to_exe.pir : $(PARROT) tools/dev/pbc_to_exe_gen.pl
	$(PERL) tools/dev/pbc_to_exe_gen.pl \
    > pbc_to_exe.pir

$(PBC_TO_EXE) : pbc_to_exe.pir $(PARROT)
	$(PARROT) -o pbc_to_exe.pbc pbc_to_exe.pir
	$(PARROT) pbc_to_exe.pir pbc_to_exe.pbc

$(PARROT_CONFIG) : tools/util/parrot-config.pir $(PARROT) $(PBC_TO_EXE)
	$(PARROT) -o parrot_config.pbc tools/util/parrot-config.pir
	$(PARROT) pbc_to_exe.pbc parrot_config.pbc

# HLL Executable targets
#IF(win32):perl6 : $(PERL6)

$(PERL6) : compilers $(PBC_TO_EXE)
	$(MAKE) languages/perl6 perl6$(EXE)
	$(CP) languages/perl6/perl6$(EXE) $(PERL6)
	$(CHMOD) 0755 $(PERL6)
	$(PERL6) -e"say 'Hello, world.'"

$(MINIPARROT) : $(SRC_DIR)/main$(O) $(GEN_HEADERS) $(LIBPARROT) \
    lib/Parrot/OpLib/core.pm $(SRC_DIR)/null_config$(O)
	$(LINK) @ld_out@$@ $(SRC_DIR)/main$(O) $(SRC_DIR)/null_config$(O) \
	@rpath_blib@ $(ALL_PARROT_LIBS) $(LINKFLAGS)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1

$(INSTALLABLEPARROT) : $(SRC_DIR)/main$(O) $(GEN_HEADERS) $(LIBPARROT) \
    lib/Parrot/OpLib/core.pm $(SRC_DIR)/install_config$(O) \
    $(PARROT)
	$(LINK) @ld_out@$@ \
    $(SRC_DIR)/main$(O) \
    @rpath_lib@ $(ALL_PARROT_LIBS) $(LINKFLAGS) $(SRC_DIR)/install_config$(O)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1

$(INC_DIR)/parrot.h : $(INC_DIR)/pbcversion.h $(INC_DIR)/vtable.h

$(INC_DIR)/extend.h : $(INC_DIR)/extend_vtable.h

$(INC_DIR)/pbcversion.h :
	$(PERL) $(BUILD_TOOLS_DIR)/pbcversion_h.pl > $(INC_DIR)/pbcversion.h

$(SRC_DIR)/parrot_config.c :  runtime/parrot/include/config.fpmc \
    $(BUILD_TOOLS_DIR)/parrot_config_c.pl
	$(PERL) $(BUILD_TOOLS_DIR)/parrot_config_c.pl > \
    $(SRC_DIR)/parrot_config.c

$(SRC_DIR)/install_config.c :  install_config.fpmc \
    $(BUILD_TOOLS_DIR)/parrot_config_c.pl
	$(PERL) $(BUILD_TOOLS_DIR)/parrot_config_c.pl --install > \
    $(SRC_DIR)/install_config.c

$(SRC_DIR)/null_config.c : myconfig $(BUILD_TOOLS_DIR)/parrot_config_c.pl
	$(PERL) $(BUILD_TOOLS_DIR)/parrot_config_c.pl --mini > \
    $(SRC_DIR)/null_config.c

install_config.fpmc : myconfig config_lib.pasm $(PARROT)
	@echo "Invoking Parrot to generate install_config.fpmc"
	$(PARROT) config_lib.pasm --install > $@

$(SRC_DIR)/parrot_config$(O) : $(SRC_DIR)/parrot_config.c

$(SRC_DIR)/install_config$(O) : $(SRC_DIR)/install_config.c

$(SRC_DIR)/null_config$(O) : $(SRC_DIR)/null_config.c

$(SRC_DIR)/oo$(O) : $(SRC_DIR)/pmc/class.c $(INC_DIR)/pbcversion.h

$(SRC_DIR)/scheduler$(O) : $(SRC_DIR)/scheduler.str   \
                           $(SRC_DIR)/pmc/scheduler.c \
                           $(SRC_DIR)/pmc/task.c      \
                           $(SRC_DIR)/pmc/timer.c     \
                           $(INC_DIR)/pbcversion.h

lib_deps_object : $(O_FILES)
	$(PERL) tools/dev/lib_deps.pl object $(O_FILES)

lib_deps_source : $(GENERAL_H_FILES)
	$(PERL) tools/dev/lib_deps.pl source all_source

lib_deps : lib_deps_object lib_deps_source

check_source : $(GENERAL_H_FILES)
	$(PERL) tools/dev/check_source_standards.pl all_source

# XXX changes don't always propagate into libparrot
# e.g. when I change debug:fataly to xfataly, nm still shows the old symbol
# and parrot builds fine (except for the unproto warning
# so always delete the lib -leo

PARROT_LIBS: \
#IF(has_static_linking):  $(LIBPARROT_STATIC) \
#IF(has_dynamic_linking): $(LIBPARROT_SHARED)

$(LIBPARROT_STATIC) : $(O_FILES)
	$(MKPATH) @blib_dir@
	$(AR_CR) @ar_out@$@ @ar_extra@ $(O_FILES)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2
	$(RANLIB) $@

$(LIBPARROT_SHARED) : $(O_FILES)
	$(MKPATH) @blib_dir@
	$(LD) $(LD_SHARE_FLAGS) $(LDFLAGS) @ld_out@$@ @libparrot_soname@ \
#IF(cygwin):		-Wl,--out-implib=libparrot.dll.a \
#IF(win32 and cc==gcc):		-Wl,--out-implib=libparrot.lib \
		$(O_FILES) $(C_LIBS) $(ICU_SHARED)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;2
#IF(libparrot_shared_alias):	( cd @blib_dir@ ; ln -sf @libparrot_shared@ @libparrot_shared_alias@ )


$(INSTALLABLECONFIG) : $(SRC_DIR)/install_config$(O) $(PARROT_CONFIG) $(PBC_TO_EXE)
	$(PARROT) -o parrot_config.pbc tools/util/parrot-config.pir
	$(PBC_TO_EXE) parrot_config.pbc --install

#
# Parrot Debugger
#

$(SRC_DIR)/parrot_debugger$(O) : $(GENERAL_H_FILES)

$(PDB) : $(SRC_DIR)/parrot_debugger$(O) $(LIBPARROT)
	$(LINK) @ld_out@$@ \
    $(SRC_DIR)/parrot_debugger$(O) \
    $(SRC_DIR)/parrot_config$(O) \
    @rpath_blib@ $(ALL_PARROT_LIBS) $(LINKFLAGS)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1

$(INSTALLABLEPDB) : $(SRC_DIR)/parrot_debugger$(O) $(LIBPARROT) $(SRC_DIR)/parrot_config$(O)
	$(LINK) @ld_out@$@ \
    $(SRC_DIR)/parrot_debugger$(O) \
    $(SRC_DIR)/parrot_config$(O) \
    @rpath_lib@ $(ALL_PARROT_LIBS) $(LINKFLAGS)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1

#
# Parrot Disassembler
#

$(SRC_DIR)/pbc_disassemble$(O) : $(GENERAL_H_FILES)

$(DIS) : $(SRC_DIR)/pbc_disassemble$(O) $(LIBPARROT)
	$(LINK) @ld_out@$@ \
    $(SRC_DIR)/pbc_disassemble$(O) \
    @rpath_blib@ $(ALL_PARROT_LIBS) $(LINKFLAGS)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1

$(INSTALLABLEDIS) : $(SRC_DIR)/pbc_disassemble$(O) $(LIBPARROT)
	$(LINK) @ld_out@$@ \
    $(SRC_DIR)/pbc_disassemble$(O) \
    @rpath_lib@ $(ALL_PARROT_LIBS) $(LINKFLAGS)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1

#
# Parrot Dump
#

$(PDUMP) : $(SRC_DIR)/pdump$(O) $(SRC_DIR)/packdump$(O) $(LIBPARROT)
	$(LINK) @ld_out@$@ \
    $(SRC_DIR)/pdump$(O) \
    $(SRC_DIR)/packdump$(O) @rpath_blib@ $(ALL_PARROT_LIBS) $(LINKFLAGS)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1

$(SRC_DIR)/pdump$(O) : $(GEN_HEADERS)

$(INSTALLABLEPDUMP) : $(SRC_DIR)/pdump$(O) $(SRC_DIR)/packdump$(O) $(LIBPARROT)
	$(LINK) @ld_out@$@ \
    $(SRC_DIR)/pdump$(O) \
    $(SRC_DIR)/packdump$(O) \
    @rpath_lib@ $(ALL_PARROT_LIBS) $(LINKFLAGS)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1


# pbc_info
$(PINFO) : $(SRC_DIR)/pbc_info$(O) $(LIBPARROT)
	$(LINK) @ld_out@$@ \
    $(SRC_DIR)/pbc_info$(O) \
    @rpath_blib@ $(ALL_PARROT_LIBS) $(LINKFLAGS)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1

$(SRC_DIR)/pbc_info$(O) : $(GEN_HEADERS)

$(INSTALLABLEPINFO) : $(SRC_DIR)/pbc_info$(O) $(LIBPARROT)
	$(LINK) @ld_out@$@ \
    $(SRC_DIR)/pbc_info$(O) \
    @rpath_lib@ $(ALL_PARROT_LIBS) $(LINKFLAGS)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1

#
# Parrot Bytecode File Merger
#

$(PBCMERGE) : $(SRC_DIR)/pbc_merge$(O) $(LIBPARROT) $(SRC_DIR)/parrot_config$(O)
	$(LINK) @ld_out@$@ \
    $(SRC_DIR)/pbc_merge$(O) \
    $(SRC_DIR)/parrot_config$(O) \
    @rpath_blib@ $(ALL_PARROT_LIBS) $(LINK_DYNAMIC) $(LINKFLAGS)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1

$(INSTALLABLEPBCMERGE) : $(SRC_DIR)/pbc_merge$(O) $(LIBPARROT) $(INSTALLABLECONFIG)
	$(LINK) @ld_out@$@ \
    $(SRC_DIR)/pbc_merge$(O) \
    $(SRC_DIR)/install_config$(O) \
    @rpath_lib@ $(ALL_PARROT_LIBS) $(LINKFLAGS)
#IF(win32):	if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1


###############################################################################
#
# Other Dependencies and Build Rules:
#
###############################################################################

$(IMCC_DIR)/main$(O) : $(IMCC_DIR)/main.c $(GENERAL_H_FILES) $(IMCC_H_FILES)

$(INC_DIR)/oplib/ops.h lib/Parrot/OpLib/core.pm : $(OPS_FILES) $(BUILD_TOOLS_DIR)/ops2pm.pl \
    lib/Parrot/OpsFile.pm lib/Parrot/Op.pm $(OPS_DIR)/ops.num $(OPS_DIR)/ops.skip
	$(PERL) $(BUILD_TOOLS_DIR)/ops2pm.pl $(OPS_FILES)

###############################################################################
#
# Examples (Assembly):
#
###############################################################################

examples-clean:
	$(RM_F) \
    examples/mops/mops$(O) \
    examples/mops/mops$(EXE) \
    examples/pasm/hello.pbc \
    examples/pasm/hello$(O) \
    examples/pasm/hello$(EXE)

# hello
hello: test_prep examples/pasm/hello$(EXE)
	$(CUR_DIR)/examples/pasm/hello$(EXE) "from your friendly makefile"

examples/pasm/hello.pbc: examples/pasm/hello.pasm
	$(PARROT) -o examples/pasm/hello.pbc examples/pasm/hello.pasm

examples/pasm/hello$(O): examples/pasm/hello.pbc
	$(PARROT) -o examples/pasm/hello$(O) examples/pasm/hello.pbc

examples/pasm/hello$(EXE): examples/pasm/hello$(O)
	$(MAKE) . EXEC=examples/pasm/hello exec



###############################################################################
#
# Dependencies:
#
###############################################################################

$(SRC_DIR)/global_setup$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/global_setup.str

$(SRC_DIR)/global$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/global.str

$(SRC_DIR)/pmc$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/pmc_freeze$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/pmc_freeze.str

$(SRC_DIR)/hash$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/intlist$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/list$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/library$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/jit$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/jit_emit.h

$(SRC_DIR)/jit_debug$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/debug.str

$(SRC_DIR)/jit_debug_xcoff$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/jit_cpu$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/jit_emit.h

$(SRC_DIR)/exec$(O) : $(GENERAL_H_FILES) @TEMP_exec_h@ $(SRC_DIR)/jit_emit.h

$(SRC_DIR)/exec_dep$(O) : $(GENERAL_H_FILES) @TEMP_exec_h@ $(SRC_DIR)/jit_emit.h

$(SRC_DIR)/exec_cpu$(O) : $(GENERAL_H_FILES) @TEMP_exec_h@ $(SRC_DIR)/jit_emit.h

$(SRC_DIR)/jit_defs$(O) : $(GENERAL_H_FILES) @TEMP_exec_h@ $(SRC_DIR)/jit_emit.h

$(INC_DIR)/extend_vtable.h $(SRC_DIR)/extend_vtable.c $(SRC_DIR)/vtable.h : src/vtable.tbl $(BUILD_TOOLS_DIR)/vtable_extend.pl lib/Parrot/Vtable.pm
	$(PERL) $(BUILD_TOOLS_DIR)/vtable_extend.pl

$(SRC_DIR)/exec_start$(O) : $(GENERAL_H_FILES) @TEMP_exec_h@

$(SRC_DIR)/exec_save$(O) : $(GENERAL_H_FILES) @TEMP_exec_h@

$(SRC_DIR)/key$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/key.str

$(SRC_DIR)/gc/mark_sweep$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/gc/api$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/gc/generational_ms$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/gc/incremental_ms$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/gc/pools$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/gc/resources$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/gc/res_lea$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/hll$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/hll.str

$(SRC_DIR)/platform$(O) : $(GENERAL_H_FILES)

#IF(platform_asm):$(SRC_DIR)/platform_asm$(O) : $(GENERAL_H_FILES)
#IF(platform_asm):
$(SRC_DIR)/core_pmcs$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/trace$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/debug$(O) : $(GENERAL_H_FILES) $(INC_DIR)/debugger.h \
    $(SRC_DIR)/debug.str

$(SRC_DIR)/sub$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/sub.str

$(SRC_DIR)/string$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/string_private_cstring.h

$(SRC_DIR)/string_primitives$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/longopt$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/dynext$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/dynext.str

$(SRC_DIR)/exceptions$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/exceptions.str

$(SRC_DIR)/events$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/thread$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/extend$(O) : $(GENERAL_H_FILES) $(INC_DIR)/extend.h

$(SRC_DIR)/interpreter$(O) : $(SRC_DIR)/interpreter.c $(GENERAL_H_FILES)

$(SRC_DIR)/inter_call$(O) : $(SRC_DIR)/inter_call.c $(GENERAL_H_FILES) \
    $(SRC_DIR)/inter_call.str

$(SRC_DIR)/inter_cb$(O) : $(SRC_DIR)/inter_cb.c $(GENERAL_H_FILES) \
    $(SRC_DIR)/inter_cb.str

$(SRC_DIR)/inter_misc$(O) : $(SRC_DIR)/inter_misc.c $(GENERAL_H_FILES) \
    $(SRC_DIR)/inter_misc.str

$(SRC_DIR)/inter_create$(O) : $(SRC_DIR)/inter_create.c $(GENERAL_H_FILES) \
    $(SRC_DIR)/inter_create.str

$(SRC_DIR)/inter_run$(O) : $(SRC_DIR)/inter_run.c $(GENERAL_H_FILES)

$(IO_DIR)/api$(O) : $(GENERAL_H_FILES) $(IO_DIR)/io_private.h $(IO_DIR)/api.str

$(IO_DIR)/buffer$(O) : $(GENERAL_H_FILES) $(IO_DIR)/io_private.h

$(IO_DIR)/portable$(O) : $(GENERAL_H_FILES) $(IO_DIR)/io_private.h

$(IO_DIR)/unix$(O) : $(GENERAL_H_FILES) $(IO_DIR)/io_private.h

$(IO_DIR)/utf8$(O) : $(GENERAL_H_FILES) $(IO_DIR)/io_private.h

$(IO_DIR)/win32$(O) : $(GENERAL_H_FILES) $(IO_DIR)/io_private.h

$(SRC_DIR)/gc/memory$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/main$(O) : $(SRC_DIR)/main.c $(GENERAL_H_FILES)

$(SRC_DIR)/pic$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/pic_jit$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/multidispatch$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/multidispatch.str

$(SRC_DIR)/packfile$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/packfile.str

$(PF_DIR)/pf_items$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/packout$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/parrot$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/gc/register$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/runops_cores$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/stacks$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/tsq$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/embed$(O) : $(GENERAL_H_FILES) $(INC_DIR)/debugger.h

$(SRC_DIR)/dataypes$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/dataypes.c

$(SRC_DIR)/exit$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/exit.c

$(SRC_DIR)/nci$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/nci.c $(SRC_DIR)/nci.str

$(SRC_DIR)/vtables$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/vtables.c

$(SRC_DIR)/cpu_dep$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/nci.c : $(SRC_DIR)/call_list.txt $(BUILD_TOOLS_DIR)/nativecall.pl
	$(PERL) $(BUILD_TOOLS_DIR)/nativecall.pl $(SRC_DIR)/call_list.txt

$(SRC_DIR)/warnings$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/misc$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/utils$(O) : $(GENERAL_H_FILES)

$(SRC_DIR)/spf_render$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/spf_render.str

$(SRC_DIR)/spf_vtable$(O) : $(GENERAL_H_FILES) $(SRC_DIR)/spf_vtable.str

$(SRC_DIR)/encoding$(O) : $(SRC_DIR)/encoding.c $(GENERAL_H_FILES)

$(SRC_DIR)/charset$(O) : $(SRC_DIR)/charset.c $(GENERAL_H_FILES)

$(SRC_DIR)/pbc_merge$(O) : $(SRC_DIR)/pbc_merge.c $(GENERAL_H_FILES)

$(IO_DIR)/filehandle$(O) : $(SRC_DIR)/pmc/pmc_filehandle.h $(SRC_DIR)/io/io_private.h

$(OPS_DIR)/core_ops$(O) : $(GENERAL_H_FILES) $(OPS_DIR)/core_ops.c

# core_ops depends upon config.h so that it gets updated along with
# updates to config.h's version numbers

# .h files are built along with .c
$(INC_DIR)/oplib/core_ops.h: $(OPS_DIR)/core_ops.c

$(OPS_DIR)/core_ops.c : $(OPS_FILES) $(BUILD_TOOLS_DIR)/ops2c.pl lib/Parrot/OpsFile.pm lib/Parrot/Op.pm $(INC_DIR)/config.h lib/Parrot/OpLib/core.pm lib/Parrot/OpTrans/C.pm
	$(PERL) $(BUILD_TOOLS_DIR)/ops2c.pl C --core

$(OPS_DIR)/core_ops_switch$(O) : $(GENERAL_H_FILES) $(OPS_DIR)/core_ops_switch.c

$(INC_DIR)/oplib/core_ops_switch.h : $(OPS_DIR)/core_ops_switch.c

$(OPS_DIR)/core_ops_switch.c : $(OPS_FILES) $(BUILD_TOOLS_DIR)/ops2c.pl lib/Parrot/OpsFile.pm lib/Parrot/Op.pm $(INC_DIR)/config.h lib/Parrot/OpLib/core.pm lib/Parrot/OpTrans/CSwitch.pm lib/Parrot/OpTrans/CPrederef.pm
	$(PERL) $(BUILD_TOOLS_DIR)/ops2c.pl CSwitch --core

@TEMP_cg_c@

@TEMP_gc_c@

@TEMP_pmc_build@

@TEMP_charset_build@

@TEMP_encoding_build@

# $(CONFIGURE_GENERATED_FILES) : Configure.pl
#	$(PERL) Configure.pl

$(INC_DIR)/vtable.h : src/vtable.tbl $(BUILD_TOOLS_DIR)/vtable_h.pl lib/Parrot/Vtable.pm
	$(PERL) $(BUILD_TOOLS_DIR)/vtable_h.pl

$(SRC_DIR)/jit_emit.h : $(SRC_DIR)/jit/@jitcpuarch@/jit_emit.h
	$(CP) $(SRC_DIR)/jit/@jitcpuarch@/jit_emit.h $(SRC_DIR)/jit_emit.h
$(SRC_DIR)/exec_dep.h : $(SRC_DIR)/jit/@jitcpuarch@/exec_dep.h
	$(CP) $(SRC_DIR)/jit/@jitcpuarch@/exec_dep.h $(SRC_DIR)/exec_dep.h
$(SRC_DIR)/jit_cpu.c : lib/Parrot/OpLib/core.pm $(SRC_DIR)/jit_emit.h \
    $(SRC_DIR)/jit/@jitcpuarch@/core.jit $(JIT_BUILD_TOOL)
	$(PERL) $(JIT_BUILD_TOOL) @jitcpuarch@ $(SRC_DIR)/jit_cpu.c
$(SRC_DIR)/jit_defs.c : $(SRC_DIR)/jit/@jitcpuarch@/jit_emit.h \
	$(SRC_DIR)/jit/@jitcpuarch@/jit_defs.c
	$(CP) $(SRC_DIR)/jit/@jitcpuarch@/jit_defs.c $(SRC_DIR)/jit_defs.c
$(SRC_DIR)/exec_cpu.c : lib/Parrot/OpLib/core.pm $(SRC_DIR)/jit_emit.h \
    $(SRC_DIR)/jit/@jitcpuarch@/core.jit @TEMP_exec_h@ $(SRC_DIR)/exec_dep.h $(JIT_BUILD_TOOL)
	$(PERL) $(JIT_BUILD_TOOL) @jitcpuarch@ $(SRC_DIR)/exec_cpu.c
@TEMP_exec_dep@

# imcc file dependencies
#
# The .flag files are needed because we keep some derived files in SVN,
# which does not keep accurate timestamps on the files, relative to each other.
# Note that YACC or LEX may be null commands, so we must `touch` all the
# target files, instead of just the .flag files.

$(IMCC_DIR)/imcc.y.flag $(IMCC_DIR)/imcparser.c $(IMCC_DIR)/imcparser.h : $(IMCC_DIR)/imcc.y
	$(YACC) $(IMCC_DIR)/imcc.y -d -o $(IMCC_DIR)/imcparser.c
	$(PERL) $(BUILD_TOOLS_DIR)/fixup_gen_file.pl -noheaderizer $(IMCC_DIR)/imcparser.c $(IMCC_DIR)/imcc.y
	$(PERL) $(BUILD_TOOLS_DIR)/fixup_gen_file.pl -noheaderizer $(IMCC_DIR)/imcparser.h $(IMCC_DIR)/imcc.y
	$(TOUCH) $(IMCC_DIR)/imcc.y.flag $(IMCC_DIR)/imcparser.c $(IMCC_DIR)/imcparser.h

$(IMCC_DIR)/imcc.l.flag $(IMCC_DIR)/imclexer.c : $(IMCC_DIR)/imcc.l
	$(LEX) -o$(IMCC_DIR)/imclexer.c $(IMCC_DIR)/imcc.l
	$(TOUCH) $(IMCC_DIR)/imcc.l.flag $(IMCC_DIR)/imclexer.c

$(IMCC_O_FILES) : $(IMCC_H_FILES) $(ALL_H_FILES)

###############################################################################
#
# Documentation targets:
#
###############################################################################

#IF(has_perldoc):docs : docs.dummy
#ELSE:docs : docs.stub

#IF(has_perldoc):html : html.dummy
#ELSE:html : html.stub

html.stub:
	@echo "Perldoc is required, but not detected."

docs.stub:
	@echo "Perldoc is required, but not detected."

docs.dummy :
	$(MAKE) docs

docs-clean :
	$(MAKE) docs clean

html.dummy :
	$(MAKE) docs html

html-clean :
	$(MAKE) docs html-clean

###############################################################################
#
# dynamic PMC targets:
#
###############################################################################

dynpmc : dynpmc.dummy

# XXX this dependancy is too broad, and should be narrowed down
dynpmc.dummy : $(PARROT)
	$(MAKE) src/dynpmc

dynpmc-test :
	$(MAKE) src/dynpmc test

dynpmc-clean :
	$(MAKE) src/dynpmc clean

###############################################################################
#
# dynamic oplibs targets:
#
###############################################################################

dynoplibs : dynoplibs.dummy

# XXX this dependancy is too broad, and should be narrowed down
dynoplibs.dummy : $(PARROT)
	$(MAKE) src/dynoplibs

dynoplibs-test :
	$(MAKE) src/dynoplibs test

dynoplibs-clean :
	$(MAKE) src/dynoplibs clean

###############################################################################
#
# language implementation targets:
#
###############################################################################

compilers : compilers.dummy

compilers.dummy : $(PARROT) $(GEN_LIBRARY)
	$(MAKE) compilers/pct
	$(MAKE) compilers/pge
	$(MAKE) compilers/tge
	$(MAKE) compilers/nqp
	$(MAKE) compilers/json

languages : languages.dummy

languages.dummy :
	$(MAKE) languages

languages-test :
	$(MAKE) languages test

languages-test-unified :
	$(MAKE) languages test-unified

languages-test-separate :
	$(MAKE) languages test-separate

languages-clean :
	$(MAKE) languages clean

languages-realclean :
	$(MAKE) languages realclean

###############################################################################
#
# compiler implementation targets:
#
###############################################################################

compilers-clean :
	$(MAKE) compilers/pct clean
	$(MAKE) compilers/pge clean
	$(MAKE) compilers/tge clean
	$(MAKE) compilers/nqp clean
	$(MAKE) compilers/json clean
	$(MAKE) compilers/pirc clean

###############################################################################
#
# editors targets:
#
###############################################################################

editor-clean :
	$(MAKE) editor clean

###############################################################################
#
# Testing Targets:
#
###############################################################################

# The --running-make-test argument is currently used by long-running tests
# to disable GC_DEBUG.
EXTRA_TEST_ARGS    = --gc-debug --running-make-test
DISTRO_TEST_FILES = \
    t/distro/*.t
BENCHMARK_TEST_FILES = \
    t/benchmark/*.t
DOC_TEST_FILES = \
    t/doc/*.t
PERL_TEST_FILES = \
    t/perl/*.t
CODINGSTD_TEST_FILES = \
    t/codingstd/*.t
RUN_TEST_FILES = \
    t/run/*.t
RUNCORE_TEST_FILES = \
    --runcore-tests
SRC_TEST_FILES = \
    t/src/*.t
TOOLS_TEST_FILES = \
    t/tools/*.t
PMC2CUTILS_DIR = t/tools/pmc2cutils
OPS2PMUTILS_DIR = t/tools/ops2pm
OPS2CUTILS_DIR = t/tools/ops2cutils
REVISIONUTILS_DIR = t/tools/revision
HARNESS_DIR = t/pharness
BUILDTOOLS_TEST_FILES = \
    $(PMC2CUTILS_DIR)/*.t \
    $(OPS2PMUTILS_DIR)/*.t \
    $(OPS2CUTILS_DIR)/*.t \
    $(REVISIONUTILS_DIR)/*.t \
    $(HARNESS_DIR)/*.t
MANIFEST_DIR = t/manifest
MANIFEST_TEST_FILES = \
    $(MANIFEST_DIR)/01-basic.t \
    $(MANIFEST_DIR)/02-regenerate_file.t \
    $(MANIFEST_DIR)/03-regenerate_skip.t \
    $(MANIFEST_DIR)/04-alt_file.t \
    $(MANIFEST_DIR)/05-alt_skip.t
EXAMPLES_TEST_FILES = \
    t/examples/*.t
CONFIGURE_TEST_FILES = \
    t/configure/*.t \
    t/steps/*.t

# Common prep for all test targets.
# We probably need a complete build before running the tests.
test_prep : all

# Run test cases with a single call of t/harness. Users have to look at only
# one report. The default set of tests to run is contained in t/harness,
# make any edits there.
# Normal test package
test : test_prep
	$(PERL) t/harness $(EXTRA_TEST_ARGS)

# run the test suite, create a TAP archive and send it off to smolder
smolder_test : test_prep
	$(PERL) t/harness $(EXTRA_TEST_ARGS) --archive --send-to-smolder

smoke : smolder_test

# "core tests" -- test basic functionality but not ancillaries
coretest : test_prep
	$(PERL) t/harness $(EXTRA_TEST_ARGS) --core-tests

# automake compatibility
check : test

# Test various run cores and other stuff
# 'testC', 'testg' and 'testj' are tested only
# when the needed runcores are available
fulltest :
	-@make@ testb \
#IF(cg_flag):	testC \
	testf \
#IF(cg_flag):	testg \
#IF(cg_flag):	testj \
	testr \
	testS \
	src_tests \
	run_tests \
	perl_tests \
	codetest \
	benchmark_tests \
	doc_tests \
	manifest_tests \
	examples_tests \
	distro_tests

# bounds checking, slow core
testb : test_prep
	$(PERL) t/harness $(EXTRA_TEST_ARGS) -b $(RUNCORE_TEST_FILES)

# CGP core
testC : test_prep
	$(PERL) t/harness $(EXTRA_TEST_ARGS) -C $(RUNCORE_TEST_FILES)

# fast core
testf : test_prep
	$(PERL) t/harness $(EXTRA_TEST_ARGS) -f $(RUNCORE_TEST_FILES)

# Computed goto
testg : test_prep
	$(PERL) t/harness $(EXTRA_TEST_ARGS) -g $(RUNCORE_TEST_FILES)

# JIT core
testj : test_prep
	$(PERL) t/harness $(EXTRA_TEST_ARGS) -j $(RUNCORE_TEST_FILES)

# normal core, write and run Parrot Byte Code
testr : test_prep
	$(PERL) t/harness $(EXTRA_TEST_ARGS) -r $(RUNCORE_TEST_FILES)

# switched core
testS : test_prep
	$(PERL) t/harness $(EXTRA_TEST_ARGS) -S $(RUNCORE_TEST_FILES)

# Computed goto jitted core
testCj : test_prep
	$(PERL) t/harness $(EXTRA_TEST_ARGS) -Cj $(RUNCORE_TEST_FILES)

# switched jitted core
testSj : test_prep
	$(PERL) t/harness $(EXTRA_TEST_ARGS) -Sj $(RUNCORE_TEST_FILES)

# test the EXEC stuff
testexec: test_prep
	$(PERL) t/harness $(EXTRA_TEST_ARGS) --run-exec $(RUNCORE_TEST_FILES)

# Test that need to be compiled by the C-compiler
src_tests :
	$(PERL) t/harness $(SRC_TEST_FILES)

# Command line and various environments
run_tests :
	$(PERL) t/harness $(RUN_TEST_FILES)

# Test the Perl5 Modules in the Parrot distribution
perl_tests :
	$(PERL) t/harness $(PERL_TEST_FILES)

codetest :
	$(PERL) t/harness $(EXTRA_TEST_ARGS) --code-tests

# Test pdd07_codingstd
codingstd_tests :
	$(PERL) t/harness $(CODINGSTD_TEST_FILES)

# Run standard test suite with warnings enabled.
warnings_tests:
	$(PERL) t/harness $(EXTRA_TEST_ARGS) -w $(RUNCORE_TEST_FILES)

buildtools_tests :
	$(PERL) t/harness $(BUILDTOOLS_TEST_FILES)

manifest_tests :
	$(PERL) t/harness $(MANIFEST_TEST_FILES)

examples_tests :
	$(PERL) t/harness $(EXAMPLES_TEST_FILES)

# benchmark tests
benchmark_tests : test_prep
	$(PERL) t/harness $(EXTRA_TEST_ARGS) $(BENCHMARK_TEST_FILES)

# doc tests
doc_tests :
	$(PERL) t/harness $(EXTRA_TEST_ARGS) $(DOC_TEST_FILES)

# Running a benchmark
mopsbench : test_prep
	$(PARROT) examples/benchmarks/mops_intval.pasm

# distro tests
distro_tests : test_prep
	$(PERL) t/harness $(DISTRO_TEST_FILES)

# configure tests
configure_tests :
	$(PERL) t/harness $(CONFIGURE_TEST_FILES)

###############################################################################
#
# Cleaning Targets:
#
###############################################################################

clean : \
    test-clean \
    prog-clean \
    dynext-clean \
    languages-clean \
#IF(has_perldoc):    docs-clean \
#IF(has_perldoc):    html-clean \
    dynpmc-clean \
    dynoplibs-clean \
    examples-clean \
    imcc-clean \
    compilers-clean \
#UNLESS(win32):    cover-clean \
    editor-clean
	@TEMP_cg_r@
	$(RM_F) chartypes "*.s" "*~"
	$(RM_F) $(FLUID_FILES_1)
	$(RM_F) $(FLUID_FILES_2)
	$(RM_RF) lib/Parrot/OpLib

prog-clean :
	$(RM_F) \
    $(O_FILES) \
    $(PARROT) \
    $(MINIPARROT) \
    $(LIBPARROT) \
    $(INSTALLABLEPARROT) \
    $(INSTALLABLEDIS) \
    $(INSTALLABLEPDUMP) \
    $(INSTALLABLEPINFO) \
    $(INSTALLABLEPBCMERGE) \
    $(INSTALLABLEPDB) \
    pbc_to_exe.pir pbc_to_exe.pbc pbc_to_exe.c pbc_to_exe$(O) pbc_to_exe$(EXE) \
    $(PERL6) \
    $(IMCC_DIR)/main$(O) \
    $(PDUMP) $(SRC_DIR)/pdump$(O) $(SRC_DIR)/packdump$(O) \
    $(SRC_DIR)/pbc_info$(O) $(PINFO) \
    $(PDB) $(SRC_DIR)/parrot_debugger$(O) \
    $(PBCMERGE) $(SRC_DIR)/pbc_merge$(O) \
    $(DIS) $(SRC_DIR)/pbc_disassemble$(O) \
    $(SRC_DIR)/main$(O) \
    $(SRC_DIR)/null_config$(O) \
    $(SRC_DIR)/parrot_config$(O) \
    $(SRC_DIR)/install_config$(O) \
    $(SRC_DIR)/exec_start$(O) \
    $(SRC_DIR)/nci_test$(O) \
    $(LIBNCI_TEST_SO) \
    $(SRC_DIR)/glut_callbacks$(O) \
    $(LIBGLUTCB_SO) \
    install_config.fpmc
	$(PERL) $(BUILD_TOOLS_DIR)/c2str.pl --init
	$(RM_F) \
    $(SRC_DIR)/string_private_cstring.h \
    "$(SRC_DIR)/*.str" "$(SRC_DIR)/io/*.str" "$(SRC_DIR)/pmc/*.str" \
    "src/pmc/*.c" "src/pmc/pmc_*.h" "src/pmc/*.dump" \
    vtable.dump "*.def" "*.lib" "*.exp"

archclean: dynoplibs-clean dynpmc-clean dynext-clean
	$(RM_F) \
    $(O_FILES) \
    $(GEN_CONFIGS) \
    $(GEN_MAKEFILES) \
    $(PARROT) \
    $(MINIPARROT) \
    $(INSTALLABLEPARROT) \
    $(INSTALLABLEDIS) \
    $(INSTALLABLEPDUMP) \
    $(INSTALLABLEPINFO) \
    $(INSTALLABLEPBCMERGE) \
    $(INSTALLABLEPDB) \
    $(INSTALLABLECONFIG) \
    $(IMCC_DIR)/main$(O) \
    $(PDUMP) $(SRC_DIR)/pdump$(O) $(SRC_DIR)/packdump$(O) \
    $(SRC_DIR)/pbc_info$(O) $(PINFO) \
    $(PDB) $(SRC_DIR)/parrot_debugger$(O) \
    $(PBCMERGE) $(SRC_DIR)/pbc_merge$(O) \
    $(DIS) $(SRC_DIR)/pbc_disassemble$(O) \
    $(SRC_DIR)/null_config$(O) \
    $(SRC_DIR)/parrot_config$(O) \
    $(SRC_DIR)/install_config$(O) \
    $(SRC_DIR)/asmfun.s \
    $(SRC_DIR)/jit_emit.h \
    $(SRC_DIR)/jit_cpu.c \
    $(SRC_DIR)/exec_cpu.c \
    $(SRC_DIR)/jit_defs.c \
    $(SRC_DIR)/exec_start$(O) \
    install_config.fpmc \
    $(SRC_DIR)/nci_test$(O) \
    $(LIBNCI_TEST_SO) \
    $(SRC_DIR)/glut_callbacks$(O) \
    $(LIBGLUTCB_SO) \
    $(LIBPARROT_STATIC) \
    $(LIBPARROT_SHARED)

dynext-clean :
# shared libs (LOAD_EXT, SHARE_EXT)
# win32 import library (.lib - shared object is deleted by LIBNCI_TEST_SO above)
# win32 program data base - contains debugging info (.pdb)
# win32 incremental link status files (.ilk)
# win32 exported functions and data items (.exp)
# win32 export definition files (.def)
	$(RM_F) \
    "$(DYNEXT_DIR)/*$(LOAD_EXT)" \
    "$(DYNEXT_DIR)/*$(SHARE_EXT)" \
    "$(DYNEXT_DIR)/*.lib" \
    "*.pdb" "$(DYNEXT_DIR)/*.pdb" \
    "*.ilk" "$(DYNEXT_DIR)/*.ilk" \
    "*.exp" "$(DYNEXT_DIR)/*.exp" \
    "*.def" "$(DYNEXT_DIR)/*.def" \
    "*.manifest" "$(DYNEXT_DIR)/*.manifest"

# Remove files generated by the test suite
# XXX Is there a danger of too long command lines in the $(RM_F) commands,
# or is there an automatic xargs?
test-clean :
	$(RM_F) \
    "t/compilers/*/*.out" \
    "t/compilers/*/*.pasm" \
    "t/compilers/*/*.pbc" \
    "t/compilers/*/*_pbcexe*" \
    "t/compilers/*/*.pir" \
    "t/compilers/*/*.stabs.s"
	$(RM_F) \
    "t/compilers/*/*/*.out" \
    "t/compilers/*/*/*.pasm" \
    "t/compilers/*/*/*.pbc" \
    "t/compilers/*/*/*_pbcexe*" \
    "t/compilers/*/*/*.pir" \
    "t/compilers/*/*/*.stabs.s"
	$(RM_F) \
    "t/*/*$(O)" \
    "t/*/*.out" \
    "t/*/*.pasm" \
    "t/*/*_pbcexe*" \
    "t/*/*.pir" \
    "t/*/*.stabs.s"
	$(RM_F) \
    "t/library/*.pbc" \
    "t/dynoplibs/*.pbc" \
    "t/op/*.pbc" \
    "t/oo/*.pbc" \
    "t/pmc/*.pbc" \
    "t/stress/*.pbc" \
    "t/tools/*.pbc"
	$(RM_F) \
    "t/src/*.c" \
    "t/src/*.pdb" \
    "t/src/*.manifest"
	$(RM_F) \
     "t/tools/pmc2c.t_*" \
     "t/tools/pmc2c.pmc_t_*" \
     "t/tools/parrot_debugger.t.*"
	$(RM_F) \
     "test$(EXE)" \
     "test.*"
	$(RM_F) \
     "parrot_test_run.tar.gz"

imcc-clean:
	$(RM_F) \
    $(IMCC_DIR)/core \
    "$(IMCC_DIR)/*$(O)" \
    $(IMCC_DIR)/imcparser.output

# a failing step of cleaning, usually doesn't concern the following steps
realclean : clean
	-$(MAKE) languages       realclean
	-$(MAKE) compilers/pirc  realclean
	-$(MAKE) src/dynpmc      realclean
	$(RM_RF) \
    $(CONFIGURE_GENERATED_FILES) \
    blib \
    cover_db

distclean : realclean

# Require .svn to exist first
# Otherwise it'll remove every last file
svnclobber : .svn
	$(PERL) tools/dev/svnclobber.pl

reconfig : clean
	$(PERL) Configure.pl

manitest :
	$(PERL) tools/dev/manicheck.pl

opsrenumber :
	$(PERL) tools/dev/opsrenumber.pl $(OPS_FILES)

pmcrenumber :
	$(PERL) tools/dev/pmcrenumber.pl $(SRC_DIR)/pmc/pmc.num

###############################################################################
#
# SVN Targets:
#
###############################################################################

update :
	svn -q update

# Is this still working ?
rsync :
	rsync -av cvs.perl.org::parrot-HEAD $(CUR_DIR)

status :
	svn -q status

patch :
	svn diff

LINTABLE_CFILES = `echo $(SRC_DIR)/main$(O) $(O_FILES) $(SRC_DIR)/parrot_config$(O) | $(PERL) -pe @PQ@s/\.o/\.c/g@PQ@`

lint : sunlint

SUNLINT = lint

# This target does sneaky magic to get the $(NOTE) fields to work.  It's
# doing replaces in $(NOTE), which is empty, of strings that will never match.
NOTE =
SUNLINT_HUSH_OPTS = \
    $(NOTE:% Errors that will never be silenced, and we must always hush =%)\
    -erroff=E_ARGUMENT_CONVERT          $(NOTE:% implicit integer-to-long conversion =%) \
    -erroff=E_BAD_PTR_CAST                    $(NOTE:% pointer casts may be troublesome =%) \
    -erroff=E_BAD_PTR_CAST_ALIGN          $(NOTE:% alignment problems with cast =%) \
    -erroff=E_LABEL_NOT_USED          $(NOTE:% Unused label =%) \
    -erroff=E_CONSTANT_CONDITION          $(NOTE:% Constant condition =%) \
    -erroff=E_INCL_NUSD                    $(NOTE:% An include file was unused =%) \
    -erroff=E_INDISTING_FROM_TRUNC          $(NOTE:% Identifier will be ambiguous if truncated =%) \
    -erroff=E_MCR_NODIFF                    $(NOTE:% Macros differ between source files =%) \
    -erroff=E_INIT_DOES_NOT_FIT          $(NOTE:% initializer does not fit or is out of range+ 0xf0e69739 =%) \
    -erroff=E_NONPORT_SBITWISE_OP   $(NOTE:% bitwise operations on signed values not portable =%) \
    \
    $(NOTE:% Things to drop some day =%) \
    -erroff=E_FUNC_ARG_UNUSED          $(NOTE:% Unused function argument =%) \
    -erroff=E_STMT_NOT_REACHED          $(NOTE:% Unreachable statement =%) \
    -erroff=E_NOP_IF_STMT                    $(NOTE:% if has a no-op =%) \
    -erroff=E_NOP_ELSE_STMT                    $(NOTE:% else has a no-op =%) \
    -erroff=E_CASE_FALLTHRU                    $(NOTE:% case fallthru =%) \
    -erroff=E_STATIC_UNUSED                    $(NOTE:% Static function not used =%) \

SUNLINT_OPTS_FOR_THE_FUTURE = -b -m -Xc

# Lint options at: http:////docs.sun.com//app//docs//doc//819-5265//6n7c29cli?a=view
SUNLINTOPTS = \
    -b \
    -p \
    -fd \
    -Ncheck=%all \
    -Nlevel=4 \
    -errchk=%all \
    -errhdr=%user \
    -errtags \
    -errchk=no%longptr64 \
    -errfmt=simple \
    $(SUNLINT_HUSH_OPTS) \

sunlint :
	rm -f *.ln
	$(SUNLINT) $(CC_INC) @cc_hasjit@ "-Isrc/pmc" $(SUNLINTOPTS) $(LINTABLE_CFILES)

BSD_LINT_FLAGS = -a -aa -b -c -e -h -n -p -r -u -x -z -F -H -V

# 132: conversion from '...' may lose accuracy
# 135: possible pointer alignment problem
# 236: static function unused
# 241: dubious operation on enum
# 247: pointer casts may be troublesome
# 249: syntax error (huh? this appears in atomic/gcc_x86.h but doesn't
#      cause any compiler to barf)
# 259: conversion to '...' due to prototype
# 265: ANSI C does not support 'long long'
# 277: initialisation of '...' with '...'
# 278: combination of '...' and '...', arg #...
BSD_LINT_EXCLUSIONS = -X132,135,236,241,247,249,259,265,277,278

bsdlint : $(PARROT)
	rm -f *.ln
	$(LINT) $(CC_INC) "-Isrc/pmc" $(BSD_LINT_FLAGS) $(BSD_LINT_EXCLUSIONS) $(LINTABLE_CFILES)

# For checking with splint see also http:////www.perlfoundation.org//parrot//index.cgi?splint
# Splint: http:////splint.org
SPLINT = splint

# Temp directory for splint.  Add +keep to splintflags if you want work files
# kept in there after completion.
SPLINT_TMP = $(TMP)/splint

# Splint flags: http:////splint.org//manual//html//appB.html
# The dashes in the names don't make any difference to Splint, but I've
# made them match how they are in the manual.  Otherwise, you might be
# looking for "declundef", except that it's "decl-undef" in the docs.
SPLINTFLAGS  = \
    +standard \
    -hints \
    \
    +indentspaces 4 \
    +locindentspaces 4 \
    +linelen 120 \
    -message-stream-stdout \
    +showdeephistory \
    -showfunc \
    -tmpdir $(SPLINT_TMP) \
    \
    +posix-strict-lib \
    -skip-posix-headers \
    \
    -show-summary \
    +show-scan \
    +time-dist \
    \
    +memchecks \
    \
    -ansi-reserved \
    +ansi-reserved-internal \
    +bool-compare \
    +bufferoverflow \
    +char-index \
    +cpp-names \
    +decl-undef \
    +duplicate-case \
    +enum-members \
    +eval-order \
    +eval-order-uncon \
    +format-code \
    +format-type \
    +ignore-signs \
    +incon-defs \
    +incon-defs-lib \
    -iso-reserved \
    +macro-assign \
    +macro-empty \
    +macro-parens \
    +macro-redef \
    +macro-stmt \
    +macro-unrecog \
    +match-fields \
    +null \
    +nullptrarith \
    +nullret \
    -pred-bool-int \
    -pred-bool-ptr \
    -pred-bool-others \
    +ptr-compare \
    +ptr-negate \
    +strict-destroy \
    \
    +use-released \
    +strict-use-released \

# I'd like the +ignore-signs to go away, but we have too many
# cross-signedness comparisons.

# Andy is working on making a decent splint target.  He's currently
# (2/29/08) dropping all the flags that he's been working with
# and going with the +weak settings, just to get the most egregious
# problems uncovered.  Then, he'll be gradually adding stricter and
# stricter settings.  The SPLINTFLAGS_OVERLY_NOISY list below represents
# his noisy-based work at the time he reverted to weak mode.
SPLINTFLAGS_OVERLY_NOISY = \
    -abstract \
    +aliasunique \
    +assignexpose \
    -boolops \
    -casebreak \
    -castfcnptr \
    -charint \
    +continuecomment \
    +controlnestdepth 15 \
    -exportlocal \
    -fcnuse \
    +fielduse \
    -globs \
    +imptype \
    -initallelements \
    -isoreserved \
    -isoreservedinternal \
    +longintegral \
    +matchanyintegral \
    +nestedextern \
    -noeffect \
    -paramuse \
    +ptrnegate \
    +readonlystrings \
    -realcompare \
    -redef \
    -retvalint \
    -retvalother \
    +shadow \
    -shiftimplementation \
    -shiftnegative \
    -showsourceloc \
    -type \
    \
    -branchstate \
    -compdef \
    -compdestroy \
    -compmempass \
    -globstate \
    -modobserver \
    -mustfreefresh \
    -mustfreeonly \
    -nullstate \
    -redecl \
    -retalias \
    \
    -immediatetrans \
    -kepttrans \
    -observertrans \
    -onlytrans \
    -readonlytrans \
    -statictrans \
    -temptrans \
    -unqualifiedtrans \

# Other options we'd like to add back
# +paramuse: As soon as we get SHIM()s in the ops
# -includedepth 8 : Let's investigate why we do so many includes.
# +initallelements : Right now, the *.ops files don't initialize all
#  values of the arrays
# +casebreak: Auto-generated ops have way too case fallthrus right now
# +noeffect: Right now the UNUSED(macro) trips +noeffect
# +realcompare: Make sure we're not doing comparisons on equality on real
#  numbers
# +fcnuse: We have many functions that are defined but not used, but they
#  should get hidden or ifdeffed
# +redef, +redecl: Ops currently have tons of redefinitions
# +boolops

# added to splint target to simplify experimentation,
# ex: make SPLINTFLAGS_TEST='-posixstrictlib +posixlib' splint
SPLINTFLAGS_TEST = \

splint : $(PARROT)
	$(MKPATH) $(SPLINT_TMP)
	$(SPLINT) $(CC_INC) @cc_hasjit@ "-Isrc/pmc" "-Icompilers/ast" $(SPLINTFLAGS) $(SPLINTFLAGS_TEST) `echo $(O_FILES) | $(PERL) -pe @PQ@s/\.o/\.c/g@PQ@`
	$(SPLINT) $(CC_INC) $(SPLINTFLAGS) $(SPLINTFLAGS_TEST) $(IMCC_DIR)/main.c

splint-andy :
	$(MKPATH) $(SPLINT_TMP)
	splint $(CC_INC) @cc_hasjit@ "-Isrc/pmc" "-Icompilers/ast" $(SPLINTFLAGS) $(SPLINTFLAGS_TEST) \
    compilers/imcc/cfg.c \
    compilers/imcc/debug.c \
    compilers/imcc/imc.c \
    compilers/imcc/imclexer.c \
    compilers/imcc/imcparser.c \
    compilers/imcc/instructions.c \
    compilers/imcc/main.c \
    compilers/imcc/optimizer.c \
    compilers/imcc/parser_util.c \
    compilers/imcc/pbc.c \
    compilers/imcc/pcc.c \
    compilers/imcc/reg_alloc.c \
    compilers/imcc/sets.c \
    compilers/imcc/symreg.c \
    | grep -v 'Source code error generation point'

COVER_FLAGS = -fprofile-arcs -ftest-coverage
COVER_DIRS = \
    $(SRC_DIR) \
    $(SRC_DIR)/charset \
    $(SRC_DIR)/dynoplibs \
    $(SRC_DIR)/dynpmc \
    $(SRC_DIR)/encodings \
    $(SRC_DIR)/gc \
    $(SRC_DIR)/ops \
    $(SRC_DIR)/packfile \
    $(SRC_DIR)/pmc \
    $(IO_DIR) \
    $(IMCC_DIR)

cover: \
    cover.dummy \
    cover-testb \
#IF(cg_flag):    cover-testC \
    cover-testf \
#IF(cg_flag):    cover-testg \
#IF(jitcapable):    cover-testj \
    cover-testr \
    cover-testS \
    cover-src \
    cover-perl \
    cover-codingstd \
    cover-benchmark \
    cover-doc \
    cover-distro
	build_dir=$$PWD; \
    for dir in $(COVER_DIRS); \
    do \
        cd $$dir; \
        gcov *.c; \
        cd $$build_dir; \
        gcov2perl $$dir/*.gcov; \
    done
	cover -ignore_re '^\/usr\/local\/bin'

cover.dummy:
	$(PERL) Configure.pl --ccflags="$(CC_FLAGS) $(COVER_FLAGS)" \
    --linkflags="$(COVER_FLAGS)" --ldflags="$(COVER_FLAGS)"

cover-testb: cover.dummy
	-@make@ testb

cover-testC: cover.dummy
	-@make@ testC

cover-testf: cover.dummy
	-@make@ testf

cover-testg: cover.dummy
	-@make@ testg

cover-testj: cover.dummy
	-@make@ testj

cover-testr: cover.dummy
	-@make@ testr

cover-testS: cover.dummy
	-@make@ testS

cover-src: cover.dummy
	-@make@ src_tests

cover-perl: cover.dummy
	-@make@ perl_tests

cover-codingstd: cover.dummy
	-@make@ codingstd_tests

cover-benchmark: cover.dummy
	-@make@ benchmark_tests

cover-doc: cover.dummy
	-@make@ doc_tests

cover-distro: cover.dummy
	-@make@ distro_tests

cover-clean:
	$(PERL) -MCwd -e 'for my $$dir qw ( $(COVER_DIRS) ) {my $$cwd = cwd(); chdir $$dir; print "Deleting gcov-generated files in $$dir\n"; unlink glob( "*.gcda *.gcno *.gcov" ); chdir $$cwd;}'

###############################################################################
#
# installation
#
###############################################################################

install: installable
	$(PERL) tools/dev/install_files.pl \
    --buildprefix=$(BUILDPREFIX) \
    --prefix=$(PREFIX) \
    --exec-prefix=$(EXEC_PREFIX) \
    --bindir=$(BIN_DIR) \
    --libdir=$(LIB_DIR) \
    --includedir=$(INCLUDE_DIR) \
    --destdir=$(DESTDIR) \
    --docdir=$(DOC_DIR) \
    MANIFEST MANIFEST.generated

###############################################################################
#
# release targets
#
###############################################################################

release : MANIFEST MANIFEST.generated
	[ -d parrot-$(VERSION) ] || ln -s $(CUR_DIR) parrot-$(VERSION)
	@$(RM_F) MANIFEST.real
	mv MANIFEST MANIFEST.real
	grep -v DEVELOPING MANIFEST.real > MANIFEST
	$(PERL) -lane 'print"parrot-$(VERSION)/$$F[0]"unless!length||/#/' MANIFEST | \
    tar -zcv -T - -f parrot-$(VERSION).tar.gz
	mv MANIFEST.real MANIFEST
	rm parrot-$(VERSION)

rpms : release
	mkdir -p rpmbuild/SOURCES rpmbuild/SPEC rpmbuild/BUILD rpmbuild/RPMS rpmbuild/SRPMS
	cp parrot-$(VERSION).tar.gz rpmbuild/SOURCES
	cp parrot.spec rpmbuild/SPEC
	echo '%_topdir '`pwd`'/rpmbuild' > .rpmmacros
	HOME=`pwd`; rpmbuild -ba parrot.spec

win32-inno-installer : world installable
	$(PERL) tools/dev/mk_inno.pl
	$(INNO_SETUP) parrot.iss

###############################################################################
#
# exec:
#
###############################################################################

exec : $(SRC_DIR)/exec_start$(O) $(SRC_DIR)/parrot_config$(O) $(LIBPARROT)
	$(LINK) @ld_out@$(EXEC)$(EXE) $(EXEC)$(O) $(SRC_DIR)/exec_start$(O) $(SRC_DIR)/parrot_config$(O) @rpath_blib@ $(ALL_PARROT_LIBS) $(LINKFLAGS)

###### OS depend targets ##########

# for use by t/pmc/nci.t
$(LIBNCI_TEST_SO): $(SRC_DIR)/nci_test$(O)
	$(LD) $(LD_LOAD_FLAGS) @ncilib_link_extra@ $(LDFLAGS) \
    @ld_out@$@ $(SRC_DIR)/nci_test$(O) $(C_LIBS)

# for use by runtime/parrot/library/OpenGL.pir
$(LIBGLUTCB_SO): $(LIBPARROT) $(SRC_DIR)/glut_callbacks$(O)
	$(LD) $(LD_LOAD_FLAGS) $(LDFLAGS) \
    @ld_out@$@ $(SRC_DIR)/glut_callbacks$(O) $(ALL_PARROT_LIBS)

# emacs etags
# this needs exuberant-ctags

tags-emacs: tags.emacs.dummy
	$(RM_F) TAGS
	@ctags@ -e \
        --links=no --totals \
        -R --exclude=blib --exclude=.svn  \
        --exclude=res_lea.c \
        --languages=c,perl --langmap=c:+.h,c:+.pmc,c:+.ops \
        -I NOTNULL,NULLOK,ARGIN,ARGMOD,ARGOUT,ARGINOUT,ARGIN_NULLOK,ARGOUT_NULLOK,ARGMOD_NULLOK \
        $(CUR_DIR)

# this works with an old etags (XEmacs 21.5*)
tags-xemacs: tags.emacs.dummy
	$(RM_F) TAGS
	find $(CUR_DIR) \
        -name \*.c -o -name \*.h -o -name \*.pmc -o -name \*.ops | etags -l c - -o TAGS

tags.emacs.dummy:

# vim ctags
# this needs exuberant-ctags

tags-vi: tags.vi.dummy
	$(RM_F) tags
	@ctags@ \
    --links=no --totals \
    -R --exclude=blib --exclude=.svn  \
    --exclude=res_lea.c \
    --languages=c,perl --langmap=c:+.h,c:+.pmc,c:+.ops \
    -I NOTNULL,NULLOK,ARGIN,ARGMOD,ARGOUT,ARGINOUT,ARGIN_NULLOK,ARGOUT_NULLOK,ARGMOD_NULLOK \
    $(CUR_DIR)
	$(PERL) $(BUILD_TOOLS_DIR)/addopstags.pl $(OPS_FILES)

tags.vi.dummy:

perlcritic:
	perlcritic --profile tools/util/perlcritic.conf

# Andy's extra-cranky Perl::Critic checking for cage cleaners
cagecritic:
	perlcritic -1 --profile tools/util/perlcritic-cage.conf lib/Parrot

# This target will eventually create all the headers automatically.  If you are
# having problems with linkage in Win32 (or elsewhere), because something is
# not PARROT_EXPORT but should be, then put PARROT_EXPORT in the C file and run "make
# headerizer".  The .h file will get updated.

HEADERIZER_O_FILES = \
    $(O_FILES) \
    src/packdump$(O) \
    src/pbc_merge$(O) \

headerizer : $(SRC_DIR)/core_pmcs.c
	$(PERL) $(BUILD_TOOLS_DIR)/headerizer.pl $(HEADERIZER_O_FILES) $(IMCC_DIR)/imcc.y

apilist: $(SRC_DIR)/core_pmcs.c
	$(PERL) $(BUILD_TOOLS_DIR)/headerizer.pl --macro=PARROT_EXPORT $(HEADERIZER_O_FILES)

malloclist: $(SRC_DIR)/core_pmcs.c
	$(PERL) $(BUILD_TOOLS_DIR)/headerizer.pl --macro=PARROT_MALLOC $(HEADERIZER_O_FILES)

#
# Local variables:
# mode: makefile
# ex: ft=make
# End:
