Selaa lähdekoodia

evx: very, very, very ugly but useful :-)

rain 5 vuotta sitten
vanhempi
sitoutus
190df7a40f
5 muutettua tiedostoa jossa 45 lisäystä ja 32 poistoa
  1. 27 26
      Makefile
  2. 3 3
      arch/x86/Makefile
  3. 5 3
      kernel/Makefile
  4. 0 0
      kernel/foo/b.c
  5. 10 0
      scripts/do_build.sh

+ 27 - 26
Makefile

@@ -1,45 +1,48 @@
-KERNEL_MAJOR = 		0
-KERNEL_PATCH_LEVEL = 	0
-KERNEL_SUBVER = 	1
+KERNEL_MAJOR 		= 0
+KERNEL_PATCH_LEVEL 	= 0
+KERNEL_SUBVER 		= 1
 
 # initial the arch variables
 
-HOSTARCH =		$(shell uname -m)
-HOSTCC = 		$(CC)
+HOSTARCH 		= $(shell uname -m)
+HOSTCC 			= $(CC)
 
 
-ifeq ($(ARCH), )
-	ARCH = 		$(HOSTARCH)
+ifeq 	($(ARCH), )
+	ARCH 		= $(HOSTARCH)
 
 endif
 
-PWD =			$(shell pwd)
-ARCHDIR =	 	$(PWD)/arch/$(ARCH)
+PWD 			= $(shell pwd)
+ARCHDIR 		= $(PWD)/arch/$(ARCH)
 
-KERNEL_COMPILE_BY = 	$(shell whoami)
-KERNEL_COMPILE_TIME = 	$(shell date)
+KERNEL_COMPILE_BY 	= $(shell whoami)
+KERNEL_COMPILE_TIME 	= $(shell date)
 
-KERNEL_VERSION = 	$(KERNEL_MAJOR).$(KERNEL_PATCH_LEVEL).$(KERNEL_SUBVER)\
+KERNEL_VERSION 		= $(KERNEL_MAJOR).$(KERNEL_PATCH_LEVEL).$(KERNEL_SUBVER)\
 			$(KERNEL_COMPILE_TIME) $(KERNEL_COMPILE_BY) on $(ARCH)
 
-MAKEFLAGS += 		--no-print-directory 
+MAKEFLAGS		+= --no-print-directory 
 
-ifeq ($(CROSS_COMPILE), )
-	CROSS_COMPILE = $(CC)
+SHELl 			= $(shell echo $$SHELL)
+EXPORT 			= export
+
+ifeq 	($(CROSS_COMPILE), )
+	CROSS_COMPILE	= $(CC)
 endif
 
 
-ifeq ($(ARCH), x86_64) 
-	ARCH = x86
+ifeq 	($(ARCH), x86_64) 
+	ARCH		= x86
 endif
 
 
-ifeq ($D,)
+ifeq 	($D,)
 
 
 # that inside object, and we don't support other objects at this time :-)
-obj-i += $(PWD)/kernel/ 
-obj-i += $(ARCHDIR)/ 
+obj-i 			+= $(PWD)/kernel/ 
+obj-i 			+= $(ARCHDIR)/ 
 
 
 _all:
@@ -53,12 +56,10 @@ _all:
 
 else
 
-%.o: 	$D/%.c
-	@cd $D && $(CROSS_COMPILE) $(CFLAGS) -c $D/$*.c 
-	@echo "CC 		$*.o"
-
-
-__all: 	$(obj-i)
+__all: 	
+	@for d in $(obj-i); do 								\
+		$(SHELL) scripts/do_build.sh $$d $(CROSS_COMPILE) $D $(CFLAGS);		\
+	done
 
 endif
 

+ 3 - 3
arch/x86/Makefile

@@ -1,15 +1,15 @@
 # this was called from the Makefile in /, 
 # and we just tell it what objects that he should make. 
 
-obj-i := b.o 
+obj-i += b.c 
 
 target:
 
-ifeq ($(D),)
+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)
+	@$(MAKE) -C $(PWD) D=$(shell pwd) obj-i="$(obj-i)"
 

+ 5 - 3
kernel/Makefile

@@ -1,15 +1,17 @@
 # this was called from the Makefile in /, 
 # and we just tell it what objects that he should make. 
 
-obj-i := a.o
+obj-i = 
+obj-i += a.c 
+obj-i += foo/b.c 
 
 target:
 
-ifeq ($(D),)
+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)
+	@$(MAKE) -C $(PWD) D=$(shell pwd) obj-i="$(obj-i)"
 

+ 0 - 0
kernel/foo/b.c


+ 10 - 0
scripts/do_build.sh

@@ -0,0 +1,10 @@
+#!/usr/bin/bash
+
+echo "CC                $1"
+
+# well, that's very, very, very ugly, but at least it works :-(
+# $2: CC, $3: directory to enter, and $4 is the CC flags
+
+cd $3
+$2 $4 -c $1 -o $1.o
+