endif
endef
-# Syntax: $(call COMPILE_templates,<sources_abs>,<suffix>)
+# Syntax: $(call COMPILE_templates,<sources_abs>,<suffix>,<obj-prefix>)
# Note: The newlines after $(call ) are IMPORTANT!!!
define COMPILE_templates
-$(foreach src,$(filter %.c,$(1)),$(call COMPILE_c_o_template,$(src),$(notdir $(src:%.c=%$(2))),)
+$(foreach src,$(filter %.c,$(1)),$(call COMPILE_c_o_template,$(src),$(3)$(notdir $(src:%.c=%$(2))),)
)
-$(foreach src,$(filter %.cc,$(1)),$(call COMPILE_cc_o_template,$(src),$(notdir $(src:%.cc=%$(2))),)
+$(foreach src,$(filter %.cc,$(1)),$(call COMPILE_cc_o_template,$(src),$(3)$(notdir $(src:%.cc=%$(2))),)
)
-$(foreach src,$(filter %.cxx,$(1)),$(call COMPILE_cc_o_template,$(src),$(notdir $(src:%.cxx=%$(2))),)
+$(foreach src,$(filter %.cxx,$(1)),$(call COMPILE_cc_o_template,$(src),$(3)$(notdir $(src:%.cxx=%$(2))),)
)
-$(foreach src,$(filter %.cpp,$(1)),$(call COMPILE_cc_o_template,$(src),$(notdir $(src:%.cpp=%$(2))),)
+$(foreach src,$(filter %.cpp,$(1)),$(call COMPILE_cc_o_template,$(src),$(3)$(notdir $(src:%.cpp=%$(2))),)
)
-$(foreach src,$(filter %.S,$(1)),$(call COMPILE_S_o_template,$(src),$(notdir $(src:%.S=%$(2))),)
+$(foreach src,$(filter %.S,$(1)),$(call COMPILE_S_o_template,$(src),$(3)$(notdir $(src:%.S=%$(2))),)
)
endef
$(filter %.c,$($(1)_IDL:%.idl=%.c))
TARGET_SOURCES = $($(1)_SOURCES) $($(1)_GEN_SOURCES) $(TARGET_IDL_SOURCES)
TARGET_SOURCES_ABS = $($(1)_SOURCES:%=$(SOURCES_DIR)/%) $($(1)_GEN_SOURCES) $(TARGET_IDL_SOURCES)
-TARGET_OBJS = $(sort $(addsuffix .o,$(basename $(notdir $(TARGET_SOURCES)))))
+TARGET_OBJ_PREFIX = $(if $($(1)_CFLAGS)$($(1)_CXXFLAGS)$($(1)_CPPFLAGS),$(1)-,)
+TARGET_OBJS = $(sort $(addprefix $(TARGET_OBJ_PREFIX),$(addsuffix .o,$(basename $(notdir $(TARGET_SOURCES))))))
TARGET_LOBJS = $(sort $(addsuffix .lo,$(basename $(notdir $(TARGET_SOURCES)))))
TARGET_IDLS = $($(1)_SERVER_IDL) $($(1)_CLIENT_IDL) $($(1)_IDL)
+TARGET_CFLAGS = $(if $($(1)_CFLAGS),$($(1)_CFLAGS),$(AM_CFLAGS))
+TARGET_CXXFLAGS = $(if $($(1)_CXXFLAGS),$($(1)_CXXFLAGS),$(AM_CXXFLAGS))
+TARGET_CPPFLAGS = $(if $($(1)_CPPFLAGS),$($(1)_CPPFLAGS),$(AM_CPPFLAGS))
LINK_WITH_CXX = $(filter %.cc,$(TARGET_SOURCES))$(filter %.cxx,$(TARGET_SOURCES))$$(filter %.cpp,$(TARGET_SOURCES))
# Syntax: $(call PROGRAM_template,<executable-name>,<dir>,<executable-suffix>,<linker-sript>)
define PROGRAM_template
$(foreach idl,$(TARGET_IDLS),$(call COMPILE_idl_template,$(SOURCES_DIR)/$(idl),$(idl:%.idl=%)))
-$(call COMPILE_templates,$(TARGET_SOURCES_ABS),.o)
+$(call COMPILE_templates,$(TARGET_SOURCES_ABS),.o,$(TARGET_OBJ_PREFIX))
+$(2)/$(1)$(3): AM_CFLAGS=$(TARGET_CFLAGS)
+$(2)/$(1)$(3): AM_CXXFLAGS=$(TARGET_CXXFLAGS)
+$(2)/$(1)$(3): AM_CPPFLAGS=$(TARGET_CPPFLAGS)
$(2)/$(1)$(3): $(TARGET_OBJS)
- @$(QUIET_CMD_ECHO) " LINK $$@"
+ @$(QUIET_CMD_ECHO) " LINK $$@ >$(1)<"
$(Q) $(if $(LINK_WITH_CXX),$$(CXX),$$(CC)) \
$$^ $$($(1)_LIBS:%=-l%) $$(LOADLIBES) $$(AM_LDFLAGS) $$(LDFLAGS) $$($(1)_LDFLAGS) -Wl,-rpath-link,$(USER_LIB_DIR) -Wl,-Map,$(USER_OBJS_DIR)/$(1).exe.map -o $$@
@echo "$(2)/$(1)$(3): \\" >$(USER_OBJS_DIR)/$(1).exe.d
$(foreach script,$(bin_SCRIPTS),$(eval $(call SCRIPT_template,$(script),$(USER_BIN_DIR))))
+# $(foreach lib,$(lib_LIBRARIES),$(info $(call LIBRARY_template,$(lib))))
$(foreach lib,$(lib_LIBRARIES),$(eval $(call LIBRARY_template,$(lib))))
$(foreach lib,$(shared_LIBRARIES),$(eval $(call SOLIB_template,$(lib))))