# bin_PROGRAMS .. list of the require binary programs
# utils_PROGRAMS .. list of the development utility programs
# test_PROGRAMS .. list of the testing programs
+# bin_SCRIPTS .. list of scripts to be copied to _compiled/bin
# kernel_MODULES .. list of the kernel side modules/applications
# rtlinux_MODULES .. list of RT-Linux the kernel side modules/applications
# xxx_SOURCES .. list of specific target sources
LIB_CFLAGS += $(CFLAGS)
ifeq ($(TARGET_OS),win32)
+ EXE_SUFFIX = .exe
SOLIB_EXT = dll
else
SOLIB_EXT = so
MAKEOVERRIDES := $(filter-out OMK_SERIALIZE_INCLUDED=n,$(MAKEOVERRIDES))
endif
-# Checks for OMK tester
-ifdef OMK_TESTSROOT
-default-config-pass-check include-pass-check:
-library-pass-check binary-pass-check:
- @[ -x "$(shell which $(CC))" ] || $(call canttest,Cannot find compiler: $(CC))
-endif
-
#=====================================================================
# User-space rules and templates to compile programs, libraries etc.
fi
endef
+NM ?= nm
# Syntax: $(call CMETRIC_o_h_template,<object_file>,<target_header>)
define CMETRIC_o_h_template
$(Q)if [ -n `dirname $$@` ] ; then \
if [ ! -e `dirname $$@` ] ; then \
mkdir -p `dirname $$@` ; fi ; fi
- $(Q)echo >$$@ '/* Automatically generated from $$< */'
- $(Q)echo >>$$@ '/* Conditionals to control compilation */'
- $(Q)set -o pipefail ; $(NM) $$< \
+ $(Q)echo >$$@.tmp '/* Automatically generated from $$< */'
+ $(Q)echo >>$$@.tmp '/* Conditionals to control compilation */'
+# Bellow, the tricks with redirection are for shells without set -o pipefail
+# (see http://www.mail-archive.com/dash@vger.kernel.org/msg00149.html)
+ $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\
| sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
- | sort >>$$@
- $(Q)echo >>$$@ '/* Defines from the values defined to symbols */'
- $(Q)set -o pipefail ; $(NM) $$< \
+ | sort >>$$@.tmp` && exit $$$$status
+ $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in hexadecimal format */'
+ $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\
| sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
- | sort >>$$@
+ | sort >>$$@.tmp` && exit $$$$status
+ $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in decimal format */'
+ $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) -td $$<; echo $$$$? >&4; }\
+ | sed -n 's/^ *0*\(0\|[1-9][0-9]*\) *A *_cmetric2defdec_\([A-Za-z_0-9]*\) */#define \2 \1/p' \
+ | sort >>$$@.tmp` && exit $$$$status
+ $(Q)mv $$@.tmp $$@
endef
@echo >>$(USER_OBJS_DIR)/$(1).exe.d
endef
+# Usage: $(call SCRIPT_template,<target-directory>,<script-name>)
+define SCRIPT_template
+$(2)/$(1): $$(SOURCES_DIR)/$(1)
+ @$(QUIET_CMD_ECHO) " CP $$@"
+ $(Q)cp $$^ $$@
+endef
+
# Syntax: $(call LIBRARY_template,<library-name>)
define LIBRARY_template
library-pass-local: $(addprefix $(USER_INCLUDE_DIR)/,$(cmetric_include_HEADERS)) \
$(lib_LIBRARIES:%=$(USER_LIB_DIR)/lib%.a) $(shared_LIBRARIES:%=$(OMK_WORK_DIR)/lib%.$(SOLIB_EXT).omkvar)
-binary-pass-local: $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%$(EXE_SUFFIX)) $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%$(EXE_SUFFIX)) $(test_PROGRAMS:%=$(USER_TESTS_DIR)/%$(EXE_SUFFIX))
+binary-pass-local: $(bin_PROGRAMS:%=$(USER_BIN_DIR)/%$(EXE_SUFFIX)) \
+ $(utils_PROGRAMS:%=$(USER_UTILS_DIR)/%$(EXE_SUFFIX)) \
+ $(test_PROGRAMS:%=$(USER_TESTS_DIR)/%$(EXE_SUFFIX)) \
+ $(bin_SCRIPTS:%=$(USER_BIN_DIR)/%)
# Special rules for CMETRIC generated headers
$(foreach prog,$(bin_PROGRAMS),$(eval $(call PROGRAM_template,$(prog),$(USER_BIN_DIR),$(EXE_SUFFIX))))
+$(foreach script,$(bin_SCRIPTS),$(eval $(call SCRIPT_template,$(script),$(USER_BIN_DIR))))
+
+
$(foreach lib,$(lib_LIBRARIES),$(eval $(call LIBRARY_template,$(lib))))
$(foreach lib,$(shared_LIBRARIES),$(eval $(call SOLIB_template,$(lib))))
-include $(USER_OBJS_DIR)/*.d
+#FIXME: This doesn't include dependencies of source files from
+#subdirectories (i.s. *_SOURCES=dir/file.c. I'm currently not sure,
+#how to handle this.
endif # USER_RULE_TEMPLATES
fi
$(eval $(call omk_pass_template, library-pass,$(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,$(lib_LIBRARIES)$(shared_LIBRARIES)))
-$(eval $(call omk_pass_template, binary-pass, $(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,$(bin_PROGRAMS)$(utils_PROGRAMS)$(test_PROGRAMS)))
+$(eval $(call omk_pass_template, binary-pass, $(USER_OBJS_DIR),USER_RULE_TEMPLATES=y,$(bin_PROGRAMS)$(utils_PROGRAMS)$(test_PROGRAMS)$(bin_SCRIPTS)))
$(eval $(call omk_pass_template,clean,$(USER_OBJS_DIR),,always))
$(eval $(call omk_pass_template,install,$(USER_OBJS_DIR),,always))
$(foreach src,$(filter %.c,$(SOLIB_GEN_SOURCES)),$(eval $(call COMPILE_c_o_template,$(src),$(src:%.c=%.lo),$(SOLIB_PICFLAGS))))
+# Create _build directories for sources in subdirectories i.e. *_SOURCES=dir/file.c
+_dirs_to_create=$(filter-out ./,$(sort $(dir $(USER_SOURCES) $(SOLIB_SOURCES))))
+ifneq ($(_dirs_to_create),)
+$(shell mkdir -p $(addprefix $(LOCAL_BUILD_DIR)/,$(_dirs_to_create)))
+endif
+
# IDL compilation
USER_IDLS := $(sort $(USER_IDLS))