Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: complete migration of isa-related logic to isa.mk #608

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 9 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ endif

-include $(NEMU_HOME)/include/config/auto.conf
-include $(NEMU_HOME)/include/config/auto.conf.cmd
include $(NEMU_HOME)/scripts/utils.mk

DIRS-y = src/cpu src/monitor src/utils
DIRS-$(CONFIG_MODE_SYSTEM) += src/memory
ENGINE ?= $(call remove_quote,$(CONFIG_ENGINE))
INC_DIR += $(NEMU_HOME)/src/engine/$(ENGINE)
DIRS-y = src/engine/$(ENGINE)
NAME = nemu-$(ENGINE)

remove_quote = $(patsubst "%",%,$(1))
include $(NEMU_HOME)/scripts/isa.mk

DIRS-y += src/cpu src/monitor src/utils
DIRS-$(CONFIG_MODE_SYSTEM) += src/memory

ISA ?= $(if $(CONFIG_ISA),$(call remove_quote,$(CONFIG_ISA)),x86)
CFLAGS += -D__ISA__=$(ISA)
# CFLAGS += -g
INC_DIR += $(NEMU_HOME)/src/isa/$(ISA)/include
DIRS-y += src/isa/$(ISA)

ENGINE ?= $(call remove_quote,$(CONFIG_ENGINE))
INC_DIR += $(NEMU_HOME)/src/engine/$(ENGINE)
DIRS-y += src/engine/$(ENGINE)

DIRS-$(CONFIG_MODE_USER) += src/user

SRCS-y += src/nemu-main.c
Expand Down Expand Up @@ -83,8 +83,6 @@ CFLAGS_BUILD += $(if $(CONFIG_CC_ASAN),-fsanitize=address,)
CFLAGS += $(CFLAGS_BUILD)
LDFLAGS += $(CFLAGS_BUILD)

NAME = nemu-$(ENGINE)

ifndef CONFIG_SHARE
ifdef CONFIG_CC_NATIVE_ARCH
CFLAGS += -march=native
Expand Down Expand Up @@ -142,7 +140,6 @@ endif

include $(NEMU_HOME)/scripts/git.mk
include $(NEMU_HOME)/scripts/config.mk
include $(NEMU_HOME)/scripts/isa.mk
include $(NEMU_HOME)/scripts/build.mk

ifdef CONFIG_DIFFTEST
Expand Down
9 changes: 6 additions & 3 deletions scripts/isa.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
# See the Mulan PSL v2 for more details.
#**************************************************************************************/

ISA ?= x86
ISAS = $(shell ls $(NEMU_HOME)/src/isa/)
ISA = $(if $(CONFIG_ISA),$(call remove_quote,$(CONFIG_ISA)),x86)
ISAS = $(shell ls $(NEMU_HOME)/src/isa/)

ifeq ($(filter $(ISAS), $(ISA)), ) # ISA must be valid
$(error Invalid ISA=$(ISA). Supported: $(ISAS))
endif
NAME := $(ISA)-$(NAME)
CFLAGS += -D__ISA__=$(ISA)
CFLAGS += -D__ISA_$(ISA)__=1

NAME := $(ISA)-$(NAME)
19 changes: 19 additions & 0 deletions scripts/utils.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#***************************************************************************************
# Copyright (c) 2014-2021 Zihao Yu, Nanjing University
#
# NEMU is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#
# See the Mulan PSL v2 for more details.
#**************************************************************************************/

print-%:
@echo $*=$($*)

remove_quote = $(patsubst "%",%,$(1))
9 changes: 7 additions & 2 deletions tools/kvm-diff/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ NAME = kvm
SRCS = $(shell find src/ -name "*.c")

SHARE = 1
INC_DIR += $(NEMU_HOME)/include $(NEMU_HOME)/src/isa/x86/include
ISA = x86

-include $(NEMU_HOME)/include/config/auto.conf
-include $(NEMU_HOME)/include/config/auto.conf.cmd

include $(NEMU_HOME)/scripts/utils.mk
include $(NEMU_HOME)/scripts/isa.mk

INC_DIR += $(NEMU_HOME)/include $(NEMU_HOME)/src/isa/$(ISA)/include

include $(NEMU_HOME)/scripts/build.mk
9 changes: 8 additions & 1 deletion tools/qemu-dl-diff/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
NAME = qemu

include $(NEMU_HOME)/scripts/utils.mk

-include $(NEMU_HOME)/include/config/auto.conf
-include $(NEMU_HOME)/include/config/auto.conf.cmd

include $(NEMU_HOME)/scripts/isa.mk

SRCS = $(shell find src/ -name "*.c" | grep -v "isa")
SRCS += $(shell find src/isa/$(ISA) -name "*.c")

SHARE = 1
CFLAGS += -DNEMU_HOME=$(NEMU_HOME)

include $(NEMU_HOME)/scripts/isa.mk
include $(NEMU_HOME)/scripts/build.mk
10 changes: 8 additions & 2 deletions tools/qemu-socket-diff/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@
#
# See the Mulan PSL v2 for more details.
#**************************************************************************************/

NAME = qemu

include $(NEMU_HOME)/scripts/utils.mk

-include $(NEMU_HOME)/include/config/auto.conf
-include $(NEMU_HOME)/include/config/auto.conf.cmd

include $(NEMU_HOME)/scripts/isa.mk

SRCS = $(shell find src/ -name "*.c" | grep -v "isa")
SRCS += $(shell find src/isa/$(ISA) -name "*.c")

SHARE = 1
CFLAGS += -DNEMU_HOME=$(NEMU_HOME) -D_ISA_H_=\"isa/$(ISA).h\"

include $(NEMU_HOME)/scripts/isa.mk
include $(NEMU_HOME)/scripts/build.mk