]> Zhao Yanbai Git Server - kernel.git/commitdiff
modify makefile
authorAceVest <zhaoyanbai@126.com>
Wed, 16 Apr 2014 14:55:13 +0000 (22:55 +0800)
committerAceVest <zhaoyanbai@126.com>
Wed, 16 Apr 2014 14:55:13 +0000 (22:55 +0800)
Makefile
bin/Makefile
boot/Makefile [deleted file]
drivers/Makefile [deleted file]
fs/Makefile [deleted file]
kernel.mk [deleted file]
kernel/Makefile [deleted file]
lib/Makefile [deleted file]
mm/Makefile [deleted file]
pci/Makefile [deleted file]
setup/Makefile [deleted file]

index 266ccb72b2309b13c6f5e1bb1ba1f01109b8efb5..37ce15e1c4ba8b73ce34537beecc984525ff227d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,52 +1,40 @@
 ############################################################################
-CF             = -c -I include -fno-builtin
-CC             = $(_CC) $(CF) -o
+CC                     = gcc
+CFLAGS         = -c -fno-builtin
 SYSTEMMAP      = System.map
 KERNELBIN      = KERNEL.BIN
 LINKSCRIPT     = scripts/link.ld
-OBJS = boot/multiboot.S.o boot/boot.o boot/reboot.S.o  boot/cmdline.o\
-       setup/*.o mm/*.o kernel/*.o fs/*.o pci/*.o lib/*.o \
-       drivers/*.o
-#BINS#######################################################################
-$(KERNELBIN):
-       cd boot && make
-       cd setup && make
-       cd mm && make
-       cd kernel && make
-       cd fs && make
-       cd pci && make
-       cd lib && make
-       cd drivers && make
-       ld -M -T$(LINKSCRIPT) -o $@ $(OBJS) > $(SYSTEMMAP)
-       ld -T$(LINKSCRIPT) -o $@ $(OBJS)
-       cd bin && make
-       md5sum $(KERNELBIN)
-       #./scripts/grub2-debug.sh
-       #mv $@ KRNL.ELF
-.PHONY:real
-real:
-
-.PHONY:c
+############################################################################
+
+SRC_DIRS = boot setup mm lib fs kernel drivers pci
+INC_DIRS = include drivers
+
+CSOURCE_FILES := $(foreach dir, $(SRC_DIRS), $(wildcard $(dir)/*.c))
+SSOURCE_FILES := $(foreach dir, $(SRC_DIRS), $(wildcard $(dir)/*.S))
+
+OBJS := $(patsubst %.c,%.c.o,$(CSOURCE_FILES))
+OBJS += $(patsubst %.S,%.S.o,$(SSOURCE_FILES))
+
+CFLAGS += ${INC_DIRS:%=-I%}
+
+${KERNELBIN}: ${OBJS} $
+       ld -M -T$(LINKSCRIPT) $(OBJS) -o $@ > $(SYSTEMMAP)
+
+%.S.o: %.S
+       ${CC} ${CFLAGS} $< -o $@
+
+%.c.o: %.c
+       ${CC} ${CFLAGS} $< -o $@
+
 c:
        rm -f $(KERNELBIN)
 
-.PHONY:clean
 clean:
-       cd boot && make clean
-       cd setup && make clean
-       cd mm && make clean
-       cd kernel && make clean
-       cd fs && make clean
-       cd pci && make clean
-       cd lib && make clean
-       cd drivers && make clean
-       cd bin && make clean
-       rm -f $(KERNELBIN) System.map snapshot.txt log.txt
-       rm -f KRNL.ELF
-
-.PHONY:install
+       rm -f $(OBJS)
+       rm -f $(KERNELBIN) $(SYSTEMMAP)
+
 install:
        cp KERNEL.BIN /boot/
-.PHONY:copy
+
 copy:
        ./scripts/copy.sh
index 12a8eee8daa6df14a55479b38abc0665cb4ccd88..66e258663d171fabe1cf4f1f4161c32a4b8fd916 100644 (file)
@@ -1,20 +1,20 @@
 CC = gcc
 CFLAGS = -c -I../include -fno-builtin
-LDOBJS = ../lib/errno.o ../lib/fork.o ../lib/lib.o ../lib/open.o \
-       ../lib/stat.o ../lib/string.o ../lib/write.o ../lib/exec.o \
-       ../lib/vsprintf.o ../lib/read.o \
-       ../lib/keyboard.o ../lib/exit.o
+LDOBJS = ../lib/errno.c.o ../lib/fork.c.o ../lib/lib.c.o ../lib/open.c.o \
+       ../lib/stat.c.o ../lib/string.c.o ../lib/write.c.o ../lib/exec.c.o \
+       ../lib/vsprintf.c.o ../lib/read.c.o \
+       ../lib/keyboard.c.o ../lib/exit.c.o
 all:
-       gcc -c shell.S -o shell.S.o
-       gcc $(CFLAGS) shell.c -o shell.o
-       ld $(LDOBJS) shell.S.o shell.o -o sh
-       gcc -c helloworld.S -o helloworld.S.o
-       gcc $(CFLAGS) helloworld.c -o helloworld.o
-       ld $(LDOBJS) helloworld.S.o helloworld.o -o hw 
+       gcc -c shell.S -o shell.S.c.o
+       gcc $(CFLAGS) shell.c -o shell.c.o
+       ld $(LDOBJS) shell.S.c.o shell.c.o -o sh
+       gcc -c helloworld.S -o helloworld.S.c.o
+       gcc $(CFLAGS) helloworld.c -o helloworld.c.o
+       ld $(LDOBJS) helloworld.S.c.o helloworld.c.o -o hw 
 
 .PHONY:clean
 clean:
-       rm sh hw helloworld.o -f
+       rm sh hw helloworld.c.o -f
 .PHONY:c
 c:
        make clean
diff --git a/boot/Makefile b/boot/Makefile
deleted file mode 100644 (file)
index 10ffe92..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS  = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c *.h ../include/*.h
-       $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S ../include/*.h
-       $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
-       $(RM) $(OBJS)
-.PHONY:c
-c:
-       make clean
diff --git a/drivers/Makefile b/drivers/Makefile
deleted file mode 100644 (file)
index 23675f3..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS  = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c ../include/*.h ./*.h
-       $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S  ../include/*.h ./*.h
-       $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
-       $(RM) $(OBJS)
-.PHONY:c
-c:
-       make clean
diff --git a/fs/Makefile b/fs/Makefile
deleted file mode 100644 (file)
index 23675f3..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS  = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c ../include/*.h ./*.h
-       $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S  ../include/*.h ./*.h
-       $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
-       $(RM) $(OBJS)
-.PHONY:c
-c:
-       make clean
diff --git a/kernel.mk b/kernel.mk
deleted file mode 100644 (file)
index e9ab7a4..0000000
--- a/kernel.mk
+++ /dev/null
@@ -1 +0,0 @@
-CF             = -g -c -I. -Iinclude -I../include -fno-builtin
diff --git a/kernel/Makefile b/kernel/Makefile
deleted file mode 100644 (file)
index 2aaf358..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS  = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c ../include/*.h
-       $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S  ../include/*.h
-       $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
-       $(RM) $(OBJS)
-.PHONY:c
-c:
-       make clean
diff --git a/lib/Makefile b/lib/Makefile
deleted file mode 100644 (file)
index 2aaf358..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS  = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c ../include/*.h
-       $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S  ../include/*.h
-       $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
-       $(RM) $(OBJS)
-.PHONY:c
-c:
-       make clean
diff --git a/mm/Makefile b/mm/Makefile
deleted file mode 100644 (file)
index 2aaf358..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS  = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c ../include/*.h
-       $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S  ../include/*.h
-       $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
-       $(RM) $(OBJS)
-.PHONY:c
-c:
-       make clean
diff --git a/pci/Makefile b/pci/Makefile
deleted file mode 100644 (file)
index 2aaf358..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS  = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c ../include/*.h
-       $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S  ../include/*.h
-       $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
-       $(RM) $(OBJS)
-.PHONY:c
-c:
-       make clean
diff --git a/setup/Makefile b/setup/Makefile
deleted file mode 100644 (file)
index 2aaf358..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-include ../kernel.mk
-CC = gcc
-CFLAGS = $(CF)
-
-CSOUCE_FILES = $(wildcard *.c)
-SSOUCE_FILES = $(wildcard *.S)
-OBJS  = $(patsubst %.c,%.o,$(CSOUCE_FILES))
-OBJS += $(patsubst %.S,%.S.o,$(SSOUCE_FILES))
-
-%.o : %.c ../include/*.h
-       $(CC) $(CFLAGS) $< -o $@
-%.S.o : %.S  ../include/*.h
-       $(CC) $(CFLAGS) $< -o $@
-
-
-all:$(OBJS)
-
-.PHONY:clean
-clean:
-       $(RM) $(OBJS)
-.PHONY:c
-c:
-       make clean