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 $M6502_OPTIONS = '-DEXEC6502 -DFAST_RDOP -DLSB_FIRST ';
$M6502_OPTIONS .= '-DDEBUG ';

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

WriteMakefile(
    NAME              => 'M6502',
    VERSION_FROM      => 'M6502.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  => 'M6502.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 => {
		# M6502 options
		'cpu$(OBJ_EXT)' => qq{src/M6502.c\n\t\$(CC) \$(CCCDLFLAGS) -c -o cpu\$(OBJ_EXT) $M6502_OPTIONS src/M6502.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
}

