diff --git a/.gitignore b/.gitignore index b1d6780..49e2a46 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,13 @@ build/ +release/ +debug/ lib/ *.a *.o *.d *.elf +*.rpx +*.bz2 docs/html/ .vs/ CMakeSettings.json diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29..0000000 diff --git a/.travis.yml b/.travis.yml index 1403490..8ab8076 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,15 +5,13 @@ matrix: - os: linux dist: xenial sudo: required - env: DEPLOY_FILE=wut.7z + env: DEPLOY_FILE=wut-*.tar.bz2 addons: apt: sources: - ubuntu-toolchain-r-test - sourceline: 'ppa:cginternals/backports-ppa' - packages: - - p7zip-full cache: directories: @@ -34,26 +32,19 @@ install: script: - cd "$TRAVIS_BUILD_DIR" # Build wut - - mkdir build && cd build - - cmake -DCMAKE_INSTALL_PREFIX=wut_install ../ - - make -j4 install - - export WUT_ROOT=$PWD/wut_install - - cd ../ + - make -j4 + - sudo make install # Build tests - - cd tests - - mkdir build && cd build - - cmake ../ - - make -j4 VERBOSE=TRUE - - cd ../../ + - echo Tests disabled for now +# - cd tests +# - mkdir build && cd build +# - cmake ../ +# - make -j4 VERBOSE=TRUE +# - cd ../../ # Build samples - - cd samples - - mkdir build && cd build - - cmake -DCMAKE_INSTALL_PREFIX=$WUT_ROOT/samples ../ - - make -j4 VERBOSE=TRUE install + - cd samples/make + - make -j4 - cd ../../ - # Create deploy zips - - cd $WUT_ROOT - - 7z a $DEPLOY_FILE . deploy: provider: releases diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..65e36e2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +#### wut 1.0.0-beta9 +###### Breaking changes + - coreinit's `exit` is no longer defined in ``. Please use `` instead, which pulls in newlib's exit. + - RPL import sections (`.fimport_coreinit` etc.) are now garbage-collected when using wut-tools 1.1.0 or above (required). Code relying on weak links to Cafe functions may exhibit different behaviour. + +###### Deprecations + - `WUT_ROOT` should no longer be defined in the user's environment, and will be set to `$DEVKITPRO/wut` internally. CMake lists and makefiles that use `$WUT_ROOT/share` to find `wut.mk` or `wut.toolchain.cmake` should be changed to `$DEVKITPRO/wut/share`. + +###### Other changes + - Builds refactored: wut now uses Makefiles to build itself, as well as providing a devkitPro-style `wut_rules` file - see the `samples/make` folder. The cmake samples are now in `samples/cmake`. + - A new linking feature, `__rplwrap`, was added to help deal with conflicts between newlib's and Cafe's functions. Because of this, wut 1.0.0-beta9 requires wut-tools 1.1.0 or newer. + - Using rplwrap, newlib's `exit` is now correctly chained with coreinit's - calls like `atexit` should work; whether calling `exit` or just returning from `main`. Applications using coreinit's `_Exit` are encouraged to migrate to a normal `exit` call. + + +#### wut 1.0.0-beta8 diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index d9a0bef..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,42 +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) - -if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set (CMAKE_INSTALL_PREFIX "/opt/devkitpro/wut" CACHE PATH "default install path" FORCE ) -endif() - -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/cafe/coreinit.def b/cafe/coreinit.def index bb3be89..32939ef 100644 --- a/cafe/coreinit.def +++ b/cafe/coreinit.def @@ -1210,7 +1210,6 @@ bspQuery bspRead bspShutdown bspWrite -exit //memclr //memcpy //memmove @@ -1229,6 +1228,9 @@ smdSimpleBufFree smdSimpleBufGetStatistics smdSimpleBufPoolCreate +:TEXT_WRAP +exit + :DATA MEMAllocFromDefaultHeap MEMAllocFromDefaultHeapEx diff --git a/include/coreinit/exit.h b/include/coreinit/exit.h index 51bcb98..5dc0087 100644 --- a/include/coreinit/exit.h +++ b/include/coreinit/exit.h @@ -12,7 +12,7 @@ extern "C" { #endif void -exit(int code); +RPLWRAP(exit)(int code); void _Exit(int code); diff --git a/include/wut.h b/include/wut.h index a704f41..cdbd464 100644 --- a/include/wut.h +++ b/include/wut.h @@ -8,3 +8,4 @@ #include "wut_structsize.h" #include "wut_types.h" +#include "wut_rplwrap.h" diff --git a/include/wut_rplwrap.h b/include/wut_rplwrap.h new file mode 100644 index 0000000..433903a --- /dev/null +++ b/include/wut_rplwrap.h @@ -0,0 +1,3 @@ +#pragma once + +#define RPLWRAP(func) __rplwrap_##func 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..fa15cdb 100644 --- a/libraries/wutcrt/wut_crt.c +++ b/libraries/wutcrt/wut_crt.c @@ -1,48 +1,31 @@ -extern void __init_wut_newlib() __attribute__((weak)); -extern void __init_wut_devoptab() __attribute__((weak)); +void __init_wut_malloc(); +void __init_wut_newlib(); extern void __init_wut_stdcpp() __attribute__((weak)); +void __init_wut_devoptab(); -extern void __fini_wut_devoptab() __attribute__((weak)); -extern void __fini_wut_newlib() __attribute__((weak)); +void __fini_wut_malloc(); +void __fini_wut_newlib(); extern void __fini_wut_stdcpp() __attribute__((weak)); +void __fini_wut_devoptab(); -void +void __attribute__((weak)) __init_wut() { - if (__init_wut_newlib) { - __init_wut_newlib(); - } - - if (__init_wut_devoptab) { - __init_wut_devoptab(); - } - + __init_wut_malloc(); + __init_wut_newlib(); if (__init_wut_stdcpp) { __init_wut_stdcpp(); } + __init_wut_devoptab(); } -void +void __attribute__((weak)) __fini_wut() { + __fini_wut_devoptab(); 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_newlib(); + __fini_wut_malloc(); } 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..c485721 100644 --- a/libraries/wutmalloc/wut_malloc.c +++ b/libraries/wutmalloc/wut_malloc.c @@ -3,41 +3,64 @@ #include #include #include +#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 +__init_wut_malloc(void) +{ +} + +void +__fini_wut_malloc(void) +{ +} void * _malloc_r(struct _reent *r, size_t size) { - return MEMAllocFromDefaultHeap(size); + void *ptr = MEMAllocFromDefaultHeap(size); + if (!ptr) { + r->_errno = ENOMEM; + } + return ptr; } void _free_r(struct _reent *r, void *ptr) { - MEMFreeToDefaultHeap(ptr); + if (ptr) { + MEMFreeToDefaultHeap(ptr); + } } void * _realloc_r(struct _reent *r, void *ptr, size_t size) { - void *new_ptr = _malloc_r(r, size); - if (!ptr || !new_ptr) { + void *new_ptr = MEMAllocFromDefaultHeap(size); + if (!new_ptr) { + r->_errno = ENOMEM; return new_ptr; } - memcpy(new_ptr, ptr, MEMGetSizeForMBlockExpHeap(ptr)); - _free_r(r, ptr); + if (ptr) { + size_t old_size = MEMGetSizeForMBlockExpHeap(ptr); + memcpy(new_ptr, ptr, old_size <= size ? old_size : size); + MEMFreeToDefaultHeap(ptr); + } return new_ptr; } void * _calloc_r(struct _reent *r, size_t num, size_t size) { - void *ptr = _malloc_r(r, num * size); + void *ptr = MEMAllocFromDefaultHeap(num * size); if (ptr) { memset(ptr, 0, num * size); + } else { + r->_errno = ENOMEM; } return ptr; @@ -75,13 +98,13 @@ _malloc_usable_size_r(struct _reent *r, void *ptr) void * _valloc_r(struct _reent *r, size_t size) { - return _memalign_r(r, OS_PAGE_SIZE, size); + return MEMAllocFromDefaultHeapEx(size, OS_PAGE_SIZE); } void * _pvalloc_r(struct _reent *r, size_t size) { - return _memalign_r(r, OS_PAGE_SIZE, (size + (OS_PAGE_SIZE - 1)) & ~(OS_PAGE_SIZE - 1)); + return MEMAllocFromDefaultHeapEx((size + (OS_PAGE_SIZE - 1)) & ~(OS_PAGE_SIZE - 1), OS_PAGE_SIZE); } int 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..3623229 100644 --- a/libraries/wutnewlib/wut_newlib.c +++ b/libraries/wutnewlib/wut_newlib.c @@ -4,14 +4,15 @@ static void __init_wut_syscall_array() { - __syscalls.sbrk_r = __wut_sbrk_r; + //__syscalls.sbrk_r = __wut_sbrk_r; __syscalls.lock_init = __wut_lock_init; __syscalls.lock_close = __wut_lock_close; __syscalls.lock_acquire = __wut_lock_acquire; __syscalls.lock_release = __wut_lock_release; - __syscalls.malloc_lock = __wut_malloc_lock; - __syscalls.malloc_unlock = __wut_malloc_unlock; - __syscalls.exit = exit; + //__syscalls.malloc_lock = __wut_malloc_lock; + //__syscalls.malloc_unlock = __wut_malloc_unlock; + //use coreinit's exit function + __syscalls.exit = RPLWRAP(exit); __syscalls.gettod_r = __wut_gettod_r; __syscalls.clock_gettime = __wut_clock_gettime; __syscalls.clock_settime = __wut_clock_settime; @@ -22,13 +23,13 @@ __init_wut_syscall_array() void __init_wut_newlib() { - __init_wut_sbrk_heap(); - __init_wut_malloc_lock(); + //__init_wut_sbrk_heap(); + //__init_wut_malloc_lock(); __init_wut_syscall_array(); } void __fini_wut_newlib() { - __fini_wut_sbrk_heap(); + //__fini_wut_sbrk_heap(); } 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.cc deleted file mode 100644 index f15f6df..0000000 --- a/libraries/wutstdc++/wut_stdcpp.cc +++ /dev/null @@ -1,12 +0,0 @@ -#include "wut_gthread.h" - -extern "C" void -__init_wut_stdcpp() -{ - __init_wut_gthread(); -} - -extern "C" void -__fini_wut_stdcpp() -{ -} diff --git a/libraries/wutstdc++/wut_stdcpp.cpp b/libraries/wutstdc++/wut_stdcpp.cpp new file mode 100644 index 0000000..c6dc737 --- /dev/null +++ b/libraries/wutstdc++/wut_stdcpp.cpp @@ -0,0 +1,23 @@ +#include "wut_gthread.h" + +__asm__ ( + "\t.section\t.text.__wrap___gxx_personality_v0,\"ax\",@progbits\n" + "\t.align\t2\n" + "\t.globl\t__wrap___gxx_personality_v0\n" + "\t.type\t__wrap___gxx_personality_v0, @function\n" + "__wrap___gxx_personality_v0:\n" + "\t.cfi_startproc\n" + "\tb\t__real___gxx_personality_v0\n" + "\t.cfi_endproc" +); + +extern "C" void +__init_wut_stdcpp() +{ + __init_wut_gthread(); +} + +extern "C" void +__fini_wut_stdcpp() +{ +} diff --git a/samples/CMakeLists.txt b/samples/cmake/CMakeLists.txt similarity index 74% rename from samples/CMakeLists.txt rename to samples/cmake/CMakeLists.txt index 1f6f3a9..aefae08 100644 --- a/samples/CMakeLists.txt +++ b/samples/cmake/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.2) -set(CMAKE_TOOLCHAIN_FILE $ENV{WUT_ROOT}/share/wut.toolchain.cmake) +set(CMAKE_TOOLCHAIN_FILE $ENV{DEVKITPRO}/wut/share/wut.toolchain.cmake) project(samples) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_subdirectory(curl) add_subdirectory(custom_default_heap) diff --git a/samples/content/README.txt b/samples/cmake/content/README.txt similarity index 100% rename from samples/content/README.txt rename to samples/cmake/content/README.txt diff --git a/samples/content/pos_col_shader.gsh b/samples/cmake/content/pos_col_shader.gsh similarity index 100% rename from samples/content/pos_col_shader.gsh rename to samples/cmake/content/pos_col_shader.gsh diff --git a/samples/content/pos_col_shader.psh b/samples/cmake/content/pos_col_shader.psh similarity index 100% rename from samples/content/pos_col_shader.psh rename to samples/cmake/content/pos_col_shader.psh diff --git a/samples/content/pos_col_shader.vsh b/samples/cmake/content/pos_col_shader.vsh similarity index 100% rename from samples/content/pos_col_shader.vsh rename to samples/cmake/content/pos_col_shader.vsh diff --git a/samples/curl/CMakeLists.txt b/samples/cmake/curl/CMakeLists.txt similarity index 85% rename from samples/curl/CMakeLists.txt rename to samples/cmake/curl/CMakeLists.txt index e4dd5bd..2d3b5e4 100644 --- a/samples/curl/CMakeLists.txt +++ b/samples/cmake/curl/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(curl C) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_executable(curl main.c) diff --git a/samples/curl/main.c b/samples/cmake/curl/main.c similarity index 100% rename from samples/curl/main.c rename to samples/cmake/curl/main.c diff --git a/samples/custom_default_heap/CMakeLists.txt b/samples/cmake/custom_default_heap/CMakeLists.txt similarity index 89% rename from samples/custom_default_heap/CMakeLists.txt rename to samples/cmake/custom_default_heap/CMakeLists.txt index a3de174..bf1f6bd 100644 --- a/samples/custom_default_heap/CMakeLists.txt +++ b/samples/cmake/custom_default_heap/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(custom_default_heap C) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_executable(custom_default_heap main.c) diff --git a/samples/custom_default_heap/exports.def b/samples/cmake/custom_default_heap/exports.def similarity index 100% rename from samples/custom_default_heap/exports.def rename to samples/cmake/custom_default_heap/exports.def diff --git a/samples/custom_default_heap/main.c b/samples/cmake/custom_default_heap/main.c similarity index 100% rename from samples/custom_default_heap/main.c rename to samples/cmake/custom_default_heap/main.c diff --git a/samples/gx2_triangle/CMakeLists.txt b/samples/cmake/gx2_triangle/CMakeLists.txt similarity index 86% rename from samples/gx2_triangle/CMakeLists.txt rename to samples/cmake/gx2_triangle/CMakeLists.txt index 231f3d5..fcd4114 100644 --- a/samples/gx2_triangle/CMakeLists.txt +++ b/samples/cmake/gx2_triangle/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(gx2_triangle C) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_executable(gx2_triangle main.c) diff --git a/samples/gx2_triangle/main.c b/samples/cmake/gx2_triangle/main.c similarity index 100% rename from samples/gx2_triangle/main.c rename to samples/cmake/gx2_triangle/main.c diff --git a/samples/helloworld/CMakeLists.txt b/samples/cmake/helloworld/CMakeLists.txt similarity index 85% rename from samples/helloworld/CMakeLists.txt rename to samples/cmake/helloworld/CMakeLists.txt index 7fe9844..e5a5d20 100644 --- a/samples/helloworld/CMakeLists.txt +++ b/samples/cmake/helloworld/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(helloworld C) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_executable(helloworld main.c) diff --git a/samples/helloworld/main.c b/samples/cmake/helloworld/main.c similarity index 100% rename from samples/helloworld/main.c rename to samples/cmake/helloworld/main.c diff --git a/samples/helloworld_cpp/CMakeLists.txt b/samples/cmake/helloworld_cpp/CMakeLists.txt similarity index 90% rename from samples/helloworld_cpp/CMakeLists.txt rename to samples/cmake/helloworld_cpp/CMakeLists.txt index 5c8496a..7bac5e2 100644 --- a/samples/helloworld_cpp/CMakeLists.txt +++ b/samples/cmake/helloworld_cpp/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(helloworld_cpp CXX) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_executable(helloworld_cpp main.cpp) diff --git a/samples/helloworld_cpp/main.cpp b/samples/cmake/helloworld_cpp/main.cpp similarity index 100% rename from samples/helloworld_cpp/main.cpp rename to samples/cmake/helloworld_cpp/main.cpp diff --git a/samples/my_first_rpl/CMakeLists.txt b/samples/cmake/my_first_rpl/CMakeLists.txt similarity index 85% rename from samples/my_first_rpl/CMakeLists.txt rename to samples/cmake/my_first_rpl/CMakeLists.txt index dd8e047..afcebab 100644 --- a/samples/my_first_rpl/CMakeLists.txt +++ b/samples/cmake/my_first_rpl/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(my_first_rpl C) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_executable(my_first_rpl my_first_rpl.c) diff --git a/samples/my_first_rpl/exports.def b/samples/cmake/my_first_rpl/exports.def similarity index 100% rename from samples/my_first_rpl/exports.def rename to samples/cmake/my_first_rpl/exports.def diff --git a/samples/my_first_rpl/my_first_rpl.c b/samples/cmake/my_first_rpl/my_first_rpl.c similarity index 100% rename from samples/my_first_rpl/my_first_rpl.c rename to samples/cmake/my_first_rpl/my_first_rpl.c diff --git a/samples/swkbd/CMakeLists.txt b/samples/cmake/swkbd/CMakeLists.txt similarity index 88% rename from samples/swkbd/CMakeLists.txt rename to samples/cmake/swkbd/CMakeLists.txt index 44ad754..e64457c 100644 --- a/samples/swkbd/CMakeLists.txt +++ b/samples/cmake/swkbd/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(swkbd CXX) -include("${WUT_ROOT}/share/wut.cmake" REQUIRED) +include("${DEVKITPRO}/wut/share/wut.cmake" REQUIRED) add_executable(swkbd main.cpp) diff --git a/samples/swkbd/main.cpp b/samples/cmake/swkbd/main.cpp similarity index 100% rename from samples/swkbd/main.cpp rename to samples/cmake/swkbd/main.cpp diff --git a/samples/make/Makefile b/samples/make/Makefile new file mode 100644 index 0000000..6b9495e --- /dev/null +++ b/samples/make/Makefile @@ -0,0 +1,9 @@ +MAKEFILES := $(shell find . -mindepth 2 -name Makefile) + +DATESTRING := $(shell date +%Y)$(shell date +%m)$(shell date +%d) + +all: + @for i in $(MAKEFILES); do $(MAKE) -C `dirname $$i` || exit 1; done; + +clean: + @for i in $(MAKEFILES); do $(MAKE) -C `dirname $$i` clean || exit 1; done; diff --git a/samples/make/helloworld/Makefile b/samples/make/helloworld/Makefile new file mode 100644 index 0000000..b9e3777 --- /dev/null +++ b/samples/make/helloworld/Makefile @@ -0,0 +1,135 @@ +#------------------------------------------------------------------------------- +.SUFFIXES: +#------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITPRO)),) +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") +endif + +TOPDIR ?= $(CURDIR) + +include $(DEVKITPRO)/wut/share/wut_rules + +#------------------------------------------------------------------------------- +# 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 := $(notdir $(CURDIR)) +BUILD := build +SOURCES := source +DATA := data +INCLUDES := include + +#------------------------------------------------------------------------------- +# options for code generation +#------------------------------------------------------------------------------- +CFLAGS := -g -Wall -O2 -ffunction-sections \ + $(MACHDEP) + +CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ + +CXXFLAGS := $(CFLAGS) + +ASFLAGS := -g $(ARCH) +LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) + +LIBS := -lwut + +#------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level +# containing include and lib +#------------------------------------------------------------------------------- +LIBDIRS := $(PORTLIBS) $(WUT_ROOT) + + +#------------------------------------------------------------------------------- +# 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 OUTPUT := $(CURDIR)/$(TARGET) +export TOPDIR := $(CURDIR) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +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 := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) +export OFILES := $(OFILES_BIN) $(OFILES_SRC) +export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +.PHONY: $(BUILD) clean all + +#------------------------------------------------------------------------------- +all: $(BUILD) + +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).rpx $(TARGET).elf + +#------------------------------------------------------------------------------- +else +.PHONY: all + +DEPENDS := $(OFILES:.o=.d) + +#------------------------------------------------------------------------------- +# main targets +#------------------------------------------------------------------------------- +all : $(OUTPUT).rpx + +$(OUTPUT).rpx : $(OUTPUT).elf +$(OUTPUT).elf : $(OFILES) + +$(OFILES_SRC) : $(HFILES_BIN) + +#------------------------------------------------------------------------------- +# you need a rule like this for each extension you use as binary data +#------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.bin +#------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + +-include $(DEPENDS) + +#------------------------------------------------------------------------------- +endif +#------------------------------------------------------------------------------- diff --git a/samples/make/helloworld/source/main.c b/samples/make/helloworld/source/main.c new file mode 100644 index 0000000..489fc47 --- /dev/null +++ b/samples/make/helloworld/source/main.c @@ -0,0 +1,39 @@ +#include +#include + +#include +#include +#include + +int +main(int argc, char **argv) +{ + int last_tm_sec = -1; + OSCalendarTime tm; + + WHBProcInit(); + WHBLogConsoleInit(); + WHBLogPrintf("Hello World!"); + + while(WHBProcIsRunning()) { + OSTicksToCalendarTime(OSGetTime(), &tm); + + if (tm.tm_sec != last_tm_sec) { + WHBLogPrintf("%02d/%02d/%04d %02d:%02d:%02d I'm still here.", + tm.tm_mday, tm.tm_mon, tm.tm_year, + tm.tm_hour, tm.tm_min, tm.tm_sec); + last_tm_sec = tm.tm_sec; + } + + WHBLogConsoleDraw(); + OSSleepTicks(OSMillisecondsToTicks(100)); + } + + WHBLogPrintf("Exiting... good bye."); + WHBLogConsoleDraw(); + OSSleepTicks(OSMillisecondsToTicks(1000)); + + WHBLogConsoleFree(); + WHBProcShutdown(); + return 0; +} diff --git a/samples/make/helloworld_cpp/Makefile b/samples/make/helloworld_cpp/Makefile new file mode 100644 index 0000000..b9e3777 --- /dev/null +++ b/samples/make/helloworld_cpp/Makefile @@ -0,0 +1,135 @@ +#------------------------------------------------------------------------------- +.SUFFIXES: +#------------------------------------------------------------------------------- + +ifeq ($(strip $(DEVKITPRO)),) +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") +endif + +TOPDIR ?= $(CURDIR) + +include $(DEVKITPRO)/wut/share/wut_rules + +#------------------------------------------------------------------------------- +# 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 := $(notdir $(CURDIR)) +BUILD := build +SOURCES := source +DATA := data +INCLUDES := include + +#------------------------------------------------------------------------------- +# options for code generation +#------------------------------------------------------------------------------- +CFLAGS := -g -Wall -O2 -ffunction-sections \ + $(MACHDEP) + +CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ + +CXXFLAGS := $(CFLAGS) + +ASFLAGS := -g $(ARCH) +LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) + +LIBS := -lwut + +#------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level +# containing include and lib +#------------------------------------------------------------------------------- +LIBDIRS := $(PORTLIBS) $(WUT_ROOT) + + +#------------------------------------------------------------------------------- +# 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 OUTPUT := $(CURDIR)/$(TARGET) +export TOPDIR := $(CURDIR) + +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + +export DEPSDIR := $(CURDIR)/$(BUILD) + +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +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 := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) +export OFILES := $(OFILES_BIN) $(OFILES_SRC) +export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) + +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) + +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) + +.PHONY: $(BUILD) clean all + +#------------------------------------------------------------------------------- +all: $(BUILD) + +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + +#------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(TARGET).rpx $(TARGET).elf + +#------------------------------------------------------------------------------- +else +.PHONY: all + +DEPENDS := $(OFILES:.o=.d) + +#------------------------------------------------------------------------------- +# main targets +#------------------------------------------------------------------------------- +all : $(OUTPUT).rpx + +$(OUTPUT).rpx : $(OUTPUT).elf +$(OUTPUT).elf : $(OFILES) + +$(OFILES_SRC) : $(HFILES_BIN) + +#------------------------------------------------------------------------------- +# you need a rule like this for each extension you use as binary data +#------------------------------------------------------------------------------- +%.bin.o %_bin.h : %.bin +#------------------------------------------------------------------------------- + @echo $(notdir $<) + @$(bin2o) + +-include $(DEPENDS) + +#------------------------------------------------------------------------------- +endif +#------------------------------------------------------------------------------- diff --git a/samples/make/helloworld_cpp/source/main.cpp b/samples/make/helloworld_cpp/source/main.cpp new file mode 100644 index 0000000..9938773 --- /dev/null +++ b/samples/make/helloworld_cpp/source/main.cpp @@ -0,0 +1,70 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include + +int +hello_thread() +{ + int last_tm_sec = -1; + uint32_t ip = 0; + WHBLogPrintf("Hello World from a std::thread!"); + + if (!nn::ac::GetAssignedAddress(&ip)) { + WHBLogPrintf("GetAssignedAddress failed!"); + } + + WHBLogPrintf("My IP is: %u.%u.%u.%u", + (ip >> 24) & 0xFF, + (ip >> 16) & 0xFF, + (ip >> 8) & 0xFF, + (ip >> 0) & 0xFF); + + while(WHBProcIsRunning()) { + OSCalendarTime tm; + OSTicksToCalendarTime(OSGetTime(), &tm); + + if (tm.tm_sec != last_tm_sec) { + WHBLogPrintf("%02d/%02d/%04d %02d:%02d:%02d I'm still here.", + tm.tm_mday, tm.tm_mon, tm.tm_year, + tm.tm_hour, tm.tm_min, tm.tm_sec); + last_tm_sec = tm.tm_sec; + } + + WHBLogConsoleDraw(); + OSSleepTicks(OSMillisecondsToTicks(100)); + } + + WHBLogPrintf("Exiting... good bye."); + WHBLogConsoleDraw(); + OSSleepTicks(OSMillisecondsToTicks(1000)); + return 0; +} + +int +main(int argc, char **argv) +{ + nn::ac::ConfigIdNum configId; + + nn::ac::Initialize(); + nn::ac::GetStartupId(&configId); + nn::ac::Connect(configId); + + WHBProcInit(); + WHBLogConsoleInit(); + + std::thread t(hello_thread); + t.join(); + + WHBLogConsoleFree(); + WHBProcShutdown(); + + nn::ac::Finalize(); + return 0; +} 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.ld b/share/wut.ld index e666586..391335b 100644 --- a/share/wut.ld +++ b/share/wut.ld @@ -143,83 +143,302 @@ SECTIONS } > relmem . = ORIGIN(loadmem); - .fexports ALIGN(32) : { *(.fexports) } > loadmem - .dexports ALIGN(32) : { *(.dexports) } > loadmem + .fexports ALIGN(32) : { KEEP( *(.fexports) ) } > loadmem + .dexports ALIGN(32) : { KEEP( *(.dexports) ) } > loadmem - .fimport_avm ALIGN(16) : { *(.fimport_avm) } > loadmem - .fimport_camera ALIGN(16) : { *(.fimport_camera) } > loadmem - .fimport_coreinit ALIGN(16) : { *(.fimport_coreinit) } > loadmem - .fimport_dc ALIGN(16) : { *(.fimport_dc) } > loadmem - .fimport_dmae ALIGN(16) : { *(.fimport_dmae) } > loadmem - .fimport_drmapp ALIGN(16) : { *(.fimport_drmapp) } > loadmem - .fimport_erreula ALIGN(16) : { *(.fimport_erreula) } > loadmem - .fimport_gx2 ALIGN(16) : { *(.fimport_gx2) } > loadmem - .fimport_h264 ALIGN(16) : { *(.fimport_h264) } > loadmem - .fimport_lzma920 ALIGN(16) : { *(.fimport_lzma920) } > loadmem - .fimport_mic ALIGN(16) : { *(.fimport_mic) } > loadmem - .fimport_nfc ALIGN(16) : { *(.fimport_nfc) } > loadmem - .fimport_nio_prof ALIGN(16) : { *(.fimport_nio_prof) } > loadmem - .fimport_nlibcurl ALIGN(16) : { *(.fimport_nlibcurl) } > loadmem - .fimport_nlibnss2 ALIGN(16) : { *(.fimport_nlibnss2) } > loadmem - .fimport_nlibnss ALIGN(16) : { *(.fimport_nlibnss) } > loadmem - .fimport_nn_ac ALIGN(16) : { *(.fimport_nn_ac) } > loadmem - .fimport_nn_acp ALIGN(16) : { *(.fimport_nn_acp) } > loadmem - .fimport_nn_act ALIGN(16) : { *(.fimport_nn_act) } > loadmem - .fimport_nn_aoc ALIGN(16) : { *(.fimport_nn_aoc) } > loadmem - .fimport_nn_boss ALIGN(16) : { *(.fimport_nn_boss) } > loadmem - .fimport_nn_ccr ALIGN(16) : { *(.fimport_nn_ccr) } > loadmem - .fimport_nn_cmpt ALIGN(16) : { *(.fimport_nn_cmpt) } > loadmem - .fimport_nn_dlp ALIGN(16) : { *(.fimport_nn_dlp) } > loadmem - .fimport_nn_ec ALIGN(16) : { *(.fimport_nn_ec) } > loadmem - .fimport_nn_fp ALIGN(16) : { *(.fimport_nn_fp) } > loadmem - .fimport_nn_hai ALIGN(16) : { *(.fimport_nn_hai) } > loadmem - .fimport_nn_hpad ALIGN(16) : { *(.fimport_nn_hpad) } > loadmem - .fimport_nn_idbe ALIGN(16) : { *(.fimport_nn_idbe) } > loadmem - .fimport_nn_ndm ALIGN(16) : { *(.fimport_nn_ndm) } > loadmem - .fimport_nn_nets2 ALIGN(16) : { *(.fimport_nn_nets2) } > loadmem - .fimport_nn_nfp ALIGN(16) : { *(.fimport_nn_nfp) } > loadmem - .fimport_nn_nim ALIGN(16) : { *(.fimport_nn_nim) } > loadmem - .fimport_nn_olv ALIGN(16) : { *(.fimport_nn_olv) } > loadmem - .fimport_nn_pdm ALIGN(16) : { *(.fimport_nn_pdm) } > loadmem - .fimport_nn_save ALIGN(16) : { *(.fimport_nn_save) } > loadmem - .fimport_nn_sl ALIGN(16) : { *(.fimport_nn_sl) } > loadmem - .fimport_nn_spm ALIGN(16) : { *(.fimport_nn_spm) } > loadmem - .fimport_nn_temp ALIGN(16) : { *(.fimport_nn_temp) } > loadmem - .fimport_nn_uds ALIGN(16) : { *(.fimport_nn_uds) } > loadmem - .fimport_nn_vctl ALIGN(16) : { *(.fimport_nn_vctl) } > loadmem - .fimport_nsysccr ALIGN(16) : { *(.fimport_nsysccr) } > loadmem - .fimport_nsyshid ALIGN(16) : { *(.fimport_nsyshid) } > loadmem - .fimport_nsyskbd ALIGN(16) : { *(.fimport_nsyskbd) } > loadmem - .fimport_nsysnet ALIGN(16) : { *(.fimport_nsysnet) } > loadmem - .fimport_nsysuhs ALIGN(16) : { *(.fimport_nsysuhs) } > loadmem - .fimport_nsysuvd ALIGN(16) : { *(.fimport_nsysuvd) } > loadmem - .fimport_ntag ALIGN(16) : { *(.fimport_ntag) } > loadmem - .fimport_padscore ALIGN(16) : { *(.fimport_padscore) } > loadmem - .fimport_proc_ui ALIGN(16) : { *(.fimport_proc_ui) } > loadmem - .fimport_sndcore2 ALIGN(16) : { *(.fimport_sndcore2) } > loadmem - .fimport_snd_core ALIGN(16) : { *(.fimport_snd_core) } > loadmem - .fimport_snduser2 ALIGN(16) : { *(.fimport_snduser2) } > loadmem - .fimport_snd_user ALIGN(16) : { *(.fimport_snd_user) } > loadmem - .fimport_swkbd ALIGN(16) : { *(.fimport_swkbd) } > loadmem - .fimport_sysapp ALIGN(16) : { *(.fimport_sysapp) } > loadmem - .fimport_tcl ALIGN(16) : { *(.fimport_tcl) } > loadmem - .fimport_tve ALIGN(16) : { *(.fimport_tve) } > loadmem - .fimport_uac ALIGN(16) : { *(.fimport_uac) } > loadmem - .fimport_uac_rpl ALIGN(16) : { *(.fimport_uac_rpl) } > loadmem - .fimport_usb_mic ALIGN(16) : { *(.fimport_usb_mic) } > loadmem - .fimport_uvc ALIGN(16) : { *(.fimport_uvc) } > loadmem - .fimport_uvd ALIGN(16) : { *(.fimport_uvd) } > loadmem - .fimport_vpadbase ALIGN(16) : { *(.fimport_vpadbase) } > loadmem - .fimport_vpad ALIGN(16) : { *(.fimport_vpad) } > loadmem - .fimport_zlib125 ALIGN(16) : { *(.fimport_zlib125) } > loadmem + .fimport_avm ALIGN(16) : { + KEEP ( *(.fimport_avm) ) + *(.fimport_avm.*) + } > loadmem + .fimport_camera ALIGN(16) : { + KEEP ( *(.fimport_camera) ) + *(.fimport_camera.*) + } > loadmem + .fimport_coreinit ALIGN(16) : { + KEEP ( *(.fimport_coreinit) ) + *(.fimport_coreinit.*) + } > loadmem + .fimport_dc ALIGN(16) : { + KEEP ( *(.fimport_dc) ) + *(.fimport_dc.*) + } > loadmem + .fimport_dmae ALIGN(16) : { + KEEP ( *(.fimport_dmae) ) + *(.fimport_dmae.*) + } > loadmem + .fimport_drmapp ALIGN(16) : { + KEEP ( *(.fimport_drmapp) ) + *(.fimport_drmapp.*) + } > loadmem + .fimport_erreula ALIGN(16) : { + KEEP ( *(.fimport_erreula) ) + *(.fimport_erreula.*) + } > loadmem + .fimport_gx2 ALIGN(16) : { + KEEP ( *(.fimport_gx2) ) + *(.fimport_gx2.*) + } > loadmem + .fimport_h264 ALIGN(16) : { + KEEP ( *(.fimport_h264) ) + *(.fimport_h264.*) + } > loadmem + .fimport_lzma920 ALIGN(16) : { + KEEP ( *(.fimport_lzma920) ) + *(.fimport_lzma920.*) + } > loadmem + .fimport_mic ALIGN(16) : { + KEEP ( *(.fimport_mic) ) + *(.fimport_mic.*) + } > loadmem + .fimport_nfc ALIGN(16) : { + KEEP ( *(.fimport_nfc) ) + *(.fimport_nfc.*) + } > loadmem + .fimport_nio_prof ALIGN(16) : { + KEEP ( *(.fimport_nio_prof) ) + *(.fimport_nio_prof.*) + } > loadmem + .fimport_nlibcurl ALIGN(16) : { + KEEP ( *(.fimport_nlibcurl) ) + *(.fimport_nlibcurl.*) + } > loadmem + .fimport_nlibnss2 ALIGN(16) : { + KEEP ( *(.fimport_nlibnss2) ) + *(.fimport_nlibnss2.*) + } > loadmem + .fimport_nlibnss ALIGN(16) : { + KEEP ( *(.fimport_nlibnss) ) + *(.fimport_nlibnss.*) + } > loadmem + .fimport_nn_ac ALIGN(16) : { + KEEP ( *(.fimport_nn_ac) ) + *(.fimport_nn_ac.*) + } > loadmem + .fimport_nn_acp ALIGN(16) : { + KEEP ( *(.fimport_nn_acp) ) + *(.fimport_nn_acp.*) + } > loadmem + .fimport_nn_act ALIGN(16) : { + KEEP ( *(.fimport_nn_act) ) + *(.fimport_nn_act.*) + } > loadmem + .fimport_nn_aoc ALIGN(16) : { + KEEP ( *(.fimport_nn_aoc) ) + *(.fimport_nn_aoc.*) + } > loadmem + .fimport_nn_boss ALIGN(16) : { + KEEP ( *(.fimport_nn_boss) ) + *(.fimport_nn_boss.*) + } > loadmem + .fimport_nn_ccr ALIGN(16) : { + KEEP ( *(.fimport_nn_ccr) ) + *(.fimport_nn_ccr.*) + } > loadmem + .fimport_nn_cmpt ALIGN(16) : { + KEEP ( *(.fimport_nn_cmpt) ) + *(.fimport_nn_cmpt.*) + } > loadmem + .fimport_nn_dlp ALIGN(16) : { + KEEP ( *(.fimport_nn_dlp) ) + *(.fimport_nn_dlp.*) + } > loadmem + .fimport_nn_ec ALIGN(16) : { + KEEP ( *(.fimport_nn_ec) ) + *(.fimport_nn_ec.*) + } > loadmem + .fimport_nn_fp ALIGN(16) : { + KEEP ( *(.fimport_nn_fp) ) + *(.fimport_nn_fp.*) + } > loadmem + .fimport_nn_hai ALIGN(16) : { + KEEP ( *(.fimport_nn_hai) ) + *(.fimport_nn_hai.*) + } > loadmem + .fimport_nn_hpad ALIGN(16) : { + KEEP ( *(.fimport_nn_hpad) ) + *(.fimport_nn_hpad.*) + } > loadmem + .fimport_nn_idbe ALIGN(16) : { + KEEP ( *(.fimport_nn_idbe) ) + *(.fimport_nn_idbe.*) + } > loadmem + .fimport_nn_ndm ALIGN(16) : { + KEEP ( *(.fimport_nn_ndm) ) + *(.fimport_nn_ndm.*) + } > loadmem + .fimport_nn_nets2 ALIGN(16) : { + KEEP ( *(.fimport_nn_nets2) ) + *(.fimport_nn_nets2.*) + } > loadmem + .fimport_nn_nfp ALIGN(16) : { + KEEP ( *(.fimport_nn_nfp) ) + *(.fimport_nn_nfp.*) + } > loadmem + .fimport_nn_nim ALIGN(16) : { + KEEP ( *(.fimport_nn_nim) ) + *(.fimport_nn_nim.*) + } > loadmem + .fimport_nn_olv ALIGN(16) : { + KEEP ( *(.fimport_nn_olv) ) + *(.fimport_nn_olv.*) + } > loadmem + .fimport_nn_pdm ALIGN(16) : { + KEEP ( *(.fimport_nn_pdm) ) + *(.fimport_nn_pdm.*) + } > loadmem + .fimport_nn_save ALIGN(16) : { + KEEP ( *(.fimport_nn_save) ) + *(.fimport_nn_save.*) + } > loadmem + .fimport_nn_sl ALIGN(16) : { + KEEP ( *(.fimport_nn_sl) ) + *(.fimport_nn_sl.*) + } > loadmem + .fimport_nn_spm ALIGN(16) : { + KEEP ( *(.fimport_nn_spm) ) + *(.fimport_nn_spm.*) + } > loadmem + .fimport_nn_temp ALIGN(16) : { + KEEP ( *(.fimport_nn_temp) ) + *(.fimport_nn_temp.*) + } > loadmem + .fimport_nn_uds ALIGN(16) : { + KEEP ( *(.fimport_nn_uds) ) + *(.fimport_nn_uds.*) + } > loadmem + .fimport_nn_vctl ALIGN(16) : { + KEEP ( *(.fimport_nn_vctl) ) + *(.fimport_nn_vctl.*) + } > loadmem + .fimport_nsysccr ALIGN(16) : { + KEEP ( *(.fimport_nsysccr) ) + *(.fimport_nsysccr.*) + } > loadmem + .fimport_nsyshid ALIGN(16) : { + KEEP ( *(.fimport_nsyshid) ) + *(.fimport_nsyshid.*) + } > loadmem + .fimport_nsyskbd ALIGN(16) : { + KEEP ( *(.fimport_nsyskbd) ) + *(.fimport_nsyskbd.*) + } > loadmem + .fimport_nsysnet ALIGN(16) : { + KEEP ( *(.fimport_nsysnet) ) + *(.fimport_nsysnet.*) + } > loadmem + .fimport_nsysuhs ALIGN(16) : { + KEEP ( *(.fimport_nsysuhs) ) + *(.fimport_nsysuhs.*) + } > loadmem + .fimport_nsysuvd ALIGN(16) : { + KEEP ( *(.fimport_nsysuvd) ) + *(.fimport_nsysuvd.*) + } > loadmem + .fimport_ntag ALIGN(16) : { + KEEP ( *(.fimport_ntag) ) + *(.fimport_ntag.*) + } > loadmem + .fimport_padscore ALIGN(16) : { + KEEP ( *(.fimport_padscore) ) + *(.fimport_padscore.*) + } > loadmem + .fimport_proc_ui ALIGN(16) : { + KEEP ( *(.fimport_proc_ui) ) + *(.fimport_proc_ui.*) + } > loadmem + .fimport_sndcore2 ALIGN(16) : { + KEEP ( *(.fimport_sndcore2) ) + *(.fimport_sndcore2.*) + } > loadmem + .fimport_snd_core ALIGN(16) : { + KEEP ( *(.fimport_snd_core) ) + *(.fimport_snd_core.*) + } > loadmem + .fimport_snduser2 ALIGN(16) : { + KEEP ( *(.fimport_snduser2) ) + *(.fimport_snduser2.*) + } > loadmem + .fimport_snd_user ALIGN(16) : { + KEEP ( *(.fimport_snd_user) ) + *(.fimport_snd_user.*) + } > loadmem + .fimport_swkbd ALIGN(16) : { + KEEP ( *(.fimport_swkbd) ) + *(.fimport_swkbd.*) + } > loadmem + .fimport_sysapp ALIGN(16) : { + KEEP ( *(.fimport_sysapp) ) + *(.fimport_sysapp.*) + } > loadmem + .fimport_tcl ALIGN(16) : { + KEEP ( *(.fimport_tcl) ) + *(.fimport_tcl.*) + } > loadmem + .fimport_tve ALIGN(16) : { + KEEP ( *(.fimport_tve) ) + *(.fimport_tve.*) + } > loadmem + .fimport_uac ALIGN(16) : { + KEEP ( *(.fimport_uac) ) + *(.fimport_uac.*) + } > loadmem + .fimport_uac_rpl ALIGN(16) : { + KEEP ( *(.fimport_uac_rpl) ) + *(.fimport_uac_rpl.*) + } > loadmem + .fimport_usb_mic ALIGN(16) : { + KEEP ( *(.fimport_usb_mic) ) + *(.fimport_usb_mic.*) + } > loadmem + .fimport_uvc ALIGN(16) : { + KEEP ( *(.fimport_uvc) ) + *(.fimport_uvc.*) + } > loadmem + .fimport_uvd ALIGN(16) : { + KEEP ( *(.fimport_uvd) ) + *(.fimport_uvd.*) + } > loadmem + .fimport_vpadbase ALIGN(16) : { + KEEP ( *(.fimport_vpadbase) ) + *(.fimport_vpadbase.*) + } > loadmem + .fimport_vpad ALIGN(16) : { + KEEP ( *(.fimport_vpad) ) + *(.fimport_vpad.*) + } > loadmem + .fimport_zlib125 ALIGN(16) : { + KEEP ( *(.fimport_zlib125) ) + *(.fimport_zlib125.*) + } > loadmem - .dimport_coreinit ALIGN(16) : { *(.dimport_coreinit) } > loadmem - .dimport_nn_act ALIGN(16) : { *(.dimport_nn_act) } > loadmem - .dimport_nn_boss ALIGN(16) : { *(.dimport_nn_boss) } > loadmem - .dimport_nn_ec ALIGN(16) : { *(.dimport_nn_ec) } > loadmem - .dimport_nn_nim ALIGN(16) : { *(.dimport_nn_nim) } > loadmem - .dimport_nn_sl ALIGN(16) : { *(.dimport_nn_sl) } > loadmem - .dimport_nn_uds ALIGN(16) : { *(.dimport_nn_uds) } > loadmem + .dimport_coreinit ALIGN(16) : { + KEEP ( *(.dimport_coreinit) ) + *(.dimport_coreinit.*) + } > loadmem + .dimport_nn_act ALIGN(16) : { + KEEP ( *(.dimport_nn_act) ) + *(.dimport_nn_act.*) + } > loadmem + .dimport_nn_boss ALIGN(16) : { + KEEP ( *(.dimport_nn_boss) ) + *(.dimport_nn_boss.*) + } > loadmem + .dimport_nn_ec ALIGN(16) : { + KEEP ( *(.dimport_nn_ec) ) + *(.dimport_nn_ec.*) + } > loadmem + .dimport_nn_nim ALIGN(16) : { + KEEP ( *(.dimport_nn_nim) ) + *(.dimport_nn_nim.*) + } > loadmem + .dimport_nn_sl ALIGN(16) : { + KEEP ( *(.dimport_nn_sl) ) + *(.dimport_nn_sl.*) + } > loadmem + .dimport_nn_uds ALIGN(16) : { + KEEP ( *(.dimport_nn_uds) ) + *(.dimport_nn_uds.*) + } > loadmem .symtab ALIGN(4) : { *(.symtab) } > loadmem .strtab ALIGN(1) : { *(.strtab) } > loadmem diff --git a/share/wut.specs b/share/wut.specs new file mode 100644 index 0000000..6b44cfd --- /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 -wrap __gxx_personality_v0 %(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)