Created
June 16, 2016 04:39
-
-
Save TakesxiSximada/2383ffddc7db85fb5bb77cfe3b3568ea to your computer and use it in GitHub Desktop.
MakefileのUsageを表示するためのperl スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env perl | |
# | |
# Display Makefile Usage Script | |
# | |
# Examle Makefile):: | |
# | |
# .all: | |
# @## version=VERSION | |
# @# comment1 | |
# @# comment2 | |
# @# comment3 | |
# echo "OK" | |
use strict; | |
use warnings; | |
open (FILE, "./Makefile") or die "$!"; | |
my $buf = do { local $/; <FILE> }; | |
close FILE; | |
while ($buf =~ /^([^._][a-zA-Z0-9_\-]*):(.*)\n(^\t\@\##.*\n)?((^\t\@\#.*\n)*)/gm ) { | |
my $cmd = $1; | |
my $synopsis = $3 || ""; | |
my $msg = $4 || ""; | |
$synopsis =~ s/@##//g; | |
$synopsis =~ s/\A\s*(.*?)\s*\z/$1/; | |
$msg =~ s/\t\@\#/ /g; | |
printf("* %-20s\n%s\n", $cmd . " " . $synopsis, $msg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment