> compile NEMU

221220000 张三
Linux zzy 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
 10:12:17 up 14:11,  2 users,  load average: 0.12, 0.13, 0.10
This commit is contained in:
tracer-ics2023
2024-08-18 10:12:18 +08:00
committed by zzy
parent 387a3fb34e
commit bae14ea6eb
3 changed files with 7 additions and 15 deletions

View File

@ -25,24 +25,12 @@ INCLUDES = $(addprefix -I, $(INC_PATH))
CFLAGS := -O2 -MMD -Wall -Werror $(INCLUDES) $(CFLAGS)
LDFLAGS := -O2 $(LDFLAGS)
# Define a variable to hold the test macro flag
TEST_CFLAGS ?=
# Check if the user passed the "test any" command
ifeq ("$(findstring test,$(MAKECMDGOALS))","test")
TEST_CFLAGS += -D$(MAKECMDGOALS:~1)
endif
# Add the test macro flag to the compilation flags
CFLAGS += $(TEST_CFLAGS)
OBJS = $(SRCS:%.c=$(OBJ_DIR)/%.o) $(CXXSRC:%.cc=$(OBJ_DIR)/%.o)
# Compilation patterns
$(OBJ_DIR)/%.o: %.c
@echo + CC $<
@mkdir -p $(dir $@)
@echo + TEST_CFLAGS $(CFLAGS)
@$(CC) $(CFLAGS) -c -o $@ $<
$(call call_fixdep, $(@:.o=.d), $@)

View File

@ -47,4 +47,10 @@ $(clean-tools):
clean-tools: $(clean-tools)
clean-all: clean distclean clean-tools
.PHONY: run gdb run-env clean-tools clean-all $(clean-tools)
test: NEMUARGS += -Dargs
test: run
.PHONY: run gdb run-env clean-tools clean-all $(clean-tools) test