Move to src/obj directory structure
This commit is contained in:
parent
878ca00f18
commit
ea68d596f7
3 changed files with 17 additions and 14 deletions
4
kernel/.gitignore
vendored
4
kernel/.gitignore
vendored
|
@ -1,4 +1,4 @@
|
||||||
/limine.h
|
/src/limine.h
|
||||||
|
/obj
|
||||||
*.elf
|
*.elf
|
||||||
*.o
|
*.o
|
||||||
*.d
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ override CFLAGS += \
|
||||||
|
|
||||||
# Internal C preprocessor flags that should not be changed by the user.
|
# Internal C preprocessor flags that should not be changed by the user.
|
||||||
override CPPFLAGS := \
|
override CPPFLAGS := \
|
||||||
-I. \
|
-I src \
|
||||||
$(CPPFLAGS) \
|
$(CPPFLAGS) \
|
||||||
-MMD \
|
-MMD \
|
||||||
-MP
|
-MP
|
||||||
|
@ -84,17 +84,17 @@ override NASMFLAGS += \
|
||||||
|
|
||||||
# Use "find" to glob all *.c, *.S, and *.asm files in the tree and obtain the
|
# Use "find" to glob all *.c, *.S, and *.asm files in the tree and obtain the
|
||||||
# object and header dependency file names.
|
# object and header dependency file names.
|
||||||
override CFILES := $(shell find -L . -type f -name '*.c')
|
override CFILES := $(shell cd src && find -L . -type f -name '*.c')
|
||||||
override ASFILES := $(shell find -L . -type f -name '*.S')
|
override ASFILES := $(shell cd src && find -L . -type f -name '*.S')
|
||||||
override NASMFILES := $(shell find -L . -type f -name '*.asm')
|
override NASMFILES := $(shell cd src && find -L . -type f -name '*.asm')
|
||||||
override OBJ := $(CFILES:.c=.c.o) $(ASFILES:.S=.S.o) $(NASMFILES:.asm=.asm.o)
|
override OBJ := $(addprefix obj/,$(CFILES:.c=.c.o) $(ASFILES:.S=.S.o) $(NASMFILES:.asm=.asm.o))
|
||||||
override HEADER_DEPS := $(CFILES:.c=.c.d) $(ASFILES:.S=.S.d)
|
override HEADER_DEPS := $(addprefix obj/,$(CFILES:.c=.c.d) $(ASFILES:.S=.S.d))
|
||||||
|
|
||||||
# Default target.
|
# Default target.
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(KERNEL)
|
all: $(KERNEL)
|
||||||
|
|
||||||
limine.h:
|
src/limine.h:
|
||||||
curl -Lo $@ https://github.com/limine-bootloader/limine/raw/trunk/limine.h
|
curl -Lo $@ https://github.com/limine-bootloader/limine/raw/trunk/limine.h
|
||||||
|
|
||||||
# Link rules for the final kernel executable.
|
# Link rules for the final kernel executable.
|
||||||
|
@ -105,22 +105,25 @@ $(KERNEL): GNUmakefile linker.ld $(OBJ)
|
||||||
-include $(HEADER_DEPS)
|
-include $(HEADER_DEPS)
|
||||||
|
|
||||||
# Compilation rules for *.c files.
|
# Compilation rules for *.c files.
|
||||||
%.c.o: %.c GNUmakefile limine.h
|
obj/%.c.o: src/%.c GNUmakefile src/limine.h
|
||||||
|
mkdir -p obj
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||||
|
|
||||||
# Compilation rules for *.S files.
|
# Compilation rules for *.S files.
|
||||||
%.S.o: %.S GNUmakefile limine.h
|
obj/%.S.o: src/%.S GNUmakefile src/limine.h
|
||||||
|
mkdir -p obj
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
||||||
|
|
||||||
# Compilation rules for *.asm (nasm) files.
|
# Compilation rules for *.asm (nasm) files.
|
||||||
%.asm.o: %.asm GNUmakefile
|
obj/%.asm.o: src/%.asm GNUmakefile
|
||||||
|
mkdir -p obj
|
||||||
nasm $(NASMFLAGS) $< -o $@
|
nasm $(NASMFLAGS) $< -o $@
|
||||||
|
|
||||||
# Remove object files and the final executable.
|
# Remove object files and the final executable.
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(KERNEL) $(OBJ) $(HEADER_DEPS)
|
rm -rf $(KERNEL) obj
|
||||||
|
|
||||||
.PHONY: distclean
|
.PHONY: distclean
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -f limine.h
|
rm -f src/limine.h
|
||||||
|
|
Loading…
Add table
Reference in a new issue