our
@ISA
=
'Mpp::CommandParser::Gcc'
;
my
%info_string
= (
user
=>
'INCLUDES'
,
usersys
=>
'INCLUDES'
,
sys
=>
'SYSTEM_INCLUDES'
);
my
$suffix_re
=
qr/\.ec$/
;
my
%suffix_re
=
(
apre
=>
qr/\.sc$/
,
ecpg
=>
qr/\.\w+$/
,
esqlc
=>
qr/\.(?:dcl|sc)$/
,
gpre
=>
qr/\.e(?:xx)?$/
);
my
%suffixes
=
(
gpre
=> [
qw(.e .exx)
]);
my
$inc_suffixes
= [
qw(/ .h)
];
my
$db2_inc_suffixes
= [
qw(/ .sqC .sqx .sqc .hpp .h)
];
*factory
= \
&Mpp::Subs::p_esql_compilation
;
sub
new {
my
$self
=
&Mpp::CommandParser::Gcc::new_no_gcc
;
$self
->{SCANNER} = new Mpp::Scanner::Esqlc(
$self
->rule,
$self
->dir);
$self
;
}
sub
set_default_signature_method {
$_
[0]->rule->set_signature_class(
'C.([eps]c|ex*|dcl|sq[Ccx])'
, 1 );
}
sub
parse_arg {
my
(
undef
,
undef
,
$words
,
$files
) =
@_
;
my
$scanner
=
$_
[0]{SCANNER};
for
(
$_
[1] ) {
if
(
$_
[0]{CMD} eq
'proc'
) {
if
( s/^(sys_?)?include=//i ) {
my
$sys
= $1;
for
( /^\((.+)\)$/ ?
split
(
','
, $1 ) :
$_
) {
$scanner
->add_include_dir(
user
=>
$_
);
$scanner
->add_include_dir(
usersys
=>
$_
);
$scanner
->add_include_dir(
sys
=>
$_
)
if
$sys
;
}
}
elsif
( s/^iname=//i ) {
push
@$files
, /\.[^\/]*$/ ?
$_
:
"$_.pc"
;
}
elsif
( s/^define=//i ) {
unshift
@$words
,
"-D$_"
;
}
elsif
( Mpp::is_windows ? s/^config=(?=(\/|[a-z]:)?)//i : s/^config=(?=(\/)?)//i ) {
$_
[0]->add_simple_dependency(
$_
);
substr
$_
, 0, 0,
&Mpp::CommandParser::dirinfo
->{FULLNAME} .
'/'
unless
defined
$1;
Mpp::Subs::prebuild file_info(
$_
,
$_
[0]{RULE}{MAKEFILE}{CWD} ),
$_
[0]{RULE}{MAKEFILE},
$_
[0]{RULE}{RULE_SOURCE};
if
(
open
my
$fh
,
$_
) {
while
( <
$fh
> ) {
chomp
;
parse_arg(
$_
[0],
$_
,
$words
,
$files
);
}
}
else
{
warn
"config file `$_' not found"
;
}
}
elsif
( !/^\w+=/ ) {
push
@$files
, /\.[^\/]*$/ ?
$_
:
"$_.pc"
;
}
}
elsif
(
$_
[0]{SUFFIXES} && Mpp::is_windows ? /(?:^|[\\\/])[^.]+$/ : /(?:^|\/)[^.]+$/ ) {
for
my
$suffix
( @{
$_
[0]{SUFFIXES}} ) {
if
( Mpp::File::exists_or_can_be_built file_info
"$_$suffix"
,
$_
[0]{RULE}{MAKEFILE}{CWD} ) {
push
@$files
,
"$_$suffix"
;
last
;
}
}
}
}
}
sub
parse_opt {
my
$words
=
$_
[2];
for
(
$_
[1] ) {
if
( s/^E(?=[DU].+)// || s/^Y// ) {
unshift
@$words
,
"-$_"
;
}
}
}
sub
tags {
my
$scanner
=
$_
[0]{SCANNER};
$scanner
->should_find(
'user'
);
$scanner
->info_string( \
%info_string
);
$scanner
->add_include_suffix_list(
usersys
=>
$_
[1] ?
$db2_inc_suffixes
:
$inc_suffixes
);
}
sub
xparse_command {
my
$scanner
=
$_
[0]{SCANNER};
my
(
$cmd
) = Mpp::is_windows ?
$_
[1][0] =~ /(\w+)(?:\.exe)?$/ :
$_
[1][0] =~ /(\w+)$/;
if
(
$cmd
eq
'db2'
) {
$_
[0]->tags( 1 );
my
$file
=
$_
[1][1];
return
0
if
$file
!~ s/^pre(?:compile|p)\s*//i;
if
(
$file
) {
$file
=~ s/\s.*//;
}
else
{
$file
=
$_
[1][2];
}
for
(
split
':'
,
$ENV
{DB2INCLUDE} ||
''
) {
$scanner
->add_include_dir(
user
=>
$_
);
$scanner
->add_include_dir(
usersys
=>
$_
);
$scanner
->add_include_dir(
sys
=>
$_
);
}
$_
[0]->set_default_signature_method;
return
$scanner
->scan_file(
$_
[0],
c
=>
$file
) ||
undef
;
}
$_
[0]{CMD} =
$cmd
;
$_
[0]{SUFFIXES} =
$suffixes
{
$cmd
};
$_
[0]{REGEXP} =
$suffix_re
{
$cmd
} ||
$suffix_re
if
$cmd
ne
'proc'
;
goto
&Mpp::CommandParser::Gcc::xparse_command
;
}
sub
input_filename_regexp {
$_
[0]{REGEXP} }
1;