$(2)_C_TARGET=1
$(2): $(1) $$(GEN_HEADERS)
@$(QUIET_CMD_ECHO) " CC $$@"
- $(Q)mkdir -p $$(dir $$@)
$(Q) if $$(c_o_COMPILE) $$(CC_DEPFLAGS) $(3) -o $$@ -c $$< ; \
then mv -f "$$@.d.tmp" "$$@.d" ; \
else rm -f "$$@.d.tmp" ; exit 1; \
$(2)_CC_TARGET=1
$(2): $(1) $$(GEN_HEADERS)
@$(QUIET_CMD_ECHO) " CXX $$@"
- $(Q)mkdir -p $$(dir $$@)
$(Q) if $$(cc_o_COMPILE) $$(CC_DEPFLAGS) $(3) -o $$@ -c $$< ; \
then mv -f "$$@.d.tmp" "$$@.d" ; \
else rm -f "$$@.d.tmp" ; exit 1; \
$(2)_S_TARGET=1
$(2): $(1) $$(GEN_HEADERS)
@$(QUIET_CMD_ECHO) " AS $$@"
- $(Q)mkdir -p $$(dir $$@)
$(Q) if $$(S_o_COMPILE) -D__ASSEMBLY__ $$(CC_DEPFLAGS) $(3) -o $$@ -c $$< ; \
then mv -f "$$@.d.tmp" "$$@.d" ; \
else rm -f "$$@.d.tmp" ; exit 1; \
$(Q)mv $$@.tmp $$@
endef
-
-
+# Syntax: $(call COMPILE_idl_template,</path/to/src.idl>,<basename>)
define COMPILE_idl_template
-GEN_HEADERS+=$(filter %.h,$(1:%.idl=%.h))
+ifeq ($$($(2)_IDL_TARGET),)
+$(2)_IDL_TARGET=1
+GEN_HEADERS+=$(filter %.h,$(notdir $(1:%.idl=%.h))) # Do we need this global variable?
$(2).c $(2)-stubs.c $(2)-skels.c $(2)-common.c $(2).h: $(1) $$(wildcard $$(firstword $$(idl_COMPILE)))
@$(QUIET_CMD_ECHO) " IDL $$@"
$(Q) $$(idl_COMPILE) $$($(2)_IDLFLAGS) $(1)
+endif
endef
-# Syntax: $(call COMPILE_templates,<sources>,<suffix>)
+# Syntax: $(call COMPILE_templates,<sources_abs>,<suffix>)
# Note: The newlines after $(call ) are IMPORTANT!!!
define COMPILE_templates
-$(foreach src,$(filter %.c,$(1)),$(call COMPILE_c_o_template,$(SOURCES_DIR)/$(src),$(src:%.c=%$(2)),)
+$(foreach src,$(filter %.c,$(1)),$(call COMPILE_c_o_template,$(src),$(notdir $(src:%.c=%$(2))),)
)
-$(foreach src,$(filter %.cc,$(1)),$(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cc=%$(2)),)
+$(foreach src,$(filter %.cc,$(1)),$(call COMPILE_cc_o_template,$(src),$(notdir $(src:%.cc=%$(2))),)
)
-$(foreach src,$(filter %.cxx,$(1)),$(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cxx=%$(2)),)
+$(foreach src,$(filter %.cxx,$(1)),$(call COMPILE_cc_o_template,$(src),$(notdir $(src:%.cxx=%$(2))),)
)
-$(foreach src,$(filter %.cpp,$(1)),$(call COMPILE_cc_o_template,$(SOURCES_DIR)/$(src),$(src:%.cpp=%$(2)),)
+$(foreach src,$(filter %.cpp,$(1)),$(call COMPILE_cc_o_template,$(src),$(notdir $(src:%.cpp=%$(2))),)
)
-$(foreach src,$(filter %.S,$(1)),$(call COMPILE_S_o_template,$(SOURCES_DIR)/$(src),$(src:%.S=%$(2)),)
+$(foreach src,$(filter %.S,$(1)),$(call COMPILE_S_o_template,$(src),$(notdir $(src:%.S=%$(2))),)
)
endef
$(filter %.c,$($(1)_CLIENT_IDL:%.idl=%-common.c)) \
$(filter %.c,$($(1)_IDL:%.idl=%.c))
TARGET_SOURCES = $($(1)_SOURCES) $(TARGET_GEN_SOURCES)
+TARGET_SOURCES_ABS = $($(1)_SOURCES:%=$(SOURCES_DIR)/%) $(TARGET_GEN_SOURCES)
TARGET_OBJS = $(sort $(addsuffix .o,$(basename $(TARGET_SOURCES))))
TARGET_LOBJS = $(sort $(addsuffix .lo,$(basename $(TARGET_SOURCES))))
TARGET_IDLS = $($(1)_SERVER_IDL) $($(1)_CLIENT_IDL) $($(1)_IDL)
define PROGRAM_template
$(foreach idl,$(TARGET_IDLS),$(call COMPILE_idl_template,$(SOURCES_DIR)/$(idl),$(idl:%.idl=%)))
-$(call COMPILE_templates,$(TARGET_SOURCES),.o)
+$(call COMPILE_templates,$(TARGET_SOURCES_ABS),.o)
$(2)/$(1)$(3): $(TARGET_OBJS)
@$(QUIET_CMD_ECHO) " LINK $$@"
$(foreach idl,$(TARGET_IDLS),$(call COMPILE_idl_template,$(SOURCES_DIR)/$(idl),$(idl:%.idl=%)))
-$(call COMPILE_templates,$(TARGET_SOURCES),.o)
+$(call COMPILE_templates,$(TARGET_SOURCES_ABS),.o)
$(USER_LIB_DIR)/lib$(1).a: $(TARGET_OBJS)
@$(QUIET_CMD_ECHO) " AR $$@"
$(foreach idl,$(TARGET_IDLS),$(call COMPILE_idl_template,$(SOURCES_DIR)/$(idl),$(idl:%.idl=%)))
-$(call COMPILE_templates,$(TARGET_SOURCES),.lo)
+$(call COMPILE_templates,$(TARGET_SOURCES_ABS),.lo)
.PHONY: $(OMK_WORK_DIR)/lib$(1).$(SOLIB_EXT).omkvar
$(OMK_WORK_DIR)/lib$(1).$(SOLIB_EXT).omkvar: AM_CFLAGS += $(SOLIB_PICFLAGS)
$(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))))