Created
December 23, 2013 02:11
-
-
Save kuniyoshi/8090892 to your computer and use it in GitHub Desktop.
A Makefile.pl to generate Makefile. Erlang's directory structure divides lib, and ebin. It makes hard to write Makefile by .SUFFIXES, and suffix rule. i gave up to write it, but generate by Perl program.
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/perl | |
use 5.10.0; | |
use utf8; | |
use strict; | |
use warnings; | |
use open qw( :utf8 :std ); | |
use Data::Dumper; | |
use Template; | |
use Path::Class qw( file ); | |
my @erls = map { file( $_ ) } | |
glob "lib/*.erl"; | |
my $template = Template->new; | |
$template->process( | |
\*DATA, | |
{ erls => \@erls }, | |
\my $makefile, | |
) | |
or die $template->error; | |
say { file( "Makefile" )->openw } $makefile; | |
exit; | |
__DATA__ | |
.PHONY: s self c compile | |
c: compile | |
compile: $(subst lib/,ebin/,$(addsuffix .beam,$(basename $(wildcard lib/*.erl)))) | |
s: self | |
self: | |
perl Makefile.pl | |
[% FOREACH erl IN erls -%] | |
ebin/[% GET erl.basename.replace( ".erl", ".beam" ) %]: [% GET erl %] | |
erlc -I include -o ebin $< | |
[% END # FOREACH erl IN erls -%] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment