diff --git a/.gitignore b/.gitignore index b1d678091..49e2a460f 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 e69de29bb..000000000 diff --git a/.travis.yml b/.travis.yml index 1403490c2..8ab807666 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 000000000..ad479ad05 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,22 @@ +#### 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. + - `snd_core` and `snd_user` are no longer linked, due to naming conflicts with `sndcore2` and `snduser2`. wut has never shipped headers for these libraries, but if you are using them, please switch to `sndcore2` and `snduser2`. + - Changes to CMake's linker flags may cause existing build trees to fail. Please delete any old build files and re-run CMake. + - Two new symbols, `__rpx_start` and `__rpl_start`, are now used internally by the toolchain, while `_start` is now undefined. As usual, applications are strongly discouraged from prefixing any symbol with two underscores, in order to avoid conflicts of this type. + +###### 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`. + - All of wut's static libraries (`-lcoreinit`, `-lwhb`, etc.) have been merged into a single `libwut`, which gets automatically linked in for all builds. While empty static libraries have been provided for CMake builds to ease the transition, these will be removed eventually. Applications should remove the build flags to link any of wut's libraries. + - Similarly, wut's build configuration options (devoptab, wutmalloc, newlib) are now integrated into `libwut`. For CMake builds, the `wut_enable_*` macros will now log a deprecation warning, and should be removed as soon as possible. + - Use of `wut.mk` as a build system is now deprecated. Applications should move to `wut_rules` and devkitPro-style makefiles, such as those in [the samples](/samples/make). `wut.mk` will not be updated further, and will be removed in a future release. + +###### 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. + - A new header file, ``, has been added and documented for OSCodegen functionality. + + +#### wut 1.0.0-beta8 diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index d9a0bef5d..000000000 --- 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 000000000..0c749933b --- /dev/null +++ b/Makefile @@ -0,0 +1,173 @@ + +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 STUB_LIBS := $(addprefix lib/stubs/lib,$(DEFFILES:.def=.a)) lib/stubs/libnn_swkbd.a lib/stubs/libwhb.a lib/stubs/libgfd.a lib/stubs/libsnd_core.a lib/stubs/libsnd_user.a + +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 $(STUB_LIBS) + +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 $@ + +lib/stubs: + @[ -d $@ ] || mkdir -p $@ + +release: + @[ -d $@ ] || mkdir -p $@ + +debug: + @[ -d $@ ] || mkdir -p $@ + +lib/libwut.a :$(SOURCES) $(INCLUDES) | lib release + @$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \ + BUILD_CFLAGS="-DNDEBUG=1 -O2" \ + DEPSDIR=$(CURDIR)/release \ + --no-print-directory -C release \ + -f $(CURDIR)/Makefile + +lib/libwutd.a : $(SOURCES) $(INCLUDES) | lib debug + @$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \ + BUILD_CFLAGS="-DDEBUG=1 -Og" \ + DEPSDIR=$(CURDIR)/debug \ + --no-print-directory -C debug \ + -f $(CURDIR)/Makefile + +# temp: Deprecation stub for directly linking cafe libs (all in libwut) +lib/stubs/lib%.a: | lib/stubs release + @echo stub $(notdir $*) + @$(AR) -rc $@ + +#--------------------------------------------------------------------------------- +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 bf4b0bf90..000000000 --- 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 bb3be89f3..32939ef46 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/cafe/snd_core.def b/cafe/snd_core.def deleted file mode 100644 index 0e4419ad9..000000000 --- a/cafe/snd_core.def +++ /dev/null @@ -1,272 +0,0 @@ -:NAME snd_core - -:TEXT -AI2CheckInit -AI2GetDMABytesLeft -AI2GetDMAEnableFlag -AI2GetDMALength -AI2GetDMAStartAddr -AI2GetDSPSampleRate -AI2Init -AI2InitDMA -AI2RegisterDMACallback -AI2Reset -AI2SetDSPSampleRate -AI2StartDMA -AI2StopDMA -AICheckInit -AIDRCGetDMALength -AIDRCGetDMAStartAddr -AIDRCRegisterDMACallback -AIGetAudioFrameCount -AIGetDMABytesLeft -AIGetDMAEnableFlag -AIGetDMALength -AIGetDMARange -AIGetDMAStartAddr -AIGetDSPSampleRate -AII2S3Init -AII2S5Init -AIInit -AIInitDMA -AIQuit -AIRegisterDMABuffer -AIRegisterDMACallback -AIReset -AISetChannel -AISetCloneMode -AISetDSPSampleRate -AISetFormatChangeState -AIStartDMA -AIStopDMA -AXAcquireVoice -AXAcquireVoiceEx -AXCheckVoiceOffsets -AXComputeLpfCoefs -AXDecodeAdpcmData -AXDeregisterAppFrameCallback -AXFreeVoice -AXGetAdpcmData -AXGetAdpcmOutputSize -AXGetAdpcmWorkSize -AXGetAuxACallback -AXGetAuxAReturnVolume -AXGetAuxBCallback -AXGetAuxBReturnVolume -AXGetAuxCCallback -AXGetAuxCReturnVolume -AXGetAuxCallback -AXGetAuxDRCCallback -AXGetAuxReturnVolume -AXGetDRCAuxReturnVolume -AXGetDRCVSMode -AXGetDSPCyclesFudgeFactor -AXGetDefaultMixerSelect -AXGetDeviceChannelCount -AXGetDeviceFinalMixCallback -AXGetDeviceFinalOutput -AXGetDeviceMode -AXGetDeviceRemixMatrix -AXGetDeviceUpsampleStage -AXGetDeviceVolume -AXGetDroppedVoiceCount -AXGetDspCycles -AXGetDspLoad -AXGetDspLoadLimit -AXGetMasterDRCVolume -AXGetMasterVolume -AXGetMaxDspCycles -AXGetMaxDspVoices -AXGetMaxVoices -AXGetMode -AXGetNumDspVoices -AXGetNumVoices -AXGetPostFinalMixCallback -AXGetPpcLoad -AXGetPpcLoadLimit -AXGetProfile -AXGetSwapProfile -AXGetVoiceCurrentOffsetEx -AXGetVoiceLoopCount -AXGetVoiceMixerSelect -AXGetVoiceOffsets -AXGetVoiceOffsetsEx -AXGlitch_GetCount -AXGlitch_PrintTrace -AXGlitch_RegisterCatcher -AXGlitch_trace -AXInit -AXInitEx -AXInitExSpecifyMem -AXInitProfile -AXInitSpecifyMem -AXIsAudioOutReady -AXIsInit -AXIsTransitionAudioDone -AXIsVoiceRunning -AXMakeCompressorTable -AXMixGetSwapProfile -AXPrepareEfxData -AXQuit -AXRegisterAppFrameCallback -AXRegisterAuxACallback -AXRegisterAuxBCallback -AXRegisterAuxCCallback -AXRegisterAuxCallback -AXRegisterAuxDRCCallback -AXRegisterCallback -AXRegisterDRCCallback -AXRegisterDeviceFinalMixCallback -AXRegisterExceedCallback -AXRegisterFrameCallback -AXRegisterPostFinalMixCallback -AXRmtAdvancePtr -AXRmtGetSamples -AXRmtGetSamplesLeft -AXSetAuxAReturnVolume -AXSetAuxBReturnVolume -AXSetAuxCReturnVolume -AXSetAuxReturnVolume -AXSetDRCAuxReturnVolume -AXSetDRCVSDownmixBalance -AXSetDRCVSLC -AXSetDRCVSLimiter -AXSetDRCVSLimiterThreshold -AXSetDRCVSMode -AXSetDRCVSOutputGain -AXSetDRCVSSpeakerPosition -AXSetDRCVSSurroundDepth -AXSetDRCVSSurroundLevelGain -AXSetDSPCyclesFudgeFactor -AXSetDefaultMixerSelect -AXSetDeviceCompressor -AXSetDeviceCompressorTable -AXSetDeviceLinearUpsampler -AXSetDeviceMode -AXSetDeviceRemixMatrix -AXSetDeviceUpsampleStage -AXSetDeviceVolume -AXSetDspLoadLimit -AXSetMasterDRCVolume -AXSetMasterVolume -AXSetMaxDspCycles -AXSetMaxDspVoices -AXSetMaxVoices -AXSetMode -AXSetPpcLoadLimit -AXSetStepMode -AXSetUpTransitionAudio -AXSetVoiceAdpcm -AXSetVoiceAdpcmLoop -AXSetVoiceBiquad -AXSetVoiceBiquadCoefs -AXSetVoiceCurrentOffset -AXSetVoiceCurrentOffsetEx -AXSetVoiceDRCMix -AXSetVoiceDeviceMix -AXSetVoiceEndOffset -AXSetVoiceEndOffsetEx -AXSetVoiceItdOn -AXSetVoiceItdTarget -AXSetVoiceLoop -AXSetVoiceLoopOffset -AXSetVoiceLoopOffsetEx -AXSetVoiceLpf -AXSetVoiceLpfCoefs -AXSetVoiceMix -AXSetVoiceMixerSelect -AXSetVoiceOffsets -AXSetVoiceOffsetsEx -AXSetVoicePriority -AXSetVoiceRmtIIR -AXSetVoiceRmtIIRCoefs -AXSetVoiceRmtMix -AXSetVoiceRmtOn -AXSetVoiceRmtSrc -AXSetVoiceSamplesAddr -AXSetVoiceSrc -AXSetVoiceSrcRatio -AXSetVoiceSrcType -AXSetVoiceState -AXSetVoiceType -AXSetVoiceVe -AXSetVoiceVeDelta -AXStartTransitionAudio -AXUpdateDeviceModes -AXUserBegin -AXUserEnd -AXUserIsProtected -AXVoiceBegin -AXVoiceEnd -AXVoiceIsProtected -DRCVS_GetVersion -DRCVS_Initialize -DRCVS_Process -DRCVS_Quit -DRCVS_SetDirectionFilterCoef -DRCVS_SetDownmixBalance -DRCVS_SetEqCoef -DRCVS_SetHeadphoneGain -DRCVS_SetLimiter -DRCVS_SetLimiterThreshold -DRCVS_SetOutputMode -DRCVS_SetSampleFreq -DRCVS_SetSlevGain -DRCVS_SetSpacialFilterCoef -DRCVS_SetSpeakerGain -DRCVS_SetSurroundDepth -DSPAddTask -DSPAssertInt -DSPAssertTask -DSPCancelTask -DSPCheckInit -DSPCheckMailFromDSP -DSPCheckMailToDSP -DSPGetDMAStatus -DSPH_RunTask -DSPH_WaitTaskComplete -DSPHalt -DSPInit -DSPQuit -DSPReadCPUToDSPMbox -DSPReadMailFromDSP -DSPReset -DSPSendMailToDSP -DSPUnhalt -ISRREnable -ISRRGetMsgQ -ISRRGetNewMsg -ISRRInit -ISRRQuit -ISRSendMessage -_CheckMailFromDSP -_CheckMailToDSP -_InitDsp -_ReadMailFromDSP -_SendMailToDSP -__AXGetAppIoMode -__AXGetMixMode -__AXSetAppIoMode -aiBSPHardwareVersion -axDspSlave -axDspSlaveBalanced -axDspSlaveBalancedLength -axDspSlaveLength -check_os_audio_transition_flag -dsp_os_switch -dsp_os_switchLength -dump_dsp_data -ex_addr_reg_stat -pcd -ppf_dn_e_coef -ppf_dn_o_coef -ppf_up_0_coef -ppf_up_1_coef -ppf_up_2_coef -s_board_type -set_os_audio_transition_flag -slaveData -slaveLength -start_os_audio_transition -stop_os_audio_transition -vs diff --git a/cafe/snd_user.def b/cafe/snd_user.def deleted file mode 100644 index 02cf236ff..000000000 --- a/cafe/snd_user.def +++ /dev/null @@ -1,379 +0,0 @@ -:NAME snd_user - -:TEXT -AXART3DSound -AXARTAddArticulator -AXARTAddSound -AXARTCents -AXARTInit -AXARTInitArt3D -AXARTInitArtAuxAVolume -AXARTInitArtAuxAVolumeEnv -AXARTInitArtAuxAVolumeMod -AXARTInitArtAuxBVolume -AXARTInitArtAuxBVolumeEnv -AXARTInitArtAuxBVolumeMod -AXARTInitArtAuxCVolume -AXARTInitArtAuxCVolumeEnv -AXARTInitArtAuxCVolumeMod -AXARTInitArtFader -AXARTInitArtItd -AXARTInitArtLpf -AXARTInitArtPanning -AXARTInitArtPitch -AXARTInitArtPitchEnv -AXARTInitArtPitchMod -AXARTInitArtRmt -AXARTInitArtRmtAuxVolume -AXARTInitArtRmtFader -AXARTInitArtSrctype -AXARTInitArtVolume -AXARTInitArtVolumeEnv -AXARTInitArtVolumeMod -AXARTInitLfo -AXARTInitSound -AXARTLfo -AXARTLpf -AXARTNoise -AXARTPitchEnv -AXARTQuit -AXARTRemoveArticulator -AXARTRemoveSound -AXARTReverseSaw -AXARTSaw -AXARTServiceSound -AXARTServiceSounds -AXARTSet3DDistanceScale -AXARTSet3DDopplerScale -AXARTSine -AXARTSquare -AXARTTriangle -AXARTVolumeEnv -AXFX2GetMemAllocFns -AXFX2SetMemAllocFns -AXFX2chChorusCallback -AXFX2chChorusGetMemSize -AXFX2chChorusInit -AXFX2chChorusSettings -AXFX2chChorusSettingsUpdate -AXFX2chChorusShutdown -AXFX2chMultiDelayCallback -AXFX2chMultiDelayGetMemSize -AXFX2chMultiDelayInit -AXFX2chMultiDelaySettingsUpdate -AXFX2chMultiDelayShutdown -AXFX2chReverbCallback -AXFX2chReverbGetMemSize -AXFX2chReverbInit -AXFX2chReverbParametersPreset -AXFX2chReverbSettingsUpdate -AXFX2chReverbShutdown -AXFX4chChorusCallback -AXFX4chChorusGetMemSize -AXFX4chChorusInit -AXFX4chChorusSettings -AXFX4chChorusSettingsUpdate -AXFX4chChorusShutdown -AXFX4chMultiDelayCallback -AXFX4chMultiDelayGetMemSize -AXFX4chMultiDelayInit -AXFX4chMultiDelaySettingsUpdate -AXFX4chMultiDelayShutdown -AXFX4chReverbCallback -AXFX4chReverbGetMemSize -AXFX4chReverbInit -AXFX4chReverbParametersPreset -AXFX4chReverbSettingsUpdate -AXFX4chReverbShutdown -AXFX6ch6chReverbCallback -AXFX6ch6chReverbGetMemSize -AXFX6ch6chReverbInit -AXFX6ch6chReverbParametersPreset -AXFX6ch6chReverbSettingsUpdate -AXFX6ch6chReverbShutdown -AXFX6chChorusCallback -AXFX6chChorusGetMemSize -AXFX6chChorusInit -AXFX6chChorusSettings -AXFX6chChorusSettingsUpdate -AXFX6chChorusShutdown -AXFX6chMultiDelayCallback -AXFX6chMultiDelayGetMemSize -AXFX6chMultiDelayInit -AXFX6chMultiDelaySettingsUpdate -AXFX6chMultiDelayShutdown -AXFX6chReverbCallback -AXFX6chReverbGetMemSize -AXFX6chReverbInit -AXFX6chReverbParametersPreset -AXFX6chReverbSettingsUpdate -AXFX6chReverbShutdown -AXFXChorusCallback -AXFXChorusCallbackDpl2 -AXFXChorusExpCallback -AXFXChorusExpCallbackDpl2 -AXFXChorusExpGetMemSize -AXFXChorusExpGetMemSizeDpl2 -AXFXChorusExpInit -AXFXChorusExpInitDpl2 -AXFXChorusExpSettings -AXFXChorusExpSettingsDpl2 -AXFXChorusExpSettingsUpdate -AXFXChorusExpSettingsUpdateDpl2 -AXFXChorusExpShutdown -AXFXChorusExpShutdownDpl2 -AXFXChorusGetMemSize -AXFXChorusGetMemSizeDpl2 -AXFXChorusInit -AXFXChorusInitDpl2 -AXFXChorusSettings -AXFXChorusSettingsDpl2 -AXFXChorusShutdown -AXFXChorusShutdownDpl2 -AXFXDelayCallback -AXFXDelayCallbackDpl2 -AXFXDelayExpCallback -AXFXDelayExpCallbackDpl2 -AXFXDelayExpGetMemSize -AXFXDelayExpGetMemSizeDpl2 -AXFXDelayExpInit -AXFXDelayExpInitDpl2 -AXFXDelayExpSettings -AXFXDelayExpSettingsDpl2 -AXFXDelayExpSettingsUpdate -AXFXDelayExpSettingsUpdateDpl2 -AXFXDelayExpShutdown -AXFXDelayExpShutdownDpl2 -AXFXDelayGetMemSize -AXFXDelayGetMemSizeDpl2 -AXFXDelayInit -AXFXDelayInitDpl2 -AXFXDelaySettings -AXFXDelaySettingsDpl2 -AXFXDelayShutdown -AXFXDelayShutdownDpl2 -AXFXGetHooks -AXFXMultiChChorusCallback -AXFXMultiChChorusGetMemSize -AXFXMultiChChorusInit -AXFXMultiChChorusSettings -AXFXMultiChChorusSettingsUpdate -AXFXMultiChChorusSettingsUpdateNoReset -AXFXMultiChChorusShutdown -AXFXMultiChDelayCallback -AXFXMultiChDelayGetMemSize -AXFXMultiChDelayInit -AXFXMultiChDelaySettingsUpdate -AXFXMultiChDelaySettingsUpdateNoReset -AXFXMultiChDelayShutdown -AXFXMultiChReverbCallback -AXFXMultiChReverbGetMemSize -AXFXMultiChReverbInit -AXFXMultiChReverbParametersPreset -AXFXMultiChReverbSettingsUpdate -AXFXMultiChReverbSettingsUpdateNoReset -AXFXMultiChReverbShutdown -AXFXReverbHiCallback -AXFXReverbHiCallbackDpl2 -AXFXReverbHiExpCallback -AXFXReverbHiExpCallbackDpl2 -AXFXReverbHiExpGetMemSize -AXFXReverbHiExpGetMemSizeDpl2 -AXFXReverbHiExpInit -AXFXReverbHiExpInitDpl2 -AXFXReverbHiExpSettings -AXFXReverbHiExpSettingsDpl2 -AXFXReverbHiExpSettingsUpdate -AXFXReverbHiExpSettingsUpdateDpl2 -AXFXReverbHiExpShutdown -AXFXReverbHiExpShutdownDpl2 -AXFXReverbHiGetMemSize -AXFXReverbHiGetMemSizeDpl2 -AXFXReverbHiInit -AXFXReverbHiInitDpl2 -AXFXReverbHiSettings -AXFXReverbHiSettingsDpl2 -AXFXReverbHiShutdown -AXFXReverbHiShutdownDpl2 -AXFXReverbSettingsUpdate -AXFXReverbSettingsUpdateNoReset -AXFXReverbStdCallback -AXFXReverbStdCallbackDpl2 -AXFXReverbStdExpCallback -AXFXReverbStdExpCallbackDpl2 -AXFXReverbStdExpGetMemSize -AXFXReverbStdExpGetMemSizeDpl2 -AXFXReverbStdExpInit -AXFXReverbStdExpInitDpl2 -AXFXReverbStdExpSettings -AXFXReverbStdExpSettingsDpl2 -AXFXReverbStdExpSettingsUpdate -AXFXReverbStdExpSettingsUpdateDpl2 -AXFXReverbStdExpShutdown -AXFXReverbStdExpShutdownDpl2 -AXFXReverbStdGetMemSize -AXFXReverbStdGetMemSizeDpl2 -AXFXReverbStdInit -AXFXReverbStdInitDpl2 -AXFXReverbStdSettings -AXFXReverbStdSettingsDpl2 -AXFXReverbStdShutdown -AXFXReverbStdShutdownDpl2 -AXFXSetHooks -AXFX_AllPass_Free -AXFX_AllPass_GetLen -AXFX_AllPass_Initialize -AXFX_AllPass_SetCoef -AXFX_AllPass_Tick -AXFX_Delay_Clear -AXFX_Delay_Free -AXFX_Delay_GetDelay -AXFX_Delay_GetMaximumDelay -AXFX_Delay_Initialize -AXFX_Delay_NextOut -AXFX_Delay_SetDelay -AXFX_Delay_TapOut -AXFX_Delay_TapOut_Interpolate -AXFX_Delay_Tick -AXFX_PS_Delay_Clear -AXFX_PS_Delay_Free -AXFX_PS_Delay_GetDelay -AXFX_PS_Delay_GetMaximumDelay -AXFX_PS_Delay_Initialize -AXFX_PS_Delay_NextOut -AXFX_PS_Delay_SetDelay -AXFX_PS_Delay_TapOut -AXFX_PS_Delay_TapOut_Interpolate -AXFX_PS_Delay_Tick -AXFX_PS_Dual_Delay_TapOut -AXFX_PS_Single_Delay_TapOut -ArticulationMutex -MIXAdjustAuxA -MIXAdjustAuxB -MIXAdjustAuxC -MIXAdjustDeviceAux -MIXAdjustDeviceFader -MIXAdjustDeviceLFE -MIXAdjustDevicePan -MIXAdjustDeviceSPan -MIXAdjustFader -MIXAdjustInput -MIXAdjustPan -MIXAdjustSPan -MIXAssignChannel -MIXAuxAIsPostFader -MIXAuxAPostFader -MIXAuxAPreFader -MIXAuxBIsPostFader -MIXAuxBPostFader -MIXAuxBPreFader -MIXAuxCIsPostFader -MIXAuxCPostFader -MIXAuxCPreFader -MIXDRCAdjustAux -MIXDRCAdjustFader -MIXDRCAdjustPan -MIXDRCAuxIsPostFader -MIXDRCAuxPostFader -MIXDRCAuxPreFader -MIXDRCGetAux -MIXDRCGetFader -MIXDRCGetPan -MIXDRCInitChannel -MIXDRCSetAux -MIXDRCSetFader -MIXDRCSetPan -MIXDeviceAuxIsPostFader -MIXDeviceAuxPostFader -MIXDeviceAuxPreFader -MIXGetAuxA -MIXGetAuxB -MIXGetAuxC -MIXGetDeviceAux -MIXGetDeviceFader -MIXGetDeviceLFE -MIXGetDevicePan -MIXGetDeviceSPan -MIXGetDeviceSoundMode -MIXGetFader -MIXGetInput -MIXGetPan -MIXGetSPan -MIXGetSoundMode -MIXInit -MIXInitChannel -MIXInitDeviceControl -MIXInitInputControl -MIXInitSpecifyMem -MIXIsMute -MIXMute -MIXQuit -MIXReleaseChannel -MIXResetAllDeviceControls -MIXResetControls -MIXResetDeviceControl -MIXRmtAdjustAux -MIXRmtAdjustFader -MIXRmtAuxIsPostFader -MIXRmtAuxPostFader -MIXRmtAuxPreFader -MIXRmtGetAux -MIXRmtGetFader -MIXRmtSetAux -MIXRmtSetFader -MIXRmtSetVolumes -MIXSetAuxA -MIXSetAuxB -MIXSetAuxC -MIXSetDeviceAux -MIXSetDeviceFader -MIXSetDeviceLFE -MIXSetDevicePan -MIXSetDeviceSPan -MIXSetDeviceSoundMode -MIXSetFader -MIXSetInput -MIXSetPan -MIXSetSPan -MIXSetSoundMode -MIXUnMute -MIXUpdateSettings -SEQAddSequence -SEQDRCGetVolume -SEQDRCSetVolume -SEQGetMixerSelect -SEQGetState -SEQGetTempo -SEQGetVolume -SEQInit -SEQQuit -SEQRegisterControllerCallback -SEQRemoveSequence -SEQRunAudioFrame -SEQSetMixerSelect -SEQSetState -SEQSetTempo -SEQSetVolume -SPGetSoundEntry -SPInitSoundTable -SPPrepareEnd -SPPrepareSound -SYNDRCGetMasterVolume -SYNDRCSetMasterVolume -SYNGetActiveNotes -SYNGetMasterVolume -SYNGetMidiController -SYNGetMixerSelect -SYNInit -SYNInitSpecifyMem -SYNInitSynth -SYNMidiInput -SYNQuit -SYNQuitSynth -SYNRunAudioFrame -SYNSetInitCallback -SYNSetMasterVolume -SYNSetMixerSelect -SYNSetUpdateCallback -SeqMutex -SynthMutex diff --git a/include/coreinit/exit.h b/include/coreinit/exit.h index 51bcb989b..5dc008790 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 a704f413c..cdbd46468 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 000000000..433903a03 --- /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 4e7c66fdc..000000000 --- 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 d031a8269..000000000 --- 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 31d854333..000000000 --- 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 702c4deb4..000000000 --- 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 b293b8242..000000000 --- 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 82ac12e1a..1ed6d91a7 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 319bfdebd..c80c66967 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 80d80978d..fa15cdbf5 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 cdd1f3bfd..000000000 --- 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 33df4ea9a..52e1e5825 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 cffdb167b..93b8ef240 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 80ff1962c..000000000 --- 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 a929006f0..c4857218d 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 9b011d98b..000000000 --- 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 70fd641f5..362322925 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 7d16c48b8..000000000 --- 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 f15f6df2d..000000000 --- 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 000000000..c6dc73706 --- /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 1f6f3a9b9..aefae08e3 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 80% rename from samples/curl/CMakeLists.txt rename to samples/cmake/curl/CMakeLists.txt index e4dd5bdbc..4a01ddb4c 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) @@ -12,7 +12,6 @@ target_link_libraries(curl nsysnet nlibcurl) -wut_enable_newlib(curl) wut_create_rpx(curl.rpx curl) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/curl.rpx" 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 a3de1747d..bf1f6bd89 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 231f3d56b..fcd4114af 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 7fe9844ef..e5a5d2034 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 71% rename from samples/helloworld_cpp/CMakeLists.txt rename to samples/cmake/helloworld_cpp/CMakeLists.txt index 5c8496a15..62adce354 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) @@ -12,10 +12,6 @@ target_link_libraries(helloworld_cpp sysapp nn_ac) -wut_default_malloc(helloworld_cpp) -wut_enable_newlib(helloworld_cpp) -wut_enable_stdcpp(helloworld_cpp) - wut_create_rpx(helloworld_cpp.rpx helloworld_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 dd8e04748..afcebab90 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 78% rename from samples/swkbd/CMakeLists.txt rename to samples/cmake/swkbd/CMakeLists.txt index 44ad7544e..198948ebc 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) @@ -16,9 +16,6 @@ target_link_libraries(swkbd nn_swkbd vpad) -wut_enable_newlib(swkbd) -wut_enable_stdcpp(swkbd) - wut_create_rpx(swkbd_sample.rpx swkbd) 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 000000000..6b9495ecc --- /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 000000000..b9e3777cf --- /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 000000000..489fc4780 --- /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 000000000..b9e3777cf --- /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 000000000..9938773f7 --- /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 000000000..8d211a5e2 --- /dev/null +++ b/share/rpl.specs @@ -0,0 +1,2 @@ +*wut_entry: +--entry=__rpl_start diff --git a/share/wut.cmake b/share/wut.cmake index 1b20f9df5..645959f9e 100644 --- a/share/wut.cmake +++ b/share/wut.cmake @@ -2,49 +2,22 @@ cmake_minimum_required(VERSION 3.2) # Links against wutnewlib macro(wut_enable_newlib target) - get_property(ENABLED_NEWLIB TARGET ${target} PROPERTY WUT_ENABLE_NEWLIB) - if(NOT DEFINED ENABLED_NEWLIB) - target_link_libraries(${target} - -Wl,--whole-archive wutnewlib -Wl,--no-whole-archive) - - set_target_properties(${target} PROPERTIES WUT_ENABLE_NEWLIB 1) - endif() + message(DEPRECATION "wut_enable_newlib is deprecated and has no effect - it is always enabled; and the macro will be removed in a future release. Please remove it from your CMakeLists.") endmacro() # Links against stdc++ wutstdc++ and set -std=c++17 macro(wut_enable_stdcpp target) - get_property(ENABLED_STDCPP TARGET ${target} PROPERTY WUT_ENABLE_STDCPP) - if(NOT DEFINED ENABLED_STDCPP) - wut_enable_newlib(${target}) - - target_link_libraries(${target} - stdc++ - -Wl,--whole-archive wutstdc++ -Wl,--no-whole-archive) - - set_target_properties(${target} PROPERTIES WUT_ENABLE_STDCPP 1) - endif() + message(DEPRECATION "wut_enable_stdcpp is deprecated and has no effect - it is always enabled when using C++; and the macro will be removed in a future release. Please remove it from your CMakeLists.") endmacro() # Links against devoptab macro(wut_enable_devoptab target) - get_property(ENABLED_DEVOPTAB TARGET ${target} PROPERTY WUT_ENABLE_DEVOPTAB) - if(NOT DEFINED ENABLED_DEVOPTAB) - target_link_libraries(${target} - -Wl,--whole-archive wutdevoptab -Wl,--no-whole-archive) - - set_target_properties(${target} PROPERTIES WUT_ENABLE_DEVOPTAB 1) - endif() + message(DEPRECATION "wut_enable_devoptab is deprecated and has no effect - it is always enabled; and the macro will be removed in a future release. Please remove it from your CMakeLists.") endmacro() # Links against wutmalloc macro(wut_default_malloc target) - get_property(ENABLED_DEFAULT_MALLOC TARGET ${target} PROPERTY WUT_DEFAULT_MALLOC) - if(NOT DEFINED ENABLED_DEFAULT_MALLOC) - target_link_libraries(${target} - -Wl,--whole-archive wutmalloc -Wl,--no-whole-archive) - - set_target_properties(${target} PROPERTIES WUT_DEFAULT_MALLOC 1) - endif() + message(DEPRECATION "wut_default_malloc is deprecated and has no effect - it is always enabled; and the macro will be removed in a future release. Please remove it from your CMakeLists.") endmacro() # Generates ${target}_exports.s from an exports file and adds it to the build @@ -72,19 +45,13 @@ function(wut_create_rpl target source) cmake_parse_arguments(RPL "${RPL_OPTIONS}" "${RPL_SINGLE_ARGS}" "${RPL_MULTI_ARGS}" "${ARGN}") if(RPL_IS_RPX) - target_link_libraries(${source} - coreinit - wutcrt) + # Do nothing - the defaults are good for RPX else() set(ELF2RPL_FLAGS ${ELF2RPL_FLAGS} --rpl) - target_link_libraries(${source} - coreinit - wutcrtrpl) + set_property(TARGET ${source} APPEND_STRING PROPERTY + LINK_FLAGS "-specs=${WUT_ROOT}/share/rpl.specs") endif() - target_link_libraries(${source} - coreinit) - add_custom_target(${target} ALL COMMAND ${CMAKE_STRIP} -g ${source} COMMAND ${WUT_ELF2RPL} ${ELF2RPL_FLAGS} ${source} ${target} diff --git a/share/wut.ld b/share/wut.ld index e666586b8..96ec12122 100644 --- a/share/wut.ld +++ b/share/wut.ld @@ -8,8 +8,7 @@ MEMORY { loadmem (rwx) : ORIGIN = 0xC0000000, LENGTH = 128M } -EXTERN(_start) -ENTRY(_start) +ENTRY(__rpx_start) SECTIONS { @@ -143,83 +142,302 @@ SECTIONS } > relmem . = ORIGIN(loadmem); - .fexports ALIGN(32) : { *(.fexports) } > loadmem - .dexports ALIGN(32) : { *(.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 - - .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 + .fexports ALIGN(32) : { KEEP( *(.fexports) ) } > loadmem + .dexports ALIGN(32) : { KEEP( *(.dexports) ) } > 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) : { + 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.mk b/share/wut.mk index 3b8790d14..62791cc55 100644 --- a/share/wut.mk +++ b/share/wut.mk @@ -8,6 +8,11 @@ ifneq ($(strip $(V)), 1) Q ?= @ endif +# ------------------------------------------------------------------------------ +# wut 1.0.0-beta9 and later ships wut_rules, in line with normal devkitPro +# makefiles - please use that! +$(warning "Using wut.mk is deprecated, and will be removed in a future release! Please switch to wut_rules as soon as possible - see https://github.com/devkitPro/wut/blob/master/samples/make/helloworld/Makefile for an example.") + # ------------------------------------------------------------------------------ # Toolchain includes and path setup @@ -45,9 +50,9 @@ WUT_CFLAGS := -mcpu=750 -meabi -mhard-float -isystem $(WUT_ROOT)/include # Defines to tell code about this environment WUT_CFLAGS += -D__WIIU__ -D__WUT__ -D__WUT_MAKEFILE__ # keep relocations, use wut linker script -WUT_LDFLAGS := -Wl,-q -Wl,-z,nocopyreloc -T $(WUT_ROOT)/share/wut.ld +WUT_LDFLAGS := -specs=$(WUT_ROOT)/share/wut.specs # Path for wut libraries, Always link against coreinit -WUT_LDFLAGS += -L$(WUT_ROOT)/lib -lcoreinit +WUT_LDFLAGS += -L$(WUT_ROOT)/lib -L$(WUT_ROOT)/lib/stubs -lwut # Append that to user-provided cflags and others CFLAGS += $(WUT_CFLAGS) @@ -67,8 +72,8 @@ ifneq ($(strip $(WUT_NO_LDGROUPS)), 1) endif # RPX and RPL need slightly different crts (init code) -%.rpx: LDFLAGS += -lwutcrt -%.rpl: LDFLAGS += -lwutcrtrpl +#%.rpx: LDFLAGS += -specs=$(WUT_ROOT)/share/rpx.specs +%.rpl: LDFLAGS += -specs=$(WUT_ROOT)/share/rpl.specs # ------------------------------------------------------------------------------ # Linking bits @@ -157,24 +162,28 @@ endif # Cafe heap to libc malloc. # To use: # LDFLAGS += $(WUT_NEWLIB_LDFLAGS) -WUT_NEWLIB_LDFLAGS := -Wl,--whole-archive -lwutnewlib -Wl,--no-whole-archive +#WUT_NEWLIB_LDFLAGS := -Wl,--whole-archive -lwutnewlib -Wl,--no-whole-archive +WUT_NEWLIB_LDFLAGS = $(warning "WUT_NEWLIB_LDFLAGS is deprecated and does nothing") # Wrap calls to malloc and friends with calls to Cafe's MEMDefaultHeap # functions, effectivley bypassing the libc heap for most allocations. Forces # libc heap to be very small. # To use: # LDFLAGS += $(WUT_MALLOC_LDFLAGS) -WUT_MALLOC_LDFLAGS := -Wl,--whole-archive -lwutmalloc -Wl,--no-whole-archive +#WUT_MALLOC_LDFLAGS := -Wl,--whole-archive -lwutmalloc -Wl,--no-whole-archive +WUT_MALLOC_LDFLAGS = $(warning "WUT_MALLOC_LDFLAGS is deprecated and does nothing") # Enable libstdc++ support. Allows use of C++11 threads, along with other C++ # functionality. Make sure to use WUT_NEWLIB_LDFLAGS too. # To use: # LDFLAGS += $(WUT_STDCPP_LDFLAGS) -WUT_STDCPP_LDFLAGS := -lstdc++ -WUT_STDCPP_LDFLAGS += -Wl,--whole-archive -lwutstdc++ -Wl,--no-whole-archive +#WUT_STDCPP_LDFLAGS := -lstdc++ +#WUT_STDCPP_LDFLAGS += -Wl,--whole-archive -lwutstdc++ -Wl,--no-whole-archive +WUT_STDCPP_LDFLAGS = $(warning "WUT_STDCPP_LDFLAGS is deprecated and does nothing") # Simple devoptab to allow filesystem access. Mounts the SD alongside the default # Cafe mounts (/vol/content etc.) # To use: # LDFLAGS += $(WUT_DEVOPTAB_LDFLAGS) -WUT_DEVOPTAB_LDFLAGS := -Wl,--whole-archive -lwutdevoptab -Wl,--no-whole-archive +#WUT_DEVOPTAB_LDFLAGS := -Wl,--whole-archive -lwutdevoptab -Wl,--no-whole-archive +WUT_DEVOPTAB_LDFLAGS = $(warning "WUT_DEVOPTAB_LDFLAGS is deprecated and does nothing") diff --git a/share/wut.specs b/share/wut.specs new file mode 100644 index 000000000..6b44cfdb3 --- /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.toolchain.cmake b/share/wut.toolchain.cmake index 9d7f908a9..5eed56dec 100644 --- a/share/wut.toolchain.cmake +++ b/share/wut.toolchain.cmake @@ -49,11 +49,22 @@ set(CMAKE_LINKER "powerpc-eabi-ld" CACHE PATH "") set(CMAKE_AR "powerpc-eabi-ar" CACHE PATH "") set(CMAKE_STRIP "powerpc-eabi-strip" CACHE PATH "") -set(WUT_C_FLAGS "-mcpu=750 -meabi -mhard-float -Wl,-q -D__WIIU__ -D__WUT__ -isystem \"${WUT_ROOT}/include\"") +set(WUT_C_FLAGS "-mcpu=750 -meabi -mhard-float -Wl,-q -D__WIIU__ -D__WUT__") set(CMAKE_C_FLAGS "${WUT_C_FLAGS}" CACHE STRING "") set(CMAKE_CXX_FLAGS "${WUT_C_FLAGS}" CACHE STRING "") set(CMAKE_ASM_FLAGS "${WUT_C_FLAGS}" CACHE STRING "") -set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc -T \"${WUT_ROOT}/share/wut.ld\" \"-L${WUT_ROOT}/lib\"" CACHE STRING "") +set(CMAKE_EXE_LINKER_FLAGS "\"-L${WUT_ROOT}/lib/stubs\" -specs=${WUT_ROOT}/share/wut.specs" CACHE STRING "") + +set(WUT_STANDARD_LIBRARIES "\"${WUT_ROOT}/lib/libwut.a\"") +set(CMAKE_C_STANDARD_LIBRARIES "${WUT_STANDARD_LIBRARIES}" CACHE STRING "") +set(CMAKE_CXX_STANDARD_LIBRARIES "${WUT_STANDARD_LIBRARIES}" CACHE STRING "") +set(CMAKE_ASM_STANDARD_LIBRARIES "${WUT_STANDARD_LIBRARIES}" CACHE STRING "") + +#for some reason cmake (3.14.3) doesn't appreciate having \" here +set(WUT_STANDARD_INCLUDE_DIRECTORIES "${WUT_ROOT}/include") +set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES "${WUT_STANDARD_INCLUDE_DIRECTORIES}" CACHE STRING "") +set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES "${WUT_STANDARD_INCLUDE_DIRECTORIES}" CACHE STRING "") +set(CMAKE_ASM_STANDARD_INCLUDE_DIRECTORIES "${WUT_STANDARD_INCLUDE_DIRECTORIES}" CACHE STRING "") # Setup root to exclude host system headers + libraries set(CMAKE_FIND_ROOT_PATH "${DEVKITPPC}" "${DEVKITPRO}/tools" "${DEVKITPRO}/portlibs/wiiu" "${DEVKITPRO}/portlibs/ppc" "${WUT_ROOT}/share") diff --git a/share/wut_rules b/share/wut_rules new file mode 100644 index 000000000..98fb9d130 --- /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 +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)