Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 21 additions & 53 deletions impls/ada.2/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include ../../steps.mk

ifdef DEBUG
ADAFLAGS := -Wall -Wextra -gnatw.eH.Y -gnatySdouxy -gnatVa -g -gnataEfoqQ \
-fstack-check -pg
Expand All @@ -13,62 +15,28 @@ CARGS = $(ADAFLAGS)
# Linker arguments.
LARGS = $(LDFLAGS) -lreadline

step0 := step0_repl
step13 := step1_read_print \
step2_eval \
step3_env
step49 := step4_if_fn_do \
step5_tco \
step6_file \
step7_quote \
step8_macros \
step9_try
stepa := stepA_mal
steps := $(step0) $(step13) $(step49) $(stepa)

.PHONY: all clean
all: $(steps)
all: $(step0A)
clean:
$(RM) *~ *.adt *.ali *.o b~*.ad[bs] gmon.out $(steps)
$(RM) *~ *.adt *.ali *.o b~*.ad[bs] gmon.out $(step0A)

# Tell Make how to detect out-of-date executables, and let gnatmake do
# the rest when it must be executed.
sources = $(foreach unit,$1,$(unit).adb $(unit).ads)
TYPES := $(call sources,\
envs \
err \
garbage_collected \
printer \
reader \
readline \
types \
types-atoms \
types-builtins \
types-fns \
types-maps \
types-sequences \
types-strings \
)
CORE := $(call sources,\
core \
)

$(step0) : %: %.adb
$(step13): %: %.adb $(TYPES)
$(step49): %: %.adb $(TYPES) $(CORE)
$(stepa) : stepA%: stepa%.adb $(TYPES) $(CORE)
$(steps) :
$(step09): %: %.adb
$(stepA): stepa_mal.adb
$(step1A): envs.adb envs.ads
$(step1A): err.adb err.ads
$(step1A): garbage_collected.adb garbage_collected.ads
$(step1A): printer.adb printer.ads
$(step1A): reader.adb reader.ads
$(step1A): readline.adb readline.ads
$(step1A): types.adb types.ads
$(step1A): types-atoms.adb types-atoms.ads
$(step1A): types-builtins.adb types-builtins.ads
$(step1A): types-fns.adb types-fns.ads
$(step1A): types-maps.adb types-maps.ads
$(step1A): types-sequences.adb types-sequences.ads
$(step1A): types-strings.adb types-strings.ads
$(step4A): core.adb core.ads
$(step0A):
gnatmake $< -o $@ -cargs $(CARGS) -largs $(LARGS)

.PHONY: steps.diff
steps.diff:
diff -u step0_*.adb step1_*.adb || true
diff -u step1_*.adb step2_*.adb || true
diff -u step2_*.adb step3_*.adb || true
diff -u step3_*.adb step4_*.adb || true
diff -u step4_*.adb step5_*.adb || true
diff -u step5_*.adb step6_*.adb || true
diff -u step6_*.adb step7_*.adb || true
diff -u step7_*.adb step8_*.adb || true
diff -u step8_*.adb step9_*.adb || true
diff -u step9_*.adb stepa_*.adb || true
23 changes: 8 additions & 15 deletions impls/ada/Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
PROGS=step0_repl step1_read_print step2_eval step3_env step4_if_fn_do \
step5_tco step6_file step7_quote step8_macros step9_try
include ../../steps.mk

all: ${PROGS} stepA_mal
all: $(step0A)

obj:
mkdir -p $@
mkdir obj

# stepA_mal is awkward because GNAT requires the filename to be lowercase
${PROGS} stepa_mal: force obj
gnatmake -O3 -gnata $@.adb -D obj

# so we make stepa_mal and just move it.
stepA_mal: stepa_mal
mv $< $@
$(step0A): | obj
gnatmake -O3 -gnata $(subst A,a,$@).adb -D obj -o $@
# Delegate the dependency handling to gnatmake.
.PHONY: $(step0A)

clean:
rm -f ${PROGS}
rm -f $(step0A)
rm -rf obj

.PHONY: force

force:
31 changes: 15 additions & 16 deletions impls/basic/Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
include ../../steps.mk

basic_MODE = cbm
BASICPP_OPTS = --mode $(basic_MODE)

FBC = fbc -lang qb

STEPS4_A = step4_if_fn_do.bas step5_tco.bas step6_file.bas \
step7_quote.bas step8_macros.bas step9_try.bas stepA_mal.bas
STEPS3_A = step3_env.bas $(STEPS4_A)
STEPS1_A = step1_read_print.bas step2_eval.bas $(STEPS3_A)
STEPS0_A = step0_repl.bas $(STEPS1_A)

all: $(if $(filter qbasic,$(basic_MODE)),$(subst .bas,,$(STEPS0_A)),$(STEPS0_A))

$(STEPS0_A): debug.in.bas mem.in.bas readline.in.bas
$(STEPS1_A): types.in.bas reader.in.bas printer.in.bas
$(STEPS3_A): env.in.bas
$(STEPS4_A): core.in.bas
ifeq (qbasic,$(basic_MODE))
all: $(step0A)
else
all: $(step0A:=.bas)
endif

$(step0A:=.bas): debug.in.bas mem.in.bas readline.in.bas
$(step1A:=.bas): types.in.bas reader.in.bas printer.in.bas
$(step3A:=.bas): env.in.bas
$(step4A:=.bas): core.in.bas


step%.bas: step%.in.bas
$(step0A:=.bas): %.bas: %.in.bas
./basicpp.py $(BASICPP_OPTS) $< > $@

tests/%.bas: tests/%.in.bas
./basicpp.py $(BASICPP_OPTS) $< > $@

# QBasic specific compilation rule
step%: step%.bas
$(step0A): %: %.bas
$(FBC) $< -x $@

# CBM/C64 image rules

%.prg: %.bas
$(step0A:=.prg): %.prg: %.bas
cat $< | tr "A-Z" "a-z" > $<.tmp
#cat $< | sed 's/["]\@<!\<\w\+\>["]\@!/\L&/g' > $<.tmp
petcat -w2 -nc -o $@ $<.tmp
Expand Down Expand Up @@ -58,5 +57,5 @@ mal.d64: mal.prg .args.mal.prg core.mal.prg
.PHONY: clean

clean:
rm -f $(STEPS0_A) $(subst .bas,,$(STEPS0_A)) *.d64 *.prg
rm -f $(step0A:=.bas) $(step0A) *.d64 *.prg
rm -rf ./internal
31 changes: 8 additions & 23 deletions impls/c.2/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include ../../steps.mk

CC = gcc

CFLAGS = -std=c99 -g -Wall -Wextra -fanalyzer
Expand Down Expand Up @@ -40,37 +42,20 @@ pkgconfig_modules += bdw-gc
CFLAGS += $(shell pkg-config --cflags $(pkgconfig_modules))
LDLIBS += $(shell pkg-config --libs $(pkgconfig_modules))

S0 = step0_repl
S1 = step1_read_print
S2 = step2_eval
S3 = step3_env
S4 = step4_if_fn_do
S5 = step5_tco
S6 = step6_file
S7 = step7_quote
S8 = step8_macros
S9 = step9_try
SA = stepA_mal

S4+ := $(S4) $(S5) $(S6) $(S7) $(S8) $(S9) $(SA)
S3+ := $(S3) $(S4+)
S1+ := $(S1) $(S2) $(S3+)
S0+ := $(S0) $(S1+)

all: $(S0+)
all: $(step0A)

# GCC could create temporary objects files, but separate recipes for
# .o objects give faster build cycles when debugging.
$(S0+): readline.o
$(S1+): error.o hashmap.o linked_list.o printer.o reader.o types.o vector.o
$(S3+): env.o
$(S4+): core.o
$(step0A): readline.o
$(step1A): error.o hashmap.o linked_list.o printer.o reader.o types.o vector.o
$(step3A): env.o
$(step4A): core.o

include deps
deps:
$(CC) -MM -MF- *.c > $@

clean:
rm -f $(S0+) *.o deps gmon.out
rm -f $(step0A) *.o deps gmon.out

.PHONY: all clean
19 changes: 8 additions & 11 deletions impls/c/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
include ../../steps.mk

USE_READLINE ?=
USE_GC ?= 1
CFLAGS ?= -g -O2
LDFLAGS ?= -g

#####################

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_try.c stepA_mal.c
OBJS = $(SRCS:%.c=%.o)
BINS = $(OBJS:%.o=%)
OTHER_OBJS = types.o readline.o reader.o printer.o env.o core.o interop.o
OTHER_HDRS = types.h readline.h reader.h printer.h core.h interop.h

Expand Down Expand Up @@ -45,17 +42,17 @@ override LDLIBS += \

#####################

all: $(BINS)
all: $(step0A)

dist: mal

mal: $(word $(words $(BINS)),$(BINS))
mal: $(stepA)
cp $< $@

$(OBJS) $(OTHER_OBJS): %.o: %.c $(OTHER_HDRS)
$(step0A:=.o) $(OTHER_OBJS): %.o: %.c $(OTHER_HDRS)

$(patsubst %.o,%,$(filter step%,$(OBJS))): $(OTHER_OBJS)
$(BINS): %: %.o
$(step0A): $(OTHER_OBJS)
$(step0A): %: %.o

clean:
rm -f $(OBJS) $(BINS) $(OTHER_OBJS) mal
rm -f *.o $(step0A) mal
9 changes: 3 additions & 6 deletions impls/coffee/Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
include ../../steps.mk

SOURCES_BASE = node_readline.coffee types.coffee \
reader.coffee printer.coffee
SOURCES_LISP = env.coffee core.coffee stepA_mal.coffee
SOURCES = $(SOURCES_BASE) $(SOURCES_LISP)

STEPS = step0_repl.coffee step1_read_print.coffee \
step2_eval.coffee step3_env.coffee step4_if_fn_do.coffee \
step5_tco.coffee step6_file.coffee step7_quote.coffee \
step8_macros.coffee step9_try.coffee stepA_mal.coffee

all: node_modules dist

node_modules:
npm install

$(STEPS): node_modules
$(step0A:=.coffee): node_modules

dist: mal.coffee mal

Expand Down
9 changes: 4 additions & 5 deletions impls/common-lisp/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include ../../steps.mk

# Helper functions
define record_lisp
$(shell (test -f "hist/$(1)_impl" && grep -q $(2) "hist/$(1)_impl") || echo $(2) > "hist/$(1)_impl")
Expand All @@ -15,9 +17,6 @@ LISP ?= sbcl
ABCL ?= abcl
MKCL ?= mkcl

BINS = step0_repl step1_read_print step2_eval step3_env step4_if_fn_do \
step5_tco step6_file step7_quote step8_macros step9_try stepA_mal

# TODO: In theory cl-launch should be able to build standalone executable using
# MKCL unfortunately the executable crashes on startup
STANDALONE_EXE = sbcl clisp ccl ecl cmucl
Expand All @@ -31,15 +30,15 @@ $(foreach step, $(call steps), $(call record_lisp,$(patsubst step%,%,$(step)),$(

.PRECIOUS: hist/%_impl

all : $(BINS)
all : $(step0A)

hist/%_impl: ;

# CL_LAUNCH_VERSION is only defined while building it. We change to the
# directory of the CL_LAUNCH_FILE in --wrap script so that the script can find the dumped
# image even if invoked from some directory different from where it
# currently resides
step% : src/step%.lisp src/utils.lisp src/types.lisp src/env.lisp src/printer.lisp src/reader.lisp src/core.lisp hist/%_impl
$(step0A): step% : src/step%.lisp src/utils.lisp src/types.lisp src/env.lisp src/printer.lisp src/reader.lisp src/core.lisp hist/%_impl

ifeq ($(LISP),clisp)
@echo "=============================================================="
Expand Down
11 changes: 5 additions & 6 deletions impls/cpp/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include ../../steps.mk

uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')

CXX=g++
Expand All @@ -19,14 +21,11 @@ LIBSOURCES=Core.cpp Environment.cpp Reader.cpp ReadLine.cpp String.cpp \
Types.cpp Validation.cpp
LIBOBJS=$(LIBSOURCES:%.cpp=%.o)

MAINS=$(wildcard step*.cpp)
TARGETS=$(MAINS:%.cpp=%)

.PHONY: all clean

.SUFFIXES: .cpp .o

all: $(TARGETS)
all: $(step0A)

dist: mal

Expand All @@ -36,7 +35,7 @@ mal: stepA_mal
.deps: *.cpp *.h
$(CXX) $(CXXFLAGS) -MM *.cpp > .deps

$(TARGETS): %: %.o libmal.a
$(step0A): %: %.o libmal.a
$(LD) $^ -o $@ $(LDFLAGS)

libmal.a: $(LIBOBJS)
Expand All @@ -46,6 +45,6 @@ libmal.a: $(LIBOBJS)
$(CXX) $(CXXFLAGS) -c $< -o $@

clean:
rm -rf *.o $(TARGETS) libmal.a .deps mal
rm -rf *.o $(step0A) libmal.a .deps mal

-include .deps
11 changes: 5 additions & 6 deletions impls/crystal/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
STEPS = step0_repl step1_read_print step2_eval step3_env \
step4_if_fn_do step5_tco step6_file step7_quote step8_macros \
step9_try stepA_mal
all: $(STEPS)
$(STEPS):
include ../../steps.mk

all: $(step0A)
$(step0A):
shards build $@ --release
clean:
rm -rf .cache/crystal/ .cache/shards/ bin/ lib/
.PHONY: all clean $(STEPS)
.PHONY: all clean $(step0A)
Loading
Loading