aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--cm-demo.c3
-rw-r--r--makefile22
3 files changed, 24 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 8109a16..17cec88 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
*.o
*.d
*.json
-.cache/ \ No newline at end of file
+.cache/
+/cm-demo
diff --git a/cm-demo.c b/cm-demo.c
new file mode 100644
index 0000000..a349379
--- /dev/null
+++ b/cm-demo.c
@@ -0,0 +1,3 @@
+#include "cheesemap.h"
+
+int main() {}
diff --git a/makefile b/makefile
index 429dd50..03f0e1d 100644
--- a/makefile
+++ b/makefile
@@ -2,6 +2,7 @@
CM_OPT_RELEASE ?= 0
CM_OPT_CC_FLAGS ?=
CM_OPT_ASSERT_PATH ?= <assert.h>
+CM_OPT_ENABLE_DEMO ?= 1
CC ?= gcc
@@ -11,6 +12,10 @@ CM_SOURCE := $(CM_DIR)/cheesemap.c
CM_OBJECT := $(CM_SOURCE:.c=.o)
CM_DEPEND := $(CM_SOURCE:.c=.d)
+CM_DEMO_SOURCE := $(CM_DIR)/cm-demo.c
+CM_DEMO := $(CM_DEMO_SOURCE:.c=)
+CM_DEMO_DEPEND := $(CM_DEMO_SOURCE:.c=.d)
+
CM_CC_FLAGS := \
-Wall -Wextra \
-MMD -MP -I$(CM_DIR)
@@ -25,13 +30,24 @@ CM_CC_FLAGS += $(CM_OPT_CC_FLAGS)
CM_CC_FLAGS += -DCM_OPT_ASSERT_PATH='$(CM_OPT_ASSERT_PATH)'
.PHONY: all
-all: $(CM_OBJECT)
+all:: $(CM_OBJECT)
$(CM_OBJECT): $(CM_SOURCE)
- $(CC) $(CM_CC_FLAGS) -c $< -o $@
+ $(CC) $(CM_CC_FLAGS) -c $^ -o $@
+
+ifeq ($(CM_OPT_ENABLE_DEMO),1)
+.PHONY: all
+all:: $(CM_DEMO)
+
+$(CM_DEMO): $(CM_DEMO_SOURCE) $(CM_OBJECT)
+ $(CC) $(CM_CC_FLAGS) $^ -o $@
+endif
.PHONY: clean
clean::
$(RM) $(CM_OBJECT) $(CM_DEPEND)
+ifeq ($(CM_OPT_ENABLE_DEMO),1)
+ $(RM) $(CM_DEMO) $(CM_DEMO_DEPEND)
+endif
--include $(CM_DEPEND)
+-include $(CM_DEPEND) $(CM_DEMO_DEPEND)