aboutsummaryrefslogtreecommitdiff
path: root/c/Makefile
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-03-24 16:32:24 -0500
committerJoel Martin <github@martintribe.org>2014-03-24 16:32:24 -0500
commit3169070063b2cb877200117ebb384269d73bcb93 (patch)
tree23de3db1ea5c37afd21a45b6ed7771f56a08c0c4 /c/Makefile
downloadmal-3169070063b2cb877200117ebb384269d73bcb93.tar.gz
mal-3169070063b2cb877200117ebb384269d73bcb93.zip
Current state of mal for Clojure West lighting talk.
Diffstat (limited to 'c/Makefile')
-rw-r--r--c/Makefile61
1 files changed, 61 insertions, 0 deletions
diff --git a/c/Makefile b/c/Makefile
new file mode 100644
index 0000000..397bcbf
--- /dev/null
+++ b/c/Makefile
@@ -0,0 +1,61 @@
+USE_READLINE ?=
+CFLAGS += -g
+LDFLAGS += -g
+
+#####################
+
+TESTS =
+
+SOURCES = types.h types.c readline.h readline.c reader.h reader.c \
+ interop.h interop.c stepA_more.c
+
+#####################
+
+SRCS = step0_repl.c step1_read_print.c step2_eval.c step3_env.c \
+ step4_if_fn_do.c step5_tco.c step6_file.c step7_quote.c \
+ step8_macros.c step9_interop.c stepA_more.c
+OBJS = $(SRCS:%.c=%.o)
+BINS = $(OBJS:%.o=%)
+OTHER_OBJS = types.o readline.o reader.o interop.o
+OTHER_HDRS = types.h readline.h reader.h interop.h
+
+GLIB_CFLAGS ?= $(shell pkg-config --cflags glib-2.0)
+GLIB_LDFLAGS ?= $(shell pkg-config --libs glib-2.0)
+
+ifeq (,$(USE_READLINE))
+RL_LIBRARY ?= edit
+else
+RL_LIBRARY ?= readline
+CFLAGS += -DUSE_READLINE=1
+endif
+
+CFLAGS += $(GLIB_CFLAGS)
+LDFLAGS += -l$(RL_LIBRARY) $(GLIB_LDFLAGS) -ldl -lffi
+
+#####################
+
+all: $(BINS) mal
+
+mal: $(word $(words $(BINS)),$(BINS))
+ cp $< $@
+
+$(OBJS) $(OTHER_OBJS): %.o: %.c $(OTHER_HDRS)
+ gcc $(CFLAGS) -c $(@:%.o=%.c) -o $@
+
+$(patsubst %.o,%,$(filter step%,$(OBJS))): $(OTHER_OBJS)
+$(BINS): %: %.o
+ gcc $+ -o $@ $(LDFLAGS)
+
+clean:
+ rm -f $(OBJS) $(BINS) $(OTHER_OBJS) mal
+
+.PHONY: stats tests $(TESTS)
+
+stats: $(SOURCES)
+ @wc $^
+
+tests: $(TESTS)
+
+$(TESTS):
+ @echo "Running $@"; \
+ ./$@ || exit 1; \