diff options
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..97c1baf --- /dev/null +++ b/Makefile @@ -0,0 +1,56 @@ +# No separable compilation here, the program is too small to bother + +CC = gcc +CFLAGS = -Wall -Wextra -Werror -ggdb3 +SRCS = $(wildcard src/*.c) + +.PHONY: compile test clean + + +build/cupcc: build FORCE + $(CC) $(CFLAGS) -o $@ $(SRCS) + +compile: build/cupcc + +FORCE: + +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Linux) + +%.o: %.nasm FORCE + nasm -felf64 $< -o $@ + +%.out: %.o FORCE + ld -o $@ $< + +endif +ifeq ($(UNAME_S),Darwin) + +%.o: %.nasm FORCE + nasm -fmacho64 $< -o $@ + +%.out: %.o FORCE + ld $< -o $@ -lSystem + +endif + +build: + @mkdir -p build + +clean: + rm -rf build + +test: compile + @for f in $(shell ls tests | grep -v "common"); \ + do echo "Running $${f}"; \ + ./tests/$${f}; \ + done + +tests/%.sh: compile + @echo "Running $@" + @$@ + +tests/%: compile + @echo "Running [email protected]" + |