From c757940bd61b0125e037a59eb77565e42470201b Mon Sep 17 00:00:00 2001 From: YJwu2023 Date: Thu, 31 Aug 2023 17:54:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96makefile=20(#352)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/src/Makefile | 5 +---- kernel/src/common/math/Makefile | 16 ++++++---------- kernel/src/driver/acpi/Makefile | 12 +++++++----- kernel/src/driver/disk/Makefile | 13 ++++++++----- kernel/src/driver/keyboard/Makefile | 12 +++++++----- kernel/src/driver/mouse/Makefile | 12 +++++++----- kernel/src/driver/multiboot2/Makefile | 13 ++++++++----- kernel/src/driver/pci/Makefile | 14 ++++++++------ kernel/src/driver/video/Makefile | 12 +++++++----- kernel/src/ktest/Makefile | 22 ++++++---------------- kernel/src/syscall/Makefile | 10 ++++++---- 11 files changed, 71 insertions(+), 70 deletions(-) diff --git a/kernel/src/Makefile b/kernel/src/Makefile index 673183b4..841c40a4 100644 --- a/kernel/src/Makefile +++ b/kernel/src/Makefile @@ -44,11 +44,8 @@ all: kernel @dbg='debug';for x in $$dbg; do \ cd $$x;\ - $(MAKE) generate_kallsyms kernel_root_path="$(shell pwd)";\ + $(MAKE) generate_kallsyms kernel_root_path="$(shell pwd)"||exit 1;\ cd ..;\ - if [ "$$?" != "0" ]; then\ - exit $$?;\ - fi;\ done diff --git a/kernel/src/common/math/Makefile b/kernel/src/common/math/Makefile index c70df022..f8513471 100644 --- a/kernel/src/common/math/Makefile +++ b/kernel/src/common/math/Makefile @@ -1,14 +1,10 @@ - - +SRC = $(wildcard *.c) +OBJ = $(SRC:.c=.o) CFLAGS += -I . -all: fabs.o round.o pow.o +.PHONY: all -fabs.o: fabs.c - $(CC) $(CFLAGS) -c fabs.c -o fabs.o +all: $(OBJ) -round.o: round.c - $(CC) $(CFLAGS) -c round.c -o round.o - -pow.o: pow.c - $(CC) $(CFLAGS) -c pow.c -o pow.o \ No newline at end of file +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ \ No newline at end of file diff --git a/kernel/src/driver/acpi/Makefile b/kernel/src/driver/acpi/Makefile index 4fed3167..f8513471 100644 --- a/kernel/src/driver/acpi/Makefile +++ b/kernel/src/driver/acpi/Makefile @@ -1,8 +1,10 @@ - -all: acpi.o - +SRC = $(wildcard *.c) +OBJ = $(SRC:.c=.o) CFLAGS += -I . +.PHONY: all -acpi.o: acpi.c - $(CC) $(CFLAGS) -c acpi.c -o acpi.o +all: $(OBJ) + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ \ No newline at end of file diff --git a/kernel/src/driver/disk/Makefile b/kernel/src/driver/disk/Makefile index 377024dc..f8513471 100644 --- a/kernel/src/driver/disk/Makefile +++ b/kernel/src/driver/disk/Makefile @@ -1,7 +1,10 @@ - -all: ata.o - +SRC = $(wildcard *.c) +OBJ = $(SRC:.c=.o) CFLAGS += -I . -ata.o: ata.c - $(CC) $(CFLAGS) -c ata.c -o ata.o \ No newline at end of file +.PHONY: all + +all: $(OBJ) + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ \ No newline at end of file diff --git a/kernel/src/driver/keyboard/Makefile b/kernel/src/driver/keyboard/Makefile index 517494b4..f8513471 100644 --- a/kernel/src/driver/keyboard/Makefile +++ b/kernel/src/driver/keyboard/Makefile @@ -1,8 +1,10 @@ - -all: ps2_keyboard.o - +SRC = $(wildcard *.c) +OBJ = $(SRC:.c=.o) CFLAGS += -I . +.PHONY: all -ps2_keyboard.o: ps2_keyboard.c - $(CC) $(CFLAGS) -c ps2_keyboard.c -o ps2_keyboard.o \ No newline at end of file +all: $(OBJ) + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ \ No newline at end of file diff --git a/kernel/src/driver/mouse/Makefile b/kernel/src/driver/mouse/Makefile index 192de29e..f8513471 100644 --- a/kernel/src/driver/mouse/Makefile +++ b/kernel/src/driver/mouse/Makefile @@ -1,8 +1,10 @@ - -all: ps2_mouse.o - +SRC = $(wildcard *.c) +OBJ = $(SRC:.c=.o) CFLAGS += -I . +.PHONY: all -ps2_mouse.o: ps2_mouse.c - $(CC) $(CFLAGS) -c ps2_mouse.c -o ps2_mouse.o \ No newline at end of file +all: $(OBJ) + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ \ No newline at end of file diff --git a/kernel/src/driver/multiboot2/Makefile b/kernel/src/driver/multiboot2/Makefile index 0e352497..f8513471 100644 --- a/kernel/src/driver/multiboot2/Makefile +++ b/kernel/src/driver/multiboot2/Makefile @@ -1,7 +1,10 @@ - -all: multiboot2.o - +SRC = $(wildcard *.c) +OBJ = $(SRC:.c=.o) CFLAGS += -I . -multiboot2.o: multiboot2.c - $(CC) $(CFLAGS) -c multiboot2.c -o multiboot2.o \ No newline at end of file +.PHONY: all + +all: $(OBJ) + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ \ No newline at end of file diff --git a/kernel/src/driver/pci/Makefile b/kernel/src/driver/pci/Makefile index 31828481..a505ba89 100644 --- a/kernel/src/driver/pci/Makefile +++ b/kernel/src/driver/pci/Makefile @@ -1,9 +1,11 @@ - -all: pci_irq.o - +SRC = $(wildcard *.c) +OBJ = $(SRC:.c=.o) CFLAGS += -I . - -pci_irq.o: pci_irq.c - $(CC) $(CFLAGS) -c pci_irq.c -o pci_irq.o +.PHONY: all + +all: $(OBJ) + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ diff --git a/kernel/src/driver/video/Makefile b/kernel/src/driver/video/Makefile index eb0fafb1..ae15a094 100644 --- a/kernel/src/driver/video/Makefile +++ b/kernel/src/driver/video/Makefile @@ -1,8 +1,10 @@ - -all: video.o - +SRC = $(wildcard *.c) +OBJ = $(SRC:.c=.o) CFLAGS += -I . +.PHONY: all -video.o: video.c - $(CC) $(CFLAGS) -c video.c -o video.o +all: $(OBJ) + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ diff --git a/kernel/src/ktest/Makefile b/kernel/src/ktest/Makefile index 4c47f8ce..f8513471 100644 --- a/kernel/src/ktest/Makefile +++ b/kernel/src/ktest/Makefile @@ -1,20 +1,10 @@ - +SRC = $(wildcard *.c) +OBJ = $(SRC:.c=.o) CFLAGS += -I . +.PHONY: all -all: ktest.o bitree.o kfifo.o mutex.o idr.o +all: $(OBJ) -ktest.o: ktest.c - $(CC) $(CFLAGS) -c ktest.c -o ktest.o - -bitree.o: test-bitree.c - $(CC) $(CFLAGS) -c test-bitree.c -o test-bitree.o - -kfifo.o: test-kfifo.c - $(CC) $(CFLAGS) -c test-kfifo.c -o test-kfifo.o - -mutex.o: test-mutex.c - $(CC) $(CFLAGS) -c test-mutex.c -o test-mutex.o - -idr.o: test-idr.c - $(CC) $(CFLAGS) -c test-idr.c -o test-idr.o \ No newline at end of file +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ \ No newline at end of file diff --git a/kernel/src/syscall/Makefile b/kernel/src/syscall/Makefile index 477a787a..ae15a094 100644 --- a/kernel/src/syscall/Makefile +++ b/kernel/src/syscall/Makefile @@ -1,8 +1,10 @@ - +SRC = $(wildcard *.c) +OBJ = $(SRC:.c=.o) CFLAGS += -I . +.PHONY: all -all: syscall.o +all: $(OBJ) -syscall.o: syscall.c - $(CC) $(CFLAGS) -c syscall.c -o syscall.o +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@