diff --git a/.gitignore b/.gitignore index b1d6780..a6f793c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,12 @@ build/ +release/ +debug/ lib/ *.a *.o *.d *.elf +*.bz2 docs/html/ .vs/ CMakeSettings.json diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29..0000000 diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 27b298d..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -set(WUT_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") -set(ENV{WUT_ROOT} "${WUT_ROOT}") -set(CMAKE_TOOLCHAIN_FILE "${WUT_ROOT}/share/wut.toolchain.cmake") - -project(wut) -option(WUT_BUILD_DOCS "Build documentation" OFF) - -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/lib") -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/lib") - -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/lib") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/lib") - -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin") -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/bin") - -if(WUT_BUILD_DOCS) - add_subdirectory(docs) -endif() - -find_program(WUT_RPLIMPORTGEN NAMES rplimportgen PATHS "${DEVKITPRO}/tools/bin") -if(NOT WUT_RPLIMPORTGEN) - message(FATAL_ERROR "Could not find rplimportgen.") -endif() - -add_subdirectory(cafe) -add_subdirectory(libraries) - -install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/" - DESTINATION "${CMAKE_INSTALL_PREFIX}/include" - FILES_MATCHING PATTERN "*.h*") - -install(DIRECTORY "${CMAKE_SOURCE_DIR}/share/" - DESTINATION "${CMAKE_INSTALL_PREFIX}/share") diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..144a239 --- /dev/null +++ b/Makefile @@ -0,0 +1,164 @@ + +TOPDIR ?= $(CURDIR) +include $(TOPDIR)/share/wut_rules + +export WUT_MAJOR := 1 +export WUT_MINOR := 0 +export WUT_PATCH := 0 + +VERSION := $(WUT_MAJOR).$(WUT_MINOR).$(WUT_PATCH) + +#--------------------------------------------------------------------------------- +# TARGET is the name of the output +# BUILD is the directory where object files & intermediate files will be placed +# SOURCES is a list of directories containing source code +# DATA is a list of directories containing data files +# INCLUDES is a list of directories containing header files +#--------------------------------------------------------------------------------- +TARGET := wut +#BUILD := build +SOURCES := cafe \ + libraries/wutcrt \ + libraries/wutnewlib \ + libraries/wutstdc++ \ + libraries/wutmalloc \ + libraries/wutdevoptab \ + libraries/libwhb/src \ + libraries/libgfd/src \ + libraries/nn_swkbd +DATA := data +INCLUDES := include \ + libraries/libwhb/include \ + libraries/libgfd/include \ + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- +CFLAGS := -g -Wall -Werror -save-temps \ + -ffunction-sections -fdata-sections \ + $(MACHDEP) \ + $(BUILD_CFLAGS) + +CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ + +CXXFLAGS := $(CFLAGS) -std=gnu++17 + +ASFLAGS := -g $(MACHDEP) + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := + +#--------------------------------------------------------------------------------- +# no real need to edit anything past this point unless you need to add additional +# rules for different file extensions +#--------------------------------------------------------------------------------- +ifneq ($(BUILD),$(notdir $(CURDIR))) +#--------------------------------------------------------------------------------- + +export TOPDIR := $(CURDIR) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +DEFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.def))) +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) +#--------------------------------------------------------------------------------- + export LD := $(CC) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- + export LD := $(CXX) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) +export OFILES_SRC := $(DEFFILES:.def=.o) $(SFILES:.s=.o) $(CFILES:.c=.o) $(CPPFILES:.cpp=.o) +export OFILES := $(OFILES_BIN) $(OFILES_SRC) +export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I. + +.PHONY: all dist-bin dist-src dist install clean + +#--------------------------------------------------------------------------------- +all: lib/libwut.a lib/libwutd.a + +dist-bin: all + @tar --exclude=*~ -cjf wut-$(VERSION).tar.bz2 include lib share -C libraries/libwhb include -C ../libgfd include + +dist-src: + @tar --exclude=*~ -cjf wut-src-$(VERSION).tar.bz2 cafe include libraries share Makefile + +dist: dist-src dist-bin + +install: dist-bin + mkdir -p $(DESTDIR)$(DEVKITPRO)/wut + bzip2 -cd wut-$(VERSION).tar.bz2 | tar -xf - -C $(DESTDIR)$(DEVKITPRO)/wut + +lib: + @[ -d $@ ] || mkdir -p $@ + +release: + @[ -d $@ ] || mkdir -p $@ + +debug: + @[ -d $@ ] || mkdir -p $@ + +lib/libwut.a : lib release $(SOURCES) $(INCLUDES) + @$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \ + BUILD_CFLAGS="-DNDEBUG=1 -O2" \ + DEPSDIR=$(CURDIR)/release \ + --no-print-directory -C release \ + -f $(CURDIR)/Makefile + +lib/libwutd.a : lib debug $(SOURCES) $(INCLUDES) + @$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \ + BUILD_CFLAGS="-DDEBUG=1 -Og" \ + DEPSDIR=$(CURDIR)/debug \ + --no-print-directory -C debug \ + -f $(CURDIR)/Makefile + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -rf release debug lib + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT) : $(OFILES) + +$(OFILES_SRC) : $(HFILES) + +#--------------------------------------------------------------------------------- +%_bin.h %.bin.o : %.bin +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------------- + diff --git a/cafe/CMakeLists.txt b/cafe/CMakeLists.txt deleted file mode 100644 index bf4b0bf..0000000 --- a/cafe/CMakeLists.txt +++ /dev/null @@ -1,87 +0,0 @@ -cmake_minimum_required(VERSION 3.2) - -# Load up the in-tree toolchain -set(WUT_ROOT "{CMAKE_CURRENT_SOURCE_DIR}/.." CACHE STRING "") -set(WUT_RPLIMPORTGEN "" CACHE STRING "") -set(ENV{WUT_ROOT} ${WUT_ROOT}) -set(CMAKE_TOOLCHAIN_FILE $ENV{WUT_ROOT}/share/wut.toolchain.cmake) - -project(cafe C CXX) -enable_language(ASM) - -macro(add_cafe_library target) - add_custom_command( - OUTPUT ${target}.s - COMMAND ${WUT_RPLIMPORTGEN} ${CMAKE_CURRENT_SOURCE_DIR}/${target}.def ${target}.s - DEPENDS ${target}.def) - - add_library(${target} STATIC ${target}.s) - install(TARGETS ${target} ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") -endmacro() - -add_cafe_library(avm) -add_cafe_library(camera) -add_cafe_library(coreinit) -add_cafe_library(dc) -add_cafe_library(dmae) -add_cafe_library(drmapp) -add_cafe_library(erreula) -add_cafe_library(gx2) -add_cafe_library(h264) -add_cafe_library(lzma920) -add_cafe_library(mic) -add_cafe_library(nfc) -add_cafe_library(nio_prof) -add_cafe_library(nlibcurl) -add_cafe_library(nlibnss) -add_cafe_library(nlibnss2) -add_cafe_library(nn_ac) -add_cafe_library(nn_acp) -add_cafe_library(nn_act) -add_cafe_library(nn_aoc) -add_cafe_library(nn_boss) -add_cafe_library(nn_ccr) -add_cafe_library(nn_cmpt) -add_cafe_library(nn_dlp) -add_cafe_library(nn_ec) -add_cafe_library(nn_fp) -add_cafe_library(nn_hai) -add_cafe_library(nn_hpad) -add_cafe_library(nn_idbe) -add_cafe_library(nn_ndm) -add_cafe_library(nn_nets2) -add_cafe_library(nn_nfp) -add_cafe_library(nn_nim) -add_cafe_library(nn_olv) -add_cafe_library(nn_pdm) -add_cafe_library(nn_save) -add_cafe_library(nn_sl) -add_cafe_library(nn_spm) -add_cafe_library(nn_temp) -add_cafe_library(nn_uds) -add_cafe_library(nn_vctl) -add_cafe_library(nsysccr) -add_cafe_library(nsyshid) -add_cafe_library(nsyskbd) -add_cafe_library(nsysnet) -add_cafe_library(nsysuhs) -add_cafe_library(nsysuvd) -add_cafe_library(ntag) -add_cafe_library(padscore) -add_cafe_library(proc_ui) -add_cafe_library(snd_core) -add_cafe_library(snd_user) -add_cafe_library(sndcore2) -add_cafe_library(snduser2) -add_cafe_library(swkbd) -add_cafe_library(sysapp) -add_cafe_library(tcl) -add_cafe_library(tve) -add_cafe_library(uac) -add_cafe_library(uac_rpl) -add_cafe_library(usb_mic) -add_cafe_library(uvc) -add_cafe_library(uvd) -add_cafe_library(vpad) -add_cafe_library(vpadbase) -add_cafe_library(zlib125) diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt deleted file mode 100644 index 4e7c66f..0000000 --- a/libraries/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 3.2) - -# Load up the in-tree toolchain -set(WUT_ROOT "{CMAKE_CURRENT_SOURCE_DIR}/.." CACHE STRING "") -set(ENV{WUT_ROOT} ${WUT_ROOT}) -set(CMAKE_TOOLCHAIN_FILE $ENV{WUT_ROOT}/share/wut.toolchain.cmake) - -project(libraries C) - -add_definitions(-Wall -Werror) -add_subdirectory(libgfd) -add_subdirectory(libwhb) -add_subdirectory(nn_swkbd) -add_subdirectory(wutcrt) -add_subdirectory(wutdevoptab) -add_subdirectory(wutmalloc) -add_subdirectory(wutnewlib) -add_subdirectory(wutstdc++) diff --git a/libraries/libgfd/CMakeLists.txt b/libraries/libgfd/CMakeLists.txt deleted file mode 100644 index d031a82..0000000 --- a/libraries/libgfd/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(libgfd) - -add_library(gfd STATIC - src/gfd.c - include/gfd.h) - -target_include_directories(gfd PRIVATE "../../include") -target_include_directories(gfd PUBLIC "include") - -install(TARGETS gfd - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") -install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ - DESTINATION "${CMAKE_INSTALL_PREFIX}/include" - FILES_MATCHING PATTERN "*.h*") diff --git a/libraries/libwhb/CMakeLists.txt b/libraries/libwhb/CMakeLists.txt deleted file mode 100644 index 31d8543..0000000 --- a/libraries/libwhb/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(libwhb) - -add_library(whb STATIC - src/commandserver.c - src/console.c - src/crash.c - src/file.c - src/gfx.c - src/gfx_heap.c - src/gfx_heap.h - src/gfx_shader.c - src/gfx_texture.c - src/libmanager.c - src/log.c - src/log_cafe.c - src/log_udp.c - src/proc.c - src/sdcard.c - include/whb/align.h - include/whb/commandserver.h - include/whb/crash.h - include/whb/file.h - include/whb/gfx.h - include/whb/libmanager.h - include/whb/log_cafe.h - include/whb/log_console.h - include/whb/log.h - include/whb/log_udp.h - include/whb/proc.h - include/whb/sdcard.h) - -target_include_directories(whb PRIVATE "../../include") -target_include_directories(whb PRIVATE "../libgfd/include") -target_include_directories(whb PUBLIC "include") - -install(TARGETS whb - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") -install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ - DESTINATION "${CMAKE_INSTALL_PREFIX}/include" - FILES_MATCHING PATTERN "*.h*") - diff --git a/libraries/nn_swkbd/CMakeLists.txt b/libraries/nn_swkbd/CMakeLists.txt deleted file mode 100644 index 702c4de..0000000 --- a/libraries/nn_swkbd/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(nn_swkbd CXX) - -add_library(nn_swkbd - nn_swkbd.cpp) - -target_include_directories(nn_swkbd - PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include" "${WUT_ROOT}/include") - -install(TARGETS nn_swkbd - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" - DESTINATION "${CMAKE_INSTALL_PREFIX}/include" - FILES_MATCHING PATTERN "*.h*") diff --git a/libraries/wutcrt/CMakeLists.txt b/libraries/wutcrt/CMakeLists.txt deleted file mode 100644 index b293b82..0000000 --- a/libraries/wutcrt/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(wutcrt C ASM) - -add_library(wutcrt - crt0_rpx.s - wut_crt.c) - -add_library(wutcrtrpl - crt0_rpl.s - wut_crt.c) - -target_include_directories(wutcrt PRIVATE "${WUT_ROOT}/include") -target_include_directories(wutcrtrpl PRIVATE "${WUT_ROOT}/include") - -install(TARGETS wutcrt wutcrtrpl - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") diff --git a/libraries/wutcrt/crt0_rpl.s b/libraries/wutcrt/crt0_rpl.s index 82ac12e..1ed6d91 100644 --- a/libraries/wutcrt/crt0_rpl.s +++ b/libraries/wutcrt/crt0_rpl.s @@ -3,8 +3,8 @@ .extern __init_wut .extern __fini_wut -.global _start -_start: +.global __rpl_start +__rpl_start: stwu 1, -0x14(1) mflr 0 stw 0, 0x18(1) diff --git a/libraries/wutcrt/crt0_rpx.s b/libraries/wutcrt/crt0_rpx.s index 319bfde..c80c669 100644 --- a/libraries/wutcrt/crt0_rpx.s +++ b/libraries/wutcrt/crt0_rpx.s @@ -3,8 +3,8 @@ .extern __init_wut .extern __fini_wut -.global _start -_start: +.global __rpx_start +__rpx_start: stwu 1, -0x14(1) mflr 0 stw 0, 0x18(1) diff --git a/libraries/wutcrt/wut_crt.c b/libraries/wutcrt/wut_crt.c index 80d8097..7eecbbf 100644 --- a/libraries/wutcrt/wut_crt.c +++ b/libraries/wutcrt/wut_crt.c @@ -1,48 +1,23 @@ -extern void __init_wut_newlib() __attribute__((weak)); -extern void __init_wut_devoptab() __attribute__((weak)); -extern void __init_wut_stdcpp() __attribute__((weak)); +void __init_wut_newlib(); +void __init_wut_stdcpp(); +void __init_wut_devoptab(); -extern void __fini_wut_devoptab() __attribute__((weak)); -extern void __fini_wut_newlib() __attribute__((weak)); -extern void __fini_wut_stdcpp() __attribute__((weak)); +void __fini_wut_newlib(); +void __fini_wut_stdcpp(); +void __fini_wut_devoptab(); -void +void __attribute__((weak)) __init_wut() { - if (__init_wut_newlib) { - __init_wut_newlib(); - } - - if (__init_wut_devoptab) { - __init_wut_devoptab(); - } - - if (__init_wut_stdcpp) { - __init_wut_stdcpp(); - } + __init_wut_newlib(); + //__init_wut_stdcpp(); + __init_wut_devoptab(); } -void +void __attribute__((weak)) __fini_wut() { - if (__fini_wut_stdcpp) { - __fini_wut_stdcpp(); - } - - if (__fini_wut_devoptab) { - __fini_wut_devoptab(); - } - - if (__fini_wut_newlib) { - __fini_wut_newlib(); - } -} - -// Forward newlib _exit to the coreinit.rpl _Exit -extern void _Exit(int status); - -void -_exit(int status) -{ - _Exit(status); + __fini_wut_devoptab(); + //__fini_wut_stdcpp(); + __fini_wut_newlib(); } diff --git a/libraries/wutdevoptab/CMakeLists.txt b/libraries/wutdevoptab/CMakeLists.txt deleted file mode 100644 index cdd1f3b..0000000 --- a/libraries/wutdevoptab/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(wutdevoptab C) - -add_library(wutdevoptab - devoptab_fs.c - devoptab_fs_chdir.c - devoptab_fs_chmod.c - devoptab_fs_close.c - devoptab_fs_dirclose.c - devoptab_fs_dirnext.c - devoptab_fs_diropen.c - devoptab_fs_dirreset.c - devoptab_fs_fchmod.c - devoptab_fs_fstat.c - devoptab_fs_fsync.c - devoptab_fs_getmtime.c - devoptab_fs_link.c - devoptab_fs_mkdir.c - devoptab_fs_open.c - devoptab_fs_read.c - devoptab_fs_rename.c - devoptab_fs_rmdir.c - devoptab_fs_seek.c - devoptab_fs_stat.c - devoptab_fs_statvfs.c - devoptab_fs_truncate.c - devoptab_fs_unlink.c - devoptab_fs_utils.c - devoptab_fs_write.c) - -target_include_directories(wutdevoptab PRIVATE "${WUT_ROOT}/include") - -install(TARGETS wutdevoptab - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") diff --git a/libraries/wutdevoptab/devoptab_fs_read.c b/libraries/wutdevoptab/devoptab_fs_read.c index 33df4ea..52e1e58 100644 --- a/libraries/wutdevoptab/devoptab_fs_read.c +++ b/libraries/wutdevoptab/devoptab_fs_read.c @@ -6,7 +6,7 @@ __wut_fs_read(struct _reent *r, char *ptr, size_t len) { - FSStatus status; + FSStatus status = 0; FSCmdBlock cmd; uint8_t *alignedReadBuffer; uint32_t bytes, bytesRead; diff --git a/libraries/wutdevoptab/devoptab_fs_write.c b/libraries/wutdevoptab/devoptab_fs_write.c index cffdb16..93b8ef2 100644 --- a/libraries/wutdevoptab/devoptab_fs_write.c +++ b/libraries/wutdevoptab/devoptab_fs_write.c @@ -6,7 +6,7 @@ __wut_fs_write(struct _reent *r, const char *ptr, size_t len) { - FSStatus status; + FSStatus status = 0; FSCmdBlock cmd; uint8_t *alignedWriteBuffer; uint32_t bytes, bytesWritten; diff --git a/libraries/wutmalloc/CMakeLists.txt b/libraries/wutmalloc/CMakeLists.txt deleted file mode 100644 index 80ff196..0000000 --- a/libraries/wutmalloc/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(wutmalloc C) - -add_library(wutmalloc - wut_malloc.c) -target_include_directories(wutmalloc PRIVATE "${WUT_ROOT}/include") - -install(TARGETS wutmalloc - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") diff --git a/libraries/wutmalloc/wut_malloc.c b/libraries/wutmalloc/wut_malloc.c index a929006..0663219 100644 --- a/libraries/wutmalloc/wut_malloc.c +++ b/libraries/wutmalloc/wut_malloc.c @@ -5,7 +5,7 @@ #include // Limit sbrk heap to 128kb -uint32_t __attribute__((weak)) __wut_heap_max_size = 128 * 1024; +uint32_t __wut_heap_max_size = 128 * 1024; void * _malloc_r(struct _reent *r, size_t size) diff --git a/libraries/wutnewlib/CMakeLists.txt b/libraries/wutnewlib/CMakeLists.txt deleted file mode 100644 index 9b011d9..0000000 --- a/libraries/wutnewlib/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(wutnewlib C) - -add_library(wutnewlib - wut_clock.c - wut_gettod_r.c - wut_lock.c - wut_malloc_lock.c - wut_nanosleep.c - wut_newlib.c - wut_sbrk.c) -target_include_directories(wutnewlib PRIVATE "${WUT_ROOT}/include") - -install(TARGETS wutnewlib - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") diff --git a/libraries/wutnewlib/wut_newlib.c b/libraries/wutnewlib/wut_newlib.c index 70fd641..d4af598 100644 --- a/libraries/wutnewlib/wut_newlib.c +++ b/libraries/wutnewlib/wut_newlib.c @@ -1,6 +1,9 @@ #include "wut_newlib.h" #include +// Forward newlib _exit to the coreinit.rpl _Exit +extern void _Exit(int status); + static void __init_wut_syscall_array() { @@ -11,7 +14,7 @@ __init_wut_syscall_array() __syscalls.lock_release = __wut_lock_release; __syscalls.malloc_lock = __wut_malloc_lock; __syscalls.malloc_unlock = __wut_malloc_unlock; - __syscalls.exit = exit; + __syscalls.exit = _Exit; __syscalls.gettod_r = __wut_gettod_r; __syscalls.clock_gettime = __wut_clock_gettime; __syscalls.clock_settime = __wut_clock_settime; diff --git a/libraries/wutstdc++/CMakeLists.txt b/libraries/wutstdc++/CMakeLists.txt deleted file mode 100644 index 7d16c48..0000000 --- a/libraries/wutstdc++/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(wutstdc++ CXX) - -add_library(wutstdc++ - wut_gthread.cc - wut_gthread_cond.cc - wut_gthread_keys.cc - wut_gthread_mutex.cc - wut_gthread_once.cc - wut_gthread_recursive_mutex.cc - wut_gthread_thread.cc - wut_stdcpp.cc) - -target_compile_definitions(wutstdc++ - PRIVATE _GLIBCXX_HAS_GTHREADS) - -target_include_directories(wutstdc++ - PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include" "${WUT_ROOT}/include") - -install(TARGETS wutstdc++ - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") -install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" - DESTINATION "${CMAKE_INSTALL_PREFIX}/include" - FILES_MATCHING PATTERN "*.h*") diff --git a/libraries/wutstdc++/wut_gthread.cc b/libraries/wutstdc++/wut_gthread.cpp similarity index 100% rename from libraries/wutstdc++/wut_gthread.cc rename to libraries/wutstdc++/wut_gthread.cpp diff --git a/libraries/wutstdc++/wut_gthread_cond.cc b/libraries/wutstdc++/wut_gthread_cond.cpp similarity index 100% rename from libraries/wutstdc++/wut_gthread_cond.cc rename to libraries/wutstdc++/wut_gthread_cond.cpp diff --git a/libraries/wutstdc++/wut_gthread_keys.cc b/libraries/wutstdc++/wut_gthread_keys.cpp similarity index 100% rename from libraries/wutstdc++/wut_gthread_keys.cc rename to libraries/wutstdc++/wut_gthread_keys.cpp diff --git a/libraries/wutstdc++/wut_gthread_mutex.cc b/libraries/wutstdc++/wut_gthread_mutex.cpp similarity index 100% rename from libraries/wutstdc++/wut_gthread_mutex.cc rename to libraries/wutstdc++/wut_gthread_mutex.cpp diff --git a/libraries/wutstdc++/wut_gthread_once.cc b/libraries/wutstdc++/wut_gthread_once.cpp similarity index 100% rename from libraries/wutstdc++/wut_gthread_once.cc rename to libraries/wutstdc++/wut_gthread_once.cpp diff --git a/libraries/wutstdc++/wut_gthread_recursive_mutex.cc b/libraries/wutstdc++/wut_gthread_recursive_mutex.cpp similarity index 100% rename from libraries/wutstdc++/wut_gthread_recursive_mutex.cc rename to libraries/wutstdc++/wut_gthread_recursive_mutex.cpp diff --git a/libraries/wutstdc++/wut_gthread_thread.cc b/libraries/wutstdc++/wut_gthread_thread.cpp similarity index 100% rename from libraries/wutstdc++/wut_gthread_thread.cc rename to libraries/wutstdc++/wut_gthread_thread.cpp diff --git a/libraries/wutstdc++/wut_stdcpp.cc b/libraries/wutstdc++/wut_stdcpp.cpp similarity index 100% rename from libraries/wutstdc++/wut_stdcpp.cc rename to libraries/wutstdc++/wut_stdcpp.cpp diff --git a/share/rpl.specs b/share/rpl.specs new file mode 100644 index 0000000..8d211a5 --- /dev/null +++ b/share/rpl.specs @@ -0,0 +1,2 @@ +*wut_entry: +--entry=__rpl_start diff --git a/share/rpx.specs b/share/rpx.specs new file mode 100644 index 0000000..9d2a1ad --- /dev/null +++ b/share/rpx.specs @@ -0,0 +1,2 @@ +*wut_entry: +--entry=__rpx_start diff --git a/share/wut.specs b/share/wut.specs new file mode 100644 index 0000000..75905bc --- /dev/null +++ b/share/wut.specs @@ -0,0 +1,4 @@ +%rename link old_link + +*link: +%(old_link) -T %:getenv(DEVKITPRO /wut/share/wut.ld) --gc-sections --emit-relocs -z nocopyreloc %(wut_entry) diff --git a/share/wut_rules b/share/wut_rules new file mode 100644 index 0000000..6e3aa48 --- /dev/null +++ b/share/wut_rules @@ -0,0 +1,52 @@ +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITPRO)),) +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitPro") +endif + +ifeq ($(strip $(DEVKITPPC)),) +$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=/devkitPro/devkitPPC") +endif + +include $(DEVKITPPC)/base_rules + +PORTLIBS := $(PORTLIBS_PATH)/wiiu $(PORTLIBS_PATH)/ppc + +export PATH := $(PORTLIBS_PATH)/wiiu/bin:$(PORTLIBS_PATH)/ppc/bin:$(PATH) + +WUT_ROOT ?= $(DEVKITPRO)/wut + +RPXSPECS := -specs=$(WUT_ROOT)/share/wut.specs -specs=$(WUT_ROOT)/share/rpx.specs +RPLSPECS := -specs=$(WUT_ROOT)/share/wut.specs -specs=$(WUT_ROOT)/share/rpl.specs + +MACHDEP = -DESPRESSO -mcpu=750 -meabi -mhard-float + +#--------------------------------------------------------------------------------- +%.rpx: %.elf + @cp $< $*.strip.elf + @$(STRIP) -g $*.strip.elf + @elf2rpl $*.strip.elf $@ + @rm $*.strip.elf + @echo built ... $(notdir $@) + +#--------------------------------------------------------------------------------- +%.rpl: %.elf + @cp $< $*.strip.elf + @$(STRIP) -g $*.strip.elf + @elf2rpl --rpl $*.strip.elf $@ + @rm $*.strip.elf + @echo built ... $(notdir $@) + +#--------------------------------------------------------------------------------- +%.elf: + @echo linking ... $(notdir $@) + @$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ + @$(NM) -CSn $@ > $(notdir $*.lst) + +#--------------------------------------------------------------------------------- +%.o: %.def + @echo $(notdir $<) + @rplimportgen $< $*.s + $(CC) -x assembler-with-cpp $(ASFLAGS) -c $*.s -o $@ $(ERROR_FILTER)