3 my ($BINDIR, $BINNAME) = $0 =~ m!^(.*)/(.*)!;
5 print STDERR <<"fnord";
6 usage: $BINNAME <module> <class-base>
7 eg: $BINNAME base QuadSet
10 Should be in module sub-directory (Reve/ or Alieve/).
11 Note that GL and Editor siffixes are not present!
16 my $MODULE = $ARGV[0];
18 # die "'$MODULE' not a directory" unless -d $MODULE;
20 %suff = ( 'gl' => 'GL', 'ged' => 'Editor');
22 my $CLASS = $STEM . $suff{$MODULE};
25 # my $H_NAME = "$MODULE/$CLASS.h";
26 # my $C_NAME = "$MODULE/$CLASS.cxx";
27 my $H_NAME = "$CLASS.h";
28 my $C_NAME = "$CLASS.cxx";
30 die "File '$H_NAME' already exists" if -e $H_NAME;
31 die "File '$C_NAME' already exists" if -e $C_NAME;
34 my ($stem, $suff) = @_;
35 my $file1 = "$stem-$MODULE.$suff";
36 return $file1 if -e $file1;
37 my $file2 = "$stem.$suff";
38 return $file2 if -e $file2;
39 die "Skeleton file not found neither as '$file 1' nor '$file2'";
42 my $SKEL_H_NAME = find_skel(".SKEL", "h");
43 my $SKEL_C_NAME = find_skel(".SKEL", "cxx");
45 print "Using skeleton files '$SKEL_H_NAME' and '$SKEL_C_NAME'\n";
47 my ($skel_h, $skel_c);
49 my $ex_sla = $/; undef $/;
50 open H, "$SKEL_H_NAME" or die "can't open $SKEL_H_NAME";
51 $skel_h = <H>; close H;
52 open C, "$SKEL_C_NAME" or die "can't open $SKEL_C_NAME";
53 $skel_c = <C>; close C;
57 print "Replacing CLASS -> $CLASS, STEM -> $STEM.\n";
59 for $f ($skel_h, $skel_c) {
60 $f =~ s/CLASS/$CLASS/g;
64 print "Writing files '$H_NAME', '$C_NAME'.\n";
67 die "can't open $H_NAME";
68 print H $skel_h; close H;
70 die "can't open $C_NAME";
71 print H $skel_c; close H;
74 print "# Now you should also edit the link-def file.\n";
75 print "# Remember to run 'make depend'.\n";