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
|
/*
This file is part of KDE.
Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "automakefile.h"
using namespace KODE;
AutoMakefile::Target::Target( const TQString &type, const TQString &name )
: mType( type ), mName( name )
{
}
AutoMakefile::AutoMakefile()
{
}
void AutoMakefile::addTarget( const Target &t )
{
mTargets.append( t );
if ( mTargetTypes.tqfind( t.type() ) == mTargetTypes.end() ) {
mTargetTypes.append( t.type() );
}
}
void AutoMakefile::addEntry( const TQString &variable, const TQString &value )
{
if ( variable.isEmpty() ) {
mEntries.append( variable );
return;
}
TQStringList::ConstIterator it = mEntries.tqfind( variable );
if ( it == mEntries.end() ) {
mEntries.append( variable );
TQMap<TQString,TQString>::Iterator it = mValues.tqfind( variable );
if ( it == mValues.end() ) {
mValues.insert( variable, value );
} else {
mValues[ variable ].append( " " + value );
}
}
}
void AutoMakefile::newLine()
{
addEntry( "" );
}
TQString AutoMakefile::text() const
{
TQString out;
TQStringList::ConstIterator it;
for( it = mEntries.begin(); it != mEntries.end(); ++it ) {
TQString variable = *it;
if ( variable.isEmpty() ) {
out += '\n';
} else {
out += variable + " = " + mValues[ variable ] + '\n';
}
}
out += '\n';
for( it = mTargetTypes.begin(); it != mTargetTypes.end(); ++it ) {
TQString targetType = *it;
out += targetType + " = ";
Target::List::ConstIterator it2;
for( it2 = mTargets.begin(); it2 != mTargets.end(); ++it2 ) {
Target t = *it2;
if ( t.type() != targetType ) continue;
out += " " + t.name();
}
out += "\n\n";
for( it2 = mTargets.begin(); it2 != mTargets.end(); ++it2 ) {
Target t = *it2;
if ( t.type() != targetType ) continue;
TQString name = t.name();
name.tqreplace( '.', '_' );
out += name + "_SOURCES = " + t.sources() + '\n';
if ( !t.libAdd().isEmpty() )
out += name + "_LIBADD = " + t.libAdd() + '\n';
else
out += name + "_LDADD = " + t.ldAdd() + '\n';
out += name + "_LDFLAGS = " + t.ldFlags() + '\n';
}
out += '\n';
}
return out;
}
|