mirror of
https://github.com/JannisHeydemann/BoredOS.git
synced 2026-05-30 10:26:59 +00:00
feature: Add ELF metadata support
This commit is contained in:
@@ -5,10 +5,19 @@ CC = x86_64-elf-gcc
|
||||
AS = nasm
|
||||
LD = x86_64-elf-ld
|
||||
|
||||
CFLAGS = -Wall -Wextra -std=gnu11 -ffreestanding -O2 -fno-stack-protector -fno-stack-check -fno-lto -fno-pie -m64 -march=x86-64 -mno-red-zone -I. -Ilibc
|
||||
CFLAGS = -Wall -Wextra -std=gnu11 -ffreestanding -O2 -fno-stack-protector -fno-stack-check -fno-lto -fno-pie -m64 -march=x86-64 -mno-red-zone -I. -Ilibc -I../sys
|
||||
LDFLAGS = -m elf_x86_64 -nostdlib -static -no-pie -Ttext=0x40000000 --no-dynamic-linker -z text -z max-page-size=0x1000 -e _start
|
||||
|
||||
BIN_DIR = bin
|
||||
APP_METADATA_TOOL = ../../tools/gen_userland_note.sh
|
||||
APP_ICON_SOURCE_DIR = ../images/icons/colloid
|
||||
APP_METADATA_SOURCE_DOOM = games/doom/doomgeneric_boredos.c
|
||||
APP_METADATA_SOURCE_LUA = cli/third_party/lua/boredos_onelua.c
|
||||
APP_SOURCE_DIRS = . cli gui sys games net cli/third_party
|
||||
|
||||
define app_source_for
|
||||
$(if $(filter doom,$1),$(APP_METADATA_SOURCE_DOOM),$(if $(filter lua,$1),$(APP_METADATA_SOURCE_LUA),$(firstword $(foreach d,$(APP_SOURCE_DIRS),$(wildcard $(d)/$1.c)))))
|
||||
endef
|
||||
|
||||
LIBC_SOURCES = $(wildcard libc/*.c)
|
||||
LIBC_OBJS = $(patsubst libc/%.c, $(BIN_DIR)/%.o, $(LIBC_SOURCES)) $(BIN_DIR)/crt0.o $(BIN_DIR)/libwidget.o
|
||||
@@ -19,6 +28,9 @@ vpath %.c cli gui sys games libc net cli/third_party
|
||||
APP_SOURCES_FULL = $(wildcard cli/*.c gui/*.c sys/*.c games/*.c *.c net/*.c cli/third_party/*.c)
|
||||
APP_SOURCES = $(filter-out stb_image.c, $(APP_SOURCES_FULL))
|
||||
APP_ELFS = $(patsubst %.c, $(BIN_DIR)/%.elf, $(notdir $(APP_SOURCES)))
|
||||
APP_NAMES = $(sort $(basename $(notdir $(APP_SOURCES))) doom lua)
|
||||
APP_NOTE_CSOURCES = $(patsubst %, $(BIN_DIR)/%.note.c, $(APP_NAMES))
|
||||
APP_NOTE_OBJS = $(patsubst %, $(BIN_DIR)/%.note.o, $(APP_NAMES))
|
||||
|
||||
DOOM_SOURCES = $(wildcard games/doom/*.c)
|
||||
DOOM_OBJS = $(patsubst games/doom/%.c, $(BIN_DIR)/%.o, $(DOOM_SOURCES))
|
||||
@@ -43,35 +55,46 @@ $(BIN_DIR)/libwidget.o: ../wm/libwidget.c | $(BIN_DIR)
|
||||
$(BIN_DIR)/stb_image.o: stb_image.c | $(BIN_DIR)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(BIN_DIR)/%.note.c: $(APP_METADATA_TOOL) | $(BIN_DIR)
|
||||
src="$(call app_source_for,$*)"; \
|
||||
if [ -z "$$src" ] || [ ! -f "$$src" ]; then \
|
||||
echo "error: metadata source not found for app '$*'" >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
sh $(APP_METADATA_TOOL) "$*" "$$src" "$(APP_ICON_SOURCE_DIR)" "$@"
|
||||
|
||||
$(BIN_DIR)/%.note.o: $(BIN_DIR)/%.note.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(BIN_DIR)/%.o: %.c | $(BIN_DIR)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(BIN_DIR)/viewer.elf: $(LIBC_OBJS) $(BIN_DIR)/viewer.o $(BIN_DIR)/stb_image.o
|
||||
$(BIN_DIR)/viewer.elf: $(LIBC_OBJS) $(BIN_DIR)/viewer.o $(BIN_DIR)/stb_image.o $(BIN_DIR)/viewer.note.o
|
||||
$(LD) $(LDFLAGS) $^ -o $@
|
||||
|
||||
$(BIN_DIR)/settings.elf: $(LIBC_OBJS) $(BIN_DIR)/settings.o $(BIN_DIR)/stb_image.o
|
||||
$(BIN_DIR)/settings.elf: $(LIBC_OBJS) $(BIN_DIR)/settings.o $(BIN_DIR)/stb_image.o $(BIN_DIR)/settings.note.o
|
||||
$(LD) $(LDFLAGS) $^ -o $@
|
||||
|
||||
$(BIN_DIR)/browser.elf: $(LIBC_OBJS) $(BIN_DIR)/browser.o $(BIN_DIR)/stb_image.o
|
||||
$(BIN_DIR)/browser.elf: $(LIBC_OBJS) $(BIN_DIR)/browser.o $(BIN_DIR)/stb_image.o $(BIN_DIR)/browser.note.o
|
||||
$(LD) $(LDFLAGS) $^ -o $@
|
||||
|
||||
$(BIN_DIR)/screenshot.elf: $(LIBC_OBJS) $(BIN_DIR)/screenshot.o $(BIN_DIR)/stb_image.o
|
||||
$(BIN_DIR)/screenshot.elf: $(LIBC_OBJS) $(BIN_DIR)/screenshot.o $(BIN_DIR)/stb_image.o $(BIN_DIR)/screenshot.note.o
|
||||
$(LD) $(LDFLAGS) $^ -o $@
|
||||
|
||||
$(BIN_DIR)/%.o: games/doom/%.c | $(BIN_DIR)
|
||||
$(CC) $(CFLAGS) -Wno-error -DBOREDOS -Igames/doom -c $< -o $@
|
||||
|
||||
$(BIN_DIR)/doom.elf: $(LIBC_OBJS) $(DOOM_OBJS) $(BIN_DIR)/stb_image.o
|
||||
$(BIN_DIR)/doom.elf: $(LIBC_OBJS) $(DOOM_OBJS) $(BIN_DIR)/stb_image.o $(BIN_DIR)/doom.note.o
|
||||
$(LD) $(LDFLAGS) $^ -o $@
|
||||
|
||||
$(BIN_DIR)/%.elf: $(LIBC_OBJS) $(BIN_DIR)/%.o
|
||||
$(BIN_DIR)/%.elf: $(LIBC_OBJS) $(BIN_DIR)/%.o $(BIN_DIR)/%.note.o
|
||||
$(LD) $(LDFLAGS) $^ -o $@
|
||||
|
||||
# Lua 5.5.0 - compiled as a single translation unit
|
||||
$(BIN_DIR)/lua_onelua.o: $(LUA_DIR)/boredos_onelua.c | $(BIN_DIR)
|
||||
$(CC) $(LUA_CFLAGS) -c $< -o $@
|
||||
|
||||
$(BIN_DIR)/lua.elf: $(LIBC_OBJS) $(BIN_DIR)/lua_onelua.o
|
||||
$(BIN_DIR)/lua.elf: $(LIBC_OBJS) $(BIN_DIR)/lua_onelua.o $(BIN_DIR)/lua.note.o
|
||||
$(LD) $(LDFLAGS) $^ -o $@
|
||||
|
||||
clean:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// This header needs to maintain in any file it is present in, as per the GPL license terms.
|
||||
// BOREDOS_APP_DESC: Show command and system help.
|
||||
#include <stdlib.h>
|
||||
#include <syscall.h>
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// This header needs to maintain in any file it is present in, as per the GPL license terms.
|
||||
// BOREDOS_APP_DESC: Manual pages CLI utility
|
||||
#include <stdlib.h>
|
||||
#include <syscall.h>
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
** Based on the official onelua.c, adapted for BoredOS freestanding environment.
|
||||
*/
|
||||
|
||||
// BOREDOS_APP_DESC: Lua REPL and scripting runtime.
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// BOREDOS_APP_DESC: 2048 number puzzle game.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/applications-games.png
|
||||
#include "libc/syscall.h"
|
||||
#include "libc/libui.h"
|
||||
#include "libc/stdlib.h"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// BOREDOS_APP_DESC: DOOM game runtime.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/doom-2016.png;/Library/images/icons/colloid/applications-games.png
|
||||
#include "doomgeneric.h"
|
||||
#include "doomkeys.h"
|
||||
#include <libui.h>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// This header needs to maintain in any file it is present in, as per the GPL license terms.
|
||||
// BOREDOS_APP_DESC: Minesweeper puzzle game.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/gnome-mines.png;/Library/images/icons/colloid/applications-games.png
|
||||
#include "libc/syscall.h"
|
||||
#include "libc/libui.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// BOREDOS_APP_DESC: Classic snake arcade game.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/cartridges.png
|
||||
#include "libc/syscall.h"
|
||||
#include "libc/libui.h"
|
||||
#include "libc/stdlib.h"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// This header needs to maintain in any file it is present in, as per the GPL license terms.
|
||||
// BOREDOS_APP_DESC: Shows BoredOS information.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/indicator-cpufreq.png
|
||||
#include "syscall.h"
|
||||
#include "libc/libui.h"
|
||||
#include "libc/stdlib.h"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// This header needs to maintain in any file it is present in, as per the GPL license terms.
|
||||
// BOREDOS_APP_DESC: Document and PDF viewer/editor.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/libreoffice-writer.png;/Library/images/icons/colloid/text-editor.png
|
||||
#include "libc/syscall.h"
|
||||
#include "libc/libui.h"
|
||||
#include "libc/stdlib.h"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// BOREDOS_APP_DESC: Web browser for internet pages.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/web-browser.png
|
||||
#include "libc/syscall.h"
|
||||
#include "libc/libui.h"
|
||||
#include "stb_image.h"
|
||||
@@ -2134,4 +2136,4 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// This header needs to maintain in any file it is present in, as per the GPL license terms.
|
||||
// BOREDOS_APP_DESC: Graphical calculator utility.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/calc.png
|
||||
#include "syscall.h"
|
||||
#include "libui.h"
|
||||
#include "../../wm/libwidget.h"
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// This header needs to maintain in any file it is present in, as per the GPL license terms.
|
||||
|
||||
// BOREDOS_APP_DESC: 3/2D Graphing and plotting utility.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/se.sjoerd.Graphs.png;/Library/images/icons/colloid/app-icon-preview.png
|
||||
#include "syscall.h"
|
||||
#include "libui.h"
|
||||
#include "../../wm/libwidget.h"
|
||||
@@ -1765,4 +1767,4 @@ int main(void) {
|
||||
free(graph_fb);
|
||||
sys_exit(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// This header needs to maintain in any file it is present in, as per the GPL license terms.
|
||||
// BOREDOS_APP_DESC: Markdown document viewer.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/text-editor.png
|
||||
#include "libc/syscall.h"
|
||||
#include "libc/libui.h"
|
||||
#include "libc/stdlib.h"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// This header needs to maintain in any file it is present in, as per the GPL license terms.
|
||||
// BOREDOS_APP_DESC: Jotting down notes and thoughts.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/text-editor.png
|
||||
#include "libc/syscall.h"
|
||||
#include "libc/libui.h"
|
||||
#include "libc/stdlib.h"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// This header needs to maintain in any file it is present in, as per the GPL license terms.
|
||||
// BOREDOS_APP_DESC: Simple drawing and paint app.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/gnome-paint.png
|
||||
#include "libc/syscall.h"
|
||||
#include "libc/libui.h"
|
||||
#include "libc/stdlib.h"
|
||||
@@ -247,4 +249,4 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// BOREDOS_APP_DESC: Screen capture utility.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/accessories-screenshot.png
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "stdlib.h"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// This header needs to maintain in any file it is present in, as per the GPL license terms.
|
||||
// BOREDOS_APP_DESC: System configuration and preferences.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/preferences-system.png;/Library/images/icons/colloid/preferences-system-services.png
|
||||
#include "libc/syscall.h"
|
||||
#include "libc/libui.h"
|
||||
#include "libc/stdlib.h"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// BOREDOS_APP_DESC: Task and process manager.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/utilities-system-monitor.png
|
||||
#include "syscall.h"
|
||||
#include "libui.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// This header needs to maintain in any file it is present in, as per the GPL license terms.
|
||||
// BOREDOS_APP_DESC: BoredOS Terminal shell.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/xterm.png;/Library/images/icons/colloid/utilities-terminal_su.png
|
||||
#include <stdlib.h>
|
||||
#include <syscall.h>
|
||||
#include "libc/libui.h"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// This header needs to maintain in any file it is present in, as per the GPL license terms.
|
||||
// BOREDOS_APP_DESC: Image viewer utility.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/preferences-desktop-wallpaper.png;/Library/images/icons/colloid/org.gnome.Loupe.png
|
||||
#include "stb_image.h"
|
||||
#include "libc/syscall.h"
|
||||
#include "libc/libui.h"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||
// This header needs to maintain in any file it is present in, as per the GPL license terms.
|
||||
// BOREDOS_APP_DESC: Clock and time utility.
|
||||
// BOREDOS_APP_ICONS: /Library/images/icons/colloid/preferences-system-time.png
|
||||
#include "syscall.h"
|
||||
#include "libui.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
Reference in New Issue
Block a user