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

One thought on “Perl Script to Generate Makefile

Leave a comment