about summary refs log tree commit diff
path: root/Makefile
blob: bc091f0f92fa02b25544063b284917352c3174bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
MUSL_LIB ?= /usr/lib/musl
MUSL_DEV ?= /usr/include/musl

DEFINES ?= -DMUSL_LIB=\"$(MUSL_LIB)\" -DMUSL_DEV=\"$(MUSL_DEV)\"
CFLAGS ?= -std=c99 -Wall -Werror -static -g -O0 $(DEFINES)

.DEFAULT_GOAL := all

BOOTSTRAP_SOURCES = boot/catboot.c boot/catboot.h boot/common.c boot/lex.c boot/tree.c boot/visit.c boot/parse.c boot/transpile.c boot/build.c
BOOTSTRAP_TEST_SOURCES = boot/tests/test.c
SOURCES = src/catskill.csk

build/catskill: build $(SOURCES)
	echo "No catskill compiler exists yet. Building empty file."
	touch ./build/catskill

build/catboot: build $(BOOTSTRAP_SOURCES) boot/scripts/embed.sh
	./boot/scripts/embed.sh $(BOOTSTRAP_SOURCES)
	$(CC) $(CFLAGS) -o ./build/catboot ./build/boot/catboot.c

build/catboot-test: build $(BOOTSTRAP_TEST_SOURCES)
	$(CC) $(CFLAGS) -o ./build/catboot-test ./boot/tests/test.c

build:
	mkdir -p ./build

.PHONY: all run run-boot clean test test-all

all: build/catskill build/catboot build/catboot-test

run: build/catskill
	echo "Not implemented yet."

run-boot: build/catboot
	./build/catboot $(ARGS)

test: build/catboot-test
	./build/catboot-test $(ARGS)

test-all: build/catboot-test
	./build/catboot-test all

clean:
	rm -rf build/*