summaryrefslogtreecommitdiff
path: root/bin/MakeProjectCreator/modules/GNUACEProjectCreator.pm
blob: a7c55ef58980b43d5dbef4ca2da717ab970a1871 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package GNUACEProjectCreator;

# ************************************************************
# Description   : A GNU Project Creator for ACE
# Author        : Chad Elliott
# Create Date   : 3/13/2002
# ************************************************************

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

use strict;
use File::Basename;

use ProjectCreator;

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

# ************************************************************
# Data Section
# ************************************************************

my(%compscript) = ('ACE_COMPONENTS'     => ['--ace',     '--set'],
                   'TAO_COMPONENTS'     => ['--tao',     '--set'],
                   'ORBSVCS_COMPONENTS' => ['--orbsvcs', '--append'],
                  );

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

sub sort_files {
  #my($self) = shift;
  return 0;
}


sub convert_slashes {
  #my($self) = shift;
  return 0;
}


sub fill_value {
  my($self)  = shift;
  my($name)  = shift;
  my($value) = undef;
  my($crlf)  = $self->crlf();
  my($tag)   = 'source_files';
  my($names) = $self->{$tag};

  if ($name eq 'gnu_source_files') {
    my(%vpath) = ();
    $value = '';
    foreach my $name (keys %$names) {
      my($comps) = $$names{$name};

      foreach my $key (sort keys %$comps) {
        my($a)   = $$comps{$key};
        my(@arr) = @$a;
        my($cpy) = $key;

        $cpy =~ s/^\d+_//;
        $value .= "$crlf$crlf$cpy = \\";
        for(my $i = 0; $i <= $#arr; $i++) {
          my($item) = $arr[$i];
          my($dname) = dirname($item);

          $item =~ s/\.[^\.]+$//;
          if ($dname ne '.' && $dname !~ /^\.\.\//) {
            $vpath{$dname} = 1;
          }
          $value .= "$crlf  $item" . ($i != $#arr ? " \\" : '');
        }
      }
    }
    foreach my $name (keys %$names) {
      my($fname) = '';
      my($comps) = $$names{$name};
      foreach my $key (sort keys %$comps) {
        $fname = $key;
        $fname =~ s/^\d+_//;
        last;
      }

      if ($name ne 'default') {
        $fname = 'FILES';
        $value .= "$crlf$crlf" . "ifndef $name$crlf" .
                  "  $name = \\$crlf";
        my(@keys) = sort keys %$comps;
        for(my $i = 0; $i <= $#keys; $i++) {
          $keys[$i] =~ s/^\d+_//;
          my($key) = $keys[$i];
          $value .= "    $key" . ($i != $#keys ? " \\" : '') . $crlf;
        }
        $value .= "endif # $name";

        foreach my $key (@keys) {
          $value .= "$crlf$crlf" . "ifneq (,\$(findstring $key, \$($name)))$crlf" .
                    "  $fname += \$($key)$crlf" .
                    "endif # $key";
        }
      }
    }
    my(@vkeys) = sort keys %vpath;
    if ($#vkeys >= 0) {
      $value .= "$crlf$crlf" . 'VPATH = .';
      foreach my $key (@vkeys) {
        $value .= ":$key";
      }
    }
  }
  elsif ($name eq 'build') {
    foreach my $name (keys %$names) {
      if ($name ne 'default') {
        if (!defined $value) {
          $value = 'BUILD +=';
        }
        $value .= " $name";
      }
    }
  }
  elsif ($name eq 'comptarget') {
    foreach my $name (keys %$names) {
      if (defined $compscript{$name}) {
        if (!defined $value) {
          $value = '';
        }
        $value .= "$crlf.PHONY: $name$crlf" .
                  "$name:$crlf" .
                  "\t\@sh \$(ACE_ROOT)/bin/ace_components $compscript{$name}->[0] $compscript{$name}->[1] '\$($name)'$crlf$crlf" .
                  "compclean:$crlf" .
                  "\t\@sh \$(ACE_ROOT)/bin/ace_components $compscript{$name}->[0] --remove";
      }
    }
  }
  elsif ($name eq 'compclean') {
    foreach my $name (keys %$names) {
      if (defined $compscript{$name}) {
        $value = 'compclean';
        last;
      }
    }
  }
  elsif ($name eq 'notdirfiles') {
    $value = '$(notdir $(FILES))';
    foreach my $name (keys %$names) {
      my($comps) = $$names{$name};
      foreach my $key (keys %$comps) {
        my($arr) = $$comps{$key};
        foreach my $file (@$arr) {
          if ($file =~ /^\.\.\//) {
            $value = '$(FILES)';
            last;
          }
        }
      }
    }
  }
  elsif ($name eq 'tao') {
    if ($self->get_assignment('includes') =~ /tao/i ||
        $self->get_assignment('libpaths') =~ /tao/i) {
      $value = 1;
    }
  }

  return $value;
}


sub project_file_name {
  my($self) = shift;
  my($name) = shift;

  if (!defined $name) {
    $name = $self->project_name();
  }

  return 'Makefile' . ($name eq '' ? '' : ".$name");
}


sub get_dll_exe_template_input_file {
  #my($self) = shift;
  return 'gnuexe';
}


sub get_dll_template_input_file {
  #my($self) = shift;
  return 'gnudll';
}


sub get_template {
  #my($self) = shift;
  return 'gnu';
}

1;