NJU-ProjectN/nemu ics2023 initialized
NJU-ProjectN/nemu eb63cf3568dbf4e0c3c6ef462e6ec685550fabbc Merge pull request #76 from rijuyuezhu/master
This commit is contained in:
parent
1efe03efb9
commit
2824efad33
141 changed files with 19573 additions and 0 deletions
57
nemu/scripts/build.mk
Normal file
57
nemu/scripts/build.mk
Normal file
|
@ -0,0 +1,57 @@
|
|||
.DEFAULT_GOAL = app
|
||||
|
||||
# Add necessary options if the target is a shared library
|
||||
ifeq ($(SHARE),1)
|
||||
SO = -so
|
||||
CFLAGS += -fPIC -fvisibility=hidden
|
||||
LDFLAGS += -shared -fPIC
|
||||
endif
|
||||
|
||||
WORK_DIR = $(shell pwd)
|
||||
BUILD_DIR = $(WORK_DIR)/build
|
||||
|
||||
INC_PATH := $(WORK_DIR)/include $(INC_PATH)
|
||||
OBJ_DIR = $(BUILD_DIR)/obj-$(NAME)$(SO)
|
||||
BINARY = $(BUILD_DIR)/$(NAME)$(SO)
|
||||
|
||||
# Compilation flags
|
||||
ifeq ($(CC),clang)
|
||||
CXX := clang++
|
||||
else
|
||||
CXX := g++
|
||||
endif
|
||||
LD := $(CXX)
|
||||
INCLUDES = $(addprefix -I, $(INC_PATH))
|
||||
CFLAGS := -O2 -MMD -Wall -Werror $(INCLUDES) $(CFLAGS)
|
||||
LDFLAGS := -O2 $(LDFLAGS)
|
||||
|
||||
OBJS = $(SRCS:%.c=$(OBJ_DIR)/%.o) $(CXXSRC:%.cc=$(OBJ_DIR)/%.o)
|
||||
|
||||
# Compilation patterns
|
||||
$(OBJ_DIR)/%.o: %.c
|
||||
@echo + CC $<
|
||||
@mkdir -p $(dir $@)
|
||||
@$(CC) $(CFLAGS) -c -o $@ $<
|
||||
$(call call_fixdep, $(@:.o=.d), $@)
|
||||
|
||||
$(OBJ_DIR)/%.o: %.cc
|
||||
@echo + CXX $<
|
||||
@mkdir -p $(dir $@)
|
||||
@$(CXX) $(CFLAGS) $(CXXFLAGS) -c -o $@ $<
|
||||
$(call call_fixdep, $(@:.o=.d), $@)
|
||||
|
||||
# Depencies
|
||||
-include $(OBJS:.o=.d)
|
||||
|
||||
# Some convenient rules
|
||||
|
||||
.PHONY: app clean
|
||||
|
||||
app: $(BINARY)
|
||||
|
||||
$(BINARY):: $(OBJS) $(ARCHIVES)
|
||||
@echo + LD $@
|
||||
@$(LD) -o $@ $(OBJS) $(LDFLAGS) $(ARCHIVES) $(LIBS)
|
||||
|
||||
clean:
|
||||
-rm -rf $(BUILD_DIR)
|
70
nemu/scripts/config.mk
Normal file
70
nemu/scripts/config.mk
Normal file
|
@ -0,0 +1,70 @@
|
|||
#***************************************************************************************
|
||||
# Copyright (c) 2014-2022 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.
|
||||
#**************************************************************************************/
|
||||
|
||||
COLOR_RED := $(shell echo "\033[1;31m")
|
||||
COLOR_END := $(shell echo "\033[0m")
|
||||
|
||||
ifeq ($(wildcard .config),)
|
||||
$(warning $(COLOR_RED)Warning: .config does not exists!$(COLOR_END))
|
||||
$(warning $(COLOR_RED)To build the project, first run 'make menuconfig'.$(COLOR_END))
|
||||
endif
|
||||
|
||||
Q := @
|
||||
KCONFIG_PATH := $(NEMU_HOME)/tools/kconfig
|
||||
FIXDEP_PATH := $(NEMU_HOME)/tools/fixdep
|
||||
Kconfig := $(NEMU_HOME)/Kconfig
|
||||
rm-distclean += include/generated include/config .config .config.old
|
||||
silent := -s
|
||||
|
||||
CONF := $(KCONFIG_PATH)/build/conf
|
||||
MCONF := $(KCONFIG_PATH)/build/mconf
|
||||
FIXDEP := $(FIXDEP_PATH)/build/fixdep
|
||||
|
||||
$(CONF):
|
||||
$(Q)$(MAKE) $(silent) -C $(KCONFIG_PATH) NAME=conf
|
||||
|
||||
$(MCONF):
|
||||
$(Q)$(MAKE) $(silent) -C $(KCONFIG_PATH) NAME=mconf
|
||||
|
||||
$(FIXDEP):
|
||||
$(Q)$(MAKE) $(silent) -C $(FIXDEP_PATH)
|
||||
|
||||
menuconfig: $(MCONF) $(CONF) $(FIXDEP)
|
||||
$(Q)$(MCONF) $(Kconfig)
|
||||
$(Q)$(CONF) $(silent) --syncconfig $(Kconfig)
|
||||
|
||||
savedefconfig: $(CONF)
|
||||
$(Q)$< $(silent) --$@=configs/defconfig $(Kconfig)
|
||||
|
||||
%defconfig: $(CONF) $(FIXDEP)
|
||||
$(Q)$< $(silent) --defconfig=configs/$@ $(Kconfig)
|
||||
$(Q)$< $(silent) --syncconfig $(Kconfig)
|
||||
|
||||
.PHONY: menuconfig savedefconfig defconfig
|
||||
|
||||
# Help text used by make help
|
||||
help:
|
||||
@echo ' menuconfig - Update current config utilising a menu based program'
|
||||
@echo ' savedefconfig - Save current config as configs/defconfig (minimal config)'
|
||||
|
||||
distclean: clean
|
||||
-@rm -rf $(rm-distclean)
|
||||
|
||||
.PHONY: help distclean
|
||||
|
||||
define call_fixdep
|
||||
@$(FIXDEP) $(1) $(2) unused > $(1).tmp
|
||||
@mv $(1).tmp $(1)
|
||||
endef
|
50
nemu/scripts/native.mk
Normal file
50
nemu/scripts/native.mk
Normal file
|
@ -0,0 +1,50 @@
|
|||
#***************************************************************************************
|
||||
# Copyright (c) 2014-2022 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.
|
||||
#**************************************************************************************/
|
||||
|
||||
-include $(NEMU_HOME)/../Makefile
|
||||
include $(NEMU_HOME)/scripts/build.mk
|
||||
|
||||
include $(NEMU_HOME)/tools/difftest.mk
|
||||
|
||||
compile_git:
|
||||
$(call git_commit, "compile NEMU")
|
||||
$(BINARY):: compile_git
|
||||
|
||||
# Some convenient rules
|
||||
|
||||
override ARGS ?= --log=$(BUILD_DIR)/nemu-log.txt
|
||||
override ARGS += $(ARGS_DIFF)
|
||||
|
||||
# Command to execute NEMU
|
||||
IMG ?=
|
||||
NEMU_EXEC := $(BINARY) $(ARGS) $(IMG)
|
||||
|
||||
run-env: $(BINARY) $(DIFF_REF_SO)
|
||||
|
||||
run: run-env
|
||||
$(call git_commit, "run NEMU")
|
||||
$(NEMU_EXEC)
|
||||
|
||||
gdb: run-env
|
||||
$(call git_commit, "gdb NEMU")
|
||||
gdb -s $(BINARY) --args $(NEMU_EXEC)
|
||||
|
||||
clean-tools = $(dir $(shell find ./tools -maxdepth 2 -mindepth 2 -name "Makefile"))
|
||||
$(clean-tools):
|
||||
-@$(MAKE) -s -C $@ clean
|
||||
clean-tools: $(clean-tools)
|
||||
clean-all: clean distclean clean-tools
|
||||
|
||||
.PHONY: run gdb run-env clean-tools clean-all $(clean-tools)
|
Loading…
Add table
Add a link
Reference in a new issue