/usr/bin/makeppbuiltin is in makepp 2.0.98.5-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | #!/usr/bin/perl -w
#use strict; # TODO: explore why this breaks the builtins.
# $Id: makeppbuiltin,v 1.24 2013/04/14 19:35:42 pfeiffer Exp $
package Mpp;
our $datadir;
BEGIN {
$datadir = '/usr/share/makepp'; unshift @INC, $datadir;
}
$Mpp::Subs::rule->{MAKEFILE}{PACKAGE} = 'Mpp'; # Make it same as ours in eval_or_die
use Mpp::Utils;
use Mpp::Text ();
use Mpp::Cmds;
$Mpp::Text::helpline = 'For command info, click on sidebar "Features" and then "Builtin Commands".';
$Mpp::Text::extraman = '_builtins';
sub eval_or_die($) {
if( wantarray ) {
my @result = eval $_[0];
&maybe_die;
@result;
} else {
my $result = eval $_[0];
&maybe_die;
$result;
}
}
{ no warnings 'redefine'; *Mpp::Cmds::eval_or_die = \&eval_or_die }
# Drop in replacement for getopts, which parses and pretty prints the option
# specification.
sub getopts_help(@) {
my @opts = @_;
print STDERR "$0 options:";
shift @opts if 'HASH' eq ref $opts[0];
my %short;
for( @opts ) {
my $long = Mpp::Text::_getopts_long( $_ );
my $short = $_->[0]; # Show only the 1st short opt (e.g. --fields & --force)
$_ = (($short && !$short{$short}) ? "$_->[0], --$long" : $long) .
($_->[3] ? '=arg' : '');
$short{$short} ||= 1 if $short;
}
for( sort { lc( substr $a, 0, 1 ) cmp lc( substr $b, 0, 1 ) ||
substr( $b, 0, 1 ) cmp substr( $a, 0, 1 ) ||
$a cmp $b } @opts ) {
s/^/-/;
s/^(-.[^,])/ -$1/; # indent only long option further
print STDERR "\n $_";
}
die "\n";
}
my $re = join '|', grep { exists &{"Mpp::Cmds::$_"} && s/^c_// } keys %Mpp::Cmds::;
# This function exists so we can efficiently run many tests in one process.
sub doit {
# Look in our called name to see if it contains a builtin's name.
my $cmd = $0;
if( $0 =~ /($re)[^\/]*$/ ) { # Yes, found a builtin.
$0 = $1;
$cmd = "Mpp::Cmds::c_$0";
} else {
my $tmp;
Mpp::Text::getopts 1,
['I', qr/include(?:[-_]?dir)?/, \$tmp, 1, sub { unshift @INC, $tmp }],
[qw(M module), \$tmp, 1, sub { $tmp =~ s/=(.*)/ qw($1)/ and $tmp =~ tr/,/ /; eval_or_die "use $tmp" }],
splice @Mpp::Text::common_opts;
&Mpp::Text::help unless @ARGV;
$tmp = $0; # 1st argument must be the command name.
$0 = shift @ARGV;
unless( exists &{$cmd = "c_$0"} ) {
$cmd = "Mpp::Cmds::c_$0";
die "$tmp: $0 is not a makepp builtin command.\n" unless exists &$cmd;
}
}
if( @ARGV and $ARGV[0] eq '-?' || $ARGV[0] eq '--help' ) {
no warnings;
*Mpp::Text::getopts = \&getopts_help; # Let the seemingly normal call handle this.
}
if( !$ENV{INSTALL_LOG} && $cmd =~ /install$/ ) {
require Mpp::Makefile;
Mpp::Makefile::find_root_makefile_upwards( $CWD_INFO );
# Fill ->{ROOT} if RootMakeppfile found.
} elsif( $cmd =~ /preprocess$/ ) {
require Mpp::Makefile;
}
&$cmd( @ARGV );
}
doit;
__DATA__
[metaoption ...] command [option ...] [argument ...]
to see options do: makeppbuiltin command --help
Options depend on the command, while metaoptions are these:
-A filename, --args-file=filename, --arguments-file=filename
Read the file and parse it as possibly quoted whitespace- and/or
newline-separated options.
-?, -h, --help
Print out a brief summary of the options.
-I directory, --include=directory, --include-dir=directory
Add directory to Perl load path @INC.
-M module[=arg,...], --module=module[=arg,...]
Load module and import any functions it exports.
-V, --version
Print out the version number.
|