aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common.rules29
1 files changed, 18 insertions, 11 deletions
diff --git a/common.rules b/common.rules
index c533f0f070..e48bf98f1b 100644
--- a/common.rules
+++ b/common.rules
@@ -1,7 +1,9 @@
# Common build rules, used by the sub modules and their module.mk files
+# 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.
MODULE_OBJS-$(MODULE) := $(MODULE_OBJS)
-MODULE_LIB-$(MODULE) := $(MODULE)/lib$(notdir $(MODULE)).a
ifdef PLUGIN
# Plugin build rule
@@ -14,19 +16,15 @@ $(PLUGIN-$(MODULE)): $(MODULE_OBJS) $(EXECUTABLE)
PLUGIN:=
plugins: $(PLUGIN-$(MODULE))
+# Pseudo target for comfort, allows for "make common", "make gui" etc.
+$(MODULE): $(PLUGIN-$(MODULE))
+
else
+MODULE_LIB-$(MODULE) := $(MODULE)/lib$(notdir $(MODULE)).a
+
# If not building as a plugin, add the object files to the main OBJS list
OBJS += $(MODULE_LIB-$(MODULE))
-endif
-
-
-# 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.
-clean: clean-$(MODULE)
-clean-$(MODULE): clean-% :
- -$(RM) $(MODULE_OBJS-$*) $(MODULE_LIB-$*) $(PLUGIN-$*)
# Convenience library target
$(MODULE_LIB-$(MODULE)): $(MODULE_OBJS)
@@ -34,8 +32,17 @@ $(MODULE_LIB-$(MODULE)): $(MODULE_OBJS)
$(AR) $@ $+
$(RANLIB) $@
-
# Pseudo target for comfort, allows for "make common", "make gui" etc.
$(MODULE): $(MODULE_LIB-$(MODULE))
+endif
+
+
+# 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.
+clean: clean-$(MODULE)
+clean-$(MODULE): clean-% :
+ -$(RM) $(MODULE_OBJS-$*) $(MODULE_LIB-$*) $(PLUGIN-$*)
+
.PHONY: clean-$(MODULE) $(MODULE)