@c TODO: Pavel's note about qmake.
-The compilation process itself is comprised of several passes. Every
+@anchor{passes}
+The compilation process itself is comprised of several @emph{passes}. Every
pass traverses the whole directory structure@footnote{In future, we are
planning some optimization that allows OMK to traverse the directories
only once and thus decrease compilation time.} and does a particular
In this section we list several OMK features, which are more complicated
or rarely used so they were omitted in previous sections.
+@menu
+* Unsorted Advanced Features::
+* Adding Hooks to Passes::
+@end menu
+
+@node Unsorted Advanced Features, Adding Hooks to Passes, Advanced OMK Features, Advanced OMK Features
+@subsection Unsorted Advanced Features
+
@itemize
@item
The @file{_compiled} directory can be shared between multiple projects
@file{Makefile.omk} to tweak compilation for specific targets.
@end defvar
+@node Adding Hooks to Passes, , Unsorted Advanced Features, Advanced OMK Features
+@subsection Adding Hooks to Passes
+
+Sometimes it is necessary to run some special commands as a part of
+compilation. Typical example might be a tool which generates source
+files on the fly. OMK supports calling additional commands during
+compilation by so called @emph{pass hooks}. A pass hook is an ordinary
+make target which is invoked as part of compilation during a particular
+pass (see @ref{passes}). Pass hooks can be defined by assigning their
+names to @code{xxx_HOOKS} variable.
+
+@defvar{xxx_HOOKS}
+Specifies one or more hooks (make targets) which are invoked during pass
+@var{xxx}. The working directory of commands or this target is under the
+@file{_build} tree.
+
+In the example bellow header file @file{generated_header.h} is created
+during @samp{include-pass} by @file{convert_data} program. The program
+takes @file{data_file.txt} in the source directory as the input and
+creates the header file in the in the correct directory under the
+@file{_build} tree.
+
+@example
+include-pass_HOOKS = generated_header.h
+
+generated_header.h: $(SOURCES_DIR)/data_file.txt
+ convert_data < $^ > $@@
+@end example
+@end defvar
+
@node Properties of Specific Makefile.rules, Running OMK under Windows OS, Advanced OMK Features, OMK User's Manual
@section Properties of Specific Makefile.rules
$(pass)-submakes:
@true # Do not emit "nothing to be done" messages
-ifneq ($(4),)
+ifneq ($(4)$($(pass)_HOOKS),)
$(pass)-submakes: $(pass)-this-dir
$(pass)-this-dir: $(foreach subdir,$(SUBDIRS),$(pass)-$(subdir)-subdir)
+@echo "make[omk]: $(pass) in $(RELATIVE_DIR)"
@$(call mkdir_def,$(2))
+@$(MAKE) $(NO_PRINT_DIRECTORY) SOURCES_DIR=$(SOURCES_DIR) RELATIVE_DIR=$(RELATIVE_DIR) -C $(2) \
-f $(SOURCESDIR_MAKEFILE) $(3) $(check-target) $(1:%=%-local)
+$(pass)-local: $($(pass)_HOOKS)
endif
endef