1SUBDIRS = kernel user 2 3# ifndef $(EMULATOR) 4ifeq ($(EMULATOR), ) 5export EMULATOR=__NO_EMULATION__ 6endif 7 8 9export ARCH=__x86_64__ 10export ROOT_PATH=$(shell pwd) 11 12export DEBUG=DEBUG 13export GLOBAL_CFLAGS := -mcmodel=large -fno-builtin -m64 -fno-stack-protector -D $(ARCH) -D $(EMULATOR) -O1 14 15ifeq ($(DEBUG), DEBUG) 16GLOBAL_CFLAGS += -g 17endif 18 19 20.PHONY: all 21all: kernel user 22 23 24 25.PHONY: kernel 26kernel: 27 mkdir -p bin/kernel/ 28 @list='./kernel'; for subdir in $$list; do \ 29 echo "make all in $$subdir";\ 30 cd $$subdir;\ 31 $(MAKE) all;\ 32 if [ "$$?" != "0" ]; then\ 33 echo "内核编译失败";\ 34 exit 1;\ 35 fi;\ 36 cd ..;\ 37 done 38 39.PHONY: user 40user: 41 mkdir -p bin/user/ 42 mkdir -p bin/tmp/ 43 @list='./user'; for subdir in $$list; do \ 44 echo "make all in $$subdir";\ 45 cd $$subdir;\ 46 $(MAKE) all;\ 47 if [ "$$?" != "0" ]; then\ 48 echo "用户态程序编译失败";\ 49 exit 1;\ 50 fi;\ 51 cd ..;\ 52 done 53 54.PHONY: clean 55clean: 56 @list='$(SUBDIRS)'; for subdir in $$list; do \ 57 echo "Clean in dir: $$subdir";\ 58 cd $$subdir && $(MAKE) clean;\ 59 cd .. ;\ 60 done 61 62gdb: 63 gdb -n -x tools/.gdbinit