xref: /DragonOS/Makefile (revision 0435eb00b1651a9d82f129a580569905501d2fcb)
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.PHONY: kernel
25kernel:
26	mkdir -p bin/kernel/
27	@list='./kernel'; for subdir in $$list; do \
28				echo "make all in $$subdir";\
29				cd $$subdir;\
30				$(MAKE) all;\
31				if [ "$$?" != "0" ]; then\
32					echo "内核编译失败";\
33					exit 1;\
34				fi;\
35				cd ..;\
36		done
37
38.PHONY: user
39user:
40	mkdir -p bin/user/
41	mkdir -p bin/tmp/user
42	@list='./user'; for subdir in $$list; do \
43    		echo "make all in $$subdir";\
44    		cd $$subdir;\
45    		$(MAKE) all;\
46			if [ "$$?" != "0" ]; then\
47				echo "用户态程序编译失败";\
48				exit 1;\
49			fi;\
50    		cd ..;\
51	done
52
53.PHONY: clean
54clean:
55	@list='$(SUBDIRS)'; for subdir in $$list; do \
56		echo "Clean in dir: $$subdir";\
57		cd $$subdir && $(MAKE) clean;\
58		cd .. ;\
59	done
60
61gdb:
62	gdb -n -x tools/.gdbinit