2024-02-07 10:08:10 +01:00
|
|
|
CC=clang
|
2024-06-30 20:27:04 +02:00
|
|
|
DISABLE_ERRORS=-Wno-error=implicit-function-declaration -Wno-shift-negative-value
|
|
|
|
|
COMMON_FLAGS=$(DISABLE_ERRORS) -g2 -fstack-protector-all -arch x86_64 --std=c11
|
2023-09-27 03:45:58 +02:00
|
|
|
PROD_FLAGS=$(COMMON_FLAGS) -DLAMA_ENV
|
|
|
|
|
TEST_FLAGS=$(COMMON_FLAGS) -DDEBUG_VERSION
|
|
|
|
|
UNIT_TESTS_FLAGS=$(TEST_FLAGS)
|
|
|
|
|
INVARIANTS_CHECK_FLAGS=$(TEST_FLAGS) -DFULL_INVARIANT_CHECKS
|
2021-02-14 18:54:44 +03:00
|
|
|
|
2024-02-05 14:18:06 +01:00
|
|
|
# this target is the most important one, its' artefacts should be used as a runtime of x86-64 version of Lama
|
|
|
|
|
all: gc64.o runtime64.o printf.o
|
|
|
|
|
ar rc runtime.a runtime64.o gc64.o printf.o
|
2024-02-04 11:58:57 +01:00
|
|
|
|
2024-02-05 14:18:06 +01:00
|
|
|
# this target is the most important one, its' artefacts should be used as a runtime of x86 (32-bits) version Lama
|
2024-02-04 11:58:57 +01:00
|
|
|
all32: gc.o runtime.o
|
2023-09-29 19:40:01 +02:00
|
|
|
ar rc runtime.a runtime.o gc.o
|
2023-03-27 10:09:54 +02:00
|
|
|
|
2023-10-04 05:23:14 +02:00
|
|
|
NEGATIVE_TESTS=$(sort $(basename $(notdir $(wildcard negative_scenarios/*_neg.c))))
|
|
|
|
|
|
|
|
|
|
$(NEGATIVE_TESTS): %: negative_scenarios/%.c
|
|
|
|
|
@echo "Running test $@"
|
|
|
|
|
@$(CC) -o $@.o $(COMMON_FLAGS) negative_scenarios/$@.c gc.c
|
|
|
|
|
@./$@.o 2> negative_scenarios/$@.err || diff negative_scenarios/$@.err negative_scenarios/expected/$@.err
|
|
|
|
|
|
|
|
|
|
negative_tests: $(NEGATIVE_TESTS)
|
|
|
|
|
|
2023-09-27 03:45:58 +02:00
|
|
|
# this is a target that runs unit tests, scenarios are written in a single file `test_main.c`
|
2023-09-29 19:40:01 +02:00
|
|
|
unit_tests.o: gc.c gc.h runtime.c runtime.h runtime_common.h virt_stack.c virt_stack.h test_main.c test_util.s
|
|
|
|
|
$(CC) -o unit_tests.o $(UNIT_TESTS_FLAGS) gc.c virt_stack.c runtime.c test_main.c test_util.s
|
2023-09-27 03:45:58 +02:00
|
|
|
|
|
|
|
|
# this target also runs unit tests but with additional expensive checks of GC invariants which aren't used in production version
|
2023-09-29 19:40:01 +02:00
|
|
|
invariants_check.o: gc.c gc.h runtime.c runtime.h runtime_common.h virt_stack.c virt_stack.h test_main.c test_util.s
|
|
|
|
|
$(CC) -o invariants_check.o $(INVARIANTS_CHECK_FLAGS) gc.c virt_stack.c runtime.c test_main.c test_util.s
|
2023-09-27 03:45:58 +02:00
|
|
|
|
|
|
|
|
# this target also runs unit tests but with additional expensive checks of GC invariants which aren't used in production version
|
|
|
|
|
# additionally, it prints debug information
|
2023-09-29 19:40:01 +02:00
|
|
|
invariants_check_debug_print.o: gc.c gc.h runtime.c runtime.h runtime_common.h virt_stack.c virt_stack.h test_main.c test_util.s
|
|
|
|
|
$(CC) -o invariants_check_debug_print.o $(INVARIANTS_CHECK_FLAGS) -DDEBUG_PRINT gc.c virt_stack.c runtime.c test_main.c test_util.s
|
2023-04-26 14:22:14 +02:00
|
|
|
|
|
|
|
|
virt_stack.o: virt_stack.h virt_stack.c
|
2023-09-27 03:45:58 +02:00
|
|
|
$(CC) $(PROD_FLAGS) -c virt_stack.c
|
2023-04-26 14:22:14 +02:00
|
|
|
|
2023-03-27 10:09:54 +02:00
|
|
|
gc.o: gc.c gc.h
|
2024-06-30 20:27:04 +02:00
|
|
|
$(CC) -m32 $(PROD_FLAGS) -c gc.c
|
2024-02-01 20:40:44 +01:00
|
|
|
|
|
|
|
|
gc64.o: gc.c gc.h
|
2024-06-30 20:27:04 +02:00
|
|
|
$(CC) $(PROD_FLAGS) -c gc.c -o gc64.o
|
2018-11-21 14:23:35 +03:00
|
|
|
|
2021-09-28 03:02:05 +03:00
|
|
|
runtime.o: runtime.c runtime.h
|
2024-02-01 20:40:44 +01:00
|
|
|
$(CC) -m32 $(PROD_FLAGS) -c runtime.c
|
|
|
|
|
|
|
|
|
|
runtime64.o: runtime.c runtime.h
|
|
|
|
|
$(CC) $(PROD_FLAGS) -c runtime.c -o runtime64.o
|
2018-03-04 23:13:08 +03:00
|
|
|
|
2024-02-05 14:18:06 +01:00
|
|
|
printf.o: printf.s
|
2024-02-05 16:48:27 +01:00
|
|
|
$(CC) $(PROD_FLAGS) -c -g printf.s -o printf.o
|
2024-02-05 14:18:06 +01:00
|
|
|
|
2018-03-04 23:13:08 +03:00
|
|
|
clean:
|
2023-10-04 05:23:14 +02:00
|
|
|
$(RM) *.a *.o *~ negative_scenarios/*.err
|