Skip to content

Instantly share code, notes, and snippets.

@seungwon0
Created April 29, 2013 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seungwon0/5480402 to your computer and use it in GitHub Desktop.
Save seungwon0/5480402 to your computer and use it in GitHub Desktop.
draws a building flowchart from makefile
#!/usr/bin/env perl
#
# makefile-graphviz.pl - draws a building flowchart from makefile
#
# Draws a buildidng flowchart from makefile using Makefile::GraphViz.
#
# Usage Example:
# % ./makefile-graphviz.pl Makefile Makefile.png
#
# Seungwon Jeong <seungwon0@gmail.com>
#
# Copyright (C) 2013 by Seungwon Jeong
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
use perl5i::2;
use Makefile::GraphViz;
my ( $input_file, $output_file );
given ( scalar @ARGV ) {
when (0) {
$input_file = 'Makefile';
$output_file = 'Makefile.png';
}
when (1) {
$input_file = $ARGV[0];
$output_file = 'Makefile.png'
}
when (2) {
$input_file = $ARGV[0];
$output_file = $ARGV[1];
}
default {
say "Usage: $PROGRAM_NAME [INPUT_FILE [OUTPUT_FILE]]";
exit 2;
}
}
my $parser = Makefile::GraphViz->new;
$parser->parse($input_file);
my $gv = $parser->plot_all;
$gv->as_png($output_file);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment