Objective-C: steps 5-A, self-hosting, perf, README
[jackhill/mal.git] / objc / Makefile
1 STEP0_DEPS = mal_readline.c mal_readline.h
2 STEP1_DEPS = $(STEP0_DEPS) types.h types.m reader.h reader.m printer.h printer.m
3 STEP2_DEPS = $(STEP1_DEPS)
4 STEP3_DEPS = $(STEP2_DEPS) env.m
5 STEP4_DEPS = $(STEP3_DEPS) malfunc.h malfunc.m core.h core.m
6
7 SOURCES = $(STEP4_DEPS) stepA_mal.m
8 SOURCES_LISP = env.h env.m core.h core.m stepA_mal.m
9
10 STEPS = step0_repl step1_read_print step2_eval step3_env \
11 step4_if_fn_do step5_tco step6_file step7_quote \
12 step8_macros step9_try stepA_mal
13
14 # From: https://blog.tlensing.org/2013/02/24/objective-c-on-linux-setting-up-gnustep-clang-llvm-objective-c-2-0-blocks-runtime-gcd-on-ubuntu-12-04/:
15 # clang `gnustep-config --objc-flags` -o main -x objective-c main.m -fconstant-string-class=NSConstantString -fobjc-nonfragile-abi -fblocks -lgnustep-base -lgnustep-gui -ldispatch -I/usr/local/include/GNUstep -L/usr/local/lib/GNUstep
16
17 CC = clang
18 LD = ld
19 #OBJCC = clang -fblocks -fobjc-nonfragile-abi -fobjc-arc -x objective-c
20 OBJCC = clang -fblocks -fobjc-nonfragile-abi -x objective-c
21 ## Bizzare gnustep-config/make interaction causes make to get run
22 ## during gnustep-config so we need to remove make output
23 OBJC_FLAGS := $(shell gnustep-config --objc-flags | egrep -v "Entering|Leaving")
24 OBJC_LIBS := $(filter-out -shared-libgcc,$(shell gnustep-config --base-libs | egrep -v "Entering|Leaving")) -ldispatch -lreadline
25
26 all: $(STEPS)
27
28 dist: mal
29
30 mal: stepA_mal
31 cp $< $@
32
33 step0_repl: $(STEP0_DEPS)
34 step1_read_print: $(STEP1_DEPS)
35 step2_eval: $(STEP2_DEPS)
36 step3_env: $(STEP3_DEPS)
37 step4_if_fn_do step5_tco step6_file step7_quote step8_macros step9_try stepA_mal: $(STEP4_DEPS)
38
39 step%: step%.m
40 $(OBJCC) $(filter-out %.h mal_readline%,$+) -xc mal_readline.c -o $@ $(OBJC_FLAGS) $(OBJC_LIBS)
41
42 %.o: %.c
43 $(CC) -c $< -o $@ $(CFLAGS)
44
45 %.o: %.m
46 $(OBJCC) -c $< -o $@ $(OBJC_FLAGS)
47
48 clean:
49 rm -f $(STEPS) *.o *.d mal
50
51 .PHONY: stats tests
52
53 stats: $(SOURCES)
54 @wc $^
55 @printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*//|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"
56 stats-lisp: $(SOURCES_LISP)
57 @wc $^
58 @printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*//|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"