Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #54 from UteroOS/reconstruct-directory-structure
Browse files Browse the repository at this point in the history
Reconstruct directory structure
  • Loading branch information
noriyotcp authored Jun 11, 2017
2 parents 5a06941 + dcd6093 commit 2da11ce
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 17 deletions.
35 changes: 26 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,36 @@ arch ?= x86_64
target ?= $(arch)-unknown-linux-musl
kernel := build/kernel-$(arch).bin
iso := build/utero-$(arch).iso
top_dir := $(shell pwd)
INCLUDE := -I$(top_dir)/src/c_kernel/include -I$(top_dir)/src/arch/x86_64/c/include
CFLAGS := -ffreestanding -nostdinc -Wno-implicit

libcr := src/musl/lib/libcr.a
libu := build/arch/$(arch)/c/libu.a
libu_fullpath := $(subst build/,$(shell pwd)/build/,$(libu))

c_source_files := $(wildcard src/arch/$(arch)/c/*.c)
c_object_files := $(patsubst src/arch/$(arch)/c/%.c, \
build/arch/$(arch)/c/%.o, $(c_source_files))
c_object_files_fullpath := $(subst build/,$(shell pwd)/build/,$(c_object_files))

crystal_os := target/$(target)/debug/main.o
c_kernel_source_files := $(wildcard src/c_kernel/*.c)
c_kernel_object_files := $(patsubst src/c_kernel/%.c, \
build/c_kernel/%.o, $(c_kernel_source_files))

linker_script := src/arch/$(arch)/linker.ld
grub_cfg := src/arch/$(arch)/grub.cfg
assembly_source_files := $(wildcard src/arch/$(arch)/*.asm)
assembly_object_files := $(patsubst src/arch/$(arch)/%.asm, \
build/arch/$(arch)/%.o, $(assembly_source_files))
crystal_files := $(shell find ./ -name *.cr)

c_object_files_fullpath := $(subst build/,$(shell pwd)/build/,$(c_object_files))

OBJS = $(assembly_object_files) $(c_object_files) $(c_kernel_object_files)

crystal_os := target/$(target)/debug/main.o

linker_script := src/arch/$(arch)/linker.ld
grub_cfg := src/arch/$(arch)/grub.cfg

.PHONY: all test clean run iso

all: $(kernel)
Expand All @@ -40,11 +52,12 @@ test:
@crystal spec -v

clean:
@rm -f $(kernel) $(iso) $(assembly_object_files) $(c_object_files) $(libu)
@rm -f $(kernel) $(iso) $(OBJS) $(libu)
@rm -rf target/
$(MAKE) -C build/musl clean

cleanobjs:
@rm -f $(assembly_object_files) $(c_object_files)
@rm -f $(OBJS)
@rm -rf target/

run: $(iso)
Expand Down Expand Up @@ -72,13 +85,17 @@ $(crystal_os): $(libu) $(crystal_files)
$(libcr):
$(MAKE) -C build/musl

$(libu): $(assembly_object_files) $(c_object_files)
@ld -n -nostdlib -melf_$(arch) --build-id=none -r -T $(linker_script) -o $@ $(c_object_files) $(assembly_object_files)
$(libu): $(OBJS)
@ld -n -nostdlib -melf_$(arch) --build-id=none -r -T $(linker_script) -o $@ $(c_kernel_object_files) $(c_object_files) $(assembly_object_files)

build/arch/$(arch)/%.o: src/arch/$(arch)/%.asm
@mkdir -p $(shell dirname $@)
@nasm -felf64 $< -o $@

build/arch/$(arch)/c/%.o: src/arch/$(arch)/c/%.c
@mkdir -p $(shell dirname $@)
@cc -ffreestanding -nostdinc -Wno-implicit -o $@ -c $<
@cc $(CFLAGS) $(INCLUDE) -o $@ -c $<

build/c_kernel/%.o: src/c_kernel/%.c
@mkdir -p $(shell dirname $@)
@cc $(CFLAGS) $(INCLUDE) -o $@ -c $<
2 changes: 1 addition & 1 deletion src/arch/x86_64/c/idt.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// The part of this file was taken from:
// https://github.com/RWTH-OS/eduOS/blob/master/arch/x86/kernel/idt.c

#include "idt.h"
#include <asm/idt.h>

static idt_entry_t idt[256] = {[0 ... 255] = {0, 0, 0, 0, 0, 0, 0}};
static idt_ptr_t idtp;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions src/arch/x86_64/c/isrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
// The part of this file was taken from:
// https://github.com/RWTH-OS/eduOS/blob/master/arch/x86/kernel/isrs.c

#include "idt.h"
#include "isrs.h"
#include "io.h"
#include "stdio.h"
#include <asm/idt.h>
#include <asm/isrs.h>
#include <asm/io.h>
#include <stdio.h>

/*
* These are function prototypes for all of the exception
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#include "stdio.h"
#include <stdio.h>
#include "make_string.h"
#define N 256

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef MAKE_STRING_H
#define MAKE_STRING_H

#include "stddef.h"
#include <asm/stddef.h>

char *make_string(char *fmt, ...);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "make_string.h"
#include "multiboot.h"
#include <asm/multiboot.h>
// #include "stdint.h"
#define N 256

Expand Down

0 comments on commit 2da11ce

Please sign in to comment.