build system refresh

This commit is contained in:
2026-07-16 16:09:12 -05:00
parent b588634253
commit 3246dbbd19
49 changed files with 185 additions and 203 deletions

Binary file not shown.

1
programs/rocksh/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
rocksh

View File

@@ -1,10 +1,14 @@
CC = i686-elf-gcc
LD = i686-elf-ld
CFLAGS = -ffreestanding -O2 -Wall -Wextra -I../../rocklibc/include
SYSROOT = ../sysroot
USR_INCLUDE = $(SYSROOT)/usr/include
USR_LIB = $(SYSROOT)/usr/lib
CFLAGS = -ffreestanding -O2 -Wall -Wextra -I$(USR_INCLUDE)
LDFLAGS = -m elf_i386 -nostdlib
TARGET = rocksh.elf
TARGET = rocksh
all: $(TARGET)
@@ -14,11 +18,12 @@ crt0.o: crt0.S
main.o: main.c
$(CC) $(CFLAGS) -c main.c -o main.o
$(TARGET): crt0.o main.o ../lib/rlibc.a
$(LD) $(LDFLAGS) -T linker.ld crt0.o main.o ../lib/rlibc.a -o $(TARGET)
$(TARGET): crt0.o main.o $(USR_LIB)/*
$(LD) $(LDFLAGS) -T linker.ld crt0.o main.o $(USR_LIB)/* -o $(TARGET)
cp $(TARGET) $(SYSROOT)/usr/bin
clean:
rm -f *.o $(TARGET) compile_commands.json
rm -f *.o $(TARGET) compile_commands.json
rm -rf .cache
.PHONY: all clean test

1
programs/rockterm/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
rockterm

View File

@@ -1,46 +1,31 @@
#include "syscall.h"
#include <unistd.h>
#include <sys/video.h>
#define VGA_TEXT_W 80
#define VGA_TEXT_H 25
typedef struct {
void term();
} font_t;
void term_write_char(char c);
void render_char_at(char c, int x, int y);
int spawn_shell();
int ptys;
int ptym;
void* fb;
fb_info_t fb_info;
void* framebuffer_address;
int terminal_col = 0;
int terminal_row = 0;
void term_write_char(char c) {
}
font_t* terminal_font = NULL;
int main(int argc, char *argv[]) {
(void)argc;
(void)argv;
ptym = pty(&ptys);
if (fork() == 0) {
close(ptym);
dup2(ptys, 0);
dup2(0, 1);
dup2(0, 2);
exec("/bin/rocksh.elf");
}
close(ptys);
dup2(ptym, 0);
dup2(0, 1);
dup2(0, 2);
int vga_fd = open("/dev/vga");
if (vga_fd == -1) return 1;
@@ -52,9 +37,38 @@ int main(int argc, char *argv[]) {
return 1;
}
framebuffer_address = mmap(vga_fd);
mmap(vga_fd);
// if (!spawn_shell()) {
// return 1;
// }
return 0;
}
void render_char_at(char c, int x, int y) {
if (!terminal_font) return;
}
void term_write_char(char c) {
}
int spawn_shell() {
ptym = pty(&ptys);
if (fork() == 0) {
close(ptym);
dup2(ptys, 0);
dup2(0, 1);
dup2(0, 2);
if (!exec("/usr/bin/rocksh")) return 0;
}
close(ptys);
dup2(ptym, 0);
dup2(0, 1);
dup2(0, 2);
return 1;
}

View File

@@ -0,0 +1,29 @@
CC = i686-elf-gcc
LD = i686-elf-ld
SYSROOT = ../sysroot
USR_INCLUDE = $(SYSROOT)/usr/include
USR_LIB = $(SYSROOT)/usr/lib
CFLAGS = -ffreestanding -O2 -Wall -Wextra -I$(USR_INCLUDE)
LDFLAGS = -m elf_i386 -nostdlib
TARGET = rockterm
all: $(TARGET)
crt0.o: crt0.S
$(CC) $(CFLAGS) -c crt0.S -o crt0.o
main.o: main.c
$(CC) $(CFLAGS) -c main.c -o main.o
$(TARGET): crt0.o main.o $(USR_LIB)/*
$(LD) $(LDFLAGS) -T linker.ld crt0.o main.o $(USR_LIB)/* -o $(TARGET)
cp $(TARGET) $(SYSROOT)/usr/bin
clean:
rm -f *.o $(TARGET) compile_commands.json
rm -rf .cache
.PHONY: all clean test

View File

@@ -1,6 +0,0 @@
#include <stdio.h>
int main(int argc, char** argv) {
printf("hello, world!\n");
return 0;
}

View File

@@ -1,24 +0,0 @@
CC = i686-elf-gcc
LD = i686-elf-ld
CFLAGS = -ffreestanding -O2 -Wall -Wextra -I../../rocklibc/include
LDFLAGS = -m elf_i386 -nostdlib
TARGET = test.elf
all: $(TARGET)
crt0.o: crt0.S
$(CC) $(CFLAGS) -c crt0.S -o crt0.o
main.o: main.c
$(CC) $(CFLAGS) -c main.c -o main.o
$(TARGET): crt0.o main.o ../lib/rlibc.a
$(LD) $(LDFLAGS) -T linker.ld crt0.o main.o ../lib/rlibc.a -o $(TARGET)
clean:
rm -f *.o $(TARGET) compile_commands.json
rm -rf .cache
.PHONY: all clean test

View File

@@ -1,21 +0,0 @@
.global _start
.extern exit
.section .text
_start:
xor %ebp, %ebp
mov (%esp), %eax
lea 4(%esp), %ebx
lea 8(%esp,%eax,4), %ecx
and $-16, %esp
push %ecx
push %ebx
push %eax
call main
push %eax
call exit

View File

@@ -1,31 +0,0 @@
ENTRY(_start)
SECTIONS
{
. = 0x40000000;
.text ALIGN(4K) :
{
/* Force the crt0.o entry code to be placed FIRST in memory */
KEEP(*crt0.o(.text))
*(.text .text.*)
}
.rodata ALIGN(4K) :
{
*(.rodata .rodata.*)
}
.data ALIGN(4K) :
{
*(.data .data.*)
}
.bss ALIGN(4K) :
{
_bss_start = .;
*(.bss .bss.*)
*(COMMON)
_bss_end = .;
}
}

View File

@@ -1,24 +0,0 @@
CC = i686-elf-gcc
LD = i686-elf-ld
CFLAGS = -ffreestanding -O2 -Wall -Wextra -I../../rocklibc/include
LDFLAGS = -m elf_i386 -nostdlib
TARGET = vga_text_term.elf
all: $(TARGET)
crt0.o: crt0.S
$(CC) $(CFLAGS) -c crt0.S -o crt0.o
main.o: main.c
$(CC) $(CFLAGS) -c main.c -o main.o
$(TARGET): crt0.o main.o ../lib/rlibc.a
$(LD) $(LDFLAGS) -T linker.ld crt0.o main.o ../lib/rlibc.a -o $(TARGET)
clean:
rm -f *.o $(TARGET) compile_commands.json
rm -rf .cache
.PHONY: all clean test