summaryrefslogtreecommitdiff
path: root/bin/MakeProjectCreator/modules/AutomakeWorkspaceCreator.pm
blob: f55713951c1fce9ac2469289b0900a9a6a72059d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package AutomakeWorkspaceCreator;

# ************************************************************
# Description   : A Automake Workspace (Makefile) creator
# Author        : Chad Elliott
# Create Date   : 5/13/2002
# ************************************************************

# ************************************************************
# Pragmas
# ************************************************************

use strict;
use File::Basename;

use AutomakeProjectCreator;
use WorkspaceCreator;

use vars qw(@ISA);
@ISA = qw(WorkspaceCreator);

# ************************************************************
# Subroutine Section
# ************************************************************

sub workspace_file_name {
  my($self) = shift;
  return $self->get_modified_workspace_name('Makefile', '.am');
}


sub pre_workspace {
  my($self) = shift;
  my($fh)   = shift;
  my($crlf) = $self->crlf();

  print $fh "##$crlf" .
            "##  Process this file with automake$crlf" .
            "##$crlf" .
            "$crlf" .
            "## The number in AUTOMAKE_OPTIONS is the minimum required version automake$crlf" .
            "## needed to process this file.$crlf" .
            "AUTOMAKE_OPTIONS = 1.4$crlf$crlf";
}


sub write_comps {
  my($self)     = shift;
  my($fh)       = shift;
  my($projects) = $self->get_projects();
  my($pjs)      = $self->get_project_info();
  my(@list)     = $self->sort_dependencies($projects, $pjs);
  my($crlf)     = $self->crlf();
  my(%unique)   = ();
  my(@dirs)     = ();

  ## Get a unique list of directories while
  ## preserving the order of the original @list
  foreach my $dep (@list) {
    my($dir) = dirname($dep);
    if (!defined $unique{$dir}) {
      $unique{$dir} = 1;
      unshift(@dirs, $dir);
    }
  }

  ## Print out the subdirectories
  print $fh 'SUBDIRS =';
  foreach my $dir (@dirs) {
    print $fh " \\$crlf        $dir";
  }
  print $fh $crlf;
}


1;