~ubuntu-branches/ubuntu/intrepid/tcm/intrepid

« back to all changes in this revision

Viewing changes to doc/developersguide/developersguidenode8.html

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2003-07-03 20:08:21 UTC
  • Revision ID: james.westby@ubuntu.com-20030703200821-se4xtqx25e5miczi
Tags: upstream-2.20
ImportĀ upstreamĀ versionĀ 2.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
 
2
<!--Converted with LaTeX2HTML 98.1p1 release (March 2nd, 1998)
 
3
originally by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds
 
4
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
 
5
* with significant contributions from:
 
6
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
 
7
<HTML>
 
8
<HEAD>
 
9
<TITLE>7. Compiling and Porting TCM</TITLE>
 
10
<META NAME="description" CONTENT="7. Compiling and Porting TCM">
 
11
<META NAME="keywords" CONTENT="TechDoc">
 
12
<META NAME="resource-type" CONTENT="document">
 
13
<META NAME="distribution" CONTENT="global">
 
14
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
 
15
<LINK REL="STYLESHEET" HREF="TechDoc.css">
 
16
<LINK REL="next" HREF="developersguidenode9.html">
 
17
<LINK REL="previous" HREF="developersguidenode7.html">
 
18
<LINK REL="up" HREF="TechDoc.html">
 
19
<LINK REL="next" HREF="developersguidenode9.html">
 
20
</HEAD>
 
21
<BODY >
 
22
<!--Navigation Panel-->
 
23
<A NAME="tex2html361"
 
24
 HREF="developersguidenode9.html">
 
25
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
 
26
<A NAME="tex2html358"
 
27
 HREF="TechDoc.html">
 
28
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
 
29
<A NAME="tex2html352"
 
30
 HREF="developersguidenode7.html">
 
31
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> 
 
32
<A NAME="tex2html360"
 
33
 HREF="developersguidenode1.html">
 
34
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>  
 
35
<BR>
 
36
<B> Next:</B> <A NAME="tex2html362"
 
37
 HREF="developersguidenode9.html">8. Wish List and</A>
 
38
<B> Up:</B> <A NAME="tex2html359"
 
39
 HREF="TechDoc.html">Toolkit for Conceptual Modeling</A>
 
40
<B> Previous:</B> <A NAME="tex2html353"
 
41
 HREF="developersguidenode7.html">6. Output Files</A>
 
42
<BR>
 
43
<BR>
 
44
<!--End of Navigation Panel-->
 
45
<!--Table of Child-Links-->
 
46
<A NAME="CHILD_LINKS"><strong>Subsections</strong></A>
 
47
<UL>
 
48
<LI><A NAME="tex2html363"
 
49
 HREF="developersguidenode8.html#SECTION00810000000000000000">7.1 Compiling TCM</A>
 
50
<UL>
 
51
<LI><A NAME="tex2html364"
 
52
 HREF="developersguidenode8.html#SECTION00811000000000000000">7.1.1 Compilation configuration files</A>
 
53
<LI><A NAME="tex2html365"
 
54
 HREF="developersguidenode8.html#SECTION00812000000000000000">7.1.2 Makefiles</A>
 
55
</UL>
 
56
<LI><A NAME="tex2html366"
 
57
 HREF="developersguidenode8.html#SECTION00820000000000000000">7.2 Porting TCM</A>
 
58
<LI><A NAME="tex2html367"
 
59
 HREF="developersguidenode8.html#SECTION00830000000000000000">7.3 G++ specific problems</A>
 
60
</UL>
 
61
<!--End of Table of Child-Links-->
 
62
<HR>
 
63
 
 
64
<H1><A NAME="SECTION00800000000000000000">&#160;</A> <A NAME="chap:compiling">&#160;</A>
 
65
<BR>
 
66
7. Compiling and Porting TCM
 
67
</H1>
 
68
 
 
69
<P>
 
70
Before you start compiling or porting TCM you first have to unzip
 
71
and untar the source code distribution in the same manner as
 
72
the executable distribution. See then the file 
 
73
<A NAME="tex2html169"
 
74
 HREF="../../INSTALL"><TT>$TCM_HOME/INSTALL</TT></A>
 
75
which contains the most up-to-date installation instructions.
 
76
See chapter&nbsp;<A HREF="developersguidenode4.html#chap:src_organization">3</A> for what files are included. Make 
 
77
sure that before compilation the <TT>TCM_HOME</TT> environment variable is 
 
78
set to the directory where the distribution resides (the ``root'' directory 
 
79
of the entire distribution, not the src directory!).
 
80
 
 
81
<P>
 
82
The TCM directory tree contains a set of Makefiles and configuration files. 
 
83
The <A NAME="tex2html170"
 
84
 HREF="../../src/Makefile"><TT>Makefile</TT></A>
 
85
in the src directory 
 
86
should be a symbolic link to <TT>Makefile.<I>compiler</I></TT>. 
 
87
<A NAME="tex2html171"
 
88
 HREF="../../src/Config.tmpl"><TT>Config.tmpl</TT></A>
 
89
should be a link to 
 
90
<TT>Config.tmpl_<I>platform</I></TT>. <TT>src/Makefile</TT> contains
 
91
the targets specific for some compiler (g++, Sun CC, etc.) and <TT>Config.tmpl</TT>
 
92
contains settings for the system. For each operating system to which
 
93
TCM has been ported (Linux, Solaris, HP-UX, etc.) a distinct Config.tmpl 
 
94
file is supplied. The default make targets are in 
 
95
<A NAME="tex2html172"
 
96
 HREF="../../src/Makefile.GEN"><TT>src/Makefile.GEN</TT></A>
 
97
and the default settings of the various Config.tmpl files 
 
98
are in <A NAME="tex2html173"
 
99
 HREF="../../src/Config.GEN"><TT>src/Config.GEN</TT></A>.
 
100
 
 
101
<P>
 
102
 
 
103
<H1><A NAME="SECTION00810000000000000000">
 
104
7.1 Compiling TCM</A>
 
105
</H1>
 
106
 
 
107
<P>
 
108
The most simple way to compile and install TCM is to type <TT>make</TT> 
 
109
for the <A NAME="tex2html174"
 
110
 HREF="../../Makefile">Makefile</A>
 
111
in <TT>$TCM_HOME</TT>. 
 
112
This default target will set the right links for the
 
113
<A NAME="tex2html175"
 
114
 HREF="../../src/Makefile"><TT>src/Makefile</TT></A>
 
115
and 
 
116
<A NAME="tex2html176"
 
117
 HREF="../../src/Config.tmpl"><TT>src/Config.tmpl</TT></A>
 
118
and then 
 
119
it will write to standard output what are the following targets that you 
 
120
can build. Of course it wise to check the setting
 
121
of <TT>src/Config.tmpl</TT> yourself first before you continue.
 
122
The next possible targets are:
 
123
<UL>
 
124
<LI><TT>make depend</TT>, for making file dependencies.
 
125
<LI><TT>make execs</TT>, for making the object libraries and binaries and then
 
126
move them in the <TT>lib</TT> and <TT>bin</TT> directories respectively.
 
127
<LI><TT>make install</TT>, for copying the binaries and all the other files 
 
128
of a binary distribution to the directory where you would like to install TCM. 
 
129
<TT>/opt/tcm</TT> is the default directory but that can be changed in the Makefile 
 
130
by setting <TT>TCM_INSTALL_DIR</TT>.
 
131
<LI><TT>make all</TT>, which is the same as <TT>make depend execs install</TT>.
 
132
<LI><TT>make docs</TT>, which tries to (re)generate all documentation in
 
133
HTML, PostScript and PDF format in the <TT>doc</TT> subdirectory. This works only of
 
134
course if you have installed the document sources in <TT>docsrc</TT>.
 
135
<LI><TT>make clean</TT>, which removes all binaries, object and temporary files.
 
136
</UL>
 
137
<P>
 
138
Instead of <TT>make install</TT> you can also call the scripts
 
139
<TT>mkbindist</TT> or <TT>mksrcdist</TT> to build a tar.gz file with
 
140
the binaries and the source code respectively. They were treated 
 
141
in chapter&nbsp;<A HREF="developersguidenode4.html#sec:files_and_dirs">3.2</A>.
 
142
 
 
143
<P>
 
144
For compiling TCM you can also go directly into the src directory.
 
145
There you are able to build individual editors and individual 
 
146
libraries. As usual, compilation is controlled by a set of Makefiles. 
 
147
In the src directory there are a number of configuration files and 
 
148
Makefiles.
 
149
 
 
150
<P>
 
151
 
 
152
<H2><A NAME="SECTION00811000000000000000">
 
153
7.1.1 Compilation configuration files</A>
 
154
</H2>
 
155
The configuration files in the <TT>src</TT> directory are called 
 
156
<TT>Config.tmpl<I>_suffix</I></TT>, one for each of the different platforms 
 
157
(platform as file name suffix). There is a file called 
 
158
<A NAME="tex2html177"
 
159
 HREF="../../src/Config.GEN"><TT>Config.GEN</TT></A>
 
160
which 
 
161
contains reasonable default values and is included in the Config.tmpl files.
 
162
The configuration file defines which compiler is used, the compiler flags, 
 
163
the location of the Unix and X include files, the needed Unix and X libraries and 
 
164
their locations. Ideally, this is the only file you need to tailor for compiling 
 
165
TCM on a Unix system. To compile TCM you also need <TT>lex</TT> and <TT>yacc</TT> 
 
166
(or the GNU variants <TT>flex</TT> and <TT>bison</TT>). The files that are generated 
 
167
have to be compiled by an ordinary C compiler. Therefore, define in 
 
168
Config.tmpl, <TT>LEX</TT>, <TT>YACC</TT> and <TT>Cc</TT>.
 
169
Before compiling TCM, make a symbolic link called <TT>Config.tmpl</TT> to the 
 
170
configuration file of the desired platform. The declarations in
 
171
the <TT>Config.tmpl</TT> will be included in the Makefiles.
 
172
 
 
173
<P>
 
174
Configuration options consist of <TT><I>Variable name</I> = <I>Value</I></TT>.
 
175
To append a value to a variable name you can use <TT>+=</TT> instead of <TT>=</TT>.
 
176
A value can contain the contents of a variable that was defined before,
 
177
by using the notation <TT>$(<I>variable name</I>)</TT>.
 
178
The following configuration options can be set:
 
179
<UL>
 
180
<LI><TT>CC</TT>. This is the C++ compiler. This is <TT>/usr/bin/g++</TT> by default.
 
181
<LI><TT>Cc</TT>. This is the C compiler. This is <TT>/usr/bin/gcc</TT> by default.
 
182
<LI><TT>CFLAGS</TT>. These are the flags given to the C++ compiler. By default these
 
183
are <TT>-Wall -pedantic</TT>. You can add compiler-specific options for C++ 
 
184
templates, optimizing options or add the option <TT>-g</TT> to add debugging 
 
185
information.
 
186
<LI><TT>INCLUDEDIRS</TT>, the system include directories (-I flags) for the compiler.
 
187
<LI><TT>LD_FLAGS</TT>, the library flags (-L and -R flags) for linking.
 
188
<LI><TT>LD_LIBS</TT>, the libraries against which TCM is linked.
 
189
<LI><TT>LEX</TT>, the (f)lex lexical analyzer.
 
190
<LI><TT>MKDEPEND</TT>, the command that is called for <TT>make depend</TT>.
 
191
<LI><TT>MKDEPENDFLAGS</TT>, the flags for <TT>make depend</TT>.
 
192
<LI><TT>MOTIF_HOME</TT>, the directory where Motif or LessTif is installed.
 
193
<LI><TT>STRIP</TT>, the Unix command to strip binaries. When you don't want to
 
194
strip (because debugging information would be lost), set it to <TT>/bin/echo</TT>.
 
195
<LI><TT>SHAREDFLAG</TT>, special compiler flag, such as <TT>-shared</TT> or <TT>-G</TT>,
 
196
to generate shared object libraries.
 
197
<LI><TT>SYSFLAGS</TT>, a number of TCM-specific flags for the compiler:
 
198
<UL>
 
199
<LI><TT>-DLINUX</TT>, <TT>-DSOLARIS</TT>, <TT>-DIRIX</TT>, etc. Set this to the 
 
200
target operating system.
 
201
<LI><TT>-DLESSTIF</TT>. Set this if you compile with LessTif, don't set it if 
 
202
you use Motif.
 
203
<LI><TT>-DDEBUG</TT>, <TT>-DDUMPWINDOWTREE</TT>, output some debugging information.
 
204
</UL>
 
205
<LI><TT>XWIN_HOME</TT>, the directory where X windows is installed.
 
206
<LI><TT>YACC</TT>, the yacc, compiler compiler.
 
207
 
 
208
<P>
 
209
</UL>
 
210
<P>
 
211
 
 
212
<H2><A NAME="SECTION00812000000000000000">
 
213
7.1.2 Makefiles</A>
 
214
</H2>
 
215
 
 
216
<P>
 
217
The main Makefile contains the rules for how to build the libraries 
 
218
and the executables in the subdirectories. Per type of compiler there 
 
219
is a distinct Makefile. They are called <TT>Makefile<I>.suffix</I></TT>.
 
220
The default make targets are in the file 
 
221
<A NAME="tex2html178"
 
222
 HREF="../../src/Makefile.GEN"><TT>Makefile.GEN</TT></A>
 
223
and 
 
224
it's included in the other Makefiles.
 
225
Before compiling TCM, make a symbolic link called <TT>Makefile</TT> to 
 
226
the Makefile of the desired compiler.
 
227
Each src-subdirectory has its own Makefile which is platform- and 
 
228
compiler-independent. If everything goes normal they need not
 
229
be changed when TCM is recompiled or ported.
 
230
 
 
231
<P>
 
232
The Makefile in the src directory has the following top-level targets:
 
233
<UL>
 
234
<LI><TT>make</TT> or <TT>make all</TT>. Compiles the entire distribution (default
 
235
compilation).
 
236
<LI><TT>make allx</TT>. Force compilation into a few executables (i.e. 
 
237
all diagram editors and all table editors are each compiled into a single 
 
238
executable). This is the default for <TT>g++</TT>. You can create the
 
239
needed symbolic links for the different editors with the 
 
240
script <A NAME="tex2html179"
 
241
 HREF="../../bin/linkx"><TT>$TCM_HOME/bin/linkx</TT></A>
 
242
<LI><TT>make ally</TT>. Force compilation into some more executables than
 
243
<TT>allx</TT>. Related tools such as all data view editors are compiled into 
 
244
one executable. The individual tools have to be soft links, that can be
 
245
made with the script <A NAME="tex2html180"
 
246
 HREF="../../bin/linky"><TT>$TCM_HOME/bin/linky</TT></A>
 
247
<LI><TT>make allz</TT>. Force compilation in which each editor is compiled
 
248
in a separate executable. This is the default for the Solaris CC compiler.
 
249
<LI><TT>make libs</TT>. Compiles all object libraries. These libraries
 
250
can be static or dynamic, depending on the compiler that is used.
 
251
<LI><TT>make staticlibs</TT>: make all static object libraries 
 
252
(the libXXX.a versions).
 
253
<LI><TT>make dynamiclibs</TT>: make all dynamic object libraries
 
254
(the libXXX.so versions).
 
255
<LI><TT>make clean</TT>. All object files in the source directories are removed.
 
256
<LI><TT>make depend</TT>. Create dependencies in the Makefiles.
 
257
You are advised to do a <TT>make depend</TT> for a <TT>make all</TT> when you 
 
258
compile TCM for the first time.
 
259
<LI><TT>make <I>library</I></TT>. Compile given library.
 
260
<LI><TT>make <I>tool</I></TT>. Compile given tool (only tool specific part,
 
261
not the libraries that it needs). So you have to type in
 
262
<TT>make dynamiclibs tgd</TT> when
 
263
you want to make TGD and the dynamic libraries that it needs.
 
264
</UL>
 
265
<P>
 
266
When a library is compiled, it will be moved to <TT>$TCM_HOME/lib</TT>
 
267
and when an executable is compiled it will be moved to <TT>$TCM_HOME/bin</TT>.
 
268
This means it will overwrite the old version.
 
269
 
 
270
<P>
 
271
Which default compilation is performed, depends on the kind of compiler that
 
272
is used. The Sun CC compiler, whose Makefile is <A NAME="tex2html181"
 
273
 HREF="../../src/Makefile.suncc">Makefile.suncc</A>, has <TT>make dynamiclibs allz</TT> as default and 
 
274
the GNU g++, whose Makefile is <A NAME="tex2html182"
 
275
 HREF="../../src/Makefile.gcc">Makefile.gcc</A>,
 
276
has <TT>make staticlibs allx</TT> as default.
 
277
 
 
278
<P>
 
279
 
 
280
<H1><A NAME="SECTION00820000000000000000">
 
281
7.2 Porting TCM</A>
 
282
</H1>
 
283
 
 
284
<P>
 
285
In principle, TCM can be ported to any Unix system that has X Windows, Motif 
 
286
and a C++ compiler that can handle templates. The easiest way is to copy 
 
287
and adapt an existing Makefile and Configuration file and then try 
 
288
to do a <TT>make clean</TT>, a <TT>make depend</TT> and then a <TT>make all</TT>.
 
289
 
 
290
<P>
 
291
Most of the source code is platform independent. Only at a few places
 
292
there are some Unix specific parts which are compiled conditionally. This is
 
293
indicated in the source code by for instance '#ifdef LINUX'. The Makefile 
 
294
compiles its targets with the <TT>-D</TT> flag (see the Config.tmpl file) for 
 
295
instance <TT>-DLINUX</TT>. The files that probably need some modification, 
 
296
because they use conditional compilation are: 
 
297
<A NAME="tex2html183"
 
298
 HREF="../../src/gl/system.c"><TT>gl/system.c</TT></A>, 
 
299
<A NAME="tex2html184"
 
300
 HREF="../../src/gl/link.c"><TT>gl/link.c</TT></A>, 
 
301
<A NAME="tex2html185"
 
302
 HREF="../../src/gl/util.h"><TT>gl/util.h</TT></A>
 
303
and 
 
304
<A NAME="tex2html186"
 
305
 HREF="../../src/ed/document.c"><TT>ed/document.c</TT></A>. The best thing 
 
306
to do before you port is to do some 
 
307
<TT>grep</TT>s on the sources to see what sources should maybe be changed when ported. 
 
308
For instance: <TT>grep SOLARIS ??/*[hc] ??/??/*[hc] ; grep LINUX ??/*[hc] ??/??/*[hc]</TT>
 
309
(do this in <TT>$TCM_HOME/src</TT>), will show what part of the sources
 
310
have things specific for Solaris and Linux.
 
311
 
 
312
<P>
 
313
Likewise, a few lines of code could be different for Motif and LessTif.
 
314
When TCM is compiled with LessTif then the compiler should be supplied with
 
315
the <TT>-DLESSTIF</TT> flag. In the source code you will find some <TT>#ifdef LESSTIF</TT>s.
 
316
 
 
317
<P>
 
318
 
 
319
<H1><A NAME="SECTION00830000000000000000">
 
320
7.3 G++ specific problems</A>
 
321
</H1>
 
322
 
 
323
<P>
 
324
The GNU C++ compiler g++ is somewhat limited in handling template classes.
 
325
GNU g++ does not implement a separate pass to instantiate template
 
326
functions and classes at this point; for this reason, it will not work,
 
327
for the most part, to declare your template functions in one file and
 
328
define them in another. The compiler will need to see the entire
 
329
definition of the function, and will generate a static copy of the
 
330
function in each file in which it is used.
 
331
G++ does not automatically instantiate templates defined in other
 
332
files. Because of this, code written for cfront will often produce
 
333
undefined symbol errors when compiled with g++. You need to tell g++
 
334
the file where they are defined. 
 
335
 
 
336
<P>
 
337
The solution for TCM was, when <TT>__GNUC__</TT> is defined, to include 
 
338
in <A NAME="tex2html187"
 
339
 HREF="../../src/gl/llist.c"><TT>gl/llist.c</TT></A>
 
340
the template 
 
341
declarations that you need from the
 
342
file <A NAME="tex2html188"
 
343
 HREF="../../src/gl/instances.h"><TT>gl/instances.h</TT></A>. u
 
344
Because different groups of editors need
 
345
different declarations, several files with instances are created in 
 
346
different source code directories and during compilation the needed 
 
347
file is copied to <TT>gl/instances.h</TT> and <TT>gl/llist.c</TT> is compiled 
 
348
and <TT>libglobal.a</TT> is generated again. The instance files contain not 
 
349
much more than declarations of template instances. This process is
 
350
controlled by the Makefiles. This solution only works with static linking 
 
351
of libglobal (because different libglobal libraries are needed by the 
 
352
executables). In principle the other libraries can be linked dynamically 
 
353
by <TT>g++</TT> This can be achieved by issuing the 
 
354
target: <TT>make semistaticlibs</TT>.
 
355
 
 
356
<P>
 
357
By the way, the List class is in the file <TT>gl/llist.[hc]</TT> because
 
358
the file name <TT>list.[hc]</TT> caused some strange name clashes while
 
359
using Sun CC compilers.
 
360
 
 
361
<P>
 
362
When you want to compile TCM with g++ on another system
 
363
(use version 2.7.2 or higher), then take 
 
364
<A NAME="tex2html189"
 
365
 HREF="../../src/Makefile.gcc"><TT>Makefile.gcc</TT></A>
 
366
as a 
 
367
basis for your Makefile and take a look in 
 
368
<A NAME="tex2html190"
 
369
 HREF="../../src/Config.tmpl_linux"><TT>Config.tmpl_linux</TT></A>
 
370
because on Linux the g++ compiler is used by default.
 
371
 
 
372
<P>
 
373
<HR>
 
374
<!--Navigation Panel-->
 
375
<A NAME="tex2html361"
 
376
 HREF="developersguidenode9.html">
 
377
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
 
378
<A NAME="tex2html358"
 
379
 HREF="TechDoc.html">
 
380
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
 
381
<A NAME="tex2html352"
 
382
 HREF="developersguidenode7.html">
 
383
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> 
 
384
<A NAME="tex2html360"
 
385
 HREF="developersguidenode1.html">
 
386
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>  
 
387
<BR>
 
388
<B> Next:</B> <A NAME="tex2html362"
 
389
 HREF="developersguidenode9.html">8. Wish List and</A>
 
390
<B> Up:</B> <A NAME="tex2html359"
 
391
 HREF="TechDoc.html">Toolkit for Conceptual Modeling</A>
 
392
<B> Previous:</B> <A NAME="tex2html353"
 
393
 HREF="developersguidenode7.html">6. Output Files</A>
 
394
<!--End of Navigation Panel-->
 
395
<ADDRESS>
 
396
<I>Henk van de Zandschulp</I>
 
397
<BR><I>2003-01-07</I>
 
398
</ADDRESS>
 
399
</BODY>
 
400
</HTML>