10aec6827SfslongjinSUBDIRS = kernel user 20aec6827Sfslongjin 3416a802bSfslongjin# ifndef $(EMULATOR) 4416a802bSfslongjinifeq ($(EMULATOR), ) 5416a802bSfslongjinexport EMULATOR=__NO_EMULATION__ 6416a802bSfslongjinendif 70aec6827Sfslongjin 8d328bfceSlogin# 计算cpu核心数 9d328bfceSloginNPROCS:=1 10d328bfceSloginOS:=$(shell uname -s) 11d328bfceSlogin 12d328bfceSloginifeq ($(OS),Linux) 13d328bfceSlogin NPROCS:=$(shell grep -c ^processor /proc/cpuinfo) 14d328bfceSloginendif 15d328bfceSloginifeq ($(OS),Darwin) # Assume Mac OS X 16d328bfceSlogin NPROCS:=$(shell system_profiler | awk '/Number Of CPUs/{print $4}{next;}') 17d328bfceSloginendif 180aec6827Sfslongjin 19edb21695Sfslongjinexport ARCH=__x86_64__ 200aec6827Sfslongjinexport ROOT_PATH=$(shell pwd) 210aec6827Sfslongjin 22*e0021523Sloginexport RUSTC=$(shell which rustc) 23*e0021523Slogin 240aec6827Sfslongjinexport DEBUG=DEBUG 25416a802bSfslongjinexport GLOBAL_CFLAGS := -mcmodel=large -fno-builtin -m64 -fno-stack-protector -D $(ARCH) -D $(EMULATOR) -O1 260aec6827Sfslongjin 270aec6827Sfslongjinifeq ($(DEBUG), DEBUG) 280aec6827SfslongjinGLOBAL_CFLAGS += -g 290aec6827Sfslongjinendif 30f479f321Sfslongjin 31fbe1e23eSlongjinexport CC=gcc 32416a802bSfslongjin 33f479f321Sfslongjin.PHONY: all 341ab51cb3Sfslongjinall: kernel user 351ab51cb3Sfslongjin 361ab51cb3Sfslongjin 371ab51cb3Sfslongjin.PHONY: kernel 381ab51cb3Sfslongjinkernel: 390b0cce93Sfslongjin mkdir -p bin/kernel/ 401ab51cb3Sfslongjin @list='./kernel'; for subdir in $$list; do \ 41f479f321Sfslongjin echo "make all in $$subdir";\ 42f479f321Sfslongjin cd $$subdir;\ 4305dc7ac7Sfslongjin $(MAKE) all;\ 4408df2581Sfslongjin if [ "$$?" != "0" ]; then\ 4508df2581Sfslongjin echo "内核编译失败";\ 4608df2581Sfslongjin exit 1;\ 4708df2581Sfslongjin fi;\ 48f479f321Sfslongjin cd ..;\ 49f479f321Sfslongjin done 50f479f321Sfslongjin 51e2a59dbdSfslongjin.PHONY: user 52e2a59dbdSfslongjinuser: 53e2a59dbdSfslongjin mkdir -p bin/user/ 54d60f1a8fSfslongjin mkdir -p bin/tmp/user 55e2a59dbdSfslongjin @list='./user'; for subdir in $$list; do \ 56e2a59dbdSfslongjin echo "make all in $$subdir";\ 57e2a59dbdSfslongjin cd $$subdir;\ 58e2a59dbdSfslongjin $(MAKE) all;\ 5908df2581Sfslongjin if [ "$$?" != "0" ]; then\ 6008df2581Sfslongjin echo "用户态程序编译失败";\ 6108df2581Sfslongjin exit 1;\ 6208df2581Sfslongjin fi;\ 63e2a59dbdSfslongjin cd ..;\ 64e2a59dbdSfslongjin done 65e2a59dbdSfslongjin 66f479f321Sfslongjin.PHONY: clean 67f479f321Sfslongjinclean: 68f479f321Sfslongjin @list='$(SUBDIRS)'; for subdir in $$list; do \ 69f479f321Sfslongjin echo "Clean in dir: $$subdir";\ 7005dc7ac7Sfslongjin cd $$subdir && $(MAKE) clean;\ 71f479f321Sfslongjin cd .. ;\ 72f479f321Sfslongjin done 73e667fff2Sfslongjin 74d328bfceSlogincppcheck-xml: 75d328bfceSlogin cppcheck kernel user --platform=unix64 --std=c11 -I user/libs/ -I=kernel/ --force -j $(NPROCS) --xml 2> cppcheck.xml 76d328bfceSlogin 77d328bfceSlogincppcheck: 78d328bfceSlogin cppcheck kernel user --platform=unix64 --std=c11 -I user/libs/ -I=kernel/ --force -j $(NPROCS) 79d328bfceSlogin 80e667fff2Sfslongjingdb: 81e667fff2Sfslongjin gdb -n -x tools/.gdbinit 82