Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif

.PHONY: all shared user kernel clean raspi virt run debug dump prepare-fs help install

all: shared user kernel
all: shared kernel user
@echo "Build complete."
./createfs

Expand Down
2 changes: 2 additions & 0 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ LD := $(ARCH)-ld
AR := $(ARCH)-ar
OBJCOPY := $(ARCH)-objcopy

BUILD_DIR := ./build

COMMON_FLAGS ?= -ffreestanding -nostdlib -fno-exceptions -fno-unwind-tables \
-fno-asynchronous-unwind-tables -g -O0 -Wall -Wextra \
-Wno-unused-parameter -Wno-address-of-packed-member \
Expand Down
File renamed without changes.
16 changes: 10 additions & 6 deletions kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,30 @@ C_SRC := $(shell find . -name '*.c')
ASM_SRC := $(shell find . -name '*.S')
CPP_SRC := $(shell find . -name '*.cpp')
OBJ := $(C_SRC:.c=.o) $(ASM_SRC:.S=.o) $(CPP_SRC:.cpp=.o)
OBJL := $(filter-out ./boot.o,$(OBJ))
OBJL := $(filter-out $(BUILD_DIR)/boot.o,$(addprefix $(BUILD_DIR)/,$(notdir $(OBJ))))
DEP := $(C_SRC:.c=.d) $(ASM_SRC:.S=.d) $(CPP_SRC:.cpp=.d)

ELF := ../kernel.elf
TARGET := ../kernel.img

all: $(TARGET)

$(TARGET): ../shared/libshared.a $(OBJ)
$(VLD) $(LDFLAGS) -o $(ELF) $(OBJL) ../shared/libshared.a
prepare:
mkdir -p $(BUILD_DIR)

$(TARGET): ../shared/libshared.a prepare $(OBJ)
echo $(LDFLAGS)
$(VLD) $(LDFLAGS) -o $(ELF) $(OBJL) ../shared/libshared.a $(BUILD_DIR)/boot.o
$(OBJCOPY) -O binary $(ELF) $@

%.o: %.S
$(VAS) $(CFLAGS) -c $< -o $@
$(VAS) $(CFLAGS) -c $< -o $(BUILD_DIR)/$(notdir $@)

%.o: %.c
$(VCC) $(CFLAGS) -c -MMD -MP $< -o $@
$(VCC) $(CFLAGS) -c -MMD -MP $< -o $(BUILD_DIR)/$(notdir $@)

%.o: %.cpp
$(VCXX) $(CXXFLAGS) -c -MMD -MP $< -o $@
$(VCXX) $(CXXFLAGS) -c -MMD -MP $< -o $(BUILD_DIR)/$(notdir $@)

clean:
$(RM) $(CLEAN_OBJS) $(CLEAN_DEPS) $(ELF) $(TARGET)
Expand Down
2 changes: 1 addition & 1 deletion kernel/linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ENTRY(_start)
SECTIONS {
. = LOAD_ADDR;
kernel_start = .;
.boot . : { boot.o(.text) }
.boot . : { ./build/boot.o(.text) }
.text : {
*(EXCLUDE_FILE(shared/*.o) .text .text.[!p]*)
}
Expand Down
17 changes: 11 additions & 6 deletions shared/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,26 @@ DEP := $(C_SRC:.c=.d) $(ASM_SRC:.S=.d) $(CPP_SRC:.cpp=.d)

TARGET := libshared.a

.PHONY: all clean
.PHONY: all clean prepare

all: $(TARGET)
all: prepare $(TARGET)

prepare:
mkdir -p $(BUILD_DIR)

$(TARGET): $(OBJ)
$(VAR) rcs $@ $^
echo "Finishing build"
echo $(addprefix $(BUILD_DIR)/,$(notdir $(OBJ)))
$(VAR) rcs $@ $(addprefix $(BUILD_DIR)/,$(notdir $(OBJ)))

%.o: %.S
$(VAS) $(CFLAGS) -c $< -o $@
$(VAS) $(CFLAGS) -c $< -o $(BUILD_DIR)/$(notdir $@)

%.o: %.c
$(VCC) $(CFLAGS) -c -MMD -MP $< -o $@
$(VCC) $(CFLAGS) -c -MMD -MP $< -o $(BUILD_DIR)/$(notdir $@)

%.o: %.cpp
$(VCXX) $(CXXFLAGS) -c -MMD -MP $< -o $@
$(VCXX) $(CXXFLAGS) -c -MMD -MP $< -o $(BUILD_DIR)/$(notdir $@)

clean:
$(RM) $(CLEAN_OBJS) $(CLEAN_DEPS) $(TARGET)
Expand Down
16 changes: 10 additions & 6 deletions user/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,26 @@ ELF := $(NAME).elf
TARGET := $(NAME).bin
LOCATION := ../fs/redos/user/

.PHONY: all clean
.PHONY: prepare all clean

all: $(LOCATION)$(TARGET)
all: prepare $(LOCATION)$(TARGET)

prepare:
mkdir -p $(BUILD_DIR)

$(LOCATION)$(TARGET): $(OBJ)
$(VLD) $(LDFLAGS) -o $(LOCATION)$(ELF) $(OBJ) ../shared/libshared.a
echo $(LDFLAGS) -o $(LOCATION)$(ELF) $(addprefix $(BUILD_DIR)/,$(notdir $(OBJ))) ../shared/libshared.a
$(VLD) $(LDFLAGS) -o $(LOCATION)$(ELF) $(addprefix $(BUILD_DIR)/,$(notdir $(OBJ))) ../shared/libshared.a
$(OBJCOPY) -O binary $(LOCATION)$(ELF) $@

%.o: %.S
$(VAS) $(CFLAGS) -c $< -o $@
$(VAS) $(CFLAGS) -c $< -o $(BUILD_DIR)/$(notdir $@)

%.o: %.c
$(VCC) $(CFLAGS) -c -MMD -MP $< -o $@
$(VCC) $(CFLAGS) -c -MMD -MP $< -o $(BUILD_DIR)/$(notdir $@)

%.o: %.cpp
$(VCXX) $(CXXFLAGS) -c -MMD -MP $< -o $@
$(VCXX) $(CXXFLAGS) -c -MMD -MP $< -o $(BUILD_DIR)/$(notdir $@)

clean:
$(RM) $(CLEAN_OBJS) $(CLEAN_DEPS) $(TARGET)
Expand Down