summaryrefslogtreecommitdiff
path: root/build/macros.mk
diff options
context:
space:
mode:
authorNicolas Schodet2012-10-11 19:13:35 +0200
committerNicolas Schodet2019-10-06 23:26:07 +0200
commit006022d6be3ceadcd5910ebc09d6465f81af6d55 (patch)
treedaff6f8fe26bae042a8ae41aea332179e80a8a8d /build/macros.mk
Add ucoolib build system and basic arch module
Diffstat (limited to 'build/macros.mk')
-rw-r--r--build/macros.mk17
1 files changed, 17 insertions, 0 deletions
diff --git a/build/macros.mk b/build/macros.mk
new file mode 100644
index 0000000..8ae3244
--- /dev/null
+++ b/build/macros.mk
@@ -0,0 +1,17 @@
+# ucoolib - Microcontroller object oriented library.
+#
+# Usefull macros.
+
+# Return $(A) only if defined, else return B.
+# $(call defval,A,B)
+defval = $(if $(filter undefined,$(origin $1)),$2,$($1))
+
+# Filter out source file for other targets, return basenames.
+# $(call filter_sources,TARGET,SOURCES)
+filter_sources = $(call filter_sources_sub,$1,$(basename $2))
+filter_sources_sub = $(foreach t,$1 $($1_SUBTARGETS),$(filter %.$t,$2)) \
+ $(foreach f,$2,$(if $(findstring .,$f),,$f))
+
+# Test if one of the source is C++, in this case, return cc, else return c.
+# $(call iscxx,SOURCES)
+iscxx = $(if $(filter %.cc,$1),cc,c)