use 5.008;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.

my $Z80_OPTIONS = '-DEXEC6502 -DFAST_RDOP -DLSB_FIRST ';
$Z80_OPTIONS .= '-DDEBUG ';

my $run = './t/05-Z80.t -d';

WriteMakefile(
    NAME              => 'Z80',
    VERSION_FROM      => 'Z80.pm', # finds $VERSION
    PREREQ_PM         => {
		'ExtUtils::Embed' => 0,
		'Class::Accessor' => 0,
		'Data::Dump' => 0,
		'Carp' => 0,
		'Test::Exception' => 0,
		'SDL' => '2.1.2',
	}, # e.g., Module::Name => 1.1
    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
      (ABSTRACT_FROM  => 'Z80.pm', # retrieve abstract from module
       AUTHOR         => 'Dobrica Pavlinusic <dpavlin@rot13.org>') : ()),
    LIBS              => [''], # e.g., '-lm'
    DEFINE            => '',
    INC               => '-I. -I./src/', # e.g., '-I. -I/usr/include/other'
	# Un-comment this if you add C files to link with later:
    OBJECT            => '$(O_FILES) cpu.o', # link all the C files too
	OPTIMIZE => '-g',
	depend => {
		# Z80 options
		'cpu$(OBJ_EXT)' => qq{src/Z80.c\n\t\$(CC) \$(CCCDLFLAGS) -c -o cpu\$(OBJ_EXT) $Z80_OPTIONS src/Z80.c},
	},
	clean => {
		'FILES' => 'html',
	},
);

sub MY::postamble {
	return <<"MAKE_FRAG";

run: all
	perl -Mblib -MOrao -le 'Orao->new->run;'

gdb: all
	gdb -x run --args perl $run

html: all
	test -d html || mkdir html
	allpod2xhtml.pl \$(INST_LIB) html

MAKE_FRAG
}

