Просмотр исходного кода

evx: new compile framework for kernel

rain 5 лет назад
Сommit
96de490df7
5 измененных файлов с 94 добавлено и 0 удалено
  1. 64 0
      Makefile
  2. 15 0
      arch/x86/Makefile
  3. 0 0
      arch/x86/b.c
  4. 15 0
      kernel/Makefile
  5. 0 0
      kernel/a.c

+ 64 - 0
Makefile

@@ -0,0 +1,64 @@
+KERNEL_MAJOR = 		0
+KERNEL_PATCH_LEVEL = 	0
+KERNEL_SUBVER = 	1
+
+# initial the arch variables
+
+HOSTARCH =		$(shell uname -m)
+HOSTCC = 		$(CC)
+
+
+ifeq ($(ARCH), )
+	ARCH = 		$(HOSTARCH)
+
+endif
+
+PWD =			$(shell pwd)
+ARCHDIR =	 	$(PWD)/arch/$(ARCH)
+
+KERNEL_COMPILE_BY = 	$(shell whoami)
+KERNEL_COMPILE_TIME = 	$(shell date)
+
+KERNEL_VERSION = 	$(KERNEL_MAJOR).$(KERNEL_PATCH_LEVEL).$(KERNEL_SUBVER)\
+			$(KERNEL_COMPILE_TIME) $(KERNEL_COMPILE_BY) on $(ARCH)
+
+MAKEFLAGS += 		--no-print-directory 
+
+ifeq ($(CROSS_COMPILE), )
+	CROSS_COMPILE = $(CC)
+endif
+
+
+ifeq ($(ARCH), x86_64) 
+	ARCH = x86
+endif
+
+
+ifeq ($D,)
+
+
+# that inside object, and we don't support other objects at this time :-)
+obj-i += $(PWD)/kernel/ 
+obj-i += $(ARCHDIR)/ 
+
+
+_all:
+	@for d in $(obj-i); do 				\
+		$(MAKE) $(MAKEFLAGS) -C $$d D=$$d;	\
+	done
+
+
+.PHONY clean:
+	@find ./ -name "*.o" | xargs rm -f 
+
+else
+
+%.o: 	$D/%.c
+	@cd $D && $(CROSS_COMPILE) $(CFLAGS) -c $D/$*.c 
+	@echo "CC 		$*.o"
+
+
+__all: 	$(obj-i)
+
+endif
+

+ 15 - 0
arch/x86/Makefile

@@ -0,0 +1,15 @@
+# this was called from the Makefile in /, 
+# and we just tell it what objects that he should make. 
+
+obj-i := b.o 
+
+target:
+
+ifeq ($(D),)
+	@echo "this should call from the Makefile in directory /, but not typing make in kernel/. :-(" >&2 
+	@exit 1
+endif
+
+# $(PWD) is the / directory of kernel, e.g. /root/evx/
+	@$(MAKE) -C $(PWD) D=$(shell pwd) obj-i=$(obj-i)
+

+ 0 - 0
arch/x86/b.c


+ 15 - 0
kernel/Makefile

@@ -0,0 +1,15 @@
+# this was called from the Makefile in /, 
+# and we just tell it what objects that he should make. 
+
+obj-i := a.o
+
+target:
+
+ifeq ($(D),)
+	@echo "this should call from the Makefile in directory /, but not typing make in kernel/. :-(" >&2 
+	@exit 1
+endif
+
+# $(PWD) is the / directory of kernel, e.g. /root/evx/
+	@$(MAKE) -C $(PWD) D=$(shell pwd) obj-i=$(obj-i)
+

+ 0 - 0
kernel/a.c