Subversion Repositories gelsvn

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 bj 1
 
2
 README, Andreas Bærentzen, December 2001
3
 
4
======================================================================
5
 
6
----------------------------------------------------------------------
7
1. INTRODUCTION
8
----------------------------------------------------------------------
9
 
10
In the following, I discuss the structure of the source code and how to
11
add new directories to the framework. 
12
 
13
The idea is that this framework should be a) simple to use and b) let 
14
people easily compile the same source code under various unix platforms.
15
A seperate configuration is kept for each combination of OS, architecture, 
16
and compiler. It is possible to specify targets release or debug.
17
 
18
Source files are compiled in build directories, and separate build 
19
directories are kept for each unique combination of 
20
 
21
os architecture compiler target
22
 
23
such as
24
 
25
Linux_i686_g++3_debug
26
 
27
this makes it easier to work in a heterogenous environment or to 
28
experiment with seperate compilers or just to switch between debug mode 
29
and optimized.
30
 
31
To see how to use the framework, you may skip to section 5.
32
 
33
----------------------------------------------------------------------
34
2. DIRECTORY STRUCTURE
35
----------------------------------------------------------------------
36
 
37
The directories under the root of the source tree (where you find this 
38
README) are
39
 
40
Libsrc     - Source code for libraries
41
Appsrc     - Source code for executables
42
doc        - Documentation
43
bin        - Executables
44
lib        - Libraries
45
makefiles  - As the name suggests, makefiles
46
 
47
Libsrc contains a number of subdirectories each of which represents a 
48
link library. Appsrc also contains subdirectories, however each of these
49
is supposed to contain source code for an executable.
50
 
51
----------------------------------------------------------------------
52
3. FILE NAMES
53
----------------------------------------------------------------------
54
 
55
source files are *.c or *.cpp depending on whether it is C or C++
56
header files are named *.h
57
 
58
----------------------------------------------------------------------
59
4. MAKEFILES
60
----------------------------------------------------------------------
61
 
62
Some defintions:
63
----------------
64
 
65
The PLATFORM is a string concatenation of the os cpu and compiler, e.g.
66
 
67
Linux_i686_g++
68
 
69
The TARGET is either `debug' or `release'
70
 
71
 
72
 
73
Make'ing from the source root
74
-----------------------------
75
 
76
Just typing
77
> make 
78
 
79
from the root of the source tree will cause first every library and
80
then every application to be remade. However, there are several
81
targets.
82
 
83
make lib       - make all libraries
84
 
85
make app       - make all applications
86
 
87
make clean     - clean all library directories and app directories.
88
                 this removes only files pertaining to the current
89
                 platform and target (release/debug). This also
90
                 removes generated libraries. 
91
 
92
make distclean - cleans and completely removes all build directories. 
93
 
94
make platform  - copies a template to OS_CPU_COMPILER.mk in the
95
                 makefiles directory
96
 
97
make makefiles - Find directories without makefiles and put some there.
98
                 If a directory without a makefile is found, the action
99
                 depends on whether the directory is subdirectory of 
100
                 Libsrc or Appsrc. Under Libsrc we put makefiles for 
101
                 creating libraries. Under Appsrc we put makefiles for
102
                 applications.
103
 
104
 
105
Make'ing in subdirectories
106
--------------------------
107
 
108
Go to a subdirectory of Libsrc, say Libsrc/somedir. 
109
Here you have the following options:
110
 
111
make lib
112
make clean
113
 
114
The former will rebuild all sourcefiles and put them in a library 
115
directory. The latter will remove all object and dependency files 
116
(but only for the current platform (e.g. Linux_i686_g++_debug) 
117
The default target is lib.
118
 
119
Go to a subdirectory of Appsrc, say Appsrc/somedir. 
120
Here you have the following options:
121
 
122
make app
123
 
124
will recompile the source files in the current directory and build the 
125
programs. This is the default target. When compiled, the application is
126
moved to ./bin
127
 
128
make force
129
 
130
does the same but tries first to recompile all libraries that the 
131
applications in somedir depend on. This is the safe way to recompile,
132
but it takes a few seconds more, so if you are sure the libraries are
133
up to date, just go make.
134
 
135
make clean
136
 
137
works like above. 
138
 
139
Makefiles in subdirectories under Appsrc should generally be edited.
140
When create by `make makefiles' the Makefile in Appsrc/somedir looks
141
like this 
142
 
143
PROGRAMS 	= prog1 prog2
144
OWN_LIBS 	= Lib1 Lib2
145
LIBS			= ${GLLIBS} ${XLIBS} -lm -lz -lexpat
146
 
147
Add something like this
148
 
149
PROGRAMS 	= prog1 prog2
150
OWN_LIBS 	= Lib1 Lib2
151
LIBS			= ${GLLIBS} ${XLIBS} -lm -lz -lexpat
152
 
153
where prog1 and prog2 are programs you wish to create. These must 
154
correspond to source files with the same name and suffix .cpp. In
155
other words, 
156
 
157
prog1.cpp 
158
prog2.cpp
159
 
160
must exist (and contain a main function)
161
 
162
Lib1 and Lib2 are libraries that must also be in the directory structure,
163
i.e. under Libsrc there are subdirectories 
164
 
165
Libsrc/Lib1
166
Libsrc/Lib2
167
 
168
the files in these subdirectories will be compiled and put in library 
169
files named libLib1.a under lib. More precisely it will be put here:
170
 
171
lib/PLATFORM_TARGET/
172
 
173
PLATFORM and TARGET are defined above. Another library directory are for
174
precompiled libraries whose source code is not a part of this tree. Put
175
such libraries here:
176
 
177
lib/PLATFORM/
178
 
179
this directory is created by 
180
 
181
make platform from the source root.
182
 
183
----------------------------------------------------------------------
184
5. CONFIGURATION
185
----------------------------------------------------------------------
186
 
187
When you add a new project to this framework, you should go through
188
the following steps:
189
 
190
Add directories for libraries under Libsrc. E.g. add 
191
 
192
mkdir Libsrc/somelib
193
 
194
Then add directories for applications:
195
 
196
mkdir Appsrc/someapp
197
 
198
Copy appropriate source files to these directories and then edit
199
 
200
makefiles/config.mk
201
 
202
to tell us which compiler to use (leave blank to use default) 
203
and to set the target to debug or release.
204
Finally, from the source root type 
205
 
206
make platform
207
 
208
Depending on your compiler you may now have to edit the makefile called
209
 
210
makefiles/PLATFORM.mk 
211
 
212
to set special compile flags. No go 
213
 
214
make makefiles
215
 
216
Finally you are all set. Go
217
 
218
make
219
 
220
 
221
----------------------------------------------------------------------
222
6. TODO
223
----------------------------------------------------------------------
224
 
225
- No real testing of blended C and C++.
226
- No dependency computation for .c 
227
 
228
 
229
 
230
 
231
 
232