2008-02-25 14:10:17 +00:00
|
|
|
###############################################
|
2002-11-21 04:08:37 +00:00
|
|
|
# Common build rules, used by the sub modules and their module.mk files
|
2008-02-25 14:10:17 +00:00
|
|
|
#
|
|
|
|
###############################################
|
|
|
|
|
2002-11-21 04:08:37 +00:00
|
|
|
|
2004-05-06 09:58:48 +00:00
|
|
|
# Copy the list of objects to a new variable. The name of the new variable
|
|
|
|
# contains the module name, a trick we use so we can keep multiple different
|
|
|
|
# module object lists, one for each module.
|
2006-02-12 00:16:31 +00:00
|
|
|
MODULE_OBJS-$(MODULE) := $(addprefix $(MODULE)/, $(MODULE_OBJS))
|
2003-09-18 13:03:56 +00:00
|
|
|
|
2006-06-24 08:48:11 +00:00
|
|
|
# Add all involved directories to the MODULE_DIRS list
|
|
|
|
MODULE_DIRS += $(sort $(dir $(MODULE_OBJS-$(MODULE))))
|
|
|
|
|
|
|
|
|
2008-02-25 14:10:17 +00:00
|
|
|
|
|
|
|
ifdef TOOL_EXECUTABLE
|
|
|
|
################################################
|
|
|
|
# Build rule for (tool) executables.
|
|
|
|
# TODO: Refactor this, so that even our master executable can use this rule?
|
|
|
|
################################################
|
|
|
|
TOOL-$(MODULE) := $(MODULE)/$(TOOL_EXECUTABLE)$(EXEEXT)
|
2011-06-01 21:50:27 +00:00
|
|
|
$(TOOL-$(MODULE)): $(MODULE_OBJS-$(MODULE)) $(TOOL_DEPS)
|
2009-08-22 11:03:00 +00:00
|
|
|
$(QUIET_CXX)$(CXX) $(LDFLAGS) $+ -o $@
|
2008-02-25 14:10:17 +00:00
|
|
|
|
2011-06-01 21:50:27 +00:00
|
|
|
# Reset TOOL_* vars
|
2008-02-25 14:10:17 +00:00
|
|
|
TOOL_EXECUTABLE:=
|
2011-06-01 21:50:27 +00:00
|
|
|
TOOL_DEPS:=
|
2008-02-25 14:10:17 +00:00
|
|
|
|
2011-04-09 21:47:35 +00:00
|
|
|
# Add to "devtools" target
|
|
|
|
devtools: $(TOOL-$(MODULE))
|
2008-02-25 14:10:17 +00:00
|
|
|
|
2011-04-09 21:47:35 +00:00
|
|
|
# Pseudo target for comfort, allows for "make devtools/skycpt", etc.
|
2008-02-25 14:10:17 +00:00
|
|
|
$(MODULE): $(TOOL-$(MODULE))
|
2011-04-09 21:47:35 +00:00
|
|
|
clean-devtools: clean-$(MODULE)
|
2008-02-25 14:10:17 +00:00
|
|
|
|
|
|
|
else
|
2003-09-18 13:03:56 +00:00
|
|
|
ifdef PLUGIN
|
2008-02-25 14:10:17 +00:00
|
|
|
################################################
|
|
|
|
# Build rule for dynamic (loadable) plugins
|
|
|
|
################################################
|
2006-02-12 12:54:41 +00:00
|
|
|
PLUGIN-$(MODULE) := plugins/$(PLUGIN_PREFIX)$(notdir $(MODULE))$(PLUGIN_SUFFIX)
|
2006-02-12 00:16:31 +00:00
|
|
|
$(PLUGIN-$(MODULE)): $(MODULE_OBJS-$(MODULE)) $(PLUGIN_EXTRA_DEPS)
|
2009-08-22 11:03:00 +00:00
|
|
|
$(QUIET)$(MKDIR) plugins
|
|
|
|
$(QUIET_PLUGIN)$(CXX) $(filter-out $(PLUGIN_EXTRA_DEPS),$+) $(PLUGIN_LDFLAGS) -o $@
|
2008-02-25 14:10:17 +00:00
|
|
|
|
|
|
|
# Reset PLUGIN var
|
2003-09-18 13:03:56 +00:00
|
|
|
PLUGIN:=
|
2008-02-25 14:10:17 +00:00
|
|
|
|
|
|
|
# Add to "plugins" target
|
2003-09-18 13:03:56 +00:00
|
|
|
plugins: $(PLUGIN-$(MODULE))
|
|
|
|
|
2008-05-02 14:30:06 +00:00
|
|
|
# Add to the PLUGINS variable
|
|
|
|
PLUGINS += $(PLUGIN-$(MODULE))
|
|
|
|
|
2004-05-06 09:58:48 +00:00
|
|
|
# Pseudo target for comfort, allows for "make common", "make gui" etc.
|
|
|
|
$(MODULE): $(PLUGIN-$(MODULE))
|
2008-02-25 14:10:17 +00:00
|
|
|
clean-plugins: clean-$(MODULE)
|
2004-05-06 09:58:48 +00:00
|
|
|
|
2003-09-18 13:03:56 +00:00
|
|
|
else
|
2008-02-25 14:10:17 +00:00
|
|
|
################################################
|
|
|
|
# Build rule for static modules/plugins
|
|
|
|
################################################
|
2004-05-06 09:58:48 +00:00
|
|
|
MODULE_LIB-$(MODULE) := $(MODULE)/lib$(notdir $(MODULE)).a
|
|
|
|
|
2003-09-18 13:03:56 +00:00
|
|
|
# If not building as a plugin, add the object files to the main OBJS list
|
|
|
|
OBJS += $(MODULE_LIB-$(MODULE))
|
2002-11-21 04:08:37 +00:00
|
|
|
|
2003-09-08 15:34:50 +00:00
|
|
|
# Convenience library target
|
2006-02-12 00:16:31 +00:00
|
|
|
$(MODULE_LIB-$(MODULE)): $(MODULE_OBJS-$(MODULE))
|
2009-08-22 11:03:00 +00:00
|
|
|
$(QUIET)-$(RM) $@
|
|
|
|
$(QUIET_AR)$(AR) $@ $+
|
|
|
|
$(QUIET_RANLIB)$(RANLIB) $@
|
2003-09-08 15:34:50 +00:00
|
|
|
|
2002-11-21 04:08:37 +00:00
|
|
|
# Pseudo target for comfort, allows for "make common", "make gui" etc.
|
2003-09-08 15:34:50 +00:00
|
|
|
$(MODULE): $(MODULE_LIB-$(MODULE))
|
2002-11-21 04:08:37 +00:00
|
|
|
|
2008-02-25 14:10:17 +00:00
|
|
|
endif # PLUGIN
|
|
|
|
endif # TOOL_EXECUTABLE
|
2004-05-06 09:58:48 +00:00
|
|
|
|
2008-02-25 14:10:17 +00:00
|
|
|
###############################################
|
2004-05-06 09:58:48 +00:00
|
|
|
# Clean target, removes all object files. This looks a bit hackish, as we have to
|
|
|
|
# copy the content of MODULE_OBJS to another unique variable (the next module.mk
|
|
|
|
# will overwrite it after all). The same for the libMODULE.a library file.
|
2008-02-25 14:10:17 +00:00
|
|
|
###############################################
|
2004-05-06 09:58:48 +00:00
|
|
|
clean: clean-$(MODULE)
|
|
|
|
clean-$(MODULE): clean-% :
|
2008-02-25 14:10:17 +00:00
|
|
|
-$(RM) $(MODULE_OBJS-$*) $(MODULE_LIB-$*) $(PLUGIN-$*) $(TOOL-$*)
|
2004-05-06 09:58:48 +00:00
|
|
|
|
2002-11-21 04:08:37 +00:00
|
|
|
.PHONY: clean-$(MODULE) $(MODULE)
|