Perl Script to Generate Makefile

Download here. createmakefile.pdf
#!/usr/bin/perl
# File name: writemake.pl
# Author: A.G.Raja
# Website: agraja.wordpress.com
# License: GPL
use strict; use warnings; open(FH,">Makefile") or die "Cannot create Makefile"; print FH ("all: buildnn"); print FH ("build: " . $ARGV[0] .".onn"); print FH ("shared: " . $ARGV[0] . ".sonn"); print FH ("clean: n"); print FH ("trm ".$ARGV[0].".*o nn"); print FH ($ARGV[0].".o: ".$ARGV[0].".cn"); print FH ("tgcc -o ".$ARGV[0].".o ".$ARGV[0].".cnn"); print FH ($ARGV[0].".so: ".$ARGV[0].".cn"); print FH ("tgcc -fPIC -shared -o ".$ARGV[0].".so ".$ARGV[0].".cn"); close FH;
# Usage:
# chmod +x writemake.pl
# writenake.pl hello
Below is the Makefile generated:
all: build build: hello.o shared: hello.so clean: rm hello.*o hello.o: hello.c gcc -o hello.o hello.c hello.so: hello.c gcc -fPIC -shared -o hello.so hello.c
Download here. createmakefile.pdf
Advertisements

One thought on “Perl Script to Generate Makefile

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s