mirror of
https://github.com/Fennix-Project/Userspace.git
synced 2025-07-11 07:09:22 +00:00
Updated libc
This commit is contained in:
5
apps/base/Makefile
Normal file
5
apps/base/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
build:
|
||||
make --quiet -C echo build
|
||||
|
||||
clean:
|
||||
make -C echo clean
|
83
apps/base/echo/Makefile
Normal file
83
apps/base/echo/Makefile
Normal file
@ -0,0 +1,83 @@
|
||||
# Config file
|
||||
include ../../../../Makefile.conf
|
||||
|
||||
FILENAME = echo.elf
|
||||
|
||||
SYSROOT = --sysroot=../../../out/system/
|
||||
|
||||
CC = ../../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
|
||||
CPP = ../../../../$(COMPILER_PATH)/$(COMPILER_ARCH)g++
|
||||
LD = ../../../../$(COMPILER_PATH)/$(COMPILER_ARCH)ld
|
||||
AS = ../../../../$(COMPILER_PATH)/$(COMPILER_ARCH)as
|
||||
OBJDUMP = ../../../../$(COMPILER_PATH)/$(COMPILER_ARCH)objdump
|
||||
|
||||
GIT_COMMIT = $(shell git rev-parse HEAD)
|
||||
GIT_COMMIT_SHORT = $(shell git rev-parse --short HEAD)
|
||||
|
||||
ifeq ($(OSARCH), amd64)
|
||||
S_SOURCES = $(shell find ./ -type f -name '*.S' -not -path "./arch/i686/*" -not -path "./arch/aarch64/*")
|
||||
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./arch/i686/*" -not -path "./arch/aarch64/*")
|
||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/i686/*" -not -path "./arch/aarch64/*")
|
||||
else ifeq ($(OSARCH), i686)
|
||||
S_SOURCES = $(shell find ./ -type f -name '*.S' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
|
||||
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
|
||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/amd64/*" -not -path "./arch/aarch64/*")
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
S_SOURCES = $(shell find ./ -type f -name '*.S' -not -path "./arch/amd64/*" -not -path "./arch/i686/*")
|
||||
C_SOURCES = $(shell find ./ -type f -name '*.c' -not -path "./arch/amd64/*" -not -path "./arch/i686/*")
|
||||
CPP_SOURCES = $(shell find ./ -type f -name '*.cpp' -not -path "./arch/amd64/*" -not -path "./arch/i686/*")
|
||||
endif
|
||||
HEADERS = $(sort $(dir $(wildcard ../../../out/system/include/*)))
|
||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
||||
INCLUDE_DIR = ../../../out/system/include
|
||||
|
||||
LDFLAGS := -Wl,-Map file.map
|
||||
|
||||
WARNCFLAG = -Wall -Wextra -Wno-builtin-declaration-mismatch
|
||||
|
||||
CFLAGS := \
|
||||
-I$(INCLUDE_DIR) \
|
||||
-DGIT_COMMIT='"$(GIT_COMMIT)"' \
|
||||
-DGIT_COMMIT_SHORT='"$(GIT_COMMIT_SHORT)"'
|
||||
|
||||
ifeq ($(OSARCH), amd64)
|
||||
|
||||
CFLAGS += -march=x86-64
|
||||
|
||||
else ifeq ($(OSARCH), i686)
|
||||
|
||||
CFLAGS += -march=i686
|
||||
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
|
||||
CFLAGS += -pipe
|
||||
|
||||
endif
|
||||
|
||||
build: $(FILENAME)
|
||||
$(OBJDUMP) -d $(FILENAME) > file_dump.map
|
||||
mv $(FILENAME) ../../../out/system/$(FILENAME)
|
||||
|
||||
$(FILENAME): $(OBJ)
|
||||
$(CC) $(LDFLAGS) $(SYSROOT) $(OBJ) -o $@
|
||||
|
||||
%.o: %.c $(HEADERS)
|
||||
$(info Compiling $<)
|
||||
$(CC) $(CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
|
||||
|
||||
%.o: %.cpp $(HEADERS)
|
||||
$(info Compiling $<)
|
||||
$(CPP) $(CFLAGS) $(WARNCFLAG) -std=c++20 -fexceptions -c $< -o $@ -fno-rtti
|
||||
|
||||
%.o: %.S
|
||||
$(info Compiling $<)
|
||||
ifeq ($(OSARCH), amd64)
|
||||
$(AS) -o $@ $<
|
||||
else ifeq ($(OSARCH), i686)
|
||||
$(AS) -o $@ $<
|
||||
else ifeq ($(OSARCH), aarch64)
|
||||
$(AS) -o $@ $<
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -f *.o file.map file_dump.map $(OBJ)
|
21
apps/base/echo/echo.cpp
Normal file
21
apps/base/echo/echo.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
static inline long syscall2(int sc, long arg1, long arg2)
|
||||
{
|
||||
long ret;
|
||||
__asm__ __volatile__("syscall"
|
||||
: "=a"(ret)
|
||||
: "a"(sc), "D"(arg1), "S"(arg2)
|
||||
: "rcx", "r11", "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// TODO: Change this to use stdout
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
for (int j = 0; argv[i][j]; j++)
|
||||
syscall2(1, argv[i][j], 0);
|
||||
syscall2(1, ' ', 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user