#!/usr/bin/perl
# Write out a Makefile and a build.xml file based on the *.inputs files
# in the current directory. Steve Wainstead, April 2001.
# $Id: makemakebuild.pl,v 1.1 2001-09-20 20:52:22 wainstead Exp $
# read in all the input files, loop over each one and build up
# text blocks that we will subsitute into the skeletons for Makefile
# and build.xml.
my @files = <*.inputs>;
chomp(@files); # prolly unnecessary, but oh well.
print "Found ", scalar(@files), " input files.\n";
foreach $inputfile (@files) {
$inputfile =~ m/\.inputs$/;
$javafile = "$`.java";
$classname = $`;
$test_make_target_names .= "$javafile ";
$test_make_targets .=<<"EOLN";
$javafile: $inputfile
\tmaketest.pl $inputfile
EOLN
$test_ant_targets .= <<"EOLN";
EOLN
push @test_dependency_names, $classname;
}
$test_dependency_names = join(',', @test_dependency_names);
# print <<"SHOW_RESULTS";
# make's targets: $test_make_target_names
# make's acutual targets:
# $test_make_targets
# ant's target names: $test_dependency_names
# ant's targets:
# $test_ant_targets
# SHOW_RESULTS
# these are the skeleton files for the Makefile and the build.xml file
$makefile = <
$test_ant_targets
BUILDXML_SKEL
print "Writing Makefile...\n";
open MAKEFILE, ">./Makefile" or die $!;
print MAKEFILE $makefile;
print "Writing build.xml...\n";
open BUILDXML, ">./build.xml" or die $!;
print BUILDXML $buildxml;
print "Done.\n";