D implementation
[jackhill/mal.git] / d / Makefile
1 CFLAGS += -g -O2 -Wall
2 LDFLAGS += -lreadline
3
4 #####################
5
6 TESTS =
7
8 SOURCES_BASE = readline.d types.d reader.d printer.d
9 SOURCES_LISP = env.d mal_core.d stepA_mal.d
10 SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)
11
12 #####################
13
14 EARLY_SRCS = step0_repl.d step1_read_print.d step2_eval.d
15 LATE_SRCS = step3_env.d step4_if_fn_do.d step5_tco.d step6_file.d \
16 step7_quote.d step8_macros.d step9_try.d stepA_mal.d
17 SRCS = $(EARLY_SRCS) $(LATE_SRCS)
18 OBJS = $(SRCS:%.d=%.o)
19 BINS = $(OBJS:%.o=%)
20 EARLY_OBJS = types.o readline.o reader.o printer.o env.o
21 OTHER_OBJS = $(EARLY_OBJS) mal_core.o
22 EARLY_STEPS_BINS = $(EARLY_SRCS:%.d=%)
23 LATE_STEPS_BINS = $(LATE_SRCS:%.d=%)
24
25 #####################
26
27 all: $(BINS) mal
28
29 mal: $(word $(words $(BINS)),$(BINS))
30 cp $< $@
31
32 $(OBJS) $(OTHER_OBJS): %.o: %.d
33 gdc $(CFLAGS) -c $(@:%.o=%.d) -o $@
34
35 $(EARLY_STEPS_BINS): $(EARLY_OBJS)
36 $(LATE_STEPS_BINS): $(OTHER_OBJS)
37
38 $(BINS): %: %.o
39 gdc $+ -o $@ $(LDFLAGS)
40
41 clean:
42 rm -f $(OBJS) $(BINS) $(OTHER_OBJS) mal
43
44 .PHONY: stats stats-lisp tests $(TESTS)
45
46 stats: $(SOURCES)
47 @wc $^
48 @printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*//|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"
49 stats-lisp: $(SOURCES_LISP)
50 @wc $^
51 @printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*//|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"
52
53 tests: $(TESTS)
54
55 $(TESTS):
56 @echo "Running $@"; \
57 ./$@ || exit 1; \