Browse Source

new build system and source file hierarchy

master
Lephenixnoir 7 months ago
parent
commit
ad9f92873b
Signed by: Lephenixnoir GPG Key ID: 1BBA026E13FC0495
  1. 3
      .gitignore
  2. 130
      CMakeLists.txt
  3. 28
      cmake/toolchain-sh.cmake
  4. 0
      src/libc/setjmp/target/sh-generic/longjmp.S
  5. 0
      src/libc/setjmp/target/sh-generic/setjmp.S
  6. 0
      src/libc/signal/target/vhex-sh/kill.S
  7. 0
      src/libc/signal/target/vhex-sh/signal.S
  8. 0
      src/libc/stdio/dprintf.c
  9. 0
      src/libc/stdio/internal/printf.h
  10. 3
      src/libc/stdio/internal/printf_actions.c
  11. 3
      src/libc/stdio/internal/printf_common.c
  12. 3
      src/libc/stdio/internal/printf_options.c
  13. 0
      src/libc/stdio/printf.c
  14. 0
      src/libc/stdio/putc.c
  15. 0
      src/libc/stdio/puts.c
  16. 0
      src/libc/stdio/snprintf.c
  17. 0
      src/libc/stdio/sprintf.c
  18. 3
      src/libc/stdio/vdprintf.c
  19. 3
      src/libc/stdio/vsnprintf.c
  20. 0
      src/libc/stdio/vsprintf.c
  21. 0
      src/libc/stdlib/calloc.c
  22. 0
      src/libc/stdlib/reallocarray.c
  23. 0
      src/libc/stdlib/target/vhex-sh/free.S
  24. 0
      src/libc/stdlib/target/vhex-sh/malloc.S
  25. 0
      src/libc/stdlib/target/vhex-sh/realloc.S
  26. 0
      src/libc/string/memcpy.c
  27. 0
      src/libc/string/memset.c
  28. 0
      src/libc/string/strcat.c
  29. 0
      src/libc/string/strchr.c
  30. 0
      src/libc/string/strcmp.c
  31. 0
      src/libc/string/strcpy.c
  32. 0
      src/libc/string/strdup.c
  33. 0
      src/libc/string/strlen.c
  34. 0
      src/libc/threads/atomic.S
  35. 0
      src/libc/threads/mutex.c
  36. 0
      src/posix/fcntl/target/vhex-sh/open.S
  37. 0
      src/posix/sys/wait/target/vhex-sh/wait.S
  38. 0
      src/posix/sys/wait/target/vhex-sh/waitpid.S
  39. 0
      src/posix/unistd/target/casiowin-fx/close.S
  40. 0
      src/posix/unistd/target/vhex-sh/close.S
  41. 0
      src/posix/unistd/target/vhex-sh/fork_execve.S
  42. 0
      src/posix/unistd/target/vhex-sh/getpgid.S
  43. 0
      src/posix/unistd/target/vhex-sh/getpid.S
  44. 0
      src/posix/unistd/target/vhex-sh/getppid.S
  45. 0
      src/posix/unistd/target/vhex-sh/lseek.S
  46. 0
      src/posix/unistd/target/vhex-sh/read.S
  47. 0
      src/posix/unistd/target/vhex-sh/setpgid.S
  48. 0
      src/posix/unistd/target/vhex-sh/write.S

3
.gitignore

@ -1,3 +1,4 @@
build
/build*/
*.txt
!CMakeLists.txt
script

130
CMakeLists.txt

@ -0,0 +1,130 @@
cmake_minimum_required(VERSION 3.16)
project(FxLibC VERSION 1.0.0 LANGUAGES C ASM)
# Options
# * -DFXLIBC_TARGET=<vhex-sh, vhex-x86, casiowin-fx, casiowin-cg, gint>
# * -DSHARED
option(SHARED "Build a shared library")
option(STANDARD_NAMESPACE "Use libc.a and put headers in global include folder")
set(TARGET_FOLDERS ${FXLIBC_TARGET})
if(FXLIBC_TARGET STREQUAL vhex-sh)
list(APPEND TARGET_FOLDERS vhex-generic sh-generic)
set(FXLIBC_ARCH sh)
add_definitions(-D__SUPPORT_VHEX_KERNEL)
endif()
if(FXLIB_TARGET STREQUAL vhex-x86)
list(APPEND TARGET_FOLDERS vhex-generic x86-generic)
set(FXLIBC_ARCH x86)
add_definitions(-D__SUPPORT_VHEX_KERNEL)
endif()
if(FXLIBC_TARGET STREQUAL casiowin-fx)
list(APPEND TARGET_FOLDERS sh-generic)
set(FXLIBC_ARCH sh)
add_definitions(-D__SUPPORT_CASIOWIN_FX9860G)
endif()
if(FXLIBC_TARGET STREQUAL casiowin-cg)
list(APPEND TARGET_FOLDERS sh-generic)
set(FXLIBC_ARCH sh)
add_definitions(-D__SUPPORT_CASIOWIN_FXCG50)
endif()
if(FXLIBC_TARGET STREQUAL gint)
list(APPEND TARGET_FOLDERS sh-generic)
set(FXLIBC_ARCH sh)
add_definitions(-D__SUPPORT_GINT)
endif()
# TODO: Preprocessor definitions for configuration
# configure_file()
# libc.{a,so} libfxlibc.{a,so}
add_compile_options(-Wall -Wextra -std=c11 -ffreestanding -Os)
if(FXLIBC_ARCH STREQUAL sh)
add_compile_options(
"$<$<COMPILE_LANGUAGE:C>:-m3;-mb>"
"$<$<COMPILE_LANGUAGE:ASM>:-m4-nofpu;-mb;-Wa,--dsp>")
endif()
# Building
set(SOURCES
src/libc/stdio/vsnprintf.c
src/libc/stdio/sprintf.c
src/libc/stdio/dprintf.c
src/libc/stdio/snprintf.c
src/libc/stdio/puts.c
src/libc/stdio/vsprintf.c
src/libc/stdio/putc.c
src/libc/stdio/internal/printf_actions.c
src/libc/stdio/internal/printf_options.c
src/libc/stdio/internal/printf_common.c
src/libc/stdio/internal/printf.h
src/libc/stdio/vdprintf.c
src/libc/stdio/printf.c
src/libc/stdlib/calloc.c
src/libc/stdlib/reallocarray.c
src/libc/string/strchr.c
src/libc/string/strcpy.c
src/libc/string/memcpy.c
src/libc/string/strcat.c
src/libc/string/memset.c
src/libc/string/strcmp.c
src/libc/string/strdup.c
src/libc/string/strlen.c)
if(vhex-generic IN_LIST TARGET_FOLDERS)
# TODO
endif()
if(vhex-sh IN_LIST TARGET_FOLDERS)
list(APPEND SOURCES
src/libc/signal/target/vhex-sh/kill.S
src/libc/signal/target/vhex-sh/signal.S
src/libc/stdlib/target/vhex-sh/free.S
src/libc/stdlib/target/vhex-sh/malloc.S
src/libc/stdlib/target/vhex-sh/realloc.S
src/posix/fcntl/target/vhex-sh/open.S
src/posix/sys/wait/target/vhex-sh/wait.S
src/posix/sys/wait/target/vhex-sh/waitpid.S
src/posix/unistd/target/vhex-sh/read.S
src/posix/unistd/target/vhex-sh/getppid.S
src/posix/unistd/target/vhex-sh/close.S
src/posix/unistd/target/vhex-sh/fork_execve.S
src/posix/unistd/target/vhex-sh/lseek.S
src/posix/unistd/target/vhex-sh/getpid.S
src/posix/unistd/target/vhex-sh/getpgid.S
src/posix/unistd/target/vhex-sh/setpgid.S
src/posix/unistd/target/vhex-sh/write.S)
endif()
if(sh-generic IN_LIST TARGET_FOLDERS)
list(APPEND SOURCES
src/libc/setjmp/target/sh-generic/setjmp.S
src/libc/setjmp/target/sh-generic/longjmp.S)
endif()
if(casiowin-fx IN_LIST TARGET_FOLDERS)
list(APPEND SOURCES
src/posix/unistd/target/casiowin-fx/close.S)
endif()
# TODO: All targets
add_library(fxlibc ${SOURCES})
target_include_directories(fxlibc PRIVATE include/)
# Install
# TODO: Install in compiler vs. in another folder
install(TARGETS fxlibc DESTINATION lib/)

28
cmake/toolchain-sh.cmake

@ -0,0 +1,28 @@
# fxSDK toolchain file for Casio graphing calculators
# Target triplet: sh-elf (custom sh3eb-elf supporting sh3 and sh4-nofpu)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR sh)
set(CMAKE_C_COMPILER sh-elf-gcc)
set(CMAKE_CXX_COMPILER sh-elf-g++)
set(CMAKE_C_FLAGS_INIT "")
set(CMAKE_CXX_FLAGS_INIT "")
add_compile_options(-nostdlib)
add_link_options(-nostdlib)
link_libraries(-lgcc)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
# Determine compiler install path
execute_process(
COMMAND ${CMAKE_C_COMPILER} --print-file-name=.
OUTPUT_VARIABLE FXSDK_COMPILER_INSTALL
OUTPUT_STRIP_TRAILING_WHITESPACE
)

0
src/setjmp/longjmp.S → src/libc/setjmp/target/sh-generic/longjmp.S

0
src/setjmp/setjmp.S → src/libc/setjmp/target/sh-generic/setjmp.S

0
src/signal/arch/vhex/kill.S → src/libc/signal/target/vhex-sh/kill.S

0
src/signal/arch/vhex/signal.S → src/libc/signal/target/vhex-sh/signal.S

0
src/stdio/dprintf.c → src/libc/stdio/dprintf.c

0
src/stdio/internal/printf.h → src/libc/stdio/internal/printf.h

3
src/stdio/internal/printf_actions.c → src/libc/stdio/internal/printf_actions.c

@ -1,8 +1,7 @@
#include <fxlibc/stdio.h>
// internal depency
// TODO: update path detection
#include "../src/stdio/internal/printf.h"
#include "printf.h"
// Define all actions
static void action_str(struct printf_opt *op, char n);

3
src/stdio/internal/printf_common.c → src/libc/stdio/internal/printf_common.c

@ -1,8 +1,7 @@
#include <fxlibc/stdio.h>
// internal depency
// TODO: update path detection
#include "../src/stdio/internal/printf.h"
#include "printf.h"
//TODO: precision handling
int printf_common(struct printf_opt *opt, const char *restrict format)

3
src/stdio/internal/printf_options.c → src/libc/stdio/internal/printf_options.c

@ -1,8 +1,7 @@
#include <fxlibc/stdio.h>
// internal depency
// TODO: update path detection
#include "../src/stdio/internal/printf.h"
#include "printf.h"
static int get_flags(struct printf_opt *opt, const char *restrict format)
{

0
src/stdio/printf.c → src/libc/stdio/printf.c

0
src/stdio/putc.c → src/libc/stdio/putc.c

0
src/stdio/puts.c → src/libc/stdio/puts.c

0
src/stdio/snprintf.c → src/libc/stdio/snprintf.c

0
src/stdio/sprintf.c → src/libc/stdio/sprintf.c

3
src/stdio/vdprintf.c → src/libc/stdio/vdprintf.c

@ -2,8 +2,7 @@
#include <fxlibc/unistd.h>
// internal depency
// TODO: update path detection
#include "../src/stdio/internal/printf.h"
#include "internal/printf.h"
// FIXME:
// if the writte syscall do not return the same

3
src/stdio/vsnprintf.c → src/libc/stdio/vsnprintf.c

@ -1,8 +1,7 @@
#include <fxlibc/stdio.h>
// internal depency
// TODO: update path detection
#include "../src/stdio/internal/printf.h"
#include "internal/printf.h"
static void disp_char(struct printf_opt *opt, char n)
{

0
src/stdio/vsprintf.c → src/libc/stdio/vsprintf.c

0
src/stdlib/calloc.c → src/libc/stdlib/calloc.c

0
src/stdlib/reallocarray.c → src/libc/stdlib/reallocarray.c

0
src/stdlib/arch/vhex/free.S → src/libc/stdlib/target/vhex-sh/free.S

0
src/stdlib/arch/vhex/malloc.S → src/libc/stdlib/target/vhex-sh/malloc.S

0
src/stdlib/arch/vhex/realloc.S → src/libc/stdlib/target/vhex-sh/realloc.S

0
src/string/memcpy.c → src/libc/string/memcpy.c

0
src/string/memset.c → src/libc/string/memset.c

0
src/string/strcat.c → src/libc/string/strcat.c

0
src/string/strchr.c → src/libc/string/strchr.c

0
src/string/strcmp.c → src/libc/string/strcmp.c

0
src/string/strcpy.c → src/libc/string/strcpy.c

0
src/string/strdup.c → src/libc/string/strdup.c

0
src/string/strlen.c → src/libc/string/strlen.c

0
src/threads/atomic.S → src/libc/threads/atomic.S

0
src/threads/mutex.c → src/libc/threads/mutex.c

0
src/fcntl/arch/vhex/open.S → src/posix/fcntl/target/vhex-sh/open.S

0
src/sys/wait/arch/vhex/wait.S → src/posix/sys/wait/target/vhex-sh/wait.S

0
src/sys/wait/arch/vhex/waitpid.S → src/posix/sys/wait/target/vhex-sh/waitpid.S

0
src/unistd/arch/fx9860g/close.S → src/posix/unistd/target/casiowin-fx/close.S

0
src/unistd/arch/vhex/close.S → src/posix/unistd/target/vhex-sh/close.S

0
src/unistd/arch/vhex/fork_execve.S → src/posix/unistd/target/vhex-sh/fork_execve.S

0
src/unistd/arch/vhex/getpgid.S → src/posix/unistd/target/vhex-sh/getpgid.S

0
src/unistd/arch/vhex/getpid.S → src/posix/unistd/target/vhex-sh/getpid.S

0
src/unistd/arch/vhex/getppid.S → src/posix/unistd/target/vhex-sh/getppid.S

0
src/unistd/arch/vhex/lseek.S → src/posix/unistd/target/vhex-sh/lseek.S

0
src/unistd/arch/vhex/read.S → src/posix/unistd/target/vhex-sh/read.S

0
src/unistd/arch/vhex/setpgid.S → src/posix/unistd/target/vhex-sh/setpgid.S

0
src/unistd/arch/vhex/write.S → src/posix/unistd/target/vhex-sh/write.S

Loading…
Cancel
Save