(re)compiled, even if @command{make} is called from a subdirectory.
@end defvar
+@anchor{USE_LEAF_MAKEFILES}
+@defvar USE_LEAF_MAKEFILES
+If this variable equals to @samp{n} (default is unset), then OMK uses
+the leaf @file{Makefile} only when it is invoked by simple
+@command{make} command. Later, during recursive directory descent leaf
+@file{Makefile} is not used and @file{Makefile.rules} is included
+directly.
+
+This feature is useful if you are integrating some non-OMK project into
+your project. You only add @file{Makefile.omk} files to the other
+project and don't need to modify project's original Makefiles.
+
+This variable can be set either globally in a @file{config.*} file or
+locally in some @file{Makefile.omk}. In the latter case, it influences
+only subdirectories of the directory containing @file{Makefile.omk}.
+@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
NO_PRINT_DIRECTORY := --no-print-directory
endif
+ifeq ($(USE_LEAF_MAKEFILES),n)
+export USE_LEAF_MAKEFILES
+SUBDIR_MAKEFILE=$(MAKERULES_DIR)/Makefile.rules
+SOURCESDIR_MAKEFILE=$(MAKERULES_DIR)/Makefile.rules
+else
+SUBDIR_MAKEFILE=$(SOURCES_DIR)/$(dir)/Makefile
+SOURCESDIR_MAKEFILE=$(SOURCES_DIR)/Makefile
+endif
+
# Syntax: $(call omk_pass_template,<pass name>,<build dir>,[<local make flags>],[<local condition>])
define omk_pass_template
.PHNOY: $(1) $(1)-local
+@$(foreach dir,$(SUBDIRS),$(call mkdir_def,$(2)/$(dir)); \
$(MAKE) SOURCES_DIR=$(SOURCES_DIR)/$(dir) $(NO_PRINT_DIRECTORY) \
RELATIVE_DIR=$(RELATIVE_PREFIX)$(dir) -C $(2)/$(dir) \
- -f $(SOURCES_DIR)/$(dir)/Makefile $$@ || exit 1 ;) true
+ -f $(SUBDIR_MAKEFILE) $$@ || exit 1 ;) true
ifneq ($(4),)
@echo "make[omk]: $$@ in $(RELATIVE_DIR)"; \
$(call mkdir_def,$(2)); \
$(MAKE) $(NO_PRINT_DIRECTORY) SOURCES_DIR=$(SOURCES_DIR) RELATIVE_DIR=$(RELATIVE_DIR) -C $(2) \
- -f $(SOURCES_DIR)/Makefile $(3) $$(@:%=%-local)
+ -f $(SOURCESDIR_MAKEFILE) $(3) $$(@:%=%-local)
endif
endef