-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.overclocked
269 lines (176 loc) · 9.72 KB
/
README.overclocked
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
~ Overclocked Build Framework ~
v1.2
--- Copyright (c) 2014, Blunt Jackson ---
Welcome. This is an effort to take make to the limits, support multiple projects
of various sizes across, potentially, multi-language builds. We don't claim that
it does any of this particularly well, or that it will be useful for you, but it
gets the job done for some applications and projects. This system is free to use
and modify without restriction. It may also be redistributed without restriction
whether changed or not. Hell, if anyone thinks it's that useful, I'll be amazed.
--------------------------------------------------------------------------------
DOCUMENTATION
--------------------------------------------------------------------------------
+-------------------------------------+
| 0. ToDo List |
+-------------------------------------+
( ) Better dependency tracking
( ) Better structure for unit tests
( ) Infrastructure for third party dependency resolving
( ) Multi-platform control over linking methologies
( ) How about more languages???
+-------------------------------------+
| 1. Directory Structures |
+-------------------------------------+
Dir Summary:
<root_dir> the top level directory of the project.
<root_dir>/src contains all source code
<root_dir>/src/<Family> clusters modules
<root_dir>/src/<Family>/<Module> the basic compilation unit.
<root_dir>/bin contains executable applications & scripts
<root_dir>/bin/<Project> executable applications clustered by project
<root_dir>/lib contains compiled libraries, optionally
organized by namespace
<root_dir>/include contains header files, org's by project or
namespace
<root_dir>/build/<Module> build-space for modules.
<root_dir>/docs for any additional documentation
<install_base> the root directory for installation.
Concept Summary:
Family: a basic aggregation of related modules. Can be useful
for defining single projects, or for keeping levels
of dependency clear in large applications.
Module: the basic build unit. One directory full of source code
is one module. Modules result in libraries or applications.
Project: Possibly Orthogonal to Family, a project may require a
a set of modules from multiple families (or it may be one
family). Projects are useful for designing distinct
distributions when multiple applications may arise from
the same build environment.
+-------------------------------------+
| 2. Build Conventions |
+-------------------------------------+
a. All source files are aggregated into 'Families' and 'Modules'
organized in the following directory hierarchy:
<root_dir>/<src_dir>/<Family>/<Module>
b. The basic unit of compilation is a Module, which represents one
library, application, or cluster of applications
c. Families are used to aggregate similar types of modules,
house large projects, and keep the src_dir from becoming too
cluttered.
d. Header files are built into the following structure:
<root_dir>/include
Unless you override the INCLUDE_DIR variable in local makefiles,
header files from other modules should be referenced like so in source:
#include "myheader.h"
Optionally, you may define a namespace which will place the header files
one directory down, e.g.:
NAMESPACE := myproj
<root_dir>/include/myproj
#include "myproj/myheader.h"
e. All modules are built in the following build space:
<root_dir>/build/<Module>
This space is considered private to each module.
f. Complete libraries are "published" into the following:
<root_dir>/lib/
g. Compiled applications are "published" into either of the following:
<root_dir>/bin/
<root_dir>/bin/<Project>
The former is the default behavior;
The latter may be obtained by defining PROJECT in an
application level Makefile.
h. Published applications and scripts will be installed (via make install)
into either of the following:
<install_base>
<install_base>/<Project>
+-------------------------------------+
| 3. Configuring Modules |
+-------------------------------------+
a. Libraries
In the Module Makefile, define:
COMPILE_MODE = lib
The compiled results will be a .so and a .a library file in the
archive directory ( <root_dir>/lib ) for C or C++ code, and a
jar file for Java code in the same location.
If you only require a .so file, define: ONLY_SHARED = 1
If you only require a .a file, define: ONLY_ARCHIVE = 1
If the library publishes header files, define:
PUBLIC_HEADERS = first_header.h second_header.h etc.
You do not have to include header files that are not intended for
use by consumers of the library.
To define the source code that builds the library, define:
OBJECT_SOURCES = first_source.cpp second_source.cpp etc.
If you are using lex/yacc facilities, the .l and .y files should
have the same base filename, and you should define:
LYOBJ = my_parser
In this example, your source would be my_parser.l & my_parser.y
To define unit-tests, define:
TEST_SOURCES = test-app-one.cpp test-app-two.cpp
Each test source should include a standard 'main' and will be used
to create a separate testing application. Each test application will
be executed after it is built. If the test application fails,
compilation will said to fail. If TEST_SOURCES are defined, then
a link line should be provided as well:
LOCAL_LIBS = -lmodule -lother
THIRD_PARTY_LIBS = -lpthread -lz
Note that THIRD_PARTY_LIBS is optional, only to be used if needed.
LOCAL_LIBS should, minimally, include the archive that is built
as a target of this module. Unit tests assume static linking.
b. Applications
In the Module Makefile, define:
COMPILE_MODE = app
The compiled application will be published to <root_dir>/bin
*unless* PROJECT is defined, eg:
PROJECT = test-app
... in which case the final app(s) will be in <root_dir>/bin/test-app
Projects may contain multiple levels of directories.
An Application Module may include scripts that will be copied
to the target bin directory and/or installed to the destination
location. Each script should be included in the SCRIPTS list:
SCRIPTS = scan-for-files.pl matrix-stuff.php
An Application Module may build one or more applications. Each
application should have a source .cpp or .c file defined:
APP_SOURCES = app_one.cpp app_two.cpp
Each APP_SOURCE file should include a standard main. This example
would result in two applications: 'app_one' and 'app_two'
An Application Module may additionally have local support files
that are included when compiling the application. Define these
like so:
OBJECT_SOURCES = common_one.cpp common_two.cpp
The object file resulting from support sources will be included
when building each application in the module.
Applications that are linked against libraries should include the
link line definitions, as described for unit tests, eg:
LOCAL_LIBS = -lmodule_one -lmodule_two
THIRD_PARTY_LIBS = -lmysql-client -lz
If you want to specify extra directories to search for third
party libraries, add this (eg):
EXTRA_LINK_DIRS = /home/user/third-party/package/lib
Applications are statically linked by default. If you want dynamic
linkage, add:
LINK_DYNAMIC = 1
c. All Makefiles, additional notes
i. Flags. All Module Makefiles may additionally specify flags
controlling compilation. These will *override* those in the
common.make, so if used, should be comprehensive.
COMP_FLAGS = common compilation flags used regardless of
language being compiled. (Note: the following
may be set in Module Makefiles to *add* to the
standard comp flags: ADDTL_FLAGS
CPP_FLAGS = flags specific to C++ compilation.
C_FLAGS = flags specific to C compilation.
LINK_FLAGS = flags to the linker
D_FLAGS = flags to the preprocessor -- added to defaults in
common.make, ie., not a replacement.
ii. Include. Each Module Makefile must include (generally as the last
thing in the Makefile) common.make, like so:
include ../../common.make
iii. Module Makefiles may, if necessary, define additional custom
targets. Generally, this should be done *after* the include,
particularly if this target will make use of any of the
structures defined in common.make
iv. The target 'post' may be defined in Module Makefiles to provide
additional post compilation functionality. 'post' will be
undertaken after all compilation and linking is finished.
--------------------------------------------------------------------------------
All programmers are playwrights and all computers are lousy actors. --Anonymous
--------------------------------------------------------------------------------