Skip to content
Open
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
14 changes: 4 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ jobs:
- name: nasm
run: brew install nasm

- name: setup
run: ./setup.sh

- name: build
run: ./build.sh
- name: make
run: make all

build-ubuntu:
runs-on: ubuntu-latest
Expand All @@ -34,8 +31,5 @@ jobs:
- name: install nasm
run: sudo apt install nasm

- name: setup
run: ./setup.sh

- name: build
run: ./build.sh
- name: make
run: make all
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

# =============================================================================
# BareMetal -- a 64-bit OS written in Assembly for x86-64 systems
# Copyright (C) 2025 Tom Everett -- see LICENSE.TXT
#
# Version 1.0
# =============================================================================

include mk/build.mk

# curl
ifneq ("/usr/bin/curl,"")
CURL_EXISTS = 1
else
CURL_EXISTS = 0
endif

OBJDIR=bin
SRCDIR=src
BAREMETAL_REPO=https://raw.githubusercontent.com/ReturnInfinity/BareMetal/master

all: apps

apps: $(OBJDIR)/monitor.bin

$(OBJDIR)/monitor.bin: objdir $(SRCDIR)/monitor.asm $(SRCDIR)/api/libBareMetal.asm
$(NASM) $(SRCDIR)/monitor.asm -o $(OBJDIR)/monitor.bin -l $(OBJDIR)/monitor-debug.txt -I $(SRCDIR)

$(SRCDIR)/api/libBareMetal.asm:
mkdir $(SRCDIR)/api
ifeq ($(CURL_EXISTS), 1)
curl -s -o $(SRCDIR)/api/libBareMetal.asm $(BAREMETAL_REPO)/api/libBareMetal.asm
else
wget -q $(BAREMETAL_REPO)/api/libBareMetal.asm
mv libBareMetal.asm $(SRCDIR)/api/
endif
clean:
rm -rf $(OBJDIR)
rm -rf $(SRCDIR)/api/

objdir:
mkdir -p $(OBJDIR)


4 changes: 0 additions & 4 deletions build.sh

This file was deleted.

4 changes: 0 additions & 4 deletions clean.sh

This file was deleted.

15 changes: 15 additions & 0 deletions mk/build.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# =============================================================================
# BareMetal -- a 64-bit OS written in Assembly for x86-64 systems
# Copyright (C) 2025 Tom Everett -- see LICENSE.TXT
#
# Version 1.0
# =============================================================================

# detect build platform
UNAME := $(shell uname)
ifeq ($(UNAME),Darwin)
include mk/gcc-i386-darwin.mk
else
include mk/gcc-i386-linux.mk
endif
28 changes: 28 additions & 0 deletions mk/gcc-i386-darwin.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

# =============================================================================
# BareMetal -- a 64-bit OS written in Assembly for x86-64 systems
# Copyright (C) 2025 Tom Everett -- see LICENSE.TXT
#
# Version 1.0
# =============================================================================

# requires 'brew install x86_64-elf-gcc'

CC=x86_64-elf-gcc
LD=x86_64-elf-ld
CFLAGS=-c -m64 -nostdlib -nostartfiles -nodefaultlibs -ffreestanding -fomit-frame-pointer -mno-red-zone -fno-builtin -mcmodel=large
LDFLAGS=
NASM=nasm

# objcopy
OBJCOPY=x86_64-elf-objcopy
OBJCOPYFLAGS=-O binary

# strip
STRIP=x86_64-elf-strip
STRIPFLAGS=

# ar
AR=x86_64-elf-ar
ARFLAGS=-crs

26 changes: 26 additions & 0 deletions mk/gcc-i386-linux.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# =============================================================================
# BareMetal -- a 64-bit OS written in Assembly for x86-64 systems
# Copyright (C) 2025 Tom Everett -- see LICENSE.TXT
#
# Version 1.0
# =============================================================================

CC=gcc
LD=ld
CFLAGS=-c -m64 -nostdlib -nostartfiles -nodefaultlibs -ffreestanding -fomit-frame-pointer -mno-red-zone -fno-builtin
LDFLAGS=
NASM=nasm

# objcopy
OBJCOPY=objcopy
OBJCOPYFLAGS=-O binary

# strip
STRIP=strip
STRIPFLAGS=


# ar
AR=ar
ARFLAGS=-crs
16 changes: 0 additions & 16 deletions setup.sh

This file was deleted.