]> rtime.felk.cvut.cz Git - omk.git/blob - doc/omk-manual.texinfo
Whitespace and copyright
[omk.git] / doc / omk-manual.texinfo
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename omk-manual
4 @documentencoding UTF-8
5 @settitle OMK: Ocera Make System
6 @c %**end of header
7
8 @copying
9 Manual for Ocera Make System (OMK) version @include .version
10
11 Copyright @copyright{} 2007, 2008, 2009, 2010, 2011, 2013 Michal Sojka, Pavel Pisa
12 @end copying
13
14 @titlepage
15 @title Ocera Make System Manual
16 @page
17 @vskip 0pt plus 1filll
18 @insertcopying
19 @end titlepage
20
21 @contents
22
23 @ifnottex
24 @node Top, Overview, (dir), (dir)
25 @top Ocera Make System
26
27 @insertcopying
28 @end ifnottex
29
30
31 @menu
32 * Overview::
33 * User's Manual::
34 * Original README::
35 * Development::
36 * Variable Index::
37 @end menu
38
39 @node Overview, User's Manual, Top, Top
40 @chapter Overview
41 @cindex overview
42
43 OMK is an advanced make system written entirely in GNU make. Compiling
44 software using OMK requires only GNU Make and standard UNIX
45 utilities (@command{sh}, @command{sed}, @command{cmp}, ...)
46 installed. OMK aims to be developer friendly; to use OMK, you do not
47 need to understand (sometimes) cryptic syntax of Makefiles.
48
49 You can use OMK on all platforms where you can run GNU Make including
50 Cygwin and MinGW. MS DOS was not tested.
51
52 @c @section Features
53
54 @c @itemize
55 @c @item
56 @c Easy to use for beginners.
57 @c @item
58 @c Automatic handling of dependencies.
59 @c @item
60 @c Supported host platforms: all Un*x operating system including Linux,
61 @c Cygwin, MS DOS and maybe others.
62 @c @end itemize
63
64 @menu
65 * Why to Use OMK?::
66 * Quick Start::
67 * History::
68 @end menu
69
70 @node Why to Use OMK?, Quick Start, Overview, Overview
71 @section Why to Use OMK?
72
73 Here we list some of OMK features, which we think are important for
74 choosing of a make system.
75
76
77 @itemize
78 @item
79   Makefile in source directories are usually very @b{simple}.
80 @item
81   There is only @b{one} @file{Makefile.rules} for most of components of
82   a bigger project.
83 @item
84   OMK greatly simplifies compilation of projects, where source files are
85   spread between @b{multiple directories}.
86 @item
87   OMK handles properly @b{dependencies} of source files and libraries,
88   so it is not necessary to recompile the whole project if only several
89   files changed.
90 @item
91   OMK allows to freely @b{move} cross-dependant components @b{in
92   directory structure} without the need to update users of moved
93   component. I hate something like
94   @option{-I../../sched/rtlshwq/include} in makefiles for example. If a
95   component is renamed or version is added to the name, many Makefiles
96   in the project would require an update.
97 @item
98   The above feature is very helpful in @b{combining components}
99   (libraries) from different projects/developers to a single project by
100   simply creating symbolic links to external components.
101 @item
102   Compilation of an OMK based projects don't require to install any
103   files before successful finish of build.
104 @item
105   OMK allows to call @command{make} for a particular subdirectory in the
106   source tree.
107 @item
108   Under OMK all products of compilation are stored @b{out of source
109   directories}. This simplifies work with version control systems and
110   helps when simultaneous compilation for multiple targets/platforms is
111   needed.
112 @end itemize
113
114
115
116
117 @node Quick Start, History, Why to Use OMK?, Overview
118 @section Quick Start
119
120 If you get some sources, which are distributed with OMK, usually the
121 following commands are sufficient to compile the whole project.
122
123 @example
124 @verbatim
125 make default-config
126 make
127 @end verbatim
128 @end example
129
130 @noindent To use OMK in your own project, follow these steps:
131
132 @enumerate
133 @item
134   The newest version of OMK can be found at @uref{http://rtime.felk.cvut.cz/omk/}.
135 @item
136   Take appropriate @file{Makefile.rules} (see @ref{Properties of
137   Specific Makefile.rules}), put it together with leaf @file{Makefile}
138   to the root directory of your project.
139 @item
140   Create @file{Makefile.omk} files in all directories you want to
141   compile something. Please refer to @ref{User's Manual} to learn
142   what to write in @file{Makefile.omk} files.
143 @item
144   Run @command{make omkize} in the root directory.
145 @end enumerate
146
147 @noindent Your project is now ready to compile.
148
149
150 @node History,  , Quick Start, Overview
151 @section History
152
153 OMK was originally written by Pavel Píša as a solution to have one
154 common make system for OCERA project, where we needed to compile
155 user-space programs, Linux kernel modules and RT Linux modules in one
156 package. Although this system was not accepted for the whole OCERA
157 project. Several individual developers (mostly from Czech Technical
158 University) liked it and started to use it.
159
160 As a number of projects using OMK grew it was necessary to modularize
161 the make system to support more ``targets''. Michal Sojka took care
162 about the process of modularization.
163
164 @node User's Manual, Original README, Overview, Top
165 @chapter User's Manual
166
167 @menu
168 * Basic Concepts::
169 * Invoking OMK::
170 * Compiling Programs::
171 * Compiling Libraries::
172 * Recursing into Subdirectories::
173 * Dependency Tracking::
174 * Configuration and Conditional Compilation::
175 * Advanced OMK Features::
176 * Properties of Specific Makefile.rules::
177 * Running OMK under Windows OS::
178 * Interfacing OMK to popular IDEs::
179 * Troubleshooting::
180 @end menu
181
182 @node Basic Concepts, Invoking OMK, User's Manual, User's Manual
183 @section Basic Concepts
184
185 The main concept of OMK is very simple. In the root directory of the
186 projects resides a file called @file{Makefile.rules}. This file contains
187 all compilation rules needed for compilation of a particular
188 project. There are different @file{Makefile.rules} for different
189 platforms (Unix, RTEMS, system-less, ...). In every subdirectory a
190 @file{Makefile.omk} is stored. This file determines what should be done
191 in the respective directory (e.g. compile a program from several source
192 files). Its syntax is very simple -- see the following sections.
193
194 Since make searches by default for a @file{Makefile} and not for
195 @file{Makefile.rules} or @file{Makefile.omk}, there must@footnote{When
196 USE_LEAF_MAKEFILES is set to @samp{n}, this @file{Makefile} can be
197 omitted in subdirectories. @xref{USE_LEAF_MAKEFILES}.} be a small
198 generic @file{Makefile} in every directory, whose task is only to find
199 @file{Makefile.rules} in the actual or any parent directory and include
200 it. This search is performed only once at the beginning of compilation.
201
202 @c TODO: Pavel's note about qmake.
203
204 @anchor{passes}
205 The compilation process itself is comprised of several @emph{passes}. Every
206 pass traverses the whole directory structure@footnote{In future, we are
207 planning some optimization that allows OMK to traverse the directories
208 only once and thus decrease compilation time.} and does a particular
209 task in every directory of the project. Typically, these passes are:
210 @table @dfn
211 @anchor{include-pass}
212 @item include-pass
213     This pass takes all include files marked for ``export'' and copies
214     (or links) them to the @file{include} directory under
215     @file{_compiled} directory. @xref{Header Files}.
216
217     Also, during this pass, automatically generated header file are
218     generated according to the current
219     configuration. @xref{Configuration and Conditional Compilation}.
220 @item library-pass
221     During this pass, all include files are in place, so all libraries
222     can be compiled.
223 @item binary-pass
224     Finally, programs can be compiled and linked against libraries
225     created in the previous pass.
226 @end table
227
228 The results of compilation are stored under the @file{_compiled}
229 directory. This directory is structured as a classical Unix file-system
230 (it contains directories like @file{bin}, @file{lib} and @file{include})
231 and can be directly copied to the target device or to some directory on
232 a host computer (e.g. @file{/usr/local}).
233
234 Besides @file{_compiled} directory, there in a @file{_build}
235 directory. Under this directory are stored some temporary files and
236 intermediate compilation products (object files, dependency files etc.).
237
238 In the next section, we provide an overview of methods, how to invoke
239 OMK from command line. Section @ref{Interfacing OMK to popular IDEs}
240 covers running of OMK from popular IDEs.
241
242 Sections @ref{Compiling Programs} through @ref{Configuration and
243 Conditional Compilation} deals with the content of
244 @file{Makefile.omk}. Its syntax in usual cases compatible to GNU
245 Automake's @file{Makefile.am} syntax. Also, the scheme for naming
246 variables was inspired by Automake so most OMK variables have the name
247 like @samp{@var{target}_@var{TYPE}}.
248
249 @node Invoking OMK, Compiling Programs, Basic Concepts, User's Manual
250 @section Invoking OMK
251
252 Before using OMK for the first time, you have to call:
253 @example
254 @command{make default-config}
255 @end example
256 @noindent See @ref{Configuration and Conditional Compilation} for
257 details. If you forget to do this, OMK will notice you.
258
259 To compile the whole project or only some subtree of the project, call
260 @example
261 @command{make}
262 @end example
263 @noindent in the appropriate directory.
264
265 To clean files in @file{_build} directory but not in @file{_compiled}
266 one, use:
267 @example
268 @command{make clean}
269 @end example
270
271 To clean the compilation completely, you can either remove
272 @file{_compiled} and @file{_build} directories manually, or call
273 @example
274 @command{make distclean}
275 @end example
276 @noindent which does the same. This command removes these directories
277 even if you call it from a subdirectory.
278
279 To debug compilation problems, you can use @code{V} variable (see
280 @ref{V}):
281 @example
282 @command{make V=1}
283 @end example
284
285 You can also set values of some other variables on command line for
286 temporary change something. The example below compiles the code
287 temporarily with debugging information:
288 @example
289 @command{make CFLAGS="-g -O0 -Wall"}
290 @end example
291
292 If your project uses an alternative make-system (e.g. Automake or custom
293 makefiles), it might be useful for you to use the command:
294 @example
295 @command{make omkize}
296 @end example
297 @noindent This will find all @file{Makefile.omk} files in all subdirectories
298 and copies generic @file{Makefile} from the root directory to that
299 subdirectories. This way you can easily switch your project to use OMK.
300
301
302
303 @anchor{V}
304 @defvar V
305 If this variable equals to @samp{1}, the whole command lines for all
306 executed commands are displayed. When not set or zero, only short
307 messages are printed. Value of @samp{2} displays the whole command lines
308 as with @samp{1} and in addition directory navigation messages are
309 printed.
310 @end defvar
311
312 @node Compiling Programs, Compiling Libraries, Invoking OMK, User's Manual
313 @section Compiling Programs
314
315 To tell OMK to compile a program, you need to set some variables in
316 @file{Makefile.omk} (usually) in the directory where program sources are
317 located.
318
319 In the example bellow a program @command{test} will be compiled from
320 source @file{test.c}.
321
322 @example
323 @verbatiminclude tests/programs/Makefile.omk
324 @end example
325
326 @noindent The variables are:
327
328 @anchor{bin_PROGRAMS}
329 @defvar bin_PROGRAMS
330   Contains a list of names (whitespace separated) of programs to be
331   compiled in this directory.
332 @end defvar
333
334 @anchor{test_PROGRAMS}
335 @defvar test_PROGRAMS
336   Almost the same as @ref{bin_PROGRAMS}, but resulting binaries are
337   stored in @file{bin-tests} directory instead of @file{bin}. This
338   variable is intended for various test programs not to be mixed with
339   the final product.
340 @end defvar
341
342 @defvar utils_PROGRAMS
343   Almost the same as @ref{bin_PROGRAMS}, but resulting binaries are
344   stored in @file{bin-utils} directory instead of @file{bin}. This
345   variable is intended for various development utilities not to be mixed
346   with the final product.
347 @end defvar
348
349 @defvar xxx_SOURCES
350   For every program name @var{xxx} in @code{bin_PROGRAMS},
351   @code{test_PROGRAMS} or @code{utils_PROGRAMS}, this variable contains
352   a list of sources that are needed to compile the program. OMK uses an
353   extension of the filename to determine the compiler to compile this
354   source.
355 @end defvar
356
357 @defvar xxx_LIBS
358   This variable contains a list of libraries the program @var{xxx} will
359   be linked with.
360
361   @example
362   test_LIBS = m curses
363   @end example
364 @end defvar
365
366 @defvar lib_LOADLIBES
367   This variable contains a list of libraries which needs to be linked to
368   to all programs or shared libraries in this directory.
369 @end defvar
370
371 @defvar LOADLIBES
372   This variable contains a list linker switches to load additional
373   libraries. You usually specify here -L and -l switches.
374
375   Note: The value of this variable is not used used by OMK for any purpose
376   other than linker invocation. Therefore dependency handling of shared
377   libraries does not work if the library is specified in LOADLIBES
378   instead of lib_LOADLIBES.
379 @end defvar
380
381 @defvar INCLUDES
382   Directives passed to the C or C++ compiler with additional directories
383   to be searched for header files. In most cases you need to specify an
384   absolute path. To specify a directory relative to the source
385   directory, you can use the @code{$(SOURCES_DIR)} variable, which
386   refers to the directory, where @file{Makefile.omk} is located. This
387   variable applies to all compilations invoked in the current directory.
388
389   @example
390   INCLUDES = -I$(SOURCES_DIR)/my_include_dir
391   @end example
392 @end defvar
393
394 @defvar DEFS
395   Directives passed to the C or C++ compiler with preprocessor macro
396   definitions. This variable applies to all compilations invoked in the
397   current directory.
398
399   @example
400   DEFS = -DDEBUG=1
401   @end example
402 @end defvar
403
404
405 @c FIXME: INCLUDES variable should not be set by rtlinux rules.
406
407 @node Compiling Libraries, Recursing into Subdirectories, Compiling Programs, User's Manual
408 @section Compiling Libraries
409
410
411 With OMK, you can easily create statically or dynamically linked
412 libraries. The way of creating libraries is very similar to how programs
413 are created. @xref{Compiling Programs}.
414
415 In @file{Makefile.omk}, you specify several variables, which defines how
416 the libraries should be compiled. In the example below the library
417 @samp{mylib} (full filename will be @file{libmylib.a}) is created from
418 two sources @file{funca.c} and @file{funcb.c}. Interface of this library
419 is defined in @file{myfunc.h}. Therefore, we export this header for use
420 by other programs.
421
422 @example
423 @verbatiminclude tests/libraries/Makefile.omk
424 @end example
425
426 @noindent Variables for use with libraries are:
427
428 @defvar lib_LIBRARIES
429   Specifies a list of statically linked libraries to be compiled. OMK
430   automatically prepends @code{lib} prefix library names.
431 @end defvar
432
433 @defvar shared_LIBRARIES
434   Specifies a list of dynamically linked libraries to be compiled.
435 @end defvar
436
437 @defvar xxx_SOURCES
438   For every library name @var{xxx} in @code{lib_LIBRARIES} or
439   @code{shared_LIBRARIES}, this variable contains a list of sources that
440   are needed to compile the library. OMK uses an extension of the
441   filename to determine the compiler to compile this source.
442 @end defvar
443
444 @menu
445 * Header Files::
446 @end menu
447
448 @node Header Files,  , Compiling Libraries, Compiling Libraries
449 @subsection Header Files
450
451 C and C++ libraries are not very useful without header files. OMK
452 provides several variables that controls operations with header files.
453
454 During compilation, header files are copied (or linked by symbolic
455 links) from source directories to the @file{_compiled} tree (see
456 @ref{include-pass}). Libraries and programs are then compiled against
457 these copies. The following variables control which headers are copied
458 and what is their destination file name.
459
460 @anchor{include_HEADERS}
461 @defvar include_HEADERS
462   Specifies the list of header files to be exported for use by other
463   libraries/programs. The files are exported directly to the
464   @file{include} directory even if the file is located in a subdirectory
465   (like @file{sci_regs.h} in the example below)
466
467   @example
468   include_HEADERS = regs.h periph/sci_regs.h
469   @end example
470 @end defvar
471
472 @defvar nobase_include_HEADERS
473   Similar to @ref{include_HEADERS}, but the directory prefix is always
474   kept. To include the file exported by this variable, use
475   @code{#include <@var{prefix}/@var{header.h}>}.
476 @end defvar
477
478 @defvar renamed_include_HEADERS
479   Exports the header files under different name. The form of the items
480   in this whitespace separated list is: @var{real name}@code{->}@var{new
481   name}.
482
483 @example
484   renamed_include_HEADERS = orte_config_omk_win32.h->orte_config.h
485 @end example
486 @end defvar
487
488 @defvar LN_HEADERS
489   If this variable equals to @samp{y}, symbolic links to headers in
490   source directories are used in @file{_compiled} tree instead of
491   copies.
492
493   Normally, the header files are copied into @file{_compiled} directory
494   to be prepared for transfer into target location afterwards. Copying
495   ensures that resulting libraries are in correspondence with the header
496   files even if the header is changed by a developer but the library is
497   not recompiled.
498
499 @c   Another reason for having single include directory for the whole
500 @c   project is tat every component knows where to find header files of
501 @c   other components.
502
503   On the other side, the copying could make problems during
504   development. Most @acronym{IDE}s, allows you to jump directly to the
505   place, where an error is reported by the compiler. If the error is in
506   a header file, IDE opens you the copy of the header file. If you
507   correct the error there, after the next compilation, your header file
508   will be overwritten by the old version from your source tree.
509
510   This option is not typically used in @file{Makefile.omk}, but in the
511   top level configuration file @file{config.omk} or on command line.
512 @end defvar
513
514 @node Recursing into Subdirectories, Dependency Tracking, Compiling Libraries, User's Manual
515 @section Recursing into Subdirectories
516
517 OMK is probably most useful in projects consisting of multiple
518 directories. For such projects, it is not easy to write from scratch
519 classic Makefiles that provides all the needed features.
520
521 You can instruct OMK to descend to a (sub)directory by setting the
522 @code{SUBDIRS} variable in @file{Makefile.omk}.
523
524 @anchor{SUBDIRS}
525 @defvar SUBDIRS
526   This variable contains a list of directories, in which compilation
527   must be also invoked. Usually, names of subdirectories are used, but
528   you can use any path specification here.
529
530   Compilation is invoked in these directories before it is invoked in
531   the current directory.
532
533   See also @ref{AUTOMATIC_SUBDIRS}.
534 @end defvar
535 @c TODO: Write tests for this.
536
537 @anchor{ALL_OMK_SUBDIRS}
538 @defvar ALL_OMK_SUBDIRS
539   This variable is set by OMK and can be used as the value of
540   @code{SUBDIRS} variable. It contains a list of all direct
541   subdirectories, which contain @file{Makefile.omk}. This is especially
542   useful if you are combining several projects or components
543   together. In the root directory of your project, you just create
544   symbolic links the components from other projects and all the linked
545   directories automatically appears as the value of this variable.
546
547   @example
548   SUBDIRS = $(ALL_OMK_SUBDIRS)
549   @end example
550 @end defvar
551
552 @anchor{AUTOMATIC_SUBDIRS}
553 @defvar AUTOMATIC_SUBDIRS
554   If this variable is set to @samp{y} and @code{SUBDIRS} is not assigned
555   in @file{Makefile.omk}, then @code{SUBDIRS} is assigned a default
556   value @code{$(ALL_OMK_SUBDIRS)}.
557 @end defvar
558
559 @node Dependency Tracking, Configuration and Conditional Compilation, Recursing into Subdirectories, User's Manual
560 @section Dependency Tracking
561
562 OMK automatically tracks dependencies of files in the project.
563 Dependencies of object files are produced with gcc's @option{-M@var{x}}
564 options. This means that whenever a header file is changed, OMK
565 recompiles only those files, which included that file.
566
567 Dependencies are also maintained for libraries and binaries. To find the
568 dependencies, OMK parses linker map files, so a change to some library
569 causes relinking of all programs using that library.
570
571 @node Configuration and Conditional Compilation, Advanced OMK Features, Dependency Tracking, User's Manual
572 @section Configuration and Conditional Compilation
573
574 In many projects, it is necessary to configure the compilation process. By
575 this configuring we mean, setting some parameters that influence the
576 output of compilation process. In GNU projects, @command{configure}
577 script is usually responsible for configuration. User provides some
578 parameters to @command{configure}, which is run before compilation, and
579 this script does all steps needed to configure the sources and
580 make-system in the desired way.
581
582 OMK has its own configuration mechanism, which is described in this
583 section. For future releases, we plan that this mechanism can make use
584 of GNU Autoconf, but currently there is no directly integrated support
585 for it.
586
587 There exist three different configuration files
588 @file{config.omk-default}, @file{config.target} and
589 @file{config.omk}. All of these have to be stored in the same directory
590 as @file{Makefile.rules}. During compilation, these files are included
591 in @file{Makefile.rules} in this order which means that variables
592 assigned in the former files are overridden by those from later
593 ones. All settings specified here apply to the whole compilation
594 tree. Each file is intended for a different kind of configuration
595 values:
596 @table @file
597 @item config.omk-default
598   Stores default configuration of compiled components. This file is
599   automatically generated (see below) and should not be edited by users.
600 @item config.target
601   Stores default configuration for a project or target hardware. This
602   file is intended to be stored in a version control system and should
603   be modified only by the maintainer of the project.
604
605   For cross compiled projects, this file typically contains settings of
606   variables like @var{CC} and @var{CFLAGS}.
607 @item config.omk
608   This is a file for end users, where any default settings set in the
609   above files can be overridden. This file should not be stored in
610   version control system. The project should compile without having this
611   file.
612 @end table
613
614 Besides variables defined in @file{config.target}, @file{Makefile.omk}
615 in any subdirectory can specify some configuration parameters. When
616 @command{make default-config} is run, all these parameters are found and
617 together with their default values are stored as makefile variables in
618 @file{config.omk-default}. This file is included during compilation, so
619 if you don't specify other values, these defaults are used. If you are
620 not satisfied with these defaults, you can override the values of
621 parameters either locally for your build in @file{config.omk} or
622 globally for all people working with the project in
623 @file{config.target}.
624
625 @menu
626 * Specifying Configuration Parameters::
627 * Using Configuration Parameters::
628 * Common Variables::
629 @end menu
630
631 @node Specifying Configuration Parameters, Using Configuration Parameters, Configuration and Conditional Compilation, Configuration and Conditional Compilation
632 @subsection Specifying Configuration Parameters
633
634 To specify names and default values of configuration parameters use the
635 @code{default_CONFIG} variable in @file{Makefile.omk}.
636
637 @defvar default_CONFIG
638   This variable contains a list of configuration parameters and their
639   default values. The format of every item in this list is
640   @var{CONFIG_xxxx}=@var{value}. You can name the parameter as you want,
641   but it is good practice to start the name with @samp{CONFIG_} prefix.
642
643   OMK can automatically generate header files, with C preprocessor macro
644   definitions according to the OMK's configuration parameters. The
645   actual content of generated header files depends on the form of the
646   @var{value}. The possible forms are:
647
648 @table @code
649 @item @samp{y}, @samp{n} or @samp{x}
650   This defines boolean parameters. If the value of the parameter is
651   @samp{y}, the @samp{#define CONFIG_@var{xxx} 1} is generated, if it is
652   @samp{n}, no @code{#define} is generated.
653
654   @samp{x} is a special value called @emph{recessive 'n'}. The meaning
655   is that this parameter influences the component in the current
656   directory (i.e. the corresponding @code{#define} will be included in
657   @code{LOCAL_CONFIG_H}; see @ref{LOCAL_CONFIG_H}) but the default value
658   is not specified here. If the default value is not specified anywhere,
659   the behavior is the same as if @samp{n} is specified.
660 @item @samp{number}
661   Numeric parameters. The define looks like @samp{#define CONFIG_@var{xxx} @var{number}}
662 @item @samp{text}
663   Text without quotes. The define looks like @samp{#define CONFIG_@var{xxx} @var{text}}
664 @item @samp{"text"}
665   Text with quotes. The define looks like @samp{#define CONFIG_@var{xxx} "@var{text}"}
666 @end table
667 @end defvar
668
669 @noindent Example of using @code{default_CONFIG}. @file{Makefile.omk} reads like:
670 @example
671 @verbatiminclude tests/default-config/Makefile.omk
672 @end example
673 @noindent and @file{subdir/Makefile.omk} like:
674 @example
675 @verbatiminclude tests/default-config/subdir/Makefile.omk
676 @end example
677
678 @noindent After running @command{make default-config}, the content of
679 @file{config.omk-default} will be:
680 @example
681 @verbatiminclude tests/default-config/config.omk-correct
682 @end example
683
684 @node Using Configuration Parameters, Common Variables, Specifying Configuration Parameters, Configuration and Conditional Compilation
685 @subsection Using Configuration Parameters
686
687 Configuration parameters can be used in two ways:
688 @enumerate
689 @item
690   as variables in @file{Makefile.omk} and
691 @item
692   as C/C++ preprocessor macros in OMK generated header files.
693 @end enumerate
694
695 @noindent For the first use, your @file{Makefile.omk} may contain something like:
696 @example
697 SUBDIRS = arch/$(CONFIG_ARCH)
698
699 ifeq ($(CONFIG_DEBUG),y)
700 DEFS += -DUSE_SIMULATOR
701 endif
702 @end example
703
704 @noindent For the second use, there are several variables that control
705 the generation of header files with configuration values. These
706 variables are described here:
707
708 @anchor{LOCAL_CONFIG_H}
709 @defvar LOCAL_CONFIG_H
710   The value of this variable is the name of a header file, which will
711   contain all configuration parameters declared in the current directory
712   by @code{default_CONFIG}. This header file is accessible only by files
713   in the current directory and it should be included like @code{#include
714   "@var{myconfig.h}"}.
715
716   In @file{Makefile.omk}, the use of this variable can look like this:
717
718 @example
719 LOCAL_CONFIG_H = myconfig.h
720 @end example
721 @end defvar
722
723 @defvar config_include_HEADERS
724   This variable is similar to @code{LOCAL_CONFIG_H}. One difference is
725   that the generated header file is accessible to all sub-projects in
726   all directories, not only to the files in the same directory (the
727   header is stored in @file{_compiled} tree). The second difference is
728   that you have to specify, which configuration parameters you want to
729   appear in the header file.
730 @end defvar
731
732 @defvar xxx_DEFINES
733   This variable determines the configuration parameters that should be
734   stored in a header file specified by
735   @code{config_include_HEADERS}. The @var{xxx} in the name of this
736   variable needs to be the same as the base name (without extension) of
737   the header file.
738 @end defvar
739
740 @noindent Example of using @code{config_include_HEADERS}:
741 @example
742 default_CONFIG = CONFIG_LINCAN=y CONFIG_LINCANRTL=n CONFIG_LINCANVME=n
743 config_include_HEADERS = global.h
744 global_DEFINES = CONFIG_OC_LINCAN CONFIG_OC_LINCANRTL
745 @end example
746
747 @noindent Here, we include only two out of the three configuration
748 parameters defined in the current @file{Makefile.omk}. It is also
749 possible to include configuration parameters defined in a different
750 directory.
751
752 @node Common Variables,  , Using Configuration Parameters, Configuration and Conditional Compilation
753 @subsection Common Variables
754
755 It is common practice to use @file{config.target} or @file{config.omk}
756 to store project-wide settings. Here is the list of variables, which are
757 commonly set here (but they can also be set elsewhere, e.g. in
758 @file{Makefile.omk}).
759
760 You can easily ``reconfigure'' your project by changing the
761 @file{config.omk} file. It is useful to have several configurations
762 stored in different files and let @file{config.omk} be a symbolic link
763 to the desired configuration.
764
765 @vtable @code
766 @item CC
767   The name of C compiler.
768 @item CFLAGS
769   Command line options for C compiler.
770 @item CXX
771   The name of C++ compiler.
772 @item CPPFLAGS
773   Additional parameters (besides @code{CFLAGS}) to by passed to C++
774   compiler.
775 @end vtable
776
777 @node Advanced OMK Features, Properties of Specific Makefile.rules, Configuration and Conditional Compilation, User's Manual
778 @section Advanced OMK Features
779
780 In this section we list several OMK features, which are more complicated
781 or rarely used so they were omitted in previous sections.
782
783 @menu
784 * Organization of the Source Tree::
785 * Additional Variables::
786 * Adding Hooks to Passes::
787 * Integration of Wvtest Framework::
788 @end menu
789
790 @node   Organization of the Source Tree, Additional Variables, Advanced OMK Features, Advanced OMK Features
791 @subsection Organization of the Source Tree
792
793 @itemize
794 @item
795   The @file{_compiled} directory can be shared between multiple projects
796   (by using symbolic links).
797
798 @item
799   If you work on a bigger project, you usually don't need to rebuild the
800   whole project and call @command{make} only in a
801   subdirectory. Sometimes, it might be useful to rebuild the whole
802   project. You can either change working directory to the root of your
803   project and call @command{make} there or, as a shortcut, you can use
804   @code{W} variable (see @ref{W}) to compile everything directly from a
805   subdirectory.
806 @example
807 @code{make W=1}
808 @end example
809
810 @item
811   Searching for @file{Makefile.rules} works such way, that if you get
812   into sources directory over symbolic links, OMK is able to unwind your
813   steps back. This implies you can make links to component directories
814   on read-only media, copy @file{Makefile.rules}, @file{Makefile} and
815   top-level @file{Makefile.omk}, adjust @file{Makefile.omk} to contain
816   only required components and then call @command{make} in the top
817   directory or even in read-only directories after changing working
818   directory from your tree to the readonly media.
819 @end itemize
820
821
822 @anchor{W}
823 @defvar W
824 If this variable equals to @samp{1}, the @b{whole} project is
825 (re)compiled, even if @command{make} is called from a subdirectory.
826 @end defvar
827
828 @node Additional Variables, Adding Hooks to Passes, Organization of the Source Tree, Advanced OMK Features
829 @subsection Additional Variables
830
831 @anchor{USE_LEAF_MAKEFILES}
832 @defvar USE_LEAF_MAKEFILES
833 If this variable equals to @samp{n} (default is unset), then OMK uses
834 the leaf @file{Makefile} only when it is invoked by simple
835 @command{make} command. Later, during recursive directory descent leaf
836 @file{Makefile} is not used and @file{Makefile.rules} is included
837 directly.
838
839 This feature is useful if you are integrating some non-OMK project into
840 your project. You only add @file{Makefile.omk} files to the non-OMK
841 project and don't need to modify project's original Makefiles.
842
843 This variable can be set either globally in a @file{config.*} file or
844 locally in some @file{Makefile.omk}. In the latter case, it influences
845 only subdirectories of the directory containing @file{Makefile.omk}.
846 @end defvar
847
848 @anchor{SOURCES_DIR}
849 @defvar{SOURCES_DIR}
850 This variable is set internally by OMK and its value is the absolute
851 path to the directory with compiled sources. It can be used if you need
852 to refer to sources files in some custom constructs in
853 @file{Makefile.omk}.
854 @example
855 @verbatim
856 include_HEADERS = $(notdir $(wildcard $(SOURCES_DIR)/*.h))
857 @end verbatim
858 @end example
859 @end defvar
860
861 @defvar{srcdir}
862 The same as @ref{SOURCES_DIR}. Provided for Automake compatibility.
863 @end defvar
864
865 @defvar{MAKERULES_DIR}
866 This variable is set internally by OMK and its value is the absolute
867 path to the directory containing @file{Makefile.rules} currently used
868 during compilation.
869 @end defvar
870
871 @defvar{OMK_RULES_TYPE}
872 Identification the type of @file{Makefile.rules} used for
873 compilation. Values are like @samp{linux}, @samp{rtems}, @samp{sysless},
874 ... This variable is automatically generated during creation of
875 @file{Makefile.rules} and can be used in configuration files (see
876 @ref{Configuration and Conditional Compilation}) or in
877 @file{Makefile.omk} to tweak compilation for specific targets.
878 @end defvar
879
880 @node Adding Hooks to Passes, Integration of Wvtest Framework, Additional Variables, Advanced OMK Features
881 @subsection Adding Hooks to Passes
882
883 Sometimes it is necessary to run some special commands as a part of
884 compilation. Typical example might be a tool which generates source
885 files on the fly. OMK supports calling additional commands during
886 compilation by so called @emph{pass hooks}. A pass hook is an ordinary
887 make target which is invoked as part of compilation during a particular
888 pass (see @ref{passes}). Pass hooks can be defined by assigning their
889 names to @code{xxx_HOOKS} variable.
890
891 @defvar{xxx_HOOKS}
892 Specifies one or more hooks (make targets) which are invoked during pass
893 @var{xxx}. The working directory of commands or this target is under the
894 @file{_build} tree.
895
896 In the example bellow header file @file{generated_header.h} is created
897 during @samp{include-pass} by @file{convert_data} program. The program
898 takes @file{data_file.txt} in the source directory as the input and
899 creates the header file in the in the correct directory under the
900 @file{_build} tree.
901
902 @example
903 include-pass_HOOKS = generated_header.h
904
905 generated_header.h: $(SOURCES_DIR)/data_file.txt
906             convert_data < $^ > $@@
907 @end example
908 @end defvar
909
910 @node Integration of Wvtest Framework,  , Adding Hooks to Passes, Advanced OMK Features
911 @subsection Integration of Wvtest Framework
912
913 OMK has integrated support for
914 @uref{https://github.com/apenwarr/wvtest,Wvtest unit testing framework}.
915 It is a very minimalistic framework whose integration with OMK does not
916 impose almost any particular policy of writing the tests. Wvtest tests
917 are specified by the following two variables:
918
919 @defvar wvtest_PROGRAMS
920 This variable has the same meaning as @ref{test_PROGRAMS} with two
921 exceptions: (1) the program is automatically linked with the library
922 specified by @code{WVTEST_LIBRARY} variable and (2) the program is
923 automatically executed by @command{make wvtest} (see below).
924 @end defvar
925
926 @defvar wvtest_SCRIPTS
927 Defines the name of a script (e.g. shell script) which is executed by
928 @command{make wvtest}. Write the scripts so, that they can be run from
929 arbitrary directory, i.e. in the case of shell scripts ensure that the
930 @file{wvtest.sh} library is sourced like this:
931 @example
932 @code{. $(dirname $0)/wvtest.sh}
933 @end example
934 @end defvar
935
936 @defvar WVTEST_LIBRARY
937 Specifies the name of the library that is automatically linked with
938 @code{wvtest_PROGRAMS}. The default is @file{wvtest}.
939 @end defvar
940
941 There is also an OMK pass called @code{wvtest-pass} which consecutively
942 runs all @code{wvtest_PROGRAMS} and @code{wvtest_SCRIPTS} in the
943 traversed subdirectories of the current directory. Every program or
944 script is executed in a temporary directory under @file{_build}
945 directory with @code{PATH} variable modified to include
946 @file{_compiled/bin} as the first component and @code{LD_LIBRARY_PATH}
947 modified to include @file{_compiled/lib} as the first component. This
948 allows the tests to run the @code{bin_PROGRAMS} without explicitly
949 specifying their full path and to use shared libraries without the path
950 as well.
951
952 When make is invoked as @command{make wvtest} it runs @command{make
953 wvtest-pass} under the control of @file{wvtestrun} script, which must be
954 present in the same directory as @file{Makefile.rules}. This script
955 suppresses the normal output of passed tests and prints only their
956 summary. For failed tests, the full output is shown. Additionally, when
957 the output is written to a terminal, the status of each test is
958 displayed in color for easy inspection.
959
960 @node Properties of Specific Makefile.rules, Running OMK under Windows OS, Advanced OMK Features, User's Manual
961 @section Properties of Specific Makefile.rules
962
963 In previous sections, general properties of @file{Makefile.rules} were
964 documented. This section contains documentation to features found only
965 in some particular @file{Makefile.rules}.
966
967 @menu
968 * Linux::
969 * System-Less::
970 * RTEMS::
971 @end menu
972
973 @node Linux, System-Less, Properties of Specific Makefile.rules, Properties of Specific Makefile.rules
974 @subsection Linux
975
976 This @file{Makefile.rules} is used not only for Linux as the name
977 suggests, but also for other Unices and even for Windows.
978
979 @defvar BUILD_OS
980   The name of the operating system (OS) where make was invoked.
981 @end defvar
982
983 @defvar TARGET_OS
984   Should specify the name of OS where the resulting binary should be
985   used. If not specified manually, it equals to BUILD_OS.
986 @end defvar
987
988 @defvar QT_SUBDIRS
989   Lists subdirectories with QT project (.pro) file. OMK will generate
990   there @file{Makefile} by calling @command{qmake} with correct
991   parameters to interface QT application to the rest of the compilation
992   tree.  Then @command{make} is called there to compile QT
993   application. Variable @samp{QTDIR} must be set to the directory with
994   QT installation (e.g. /usr/share/qt4 on Debian).
995 @end defvar
996
997 @defvar bin_SCRIPTS
998   Lists the names of the files (persumably scripts) to be copied to
999   @file{_compiled/bin}.
1000 @end defvar
1001
1002
1003
1004 @node System-Less, RTEMS, Linux, Properties of Specific Makefile.rules
1005 @subsection System-Less
1006
1007 This @file{Makefile.rules} is designed for compilation of code for
1008 (small) micro-controllers without operating systems. See
1009 @uref{http://rtime.felk.cvut.cz/hw/index.php/System-Less_Framework} for
1010 more information about our framework, which uses this rules.
1011
1012 @node RTEMS,  , System-Less, Properties of Specific Makefile.rules
1013 @subsection RTEMS
1014
1015 TODO
1016
1017
1018 @node Running OMK under Windows OS, Interfacing OMK to popular IDEs, Properties of Specific Makefile.rules, User's Manual
1019 @section Running OMK under Windows OS
1020
1021 It is possible to use OMK under Windows OS with MinGW (see
1022 @uref{http://www.mingw.org/}). Unfortunately, the compilation speed is
1023 much lower than on UNIX systems.
1024
1025 TODO: Is it necessary to install anything special?
1026
1027 @node Interfacing OMK to popular IDEs, Troubleshooting, Running OMK under Windows OS, User's Manual
1028 @section Interfacing OMK to popular IDEs
1029
1030 @menu
1031 * KDevelop::
1032 * Eclipse/CDT::
1033 * Emacs/Vim/etc.::
1034 @end menu
1035
1036 @node KDevelop, Eclipse/CDT, Interfacing OMK to popular IDEs, Interfacing OMK to popular IDEs
1037 @subsection KDevelop
1038
1039 KDevelop has support for custom build systems. To use KDevelop to
1040 develop projects using OMK follow these steps. These steps are valid for
1041 version 3.5.0 of KDevelop, but for previous versions it doesn't differ
1042 much.
1043
1044 @enumerate
1045 @item
1046   Import project to KDevelop (from menu choose @emph{Project---Import
1047   existing project}). Select the type of project to @emph{Generic C
1048   Application (Custom Buildsystem)}.
1049 @example
1050   @image{kdevelop1}
1051 @end example
1052
1053 @item
1054   Then answer to following dialogs as you want.
1055 @example
1056   @image{kdevelop2}
1057 @end example
1058 @example
1059   @image{kdevelop3} @image{kdevelop4}
1060 @end example
1061
1062 @item
1063   If you are working only on some small part of the bigger project, you
1064   usually don't want to recompile the whole project every time. In
1065   @emph{Project---Project Options}, you can specify the subdirectory where to
1066   run @command{make}.
1067 @example
1068   @image{kdevelop5}
1069 @end example
1070
1071 @item
1072   If you want to switch between several configurations easily (see also
1073   @ref{Configuration and Conditional Compilation}), in the same dialog
1074   you can add @option{-e} to make options. This makes environment variables
1075   have higher precedence than those in @file{config.omk-default}. Then,
1076   you can define several environments with different
1077   @code{CONFIG_@var{xxx}} variables and their values.
1078 @example
1079   @image{kdevelop6}
1080 @end example
1081
1082 @item
1083   You can easily switch the configurations from @emph{Build---Make
1084   Environment}.
1085 @example
1086   @image{kdevelop7}
1087 @end example
1088 @end enumerate
1089
1090 @node Eclipse/CDT, Emacs/Vim/etc., KDevelop, Interfacing OMK to popular IDEs
1091 @subsection Eclipse/CDT
1092 TODO
1093 @node Emacs/Vim/etc.,  , Eclipse/CDT, Interfacing OMK to popular IDEs
1094 @subsection Emacs, VIM, etc.
1095
1096 Since OMK compilation is started by executing @command{make} command,
1097 many common editors can work easily with OMK.
1098
1099 Under Emacs, you can use @command{compile} or @command{recompile}
1100 commands as you are used to do.
1101
1102 @node Troubleshooting,  , Interfacing OMK to popular IDEs, User's Manual
1103 @section Troubleshooting & Knows Bugs
1104
1105 @itemize
1106 @item
1107   If you rename some file or directory and then you can't compile your
1108   project, call @command{make clean} in the directory with errors. The
1109   reason for this behavior is that OMK remembers dependencies of every
1110   file. After renaming something, the original name is still stored in
1111   dependencies, but make doesn't know how to create this non-existent
1112   source.
1113
1114 @item
1115   Sometimes, you may want to compile one file the same way as OMK does
1116   it, but run the compilation manually from command line. For example,
1117   you want to debug some preprocessor macros and you only want to
1118   produce preprocessed source instead of an object file.
1119
1120   To compile something manually, you can run OMK by @command{make
1121   V=2}. This will print all commands executed together with directory
1122   navigation messages. Find the command you want to execute manually in
1123   the output. To run it, you need to change the working directory to the
1124   correct one in the @file{_build} tree. The correct directory can be
1125   found in make output on the line @samp{Entering directory} preceding
1126   the desired command.
1127
1128 @item
1129   Currently, C++ sources are supposed to have @file{.cc} or @file{.cxx}
1130   extensions. The @file{.cpp} extension is not supported (yet).
1131
1132 @item
1133   Removing of library source file does not cause the library to be
1134   rebuild. You need to manually delete the library or run @command{make
1135   distclean} before you run @command{make}.
1136 @end itemize
1137
1138 @node Original README, Development, User's Manual, Top
1139 @chapter Original README
1140
1141 Since this manual still doesn't cover all aspects of OMK, we include
1142 here a @file{README.rules} file, which was written for the first version
1143 of OMK.
1144
1145 @b{Important notice:} This make system uses features found in recent
1146 versions of GNU Make program. If you encounter problems with package
1147 building, check, that you use correct version of Make program.  The
1148 Make older than version 3.80, could not be used.  Even Make version
1149 3.80 has annoying bug which causes building fail with misleading
1150 message "virtual memory exhausted".  Please, upgrade at least to
1151 version 3.81 of GNU Make.
1152
1153 There is list of features which we want to solve with our make system:
1154 @itemize
1155 @item
1156 Central @file{Makefile.rules} for most of components of a bigger project.
1157
1158 FIXME (our CAN framework includes more libraries common with our other
1159 projects, we need to separate some utility libraries etc.)
1160 @item
1161 The rules in more spread Makefiles are way to the hell (update for
1162 different kernel, RT-Linux etc would be nightmare in other case).
1163 @item
1164 Make system should allow to freely move cross-dependant components in
1165 directory structure without need to update users of moved component (I
1166 hate something like @option{-I../../sched/rtlshwq/include} in CAN makefiles for
1167 example. If a component is renamed or version is added to then name,
1168 all Makefiles in CAN will require update).
1169 @item
1170 Make system should be able to compile mutually cross-dependant
1171 libraries and should ensure, that change in one component sources or
1172 headers would result in relink or rebuild in components linked against
1173 that library or including modified header file.
1174 @item
1175 Make system has to enable compilation out of OCERA full source tree
1176 (we would lost many users of particular components in other case).
1177 @item
1178 Compile should be able to do all above work without need to install
1179 any files before successful finish of build.
1180 @item
1181 Because we use some libraries for RT-Linux build and user-space build,
1182 we need to solve how to compile from same sources to both targets.
1183 @item
1184 The build system should allow to call make for particular source
1185 subdirectory. Time of recursive make through all subdirectories is
1186 unacceptable.
1187 @item
1188 Make system should enable to build out of sources tree (else clean or
1189 working with CVS sandbox gets fussy and simultaneous multiple targets
1190 gets problematic).
1191 @item
1192 It would be good, if there is a possibility to call make from
1193 read-only media sources.
1194 @item
1195 Make system should store results of build in some separate directory
1196 structure to simple install and testing.
1197 @item
1198 Makefiles in sources directories should be simple.
1199 @end itemize
1200
1201 There is probably only one alternative fully supporting above requirements
1202 and it is GNU Autoheader...Automake...Autoconf... system.
1203 But it is complicated and requires big amount of support files.
1204 It would be acceptable if it could be easily used for OCERA framework.
1205 But there are important show stoppers for that system:
1206 @itemize
1207 @item
1208 It would require deep revision of all OCERA CVS contents and agreement
1209 on this would be problematic
1210 @item
1211 This system is not well prepared for dual compilation for Linux and
1212 RT-Linux sub-targets. It would mean many changes in default autoconf
1213 setup to support this. Probably simplest way would be to rebuild GCC
1214 tool chain for something like i586-elf-rtlinux.  This would require
1215 even more space for OCERA development.
1216 @end itemize
1217
1218 The problem calls for some solution, which would have minimal impact
1219 on other components and would be elegant and would be maintainable
1220 and small, because our main goal is components development and not
1221 make systems development.
1222
1223 There is result of our trial. It is OMK make system.
1224 The @file{Makefile} and @file{Makefile.omk} files should be in all source
1225 directories. Common @file{Makefile.rules} file is required in the toplevel
1226 sources directory. Alternatively this file could be moved
1227 to link tree pointing into readonly media or can be anywhere
1228 else if @code{MAKERULES_DIR} and @code{SOURCES_DIR} are specified.
1229
1230 @c !!! tohle tam nejak zmizelo, mozna by to chtelo zkontrolovat, ze to
1231 @c     sedi s aktualnim stavem
1232
1233
1234 Syntax of Makefile.omk files is for usual cases compatible
1235 to Automake's Makefile.am descriptions. There are specific targets
1236 for RT-Linux and Linux kernel related stuff
1237
1238 Makefile.omk user defined variables
1239 @vtable @code
1240 @item SUBDIRS
1241 list of subdirectories intended for make from actual directory
1242 @item lib_LIBRARIES
1243 list of the user-space libraries
1244 @item shared_LIBRARIES
1245 list of the user-space shared libraries
1246 @item kernel_LIBRARIES
1247 list of the kernel-space libraries
1248 @item rtlinux_LIBRARIES
1249 list of the RT-Linux kernel-space libraries
1250 @item include_HEADERS
1251 list of the user-space header files
1252 @item nobase_include_HEADERS
1253 headers copied even with directory part
1254 @item kernel_HEADERS
1255 list of the kernel-space  header files
1256 @item rtlinux_HEADERS
1257 list of the RT-Linux kernel-space  header files
1258 @item bin_PROGRAMS
1259 list of the require binary programs
1260 @item utils_PROGRAMS
1261 list of the development utility programs
1262 @item kernel_MODULES
1263 list of the kernel side modules/applications
1264 @item rtlinux_MODULES
1265 list of RT-Linux the kernel side modules/applications
1266 @item xxx_SOURCES
1267 list of specific target sources
1268 @item INCLUDES
1269 additional include directories and defines for user-space
1270 @item kernel_INCLUDES
1271 additional include directories and defines for kernel-space
1272 @item rtlinux_INCLUDES
1273 additional include directories and defines for RT-Linux
1274 @item default_CONFIG
1275 list of default config assignments CONFIG_XXX=y/n ...
1276 @end vtable
1277
1278 The Makefile is same for all sources directories and is only 14 lines
1279 long.  It is there only for convenience reasons to enable call "make"
1280 from local directory. It contains code which locates
1281 @file{Makefile.rules} in actual or any parent directory. With standard
1282 BASH environment it works such way, that if you get into sources
1283 directory over symbolic links, it is able to unwind yours steps back
1284 => you can make links to readonly media component directories, copy
1285 @file{Makefile.rules}, Makefile and toplevel Makefile.omk, adjust
1286 Makefile.omk to contain only required components and then call make in
1287 top or even directories after crossing from your tree to readonly
1288 media.
1289
1290 The system compiles all files out of source directories.  The actual
1291 version of system is adapted even for OCERA tree mode if
1292 @code{OCERA_DIR} variable is defined in @file{Makefile.rules}
1293
1294 There are next predefined directory name components, which can be
1295 adapted if required
1296
1297 @table @code
1298 @item BUILD_DIR_NAME = _build
1299         prefix of directory, where temporary build files are stored
1300 @item COMPILED_DIR_NAME = _compiled
1301         prefix of directory, where final compilation results are stored
1302 @item GROUP_DIR_NAME = yyy
1303         this is used for separation of build sub-trees in OCERA environment
1304         where more @file{Makefile.rules} is spread in the tree
1305 @end table
1306
1307 Next directories are used:
1308
1309 @table @code
1310 @item KERN_BUILD_DIR   := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/kern
1311         directory to store intermediate files for kernel-space targets
1312 @item USER_BUILD_DIR   := $(MAKERULES_DIR)/$(BUILD_DIR_NAME)/user
1313         directory to store intermediate files for user-space targets
1314
1315 @item USER_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include
1316         directory to store exported include files which should be installed later
1317         on user-space include path
1318 @item USER_LIB_DIR     := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib
1319         same for user-pace libraries
1320 @item USER_UTILS_DIR   := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin-utils
1321         utilities for testing, which would not probably be installed
1322 @item USER_BIN_DIR     := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/bin
1323         binaries, which should go into directory on standard system PATH
1324         (/usr/local/bin, /usr/bin or $(prefix)/bin)
1325
1326 @item KERN_INCLUDE_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/include-kern
1327         directory to store exported include files which should be installed later
1328         on kernel-space include path
1329 @item KERN_LIB_DIR     := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/lib-kern
1330         same for kernel-pace libraries
1331 @item KERN_MODULES_DIR := $(MAKERULES_DIR)/$(COMPILED_DIR_NAME)/modules
1332         builded modules for Linux kernel or RT-Linux system
1333 @end table
1334
1335 There is more recursive passes through directories to enable
1336 mutual dependant libraries and binaries to compile.
1337 Next passes are defined
1338
1339 @table @samp
1340 @item default-config
1341 generates @file{config.omk-default} or xxx-default (FIXME) configuration file
1342 @item check-dir
1343 checks and creates required build directories
1344 @item include-pass
1345 copies header files to @code{USER_INCLUDE_DIR} and @code{KERN_INCLUDE_DIR}
1346 @item library-pass
1347 builds objects in USER_BUILD_DIR/@var{relative path} and creates libraries
1348 in USER_LIB_DIR
1349 @item binary-pass and utils-pass
1350 links respective binaries in USER_@{BIN,UTILS@}_DIR directory. If some
1351 object file is missing it compiles it in USER_BUILD_DIR/@var{relative path}
1352 @item kernel-lib-pass
1353 builds libraries for kernel space targets
1354 @item kernel-pass
1355 builds kernel modules
1356 @end table
1357
1358 The amount of passes is relatively high and consumes some time.  But
1359 only other way to support all required features is to assemble one big
1360 toplevel Makefile, which would contain all components and targets
1361 cross-dependencies.
1362
1363 Drawbacks of designed make system
1364 @itemize
1365 @item
1366 the system is not as fast as we would like
1367 @item
1368 it lacks Autoconf and configure extensive support for many systems
1369 from UNIX to DOS and WINDOWS
1370 @item
1371 it does not contain support for checking existence of target
1372 libraries and functionalities as GNU Autoconf
1373 @item
1374 it is heavily dependant on GNU MAKE program. But it would not be big
1375 problem, because even many commercial applications distribute GNU MAKE
1376 with them to be able to work in non-friendly systems
1377 @item
1378 the key drawback is dependence on recent MAKE version 3.80 and better
1379 and even version 3.80 of MAKE has important bug, which has been
1380 corrected in newer sources (FIXME)
1381 @end itemize
1382
1383 The last point is critical. I have not noticed it first, because
1384 I use Slackware-9.2 and it contains latest released version
1385 of MAKE (version 3.80).
1386 The problem appears when I have tried to build bigger libraries.
1387 There is bug in version 3.80, which results in misleading
1388 error "Virtual memory exhausted". It is known bug with ID 1517
1389
1390 @smallexample
1391 * long prerequisite inside eval(call()) => vm exhausted, Paul D. Smith
1392 @end smallexample
1393
1394
1395 I have optimized some rules to not push memory to the edge,
1396 but there could be still issues with 3.80 version.
1397
1398 I have downloaded latest MAKE CVS sources. The compilation required
1399 separate lookup and download for .po files and full Autoheader... cycle.
1400 I have put together package similar to release. Only ./configure --prefix=...
1401 and make is required. CVS sources contains version 3.81beta1.
1402 You can download prepared sources archive from
1403   @uref{http://paulandlesley.org/make/make-3.81beta1.tar.bz2}
1404 Or you can get our local copy from
1405   @uref{http://cmp.felk.cvut.cz/~pisa/can/make-3.81beta1.tar.gz}
1406
1407 The archive contains even "make" binary build by me, which should work
1408 on other Linux distributions as well.  Older version of MAKE (3.79.x
1409 released about year 2000) found on Mandrake and RedHat are not
1410 sufficient and do not support eval feature.  I do not expect, that
1411 Debian would be more up-to-date or contain fixes to MAKE vm exhausted
1412 bug.
1413
1414 The local CTU archive with our CAN components prepared for inclusion
1415 into OCERA SF CVS could be found in my "can" directory
1416
1417   @uref{http://cmp.felk.cvut.cz/~pisa/can/ocera-can-031212.tar.gz}
1418
1419 The code should build for user-space with new make on most of Linux distros
1420 when make is updated.
1421
1422 If you want to test compile for RT-Linux targets, line
1423
1424 @example
1425 #RTL_DIR := /home/cvs/ocera/ocera-build/kernel/rtlinux
1426 @end example
1427
1428 in @file{Makefile.rules} has to be activated and updated
1429 to point RT-Linux directory containing "rtl.mk".
1430 There is only one library ("ulutrtl") and test utility compiled for RT-Linux
1431 (@file{can/utils/ulut/ul_rtlchk.c}).
1432
1433 The next line, if enabled, controls compilation in OCERA project tree
1434
1435 @example
1436 #OCERA_DIR := $(shell ( cd -L $(MAKERULES_DIR)/../../.. ; pwd -L ) )
1437 @end example
1438
1439 The LinCAN driver has been updated to compile out of source directories.
1440
1441 Please, check, if you could compile CAN package and help us with integration
1442 into OCERA SF CVS. Send your comments and objections.
1443
1444 The OMK system has been adapted to support actual OCERA configuration process.
1445 I am not happy with ocera.mk mix of defines and poor two or three rules,
1446 but OMK is able to overcome that.
1447
1448 The OMK system has integrated rules (default-config) to build default
1449 configuration file. The file is named @file{config.omk-default} for
1450 the stand-alone compilation.  The name corresponds to OCERA config +
1451 "-default" if OCERA_DIR is defined.  This file contains statements
1452 from all @code{default_CONFIG} lines in all @file{Makefile.omk}.  The
1453 file should be used for building of own @file{config.omk} file, or as
1454 list for all options if Kconfig is used.
1455
1456 @c @chapter OMK Reference
1457
1458 @node Development, Variable Index, Original README, Top
1459 @chapter Development
1460
1461 This section is far from complete. Its purpose is to document internals
1462 of @file{Makefile.rules} as well as other things needed only by people
1463 who hack OMK itself.
1464
1465 @section Passes
1466
1467 A pass is created by instantiation of @code{omk_pass_template} with
1468 @var{pass-name} as one of arguments. This defines several targets which
1469 are described here:
1470
1471 @table @code
1472 @item @var{pass-name}
1473 Target used to invoke the individual pass either from command line or
1474 from inside of @file{Makefile.rules}.
1475
1476 @item @var{pass-name}-submakes
1477 Invoked recursively from @var{pass-name}. The reason for this is the
1478 fact that
1479
1480 @item @var{pass-name}-this-dir
1481 This target calls make recursively once again with @var{pass-name}-local
1482 target, which does the real-work. Make's working directory is set to the
1483 corresponding directory in @file{_build} tree and the -local
1484
1485 @item @var{pass-name}-@var{dirname}-subdir
1486 This target is responsible for recursive invocation of @command{make} in
1487 subdirectories specified in @code{@ref{SUBDIRS}} variable.
1488 @end table
1489
1490 @node Variable Index,  , Development, Top
1491 @unnumbered Variable Index
1492
1493 @printindex vr
1494
1495 @c @node Concept Index,  , Variable Index, Top
1496 @c @unnumbered Concept Index
1497 @c @printindex cp
1498
1499 @bye