Subversion Repositories gelsvn

Rev

Rev 107 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
107 bj 1
package BMakeWorkspaceCreator;
2
 
3
# ************************************************************
4
# Description   : A Borland Make Workspace (Makefile) creator
5
# Author        : Chad Elliott
6
# Create Date   : 2/03/2004
7
# ************************************************************
8
 
9
# ************************************************************
10
# Pragmas
11
# ************************************************************
12
 
13
use strict;
14
use File::Basename;
15
 
16
use BMakeProjectCreator;
17
use WorkspaceCreator;
18
 
19
use vars qw(@ISA);
20
@ISA = qw(WorkspaceCreator);
21
 
22
# ************************************************************
23
# Data Section
24
# ************************************************************
25
 
26
my($max_line_length) = 32767; ## Borland Make's maximum line length
27
my(@targets) = ('clean', 'generated', 'realclean', '$(CUSTOM_TARGETS)');
28
 
29
# ************************************************************
30
# Subroutine Section
31
# ************************************************************
32
 
33
sub supports_make_coexistence {
34
  #my($self) = shift;
35
  return 1;
36
}
37
 
38
 
39
sub crlf {
40
  my($self) = shift;
41
  return $self->windows_crlf();
42
}
43
 
44
 
45
sub workspace_file_name {
46
  my($self) = shift;
47
  if ($self->make_coexistence()) {
48
    return $self->get_modified_workspace_name($self->get_workspace_name(),
49
                                              '.bmake');
50
  }
51
  else {
52
    return $self->get_modified_workspace_name('Makefile', '');
53
  }
54
}
55
 
56
 
57
sub workspace_per_project {
58
  #my($self) = shift;
59
  return 1;
60
}
61
 
62
 
63
sub pre_workspace {
64
  my($self) = shift;
65
  my($fh)   = shift;
66
  my($crlf) = $self->crlf();
67
 
68
  print $fh '#----------------------------------------------------------------------------', $crlf,
69
            '#       Borland Workspace Makefile', $crlf,
70
            '#', $crlf,
71
            '# $Id: BMakeWorkspaceCreator.pm 107 2005-09-02 16:42:23Z bj $', $crlf,
72
            '#', $crlf,
73
            '# This file was generated by MPC.  Any changes made directly to', $crlf,
74
            '# this file will be lost the next time it is generated.', $crlf,
75
            '#', $crlf,
76
            '# MPC Command:', $crlf,
77
            "# $0 @ARGV", $crlf,
78
            '#', $crlf,
79
            '#----------------------------------------------------------------------------', $crlf,
80
            $crlf;
81
}
82
 
83
 
84
sub write_project_targets {
85
  my($self)     = shift;
86
  my($fh)       = shift;
87
  my($target)   = shift;
88
  my($list)     = shift;
89
  my($crlf)     = $self->crlf();
90
 
91
  foreach my $project (@$list) {
92
    my($dir)   = $self->mpc_dirname($project);
93
    my($chdir) = 0;
94
    my($back)  = '';
95
 
96
    ## If the directory isn't '.' then we need
97
    ## to figure out how to get back to our starting point
98
    if ($dir ne '.') {
99
      $chdir = 1;
100
      my($count) = ($dir =~ tr/\///);
101
      if ($dir =~ /^\.\.\//) {
102
        $back = ('../' x $count) . basename($self->getcwd());
103
      }
104
      else {
105
        $back = ('../' x ($count + 1));
106
      }
107
    }
108
 
109
    print $fh ($chdir ? "\t\@cd $dir$crlf" : ''),
110
              "\t\$(MAKE) -\$(MAKEFLAGS) -f ", basename($project),
111
              " $target$crlf",
112
              ($chdir ? "\t\@cd $back$crlf" : '');
113
  }
114
}
115
 
116
 
117
sub write_comps {
118
  my($self)     = shift;
119
  my($fh)       = shift;
120
  my($projects) = $self->get_projects();
121
  my($pjs)      = $self->get_project_info();
122
  my(%targnum)  = ();
123
  my(@list)     = $self->number_target_deps($projects, $pjs, \%targnum);
124
  my($crlf)     = $self->crlf();
125
  my(@ltargets) = @targets;
126
 
127
  ## Set up the custom targets
128
  print $fh '!ifndef CUSTOM_TARGETS', $crlf,
129
            'CUSTOM_TARGETS=_EMPTY_TARGET_', $crlf,
130
            '!endif', $crlf;
131
 
132
  ## Construct the "all" target
133
  my($all) = 'all:';
134
  foreach my $project (@list) {
135
    $all .= " $$pjs{$project}->[0]";
136
  }
137
  if (length($all) < $max_line_length) {
138
    print $fh $crlf, $all, $crlf;
139
  }
140
  else {
141
    unshift(@ltargets, 'all');
142
  }
143
 
144
  ## Print out all other targets here
145
  foreach my $target (@ltargets) {
146
    print $fh $crlf, $target, ':', $crlf;
147
    $self->write_project_targets($fh, $target, \@list);
148
  }
149
 
150
  ## Print out each target separately
151
  foreach my $project (@list) {
152
    print $fh $crlf, $$pjs{$project}->[0], ':';
153
    if (defined $targnum{$project}) {
154
      foreach my $number (@{$targnum{$project}}) {
155
        print $fh " $$pjs{$list[$number]}->[0]";
156
      }
157
    }
158
 
159
    print $fh $crlf;
160
    $self->write_project_targets($fh, 'all', [ $project ]);
161
  }
162
 
163
  ## Print out the project_name_list target
164
  print $fh $crlf, 'project_name_list:', $crlf;
165
  foreach my $project (sort @list) {
166
    print $fh "\t\@echo $$pjs{$project}->[0]$crlf";
167
  }
168
}
169
 
170
 
171
 
172
1;