xref: /DragonOS/Makefile (revision fbe1e23e97bf380ed187da88cba1ed075c5e435f)
10aec6827SfslongjinSUBDIRS = kernel user
20aec6827Sfslongjin
3416a802bSfslongjin# ifndef $(EMULATOR)
4416a802bSfslongjinifeq ($(EMULATOR), )
5416a802bSfslongjinexport EMULATOR=__NO_EMULATION__
6416a802bSfslongjinendif
70aec6827Sfslongjin
80aec6827Sfslongjin
9edb21695Sfslongjinexport ARCH=__x86_64__
100aec6827Sfslongjinexport ROOT_PATH=$(shell pwd)
110aec6827Sfslongjin
120aec6827Sfslongjinexport DEBUG=DEBUG
13416a802bSfslongjinexport GLOBAL_CFLAGS := -mcmodel=large -fno-builtin -m64  -fno-stack-protector -D $(ARCH) -D $(EMULATOR) -O1
140aec6827Sfslongjin
150aec6827Sfslongjinifeq ($(DEBUG), DEBUG)
160aec6827SfslongjinGLOBAL_CFLAGS += -g
170aec6827Sfslongjinendif
18f479f321Sfslongjin
19*fbe1e23eSlongjinexport CC=gcc
20416a802bSfslongjin
21f479f321Sfslongjin.PHONY: all
221ab51cb3Sfslongjinall: kernel user
231ab51cb3Sfslongjin
241ab51cb3Sfslongjin
251ab51cb3Sfslongjin.PHONY: kernel
261ab51cb3Sfslongjinkernel:
270b0cce93Sfslongjin	mkdir -p bin/kernel/
281ab51cb3Sfslongjin	@list='./kernel'; for subdir in $$list; do \
29f479f321Sfslongjin				echo "make all in $$subdir";\
30f479f321Sfslongjin				cd $$subdir;\
3105dc7ac7Sfslongjin				$(MAKE) all;\
3208df2581Sfslongjin				if [ "$$?" != "0" ]; then\
3308df2581Sfslongjin					echo "内核编译失败";\
3408df2581Sfslongjin					exit 1;\
3508df2581Sfslongjin				fi;\
36f479f321Sfslongjin				cd ..;\
37f479f321Sfslongjin		done
38f479f321Sfslongjin
39e2a59dbdSfslongjin.PHONY: user
40e2a59dbdSfslongjinuser:
41e2a59dbdSfslongjin	mkdir -p bin/user/
42d60f1a8fSfslongjin	mkdir -p bin/tmp/user
43e2a59dbdSfslongjin	@list='./user'; for subdir in $$list; do \
44e2a59dbdSfslongjin    		echo "make all in $$subdir";\
45e2a59dbdSfslongjin    		cd $$subdir;\
46e2a59dbdSfslongjin    		$(MAKE) all;\
4708df2581Sfslongjin			if [ "$$?" != "0" ]; then\
4808df2581Sfslongjin				echo "用户态程序编译失败";\
4908df2581Sfslongjin				exit 1;\
5008df2581Sfslongjin			fi;\
51e2a59dbdSfslongjin    		cd ..;\
52e2a59dbdSfslongjin	done
53e2a59dbdSfslongjin
54f479f321Sfslongjin.PHONY: clean
55f479f321Sfslongjinclean:
56f479f321Sfslongjin	@list='$(SUBDIRS)'; for subdir in $$list; do \
57f479f321Sfslongjin		echo "Clean in dir: $$subdir";\
5805dc7ac7Sfslongjin		cd $$subdir && $(MAKE) clean;\
59f479f321Sfslongjin		cd .. ;\
60f479f321Sfslongjin	done
61e667fff2Sfslongjin
62e667fff2Sfslongjingdb:
63e667fff2Sfslongjin	gdb -n -x tools/.gdbinit