Repository: devkitPro/pacman-packages Branch: master Commit: e7929f400848 Files: 478 Total size: 3.2 MB Directory structure: gitextract_utdhukg8/ ├── .gitattributes ├── .gitignore ├── 3ds/ │ ├── SDL/ │ │ ├── PKGBUILD │ │ └── SDL-1.2.15.patch │ ├── SDL_gfx/ │ │ └── PKGBUILD │ ├── SDL_image/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── SDL_mixer/ │ │ └── PKGBUILD │ ├── SDL_ttf/ │ │ └── PKGBUILD │ ├── TinyXML2/ │ │ └── PKGBUILD │ ├── WildMidi/ │ │ ├── PKGBUILD │ │ └── wildmidi-0.4.3.patch │ ├── box2d/ │ │ └── PKGBUILD │ ├── bulletphysics/ │ │ ├── PKGBUILD │ │ └── bulletphysics.patch │ ├── bzip2/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── curl/ │ │ ├── .gitignore │ │ ├── PKGBUILD │ │ └── curl-8.4.0.patch │ ├── flac/ │ │ ├── .gitignore │ │ ├── PKGBUILD │ │ └── flac-1.3.4.patch │ ├── flite/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── freetype/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── giflib/ │ │ └── PKGBUILD │ ├── jansson/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── libarchive/ │ │ ├── PKGBUILD │ │ └── libarchive-3.7.4.patch │ ├── libconfig/ │ │ ├── .gitignore │ │ ├── PKGBUILD │ │ └── libconfig.patch │ ├── libfribidi/ │ │ └── PKGBUILD │ ├── libiconv/ │ │ ├── PKGBUILD │ │ └── libiconv-1.17.patch │ ├── libid3tag/ │ │ └── PKGBUILD │ ├── libjpeg-turbo/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── libjson-c/ │ │ ├── PKGBUILD │ │ └── json-c-0.16.patch │ ├── liblzma/ │ │ └── PKGBUILD │ ├── libmad/ │ │ └── PKGBUILD │ ├── libmodplug/ │ │ ├── PKGBUILD │ │ └── libmodplug-0.8.9.0.patch │ ├── libogg/ │ │ └── PKGBUILD │ ├── libopus/ │ │ └── PKGBUILD │ ├── libpng/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── libsidplay/ │ │ ├── PKGBUILD │ │ └── libsidplay-1.36.60.patch │ ├── libtheora/ │ │ ├── PKGBUILD │ │ └── libtheora-1.2.0.patch │ ├── libvorbisidec/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── libxmp/ │ │ └── PKGBUILD │ ├── libzstd/ │ │ ├── PKGBUILD │ │ └── zstd-1.5.5.patch │ ├── lua51/ │ │ └── PKGBUILD │ ├── lz4/ │ │ └── PKGBUILD │ ├── mbedtls/ │ │ ├── .gitignore │ │ ├── PKGBUILD │ │ └── mbedtls-2.28.8.patch │ ├── mikmod/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── mpg123/ │ │ ├── PKGBUILD │ │ └── mpg123-1.31.3.patch │ ├── opusfile/ │ │ └── PKGBUILD │ ├── physfs/ │ │ ├── PKGBUILD │ │ └── physfs-3.2.0.patch │ ├── pkg-config/ │ │ ├── .gitignore │ │ ├── PKGBUILD │ │ └── pkg-config.in │ ├── wslay/ │ │ └── PKGBUILD │ ├── yaml_cpp/ │ │ └── PKGBUILD │ └── zlib/ │ ├── .gitignore │ └── PKGBUILD ├── 3ds-examples/ │ └── PKGBUILD ├── README.md ├── armv4t/ │ ├── bzip2/ │ │ └── PKGBUILD │ ├── flac/ │ │ ├── PKGBUILD │ │ └── flac-1.3.2.patch │ ├── flite/ │ │ └── PKGBUILD │ ├── freetype/ │ │ └── PKGBUILD │ ├── libconfig/ │ │ ├── PKGBUILD │ │ └── libconfig.patch │ ├── libexpat/ │ │ └── PKGBUILD │ ├── libid3tag/ │ │ └── PKGBUILD │ ├── liblzma/ │ │ └── PKGBUILD │ ├── libmad/ │ │ ├── PKGBUILD │ │ └── libmad-0.15.1b.patch │ ├── libogg/ │ │ └── PKGBUILD │ ├── libpng/ │ │ └── PKGBUILD │ ├── libtheora/ │ │ ├── PKGBUILD │ │ └── libtheora-1.2.0.patch │ ├── libvorbisidec/ │ │ └── PKGBUILD │ ├── libxmp/ │ │ ├── PKGBUILD │ │ └── libxmp.patch │ ├── mikmod/ │ │ └── PKGBUILD │ ├── mpg123/ │ │ ├── PKGBUILD │ │ ├── mpg123-1.25.10.patch │ │ └── mpg123-1.31.3.patch │ ├── pkg-config/ │ │ ├── PKGBUILD │ │ └── pkg-config.in │ └── zlib/ │ └── PKGBUILD ├── calico/ │ └── PKGBUILD ├── citro2d/ │ └── PKGBUILD ├── citro3d/ │ └── PKGBUILD ├── cmake/ │ ├── 3ds/ │ │ ├── 3DS.cmake │ │ ├── Nintendo3DS.cmake │ │ ├── PKGBUILD │ │ └── arm-none-eabi-cmake │ ├── catnip/ │ │ └── PKGBUILD │ ├── common-utils/ │ │ ├── Generic-dkP.cmake │ │ ├── PKGBUILD │ │ ├── dkp-asset-folder.cmake │ │ ├── dkp-custom-target.cmake │ │ ├── dkp-embedded-binary.cmake │ │ ├── dkp-impl-helpers.cmake │ │ ├── dkp-initialize-path.cmake │ │ ├── dkp-linker-utils.cmake │ │ ├── dkp-rule-overrides.cmake │ │ └── dkp-toolchain-common.cmake │ ├── devkita64/ │ │ ├── PKGBUILD │ │ ├── aarch64-none-elf-cmake │ │ └── devkitA64.cmake │ ├── devkitarm/ │ │ ├── PKGBUILD │ │ ├── arm-none-eabi-cmake │ │ ├── devkitARM.cmake │ │ ├── dkp-arm-mode-wrapper │ │ ├── dkp-gba-ds-common.cmake │ │ └── dkp-gba-ds-utils.cmake │ ├── devkitppc/ │ │ ├── PKGBUILD │ │ ├── devkitPPC.cmake │ │ └── powerpc-eabi-cmake │ ├── gamecube/ │ │ ├── GameCube.cmake │ │ ├── NintendoGameCube.cmake │ │ ├── PKGBUILD │ │ └── powerpc-eabi-cmake │ ├── gba/ │ │ ├── GBA.cmake │ │ ├── NintendoGBA.cmake │ │ ├── PKGBUILD │ │ └── arm-none-eabi-cmake │ ├── nds/ │ │ ├── NDS.cmake │ │ ├── NintendoDS.cmake │ │ ├── PKGBUILD │ │ └── arm-none-eabi-cmake │ ├── ogc/ │ │ ├── PKGBUILD │ │ ├── libogc.cmake │ │ └── ogc-common.cmake │ ├── switch/ │ │ ├── NintendoSwitch.cmake │ │ ├── PKGBUILD │ │ ├── Switch.cmake │ │ └── aarch64-none-elf-cmake │ ├── wii/ │ │ ├── NintendoWii.cmake │ │ ├── PKGBUILD │ │ ├── Wii.cmake │ │ └── powerpc-eabi-cmake │ └── wiiu/ │ ├── CafeOS.cmake │ ├── PKGBUILD │ ├── WiiU.cmake │ └── powerpc-eabi-cmake ├── default-arm7/ │ └── PKGBUILD ├── deko3d/ │ └── PKGBUILD ├── devkita64/ │ ├── devkitA64/ │ │ └── PKGBUILD │ ├── devkita64-rules/ │ │ └── PKGBUILD │ └── newlib/ │ └── PKGBUILD ├── devkitarm/ │ ├── devkitARM/ │ │ └── PKGBUILD │ ├── devkitarm-crtls/ │ │ └── PKGBUILD │ ├── devkitarm-rules/ │ │ └── PKGBUILD │ └── newlib/ │ └── PKGBUILD ├── devkitppc/ │ ├── devkitPPC/ │ │ └── PKGBUILD │ ├── devkitppc-crtls/ │ │ └── PKGBUILD │ ├── devkitppc-rules/ │ │ └── PKGBUILD │ └── newlib/ │ └── PKGBUILD ├── dkp-meson-scripts/ │ ├── PKGBUILD │ ├── meson-cross.sh │ └── meson-toolchain.sh ├── dkp-toolchain-vars/ │ ├── 3dsvars.sh │ ├── PKGBUILD │ ├── armv4tvars.sh │ ├── cubevars.sh │ ├── devkita64.sh │ ├── devkitarm.sh │ ├── devkitppc.sh │ ├── ndsvars.sh │ ├── portlibs_prefix.sh │ ├── ppcvars.sh │ ├── switchvars.sh │ ├── wiiuvars.sh │ └── wiivars.sh ├── dswifi/ │ └── PKGBUILD ├── gamecube/ │ ├── SDL/ │ │ ├── PKGBUILD │ │ ├── SDL-1.2.15.patch │ │ └── config.site │ ├── SDL2/ │ │ ├── PKGBUILD │ │ └── SDL2-2.28.5.patch │ ├── SDL2_gfx/ │ │ └── PKGBUILD │ ├── SDL2_image/ │ │ ├── Makefile.in.patch │ │ └── PKGBUILD │ ├── SDL2_mixer/ │ │ ├── PKGBUILD │ │ └── sdl2_mixer-config.cmake.in.patch │ ├── SDL2_ttf/ │ │ └── PKGBUILD │ ├── SDL_gfx/ │ │ ├── PKGBUILD │ │ └── SDL_gfx-2.0.25.patch │ ├── SDL_image/ │ │ └── PKGBUILD │ ├── SDL_mixer/ │ │ ├── PKGBUILD │ │ └── SDL_mixer-1.2.12.patch │ ├── SDL_ttf/ │ │ ├── PKGBUILD │ │ └── SDL_ttf-2.0.11.patch │ ├── freeglut/ │ │ ├── PKGBUILD │ │ └── freeglut-3.6.0.patch │ ├── glu/ │ │ ├── LICENSE │ │ └── PKGBUILD │ ├── opengx/ │ │ └── PKGBUILD │ ├── physfs/ │ │ ├── PKGBUILD │ │ └── physfs-3.2.0.patch │ └── pkg-config/ │ ├── PKGBUILD │ └── pkg-config.in ├── gamecube-examples/ │ └── PKGBUILD ├── gba/ │ └── pkg-config/ │ ├── PKGBUILD │ └── pkg-config.in ├── gba-examples/ │ └── PKGBUILD ├── gp2x/ │ ├── gp2x-core/ │ │ └── PKGBUILD │ ├── gp2x-examples/ │ │ └── PKGBUILD │ ├── libfat/ │ │ └── PKGBUILD │ ├── liborcus/ │ │ └── PKGBUILD │ └── pkg-config/ │ ├── PKGBUILD │ └── pkg-config.in ├── gp32-examples/ │ └── PKGBUILD ├── libctru/ │ └── PKGBUILD ├── libfat/ │ └── PKGBUILD ├── libfilesystem/ │ └── PKGBUILD ├── libgba/ │ └── PKGBUILD ├── libgxflux/ │ ├── PKGBUILD │ └── libgxflux-destdir.patch ├── libmirko/ │ └── PKGBUILD ├── libnds/ │ ├── 0001-fix-within-comment.patch │ └── PKGBUILD ├── libnx/ │ └── PKGBUILD ├── libogc/ │ └── PKGBUILD ├── libtonc/ │ └── PKGBUILD ├── maxmod/ │ └── PKGBUILD ├── nds/ │ ├── bzip2/ │ │ └── PKGBUILD │ ├── freetype/ │ │ └── PKGBUILD │ ├── libexpat/ │ │ └── PKGBUILD │ ├── libmad/ │ │ ├── PKGBUILD │ │ └── libmad-0.15.1b.patch │ ├── libpng/ │ │ └── PKGBUILD │ ├── pkg-config/ │ │ ├── PKGBUILD │ │ └── pkg-config.in │ └── zlib/ │ └── PKGBUILD ├── nds-examples/ │ └── PKGBUILD ├── pkgbuild-scripts/ │ ├── .gitignore │ ├── PKGBUILD │ └── pkgbuild-scripts.install ├── ppc/ │ ├── TinyXML2/ │ │ └── PKGBUILD │ ├── box2d/ │ │ └── PKGBUILD │ ├── brotli/ │ │ ├── PKGBUILD │ │ └── brotli-1.2.0.patch │ ├── bzip2/ │ │ └── PKGBUILD │ ├── faad2/ │ │ └── PKGBUILD │ ├── flac/ │ │ └── PKGBUILD │ ├── freetype/ │ │ └── PKGBUILD │ ├── giflib/ │ │ └── PKGBUILD │ ├── glm/ │ │ ├── PKGBUILD │ │ └── glm-1.0.2-ppc.patch │ ├── harfbuzz/ │ │ └── PKGBUILD │ ├── jansson/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── json-cpp/ │ │ └── PKGBUILD │ ├── libconfig/ │ │ └── PKGBUILD │ ├── libexpat/ │ │ └── PKGBUILD │ ├── libfribidi/ │ │ └── PKGBUILD │ ├── libgd/ │ │ ├── PKGBUILD │ │ └── libgd-2.3.3.patch │ ├── libjpeg-turbo/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── liblzma/ │ │ └── PKGBUILD │ ├── libmad/ │ │ ├── PKGBUILD │ │ ├── frame_length.patch │ │ ├── optimise.diff │ │ └── pkg-config.patch │ ├── libmodplug/ │ │ └── PKGBUILD │ ├── libogg/ │ │ └── PKGBUILD │ ├── libopus/ │ │ └── PKGBUILD │ ├── libpng/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── libtheora/ │ │ ├── PKGBUILD │ │ ├── config.guess │ │ └── config.sub │ ├── libvorbis/ │ │ └── PKGBUILD │ ├── libvorbisidec/ │ │ └── PKGBUILD │ ├── libwebp/ │ │ └── PKGBUILD │ ├── libzip/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── lua51/ │ │ └── PKGBUILD │ ├── lz4/ │ │ └── PKGBUILD │ ├── mpg123/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── mxml/ │ │ └── PKGBUILD │ ├── ode/ │ │ └── PKGBUILD │ ├── opusfile/ │ │ └── PKGBUILD │ ├── pkg-config/ │ │ ├── .gitignore │ │ ├── PKGBUILD │ │ └── pkg-config.in │ ├── yaml_cpp/ │ │ └── PKGBUILD │ ├── zlib/ │ │ ├── .gitignore │ │ └── PKGBUILD │ └── zstd/ │ ├── PKGBUILD │ └── zstd-1.5.7.patch ├── switch/ │ ├── SDL2/ │ │ ├── .gitignore │ │ ├── PKGBUILD │ │ └── SDL2-2.28.5.patch │ ├── SDL2_gfx/ │ │ ├── PKGBUILD │ │ ├── config.guess │ │ └── config.sub │ ├── SDL2_image/ │ │ ├── Makefile.in.patch │ │ └── PKGBUILD │ ├── SDL2_mixer/ │ │ └── PKGBUILD │ ├── SDL2_net/ │ │ └── PKGBUILD │ ├── SDL2_ttf/ │ │ └── PKGBUILD │ ├── TinyXML2/ │ │ └── PKGBUILD │ ├── box2d/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── bulletphysics/ │ │ ├── PKGBUILD │ │ └── bulletphysics.patch │ ├── bzip2/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── curl/ │ │ ├── .gitignore │ │ ├── PKGBUILD │ │ └── switch-curl.patch │ ├── dav1d/ │ │ ├── PKGBUILD │ │ └── dav1d.patch │ ├── enet/ │ │ └── PKGBUILD │ ├── ffmpeg/ │ │ ├── PKGBUILD │ │ ├── ffmpeg-7.1.patch │ │ └── tls.patch │ ├── flac/ │ │ ├── .gitignore │ │ ├── PKGBUILD │ │ └── flac-1.3.2.patch │ ├── freetype/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── giflib/ │ │ └── PKGBUILD │ ├── glad/ │ │ └── PKGBUILD │ ├── glfw/ │ │ ├── PKGBUILD │ │ └── switch-glfw-3.3.4.patch │ ├── glm/ │ │ └── PKGBUILD │ ├── glu/ │ │ ├── LICENSE │ │ ├── PKGBUILD │ │ └── glu-9.0.3-meson-enable-egl-arg.patch │ ├── harfbuzz/ │ │ └── PKGBUILD │ ├── jansson/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── libarchive/ │ │ ├── PKGBUILD │ │ └── libarchive-3.7.2.patch │ ├── libass/ │ │ └── PKGBUILD │ ├── libavif/ │ │ ├── CMakeLists.txt.patch │ │ └── PKGBUILD │ ├── libconfig/ │ │ ├── .gitignore │ │ ├── PKGBUILD │ │ └── libconfig.patch │ ├── libdrm_nouveau/ │ │ └── PKGBUILD │ ├── libexpat/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── libfribidi/ │ │ └── PKGBUILD │ ├── libgd/ │ │ ├── PKGBUILD │ │ └── libgd-2.2.5-nosyslog.patch │ ├── libjpeg-turbo/ │ │ ├── .gitignore │ │ ├── PKGBUILD │ │ └── libjpeg-turbo.patch │ ├── libjson-c/ │ │ ├── PKGBUILD │ │ └── json-c-0.16.patch │ ├── liblzma/ │ │ └── PKGBUILD │ ├── liblzo2/ │ │ └── PKGBUILD │ ├── libmad/ │ │ └── PKGBUILD │ ├── libmikmod/ │ │ ├── PKGBUILD │ │ └── libmikmod-switch-support.patch │ ├── libmodplug/ │ │ ├── .gitignore │ │ ├── PKGBUILD │ │ └── libmodplug-0.8.9.0.patch │ ├── libmpeg2/ │ │ └── PKGBUILD │ ├── libmpv/ │ │ ├── PKGBUILD │ │ └── mpv.patch │ ├── libogg/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── libopus/ │ │ └── PKGBUILD │ ├── libpcre2/ │ │ └── PKGBUILD │ ├── libplacebo/ │ │ └── PKGBUILD │ ├── libpng/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── libsamplerate/ │ │ ├── PKGBUILD │ │ └── libsamplerate-0.1.9.patch │ ├── libsodium/ │ │ └── PKGBUILD │ ├── libssh2/ │ │ ├── PKGBUILD │ │ └── disable-tests.patch │ ├── libtheora/ │ │ ├── PKGBUILD │ │ ├── config.guess │ │ └── config.sub │ ├── libtimidity/ │ │ └── PKGBUILD │ ├── libvorbis/ │ │ ├── .gitignore │ │ └── PKGBUILD │ ├── libvorbisidec/ │ │ └── PKGBUILD │ ├── libvpx/ │ │ ├── PKGBUILD │ │ └── libvpx.patch │ ├── libwebp/ │ │ └── PKGBUILD │ ├── libxml2/ │ │ └── PKGBUILD │ ├── libzstd/ │ │ └── PKGBUILD │ ├── lua51/ │ │ └── PKGBUILD │ ├── lwext4/ │ │ ├── PKGBUILD │ │ └── lwext4-1.0.0.patch │ ├── lz4/ │ │ └── PKGBUILD │ ├── mbedtls/ │ │ ├── PKGBUILD │ │ └── mbedtls-2.28.10.patch │ ├── mesa/ │ │ ├── OpenGLConfig.cmake │ │ ├── PKGBUILD │ │ ├── glX_XML.py.patch │ │ ├── gl_XML.py.patch │ │ └── switch-mesa-20.1.0-5.patch │ ├── miniupnpc/ │ │ ├── PKGBUILD │ │ └── miniupnpc.patch │ ├── mpg123/ │ │ ├── .gitignore │ │ ├── PKGBUILD │ │ └── mpg123-1.31.3.patch │ ├── mupdf/ │ │ ├── PKGBUILD │ │ └── mupdf.patch │ ├── ntfs-3g/ │ │ ├── PKGBUILD │ │ └── ntfs-3g-2022.10.3.patch │ ├── ode/ │ │ └── PKGBUILD │ ├── oniguruma/ │ │ └── PKGBUILD │ ├── openal-soft/ │ │ ├── PKGBUILD │ │ └── avoid-readlink.patch │ ├── opusfile/ │ │ └── PKGBUILD │ ├── physfs/ │ │ ├── PKGBUILD │ │ └── physfs-3.2.0.patch │ ├── pkg-config/ │ │ ├── .gitignore │ │ ├── PKGBUILD │ │ └── pkg-config.in │ ├── smpeg2/ │ │ ├── PKGBUILD │ │ ├── config.guess │ │ ├── config.sub │ │ └── smpeg2-2.0.0.patch │ ├── wslay/ │ │ └── PKGBUILD │ ├── xxhash/ │ │ └── PKGBUILD │ ├── zlib/ │ │ ├── .gitignore │ │ └── PKGBUILD │ └── zziplib/ │ ├── PKGBUILD │ └── zziplib-0.13.78.patch ├── switch-examples/ │ └── PKGBUILD ├── wii/ │ ├── SDL/ │ │ ├── PKGBUILD │ │ ├── SDL-1.2.15.patch │ │ └── config.site │ ├── SDL2/ │ │ ├── PKGBUILD │ │ └── SDL2-2.28.5.patch │ ├── SDL2_gfx/ │ │ └── PKGBUILD │ ├── SDL2_image/ │ │ ├── Makefile.in.patch │ │ └── PKGBUILD │ ├── SDL2_mixer/ │ │ ├── PKGBUILD │ │ └── sdl2_mixer-config.cmake.in.patch │ ├── SDL2_ttf/ │ │ └── PKGBUILD │ ├── SDL_gfx/ │ │ └── PKGBUILD │ ├── SDL_image/ │ │ └── PKGBUILD │ ├── SDL_mixer/ │ │ ├── PKGBUILD │ │ └── SDL_mixer-1.2.12.patch │ ├── SDL_ttf/ │ │ ├── PKGBUILD │ │ └── SDL_ttf-2.0.11.patch │ ├── freeglut/ │ │ ├── PKGBUILD │ │ └── freeglut-3.6.0.patch │ ├── glu/ │ │ ├── LICENSE │ │ └── PKGBUILD │ ├── opengx/ │ │ └── PKGBUILD │ ├── physfs/ │ │ ├── PKGBUILD │ │ └── physfs-3.2.0.patch │ └── pkg-config/ │ ├── PKGBUILD │ └── pkg-config.in └── wii-examples/ └── PKGBUILD ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitattributes ================================================ * text=lf ================================================ FILE: .gitignore ================================================ sources packages *.tar.xz src pkg *.pkg.tar.xz* *.tar.gz *.tar.bz2 *.tar.zst *~ ================================================ FILE: 3ds/SDL/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=3ds-sdl pkgver=1.2.15 pkgrel=19 pkgdesc="A library for portable low-level access to a video framebuffer, audio output, mouse, and keyboard (Nintendo 3DS port)" arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') source=("${url}/release/SDL-${pkgver}.tar.gz" "SDL-1.2.15.patch") groups=('3ds-portlibs' '3ds-sdl-libs') prepare() { cd SDL-$pkgver source /opt/devkitpro/3dsvars.sh patch -p1 -i $srcdir/SDL-1.2.15.patch ./autogen.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static --enable-n3ds } build() { cd SDL-$pkgver source /opt/devkitpro/3dsvars.sh make } package() { cd SDL-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share } sha256sums=('d6d316a793e5e348155f0dd93b979798933fb98aa1edebcc108829d6474aad00' '83941419c8fc87a280b1d45db595b720fe190959a0094c727a566d2b9de20804') ================================================ FILE: 3ds/SDL/SDL-1.2.15.patch ================================================ diff --git a/build-scripts/makedep.sh b/build-scripts/makedep.sh index 3b3863b4c2..f24b851b2f 100755 --- a/build-scripts/makedep.sh +++ b/build-scripts/makedep.sh @@ -42,13 +42,38 @@ for src in $SOURCES do echo "Generating dependencies for $src" ext=`echo $src | sed 's|.*\.\(.*\)|\1|'` obj=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1.lo|g"` - echo "\$(objects)/$obj: $src \\" >>${output}.new - + if test x"$ext" != x"pica"; then + echo "\$(objects)/$obj: $src \\" >>${output}.new + else + stem=`echo $src | sed "s|^.*/\([^ ]*\)\..*|\1|g"` + obj=$stem.shbin.o + hdr=${stem}_shbin.h + shbin=$stem.shbin + cat >>${output}.new <<__EOF__ +\$(objects)/$stem.shbin.lo: \$(objects)/$obj + @echo "# $stem.shbin.lo - a libtool object file" > \$@ + @echo "# Generated by ltmain.sh (GNU libtool) 2.2.6" >> \$@ + @echo "pic_object=none" >> \$@ + @echo "non_pic_object='$stem.shbin.o'" >> \$@ + +\$(objects)/$obj \$(objects)/$hdr: \$(objects)/$shbin + @echo "extern const u8 ${stem}_shbin[];" > \$(objects)/$hdr + @echo "extern const u8 ${stem}_shbin_end[];" >> \$(objects)/$hdr + @echo "extern const u32 ${stem}_shbin_size;" >> \$(objects)/$hdr + @bin2s \$(objects)/$shbin | \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -x assembler-with-cpp -c - -o \$(objects)/$obj + + +\$(objects)/$shbin: $src + picasso -o \$@ \$< +__EOF__ + fi # No search to be done with Windows resource files if test x"$ext" != x"rc"; then search_deps $src | sort | uniq >>${output}.new fi case $ext in + pica) + ;; c) cat >>${output}.new <<__EOF__ \$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) -c $src -o \$@ @@ -89,5 +114,7 @@ __EOF__ esac echo "" >>${output}.new done +echo "\$(objects)/SDL_n3dsvideo.lo : \$(objects)/vshader_shbin.h" >>${output}.new + mv ${output}.new ${output} rm -f ${cache_prefix}* diff --git a/configure.in b/configure.in index 08c8e1e97c..7192c31af5 100644 --- a/configure.in +++ b/configure.in @@ -62,7 +62,7 @@ AC_PROG_MAKE_SET AC_CHECK_TOOL(WINDRES, [windres], [:]) dnl Set up the compiler and linker flags -INCLUDE="-I$srcdir/include" +INCLUDE="-I$srcdir/include -I\$(objects)" if test x$srcdir != x.; then # Remove SDL_config.h from the source directory, since it's the # default one, and we want to include the one that we generate. @@ -925,6 +925,41 @@ AC_HELP_STRING([--enable-ipod], [configure SDL to work with iPodLinux [[default= fi } +Checkn3ds() +{ + AC_ARG_ENABLE(n3ds, + AC_HELP_STRING([--enable-n3ds], [configure SDL to work with n3ds [[default=no]]]),, enable_n3ds=no) + + if test x$enable_n3ds = xyes; then + ARCH=n3ds + N3DS_CFLAGS="-ffunction-sections -fdata-sections -march=armv6k \ + -mtune=mpcore -mfloat-abi=hard -mword-relocations \ + -I$DEVKITPRO/libctru/include -D__3DS__" + EXTRA_CFLAGS="$EXTRA_CFLAGS $N3DS_CFLAGS" + CFLAGS="$CFLAGS $N3DS_CFLAGS" + SDL_CFLAGS="$SDL_CFLAGS $N3DS_CFLAGS" + SDL_LIBS="-march=armv6k -mfloat-abi=hard \ + -L${DEVKITPRO}/portlibs/3ds $SDL_LIBS \ + -L${DEVKITPRO}/libctru/lib -lcitro3d -lctru" + AC_DEFINE(SDL_TIMER_N3DS) + SOURCES="$SOURCES $srcdir/src/timer/n3ds/*.c" + have_timers=yes + AC_DEFINE(SDL_AUDIO_DRIVER_N3DS) + SOURCES="$SOURCES $srcdir/src/audio/n3ds/*.c" + have_audio=yes + AC_DEFINE(SDL_JOYSTICK_N3DS) + SOURCES="$SOURCES $srcdir/src/joystick/n3ds/*.c" + have_joystick=yes + AC_DEFINE(SDL_THREAD_N3DS) + SOURCES="$SOURCES $srcdir/src/thread/n3ds/*.c" + have_threads=yes + AC_DEFINE(SDL_VIDEO_DRIVER_N3DS) + SOURCES="$SOURCES $srcdir/src/video/n3ds/vshader.pica" + SOURCES="$SOURCES $srcdir/src/video/n3ds/*.c" + have_video=yes + fi +} + dnl Find the nanox include and library directories CheckNANOX() { @@ -2314,6 +2349,9 @@ AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]] dnl Set up the configuration based on the host platform! case "$host" in + *arm-none-eabi*) + Checkn3ds + ;; arm-*-elf*) # FIXME: Can we get more specific for iPodLinux? ARCH=linux CheckDummyVideo @@ -2885,6 +2923,7 @@ OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'` OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'` OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.S,$(objects)/\1.lo,g'` OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.lo,g'` +OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.pica,$(objects)/\1.shbin.lo,g'` SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'` SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'` diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 8bb1773c0e..d6f349499c 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -185,6 +185,7 @@ #undef SDL_AUDIO_DRIVER_SNDMGR #undef SDL_AUDIO_DRIVER_SUNAUDIO #undef SDL_AUDIO_DRIVER_WAVEOUT +#undef SDL_AUDIO_DRIVER_N3DS /* Enable various cdrom drivers */ #undef SDL_CDROM_AIX @@ -218,6 +219,7 @@ #undef SDL_JOYSTICK_WINMM #undef SDL_JOYSTICK_USBHID #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H +#undef SDL_JOYSTICK_N3DS /* Enable various shared object loading systems */ #undef SDL_LOADSO_BEOS @@ -239,6 +241,7 @@ #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP #undef SDL_THREAD_SPROC #undef SDL_THREAD_WIN32 +#undef SDL_THREAD_N3DS /* Enable various timer systems */ #undef SDL_TIMER_BEOS @@ -251,6 +254,7 @@ #undef SDL_TIMER_UNIX #undef SDL_TIMER_WIN32 #undef SDL_TIMER_WINCE +#undef SDL_TIMER_N3DS /* Enable various video drivers */ #undef SDL_VIDEO_DRIVER_AALIB @@ -293,6 +297,7 @@ #undef SDL_VIDEO_DRIVER_X11_XRANDR #undef SDL_VIDEO_DRIVER_X11_XV #undef SDL_VIDEO_DRIVER_XBIOS +#undef SDL_VIDEO_DRIVER_N3DS /* Enable OpenGL support */ #undef SDL_VIDEO_OPENGL diff --git a/include/SDL_keyboard.h b/include/SDL_keyboard.h index 9d7129c526..b03422411e 100644 --- a/include/SDL_keyboard.h +++ b/include/SDL_keyboard.h @@ -125,7 +125,6 @@ extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); */ extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key); - /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index 35a4fdde59..5d8b620459 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -147,7 +147,7 @@ typedef enum { DUMMY_ENUM_VALUE } SDL_DUMMY_ENUM; -#ifndef __NDS__ +#if !defined(__NDS__) && !defined(__3DS__) SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); #endif /*@}*/ diff --git a/include/SDL_video.h b/include/SDL_video.h index f9c4e07025..b2d0642843 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -142,7 +142,16 @@ typedef struct SDL_Surface { #define SDL_OPENGL 0x00000002 /**< Create an OpenGL rendering context */ #define SDL_OPENGLBLIT 0x0000000A /**< Create an OpenGL rendering context and use it for blitting */ #define SDL_RESIZABLE 0x00000010 /**< This video mode may be resized */ -#define SDL_NOFRAME 0x00000020 /**< No window caption or edge frame */ +#define SDL_NOFRAME 0x00000020 /**< No window caption or edge frame */ +#ifdef __3DS__ +#define SDL_TOPSCR 0x00100000 /**< 3DS Top Screen mode */ +#define SDL_BOTTOMSCR 0x00200000 /**< 3DS Bottom Screen mode */ +#define SDL_DUALSCR 0x00300000 /**< 3DS Top+Bottom Screen mode */ +#define SDL_FITWIDTH 0x00400000 /**> Render a resized surface to fit systen screen width */ +#define SDL_FITHEIGHT 0x00800000 /**> Render a resized surface to fit systen screen height */ +#define SDL_CONSOLETOP 0x00040000 /**> Enale console output on Top screen */ +#define SDL_CONSOLEBOTTOM 0x00080000 /**> Enale console output on Bottom screen */ +#endif /*@}*/ /** Used internally (read-only) */ diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index beb26e0b4d..4fd548c70c 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -104,6 +104,9 @@ static AudioBootStrap *bootstrap[] = { #if SDL_AUDIO_DRIVER_NDS &NDSAUD_bootstrap, #endif +#if SDL_AUDIO_DRIVER_N3DS + &N3DSAUD_bootstrap, +#endif #if SDL_AUDIO_DRIVER_MMEAUDIO &MMEAUDIO_bootstrap, #endif diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 74ac21df04..2cba86dae5 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -170,6 +170,9 @@ extern AudioBootStrap DCAUD_bootstrap; #if SDL_AUDIO_DRIVER_NDS extern AudioBootStrap NDSAUD_bootstrap; #endif +#if SDL_AUDIO_DRIVER_N3DS +extern AudioBootStrap N3DSAUD_bootstrap; +#endif #if SDL_AUDIO_DRIVER_MMEAUDIO extern AudioBootStrap MMEAUDIO_bootstrap; #endif diff --git a/src/audio/n3ds/SDL_n3dsaudio.c b/src/audio/n3ds/SDL_n3dsaudio.c new file mode 100644 index 0000000000..019f205bab --- /dev/null +++ b/src/audio/n3ds/SDL_n3dsaudio.c @@ -0,0 +1,339 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org + + This file written by Ryan C. Gordon (icculus@icculus.org) +*/ +#include "SDL_config.h" + +/* Output audio to nowhere... */ + +#include "SDL_rwops.h" +#include "SDL_timer.h" +#include "SDL_audio.h" +#include "../SDL_audiomem.h" +#include "../SDL_audio_c.h" +#include "../SDL_audiodev_c.h" +#include "SDL_n3dsaudio.h" + +#include <3ds.h> +#include + +/* The tag name used by N3DS audio */ +#define N3DSAUD_DRIVER_NAME "n3ds" + +static dspHookCookie g_dspHook; +static SDL_AudioDevice *g_audDev; + +/* Audio driver functions */ +static int N3DSAUD_OpenAudio(_THIS, SDL_AudioSpec *spec); +static void N3DSAUD_WaitAudio(_THIS); +static void N3DSAUD_PlayAudio(_THIS); +static Uint8 *N3DSAUD_GetAudioBuf(_THIS); +static void N3DSAUD_CloseAudio(_THIS); + +/* Audio driver bootstrap functions */ +static int N3DSAUD_Available(void) +{ + return(1); +} + +static inline void contextLock(_THIS) +{ + LightLock_Lock(&this->hidden->lock); +} + +static inline void contextUnlock(_THIS) +{ + LightLock_Unlock(&this->hidden->lock); +} + +static void N3DSAUD_LockAudio(_THIS) +{ + SDL_mutexP(this->mixer_lock); +} + +static void N3DSAUD_UnlockAudio(_THIS) +{ + SDL_mutexV(this->mixer_lock); +} + +static void N3DSAUD_DeleteDevice(SDL_AudioDevice *device) +{ + if ( device->hidden->mixbuf != NULL ) { + SDL_FreeAudioMem(device->hidden->mixbuf); + device->hidden->mixbuf = NULL; + } + if ( device->hidden->waveBuf[0].data_vaddr!= NULL ) { + linearFree((void*)device->hidden->waveBuf[0].data_vaddr); + device->hidden->waveBuf[0].data_vaddr = NULL; + } + + ndspExit(); + + SDL_free(device->hidden); + SDL_free(device); +} + +static SDL_AudioDevice *N3DSAUD_CreateDevice(int devindex) +{ + SDL_AudioDevice *this; + + /* Initialize all variables that we clean on shutdown */ + this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); + if ( this ) { + SDL_memset(this, 0, (sizeof *this)); + this->hidden = (struct SDL_PrivateAudioData *) + SDL_malloc((sizeof *this->hidden)); + } + if ( (this == NULL) || (this->hidden == NULL) ) { + SDL_OutOfMemory(); + if ( this ) { + SDL_free(this); + } + return(0); + } + + //start 3ds DSP init + Result rc = ndspInit(); + if (R_FAILED(rc)) { + SDL_free(this); + if ((R_SUMMARY(rc) == RS_NOTFOUND) && (R_MODULE(rc) == RM_DSP)) + SDL_SetError("DSP init failed: dspfirm.cdc missing!"); + else + SDL_SetError("DSP init failed. Error code: 0x%X", rc); + return(0); + } + + /* Initialize internal state */ + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); + LightLock_Init(&this->hidden->lock); + CondVar_Init(&this->hidden->cv); + + /* Set the function pointers */ + this->OpenAudio = N3DSAUD_OpenAudio; + this->WaitAudio = N3DSAUD_WaitAudio; + this->PlayAudio = N3DSAUD_PlayAudio; + this->GetAudioBuf = N3DSAUD_GetAudioBuf; + this->CloseAudio = N3DSAUD_CloseAudio; + this->LockAudio = N3DSAUD_LockAudio; + this->UnlockAudio = N3DSAUD_UnlockAudio; + this->free = N3DSAUD_DeleteDevice; + + return this; +} + +AudioBootStrap N3DSAUD_bootstrap = { + N3DSAUD_DRIVER_NAME, "SDL N3DS audio driver", + N3DSAUD_Available, N3DSAUD_CreateDevice +}; + +/* called by ndsp thread on each audio frame */ +static void audioFrameFinished(void *context) +{ + SDL_AudioDevice *this = (SDL_AudioDevice *) context; + + contextLock(this); + + bool shouldBroadcast = false; + unsigned i; + for (i = 0; i < NUM_BUFFERS; i ++) { + if (this->hidden->waveBuf[i].status == NDSP_WBUF_DONE) { + this->hidden->waveBuf[i].status = NDSP_WBUF_FREE; + shouldBroadcast = true; + } + } + + if (shouldBroadcast) + CondVar_Broadcast(&this->hidden->cv); + + contextUnlock(this); +} + +/* This function blocks until it is possible to write a full sound buffer */ +static void N3DSAUD_WaitAudio(_THIS) +{ + contextLock(this); + while (!this->hidden->isCancelled && this->hidden->waveBuf[this->hidden->nextbuf].status != NDSP_WBUF_FREE) { + CondVar_Wait(&this->hidden->cv, &this->hidden->lock); + } + contextUnlock(this); +} + +static void N3DSAUD_DspHook(DSP_HookType hook) +{ + if (hook == DSPHOOK_ONCANCEL) + { + contextLock(g_audDev); + g_audDev->hidden->isCancelled = true; + g_audDev->enabled = false; + CondVar_Broadcast(&g_audDev->hidden->cv); + contextUnlock(g_audDev); + } +} + +static void N3DSAUD_PlayAudio(_THIS) +{ + contextLock(this); + + size_t nextbuf = this->hidden->nextbuf; + size_t sampleLen = this->hidden->mixlen; + + if (this->hidden->isCancelled || this->hidden->waveBuf[nextbuf].status != NDSP_WBUF_FREE) + { + contextUnlock(this); + return; + } + + this->hidden->nextbuf = (nextbuf + 1) % NUM_BUFFERS; + + contextUnlock(this); + + memcpy((void*)this->hidden->waveBuf[nextbuf].data_vaddr,this->hidden->mixbuf,sampleLen); + DSP_FlushDataCache(this->hidden->waveBuf[nextbuf].data_vaddr,sampleLen); + + ndspChnWaveBufAdd(0, &this->hidden->waveBuf[nextbuf]); +} + +static Uint8 *N3DSAUD_GetAudioBuf(_THIS) +{ + return(this->hidden->mixbuf); +} + +static void N3DSAUD_CloseAudio(_THIS) +{ + contextLock(this); + + dspUnhook(&g_dspHook); + ndspSetCallback(NULL, NULL); + if (!this->hidden->isCancelled) + ndspChnReset(0); + + if ( this->hidden->mixbuf != NULL ) { + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; + } + if ( this->hidden->waveBuf[0].data_vaddr!= NULL ) { + linearFree((void*)this->hidden->waveBuf[0].data_vaddr); + this->hidden->waveBuf[0].data_vaddr = NULL; + } + + if (!this->hidden->isCancelled) { + memset(this->hidden->waveBuf,0,sizeof(ndspWaveBuf)*NUM_BUFFERS); + CondVar_Broadcast(&this->hidden->cv); + } + + contextUnlock(this); +} + +static int N3DSAUD_OpenAudio(_THIS, SDL_AudioSpec *spec) +{ + if (this->hidden->isCancelled) { + SDL_SetError("DSP is in cancelled state"); + return (-1); + } + + if(spec->channels > 2) + spec->channels = 2; + + Uint16 test_format = SDL_FirstAudioFormat(spec->format); + int valid_datatype = 0; + while ((!valid_datatype) && (test_format)) { + spec->format = test_format; + switch (test_format) { + case AUDIO_S8: + /* Signed 8-bit audio supported */ + this->hidden->format=(spec->channels==2)?NDSP_FORMAT_STEREO_PCM8:NDSP_FORMAT_MONO_PCM8; + this->hidden->isSigned=1; + this->hidden->bytePerSample = (spec->channels); + valid_datatype = 1; + break; + case AUDIO_S16: + /* Signed 16-bit audio supported */ + this->hidden->format=(spec->channels==2)?NDSP_FORMAT_STEREO_PCM16:NDSP_FORMAT_MONO_PCM16; + this->hidden->isSigned=1; + this->hidden->bytePerSample = (spec->channels) * 2; + valid_datatype = 1; + break; + default: + test_format = SDL_NextAudioFormat(); + break; + } + } + + if (!valid_datatype) { /* shouldn't happen, but just in case... */ + SDL_SetError("Unsupported audio format"); + return (-1); + } + + /* Update the fragment size as size in bytes */ + SDL_CalculateAudioSpec(spec); + + /* Allocate mixing buffer */ + if (spec->size >= UINT32_MAX/2) + return(-1); + this->hidden->mixlen = spec->size; + this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(spec->size); + if ( this->hidden->mixbuf == NULL ) { + return(-1); + } + SDL_memset(this->hidden->mixbuf, spec->silence, spec->size); + + Uint8 * temp = (Uint8 *) linearAlloc(this->hidden->mixlen*NUM_BUFFERS); + if (temp == NULL ) { + SDL_free(this->hidden->mixbuf); + return(-1); + } + memset(temp,0,this->hidden->mixlen*NUM_BUFFERS); + DSP_FlushDataCache(temp,this->hidden->mixlen*NUM_BUFFERS); + + this->hidden->nextbuf = 0; + this->hidden->channels = spec->channels; + this->hidden->samplerate = spec->freq; + + ndspChnReset(0); + + ndspChnSetInterp(0, NDSP_INTERP_LINEAR); + ndspChnSetRate(0, spec->freq); + ndspChnSetFormat(0, this->hidden->format); + + float mix[12]; + memset(mix, 0, sizeof(mix)); + mix[0] = 1.0; + mix[1] = 1.0; + ndspChnSetMix(0, mix); + + memset(this->hidden->waveBuf,0,sizeof(ndspWaveBuf)*NUM_BUFFERS); + + unsigned i; + for (i = 0; i < NUM_BUFFERS; i ++) { + this->hidden->waveBuf[i].data_vaddr = temp; + this->hidden->waveBuf[i].nsamples = this->hidden->mixlen / this->hidden->bytePerSample; + temp += this->hidden->mixlen; + } + + /* Setup callback */ + g_audDev = this; + ndspSetCallback(audioFrameFinished, this); + dspHook(&g_dspHook, N3DSAUD_DspHook); + + /* We're ready to rock and roll. :-) */ + return(0); +} diff --git a/src/audio/n3ds/SDL_n3dsaudio.h b/src/audio/n3ds/SDL_n3dsaudio.h new file mode 100644 index 0000000000..c51c850b94 --- /dev/null +++ b/src/audio/n3ds/SDL_n3dsaudio.h @@ -0,0 +1,50 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include <3ds.h> +#include "SDL_config.h" + +#ifndef _SDL_n3dsaudio_h +#define _SDL_n3dsaudio_h + +#include "../SDL_sysaudio.h" + +#define _THIS SDL_AudioDevice *this + +#define NUM_BUFFERS 2 /* -- Don't lower this! */ + +struct SDL_PrivateAudioData { + /* The file descriptor for the audio device */ + Uint8 *mixbuf; + Uint32 mixlen; + Uint32 format; + Uint32 samplerate; + Uint32 channels; + Uint8 bytePerSample; + Uint32 isSigned; + Uint32 nextbuf; + ndspWaveBuf waveBuf[NUM_BUFFERS]; + LightLock lock; + CondVar cv; + bool isCancelled; +}; + +#endif /* _SDL_n3dsaudio_h */ diff --git a/src/joystick/n3ds/SDL_sysjoystick.c b/src/joystick/n3ds/SDL_sysjoystick.c new file mode 100644 index 0000000000..c41e7a2455 --- /dev/null +++ b/src/joystick/n3ds/SDL_sysjoystick.c @@ -0,0 +1,183 @@ +#include "SDL_config.h" + +#include <3ds.h> + +#include "SDL_error.h" +#include "SDL_events.h" +#include "SDL_joystick.h" +#include "../SDL_sysjoystick.h" +#include "../SDL_joystick_c.h" + +#include "../../video/n3ds/SDL_n3dsvideo.h" + +int old_x = 0, old_y = 0; +int old_cs_x = 0, old_cs_y = 0; +u32 key_press, key_release = 0; +int old_dpad_state = 0; + +int SDL_SYS_JoystickInit (void) { + SDL_numjoysticks = 1; + + return 1; +} + +const char *SDL_SYS_JoystickName (int index) { + if(!index) + return "3DS builtin joypad"; + + SDL_SetError ("No joystick available with that index"); + + return (NULL); +} + +int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) { + joystick->nbuttons = 10; + joystick->nhats = 1; + joystick->nballs = 0; + joystick->naxes = 4; + + return 0; +} + +void SDL_SYS_JoystickUpdate (SDL_Joystick *joystick) { + + if (!aptIsActive()) { + // Avoid pumping events if we are not in the foreground. + return; + } + + circlePosition circlePad; + hidCircleRead(&circlePad); + int x,y; + x = circlePad.dx; + y = circlePad.dy; + if (x > 156) x= 156; + if (x < -156) x= -156; + if (y > 156) y= 156; + if (y < -156) y= -156; + if (old_x != x) { + old_x = x; + SDL_PrivateJoystickAxis (joystick, 0, x * 210); + } + if (old_y != y) { + old_y = y; + SDL_PrivateJoystickAxis (joystick, 1, - y * 210); + } + + circlePosition circleStick = {0}; + irrstCstickRead(&circleStick); + x = circleStick.dx; + y = circleStick.dy; + if (x > 156) x= 156; + if (x < -156) x= -156; + if (y > 156) y= 156; + if (y < -156) y= -156; + if (old_cs_x != x) { + old_cs_x = x; + SDL_PrivateJoystickAxis (joystick, 2, x * 210); + } + if (old_cs_y != y) { + old_cs_y = y; + SDL_PrivateJoystickAxis (joystick, 3, - y * 210); + } + + key_press = hidKeysDown (); + int dpad_state = old_dpad_state; + if ((key_press & KEY_A)) { + SDL_PrivateJoystickButton (joystick, 1, SDL_PRESSED); + } + if ((key_press & KEY_B)) { + SDL_PrivateJoystickButton (joystick, 2, SDL_PRESSED); + } + if ((key_press & KEY_X)) { + SDL_PrivateJoystickButton (joystick, 3, SDL_PRESSED); + } + if ((key_press & KEY_Y)) { + SDL_PrivateJoystickButton (joystick, 4, SDL_PRESSED); + } + if ((key_press & KEY_SELECT)) { + SDL_PrivateJoystickButton (joystick, 7, SDL_PRESSED); + } + if ((key_press & KEY_START)) { + SDL_PrivateJoystickButton (joystick, 0, SDL_PRESSED); + } + if ((key_press & KEY_L)) { + SDL_PrivateJoystickButton (joystick, 5, SDL_PRESSED); + } + if ((key_press & KEY_R)) { + SDL_PrivateJoystickButton (joystick, 6, SDL_PRESSED); + } + if ((key_press & KEY_DDOWN)) { + dpad_state |= SDL_HAT_DOWN; + } + if ((key_press & KEY_DLEFT)) { + dpad_state |= SDL_HAT_LEFT; + } + if ((key_press & KEY_DUP)) { + dpad_state |= SDL_HAT_UP; + } + if ((key_press & KEY_DRIGHT)) { + dpad_state |= SDL_HAT_RIGHT; + } + if ((key_press & KEY_ZL)) { + SDL_PrivateJoystickButton (joystick, 8, SDL_PRESSED); + } + if ((key_press & KEY_ZR)) { + SDL_PrivateJoystickButton (joystick, 9, SDL_PRESSED); + } + + key_release = hidKeysUp (); + if ((key_release & KEY_A)) { + SDL_PrivateJoystickButton (joystick, 1, SDL_RELEASED); + } + if ((key_release & KEY_B)) { + SDL_PrivateJoystickButton (joystick, 2, SDL_RELEASED); + } + if ((key_release & KEY_X)) { + SDL_PrivateJoystickButton (joystick, 3, SDL_RELEASED); + } + if ((key_release & KEY_Y)) { + SDL_PrivateJoystickButton (joystick, 4, SDL_RELEASED); + } + if ((key_release & KEY_SELECT)) { + SDL_PrivateJoystickButton (joystick, 7, SDL_RELEASED); + } + if ((key_release & KEY_START)) { + SDL_PrivateJoystickButton (joystick, 0, SDL_RELEASED); + } + if ((key_release & KEY_L)) { + SDL_PrivateJoystickButton (joystick, 5, SDL_RELEASED); + } + if ((key_release & KEY_R)) { + SDL_PrivateJoystickButton (joystick, 6, SDL_RELEASED); + } + if ((key_release & KEY_DDOWN)) { + dpad_state &= ~SDL_HAT_DOWN; + } + if ((key_release & KEY_DLEFT)) { + dpad_state &= ~SDL_HAT_LEFT; + } + if ((key_release & KEY_DUP)) { + dpad_state &= ~SDL_HAT_UP; + } + if ((key_release & KEY_DRIGHT)) { + dpad_state &= ~SDL_HAT_RIGHT; + } + if ((key_release & KEY_ZL)) { + SDL_PrivateJoystickButton (joystick, 8, SDL_RELEASED); + } + if ((key_release & KEY_ZR)) { + SDL_PrivateJoystickButton (joystick, 9, SDL_RELEASED); + } + + if (dpad_state != old_dpad_state) { + old_dpad_state = dpad_state; + SDL_PrivateJoystickHat (joystick, 0, dpad_state); + } +} + +void SDL_SYS_JoystickClose (SDL_Joystick *joystick) { +} + +void SDL_SYS_JoystickQuit (void) { +} diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index 8af6e52f41..c48803ff2a 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -43,6 +43,8 @@ #include "win32/SDL_systhread_c.h" #elif SDL_THREAD_SYMBIAN #include "symbian/SDL_systhread_c.h" +#elif SDL_THREAD_N3DS +#include "n3ds/SDL_systhread_c.h" #else #error Need thread implementation for this platform #include "generic/SDL_systhread_c.h" diff --git a/src/thread/n3ds/SDL_syscond.c b/src/thread/n3ds/SDL_syscond.c new file mode 100644 index 0000000000..df20c52e58 --- /dev/null +++ b/src/thread/n3ds/SDL_syscond.c @@ -0,0 +1,137 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +//#include "../../SDL_internal.h" + +#include "SDL_config.h" + +#include "SDL_sysmutex_c.h" + +struct SDL_cond +{ + CondVar cv; +}; + +/* Create a condition variable */ +SDL_cond * +SDL_CreateCond(void) +{ + SDL_cond *cond; + + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); + if (cond) { + CondVar_Init(&cond->cv); + } else { + SDL_OutOfMemory(); + } + return (cond); +} + +/* Destroy a condition variable */ +void +SDL_DestroyCond(SDL_cond * cond) +{ + if (cond) { + SDL_free(cond); + } +} + +/* Restart one of the threads that are waiting on the condition variable */ +int +SDL_CondSignal(SDL_cond * cond) +{ + if (!cond) { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + + CondVar_Signal(&cond->cv); + return 0; +} + +/* Restart all threads that are waiting on the condition variable */ +int +SDL_CondBroadcast(SDL_cond * cond) +{ + if (!cond) { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + + CondVar_Broadcast(&cond->cv); + return 0; +} + +/* Wait on the condition variable for at most 'ms' milliseconds. + The mutex must be locked before entering this function! + The mutex is unlocked during the wait, and locked again after the wait. + +Typical use: + +Thread A: + SDL_LockMutex(lock); + while ( ! condition ) { + SDL_CondWait(cond, lock); + } + SDL_UnlockMutex(lock); + +Thread B: + SDL_LockMutex(lock); + ... + condition = true; + ... + SDL_CondSignal(cond); + SDL_UnlockMutex(lock); + */ +int +SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +{ + if (!cond) { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + + if (!mutex) { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + RecursiveLock rl_backup = mutex->rl; + mutex->rl.thread_tag = 0; + mutex->rl.counter = 0; + + Result res = 0; + if (ms == SDL_MUTEX_MAXWAIT) + CondVar_Wait(&cond->cv, &mutex->rl.lock); + else + res = CondVar_WaitTimeout(&cond->cv, &mutex->rl.lock, (s64)ms * 1000000LL); + + mutex->rl.thread_tag = rl_backup.thread_tag; + mutex->rl.counter = rl_backup.counter; + + return R_SUCCEEDED(res) ? 0 : SDL_MUTEX_TIMEDOUT; +} + +/* Wait on the condition variable forever */ +int +SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) +{ + return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT); +} diff --git a/src/thread/n3ds/SDL_sysmutex.c b/src/thread/n3ds/SDL_sysmutex.c new file mode 100644 index 0000000000..9a84e761ce --- /dev/null +++ b/src/thread/n3ds/SDL_sysmutex.c @@ -0,0 +1,85 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +//#include "../../SDL_internal.h" + +#include "SDL_config.h" + +#include "SDL_sysmutex_c.h" + +/* Create a mutex */ +SDL_mutex * +SDL_CreateMutex(void) +{ + SDL_mutex *mutex; + + /* Allocate mutex memory */ + mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); + if (mutex) { + /* Initialize the inner recursive lock */ + RecursiveLock_Init(&mutex->rl); + } else { + SDL_OutOfMemory(); + } + return mutex; +} + +/* Free the mutex */ +void +SDL_DestroyMutex(SDL_mutex * mutex) +{ + if (mutex) { + SDL_free(mutex); + } +} + +/* Lock the semaphore */ +int +SDL_mutexP(SDL_mutex * mutex) +{ +#if SDL_THREADS_DISABLED + return 0; +#else + if (mutex == NULL) { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + RecursiveLock_Lock(&mutex->rl); + return 0; +#endif /* SDL_THREADS_DISABLED */ +} + +/* Unlock the mutex */ +int +SDL_mutexV(SDL_mutex * mutex) +{ +#if SDL_THREADS_DISABLED + return 0; +#else + if (mutex == NULL) { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + RecursiveLock_Unlock(&mutex->rl); + return 0; +#endif /* SDL_THREADS_DISABLED */ +} diff --git a/src/thread/n3ds/SDL_sysmutex_c.h b/src/thread/n3ds/SDL_sysmutex_c.h new file mode 100644 index 0000000000..4f123f78cd --- /dev/null +++ b/src/thread/n3ds/SDL_sysmutex_c.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#include "SDL_thread.h" +#include "SDL_systhread_c.h" + +struct SDL_mutex +{ + RecursiveLock rl; +}; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/n3ds/SDL_syssem.c b/src/thread/n3ds/SDL_syssem.c new file mode 100644 index 0000000000..eefbd95faf --- /dev/null +++ b/src/thread/n3ds/SDL_syssem.c @@ -0,0 +1,103 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +//#include "../../SDL_internal.h" + +#include +#include + +#include "SDL_config.h" + +#include "SDL_error.h" +#include "SDL_thread.h" + +#include <3ds.h> + +struct SDL_semaphore { + LightSemaphore sem; +}; + + +/* Create a semaphore */ +SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) +{ + SDL_sem *sem; + + sem = (SDL_sem *) malloc(sizeof(*sem)); + if (sem != NULL) { + LightSemaphore_Init(&sem->sem, initial_value, 255); + } else { + SDL_OutOfMemory(); + } + + return sem; +} + +/* Free the semaphore */ +void SDL_DestroySemaphore(SDL_sem *sem) +{ + if (sem != NULL) { + free(sem); + } +} + +/* Waits on a semaphore */ +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) +{ + if (sem == NULL) { + SDL_SetError("Passed a NULL sem"); + return -1; + } + + if (timeout == SDL_MUTEX_MAXWAIT) { + LightSemaphore_Acquire(&sem->sem, 1); + return 0; + } + else if (timeout == 0) { + int rc = LightSemaphore_TryAcquire(&sem->sem, 1); + return rc != 0 ? SDL_MUTEX_TIMEDOUT : 0; + } + else { + SDL_SetError("Non-trivial semaphore wait timeout values not supported"); + return -1; + } +} + +int SDL_SemTryWait(SDL_sem *sem) +{ + return SDL_SemWaitTimeout(sem, 0); +} + +int SDL_SemWait(SDL_sem *sem) +{ + return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); +} + +/* Returns the current count of the semaphore */ +Uint32 SDL_SemValue(SDL_sem *sem) +{ + return sem->sem.current_count; +} + +int SDL_SemPost(SDL_sem *sem) +{ + LightSemaphore_Release(&sem->sem, 1); + return 0; +} diff --git a/src/thread/n3ds/SDL_systhread.c b/src/thread/n3ds/SDL_systhread.c new file mode 100644 index 0000000000..aace52a72b --- /dev/null +++ b/src/thread/n3ds/SDL_systhread.c @@ -0,0 +1,93 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include +#include +#include + +#include "SDL_config.h" + +#include "SDL_error.h" +#include "SDL_thread.h" +#include "../SDL_systhread.h" +#include "../SDL_thread_c.h" +#include <3ds.h> + +#define STACKSIZE (128 * 1024) + +void ThreadEntry(void *arg) +{ + SDL_RunThread(arg); +} + +int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) +{ +// s32 priority = 0x2F; + s32 priority = 0x30; + + /* Set priority of new thread higher than the current thread */ + svcGetThreadPriority(&priority, CUR_THREAD_HANDLE); + if(priority>0x19) priority--; + else priority = 0x19; //priority 0x18 is for video thread that is activated by a signal and than must run at maximum priority to avoid flickering + if(priority>0x2F) priority = 0x2F; + + thread->handle = threadCreate(ThreadEntry, args, + STACKSIZE, priority, -2, false); + + thread->threadid = (int) thread->handle; + if (!thread->threadid) + { + SDL_SetError("Create Thread failed"); + return(-1); + } + + return 0; +} + +void SDL_SYS_SetupThread(void) +{ + //Nothing, probably +} + +Uint32 SDL_ThreadID(void) +{ + //Incompatible with SDL API, this function will NOT return + //a valid thread ID when called from the main thread. + u32 threadID=0; + Thread current = threadGetCurrent(); + if (current) { + Handle handle = threadGetHandle(current); + svcGetThreadId(&threadID, handle); + } + + return threadID; +} + +void SDL_SYS_WaitThread(SDL_Thread *thread) +{ + threadJoin(thread->handle, U64_MAX); +} + +void SDL_SYS_KillThread(SDL_Thread *thread) +{ + threadFree(thread->handle); +} + diff --git a/src/thread/n3ds/SDL_systhread_c.h b/src/thread/n3ds/SDL_systhread_c.h new file mode 100644 index 0000000000..1baf0d7210 --- /dev/null +++ b/src/thread/n3ds/SDL_systhread_c.h @@ -0,0 +1,24 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include <3ds.h> + +typedef Thread SYS_ThreadHandle; diff --git a/src/timer/n3ds/SDL_systimer.c b/src/timer/n3ds/SDL_systimer.c new file mode 100644 index 0000000000..d921cdc0eb --- /dev/null +++ b/src/timer/n3ds/SDL_systimer.c @@ -0,0 +1,42 @@ +#include "SDL_config.h" + +#include +#include <3ds.h> +#include + + +#include "SDL_thread.h" +#include "SDL_timer.h" +#include "SDL_error.h" +#include "../SDL_timer_c.h" + +static u64 g_startTicks; + +void SDL_StartTicks (void) { + g_startTicks = svcGetSystemTick(); +} + +Uint32 SDL_GetTicks (void) { + u64 elapsed = svcGetSystemTick() - g_startTicks; + return elapsed * 1000 / SYSCLOCK_ARM11; +} + +void SDL_Delay (Uint32 ms) { + svcSleepThread((u64)ms * 1000000ULL); +} + +int SDL_SYS_TimerInit (void) { + return 0; +} + +void SDL_SYS_TimerQuit (void) { +} + +int SDL_SYS_StartTimer (void) { + SDL_SetError ("Timers not implemented on 3DS"); + + return -1; +} + +void SDL_SYS_StopTimer (void) { +} diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 436450e330..50735f4476 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -398,6 +398,9 @@ extern VideoBootStrap DC_bootstrap; #if SDL_VIDEO_DRIVER_NDS extern VideoBootStrap NDS_bootstrap; #endif +#if SDL_VIDEO_DRIVER_N3DS +extern VideoBootStrap N3DS_bootstrap; +#endif #if SDL_VIDEO_DRIVER_RISCOS extern VideoBootStrap RISCOS_bootstrap; #endif diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 46285c990e..94620ad04e 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -114,6 +114,9 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_NDS &NDS_bootstrap, #endif +#if SDL_VIDEO_DRIVER_N3DS + &N3DS_bootstrap, +#endif #if SDL_VIDEO_DRIVER_RISCOS &RISCOS_bootstrap, #endif diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c index 7e096e2f7f..23af477cca 100644 --- a/src/video/dummy/SDL_nullvideo.c +++ b/src/video/dummy/SDL_nullvideo.c @@ -68,12 +68,15 @@ static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects); static int DUMMY_Available(void) { + return(1); +/* const char *envr = SDL_getenv("SDL_VIDEODRIVER"); if ((envr) && (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0)) { return(1); } return(0); +*/ } static void DUMMY_DeleteDevice(SDL_VideoDevice *device) diff --git a/src/video/n3ds/SDL_n3dsevents.c b/src/video/n3ds/SDL_n3dsevents.c new file mode 100644 index 0000000000..42dda2f289 --- /dev/null +++ b/src/video/n3ds/SDL_n3dsevents.c @@ -0,0 +1,89 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* Being a null driver, there's no event stream. We just define stubs for + most of the API. */ + +#include <3ds.h> + +#include "SDL.h" +#include "../../events/SDL_sysevents.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_n3dsvideo.h" +#include "SDL_n3dsevents_c.h" + +void N3DS_PumpEvents(_THIS) +{ + svcSleepThread(100000); // 0.1 ms + + if (!aptMainLoop()) + { + static bool pushedQuit = false; + if (!pushedQuit) { + SDL_Event sdlevent; + sdlevent.type = SDL_QUIT; + SDL_PushEvent(&sdlevent); + pushedQuit = true; + } + return; + } + + hidScanInput(); + + if (hidKeysHeld() & KEY_TOUCH) { + touchPosition touch; + + hidTouchRead (&touch); + +// TO DO: handle fit screen on x and y.Y and Y to be considered separately + + if(this->hidden->screens&SDL_TOPSCR && this->hidden->screens&SDL_BOTTOMSCR) { + if (touch.px != 0 || touch.py != 0) { + SDL_PrivateMouseMotion (0, 0, + touch.px + (this->hidden->w1 - 320)/2, + this->hidden->y2 + touch.py + (this->hidden->h2 - 240)/2); + if (!SDL_GetMouseState (NULL, NULL)) + SDL_PrivateMouseButton (SDL_PRESSED, 1, 0, 0); + } + } else { + if (touch.px != 0 || touch.py != 0) { + SDL_PrivateMouseMotion (0, 0, (touch.px * this->hidden->w1) / 320, (touch.py * this->hidden->h1) / 240); + if (!SDL_GetMouseState (NULL, NULL)) + SDL_PrivateMouseButton (SDL_PRESSED, 1, 0, 0); + } + } + } else { + if (SDL_GetMouseState (NULL, NULL)) + SDL_PrivateMouseButton (SDL_RELEASED, 1, 0, 0); + } +} + +void N3DS_InitOSKeymap(_THIS) +{ + // Do nothing +} + + +/* end of SDL_nullevents.c ... */ + diff --git a/src/video/n3ds/SDL_n3dsevents_c.h b/src/video/n3ds/SDL_n3dsevents_c.h new file mode 100644 index 0000000000..af9957168d --- /dev/null +++ b/src/video/n3ds/SDL_n3dsevents_c.h @@ -0,0 +1,34 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#include "SDL_config.h" + +#include "SDL_n3dsvideo.h" + +/* Variables and functions exported by SDL_sysevents.c to other parts + of the native video subsystem (SDL_sysvideo.c) +*/ +extern void N3DS_InitOSKeymap(_THIS); +extern void N3DS_PumpEvents(_THIS); + +/* end of SDL_nullevents_c.h ... */ + diff --git a/src/video/n3ds/SDL_n3dsmouse.c b/src/video/n3ds/SDL_n3dsmouse.c new file mode 100644 index 0000000000..1da84a4e6d --- /dev/null +++ b/src/video/n3ds/SDL_n3dsmouse.c @@ -0,0 +1,33 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_mouse.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_n3dsmouse_c.h" + + +/* The implementation dependent data for the window manager cursor */ +struct WMcursor { + int unused; +}; diff --git a/src/video/n3ds/SDL_n3dsmouse_c.h b/src/video/n3ds/SDL_n3dsmouse_c.h new file mode 100644 index 0000000000..cdbdd17ce5 --- /dev/null +++ b/src/video/n3ds/SDL_n3dsmouse_c.h @@ -0,0 +1,26 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_n3dsvideo.h" + +/* Functions to be exported */ diff --git a/src/video/n3ds/SDL_n3dsvideo.c b/src/video/n3ds/SDL_n3dsvideo.c new file mode 100644 index 0000000000..2fbb8ee820 --- /dev/null +++ b/src/video/n3ds/SDL_n3dsvideo.c @@ -0,0 +1,766 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_video.h" +#include "SDL_mouse.h" +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_thread.h" +#include "SDL_timer.h" + +#include <3ds.h> +#include + +#include "SDL_n3dsvideo.h" +#include "SDL_n3dsevents_c.h" +#include "SDL_n3dsmouse_c.h" + +#define N3DSVID_DRIVER_NAME "n3ds" + +/* Low level N3ds */ + +// This header is generated by the build process +#include "vshader_shbin.h" + +#define STACKSIZE (32 * 1024) + +#define TEX_MIN_SIZE 32 +#define CLEAR_COLOR0 0x000000FF +#define CLEAR_COLOR1 0x000000 +#define CLEAR_COLOR2 0x000000 +#define CLEAR_COLOR3 0x000001 + +// Used to transfer the final rendered display to the framebuffer +#define DISPLAY_TRANSFER_FLAGS0 \ + (GX_TRANSFER_FLIP_VERT(0) | GX_TRANSFER_OUT_TILED(0) | GX_TRANSFER_RAW_COPY(0) | \ + GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8)) +#define DISPLAY_TRANSFER_FLAGS1 \ + (GX_TRANSFER_FLIP_VERT(0) | GX_TRANSFER_OUT_TILED(0) | GX_TRANSFER_RAW_COPY(0) | \ + GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8)) +#define DISPLAY_TRANSFER_FLAGS2 \ + (GX_TRANSFER_FLIP_VERT(0) | GX_TRANSFER_OUT_TILED(0) | GX_TRANSFER_RAW_COPY(0) | \ + GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB5A1) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB565)) +#define DISPLAY_TRANSFER_FLAGS3 \ + (GX_TRANSFER_FLIP_VERT(0) | GX_TRANSFER_OUT_TILED(0) | GX_TRANSFER_RAW_COPY(0) | \ + GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB5A1) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB565)) + +// Used to convert textures to 3DS tiled format +// Note: vertical flip flag set so 0,0 is top left of texture +#define TEXTURE_TRANSFER_FLAGS0 \ + (GX_TRANSFER_FLIP_VERT(1) | GX_TRANSFER_OUT_TILED(1) | GX_TRANSFER_RAW_COPY(0) | \ + GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGBA8) | \ + GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO)) +#define TEXTURE_TRANSFER_FLAGS1 \ + (GX_TRANSFER_FLIP_VERT(1) | GX_TRANSFER_OUT_TILED(1) | GX_TRANSFER_RAW_COPY(0) | \ + GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8) | \ + GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO)) +#define TEXTURE_TRANSFER_FLAGS2 \ + (GX_TRANSFER_FLIP_VERT(1) | GX_TRANSFER_OUT_TILED(1) | GX_TRANSFER_RAW_COPY(0) | \ + GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB565) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB5A1) | \ + GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO)) +#define TEXTURE_TRANSFER_FLAGS3 \ + (GX_TRANSFER_FLIP_VERT(1) | GX_TRANSFER_OUT_TILED(1) | GX_TRANSFER_RAW_COPY(0) | \ + GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB5A1) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB5A1) | \ + GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO)) + +static DVLB_s* vshader_dvlb; +static shaderProgram_s program; +static int uLoc_projection; +static C3D_Mtx projection; +static C3D_Mtx projection2; + +C3D_RenderTarget *VideoSurface1; +C3D_RenderTarget *VideoSurface2; +static C3D_Tex spritesheet_tex; + +static int textureTranferFlags[4] = { TEXTURE_TRANSFER_FLAGS0, TEXTURE_TRANSFER_FLAGS1, TEXTURE_TRANSFER_FLAGS2, TEXTURE_TRANSFER_FLAGS3}; +static int displayTranferFlags[4] = { DISPLAY_TRANSFER_FLAGS0, DISPLAY_TRANSFER_FLAGS1, DISPLAY_TRANSFER_FLAGS2, DISPLAY_TRANSFER_FLAGS3}; +static unsigned int clearcolors[4] = { CLEAR_COLOR0, CLEAR_COLOR1, CLEAR_COLOR2, CLEAR_COLOR3}; + +static void sceneInit(GSPGPU_FramebufferFormat mode, bool scale); +static void sceneExit(void); +void drawTexture( int x, int y, int width, int height, float left, float right, float top, float bottom); + +// video thread variables and functions +volatile bool runThread = false; +LightEvent privateVideoThreadEvent; +Thread privateVideoThreadHandle = NULL; +static void videoThread(void* data); + +/* Initialization/Query functions */ +static int N3DS_VideoInit(_THIS, SDL_PixelFormat *vformat); +static SDL_Rect **N3DS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); +static SDL_Surface *N3DS_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); +static int N3DS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); +static void N3DS_UpdateRects(_THIS, int numrects, SDL_Rect *rects); +static void N3DS_VideoQuit(_THIS); + +/* Hardware surface functions */ +static int N3DS_AllocHWSurface(_THIS, SDL_Surface *surface); +static int N3DS_LockHWSurface(_THIS, SDL_Surface *surface); +static void N3DS_UnlockHWSurface(_THIS, SDL_Surface *surface); +static void N3DS_FreeHWSurface(_THIS, SDL_Surface *surface); +static int N3DS_FlipHWSurface (_THIS, SDL_Surface *surface); + +int N3DS_ToggleFullScreen(_THIS, int on); + + +//Copied from sf2dlib that grabbed it from: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 +unsigned int next_pow2(unsigned int v) +{ + v--; + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + v++; + return v >= TEX_MIN_SIZE ? v : TEX_MIN_SIZE; +} + +static int N3DS_Available(void) +{ + return(1); //what else? +} + +static void N3DS_DeleteDevice(SDL_VideoDevice *device) +{ + if (device->hidden) SDL_free(device->hidden); + if (device) SDL_free(device); + device=NULL; +} + +static SDL_VideoDevice *N3DS_CreateDevice(int devindex) +{ + SDL_VideoDevice *device; + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); + if ( device ) { + SDL_memset(device, 0, (sizeof *device)); + device->hidden = (struct SDL_PrivateVideoData *) + SDL_malloc((sizeof *device->hidden)); + } + if ( (device == NULL) || (device->hidden == NULL) ) { + SDL_OutOfMemory(); + if ( device ) { + SDL_free(device); + } + return(0); + } + + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + + /* Set the function pointers */ + device->VideoInit = N3DS_VideoInit; + device->ListModes = N3DS_ListModes; + device->SetVideoMode = N3DS_SetVideoMode; + device->CreateYUVOverlay = NULL; + device->SetColors = N3DS_SetColors; + device->UpdateRects = N3DS_UpdateRects; + device->VideoQuit = N3DS_VideoQuit; + device->AllocHWSurface = N3DS_AllocHWSurface; + device->CheckHWBlit = NULL; + device->FillHWRect = NULL; + device->SetHWColorKey = NULL; + device->SetHWAlpha = NULL; + device->LockHWSurface = N3DS_LockHWSurface; + device->UnlockHWSurface = N3DS_UnlockHWSurface; + device->FlipHWSurface = N3DS_FlipHWSurface; + device->FreeHWSurface = N3DS_FreeHWSurface; + device->SetCaption = NULL; + device->SetIcon = NULL; + device->IconifyWindow = NULL; + device->GrabInput = NULL; + device->GetWMInfo = NULL; + device->InitOSKeymap = N3DS_InitOSKeymap; + device->PumpEvents = N3DS_PumpEvents; +// device->info.blit_hw = 1; + + device->ToggleFullScreen = N3DS_ToggleFullScreen; + + device->free = N3DS_DeleteDevice; + + return device; +} + +VideoBootStrap N3DS_bootstrap = { + N3DSVID_DRIVER_NAME, "N3ds video driver", + N3DS_Available, N3DS_CreateDevice +}; + + +int N3DS_VideoInit(_THIS, SDL_PixelFormat *vformat) +{ + // Initialize graphics + gfxInitDefault(); + gfxSet3D(false); + C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); + + vformat->BitsPerPixel = 32; + vformat->BytesPerPixel = 4; + vformat->Rmask = 0xff000000; + vformat->Gmask = 0x00ff0000; + vformat->Bmask = 0x0000ff00; + vformat->Amask = 0x000000ff; + + /* We're done! */ + return(0); +} + +SDL_Rect **N3DS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) +{ + return (SDL_Rect **) -1; +} + +void N3DS_SetScaling(_THIS) +{ + if(this->hidden->flags & SDL_FULLSCREEN) +// flags |= (SDL_FITWIDTH | SDL_FITHEIGHT); + this->hidden->fitscreen = (SDL_FITWIDTH | SDL_FITHEIGHT); + else + this->hidden->fitscreen = this->hidden->flags & (SDL_FITWIDTH | SDL_FITHEIGHT); + + if((this->hidden->fitscreen & SDL_FITWIDTH)&&(this->hidden->fitscreen & SDL_FITHEIGHT)) { + this->hidden->scalex= 400.0/(float)this->hidden->w1; + this->hidden->scaley= 240.0/(float)this->hidden->h1; + } else if(this->hidden->fitscreen & SDL_FITWIDTH) { + this->hidden->scalex= 400.0/(float)this->hidden->w1; + this->hidden->scaley= this->hidden->scalex;//1.0f; + } else if(this->hidden->fitscreen & SDL_FITHEIGHT) { + this->hidden->scaley= 240.0/(float)this->hidden->h1; + this->hidden->scalex= this->hidden->scaley;//1.0f; + } else { + this->hidden->scalex= 1.0f; + this->hidden->scaley= 1.0f; + } +} + +int N3DS_ToggleFullScreen(_THIS, int on){ + if ((this->hidden->flags & SDL_FITWIDTH) && (this->hidden->flags & SDL_FITHEIGHT)) + return -1; + + if ( this->hidden->flags & SDL_FULLSCREEN ) + this->hidden->flags &= ~SDL_FULLSCREEN; + else + this->hidden->flags |= SDL_FULLSCREEN; + + N3DS_SetScaling(this); + return 1; +} + +Uint32 setVideoModecount = 0; + +SDL_Surface *N3DS_SetVideoMode(_THIS, SDL_Surface *current, + int width, int height, int bpp, Uint32 flags) +{ + + Uint32 Rmask, Gmask, Bmask, Amask; + int hw = next_pow2(width); + int hh= next_pow2(height); + + setVideoModecount++; + + this->hidden->screens = flags & (SDL_DUALSCR); // SDL_DUALSCR = SDL_TOPSCR | SDL_BOTTOMSCR + if(this->hidden->screens==0) this->hidden->screens = SDL_TOPSCR; //Default + flags &= ~SDL_DUALSCR; + flags |= this->hidden->screens; + + this->hidden->flags = flags; + + switch(bpp) { + case 0: + bpp = 32; + case 32: + Rmask = 0xff000000; + Gmask = 0x00ff0000; + Bmask = 0x0000ff00; + Amask = 0x000000ff; + this->hidden->mode=GSP_RGBA8_OES; + this->hidden->byteperpixel=4; + this->hidden->bpp = 32; + break; + case 24: + Rmask = 0xff0000; + Gmask = 0x00ff00; + Bmask = 0x0000ff; + Amask = 0x0; + this->hidden->mode=GSP_BGR8_OES; + this->hidden->byteperpixel=3; + this->hidden->bpp = 24; + break; + case 16: + Rmask = 0xF800; + Gmask = 0x07E0; + Bmask = 0x001F; + Amask = 0x0000; + this->hidden->mode=GSP_RGB565_OES; + this->hidden->byteperpixel=2; + this->hidden->bpp = 16; + break; + case 15: + bpp = 16; + Rmask = 0xF800; + Gmask = 0x07C0; + Bmask = 0x003E; + Amask = 0x0001; + this->hidden->mode=GSP_RGB5_A1_OES; + this->hidden->byteperpixel=2; + this->hidden->bpp = 16; + break; + case 8: + Rmask = 0; + Gmask = 0; + Bmask = 0; + Amask = 0; + this->hidden->mode=GSP_RGBA8_OES; + this->hidden->byteperpixel=4; + this->hidden->bpp = 8; + break; + default: + return NULL; + break; + } + + +// if there is a video thread running, stop and free it + if (privateVideoThreadHandle) { + runThread = false; + LightEvent_Signal(&privateVideoThreadEvent); + threadJoin(privateVideoThreadHandle, U64_MAX); + privateVideoThreadHandle = NULL; + } + + if ( this->hidden->buffer ) { + linearFree( this->hidden->buffer ); + this->hidden->buffer = NULL; + } + if ( this->hidden->palettedbuffer ) { + free( this->hidden->palettedbuffer ); + this->hidden->palettedbuffer = NULL; + } + + this->hidden->buffer = (u8*) linearAlloc(hw * hh * this->hidden->byteperpixel); + if ( ! this->hidden->buffer ) { + SDL_SetError("Couldn't allocate buffer for requested mode"); + return(NULL); + } + + SDL_memset(this->hidden->buffer, 0, hw * hh * this->hidden->byteperpixel); + + if(bpp==8) { + this->hidden->palettedbuffer = malloc(width * height); + if ( ! this->hidden->palettedbuffer ) { + SDL_SetError("Couldn't allocate buffer for requested mode"); + linearFree(this->hidden->buffer); + return(NULL); + } + SDL_memset(this->hidden->palettedbuffer, 0, width * height); + } + + /* Allocate the new pixel format for the screen */ + if ( ! SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, Amask) ) { + linearFree(this->hidden->buffer); + this->hidden->buffer = NULL; + SDL_SetError("Couldn't allocate new pixel format for requested mode"); + return(NULL); + } + + if(setVideoModecount>1) sceneExit(); // unload rendertarget and the shader + + //setup the screens mode + sceneInit(this->hidden->mode, (this->hidden->fitscreen & (SDL_FITWIDTH | SDL_FITHEIGHT)) ? false:true); + + if((flags & SDL_CONSOLETOP) && !(this->hidden->screens & SDL_TOPSCR)) { + consoleInit(GFX_TOP, NULL); + this->hidden->console = SDL_CONSOLETOP; + flags &= ~SDL_CONSOLEBOTTOM; + // todo here: setup bottom video for graphics; + } else if((flags & SDL_CONSOLEBOTTOM) && !(this->hidden->screens & SDL_BOTTOMSCR)) { + consoleInit(GFX_BOTTOM, NULL); + this->hidden->console = SDL_CONSOLEBOTTOM; + } + /* Set up the new mode framebuffer */ + current->flags = SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_HWPALETTE; + this->hidden->w = hw; + this->hidden->h = hh; + + this->hidden->x1 = 0; + this->hidden->y1 = 0; + this->hidden->x2 = 0; + this->hidden->y2 = 0; + if((this->hidden->screens & SDL_TOPSCR) && (this->hidden->screens & SDL_BOTTOMSCR)){ + this->hidden->w1 = width; + this->hidden->h1 = height/2; + this->hidden->w2 = width; + this->hidden->h2 = height/2; + this->hidden->y2 = height/2; + } else { + this->hidden->w1 = width; + this->hidden->h1 = height; + this->hidden->w2 = width; + this->hidden->h2 = height; + } + + this->hidden->l1 = 0.0f; + this->hidden->t1 = 0.0f; + this->hidden->r1 = (float)this->hidden->w1/(float)this->hidden->w; + this->hidden->b1 = (float)this->hidden->h1/(float)this->hidden->h; + this->hidden->l2 = 0.0f; + this->hidden->t2 = (float)this->hidden->y2/(float)this->hidden->h; + this->hidden->r2 = (float)this->hidden->w2/(float)this->hidden->w; + this->hidden->b2 = ((float)this->hidden->y2+(float)this->hidden->h2)/(float)this->hidden->h; + +//Set scaling + + N3DS_SetScaling(this); + + this->info.current_w = current->w = width; + this->info.current_h = current->h = height; + if(bpp>8) { + current->pixels = this->hidden->buffer; + current->pitch = hw * this->hidden->byteperpixel; + } else { + current->pixels = this->hidden->palettedbuffer; + current->pitch = width; + } + +// NOTE: the following is a dirty hack to make work mode 2. Passing a RGB565 buffer to a RGB656 texture and rendering it to a RGB656 display results in some colors being transparent. +// To fix this we are transfering a RGB656 buffer to a RGB5A1 texure and then rendering it to a RGB656 display. We lose 1 bit of Green color depth, but at least it works + int mode = this->hidden->mode; + if (mode==2) mode = 3; + + // Setup the textures + if(setVideoModecount>1) + C3D_TexDelete(&spritesheet_tex); // delete in case it was initialized before + C3D_TexInit(&spritesheet_tex, hw, hh, this->hidden->mode); + C3D_TexSetFilter(&spritesheet_tex, this->hidden->fitscreen ? GPU_LINEAR : GPU_NEAREST , GPU_NEAREST); +// C3D_TexBind(0, &spritesheet_tex); + + runThread = true; + LightEvent_Init(&privateVideoThreadEvent, RESET_ONESHOT); + // libctru sys threads uses 0x18, so we use a lower priority, but higher than any other SDL thread + privateVideoThreadHandle = threadCreate(videoThread, (void *) this, STACKSIZE, 0x19, -2, true); + this->hidden->currentVideoSurface = current; + /* We're done */ + + return(current); +} + +/* We don't actually allow hardware surfaces other than the main one */ +static int N3DS_AllocHWSurface(_THIS, SDL_Surface *surface) +{ + return(-1); +} +static void N3DS_FreeHWSurface(_THIS, SDL_Surface *surface) +{ + return; +} + +/* We need to wait for vertical retrace on page flipped displays */ +static int N3DS_LockHWSurface(_THIS, SDL_Surface *surface) +{ + return(0); +} + +static void N3DS_UnlockHWSurface(_THIS, SDL_Surface *surface) +{ + return; +} + +static unsigned int RenderClearColor; + +static void videoThread(void* data) +{ + _THIS = (SDL_VideoDevice *) data; + + while (runThread) { + LightEvent_Wait(&privateVideoThreadEvent); + + if (!runThread) + break; + + if(gspHasGpuRight()) { + if (C3D_FrameBegin(C3D_FRAME_SYNCDRAW)){ +// if (C3D_FrameBegin(C3D_FRAME_NONBLOCK)){ + if (this->hidden->screens & SDL_TOPSCR) { + C3D_RenderTargetClear(VideoSurface1, C3D_CLEAR_ALL, RenderClearColor, 0); + C3D_FrameDrawOn(VideoSurface1); + C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, uLoc_projection, &projection); + drawTexture((400-this->hidden->w1*this->hidden->scalex)/2,(240-this->hidden->h1*this->hidden->scaley)/2, this->hidden->w1*this->hidden->scalex, this->hidden->h1*this->hidden->scaley, this->hidden->l1, this->hidden->r1, this->hidden->t1, this->hidden->b1); + } + if (this->hidden->screens & SDL_BOTTOMSCR) { + C3D_RenderTargetClear(VideoSurface2, C3D_CLEAR_ALL, RenderClearColor, 0); + C3D_FrameDrawOn(VideoSurface2); + C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, uLoc_projection, &projection2); + if (this->hidden->fitscreen & SDL_FITWIDTH) + drawTexture(0,(240-this->hidden->h2*this->hidden->scaley)/2, this->hidden->w2*this->hidden->scalex, this->hidden->h2*this->hidden->scaley, this->hidden->l2, this->hidden->r2, this->hidden->t2, this->hidden->b2); + else + drawTexture((400-this->hidden->w2*this->hidden->scalex*1.25)/2,(240-this->hidden->h2*this->hidden->scaley)/2, this->hidden->w2*this->hidden->scalex*1.25, this->hidden->h2*this->hidden->scaley, this->hidden->l2, this->hidden->r2, this->hidden->t2, this->hidden->b2); + } + C3D_FrameEnd(0); + } + } + } +} + +static void drawBuffers(_THIS) +{ + if(this->hidden->buffer) { + + if(!gspHasGpuRight()) return; // Blocking video output if the application is closing + + GSPGPU_FlushDataCache(this->hidden->buffer, this->hidden->w*this->hidden->h*this->hidden->byteperpixel); + + C3D_SyncDisplayTransfer ((u32*)this->hidden->buffer, GX_BUFFER_DIM(this->hidden->w, this->hidden->h), (u32*)spritesheet_tex.data, GX_BUFFER_DIM(this->hidden->w, this->hidden->h), textureTranferFlags[this->hidden->mode]); + + GSPGPU_FlushDataCache(spritesheet_tex.data, this->hidden->w*this->hidden->h*this->hidden->byteperpixel); + + C3D_TexBind(0, &spritesheet_tex); + // Configure the first fragment shading substage to just pass through the texture color + // See https://www.opengl.org/sdk/docs/man2/xhtml/glTexEnv.xml for more insight + C3D_TexEnv* env = C3D_GetTexEnv(0); + C3D_TexEnvInit(env); + C3D_TexEnvSrc(env, C3D_Both, GPU_TEXTURE0, 0, 0); + + C3D_TexEnvFunc(env, C3D_Both, GPU_REPLACE); + +// gspWaitForVBlank(); + LightEvent_Signal(&privateVideoThreadEvent); + } +} + +static void N3DS_UpdateRects(_THIS, int numrects, SDL_Rect *rects) +{ + if(!gspHasGpuRight()) return; //Block video output on quitting + + if( this->hidden->bpp == 8) { +/* + // update only changed rects + int i; + for(i=0; i< numrects; i++) { + SDL_Rect *rect = &rects[i]; + Uint8 *src_addr, *dst_addr, *src_baseaddr, *dst_baseaddr; + Uint32 *palette; + int cols, rows; + int x,y; + palette = this->hidden->palette; + src_baseaddr = this->hidden->palettedbuffer; + dst_baseaddr = this->hidden->buffer; + cols = (rect->x + rect->w > this->info.current_w) ? this->info.current_w - rect->x : rect->w; + rows = (rect->y + rect->h > this->info.current_h) ? this->info.current_h - rect->y : rect->h; + for(y=0;yx + x + (rect->y + y) * this->info.current_w; + dst_addr = dst_baseaddr + (rect->x + x + (rect->y + y) * this->hidden->w) * 4; + for(;xhidden->palette; + src_addr = this->hidden->palettedbuffer; + dst_baseaddr = this->hidden->buffer; + + int x, y; + for(y = 0; y < this->info.current_h; y++) { + dst_addr = dst_baseaddr + y * this->hidden->w; + for(x = 0; x < this->info.current_w; x++) { + *dst_addr++ = palette[*src_addr++]; + } + } + } + + drawBuffers(this); +} + +#define N3DS_MAP_RGB(r, g, b) ((Uint32)r << 24 | (Uint32)g << 16 | (Uint32)b << 8 | 0xff) + +static int N3DS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) +{ + int i; + Uint32* palette = this->hidden->palette; + + for (i = firstcolor; i < firstcolor + ncolors; i++) + { + int colorIndex = i - firstcolor; + palette[i] = N3DS_MAP_RGB(colors[colorIndex].r, colors[colorIndex].g, colors[colorIndex].b); + } + + return(1); +} + +static int N3DS_FlipHWSurface (_THIS, SDL_Surface *surface) { + + if(!gspHasGpuRight()) return(0); //Block video output on quitting + + if(this->hidden->bpp == 8) { + Uint8 *src_addr; + Uint32 *palette, *dst_baseaddr, *dst_addr; + palette = this->hidden->palette; + src_addr = this->hidden->palettedbuffer; + dst_baseaddr = this->hidden->buffer; + + int x, y; + for(y = 0; y < this->info.current_h; y++) { + dst_addr = dst_baseaddr + y * this->hidden->w; + for(x = 0; x < this->info.current_w; x++) { + *dst_addr++ = palette[*src_addr++]; + } + } + } + + drawBuffers(this); + + return (0); +} + +/* Note: If we are terminated, this could be called in the middle of + another SDL video routine -- notably UpdateRects. +*/ +void N3DS_VideoQuit(_THIS) +{ + if (privateVideoThreadHandle) { + runThread = false; + LightEvent_Signal(&privateVideoThreadEvent); + threadJoin(privateVideoThreadHandle, U64_MAX); + privateVideoThreadHandle = NULL; + } + if (this->hidden->buffer) + { + linearFree(this->hidden->buffer); + this->hidden->buffer = NULL; + } + if (this->hidden->palettedbuffer) + { + free(this->hidden->palettedbuffer); + this->hidden->palettedbuffer = NULL; + } + this->hidden->currentVideoSurface->pixels = NULL; // set to buffer or to palettedbuffer, so now pointing to not allocated memory + + sceneExit(); + C3D_Fini(); + gfxExit(); +} + + +//--------------------------------------------------------------------------------- +static void sceneInit(GSPGPU_FramebufferFormat mode, bool scale) { +//--------------------------------------------------------------------------------- + // Load the vertex shader, create a shader program and bind it + vshader_dvlb = DVLB_ParseFile((u32*)vshader_shbin, vshader_shbin_size); + shaderProgramInit(&program); + shaderProgramSetVsh(&program, &vshader_dvlb->DVLE[0]); + C3D_BindProgram(&program); + + // Get the location of the uniforms + uLoc_projection = shaderInstanceGetUniformLocation(program.vertexShader, "projection"); + + // Configure attributes for use with the vertex shader + // Attribute format and element count are ignored in immediate mode + C3D_AttrInfo* attrInfo = C3D_GetAttrInfo(); + AttrInfo_Init(attrInfo); + AttrInfo_AddLoader(attrInfo, 0, GPU_FLOAT, 3); // v0=position + AttrInfo_AddLoader(attrInfo, 1, GPU_FLOAT, 2); // v2=texcoord + + // Compute the projection matrix + // Note: we're setting top to 240 here so origin is at top left. + Mtx_OrthoTilt(&projection, 0.0, 400.0, 240.0, 0.0, 0.0, 1.0, true); + Mtx_OrthoTilt(&projection2, 0.0, 400.0, 240.0, 0.0, 0.0, 1.0, true); + + // Configure buffers + C3D_BufInfo* bufInfo = C3D_GetBufInfo(); + BufInfo_Init(bufInfo); + + if (mode<=1) { + gfxSetScreenFormat(GFX_TOP, GSP_BGR8_OES); + gfxSetScreenFormat(GFX_BOTTOM, GSP_BGR8_OES); + } else { + gfxSetScreenFormat(GFX_TOP, GSP_RGB565_OES); + gfxSetScreenFormat(GFX_BOTTOM, GSP_RGB565_OES); + } + + RenderClearColor = clearcolors[mode]; + + // Initialize the top screen render target + if (scale) + VideoSurface1 = C3D_RenderTargetCreate(240*2, 400*2, mode, GPU_RB_DEPTH24_STENCIL8); + else + VideoSurface1 = C3D_RenderTargetCreate(240, 400, mode, GPU_RB_DEPTH24_STENCIL8); + if(scale) + C3D_RenderTargetSetOutput(VideoSurface1, GFX_TOP, GFX_LEFT, displayTranferFlags[mode] | GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_XY)); + else + C3D_RenderTargetSetOutput(VideoSurface1, GFX_TOP, GFX_LEFT, displayTranferFlags[mode] | GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO)); + + // Initialize the bottom screen render target + if (scale) + VideoSurface2 = C3D_RenderTargetCreate(240*2, 320*2, mode, GPU_RB_DEPTH24_STENCIL8); + else + VideoSurface2 = C3D_RenderTargetCreate(240, 320, mode, GPU_RB_DEPTH24_STENCIL8); + if (scale) + C3D_RenderTargetSetOutput(VideoSurface2, GFX_BOTTOM, GFX_LEFT, displayTranferFlags[mode] | GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_XY)); + else + C3D_RenderTargetSetOutput(VideoSurface2, GFX_BOTTOM, GFX_LEFT, displayTranferFlags[mode] | GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO)); + + // Configure depth test to overwrite pixels with the same depth (needed to draw overlapping sprites) +// C3D_DepthTest(true, GPU_GEQUAL, GPU_WRITE_ALL); +} + +//--------------------------------------------------------------------------------- +static void sceneExit(void) { +//--------------------------------------------------------------------------------- + + if(VideoSurface1) C3D_RenderTargetDelete(VideoSurface1); + if (VideoSurface2) C3D_RenderTargetDelete(VideoSurface2); + // Free the shader program + shaderProgramFree(&program); + DVLB_Free(vshader_dvlb); +} + +//--------------------------------------------------------------------------------- +void drawTexture( int x, int y, int width, int height, float left, float right, float top, float bottom) { +//--------------------------------------------------------------------------------- + + // Draw a textured quad directly + C3D_ImmDrawBegin(GPU_TRIANGLE_STRIP); + C3D_ImmSendAttrib(x, y, 0.5f, 0.0f); // v0=position + C3D_ImmSendAttrib( left, top, 0.0f, 0.0f); + + C3D_ImmSendAttrib(x, y+height, 0.5f, 0.0f); + C3D_ImmSendAttrib( left, bottom, 0.0f, 0.0f); + + C3D_ImmSendAttrib(x+width, y, 0.5f, 0.0f); + C3D_ImmSendAttrib( right, top, 0.0f, 0.0f); + + C3D_ImmSendAttrib(x+width, y+height, 0.5f, 0.0f); + C3D_ImmSendAttrib( right, bottom, 0.0f, 0.0f); + C3D_ImmDrawEnd(); +} diff --git a/src/video/n3ds/SDL_n3dsvideo.h b/src/video/n3ds/SDL_n3dsvideo.h new file mode 100644 index 0000000000..4b204224a3 --- /dev/null +++ b/src/video/n3ds/SDL_n3dsvideo.h @@ -0,0 +1,63 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_n3dsvideo_h +#define _SDL_n3dsvideo_h + +#include "../SDL_sysvideo.h" + +#include <3ds.h> + +/* Hidden "this" pointer for the video functions */ +#define _THIS SDL_VideoDevice *this + +/* Private display data */ + +struct SDL_PrivateVideoData { +//GPU drawing specific + int x1,y1,w1,h1; // drawing window for top screen; width and height of top screen part of the video buffer + int x2,y2,w2,h2; // drawing window for bottom screen; width and height of bottom part of the video buffer + float l1,r1,t1,b1; // GPU source window for the top part of the video buffer + float l2,r2,t2,b2; // GPU source window for the bottom part of the video buffer + float scalex,scaley; // scaling factors + float scalex2,scaley2; // scaling factors + +// framebuffer data + int w, h; // width and height of the video buffer + void *buffer; + Uint8 *palettedbuffer; + Uint32 palette[256]; + GSPGPU_FramebufferFormat mode; + unsigned int flags; // backup of create device flags + unsigned int screens; // SDL_TOPSCR, SDL_BOTTOMSCR, SDL_DUALSCR + unsigned int console; // SDL_CONSOLETOP, SDL_CONSOLEBOTTOM + unsigned int fitscreen; // SDL_TRIMBOTTOMSCR, SDL_FITWIDTH, SDL_FITHEIGHT (SDL_FULLSCREEN sets both SDL_FITWIDTH and SDL_FITHEIGHT) + int byteperpixel; + int bpp; +// video surface + SDL_Surface* currentVideoSurface; +// Video process flags + bool blockVideo; // block video output and events handlings on SDL_QUIT +}; + +#endif /* _SDL_n3dsvideo_h */ diff --git a/src/video/n3ds/vshader.pica b/src/video/n3ds/vshader.pica new file mode 100644 index 0000000000..9f51b4a4dc --- /dev/null +++ b/src/video/n3ds/vshader.pica @@ -0,0 +1,34 @@ +; Example PICA200 vertex shader + +; Uniforms +.fvec projection[4] + +; Constants +.constf myconst(0.0, 1.0, -1.0, 0.1) +.constf myconst2(0.3, 0.0, 0.0, 0.0) +.alias zeros myconst.xxxx ; Vector full of zeros +.alias ones myconst.yyyy ; Vector full of ones + +; Outputs +.out outpos position +.out outtc0 texcoord0 + +; Inputs +.in inpos v0 +.in intex v1 + +.proc main + ; Force the w component of inpos to be 1.0 + mov r0.xyz, inpos + mov r0.w, ones + + ; outpos = projectionMatrix * inpos + dp4 outpos.x, projection[0], r0 + dp4 outpos.y, projection[1], r0 + dp4 outpos.z, projection[2], r0 + dp4 outpos.w, projection[3], r0 + + mov outtc0, intex + + end +.end ================================================ FILE: 3ds/SDL_gfx/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=3ds-sdl_gfx pkgver=2.0.25 pkgrel=2 pkgdesc="Graphics drawing primitives and other support functions wrapped up in an add-on, C-based library for the Simple Direct Media (SDL) cross-platform API layer" arch=('any') url="http://www.ferzkopp.net/wordpress/2016/01/02/sdl_gfx-sdl2_gfx/" license=("LGPL") options=(!strip libtool staticlibs) depends=( '3ds-sdl' ) makedepends=( '3ds-pkg-config' 'dkp-toolchain-vars' ) source=("https://sourceforge.net/projects/sdlgfx/files/SDL_gfx-${pkgver}.tar.gz") groups=('3ds-portlibs' '3ds-sdl-libs') sha256sums=( '556eedc06b6cf29eb495b6d27f2dcc51bf909ad82389ba2fa7bdc4dec89059c0' ) build() { cd SDL_gfx-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static \ --disable-mmx make } package() { cd SDL_gfx-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: 3ds/SDL_image/.gitignore ================================================ 3ds-sdl_image ================================================ FILE: 3ds/SDL_image/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=3ds-sdl_image pkgver=1.2.12 pkgrel=3 pkgdesc="A simple library to load images of various formats as SDL surfaces (Nintendo 3DS port)" arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) depends=( '3ds-sdl' '3ds-libpng' '3ds-libjpeg-turbo' ) makedepends=( '3ds-pkg-config' 'dkp-toolchain-vars' ) groups=('3ds-portlibs' '3ds-sdl-libs') source=("${url}/projects/SDL_image/release/SDL_image-${pkgver}.tar.gz") sha256sums=( '0b90722984561004de84847744d566809dbb9daf732a9e503b91a1b5a84e5699' ) build() { cd SDL_image-$pkgver sed -i 's,showimage\$(EXEEXT),,g' Makefile.in source /opt/devkitpro/3dsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd SDL_image-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install # add our static libs echo "Requires.private: libpng libturbojpeg" >> "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/SDL_image.pc" } ================================================ FILE: 3ds/SDL_mixer/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=3ds-sdl_mixer pkgver=1.2.12 pkgrel=9 pkgdesc="A simple multi-channel audio mixer library (Nintendo 3DS port)" arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) depends=( '3ds-sdl' '3ds-libvorbisidec' '3ds-mikmod' '3ds-libogg' '3ds-libmad' ) makedepends=( '3ds-pkg-config' 'dkp-toolchain-vars' ) source=("${url}/projects/SDL_mixer/release/SDL_mixer-${pkgver}.tar.gz") sha256sums=( '1644308279a975799049e4826af2cfc787cad2abb11aa14562e402521f86992a' ) groups=('3ds-portlibs' '3ds-sdl-libs') build() { cd SDL_mixer-$pkgver source /opt/devkitpro/3dsvars.sh sed -i 's,\$(objects)/playwave\$(EXE) \$(objects)/playmus\$(EXE),,g' Makefile.in LIBS="-logg" ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static \ --enable-music-ogg-tremor \ --disable-music-cmd \ --enable-music-mp3-mad-gpl make } package() { cd SDL_mixer-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install # add our static libs echo "Requires.private: vorbisidec ogg libmikmod" >> "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/SDL_mixer.pc" sed -i 's,-lSDL_mixer,-lSDL_mixer -lmad,' "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/SDL_mixer.pc" } ================================================ FILE: 3ds/SDL_ttf/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=3ds-sdl_ttf pkgver=2.0.11 pkgrel=2 pkgdesc="A sample library which allows you to use TrueType fonts in your SDL applications (Nintendo 3DS port)" arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) depends=( '3ds-freetype' '3ds-sdl' ) makedepends=( '3ds-pkg-config' 'dkp-toolchain-vars' ) source=("${url}/projects/SDL_ttf/release/SDL_ttf-${pkgver}.tar.gz") groups=('3ds-portlibs' '3ds-sdl-libs') sha256sums=( '724cd895ecf4da319a3ef164892b72078bd92632a5d812111261cde248ebcdb7' ) build() { cd SDL_ttf-$pkgver source /opt/devkitpro/3dsvars.sh sed '/^noinst_PROGRAMS/d' -i Makefile.in ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd SDL_ttf-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: 3ds/TinyXML2/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=3ds-tinyxml2 pkgver=6.0.0 pkgrel=2 pkgdesc='A simple, small, efficient, C++ XML parser that can be easily integrated into other programs (for Nintendo 3DS homebrew development)' arch=('any') url='http://leethomason.github.io/tinyxml2/' license=('apache') options=(!strip libtool staticlibs) source=( "https://github.com/leethomason/tinyxml2/archive/${pkgver}.tar.gz" ) makedepends=('dkp-toolchain-vars') sha256sums=('9444ba6322267110b4aca61cbe37d5dcab040344b5c97d0b36c119aa61319b0f') groups=('3ds-portlibs') build() { cd tinyxml2-$pkgver source /opt/devkitpro/3dsvars.sh cmake -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/3ds.cmake \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DCMAKE_C_FLAGS="$CFLAGS $CPPFLAGS" \ -DCMAKE_CXX_FLAGS="$CFLAGS -fno-exceptions -fno-rtti" \ -DCMAKE_AR="$DEVKITARM/bin/arm-none-eabi-gcc-ar" \ -DBUILD_TESTS:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON \ -G"Unix Makefiles" \ . make } package() { cd tinyxml2-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh make install DESTDIR="$pkgdir" } ================================================ FILE: 3ds/WildMidi/PKGBUILD ================================================ # Maintainer: WinterMute # Contributor: oreo639 pkgname=3ds-wildmidi pkgver=0.4.3 pkgrel=2 pkgdesc='Core softsynth library that can be used with other applications.' arch=('any') url='https://www.mindwerks.net/projects/wildmidi/' license=('LGPL') options=(!strip libtool staticlibs) source=( "https://github.com/Mindwerks/wildmidi/archive/wildmidi-${pkgver}.tar.gz" "wildmidi-0.4.3.patch") groups=('3ds-portlibs') makedepends=('dkp-toolchain-vars') sha256sums=( '498e5a96455bb4b91b37188ad6dcb070824e92c44f5ed452b90adbaec8eef3c5' '2ff10193fe06e908b0658f9035711576a2781314e3f0cfe7969dde590f18b813') build() { cd wildmidi-wildmidi-$pkgver source /opt/devkitpro/3dsvars.sh patch -p1 -i $srcdir/wildmidi-0.4.3.patch cmake . -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/3ds.cmake \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DCMAKE_C_FLAGS="$CFLAGS $CPPFLAGS" \ -DWANT_PLAYER=OFF -DWANT_STATIC=ON \ -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -G"Unix Makefiles" make } package() { cd wildmidi-wildmidi-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: 3ds/WildMidi/wildmidi-0.4.3.patch ================================================ diff -Naur wildmidi-wildmidi-0.4.2-orig/src/CMakeLists.txt wildmidi-wildmidi-0.4.2/src/CMakeLists.txt --- wildmidi-wildmidi-0.4.2-orig/src/CMakeLists.txt 2018-02-23 21:47:25.644089430 +0100 +++ wildmidi-wildmidi-0.4.2/src/CMakeLists.txt 2018-02-23 21:47:50.067439452 +0100 @@ -248,7 +248,6 @@ CONFIGURE_FILE("wildmidi.pc.in" "${CMAKE_BINARY_DIR}/wildmidi.pc" @ONLY) # install target (*nix OSes) -IF (UNIX AND NOT APPLE) # install our libraries IF (WANT_STATIC) INSTALL(TARGETS libwildmidi_static DESTINATION ${WILDMIDILIB_INSTALLDIR}) @@ -274,8 +273,6 @@ # install supporting man pages and headers INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/wildmidi_lib.h DESTINATION include) - INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/docs/man/ DESTINATION share/man) -ENDIF (UNIX AND NOT APPLE) # install target (Windows: MinGW or MinGW-w64) IF (WIN32 AND CMAKE_COMPILER_IS_MINGW) --- a/CMakeLists.txt 2018-10-04 06:56:52.000000000 -0700 +++ b/CMakeLists.txt 2018-11-14 16:40:18.567465492 -0800 @@ -56,14 +56,12 @@ # Platform specific defines -IF (UNIX) # allow 'large' files in 32 bit builds ADD_DEFINITIONS( -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES ) -ENDIF (UNIX) # Usage of RPATH for macOS is enabled by default; this just suppresses the CMP0042 warning # when building libwildmidi_dynamic. ================================================ FILE: 3ds/box2d/PKGBUILD ================================================ # Maintainer: TurtleP pkgbasename=box2d pkgname=3ds-$pkgbasename pkgver=2.4.1 pkgrel=1 pkgdesc='Box2D is a 2D physics engine for games.' arch=('any') url='https://github.com/erincatto/box2d' license=(MIT) options=(!strip libtool staticlibs) source=("${url}/archive/refs/tags/v${pkgver}.zip") sha256sums=('0cb512dfa5be79ca227cd881b279adee61249c85c8b51caf5aa036b71e943002') makedepends=('dkp-toolchain-vars' '3ds-cmake') groups=('3ds-portlibs') build() { cd ${pkgbasename}-${pkgver} source /opt/devkitpro/3dsvars.sh arm-none-eabi-cmake \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DBOX2D_BUILD_DOCS=OFF -DBOX2D_BUILD_UNIT_TESTS=OFF -DBOX2D_BUILD_TESTBED=OFF \ make } package() { cd ${pkgbasename}-${pkgver} make install DESTDIR="$pkgdir" } ================================================ FILE: 3ds/bulletphysics/PKGBUILD ================================================ # Maintainer: fincs pkgname=3ds-bulletphysics pkgver=2.87 pkgrel=5 pkgdesc='Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc. (for Nintendo 3DS homebrew development)' arch=('any') url='http://bulletphysics.org/' license=('apache') options=(!strip libtool staticlibs) source=( "https://github.com/bulletphysics/bullet3/archive/${pkgver}.tar.gz" "bulletphysics.patch") makedepends=('devkitARM' 'dkp-toolchain-vars' '3ds-cmake') sha256sums=( '438c151c48840fe3f902ec260d9496f8beb26dba4b17769a4a53212903935f95' 'ab9b5c35c7eb98336f685595a2c3c6da11ac1b2935cbef2b699ebe597827ed91' ) groups=('3ds-portlibs') build() { cd bullet3-$pkgver source /opt/devkitpro/3dsvars.sh patch -Np1 -i "$srcdir"/bulletphysics.patch arm-none-eabi-cmake -G"Unix Makefiles" \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DCMAKE_C_FLAGS="$CFLAGS $CPPFLAGS" \ -DCMAKE_CXX_FLAGS="$CFLAGS -fno-exceptions -fno-rtti" \ -DCMAKE_AR="$DEVKITARM/bin/arm-none-eabi-gcc-ar" \ -DBUILD_CPU_DEMOS:BOOL=OFF -DBUILD_BULLET3:BOOL=OFF -DBUILD_OPENGL3_DEMOS:BOOL=OFF -DBUILD_BULLET2_DEMOS:BOOL=OFF -DBUILD_EXTRAS:BOOL=OFF -DBUILD_UNIT_TESTS:BOOL=OFF \ . make } package() { cd bullet3-$pkgver source /opt/devkitpro/3dsvars.sh make install DESTDIR="$pkgdir" install -Dm644 "LICENSE.txt" "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}/LICENSE.txt" } ================================================ FILE: 3ds/bulletphysics/bulletphysics.patch ================================================ --- bullet3-2.87/CMakeLists.txt 2017-09-30 00:20:39.000000000 +0100 +++ bullet3-2.87-3ds/CMakeLists.txt 2018-11-20 01:14:42.028362942 +0000 @@ -282,15 +282,17 @@ # This is the shortcut to finding GLU, GLUT and OpenGL if they are properly installed on your system # This should be the case. -FIND_PACKAGE(OpenGL) -IF (OPENGL_FOUND) +IF(NOT NINTENDO_3DS) + FIND_PACKAGE(OpenGL) + IF (OPENGL_FOUND) MESSAGE("OPENGL FOUND") MESSAGE(${OPENGL_LIBRARIES}) -ELSE (OPENGL_FOUND) + ELSE (OPENGL_FOUND) MESSAGE("OPENGL NOT FOUND") SET(OPENGL_gl_LIBRARY opengl32) SET(OPENGL_glu_LIBRARY glu32) -ENDIF (OPENGL_FOUND) + ENDIF (OPENGL_FOUND) +ENDIF(NOT NINTENDO_3DS) #FIND_PACKAGE(GLU) @@ -303,6 +305,7 @@ OPTION(BUILD_BULLET3 "Set when you want to build Bullet 3" ON) # Optional Python configuration # builds pybullet automatically if all the requirements are met +IF(NOT NINTENDO_3DS) SET(PYTHON_VERSION_PYBULLET "" CACHE STRING "Python version pybullet will use.") SET(Python_ADDITIONAL_VERSIONS 3 3.6 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.7.12 2.7.10 2.7.3 ) SET_PROPERTY(CACHE PYTHON_VERSION_PYBULLET PROPERTY STRINGS ${Python_ADDITIONAL_VERSIONS}) @@ -320,6 +323,7 @@ SET(DEFAULT_BUILD_PYBULLET ON) ENDIF(PYTHONLIBS_FOUND) OPTION(BUILD_PYBULLET "Set when you want to build pybullet (Python bindings for Bullet)" ${DEFAULT_BUILD_PYBULLET}) +ENDIF(NOT NINTENDO_3DS) OPTION(BUILD_ENET "Set when you want to build apps with enet UDP networking support" ON) OPTION(BUILD_CLSOCKET "Set when you want to build apps with enet TCP networking support" ON) ================================================ FILE: 3ds/bzip2/.gitignore ================================================ 3ds-bzip2 ================================================ FILE: 3ds/bzip2/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('3ds-bzip2') pkgver=1.0.8 pkgrel=1 pkgdesc="A high-quality data compression program" arch=('any') license=('custom') url="https://sourceware.org/bzip2/" options=(!strip libtool staticlibs) source=(https://sourceware.org/pub/bzip2/bzip2-${pkgver}.tar.gz) sha256sums=( 'ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269' ) makedepends=('devkitARM' 'devkitarm-rules' 'devkitarm-crtls' '3ds-pkg-config' 'dkp-toolchain-vars') groups=('3ds-portlibs') build() { source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh make -C "$srcdir/bzip2-$pkgver" \ CC=arm-none-eabi-gcc \ AR=arm-none-eabi-ar \ RANLIB=arm-none-eabi-ranlib \ CPPFLAGS="${CPPFLAGS}" \ CFLAGS="-D_FILE_OFFSET_BITS=64 -Winline ${CFLAGS}" libbz2.a } package() { source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh install -Dm 644 "$srcdir/bzip2-$pkgver"/LICENSE -t "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}" install -Dm 644 "$srcdir/bzip2-$pkgver"/bzlib.h -t "${pkgdir}/${PORTLIBS_PREFIX}/include/" install -Dm 644 "$srcdir/bzip2-$pkgver"/libbz2.a -t "${pkgdir}/${PORTLIBS_PREFIX}/lib" } ================================================ FILE: 3ds/curl/.gitignore ================================================ 3ds-curl ================================================ FILE: 3ds/curl/PKGBUILD ================================================ # Maintainer: WinterMute # Contributor: Elouan Martinet pkgname=3ds-curl pkgver=8.4.0 pkgrel=1 pkgdesc='Library for transferring data with URLs. (for Nintendo 3DS homebrew development)' arch=('any') url='https://curl.haxx.se' license=('MIT') options=(!strip libtool staticlibs) depends=('3ds-zlib' '3ds-mbedtls') makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') source=("https://curl.haxx.se/download/curl-${pkgver}.tar.xz" "curl-${pkgver}.patch" ) sha256sums=('03c7d5e6697f7b7e40ada1b2256e565a555657398e6c1fcfa4cb251ccd819d4f' 'fd18f93838addd62776b30c699ab9ea472e1d7f31f3d19d28c92728830a06413') groups=('3ds-portlibs') build() { cd curl-$pkgver source /opt/devkitpro/3dsvars.sh patch -Np1 -i $srcdir/curl-${pkgver}.patch ./configure CFLAGS="${CFLAGS}" CPPFLAGS="${CPPFLAGS}" LIBS="-lctru" \ --prefix=${PORTLIBS_PREFIX} \ --host=arm-none-eabi \ --disable-shared \ --enable-static \ --disable-ipv6 \ --disable-unix-sockets \ --disable-threaded-resolver \ --disable-manual \ --disable-pthreads \ --disable-socketpair \ --disable-ntlm-wb \ --with-mbedtls=${PORTLIBS_PREFIX} \ --with-ca-bundle=sdmc:/config/ssl/cacert.pem make -C lib } package() { cd curl-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" -C lib install make DESTDIR="$pkgdir" -C include install make DESTDIR="$pkgdir" install-binSCRIPTS install-pkgconfigDATA mkdir -p "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname install -m644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING } sha256sums=('16c62a9c4af0f703d28bda6d7bbf37ba47055ad3414d70dec63e2e6336f2a82d' 'e41d19d24631f3dce4a0e1c5f9fd92c36f4ddd803d07a943507dab525813ecbe') ================================================ FILE: 3ds/curl/curl-8.4.0.patch ================================================ diff --git a/lib/cf-socket.c b/lib/cf-socket.c index ce3f9e943..62d1ed4a3 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -161,6 +161,7 @@ static void tcpkeepalive(struct Curl_easy *data, curl_socket_t sockfd) { +#ifndef __3DS__ int optval = data->set.tcp_keepalive?1:0; /* only set IDLE and INTVL if setting KEEPALIVE is successful */ @@ -211,6 +212,7 @@ tcpkeepalive(struct Curl_easy *data, #endif #endif } +#endif } /** @@ -658,6 +660,7 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn, static bool verifyconnect(curl_socket_t sockfd, int *error) { bool rc = TRUE; +#ifndef __3DS__ #ifdef SO_ERROR int err = 0; curl_socklen_t errSize = sizeof(err); @@ -715,6 +718,7 @@ static bool verifyconnect(curl_socket_t sockfd, int *error) (void)sockfd; if(error) *error = SOCKERRNO; +#endif #endif return rc; } diff --git a/lib/curl_addrinfo.c b/lib/curl_addrinfo.c index f9211d3f5..4d9054257 100644 --- a/lib/curl_addrinfo.c +++ b/lib/curl_addrinfo.c @@ -141,9 +141,11 @@ Curl_getaddrinfo_ex(const char *nodename, if(!ai->ai_addr || !(ai->ai_addrlen > 0)) continue; +#if 0 // 3DS socu returns ai_addrlen = 8 /* ignore elements with bogus address size */ if((size_t)ai->ai_addrlen < ss_size) continue; +#endif ca = malloc(sizeof(struct Curl_addrinfo) + ss_size + namelen); if(!ca) { ================================================ FILE: 3ds/flac/.gitignore ================================================ 3ds-flac ================================================ FILE: 3ds/flac/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: cpasjuste # Contributor: oreo639 pkgname=3ds-flac pkgver=1.3.4 pkgrel=1 pkgdesc='Open source Free Lossless Audio Codec' arch=('any') url='https://xiph.org/flac/' license=(Xiph.org) options=(!strip libtool staticlibs) depends=("3ds-libogg") makedepends=('dkp-toolchain-vars') groups=('3ds-portlibs') source=( "https://ftp.osuosl.org/pub/xiph/releases/flac/flac-$pkgver.tar.xz" "flac-${pkgver}.patch" ) sha256sums=( '8ff0607e75a322dd7cd6ec48f4f225471404ae2730d0ea945127b1355155e737' 'ad264b37cd1e36f418f9ada7fc117f13b18659187d947600d4de05ce4eca4a25' ) build() { cd flac-$pkgver source /opt/devkitpro/3dsvars.sh patch -Np1 -i "$srcdir/flac-${pkgver}.patch" ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static --disable-examples \ --disable-xmms-plugin --disable-doxygen-docs \ --disable-sse --disable-oggtest --disable-thorough-tests make -C src/libFLAC } package() { cd flac-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: 3ds/flac/flac-1.3.4.patch ================================================ diff -Naur flac-1.3.4.orig/include/share/compat.h flac-1.3.4/include/share/compat.h --- flac-1.3.4.orig/include/share/compat.h 2021-07-09 13:24:42.168553000 -0700 +++ flac-1.3.4/include/share/compat.h 2022-04-10 14:46:25.896436562 -0700 @@ -163,17 +163,27 @@ #define flac_vfprintf vfprintf #define flac_fopen fopen -#define flac_chmod chmod #define flac_unlink unlink #define flac_rename rename #define flac_stat stat +#ifdef __3DS__ +#define flac_chmod(a, b) printf("flac_chmod: not implemented\n") +#define chown(a, b, c) printf("flac_chown: not implemented\n") +#else + #define flac_chmod chmod +#endif + +#ifdef __3DS__ +#define flac_utime(a, b) printf("flac_utime: not implemented\n") +#else #if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) #define flac_utime(a, b) utimensat (AT_FDCWD, a, *b, 0) #else #define flac_utime utime #endif #endif +#endif #ifdef _WIN32 #define flac_stat_s __stat64 /* stat struct */ diff -Naur flac-1.3.4.orig/Makefile.in flac-1.3.4/Makefile.in --- flac-1.3.4.orig/Makefile.in 2022-02-20 10:55:03.025219000 -0800 +++ flac-1.3.4/Makefile.in 2022-04-10 15:03:22.399528198 -0700 @@ -403,7 +403,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = doc include m4 man src test build microbench oss-fuzz \ +SUBDIRS = include m4 src test build microbench oss-fuzz \ $(am__append_1) EXTRA_DIST = \ CMakeLists.txt \ diff -Naur flac-1.3.4.orig/src/Makefile.in flac-1.3.4/src/Makefile.in --- flac-1.3.4.orig/src/Makefile.in 2022-02-20 10:55:03.619219000 -0800 +++ flac-1.3.4/src/Makefile.in 2022-04-10 15:03:34.442552908 -0700 @@ -371,8 +371,6 @@ SUBDIRS = \ libFLAC \ share \ - flac \ - metaflac \ $(XMMS_DIRS) \ test_grabbag \ test_libs_common \ ================================================ FILE: 3ds/flite/.gitignore ================================================ 3ds-flite ================================================ FILE: 3ds/flite/PKGBUILD ================================================ pkgname=3ds-flite pkgver=2.1 pkgrel=2 pkgdesc='A small fast portable speech synthesis system' arch=('any') url='http://festvox.org/flite/' license=('MIT') options=(!strip libtool staticlibs) depends=() makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') groups=('3ds-portlibs') source=("http://festvox.org/flite/packed/flite-${pkgver}/flite-${pkgver}-release.tar.bz2") sha256sums=('c73c3f6a2ea764977d6eaf0a287722d1e2066b4697088c552e342c790f3d2b85') build() { cd flite-$pkgver-release source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh ./configure --prefix=$PORTLIBS_PREFIX --host=arm-none-eabi --disable-shared \ CFLAGS="${CFLAGS}" CPPFLAGS="${CPPFLAGS}" LIBS="${LIBS}" make -C src make -C lang } package() { cd flite-$pkgver-release source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh mkdir -p $pkgdir$PORTLIBS_PREFIX/lib cp -a build/arm-eabi/lib/. $pkgdir$PORTLIBS_PREFIX/lib/ mkdir -p $pkgdir$PORTLIBS_PREFIX/include/flite/ install -m 644 include/*.h $pkgdir$PORTLIBS_PREFIX/include/flite/ install -Dm644 COPYING $pkgdir$PORTLIBS_PREFIX/licenses/$pkgname/COPYING } ================================================ FILE: 3ds/freetype/.gitignore ================================================ 3ds-freetype ================================================ FILE: 3ds/freetype/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname="3ds-freetype" pkgver=2.14.1 pkgrel=1 pkgdesc="TrueType font rendering library (mingw-w64)" arch=('any') url="https://www.freetype.org/" license=(GPL2+ custom:FreeType) depends=("3ds-bzip2" "3ds-libpng" "3ds-zlib") makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') options=('!strip' '!libtool' 'staticlibs') source=(https://downloads.sourceforge.net/sourceforge/freetype/freetype-${pkgver}.tar.xz) groups=('3ds-portlibs') build() { source /opt/devkitpro/3dsvars.sh cd freetype-${pkgver} ./configure \ --enable-freetype-config \ --host=arm-none-eabi \ --target=arm-none-eabi \ --prefix=${PORTLIBS_PREFIX} \ --enable-static \ --disable-shared \ --with-zlib \ --with-bzip2 \ --without-harfbuzz \ --with-png make } package () { source /opt/devkitpro/3dsvars.sh cd freetype-${pkgver} make DESTDIR="${pkgdir}" install # patch the config script to always output static libraries when not relying on pkg-config sed 's/\$show_static/yes/' -i "${pkgdir}/${PORTLIBS_PREFIX}/bin/freetype-config" # Licenses install -Dm644 "LICENSE.TXT" "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}/LICENSE.TXT" install -Dm644 "docs/GPLv2.TXT" "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}/GPLv2.TXT" install -Dm644 "docs/FTL.TXT" "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}/FTL.TXT" } sha256sums=('32427e8c471ac095853212a37aef816c60b42052d4d9e48230bab3bdf2936ccc') ================================================ FILE: 3ds/giflib/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Colin969 pkgname=3ds-giflib pkgver=5.1.4 pkgrel=3 pkgdesc='A library for reading and writing gif images' arch=('any') url='http://sourceforge.net/projects/giflib' license=('MIT') options=(!strip libtool staticlibs) source=("http://downloads.sourceforge.net/sourceforge/giflib/giflib-${pkgver}.tar.bz2") sha256sums=('df27ec3ff24671f80b29e6ab1c4971059c14ac3db95406884fc26574631ba8d5') makedepends=('dkp-toolchain-vars') groups=('3ds-portlibs') build() { source /opt/devkitpro/3dsvars.sh cd giflib-$pkgver ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi make } package() { cd giflib-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="${pkgdir}" install # MIT License install -Dm644 COPYING "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/COPYING" rm -fr "${pkgdir}/${PORTLIBS_PREFIX}/bin" } ================================================ FILE: 3ds/jansson/.gitignore ================================================ 3ds-jansson ================================================ FILE: 3ds/jansson/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Cpasjuste pkgname=3ds-jansson pkgver=2.13 pkgrel=1 pkgdesc='A C library for encoding, decoding and manipulating JSON data.' arch=('any') url='http://www.digip.org/jansson/' license=('custom') options=(!strip libtool staticlibs) makedepends=('dkp-toolchain-vars') source=("http://www.digip.org/jansson/releases/jansson-$pkgver.tar.gz") groups=('3ds-portlibs') sha256sums=('02c31bc16e702b30feb06d18bbfe086c0d8c938e906950980af7adcdb324541b') build() { cd jansson-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd jansson-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 LICENSE "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/LICENSE } ================================================ FILE: 3ds/libarchive/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=3ds-libarchive pkgver=3.7.4 pkgrel=1 pkgdesc='library that can create and read several streaming archive format (for Nintendo 3DS homebrew development)' arch=('any') url="https://www.libarchive.org" license=('Simplified BSD') options=(!strip libtool staticlibs) source=( "http://www.libarchive.org/downloads/libarchive-${pkgver}.tar.gz" "libarchive-${pkgver}.patch" ) makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') depends=('3ds-bzip2' '3ds-zlib' '3ds-liblzma' '3ds-libzstd') groups=('3ds-portlibs') build() { cd libarchive-$pkgver source /opt/devkitpro/3dsvars.sh patch -Np1 -i "$srcdir"/libarchive-${pkgver}.patch arm-none-eabi-cmake -B _3ds -S . -GNinja \ -DENABLE_TAR=OFF \ -DENABLE_TEST=OFF \ -DENABLE_CAT=OFF \ -DENABLE_CPIO=OFF \ -DENABLE_UNZIP=OFF cmake --build _3ds } package() { cd libarchive-$pkgver source /opt/devkitpro/3dsvars.sh DESTDIR="$pkgdir" cmake --install _3ds # license install -Dm644 "$srcdir"/libarchive-${pkgver}/COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING # remove useless stuff rm -fr "$pkgdir"${PORTLIBS_PREFIX}/share } sha256sums=('7875d49596286055b52439ed42f044bd8ad426aa4cc5aabd96bfe7abb971d5e8' 'b08920a298b3142e2075379542d85e6471baac634034b25009d6b5c5d30d56e1') ================================================ FILE: 3ds/libarchive/libarchive-3.7.4.patch ================================================ diff --git a/libarchive/archive_read_disk_posix.c b/libarchive/archive_read_disk_posix.c index 76a4fa44..efd192ec 100644 --- a/libarchive/archive_read_disk_posix.c +++ b/libarchive/archive_read_disk_posix.c @@ -98,8 +98,10 @@ #include "archive_read_disk_private.h" #ifndef HAVE_FCHDIR +#ifndef __3DS__ #error fchdir function required. #endif +#endif #ifndef O_BINARY #define O_BINARY 0 #endif diff --git a/libarchive/archive_read_support_filter_program.c b/libarchive/archive_read_support_filter_program.c index 0482c57c..87b8fa76 100644 --- a/libarchive/archive_read_support_filter_program.c +++ b/libarchive/archive_read_support_filter_program.c @@ -57,6 +57,13 @@ #include "archive_read_private.h" #include "filter_fork.h" +#ifdef __3DS__ +int +__archive_read_program(struct archive_read_filter *self, const char *cmd) { + return (ARCHIVE_OK); +} +#else + #if ARCHIVE_VERSION_NUMBER < 4000000 /* Deprecated; remove in libarchive 4.0 */ @@ -493,3 +500,6 @@ program_filter_close(struct archive_read_filter *self) return (e); } + +#endif + diff --git a/libarchive/archive_write_set_format_iso9660.c b/libarchive/archive_write_set_format_iso9660.c index 2a3ae07f..56627bc0 100644 --- a/libarchive/archive_write_set_format_iso9660.c +++ b/libarchive/archive_write_set_format_iso9660.c @@ -2178,9 +2178,11 @@ get_system_identitier(char *system_id, size_t size) strncpy(system_id, "Windows", size-1); system_id[size-1] = '\0'; #else +#ifndef __3DS__ strncpy(system_id, "Unknown", size-1); system_id[size-1] = '\0'; #endif +#endif } static void @@ -2506,7 +2508,7 @@ get_gmoffset(struct tm *tm) #if defined(HAVE__GET_TIMEZONE) _get_timezone(&offset); -#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) +#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) || defined(__3DS__) offset = _timezone; #else offset = timezone; diff --git a/libarchive/archive_xxhash.h b/libarchive/archive_xxhash.h index 1c7131ca..b665b65c 100644 --- a/libarchive/archive_xxhash.h +++ b/libarchive/archive_xxhash.h @@ -31,16 +31,33 @@ #error This header is only to be used internally to libarchive. #endif +/*************************************** +** Basic Types +****************************************/ +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ +# include + typedef uint8_t BYTE; + typedef uint16_t U16; + typedef uint32_t U32; + typedef int32_t S32; + typedef uint64_t U64; +#else + typedef unsigned char BYTE; + typedef unsigned short U16; + typedef unsigned int U32; + typedef signed int S32; + typedef unsigned long long U64; +#endif typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode; struct archive_xxhash { - unsigned int (*XXH32)(const void* input, unsigned int len, - unsigned int seed); - void* (*XXH32_init)(unsigned int seed); + U32 (*XXH32)(const void* input, unsigned int len, + U32 seed); + void* (*XXH32_init)(U32 seed); XXH_errorcode (*XXH32_update)(void* state, const void* input, unsigned int len); - unsigned int (*XXH32_digest)(void* state); + U32 (*XXH32_digest)(void* state); }; extern const struct archive_xxhash __archive_xxhash; diff --git a/libarchive/xxhash.c b/libarchive/xxhash.c index beacd239..06b44ff4 100644 --- a/libarchive/xxhash.c +++ b/libarchive/xxhash.c @@ -93,33 +93,15 @@ You can contact the author at : #define XXH_memcpy memcpy -static unsigned int XXH32 (const void*, unsigned int, unsigned int); -static void* XXH32_init (unsigned int); -static XXH_errorcode XXH32_update (void*, const void*, unsigned int); -static unsigned int XXH32_digest (void*); -/*static int XXH32_sizeofState(void);*/ -static XXH_errorcode XXH32_resetState(void*, unsigned int); +static U32 XXH32 (const void*, unsigned int, U32); +static void* XXH32_init (U32); +static XXH_errorcode XXH32_update (void*, const void*, unsigned int); +static U32 XXH32_digest (void*); +/*static int XXH32_sizeofState(void);*/ +static XXH_errorcode XXH32_resetState(void*, U32); #define XXH32_SIZEOFSTATE 48 typedef struct { long long ll[(XXH32_SIZEOFSTATE+(sizeof(long long)-1))/sizeof(long long)]; } XXH32_stateSpace_t; -static unsigned int XXH32_intermediateDigest (void*); - -/*************************************** -** Basic Types -****************************************/ -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ -# include - typedef uint8_t BYTE; - typedef uint16_t U16; - typedef uint32_t U32; - typedef int32_t S32; - typedef uint64_t U64; -#else - typedef unsigned char BYTE; - typedef unsigned short U16; - typedef unsigned int U32; - typedef signed int S32; - typedef unsigned long long U64; -#endif +static U32 XXH32_intermediateDigest (void*); #if defined(__GNUC__) && !defined(XXH_USE_UNALIGNED_ACCESS) # define _PACKED __attribute__ ((packed)) diff --git a/libarchive_fe/passphrase.c b/libarchive_fe/passphrase.c index 90fef32d..a74f3f05 100644 --- a/libarchive_fe/passphrase.c +++ b/libarchive_fe/passphrase.c @@ -129,9 +129,12 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags) #endif #include #include +#ifndef __3DS__ #include +#endif #include +#ifndef __3DS__ #ifndef _PATH_TTY #define _PATH_TTY "/dev/tty" #endif @@ -316,7 +319,12 @@ restart: } #endif /* _WIN32 && !__CYGWIN__ */ #endif /* HAVE_READPASSPHRASE */ - +#else +static char* readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags) +{ + return NULL; +} +#endif /* __3DS__ */ char * lafe_readpassphrase(const char *prompt, char *buf, size_t bufsiz) { ================================================ FILE: 3ds/libconfig/.gitignore ================================================ 3ds-libconfig ================================================ FILE: 3ds/libconfig/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=3ds-libconfig pkgver=1.7.2 pkgrel=3 pkgdesc='C/C++ Configuration File Library (for Nintendo 3DS homebrew development)' arch=('any') url="https://www.hyperrealm.com/libconfig/libconfig.html" license=('LGPL') options=(!strip libtool staticlibs) source=("https://hyperrealm.github.io/libconfig/dist/libconfig-${pkgver}.tar.gz" "libconfig.patch") makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') sha256sums=( '7c3c7a9c73ff3302084386e96f903eb62ce06953bb1666235fac74363a16fad9' '474c17940200d4aa286e486568a0ecaba2130a758f108e2a0b86c6fed5915d1f' ) groups=('3ds-portlibs') build() { cd libconfig-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh patch -Np1 -i "$srcdir"/libconfig.patch ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static \ --disable-examples make } package() { cd libconfig-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 COPYING.LIB "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING.LIB # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share } ================================================ FILE: 3ds/libconfig/libconfig.patch ================================================ diff -Naur libconfig-1.7.2-ori/lib/libconfig.c libconfig-1.7.2-new/lib/libconfig.c --- libconfig-1.7.2-ori/lib/libconfig.c 2017-12-02 19:12:14.000000000 +0100 +++ libconfig-1.7.2-new/lib/libconfig.c 2020-05-24 15:17:00.850073719 +0200 @@ -78,48 +78,12 @@ static void __config_locale_override(void) { -#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ - && ! defined(__MINGW32__) - - _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); - setlocale(LC_NUMERIC, "C"); - -#elif defined(__APPLE__) - - locale_t loc = newlocale(LC_NUMERIC_MASK, "C", NULL); - uselocale(loc); - -#elif ((defined HAVE_NEWLOCALE) && (defined HAVE_USELOCALE)) - - locale_t loc = newlocale(LC_NUMERIC, "C", NULL); - uselocale(loc); - -#else - -#warning "No way to modify calling thread's locale!" - -#endif } /* ------------------------------------------------------------------------- */ static void __config_locale_restore(void) { -#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ - && ! defined(__MINGW32__) - - _configthreadlocale(_DISABLE_PER_THREAD_LOCALE); - -#elif ((defined HAVE_USELOCALE) && (defined HAVE_FREELOCALE)) - - locale_t loc = uselocale(LC_GLOBAL_LOCALE); - freelocale(loc); - -#else - -#warning "No way to modify calling thread's locale!" - -#endif } /* ------------------------------------------------------------------------- */ ================================================ FILE: 3ds/libfribidi/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: carstene1ns pkgname=3ds-libfribidi pkgver=1.0.12 pkgrel=1 pkgdesc='Free Implementation of the Unicode Bidirectional Algorithm (Nintendo 3DS port)' arch=('any') url="https://github.com/fribidi/fribidi" license=('LGPL2.1') options=(!strip staticlibs) makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') source=("https://github.com/fribidi/fribidi/releases/download/v$pkgver/fribidi-$pkgver.tar.xz") sha256sums=('0cd233f97fc8c67bb3ac27ce8440def5d3ffacf516765b91c2cc654498293495') groups=('3ds-portlibs') prepare() { cd fribidi-$pkgver # patch out binaries, as they conflict with getopt and do not work anyway sed '/^SUBDIRS/ s/bin //' -i Makefile.am ./autogen.sh } build() { cd fribidi-$pkgver source /opt/devkitpro/3dsvars.sh ./configure --prefix="$PORTLIBS_PREFIX" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd fribidi-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install # remove documentation rm -fr "$pkgdir"${PORTLIBS_PREFIX}/share } ================================================ FILE: 3ds/libiconv/PKGBUILD ================================================ pkgname=3ds-libiconv pkgver=1.17 pkgrel=1 pkgdesc='' arch=('any') url='https://www.gnu.org/software/libiconv/' license=('LGPL') options=(!strip libtool staticlibs) depends=() makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') groups=('3ds-portlibs') source=( "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-${pkgver}.tar.gz" libiconv-${pkgver}.patch ) build() { cd libiconv-$pkgver patch -p0 -i ${srcdir}/libiconv-${pkgver}.patch source /opt/devkitpro/3dsvars.sh ./configure --prefix=$PORTLIBS_PREFIX --host=arm-none-eabi --disable-shared \ CFLAGS="${CFLAGS}" CPPFLAGS="${CPPFLAGS}" LIBS="${LIBS}" make } package() { cd libiconv-$pkgver source /opt/devkitpro/3dsvars.sh make install-lib includedir=${pkgdir}/${PORTLIBS_PREFIX}/include libdir=${pkgdir}/${PORTLIBS_PREFIX}/lib } sha256sums=('8f74213b56238c85a50a5329f77e06198771e70dd9a739779f4c02f65d971313' '50b1331b9bf8aa115846db958ebb8e73d80bb5a224ffc892041edce9a4af88b3') ================================================ FILE: 3ds/libiconv/libiconv-1.17.patch ================================================ --- Makefile.in~ 2023-06-12 18:17:08 +++ Makefile.in 2023-06-12 18:20:01 @@ -31,11 +31,6 @@ all : lib/localcharset.h force cd lib && $(MAKE) all - cd srclib && $(MAKE) all - cd src && $(MAKE) all - cd po && $(MAKE) all - cd man && $(MAKE) all - if test -d tests; then cd tests && $(MAKE) all; fi lib/localcharset.h : builddir="`pwd`"; cd libcharset && $(MAKE) all && $(MAKE) install-lib libdir="$$builddir/lib" includedir="$$builddir/lib" ================================================ FILE: 3ds/libid3tag/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=3ds-libid3tag pkgver=0.15.1b pkgrel=2 pkgdesc='A library for reading and (eventually) writing ID3 tags, both ID3v1 and the various versions of ID3v2. (for Nintendo 3DS homebrew development)' arch=('any') url='https://www.underbit.com' license=('GPL') options=(!strip libtool staticlibs) source=("https://sourceforge.net/projects/mad/files/libid3tag/0.15.1b/libid3tag-${pkgver}.tar.gz") groups=('3ds-portlibs') sha256sums=('63da4f6e7997278f8a3fef4c6a372d342f705051d1eeb6a46a86b03610e26151') depends=('3ds-zlib') makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') build() { cd libid3tag-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh CPPFLAGS="${CFLAGS} ${CPPFLAGS}" ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi --disable-shared --enable-static make } package() { cd libid3tag-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: 3ds/libjpeg-turbo/.gitignore ================================================ 3ds-libjpeg-turbo ================================================ FILE: 3ds/libjpeg-turbo/PKGBUILD ================================================ # Maintainer: WinterMute _libname=libjpeg-turbo pkgname=3ds-${_libname} pkgver=3.1.3 pkgrel=1 pkgdesc='libjpeg derivative with accelerated baseline JPEG compression and decompression' arch=('any') url='https://github.com/libjpeg-turbo/libjpeg-turbo' license=('IJG') options=(!strip libtool staticlibs) source=( "${_libname}-${pkgver}.tar.gz::${url}/archive/refs/tags/${pkgver}.tar.gz" ) sha256sums=('3a13a5ba767dc8264bc40b185e41368a80d5d5f945944d1dbaa4b2fb0099f4e5') makedepends=('3ds-cmake' '3ds-pkg-config' 'dkp-toolchain-vars') groups=('3ds-portlibs') build() { cd libjpeg-turbo-$pkgver source /opt/devkitpro/3dsvars.sh arm-none-eabi-cmake -DENABLE_SHARED:BOOLEAN=false -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX . make } package() { cd libjpeg-turbo-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install # license install -d "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname cp -v LICENSE.md "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/ # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share rm -r "$pkgdir"${PORTLIBS_PREFIX}/bin } ================================================ FILE: 3ds/libjson-c/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Pablo Curiel pkgname=3ds-libjson-c pkgver=0.16 pkgrel=1 pkgdesc='A JSON implementation in C.' arch=('any') url='https://github.com/json-c/json-c/' license=('MIT') options=(!strip libtool staticlibs) source=( "https://s3.amazonaws.com/json-c_releases/releases/json-c-${pkgver}.tar.gz" "json-c-${pkgver}.patch" ) sha256sums=( '8e45ac8f96ec7791eaf3bb7ee50e9c2100bbbc87b8d0f1d030c5ba8a0288d96b' 'b4936c9cba4e80f3c7c12148d4f511ed3472bd94c7aebb13e0ea9679435d1399' ) makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') groups=('3ds-portlibs') build() { cd json-c-$pkgver patch -p0 -i ${srcdir}/json-c-${pkgver}.patch source /opt/devkitpro/3dsvars.sh arm-none-eabi-cmake \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DBUILD_SHARED_LIBS=OFF \ -DBUILD_STATIC_LIBS=ON \ -DDISABLE_THREAD_LOCAL_STORAGE=TRUE \ -DCMAKE_BUILD_TYPE=Release \ . make } package() { cd json-c-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: 3ds/libjson-c/json-c-0.16.patch ================================================ --- CMakeLists.txt.orig 2023-03-06 22:27:27.653258333 +0000 +++ CMakeLists.txt 2023-03-06 22:29:07.183682590 +0000 @@ -105,7 +105,7 @@ option(DISABLE_JSON_POINTER "Disable JSON pointer (RFC6901) support." OFF) -if (UNIX OR MINGW OR CYGWIN) +if (UNIX OR MINGW OR CYGWIN OR NINTENDO_3DS) list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) endif() @@ -164,7 +164,7 @@ check_symbol_exists(_isnan "float.h" HAVE_DECL__ISNAN) check_symbol_exists(_finite "float.h" HAVE_DECL__FINITE) -if ((MSVC AND NOT (MSVC_VERSION LESS 1800)) OR MINGW OR CYGWIN OR UNIX) +if ((MSVC AND NOT (MSVC_VERSION LESS 1800)) OR MINGW OR CYGWIN OR UNIX OR NINTENDO_3DS) check_symbol_exists(INFINITY "math.h" HAVE_DECL_INFINITY) check_symbol_exists(isinf "math.h" HAVE_DECL_ISINF) check_symbol_exists(isnan "math.h" HAVE_DECL_ISNAN) @@ -172,7 +172,7 @@ endif() check_symbol_exists(_doprnt "stdio.h" HAVE_DOPRNT) -if (UNIX OR MINGW OR CYGWIN) +if (UNIX OR MINGW OR CYGWIN OR NINTENDO_3DS) check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF) endif() check_symbol_exists(vasprintf "stdio.h" HAVE_VASPRINTF) ================================================ FILE: 3ds/liblzma/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=3ds-liblzma pkgver=5.8.2 pkgrel=1 pkgdesc='A compression library with an API similar to that of zlib. (for Nintendo 3DS homebrew development)' arch=('any') url='https://tukaani.org' license=('GPL') options=(!strip libtool staticlibs) source=("https://tukaani.org/xz/xz-${pkgver}.tar.xz") makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') groups=('3ds-portlibs') build() { cd xz-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh ./configure --prefix=${PORTLIBS_PREFIX} --host=arm-none-eabi \ --enable-static --disable-shared --disable-threads \ --disable-lzma-links --disable-xz --disable-xzdec \ --disable-lzmadec --disable-lzmainfo --disable-nls \ --disable-scripts --disable-doc make } package() { cd xz-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install rm -fr "$pkgdir"${PORTLIBS_PREFIX}/bin } sha256sums=('890966ec3f5d5cc151077879e157c0593500a522f413ac50ba26d22a9a145214') ================================================ FILE: 3ds/libmad/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=3ds-libmad pkgver=0.15.1b pkgrel=2 pkgdesc='A high-quality MPEG audio decoder. (for Nintendo 3DS homebrew development)' arch=('any') url='https://www.underbit.com' license=('GPL') options=(!strip libtool staticlibs) source=("https://sourceforge.net/projects/mad/files/libmad/${pkgver}/libmad-${pkgver}.tar.gz") sha256sums=('bbfac3ed6bfbc2823d3775ebb931087371e142bb0e9bb1bee51a76a6e0078690') makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') groups=('3ds-portlibs') prepare() { sed -i 's,optimize="$optimize -fforce-mem",#optimize="$optimize -fforce-mem",' ${srcdir}/libmad-${pkgver}/configure } build() { cd libmad-$pkgver source /opt/devkitpro/3dsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi --disable-shared --enable-static make } package() { cd libmad-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: 3ds/libmodplug/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: TurtleP pkgname=3ds-libmodplug pkgver=0.8.9.0 pkgrel=1 pkgdesc='Play various .mod formats' arch=('any') url='http://modplug-xmms.sourceforge.net/' license=(public domain) options=(!strip libtool staticlibs) depends=("3ds-zlib") groups=('3ds-portlibs') source=( "https://sourceforge.net/projects/modplug-xmms/files/libmodplug/$pkgver/libmodplug-$pkgver.tar.gz" "libmodplug-${pkgver}.patch" ) sha256sums=( '457ca5a6c179656d66c01505c0d95fafaead4329b9dbaa0f997d00a3508ad9de' '21b02fafbde542e969fc41514bca7e544794110678d874fae49ce9e21cd4b342' ) build() { cd libmodplug-$pkgver source /opt/devkitpro/3dsvars.sh patch -Np1 -i "$srcdir/libmodplug-${pkgver}.patch" ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd libmodplug-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: 3ds/libmodplug/libmodplug-0.8.9.0.patch ================================================ diff -Naur libmodplug-0.8.9.0.old/src/load_abc.cpp libmodplug-0.8.9.0/src/load_abc.cpp --- libmodplug-0.8.9.0.old/src/load_abc.cpp 2020-10-08 22:58:42.530000706 +0200 +++ libmodplug-0.8.9.0/src/load_abc.cpp 2020-10-08 22:59:20.744998238 +0200 @@ -3597,8 +3597,10 @@ mm.mm = (char *)lpStream; mm.sz = dwMemLength; mm.pos = 0; +#ifndef __3DS__ while( avoid_reentry ) sleep(1); avoid_reentry = 1; +#endif pat_resetsmp(); pat_init_patnames(); m_nDefaultTempo = 0; diff -Naur libmodplug-0.8.9.0.old/src/load_mid.cpp libmodplug-0.8.9.0/src/load_mid.cpp --- libmodplug-0.8.9.0.old/src/load_mid.cpp 2020-10-08 22:58:42.530000706 +0200 +++ libmodplug-0.8.9.0/src/load_mid.cpp 2020-10-08 22:59:30.568997604 +0200 @@ -1170,8 +1170,10 @@ BYTE midibyte[2]; long metalen, delta; BYTE *p; +#ifndef __3DS__ while( avoid_reentry ) sleep(1); avoid_reentry = 1; +#endif if( !TestMID(lpStream, dwMemLength) ) { avoid_reentry = 0; return FALSE; diff -Naur libmodplug-0.8.9.0.old/src/load_pat.cpp libmodplug-0.8.9.0/src/load_pat.cpp --- libmodplug-0.8.9.0.old/src/load_pat.cpp 2020-10-08 22:58:42.531000706 +0200 +++ libmodplug-0.8.9.0/src/load_pat.cpp 2020-10-08 22:59:26.472997869 +0200 @@ -1149,8 +1149,10 @@ mm.sz = dwMemLength; mm.pos = 0; mm.error = 0; +#ifndef __3DS__ while( avoid_reentry ) sleep(1); avoid_reentry = 1; +#endif pat_read_patname(h, mmfile); h->samples = pat_read_numsmp(mmfile); if( strlen(h->patname) ) ================================================ FILE: 3ds/libogg/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=3ds-libogg pkgver=1.3.6 pkgrel=1 pkgdesc='The Ogg transport bitstream is designed to provide framing, error protection and seeking structure for higher-level codec streams that consist of raw, unencapsulated data packets, such as the Opus, Vorbis and FLAC audio codecs or the Theora and Dirac video codecs.' arch=('any') url='https://wiki.xiph.org/Ogg' license=(Xiph.org) options=(!strip libtool staticlibs) source=("https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-$pkgver.tar.gz") sha256sums=('83e6704730683d004d20e21b8f7f55dcb3383cdf84c0daedf30bde175f774638') makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') groups=('3ds-portlibs') build() { cd libogg-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd libogg-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install install -Dm644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING # remove useless documentation rm -r "$pkgdir"${PORTLIBS_PREFIX}/share/doc } ================================================ FILE: 3ds/libopus/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=3ds-libopus pkgver=1.4 pkgrel=1 pkgdesc='Reference implementation of the lossy audio codec, Opus' arch=('any') url='https://opus-codec.org/' license=(BSD) options=(!strip libtool staticlibs) source=("https://downloads.xiph.org/releases/opus/opus-$pkgver.tar.gz") sha256sums=('c9b32b4253be5ae63d1ff16eea06b94b5f0f2951b7a02aceef58e3a3ce49c51f') makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') groups=('3ds-portlibs') build() { cd opus-$pkgver source /opt/devkitpro/3dsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd opus-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: 3ds/libpng/.gitignore ================================================ 3ds-libpng ================================================ FILE: 3ds/libpng/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: carstene1ns - http://git.io/ctPKG # Contributor: Aaron Lindsay pkgname=3ds-libpng pkgver=1.6.53 pkgrel=1 pkgdesc='PNG format graphic files library' arch=('any') url='http://www.libpng.org' license=('custom') options=(!strip libtool staticlibs) depends=('3ds-zlib') groups=('3ds-portlibs') makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') source=("https://download.sourceforge.net/libpng/libpng-$pkgver.tar.xz") build() { cd libpng-$pkgver source /opt/devkitpro/3dsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-tools --disable-shared --enable-static make } package() { cd libpng-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh make LN_S=cp DESTDIR="$pkgdir" install # license install -Dm644 LICENSE "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/LICENSE # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share } sha256sums=('1d3fb8ccc2932d04aa3663e22ef5ef490244370f4e568d7850165068778d98d4') ================================================ FILE: 3ds/libsidplay/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: badda71 pkgname=3ds-libsidplay pkgver=1.36.60 pkgrel=1 pkgdesc="SID chip music module playing library" arch=('any') url="http://web.archive.org/web/20061202103201/http://www.geocities.com/SiliconValley/Lakes/5147/sidplay/" license=('GPLv2') options=(!strip libtool staticlibs) source=( "http://ftp.jaist.ac.jp/pub/Linux/Momonga/development/source/SOURCES/libsidplay-${pkgver}.tar.bz2" "libsidplay-${pkgver}.patch" ) sha256sums=('1729beb5b54e7486e0b2b83dc0e02130e753a8dcd6fe03677217dbe358941396' 'd47be6d24f3f26ab4f91b6f207a81e7ab419e1d98995ca0103109aaa47d44d2c') makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') groups=('3ds-portlibs') build() { cd libsidplay-$pkgver patch -p0 -i ../libsidplay-${pkgver}.patch source /opt/devkitpro/3dsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi --disable-shared --enable-static make } package() { cd libsidplay-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: 3ds/libsidplay/libsidplay-1.36.60.patch ================================================ --- src/samples.cpp Wed May 22 18:38:18 2002 +++ src/samples.cpp Mon Mar 04 13:21:58 2019 @@ -75,7 +75,7 @@ sampleChannel ch4, ch5; -const sbyte galwayNoiseTab1[16] = +const ubyte galwayNoiseTab1[16] = { 0x80,0x91,0xa2,0xb3,0xc4,0xd5,0xe6,0xf7, 0x08,0x19,0x2a,0x3b,0x4c,0x5d,0x6e,0x7f @@ -84,7 +84,7 @@ ubyte galwayNoiseVolTab[16]; sbyte galwayNoiseSamTab[16]; -const sbyte sampleConvertTab[16] = +const ubyte sampleConvertTab[16] = { // 0x81,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff, // 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x7f --- scripts/config.sub Fri Aug 20 12:49:08 2010 +++ scripts/config.sub Mon Mar 04 21:48:01 2019 @@ -1293,7 +1293,7 @@ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ ================================================ FILE: 3ds/libtheora/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: oreo639 pkgname=3ds-libtheora pkgver=1.2.0alpha1 pkgrel=2 pkgdesc='Free and open video compression codec from the Xiph.org Foundation' arch=('any') url='https://www.theora.org/' license=(Xiph.org) options=(!strip libtool staticlibs) source=( "https://ftp.osuosl.org/pub/xiph/releases/theora/libtheora-${pkgver}.tar.gz" "libtheora-1.2.0.patch" ) sha256sums=( '538305e6efa484ba740616b521f0d8c4428a0a995193c5e6af9b20f488f3c497' 'b508af29ae3b290e0c2cb0565937826024b0acd6d8c9fb47d2abff6dd04de89a' ) makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') depends=('3ds-libogg') groups=('3ds-portlibs') build() { cd libtheora-${pkgver} patch -Np1 -i "$srcdir/libtheora-1.2.0.patch" source /opt/devkitpro/3dsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static --disable-encode \ --disable-examples --disable-vorbistest make } package() { cd libtheora-${pkgver} source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install install -Dm644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING # remove useless documentation rm -r "$pkgdir"${PORTLIBS_PREFIX}/share/doc } ================================================ FILE: 3ds/libtheora/libtheora-1.2.0.patch ================================================ diff -Naur libtheora-1.2.0alpha1.orig/lib/arm/armcpu.c libtheora-1.2.0alpha1/lib/arm/armcpu.c --- libtheora-1.2.0alpha1.orig/lib/arm/armcpu.c 2010-09-23 13:21:44.000000000 -0700 +++ libtheora-1.2.0alpha1/lib/arm/armcpu.c 2021-03-18 15:13:29.976897091 -0700 @@ -107,6 +107,22 @@ return flags; } +#elif defined(_3DS) + +ogg_uint32_t oc_cpu_flags_get(void){ + ogg_uint32_t flags; + flags=0; + +#if defined(OC_ARM_ASM_EDSP) + flags|=OC_CPU_ARM_EDSP; +#endif +#if defined(OC_ARM_ASM_MEDIA) + flags|=OC_ARM_ASM_MEDIA; +#endif + + return flags; +} + #else /*The feature registers which can tell us what the processor supports are accessible in priveleged modes only, so we can't have a general user-space ================================================ FILE: 3ds/libvorbisidec/.gitignore ================================================ 3ds-libvorbisidec ================================================ FILE: 3ds/libvorbisidec/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=3ds-libvorbisidec pkgver=1.2.1 pkgrel=3 pkgdesc='Fixed-point version of the Ogg Vorbis decoder (for Nintendo 3DS homebrew development)' arch=('any') url="http://xiph.org" license=('LGPL') options=(!strip libtool staticlibs) source=("https://downloads.devkitpro.org/packages/sources/libvorbisidec-${pkgver}.tar.xz") sha256sums=('6ae33489ed40b54ab4a1cd0cf349e9b3b1d5c68d722485704d951f4bf80c64c6') makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') depends=('3ds-libogg') groups=('3ds-portlibs') build() { cd libvorbisidec-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi make } package() { cd libvorbisidec-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING } ================================================ FILE: 3ds/libxmp/PKGBUILD ================================================ # Maintainer: Chromaryu pkgname=3ds-libxmp pkgver=4.6.0 pkgrel=1 pkgdesc="Library that supports over 90 module formats" arch=('any') url="http://xmp.sourceforge.net/" license=('GPL') options=(!strip libtool staticlibs) source=("http://download.sourceforge.net/project/xmp/libxmp/$pkgver/libxmp-$pkgver.tar.gz") sha256sums=('2d3c45fe523b50907e89e60f9a3b7f4cc9aab83ec9dbba7743eaffbcdcb35ea6') makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') groups=('3ds-portlibs') build() { cd "libxmp-$pkgver" source /opt/devkitpro/3dsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd "libxmp-$pkgver" source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir/" install } ================================================ FILE: 3ds/libzstd/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=3ds-libzstd pkgver=1.5.5 pkgrel=2 pkgdesc='Zstd, short for Zstandard, is a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level compression ratio (for Nintendo Switch homebrew development)' arch=('any') url='https://zstd.net' license=('BSD and GPLv2') options=(!strip libtool staticlibs) source=( "https://github.com/facebook/zstd/releases/download/v$pkgver/zstd-${pkgver}.tar.gz" zstd-${pkgver}.patch ) sha256sums=('59ef70ebb757ffe74a7b3fe9c305e2ba3350021a918d168a046c6300aeea9315') makedepends=('dkp-toolchain-vars') groups=('3ds-portlibs') prepare() { cd zstd-${pkgver} patch -Np1 -i ${srcdir}/zstd-${pkgver}.patch } build() { source /opt/devkitpro/3dsvars.sh cd zstd-${pkgver}/lib make CC=${TOOL_PREFIX}gcc PREFIX=${PORTLIBS_PREFIX} libzstd.a libzstd.pc } package() { source /opt/devkitpro/3dsvars.sh cd zstd-${pkgver}/lib make DESTDIR="${pkgdir}" PREFIX=${PORTLIBS_PREFIX} install-pc install-static install-includes install -d "${pkgdir}"/opt/devkitpro/portlibs/3ds/licenses/${pkgname} install ../COPYING "${pkgdir}"/opt/devkitpro/portlibs/3ds/licenses/${pkgname}/COPYING install ../LICENSE "${pkgdir}"/opt/devkitpro/portlibs/3ds/licenses/${pkgname}/LICENSE } sha256sums=('9c4396cc829cfae319a6e2615202e82aad41372073482fce286fac78646d3ee4') sha256sums=('9c4396cc829cfae319a6e2615202e82aad41372073482fce286fac78646d3ee4' 'dd4980ee49323cbaa3b5b83271fa033eb1c0e911437127d70d84c4ac05619eb1') ================================================ FILE: 3ds/libzstd/zstd-1.5.5.patch ================================================ From d5e53f90cbd1ae0e999ec66e4113558c024c904e Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Fri, 22 Dec 2023 11:04:00 +0000 Subject: [PATCH] fix mismatched function signatures --- lib/legacy/zstd_v06.c | 10 +++++----- lib/legacy/zstd_v07.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/legacy/zstd_v06.c b/lib/legacy/zstd_v06.c index 175f7cc4..81ea07e8 100644 --- a/lib/legacy/zstd_v06.c +++ b/lib/legacy/zstd_v06.c @@ -789,7 +789,7 @@ typedef enum { BITv06_DStream_unfinished = 0, /* 1,2,4,8 would be better for bitmap combinations, but slows down performance a bit ... :( */ MEM_STATIC size_t BITv06_initDStream(BITv06_DStream_t* bitD, const void* srcBuffer, size_t srcSize); -MEM_STATIC size_t BITv06_readBits(BITv06_DStream_t* bitD, unsigned nbBits); +MEM_STATIC size_t BITv06_readBits(BITv06_DStream_t* bitD, U32 nbBits); MEM_STATIC BITv06_DStream_status BITv06_reloadDStream(BITv06_DStream_t* bitD); MEM_STATIC unsigned BITv06_endOfDStream(const BITv06_DStream_t* bitD); @@ -798,7 +798,7 @@ MEM_STATIC unsigned BITv06_endOfDStream(const BITv06_DStream_t* bitD); /*-**************************************** * unsafe API ******************************************/ -MEM_STATIC size_t BITv06_readBitsFast(BITv06_DStream_t* bitD, unsigned nbBits); +MEM_STATIC size_t BITv06_readBitsFast(BITv06_DStream_t* bitD, U32 nbBits); /* faster, but works only if nbBits >= 1 */ @@ -1770,10 +1770,10 @@ HUFv06_decompress() does the following: 3. decode 1 or 4 segments in parallel using HUFv06_decompressSXn_usingDTable */ size_t HUFv06_readDTableX2 (unsigned short* DTable, const void* src, size_t srcSize); -size_t HUFv06_readDTableX4 (unsigned* DTable, const void* src, size_t srcSize); +size_t HUFv06_readDTableX4 (U32* DTable, const void* src, size_t srcSize); size_t HUFv06_decompress4X2_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const unsigned short* DTable); -size_t HUFv06_decompress4X4_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const unsigned* DTable); +size_t HUFv06_decompress4X4_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const U32* DTable); /* single stream variants */ @@ -1781,7 +1781,7 @@ size_t HUFv06_decompress1X2 (void* dst, size_t dstSize, const void* cSrc, size_t size_t HUFv06_decompress1X4 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /* double-symbol decoder */ size_t HUFv06_decompress1X2_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const unsigned short* DTable); -size_t HUFv06_decompress1X4_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const unsigned* DTable); +size_t HUFv06_decompress1X4_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const U32* DTable); diff --git a/lib/legacy/zstd_v07.c b/lib/legacy/zstd_v07.c index 15dc3ef7..100f6cf3 100644 --- a/lib/legacy/zstd_v07.c +++ b/lib/legacy/zstd_v07.c @@ -460,7 +460,7 @@ typedef enum { BITv07_DStream_unfinished = 0, /* 1,2,4,8 would be better for bitmap combinations, but slows down performance a bit ... :( */ MEM_STATIC size_t BITv07_initDStream(BITv07_DStream_t* bitD, const void* srcBuffer, size_t srcSize); -MEM_STATIC size_t BITv07_readBits(BITv07_DStream_t* bitD, unsigned nbBits); +MEM_STATIC size_t BITv07_readBits(BITv07_DStream_t* bitD, U32 nbBits); MEM_STATIC BITv07_DStream_status BITv07_reloadDStream(BITv07_DStream_t* bitD); MEM_STATIC unsigned BITv07_endOfDStream(const BITv07_DStream_t* bitD); @@ -469,7 +469,7 @@ MEM_STATIC unsigned BITv07_endOfDStream(const BITv07_DStream_t* bitD); /*-**************************************** * unsafe API ******************************************/ -MEM_STATIC size_t BITv07_readBitsFast(BITv07_DStream_t* bitD, unsigned nbBits); +MEM_STATIC size_t BITv07_readBitsFast(BITv07_DStream_t* bitD, U32 nbBits); /* faster, but works only if nbBits >= 1 */ -- 2.30.2 ================================================ FILE: 3ds/lua51/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgsuffix=51 pkgname=("3ds-liblua${pkgsuffix}") pkgvermaj=5.1 pkgver=${pkgvermaj}.5 pkgrel=1 pkgdesc="Powerful lightweight programming language designed for extending applications" arch=('any') license=('MIT') url="https://www.lua.org/" options=(!strip libtool staticlibs) source=(${url}/ftp//lua-${pkgver}.tar.gz) makedepends=('devkitARM' '3ds-pkg-config' 'dkp-toolchain-vars') groups=('3ds-portlibs') build() { source /opt/devkitpro/3dsvars.sh make -C "${srcdir}/lua-${pkgver}" \ CC=arm-none-eabi-gcc \ AR="arm-none-eabi-ar rcu" \ RANLIB=arm-none-eabi-ranlib \ LUA_A=liblua${pkgvermaj}.a \ ALL_T=liblua${pkgvermaj}.a \ CPPFLAGS="${CPPFLAGS} ${CFLAGS}" \ PLAT=generic } package() { source /opt/devkitpro/3dsvars.sh cd ${srcdir}/lua-${pkgver} echo $pkgdir echo $PORTLIBS_PREFIX install -dm 755 ${pkgdir}/${PORTLIBS_PREFIX}/include/lua${pkgvermaj} install -m 644 src/lua.h src/luaconf.h src/lualib.h src/lauxlib.h ${pkgdir}/${PORTLIBS_PREFIX}/include/lua${pkgvermaj} sed -i "s,prefix= /usr/local,prefix= ${PORTLIBS_PREFIX}," etc/lua.pc sed -i "s,includedir=\${prefix}/include,includedir=\${prefix}/include/lua${pkgvermaj}," etc/lua.pc sed -i "s,-llua,-llua${pkgvermaj}," etc/lua.pc install -dm 755 ${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig install -m 644 etc/lua.pc ${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/lua${pkgsuffix}.pc install -m 644 src/liblua${pkgvermaj}.a ${pkgdir}/${PORTLIBS_PREFIX}/lib } sha256sums=('2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333') ================================================ FILE: 3ds/lz4/PKGBUILD ================================================ # Maintainer: TurtleP pkgname=3ds-lz4 pkgver=1.9.3 pkgrel=1 pkgdesc="Very fast lossless compression algorithm" arch=("any") url="https://lz4.github.io/lz4/" license=("BSD" "GPL2") options=("staticlibs" "!strip") source=("https://github.com/lz4/lz4/archive/refs/tags/v${pkgver}.zip") sha256sums=("4ec935d99aa4950eadfefbd49c9fad863185ac24c32001162c44a683ef61b580") makedepends=("dkp-toolchain-vars") groups=("3ds-portlibs") package() { source /opt/devkitpro/3dsvars.sh cd lz4-${pkgver}/lib make BUILD_SHARED=no \ PREFIX=${PORTLIBS_PREFIX} \ DESTDIR=${pkgdir} \ install } ================================================ FILE: 3ds/mbedtls/.gitignore ================================================ 3ds-mbedtls *.tgz ================================================ FILE: 3ds/mbedtls/PKGBUILD ================================================ # Maintainer: WinterMute # Contributor: Elouan Martinet _realname=mbedtls pkgname=3ds-${_realname} pkgver=2.28.8 pkgrel=1 pkgdesc='An open source, portable, easy to use, readable and flexible SSL library (for Nintendo 3DS homebrew development)' arch=('any') url='https://tls.mbed.org/' license=('apache') options=(!strip libtool staticlibs) depends=(3ds-zlib) makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') source=( "${_realname}-${pkgver}.tar.gz::https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${pkgver}.tar.gz" "mbedtls-${pkgver}.patch" ) groups=('3ds-portlibs') sha256sums=('bdf7c5bbdc338da3edad89b2885d4f8668f9a6fffeba6ec17a60333e36dade6f' 'a3332c2b65f69f9224e799ac6f05db4555faf76fcfaa720411068252c848b0ee') build() { cd mbedtls-$pkgver patch -Np1 -i $srcdir/mbedtls-${pkgver}.patch ./scripts/config.pl set MBEDTLS_ENTROPY_HARDWARE_ALT ./scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY ./scripts/config.pl set MBEDTLS_CMAC_C ./scripts/config.pl unset MBEDTLS_SELF_TEST ./scripts/config.pl unset MBEDTLS_TIMING_C source /opt/devkitpro/3dsvars.sh arm-none-eabi-cmake \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DCMAKE_C_FLAGS="$CFLAGS $CPPFLAGS" \ -DCMAKE_CXX_FLAGS="CFLAGS -fno-exceptions -fno-rtti" \ -DZLIB_ROOT="$PORTLIBS_PREFIX" \ -DENABLE_ZLIB_SUPPORT=TRUE -DENABLE_TESTING=FALSE -DENABLE_PROGRAMS=FALSE \ . make } package() { cd mbedtls-$pkgver source /opt/devkitpro/3dsvars.sh make install DESTDIR="$pkgdir" install -d "$pkgdir"$PORTLIBS_PREFIX/licenses/$pkgname cp -v LICENSE "$pkgdir"$PORTLIBS_PREFIX/licenses/$pkgname } sha256sums=('4fef7de0d8d542510d726d643350acb3cdb9dc76ad45611b59c9aa08372b4213' '84892ec63ab68804a582364d8c4bd6c8dfd0d697ed175bddcd5b7339cce35563') ================================================ FILE: 3ds/mbedtls/mbedtls-2.28.8.patch ================================================ diff --git a/library/entropy.c b/library/entropy.c index e9a7ae63d..b572edd2f 100644 --- a/library/entropy.c +++ b/library/entropy.c @@ -107,6 +107,19 @@ void mbedtls_entropy_init(mbedtls_entropy_context *ctx) #endif /* MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES */ } +#ifdef __3DS__ + #include <3ds.h> + int mbedtls_hardware_poll( void *data, + unsigned char *output, size_t len, size_t *olen ) + { + (void)(data); + sslcGenerateRandomData(output, len); + if(olen) + *olen = len; + return 0; + } +#endif + void mbedtls_entropy_free(mbedtls_entropy_context *ctx) { /* If the context was already free, don't call free() again. diff --git a/library/net_sockets.c b/library/net_sockets.c index 2c2a876b0..bf2925c97 100644 --- a/library/net_sockets.c +++ b/library/net_sockets.c @@ -33,7 +33,7 @@ #if !defined(unix) && !defined(__unix__) && !defined(__unix) && \ !defined(__APPLE__) && !defined(_WIN32) && !defined(__QNXNTO__) && \ - !defined(__HAIKU__) && !defined(__midipix__) + !defined(__HAIKU__) && !defined(__midipix__) && !defined(__3DS__) #error "This module only works on Unix and Windows, see MBEDTLS_NET_C in config.h" #endif @@ -411,6 +411,7 @@ } memcpy(client_ip, &addr4->sin_addr.s_addr, *cip_len); +#ifndef __3DS__ } else { struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) &client_addr; *cip_len = sizeof(addr6->sin6_addr.s6_addr); @@ -420,6 +421,7 @@ } memcpy(client_ip, &addr6->sin6_addr.s6_addr, *cip_len); +#endif } } ================================================ FILE: 3ds/mikmod/.gitignore ================================================ 3ds-mikmod ================================================ FILE: 3ds/mikmod/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=3ds-mikmod pkgver=3.3.13 pkgrel=1 pkgdesc="Module player and library supporting many formats, including mod, s3m, it, and xm (Nintendo 3DS port)" arch=('any') url="http://mikmod.sourceforge.net/" license=("LGPL") options=(!strip libtool staticlibs) makedepends=( '3ds-pkg-config' 'dkp-toolchain-vars' ) source=("https://sourceforge.net/projects/mikmod/files/libmikmod/$pkgver/libmikmod-$pkgver.tar.gz") sha256sums=('9fc1799f7ea6a95c7c5882de98be85fc7d20ba0a4a6fcacae11c8c6b382bb207') groups=('3ds-portlibs') build() { cd libmikmod-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd libmikmod-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install rm -fr "$pkgdir"${PORTLIBS_PREFIX}/share } ================================================ FILE: 3ds/mpg123/PKGBUILD ================================================ # Maintainer: Gabriel Kind pkgname=3ds-mpg123 pkgver=1.31.3 pkgrel=3 pkgdesc="A real time MPEG audio decoder for layer 1, 2 and 3" arch=('any') url="http://sourceforge.net/projects/mpg123" license=('LGPL2.1') options=(!strip libtool staticlibs) groups=("3ds-portlibs") source=( "https://downloads.sourceforge.net/sourceforge/mpg123/mpg123-${pkgver}.tar.bz2" "mpg123-${pkgver}.patch" ) sha256sums=('1ca77d3a69a5ff845b7a0536f783fee554e1041139a6b978f6afe14f5814ad1a' '9af6c4c39d4cc58c5b81bf6e26a95fe9bf8322f583a98ec73f0362214a3c3b89' ) makedepends=('dkp-toolchain-vars' '3ds-pkg-config') build() { cd mpg123-$pkgver source /opt/devkitpro/3dsvars.sh patch -Np1 -i "$srcdir"/mpg123-${pkgver}.patch autoreconf -fi ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static --enable-fifo=no \ --enable-ipv6=no --enable-network=no --enable-int-quality=no \ --with-cpu=generic --with-default-audio=dummy make } package() { source /opt/devkitpro/3dsvars.sh cd mpg123-$pkgver make DESTDIR="$pkgdir" install # remove useless stuff rm -rf "$pkgdir"${PORTLIBS_PREFIX}/bin "$pkgdir"${PORTLIBS_PREFIX}/share } ================================================ FILE: 3ds/mpg123/mpg123-1.31.3.patch ================================================ diff -NBaur mpg123-1.31.3.orig/configure.ac mpg123-1.31.3/configure.ac --- mpg123-1.31.3.orig/configure.ac 2023-03-17 17:10:06.000000000 +0000 +++ mpg123-1.31.3/configure.ac 2023-04-11 18:10:11.322818703 +0100 @@ -1350,6 +1350,20 @@ # Optionally use platform macros for byte swapping. AC_CHECK_HEADERS([byteswap.h]) +if test x"$ac_cv_header_sys_signal_h" = xyes; then + AC_CHECK_FUNCS( sigemptyset sigaddset sigprocmask sigaction ) + if test x"$ac_cv_func_sigemptyset" = xno || + test x"$ac_cv_func_sigaddset" = xno || + test x"$ac_cv_func_sigprocmask" = xno || + test x"$ac_cv_func_sigaction" = xno; then + AC_DEFINE(DONT_CATCH_SIGNALS, 1, [ Signal handling is not supported on this platform ]) + fi +else + AC_DEFINE(DONT_CATCH_SIGNALS, 1, [ Signal handling is not supported on this platform ]) +fi + +AC_CHECK_FUNCS( sleep, [ have_sleep=yes ], [ have_sleep=no ] ) + dnl ############## Choose compiler flags and CPU # do not assume gcc here, so no flags by default diff -NBaur mpg123-1.31.3.orig/libmpg123.pc.in mpg123-1.31.3/libmpg123.pc.in --- mpg123-1.31.3.orig/libmpg123.pc.in 2023-03-15 08:02:58.000000000 +0000 +++ mpg123-1.31.3/libmpg123.pc.in 2023-04-11 18:11:17.209838741 +0100 @@ -7,6 +7,6 @@ Description: An optimised MPEG Audio decoder Requires: Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lmpg123 +Libs: -L${libdir} -lmpg123 -lm Libs.private: @LIBMPG123_LIBS@ Cflags: -I${includedir} diff -NBaur mpg123-1.31.3.orig/libout123.pc.in mpg123-1.31.3/libout123.pc.in --- mpg123-1.31.3.orig/libout123.pc.in 2023-03-15 08:02:58.000000000 +0000 +++ mpg123-1.31.3/libout123.pc.in 2023-04-11 18:11:53.141671612 +0100 @@ -7,6 +7,6 @@ Description: A streaming audio output API derived from mpg123 Requires: Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lout123 +Libs: -L${libdir} -lout123 -lm Libs.private: @LIBOUT123_LIBS@ @LIBDL@ Cflags: -I${includedir} diff -NBaur mpg123-1.31.3.orig/src/control_generic.c mpg123-1.31.3/src/control_generic.c --- mpg123-1.31.3.orig/src/control_generic.c 2023-03-15 08:20:01.000000000 +0000 +++ mpg123-1.31.3/src/control_generic.c 2023-04-11 18:10:11.326822156 +0100 @@ -28,8 +28,10 @@ #include #if !defined (_WIN32) || defined (__CYGWIN__) #include +#ifdef NETWORK #include #endif +#endif #include #include diff -NBaur mpg123-1.31.3.orig/src/mpg123.c mpg123-1.31.3/src/mpg123.c --- mpg123-1.31.3.orig/src/mpg123.c 2023-03-15 08:02:57.000000000 +0000 +++ mpg123-1.31.3/src/mpg123.c 2023-04-11 18:10:11.326822156 +0100 @@ -1334,6 +1334,8 @@ if(param.verbose > 2) fprintf(stderr, "Note: pausing %i seconds before next track.\n", param.delay); #ifdef WIN32 Sleep(param.delay*1000); +#elif !defined(HAVE_SLEEP) + fprintf(stderr, "sleep not supported on this platform\n"); #else sleep(param.delay); #endif ================================================ FILE: 3ds/opusfile/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=3ds-opusfile pkgver=0.11 pkgrel=1 pkgdesc='Library for opening, seeking, and decoding .opus files' arch=('any') url='https://opus-codec.org/' license=(BSD) options=(!strip libtool staticlibs) source=("https://downloads.xiph.org/releases/opus/opusfile-$pkgver.tar.gz") sha256sums=('74ce9b6cf4da103133e7b5c95df810ceb7195471e1162ed57af415fabf5603bf') makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') depends=('3ds-libogg' '3ds-libopus') groups=('3ds-portlibs') build() { cd opusfile-$pkgver source /opt/devkitpro/3dsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd opusfile-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: 3ds/physfs/PKGBUILD ================================================ # Maintainer: Dave Murphy _realname=physfs pkgname=3ds-${_realname} pkgver=3.2.0 pkgrel=2 pkgdesc='A library to provide abstract access to various archives.' arch=('any') url='https://icculus.org/physfs/' license=('zlib') options=(!strip libtool staticlibs) source=( "${_realname}-${pkgver}.tar.gz::https://github.com/icculus/physfs/archive/refs/tags/release-${pkgver}.tar.gz" "physfs-${pkgver}.patch") makedepends=('devkitARM' 'dkp-toolchain-vars' '3ds-cmake') sha256sums=( '1991500eaeb8d5325e3a8361847ff3bf8e03ec89252b7915e1f25b3f8ab5d560' '97bdab0dc338921fe43d67b28225363fc3552c89b11fb28f3ff5889da5ab9d1c' ) groups=('3ds-portlibs') build() { cd physfs-release-$pkgver patch -Np1 -i "$srcdir"/physfs-${pkgver}.patch source ${DEVKITPRO}/3dsvars.sh arm-none-eabi-cmake -G"Unix Makefiles" \ -DCMAKE_INSTALL_PREFIX=/opt/devkitpro/portlibs/3ds \ -DPHYSFS_BUILD_STATIC=ON -DPHYSFS_BUILD_SHARED=OFF \ -DPHYSFS_BUILD_TEST=OFF \ . make } package() { cd physfs-release-$pkgver make install DESTDIR="$pkgdir" } ================================================ FILE: 3ds/physfs/physfs-3.2.0.patch ================================================ diff -NBaur physfs-release-3.2.0/CMakeLists.txt physfs-release-3.2.0-new/CMakeLists.txt --- physfs-release-3.2.0/CMakeLists.txt 2022-09-30 21:13:07.000000000 +0100 +++ physfs-release-3.2.0-new/CMakeLists.txt 2023-03-26 16:19:44.629038704 +0100 @@ -77,6 +77,7 @@ src/physfs.c src/physfs_byteorder.c src/physfs_unicode.c + src/physfs_platform_3ds.c src/physfs_platform_posix.c src/physfs_platform_unix.c src/physfs_platform_windows.c diff -NBaur physfs-release-3.2.0/src/physfs_internal.h physfs-release-3.2.0-new/src/physfs_internal.h --- physfs-release-3.2.0/src/physfs_internal.h 2022-09-30 21:13:07.000000000 +0100 +++ physfs-release-3.2.0-new/src/physfs_internal.h 2023-03-26 16:16:59.634275766 +0100 @@ -108,6 +108,10 @@ const void *__PHYSFS_winrtCalcPrefDir(void); #endif +#ifdef PHYSFS_PLATFORM_3DS +char *__PHYSFS_3DSCalcUserDir(void); +#endif + /* atomic operations. */ /* increment/decrement operations return the final incremented/decremented value. */ #if defined(_MSC_VER) && (_MSC_VER >= 1500) diff -NBaur physfs-release-3.2.0/src/physfs_platform_3ds.c physfs-release-3.2.0-new/src/physfs_platform_3ds.c --- physfs-release-3.2.0/src/physfs_platform_3ds.c 1970-01-01 01:00:00.000000000 +0100 +++ physfs-release-3.2.0-new/src/physfs_platform_3ds.c 2023-03-26 16:16:59.634275766 +0100 @@ -0,0 +1,106 @@ +/* + * Nintendo 3DS support routines for PhysicsFS. + * + * Please see the file LICENSE.txt in the source's root directory. + * + */ + + +#define __PHYSICSFS_INTERNAL__ +#include "physfs_platforms.h" + +#ifdef PHYSFS_PLATFORM_3DS + +#include <3ds.h> + +// for getcwd +#include +// for PATH_MAX +#include + +#include "physfs_internal.h" + +int __PHYSFS_platformInit(void) +{ + return 1; /* always succeed. */ +} /* __PHYSFS_platformInit */ + + +void __PHYSFS_platformDeinit(void) +{ + /* no-op */ +} /* __PHYSFS_platformDeinit */ + + +void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data) +{ + /* no-op */ +} + +char *__PHYSFS_3DSCalcUserDir(void) +{ + /* Use the jail directory (hopefully) found before. */ + return __PHYSFS_strdup(PHYSFS_getBaseDir()); +} + +char *__PHYSFS_platformCalcBaseDir(const char *argv0) +{ + char *retval = NULL; + /* As there is no system-specific directory, directly inspect argv0. */ + if (argv0 == NULL) + { + /* User did not provide a path, just use the current working directory. + * As physfs should be initialized soon after application start, this + * should give us a useable directory. + */ + char fullpath[PATH_MAX]; + if (getcwd(fullpath, sizeof(fullpath)) != NULL) + { + const size_t cwdlen = strlen(fullpath); + /* getcwd does not provide a trailing slash, add it. */ + retval = (char*) allocator.Malloc(cwdlen + 2); + BAIL_IF(!retval, PHYSFS_ERR_OUT_OF_MEMORY, NULL); + strncpy(retval, fullpath, cwdlen); + retval[cwdlen] = '/'; + retval[cwdlen + 1] = '\0'; + } + } + else + { + /* hbmenu should give us the full path of the application, this may + * reside in a subfolder. Higher level code will strip away the name + * and extension. + */ + return NULL; + } + + if (!retval) + /* Last resort: use `/3ds` directory. */ + retval = __PHYSFS_strdup("/3ds/"); + + return retval; +} /* __PHYSFS_platformCalcBaseDir */ + +char *__PHYSFS_platformCalcPrefDir(const char *org, const char *app) +{ + char *retval = NULL; + size_t len = 0; + + /* Use the jail directory (hopefully) found before. This way we do not + * need to add an application folder, because it is exclusive. + */ + const char *envr = __PHYSFS_getUserDir(); + BAIL_IF_ERRPASS(!envr, NULL); + const char *append = ".config/"; + len = strlen(envr) + strlen(append) + 1; + retval = (char *) allocator.Malloc(len); + BAIL_IF(!retval, PHYSFS_ERR_OUT_OF_MEMORY, NULL); + snprintf(retval, len, "%s%s", envr, append); + + return retval; +} /* __PHYSFS_platformCalcPrefDir */ + + +#endif /* PHYSFS_PLATFORM_3DS */ + +/* end of physfs_platform_3ds.c ... */ diff -NBaur physfs-release-3.2.0/src/physfs_platform_posix.c physfs-release-3.2.0-new/src/physfs_platform_posix.c --- physfs-release-3.2.0/src/physfs_platform_posix.c 2022-09-30 21:13:07.000000000 +0100 +++ physfs-release-3.2.0-new/src/physfs_platform_posix.c 2023-03-26 16:16:59.634275766 +0100 @@ -23,6 +23,10 @@ #include "physfs_internal.h" +#ifdef PHYSFS_PLATFORM_3DS +#include <3ds/synchronization.h> +#include <3ds/thread.h> +#endif static PHYSFS_ErrorCode errcodeFromErrnoError(const int err) { @@ -58,6 +62,9 @@ static char *getUserDirByUID(void) { +#ifdef PHYSFS_PLATFORM_3DS + return __PHYSFS_3DSCalcUserDir(); +#else uid_t uid = getuid(); struct passwd *pw; char *retval = NULL; @@ -78,13 +85,16 @@ } /* if */ } /* if */ } /* if */ - return retval; +#endif } /* getUserDirByUID */ char *__PHYSFS_platformCalcUserDir(void) { +#ifdef PHYSFS_PLATFORM_3DS + return __PHYSFS_3DSCalcUserDir(); +#endif char *retval = NULL; char *envr = getenv("HOME"); @@ -362,27 +372,43 @@ st->createtime = statbuf.st_ctime; st->accesstime = statbuf.st_atime; - st->readonly = (access(fname, W_OK) == -1); +#ifdef PHYSFS_PLATFORM_3DS + /* shortcut */ + st->readonly = !(statbuf.st_mode & S_IWRITE); +#else + st->readonly = (access(fname, W_OK) == -1); +#endif return 1; } /* __PHYSFS_platformStat */ +#ifdef PHYSFS_PLATFORM_3DS +#else typedef struct { pthread_mutex_t mutex; pthread_t owner; PHYSFS_uint32 count; } PthreadMutex; - +#endif void *__PHYSFS_platformGetThreadID(void) { +#ifdef PHYSFS_PLATFORM_3DS + return (void*)threadGetCurrent(); +#else return ( (void *) ((size_t) pthread_self()) ); +#endif } /* __PHYSFS_platformGetThreadID */ void *__PHYSFS_platformCreateMutex(void) { +#ifdef PHYSFS_PLATFORM_3DS + RecursiveLock *m = allocator.Malloc(sizeof(RecursiveLock)); + BAIL_IF(!m, PHYSFS_ERR_OUT_OF_MEMORY, NULL); + RecursiveLock_Init(m); +#else int rc; PthreadMutex *m = (PthreadMutex *) allocator.Malloc(sizeof (PthreadMutex)); BAIL_IF(!m, PHYSFS_ERR_OUT_OF_MEMORY, NULL); @@ -395,12 +421,16 @@ m->count = 0; m->owner = (pthread_t) 0xDEADBEEF; +#endif return ((void *) m); } /* __PHYSFS_platformCreateMutex */ void __PHYSFS_platformDestroyMutex(void *mutex) { +#ifdef PHYSFS_PLATFORM_3DS + allocator.Free((RecursiveLock *)mutex); +#else PthreadMutex *m = (PthreadMutex *) mutex; /* Destroying a locked mutex is a bug, but we'll try to be helpful. */ @@ -409,11 +439,15 @@ pthread_mutex_destroy(&m->mutex); allocator.Free(m); +#endif } /* __PHYSFS_platformDestroyMutex */ int __PHYSFS_platformGrabMutex(void *mutex) { +#ifdef PHYSFS_PLATFORM_3DS + RecursiveLock_Lock((RecursiveLock *)mutex); +#else PthreadMutex *m = (PthreadMutex *) mutex; pthread_t tid = pthread_self(); if (m->owner != tid) @@ -424,12 +458,16 @@ } /* if */ m->count++; +#endif return 1; } /* __PHYSFS_platformGrabMutex */ void __PHYSFS_platformReleaseMutex(void *mutex) { +#ifdef PHYSFS_PLATFORM_3DS + RecursiveLock_Unlock((RecursiveLock *)mutex); +#else PthreadMutex *m = (PthreadMutex *) mutex; assert(m->owner == pthread_self()); /* catch programming errors. */ assert(m->count > 0); /* catch programming errors. */ @@ -441,6 +479,7 @@ pthread_mutex_unlock(&m->mutex); } /* if */ } /* if */ +#endif } /* __PHYSFS_platformReleaseMutex */ #endif /* PHYSFS_PLATFORM_POSIX */ diff -NBaur physfs-release-3.2.0/src/physfs_platforms.h physfs-release-3.2.0-new/src/physfs_platforms.h --- physfs-release-3.2.0/src/physfs_platforms.h 2022-09-30 21:13:07.000000000 +0100 +++ physfs-release-3.2.0-new/src/physfs_platforms.h 2023-03-26 16:16:59.634275766 +0100 @@ -69,6 +69,10 @@ #elif defined(__QNX__) # define PHYSFS_PLATFORM_QNX 1 # define PHYSFS_PLATFORM_POSIX 1 +#elif defined(__3DS__) +# define PHYSFS_PLATFORM_POSIX 1 +# define PHYSFS_PLATFORM_3DS 1 +# define PHYSFS_NO_CDROM_SUPPORT 1 #elif defined(unix) || defined(__unix__) # define PHYSFS_PLATFORM_UNIX 1 # define PHYSFS_PLATFORM_POSIX 1 ================================================ FILE: 3ds/pkg-config/.gitignore ================================================ 3ds-pkg-config ================================================ FILE: 3ds/pkg-config/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=3ds-pkg-config pkgver=0.28 pkgrel=5 pkgdesc='pkg-config wrapper (for Nintendo 3DS homebrew development)' arch=('any') url='http://devkitpro.org/' source=('pkg-config.in') sha256sums=('0478950b8d4b6b08c8cd678237d99563b50752bfc8680d0ce797601c6677fe57') groups=('3ds-dev') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/3ds/bin cp "$srcdir"/pkg-config.in "$pkgdir"/opt/devkitpro/portlibs/3ds/bin/arm-none-eabi-pkg-config } ================================================ FILE: 3ds/pkg-config/pkg-config.in ================================================ #!/usr/bin/env bash command -v pkg-config >/dev/null 2>&1 || { echo >&2 "I require pkg-config but it's not installed. Aborting."; exit 1; } # reset pkg-config variables to ensure we're not polluted by host libraries export PKG_CONFIG_DIR= export PKG_CONFIG_PATH= export PKG_CONFIG_SYSROOT_DIR= export PKG_CONFIG_LIBDIR=${DEVKITPRO}/portlibs/3ds/lib/pkgconfig:${DEVKITPRO}/portlibs/armv6k/lib/pkgconfig [[ "$1" == '--version' ]] && exec pkg-config --version exec pkg-config --static "$@" ================================================ FILE: 3ds/wslay/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=3ds-wslay pkgver=1.1.1 pkgrel=1 pkgdesc='Wslay is a WebSocket library written in C.' arch=('any') url='https://github.com/tatsuhiro-t/wslay' license=('MIT') options=(!strip libtool staticlibs) groups=('3ds-portlibs') makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') source=("https://github.com/tatsuhiro-t/wslay/releases/download/release-${pkgver}/wslay-${pkgver}.tar.gz") sha256sums=('90CE68C6DFD614722D44FBB14563A3F6DACC68B548B20AE382AC4F4952C55268') build() { cd wslay-$pkgver source /opt/devkitpro/3dsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd wslay-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share } ================================================ FILE: 3ds/yaml_cpp/PKGBUILD ================================================ _realname=yaml_cpp pkgname=3ds-${_realname} pkgver=0.8.0 pkgrel=1 pkgdesc='A YAML parser and emitter in C++ matching the YAML 1.2 spec.' arch=('any') url='https://github.com/jbeder/yaml-cpp' license=('MIT') options=(!strip libtool staticlibs) source=( ${_realname}-${pkgver}.tar.gz::${url}/archive/refs/tags/${pkgver}.tar.gz) makedepends=('devkitARM' '3ds-cmake') groups=('3ds-portlibs') build() { cd yaml-cpp-${pkgver} /opt/devkitpro/portlibs/3ds/bin/arm-none-eabi-cmake -B _build -S . -DCMAKE_INSTALL_PREFIX=/opt/devkitpro/portlibs/3ds -DYAML_CPP_BUILD_TOOLS=OFF -GNinja cmake --build _build --parallel } package() { cd yaml-cpp-${pkgver} DESTDIR="${pkgdir}" cmake --install _build } sha256sums=('fbe74bbdcee21d656715688706da3c8becfd946d92cd44705cc6098bb23b3a16') ================================================ FILE: 3ds/zlib/.gitignore ================================================ 3ds-zlib ================================================ FILE: 3ds/zlib/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=3ds-zlib pkgver=1.3.1 pkgrel=1 pkgdesc='Deflate compression method library' arch=('any') url='http://www.zlib.net' license=('zlib') options=(!strip libtool staticlibs) source=("${url}/zlib-$pkgver.tar.xz") makedepends=('dkp-toolchain-vars') groups=('3ds-portlibs') build() { cd zlib-$pkgver source /opt/devkitpro/3dsvars.sh CHOST=arm-none-eabi \ ./configure --prefix="${PORTLIBS_PREFIX}" --static make libz.a # only build library, no programs # libminizip cd contrib/minizip autoreconf --force --verbose --install CFLAGS="${CFLAGS} -DUSE_FILE32API" ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd zlib-$pkgver source /opt/devkitpro/3dsvars.sh make DESTDIR="$pkgdir" install # license install -d "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname tail -n 31 README > "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/LICENSE # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share # libminizip cd contrib/minizip make DESTDIR="$pkgdir" install } sha256sums=('38ef96b8dfe510d42707d9c781877914792541133e1870841463bfa73f883e32') ================================================ FILE: 3ds-examples/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('3ds-examples') pkgver=20240917 pkgrel=1 pkgdesc="Nintendo 3DS example code." arch=('any') license=('custom') url="http://github.com/devkitpro/3ds-examples" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz) makedepends=('devkitARM') groups=('3ds-dev') package() { mkdir -p "$pkgdir"/opt/devkitpro/examples/3ds cp -R $srcdir/${pkgname}-${pkgver}/* "$pkgdir"/opt/devkitpro/examples/3ds } sha256sums=('38ef002fe43d20852a0c9e539c33d8fcd8580bf5ee04331ed48860cb3283eb47') ================================================ FILE: README.md ================================================ # devkitPro portlibs All the libraries here are installable through [devkitPro pacman](https://devkitpro.org/wiki/devkitPro_pacman) ================================================ FILE: armv4t/bzip2/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('armv4t-bzip2') pkgver=1.0.8 pkgrel=1 pkgdesc="A high-quality data compression program" arch=('any') license=('custom') url="https://sourceware.org/bzip2/" options=(!strip libtool staticlibs) source=(https://sourceware.org/pub/bzip2/bzip2-${pkgver}.tar.gz) sha256sums=( 'ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269' ) makedepends=('armv4t-pkg-config' 'dkp-toolchain-vars') groups=('armv4t-portlibs') build() { source /opt/devkitpro/armv4tvars.sh make -C "$srcdir/bzip2-$pkgver" \ CC=${TOOL_PREFIX}gcc \ AR=${TOOL_PREFIX}ar \ RANLIB=${TOOL_PREFIX}ranlib \ CPPFLAGS="${CPPFLAGS}" \ CFLAGS="-D_FILE_OFFSET_BITS=64 -Winline ${CFLAGS}" libbz2.a } package() { source /opt/devkitpro/armv4tvars.sh install -Dm 644 "$srcdir/bzip2-$pkgver"/LICENSE -t "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}" install -Dm 644 "$srcdir/bzip2-$pkgver"/bzlib.h -t "${pkgdir}/${PORTLIBS_PREFIX}/include/" install -Dm 644 "$srcdir/bzip2-$pkgver"/libbz2.a -t "${pkgdir}/${PORTLIBS_PREFIX}/lib" } ================================================ FILE: armv4t/flac/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: cpasjuste # Contributor: oreo639 pkgname=armv4t-flac pkgver=1.3.2 pkgrel=1 pkgdesc='Open source Free Lossless Audio Codec' arch=('any') url='https://xiph.org/flac/' license=(Xiph.org) options=(!strip libtool staticlibs) depends=("armv4t-libogg") makedepends=('dkp-toolchain-vars') groups=('armv4t-portlibs') source=( "https://ftp.osuosl.org/pub/xiph/releases/flac/flac-$pkgver.tar.xz" "flac-${pkgver}.patch" ) sha256sums=( '91cfc3ed61dc40f47f050a109b08610667d73477af6ef36dcad31c31a4a8d53f' '33032574b3a148daab60a5500be1811e64862b39851c6c326a0ee0a90b081edd' ) build() { cd flac-$pkgver source /opt/devkitpro/armv4tvars.sh patch -Np1 -i "$srcdir/flac-${pkgver}.patch" ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static --disable-examples \ --disable-xmms-plugin --disable-doxygen-docs \ --disable-sse make -C src/libFLAC } package() { cd flac-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: armv4t/flac/flac-1.3.2.patch ================================================ diff -ur srcpure/include/share/compat.h srcpatched/include/share/compat.h --- srcpure/include/share/compat.h 2016-12-07 20:10:26.218454157 +0000 +++ srcpatched/include/share/compat.h 2020-08-23 13:10:05.619975022 +0100 @@ -167,8 +167,9 @@ #define flac_vfprintf vfprintf #define flac_fopen fopen -#define flac_chmod chmod -#define flac_utime utime +#define flac_chmod(a, b) printf("flac_chmod: not implemented\n") +#define flac_utime(a, b) printf("flac_utime: not implemented\n") +#define chown(a, b, c) printf("flac_chown: not implemented\n") #define flac_unlink unlink #define flac_rename rename #define flac_stat stat Only in srcpatched/include/share: compat.h~ diff -ur srcpure/Makefile.in srcpatched/Makefile.in --- srcpure/Makefile.in 2017-01-01 03:46:48.833726273 +0000 +++ srcpatched/Makefile.in 2020-08-23 13:09:00.589975823 +0100 @@ -397,7 +397,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = doc include m4 man src examples test build objs microbench +SUBDIRS = include m4 src build objs EXTRA_DIST = \ COPYING.FDL \ COPYING.GPL \ diff -ur srcpure/src/Makefile.in srcpatched/src/Makefile.in --- srcpure/src/Makefile.in 2017-01-01 03:46:49.385728167 +0000 +++ srcpatched/src/Makefile.in 2020-08-23 13:09:00.589975823 +0100 @@ -363,19 +363,11 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @FLaC__HAS_XMMS_TRUE@XMMS_DIRS = plugin_common plugin_xmms -@FLaC__WITH_CPPLIBS_TRUE@CPPLIBS_DIRS = libFLAC++ test_libFLAC++ +@FLaC__WITH_CPPLIBS_TRUE@CPPLIBS_DIRS = libFLAC++ SUBDIRS = \ libFLAC \ share \ - flac \ - metaflac \ $(XMMS_DIRS) \ - test_grabbag \ - test_libs_common \ - test_libFLAC \ - test_seeking \ - test_streams \ - utils \ $(CPPLIBS_DIRS) EXTRA_DIST = \ ================================================ FILE: armv4t/flite/PKGBUILD ================================================ pkgname=armv4t-flite pkgver=2.1 pkgrel=2 pkgdesc='A small fast portable speech synthesis system' arch=('any') url='http://festvox.org/flite/' license=('MIT') options=(!strip libtool staticlibs) depends=() makedepends=('dkp-toolchain-vars') groups=('armv4t-portlibs') source=("http://festvox.org/flite/packed/flite-${pkgver}/flite-${pkgver}-release.tar.bz2") sha256sums=('c73c3f6a2ea764977d6eaf0a287722d1e2066b4697088c552e342c790f3d2b85') build() { cd flite-$pkgver-release source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/armv4tvars.sh ./configure --prefix=$PORTLIBS_PREFIX --host=arm-none-eabi --disable-shared \ CFLAGS="${CFLAGS} -DCST_NO_SOCKETS=true" CPPFLAGS="${CPPFLAGS}" LIBS="${LIBS}" make -C src make -C lang } package() { cd flite-$pkgver-release source /opt/devkitpro/armv4tvars.sh mkdir -p $pkgdir$PORTLIBS_PREFIX/lib cp -a build/arm-eabi/lib/. $pkgdir$PORTLIBS_PREFIX/lib/ mkdir -p $pkgdir$PORTLIBS_PREFIX/include/flite/ install -m 644 include/*.h $pkgdir$PORTLIBS_PREFIX/include/flite/ install -Dm644 COPYING $pkgdir$PORTLIBS_PREFIX/licenses/$pkgname/COPYING } ================================================ FILE: armv4t/freetype/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=armv4t-freetype pkgver=2.13.0 pkgrel=1 pkgdesc='FreeType is a freely available software library to render fonts.' arch=('any') url='https://www.freetype.org/' license=(GPL2+ custom:FreeType) options=(!strip libtool staticlibs) depends=("armv4t-bzip2" "armv4t-libpng" "armv4t-zlib" ) makedepends=('dkp-toolchain-vars') source=("http://download.savannah.gnu.org/releases/freetype/freetype-$pkgver.tar.xz") sha256sums=( '5ee23abd047636c24b2d43c6625dcafc66661d1aca64dec9e0d05df29592624c' ) groups=("armv4t-portlibs") build() { cd freetype-$pkgver source /opt/devkitpro/armv4tvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --enable-freetype-config \ --disable-shared --enable-static \ --with-zlib \ --with-bzip2 \ --with-png make } package() { cd freetype-$pkgver source /opt/devkitpro/armv4tvars.sh make DESTDIR="$pkgdir" install # patch the config script to always output static libraries when not relying on pkg-config sed 's/\$show_static/yes/' -i "${pkgdir}/${PORTLIBS_PREFIX}/bin/freetype-config" # patch the config script to always output static libraries when not relying on pkg-config sed 's/\$show_static/yes/' -i "${pkgdir}/${PORTLIBS_PREFIX}/bin/freetype-config" # Licenses install -Dm644 "LICENSE.TXT" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/LICENSE.TXT" install -Dm644 "docs/GPLv2.TXT" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/GPLv2.TXT" install -Dm644 "docs/FTL.TXT" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/FTL.TXT" # remove useless stuff rm -r "${pkgdir}/${PORTLIBS_PREFIX}/share" } ================================================ FILE: armv4t/libconfig/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=armv4t-libconfig pkgver=1.7.2 pkgrel=1 pkgdesc='C/C++ Configuration File Library (for armv4t homebrew development)' arch=('any') url="https://www.hyperrealm.com/libconfig/libconfig.html" license=('LGPL') options=(!strip libtool staticlibs) source=("https://hyperrealm.github.io/libconfig/dist/libconfig-${pkgver}.tar.gz" "libconfig.patch") makedepends=('dkp-toolchain-vars') sha256sums=( '7c3c7a9c73ff3302084386e96f903eb62ce06953bb1666235fac74363a16fad9' '474c17940200d4aa286e486568a0ecaba2130a758f108e2a0b86c6fed5915d1f' ) groups=('armv4t-portlibs') build() { cd libconfig-$pkgver source /opt/devkitpro/armv4tvars.sh patch -Np1 -i "$srcdir"/libconfig.patch ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static \ --disable-examples make } package() { cd libconfig-$pkgver source /opt/devkitpro/armv4tvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 COPYING.LIB "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING.LIB # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share } ================================================ FILE: armv4t/libconfig/libconfig.patch ================================================ diff -Naur libconfig-1.7.2-ori/lib/libconfig.c libconfig-1.7.2-new/lib/libconfig.c --- libconfig-1.7.2-ori/lib/libconfig.c 2017-12-02 19:12:14.000000000 +0100 +++ libconfig-1.7.2-new/lib/libconfig.c 2020-05-24 15:17:00.850073719 +0200 @@ -78,48 +78,12 @@ static void __config_locale_override(void) { -#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ - && ! defined(__MINGW32__) - - _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); - setlocale(LC_NUMERIC, "C"); - -#elif defined(__APPLE__) - - locale_t loc = newlocale(LC_NUMERIC_MASK, "C", NULL); - uselocale(loc); - -#elif ((defined HAVE_NEWLOCALE) && (defined HAVE_USELOCALE)) - - locale_t loc = newlocale(LC_NUMERIC, "C", NULL); - uselocale(loc); - -#else - -#warning "No way to modify calling thread's locale!" - -#endif } /* ------------------------------------------------------------------------- */ static void __config_locale_restore(void) { -#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ - && ! defined(__MINGW32__) - - _configthreadlocale(_DISABLE_PER_THREAD_LOCALE); - -#elif ((defined HAVE_USELOCALE) && (defined HAVE_FREELOCALE)) - - locale_t loc = uselocale(LC_GLOBAL_LOCALE); - freelocale(loc); - -#else - -#warning "No way to modify calling thread's locale!" - -#endif } /* ------------------------------------------------------------------------- */ ================================================ FILE: armv4t/libexpat/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=armv4t-libexpat pkgver=2.2.5 pkgrel=1 pkgdesc='Expat, a stream-oriented XML parser library written in C.' arch=('any') url='https://libexpat.github.io/' license=(MIT/X) options=(!strip libtool staticlibs) source=("https://github.com/libexpat/libexpat/releases/download/R_2_2_5/expat-$pkgver.tar.bz2") sha256sums=('d9dc32efba7e74f788fcc4f212a43216fc37cf5f23f4c2339664d473353aedf6') makedepends=('dkp-toolchain-vars') groups=('armv4t-portlibs') build() { cd expat-$pkgver source /opt/devkitpro/armv4tvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd expat-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: armv4t/libid3tag/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=armv4t-libid3tag pkgver=0.15.1b pkgrel=1 pkgdesc='A library for reading and (eventually) writing ID3 tags, both ID3v1 and the various versions of ID3v2. (for armv4t homebrew development)' arch=('any') url='https://www.underbit.com' license=('GPL') options=(!strip libtool staticlibs) source=("https://sourceforge.net/projects/mad/files/libid3tag/0.15.1b/libid3tag-${pkgver}.tar.gz") groups=('armv4t-portlibs') sha256sums=('63da4f6e7997278f8a3fef4c6a372d342f705051d1eeb6a46a86b03610e26151') depends=('armv4t-zlib') makedepends=('dkp-toolchain-vars') build() { cd libid3tag-$pkgver source /opt/devkitpro/armv4tvars.sh CPPFLAGS="${CFLAGS} ${CPPFLAGS}" ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi --disable-shared --enable-static make } package() { cd libid3tag-$pkgver source /opt/devkitpro/armv4tvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: armv4t/liblzma/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=armv4t-liblzma pkgver=5.8.2 pkgrel=1 pkgdesc='A compression library with an API similar to that of zlib. (for armv4t homebrew development)' arch=('any') url='https://tukaani.org' license=('GPL') options=(!strip libtool staticlibs) source=("https://tukaani.org/xz/xz-${pkgver}.tar.xz") makedepends=('dkp-toolchain-vars') groups=('armv4t-portlibs') build() { cd xz-$pkgver source /opt/devkitpro/armv4tvars.sh ./configure --prefix=${PORTLIBS_PREFIX} --host=arm-none-eabi \ --enable-static --disable-shared --disable-threads \ --disable-lzma-links --disable-xz --disable-xzdec \ --disable-lzmadec --disable-lzmainfo --disable-nls \ --disable-scripts --disable-doc make } package() { cd xz-$pkgver source /opt/devkitpro/armv4tvars.sh make DESTDIR="$pkgdir" install rm -fr "$pkgdir"${PORTLIBS_PREFIX}/bin } sha256sums=('890966ec3f5d5cc151077879e157c0593500a522f413ac50ba26d22a9a145214') ================================================ FILE: armv4t/libmad/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=armv4t-libmad pkgver=0.15.1b pkgrel=1 pkgdesc='A high-quality MPEG audio decoder. (for armv4t homebrew development)' arch=('any') url='https://www.underbit.com' license=('GPL') options=(!strip libtool staticlibs) source=( "https://sourceforge.net/projects/mad/files/libmad/${pkgver}/libmad-${pkgver}.tar.gz" "libmad-0.15.1b.patch" ) sha256sums=( 'bbfac3ed6bfbc2823d3775ebb931087371e142bb0e9bb1bee51a76a6e0078690' 'b8fd4477d793c1081bd1a4c5c6870fc088b593516c153d3d40bf5d22e7f38a7f' ) makedepends=('dkp-toolchain-vars') groups=('armv4t-portlibs') build() { cd libmad-$pkgver patch -Np1 -i "$srcdir/libmad-0.15.1b.patch" source /opt/devkitpro/armv4tvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi --disable-shared --enable-static \ --enable-fpm=arm --enable-speed make } package() { cd libmad-$pkgver source /opt/devkitpro/devkitarm.sh source /opt/devkitpro/armv4tvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: armv4t/libmad/libmad-0.15.1b.patch ================================================ diff -ur libmad-0.15.1b/configure libmad-0.15.1b-patched/configure --- libmad-0.15.1b/configure 2004-02-05 09:34:07.000000000 +0000 +++ libmad-0.15.1b-patched/configure 2020-08-12 11:51:55.049809336 +0100 @@ -19099,7 +19099,7 @@ case "$optimize" in -O|"-O "*) optimize="-O" - optimize="$optimize -fforce-mem" + optimize="$optimize" optimize="$optimize -fforce-addr" : #x optimize="$optimize -finline-functions" : #- optimize="$optimize -fstrength-reduce" Only in libmad-0.15.1b-patched/: configure~ diff -ur libmad-0.15.1b/configure.ac libmad-0.15.1b-patched/configure.ac --- libmad-0.15.1b/configure.ac 2004-01-23 09:41:32.000000000 +0000 +++ libmad-0.15.1b-patched/configure.ac 2020-08-12 11:51:45.776476110 +0100 @@ -140,7 +140,7 @@ case "$optimize" in -O|"-O "*) optimize="-O" - optimize="$optimize -fforce-mem" + optimize="$optimize" optimize="$optimize -fforce-addr" : #x optimize="$optimize -finline-functions" : #- optimize="$optimize -fstrength-reduce" Only in libmad-0.15.1b-patched/: configure.ac~ ================================================ FILE: armv4t/libogg/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=armv4t-libogg pkgver=1.3.4 pkgrel=1 pkgdesc='The Ogg transport bitstream is designed to provide framing, error protection and seeking structure for higher-level codec streams that consist of raw, unencapsulated data packets, such as the Opus, Vorbis and FLAC audio codecs or the Theora and Dirac video codecs.' arch=('any') url='https://wiki.xiph.org/Ogg' license=(Xiph.org) options=(!strip libtool staticlibs) source=("https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-$pkgver.tar.gz") sha256sums=('fe5670640bd49e828d64d2879c31cb4dde9758681bb664f9bdbf159a01b0c76e') makedepends=('dkp-toolchain-vars') groups=('armv4t-portlibs') build() { cd libogg-$pkgver source /opt/devkitpro/armv4tvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd libogg-$pkgver source /opt/devkitpro/armv4tvars.sh make DESTDIR="$pkgdir" install install -Dm644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING # remove useless documentation rm -r "$pkgdir"${PORTLIBS_PREFIX}/share/doc } ================================================ FILE: armv4t/libpng/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=armv4t-libpng pkgver=1.6.48 pkgrel=1 pkgdesc='PNG format graphic files library' arch=('any') url='http://www.libpng.org' license=('custom') options=(!strip libtool staticlibs) depends=('armv4t-zlib') groups=('armv4t-portlibs') makedepends=('dkp-toolchain-vars') source=("https://download.sourceforge.net/libpng/libpng-$pkgver.tar.xz") build() { cd libpng-$pkgver source /opt/devkitpro/armv4tvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-tools --disable-shared --enable-static make } package() { cd libpng-$pkgver source /opt/devkitpro/armv4tvars.sh make LN_S=cp DESTDIR="$pkgdir" install # license install -Dm644 LICENSE "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/LICENSE # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share } sha256sums=('46fd06ff37db1db64c0dc288d78a3f5efd23ad9ac41561193f983e20937ece03') ================================================ FILE: armv4t/libtheora/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: oreo639 pkgname=armv4t-libtheora pkgver=1.2.0alpha1 pkgrel=1 pkgdesc='Free and open video compression codec from the Xiph.org Foundation' arch=('any') url='https://www.theora.org/' license=(Xiph.org) options=(!strip libtool staticlibs) source=( "https://ftp.osuosl.org/pub/xiph/releases/theora/libtheora-${pkgver}.tar.gz" "libtheora-1.2.0.patch" ) sha256sums=( '538305e6efa484ba740616b521f0d8c4428a0a995193c5e6af9b20f488f3c497' '45c9601eda3425699530edd66da0cf70658844f4cae04f4b1910d1f7f6cb2aa1' ) makedepends=('dkp-toolchain-vars') depends=('armv4t-libogg') groups=('armv4t-portlibs') build() { cd libtheora-${pkgver} patch -Np1 -i "$srcdir/libtheora-1.2.0.patch" source /opt/devkitpro/armv4tvars.sh HAVE_ARM_ASM_EDSP=0 ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static --disable-encode \ --disable-examples --disable-vorbistest \ --disable-asflag-probe --disable-float CFLAGS="-march=armv4t" make } package() { cd libtheora-${pkgver} source /opt/devkitpro/armv4tvars.sh make DESTDIR="$pkgdir" install install -Dm644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING # remove useless documentation rm -r "$pkgdir"${PORTLIBS_PREFIX}/share/doc } ================================================ FILE: armv4t/libtheora/libtheora-1.2.0.patch ================================================ diff -Naur libtheora-1.2.0alpha1.orig/lib/arm/armcpu.c libtheora-1.2.0alpha1/lib/arm/armcpu.c --- libtheora-1.2.0alpha1.orig/lib/arm/armcpu.c 2020-05-06 15:19:58.912792332 -0700 +++ libtheora-1.2.0alpha1/lib/arm/armcpu.c 2020-05-06 15:17:05.241797764 -0700 @@ -111,6 +111,20 @@ /*The feature registers which can tell us what the processor supports are accessible in priveleged modes only, so we can't have a general user-space detection method like on x86.*/ -# error "Configured to use ARM asm but no CPU detection method available for " \ - "your platform. Reconfigure with --disable-asm (or send patches)." + +ogg_uint32_t oc_cpu_flags_get(void){ + ogg_uint32_t flags; + flags=0; + +#if defined(OC_ARM_ASM_EDSP) + flags|=OC_CPU_ARM_EDSP; +#elif defined(OC_ARM_ASM_MEDIA) + flags|=OC_ARM_ASM_MEDIA; +#elif defined(OC_ARM_ASM_NEON) + flags|=OC_ARM_ASM_NEON; +#endif + + return flags; +} + #endif ================================================ FILE: armv4t/libvorbisidec/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=armv4t-libvorbisidec pkgver=1.2.1 pkgrel=1 pkgdesc='Fixed-point version of the Ogg Vorbis decoder (for armv4t homebrew development)' arch=('any') url="http://xiph.org" license=('LGPL') options=(!strip libtool staticlibs) source=("https://downloads.devkitpro.org/packages/sources/libvorbisidec-${pkgver}.tar.xz") sha256sums=('6ae33489ed40b54ab4a1cd0cf349e9b3b1d5c68d722485704d951f4bf80c64c6') makedepends=('dkp-toolchain-vars' 'armv4t-pkg-config') depends=('armv4t-libogg') groups=('armv4t-portlibs') build() { cd libvorbisidec-$pkgver source /opt/devkitpro/armv4tvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi make } package() { cd libvorbisidec-$pkgver source /opt/devkitpro/armv4tvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING } ================================================ FILE: armv4t/libxmp/PKGBUILD ================================================ pkgname=armv4t-libxmp pkgver=4.4.1 pkgrel=1 pkgdesc="Library that supports over 90 module formats" arch=('any') url="http://xmp.sourceforge.net/" license=('GPL') options=(!strip libtool staticlibs) source=("http://download.sourceforge.net/project/xmp/libxmp/$pkgver/libxmp-$pkgver.tar.gz" "libxmp.patch") sha256sums=('353535cc84c8cddae8decec4e65fa4c51fc64f22eb0891bc3dae6eaf25f9cccf' 'f63e0e3aa4197423d82c0cff42a400ca5182a4a56b62bd087e32e7913ed7f42d') makedepends=('dkp-toolchain-vars') groups=("armv4t-portlibs") build() { cd "libxmp-$pkgver" patch -Np1 -i $srcdir/libxmp.patch source /opt/devkitpro/armv4tvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd "libxmp-$pkgver" source /opt/devkitpro/armv4tvars.sh make DESTDIR="$pkgdir/" install } ================================================ FILE: armv4t/libxmp/libxmp.patch ================================================ diff -NBaur libxmp-4.4.1-old/src/load.c libxmp-4.4.1-new/src/load.c --- libxmp-4.4.1-old/src/load.c 2016-10-12 11:30:03.000000000 +0100 +++ libxmp-4.4.1-new/src/load.c 2019-09-22 21:13:57.155910284 +0100 @@ -82,6 +82,7 @@ static int execute_command(char *cmd, char *filename, FILE *t) { +#if defined(HAVE_POPEN) || defined(WIN32) char line[1024], buf[BUFLEN]; FILE *p; int n; @@ -111,7 +112,7 @@ } pclose (p); - +#endif return 0; } @@ -171,7 +172,7 @@ return 0; } -#if defined __ANDROID__ || defined __native_client__ +#if defined __ANDROID__ || defined __native_client__ || !defined(HAVE_POPEN) /* Don't use external helpers in android */ if (cmd) { return 0; ================================================ FILE: armv4t/mikmod/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=armv4t-mikmod pkgver=3.3.11.1 pkgrel=1 pkgdesc="Amodule player and library supporting many formats, including mod, s3m, it, and xm (armv4t port)" arch=('any') url="http://mikmod.sourceforge.net/" license=("LGPL") options=(!strip libtool staticlibs) makedepends=( 'dkp-toolchain-vars' ) source=("https://sourceforge.net/projects/mikmod/files/libmikmod/$pkgver/libmikmod-$pkgver.tar.gz") sha256sums=( 'ad9d64dfc8f83684876419ea7cd4ff4a41d8bcd8c23ef37ecb3a200a16b46d19' ) groups=("armv4t-portlibs") build() { cd libmikmod-$pkgver source /opt/devkitpro/armv4tvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd libmikmod-$pkgver source /opt/devkitpro/armv4tvars.sh make DESTDIR="$pkgdir" install rm -fr "$pkgdir"${PORTLIBS_PREFIX}/share } ================================================ FILE: armv4t/mpg123/PKGBUILD ================================================ # Maintainer: Gabriel Kind pkgname=armv4t-mpg123 pkgver=1.31.3 pkgrel=2 pkgdesc="A real time MPEG audio decoder for layer 1, 2 and 3" arch=('any') url="http://sourceforge.net/projects/mpg123" license=('LGPL2.1') options=(!strip libtool staticlibs) groups=("armv4t-portlibs") source=( "https://downloads.sourceforge.net/sourceforge/mpg123/mpg123-${pkgver}.tar.bz2" "mpg123-${pkgver}.patch" ) makedepends=('dkp-toolchain-vars') build() { cd mpg123-$pkgver source /opt/devkitpro/armv4tvars.sh patch -Np1 -i "$srcdir"/mpg123-${pkgver}.patch autoreconf -fi ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static --enable-fifo=no \ --enable-ipv6=no --enable-network=no --enable-int-quality=no \ --with-cpu=generic --with-default-audio=dummy make } package() { cd mpg123-$pkgver make DESTDIR="$pkgdir" install # remove useless stuff rm -rf "$pkgdir"${PORTLIBS_PREFIX}/bin "$pkgdir"${PORTLIBS_PREFIX}/share } sha256sums=('1ca77d3a69a5ff845b7a0536f783fee554e1041139a6b978f6afe14f5814ad1a' '99e86f82aa5c53769747c7e104f6d2f3a679b29481df38386321beb6f7ef0b70') ================================================ FILE: armv4t/mpg123/mpg123-1.25.10.patch ================================================ diff -Naur mpg123-1.25.10.old/configure.ac mpg123-1.25.10/configure.ac --- mpg123-1.25.10.old/configure.ac 2018-02-27 10:34:27.000000000 +0000 +++ mpg123-1.25.10/configure.ac 2018-03-28 15:37:59.296955042 +0100 @@ -1217,6 +1217,20 @@ # AC_DEFINE( #fi +if test x"$ac_cv_header_sys_signal_h" = xyes; then + AC_CHECK_FUNCS( sigemptyset sigaddset sigprocmask sigaction ) + if test x"$ac_cv_func_sigemptyset" = xno || + test x"$ac_cv_func_sigaddset" = xno || + test x"$ac_cv_func_sigprocmask" = xno || + test x"$ac_cv_func_sigaction" = xno; then + AC_DEFINE(DONT_CATCH_SIGNALS, 1, [ Signal handling is not supported on this platform ]) + fi +else + AC_DEFINE(DONT_CATCH_SIGNALS, 1, [ Signal handling is not supported on this platform ]) +fi + +AC_CHECK_FUNCS( sleep, [ have_sleep=yes ], [ have_sleep=no ] ) + dnl ############## Choose compiler flags and CPU # do not assume gcc here, so no flags by default diff -Naur mpg123-1.25.10.old/libmpg123.pc.in mpg123-1.25.10/libmpg123.pc.in --- mpg123-1.25.10.old/libmpg123.pc.in 2018-02-27 10:26:38.000000000 +0000 +++ mpg123-1.25.10/libmpg123.pc.in 2018-03-28 15:38:45.242144066 +0100 @@ -7,5 +7,5 @@ Description: An optimised MPEG Audio decoder Requires: Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lmpg123 +Libs: -L${libdir} -lmpg123 -lm Cflags: -I${includedir} diff -Naur mpg123-1.25.10.old/libout123.pc.in mpg123-1.25.10/libout123.pc.in --- mpg123-1.25.10.old/libout123.pc.in 2018-02-27 10:26:38.000000000 +0000 +++ mpg123-1.25.10/libout123.pc.in 2018-03-28 15:38:59.027716837 +0100 @@ -7,5 +7,5 @@ Description: A streaming audio output API derived from mpg123 Requires: Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lout123 +Libs: -L${libdir} -lout123 -lm Cflags: -I${includedir} diff -Naur mpg123-1.25.10.old/src/control_generic.c mpg123-1.25.10/src/control_generic.c --- mpg123-1.25.10.old/src/control_generic.c 2018-02-27 10:26:38.000000000 +0000 +++ mpg123-1.25.10/src/control_generic.c 2018-03-28 15:37:59.296955042 +0100 @@ -28,8 +28,10 @@ #include #if !defined (WIN32) || defined (__CYGWIN__) #include +#ifdef NETWORK #include #endif +#endif #include #include @@ -311,8 +313,11 @@ outstream = stderr; else outstream = stdout; - -#ifndef WIN32 + +#if 1 + fprintf(outstream, "The control interface is not supported on this platform\n"); + return 0; +#elif !defined(WIN32) setlinebuf(outstream); #else /* perhaps just use setvbuf as it's C89 */ /* diff -Naur mpg123-1.25.10.old/src/mpg123.c mpg123-1.25.10/src/mpg123.c --- mpg123-1.25.10.old/src/mpg123.c 2018-02-27 10:26:38.000000000 +0000 +++ mpg123-1.25.10/src/mpg123.c 2018-03-28 15:37:59.296955042 +0100 @@ -1239,6 +1239,8 @@ if(param.verbose > 2) fprintf(stderr, "Note: pausing %i seconds before next track.\n", param.delay); #ifdef WIN32 Sleep(param.delay*1000); +#elif !defined(HAVE_SLEEP) + fprintf(stderr, "sleep not supported on this platform\n"); #else sleep(param.delay); #endif ================================================ FILE: armv4t/mpg123/mpg123-1.31.3.patch ================================================ diff -NBaur mpg123-1.31.3.orig/configure.ac mpg123-1.31.3/configure.ac --- mpg123-1.31.3.orig/configure.ac 2023-03-17 17:10:06.000000000 +0000 +++ mpg123-1.31.3/configure.ac 2023-08-30 19:13:29.093284185 +0100 @@ -1350,6 +1350,20 @@ # Optionally use platform macros for byte swapping. AC_CHECK_HEADERS([byteswap.h]) +if test x"$ac_cv_header_sys_signal_h" = xyes; then + AC_CHECK_FUNCS( sigemptyset sigaddset sigprocmask sigaction ) + if test x"$ac_cv_func_sigemptyset" = xno || + test x"$ac_cv_func_sigaddset" = xno || + test x"$ac_cv_func_sigprocmask" = xno || + test x"$ac_cv_func_sigaction" = xno; then + AC_DEFINE(DONT_CATCH_SIGNALS, 1, [ Signal handling is not supported on this platform ]) + fi +else + AC_DEFINE(DONT_CATCH_SIGNALS, 1, [ Signal handling is not supported on this platform ]) +fi + +AC_CHECK_FUNCS( sleep, [ have_sleep=yes ], [ have_sleep=no ] ) + dnl ############## Choose compiler flags and CPU # do not assume gcc here, so no flags by default diff -NBaur mpg123-1.31.3.orig/libmpg123.pc.in mpg123-1.31.3/libmpg123.pc.in --- mpg123-1.31.3.orig/libmpg123.pc.in 2023-03-15 08:02:58.000000000 +0000 +++ mpg123-1.31.3/libmpg123.pc.in 2023-08-30 19:13:29.093284185 +0100 @@ -7,6 +7,6 @@ Description: An optimised MPEG Audio decoder Requires: Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lmpg123 +Libs: -L${libdir} -lmpg123 -lm Libs.private: @LIBMPG123_LIBS@ Cflags: -I${includedir} diff -NBaur mpg123-1.31.3.orig/libout123.pc.in mpg123-1.31.3/libout123.pc.in --- mpg123-1.31.3.orig/libout123.pc.in 2023-03-15 08:02:58.000000000 +0000 +++ mpg123-1.31.3/libout123.pc.in 2023-08-30 19:13:29.093284185 +0100 @@ -7,6 +7,6 @@ Description: A streaming audio output API derived from mpg123 Requires: Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lout123 +Libs: -L${libdir} -lout123 -lm Libs.private: @LIBOUT123_LIBS@ @LIBDL@ Cflags: -I${includedir} diff -NBaur mpg123-1.31.3.orig/src/control_generic.c mpg123-1.31.3/src/control_generic.c --- mpg123-1.31.3.orig/src/control_generic.c 2023-03-15 08:20:01.000000000 +0000 +++ mpg123-1.31.3/src/control_generic.c 2023-08-30 19:13:29.093284185 +0100 @@ -28,8 +28,10 @@ #include #if !defined (_WIN32) || defined (__CYGWIN__) #include +#ifdef NETWORK #include #endif +#endif #include #include diff -NBaur mpg123-1.31.3.orig/src/Makemodule.am mpg123-1.31.3/src/Makemodule.am --- mpg123-1.31.3.orig/src/Makemodule.am 2023-03-15 08:02:57.000000000 +0000 +++ mpg123-1.31.3/src/Makemodule.am 2023-08-30 19:16:12.291812289 +0100 @@ -1,34 +1,10 @@ # Module for non-recursive mpg123 build system. -include src/tests/Makemodule.am include src/compat/Makemodule.am include src/libmpg123/Makemodule.am include src/libout123/Makemodule.am include src/libsyn123/Makemodule.am -bin_PROGRAMS += \ - src/mpg123 \ - src/out123 \ - src/mpg123-id3dump \ - src/mpg123-strip - -src_mpg123_LDADD = \ - src/compat/libcompat.la \ - src/libmpg123/libmpg123.la \ - src/libout123/libout123.la \ - src/libsyn123/libsyn123.la \ - @PROG_LIBS@ - -src_mpg123_LDFLAGS = @EXEC_LT_LDFLAGS@ - -src_out123_LDADD = \ - src/compat/libcompat.la \ - src/libsyn123/libsyn123.la \ - src/libout123/libout123.la \ - @PROG_LIBS@ - -src_out123_LDFLAGS = @EXEC_LT_LDFLAGS@ - EXTRA_DIST += \ src/intsym.h \ src/mpg123-with-modules \ @@ -36,118 +12,3 @@ CLEANFILES += src/*.a -src_mpg123_id3dump_LDADD = \ - src/compat/libcompat.la \ - src/libmpg123/libmpg123.la \ - @PROG_LIBS@ - -src_mpg123_strip_LDADD = \ - src/compat/libcompat.la \ - src/libmpg123/libmpg123.la \ - @PROG_LIBS@ - -src_mpg123_SOURCES = \ - src/audio.c \ - src/audio.h \ - src/common.c \ - src/common.h \ - src/sysutil.c \ - src/sysutil.h \ - src/control_generic.c \ - src/equalizer.c \ - src/getlopt.c \ - src/getlopt.h \ - src/httpget.c \ - src/httpget.h \ - src/resolver.c \ - src/resolver.h \ - src/genre.h \ - src/genre.c \ - src/mpg123.c \ - src/mpg123app.h \ - src/metaprint.c \ - src/metaprint.h \ - src/local.h \ - src/local.c \ - src/playlist.c \ - src/playlist.h \ - src/streamdump.h \ - src/streamdump.c \ - src/term.c \ - src/term.h \ - src/terms.h \ - src/win32_support.h - -# Does that finally work to build/link the correct object file? -src_mpg123_SOURCES += - -# Replace common.h by sysutil.h! -src_out123_SOURCES = \ - src/sysutil.c \ - src/sysutil.h \ - src/common.h \ - src/getlopt.c \ - src/getlopt.h \ - src/local.h \ - src/local.c \ - src/filters.h \ - src/filters.c \ - src/out123.c \ - src/mpg123app.h \ - src/win32_support.h - -src_mpg123_id3dump_SOURCES = \ - src/mpg123-id3dump.c \ - src/getlopt.c \ - src/getlopt.h - -src_mpg123_strip_SOURCES = \ - src/mpg123-strip.c \ - src/getlopt.c \ - src/getlopt.h - -if TERM_POSIX -src_mpg123_SOURCES += src/term_posix.c -endif - -if TERM_WIN32 -src_mpg123_SOURCES += src/term_win32.c -endif - -if TERM_NONE -src_mpg123_SOURCES += src/term_none.c -endif - -if NET123 -src_mpg123_SOURCES += src/net123.h -endif - -if NET123_EXEC -src_mpg123_SOURCES += src/net123_exec.c -endif - -if NET123_WINHTTP -src_mpg123_SOURCES += src/net123_winhttp.c -src_mpg123_LDADD += -lwinhttp -endif - -if NET123_WININET -src_mpg123_SOURCES += src/net123_wininet.c -src_mpg123_LDADD += -lwininet -endif - -if WIN32_CODES -src_mpg123_SOURCES += \ - src/win32_support.c - -if NETWORK_WINSOCK -src_mpg123_SOURCES += src/win32_net.c -src_mpg123_LDADD += -lws2_32 -endif - -src_out123_SOURCES+= \ - src/win32_support.c - -src_mpg123_id3dump_SOURCES += \ - src/win32_support.c -endif diff -NBaur mpg123-1.31.3.orig/src/mpg123.c mpg123-1.31.3/src/mpg123.c --- mpg123-1.31.3.orig/src/mpg123.c 2023-03-15 08:02:57.000000000 +0000 +++ mpg123-1.31.3/src/mpg123.c 2023-08-30 19:13:29.093284185 +0100 @@ -1334,6 +1334,8 @@ if(param.verbose > 2) fprintf(stderr, "Note: pausing %i seconds before next track.\n", param.delay); #ifdef WIN32 Sleep(param.delay*1000); +#elif !defined(HAVE_SLEEP) + fprintf(stderr, "sleep not supported on this platform\n"); #else sleep(param.delay); #endif ================================================ FILE: armv4t/pkg-config/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=armv4t-pkg-config pkgver=0.28 pkgrel=1 pkgdesc='pkg-config wrapper' arch=('any') url='http://devkitpro.org/' source=('pkg-config.in') sha256sums=('696a12398d82b5e29c267334aef85346f2f0373697ecd7fde3bd420cbf293540') groups=('gp32-dev' 'gba-dev' 'gp2x-dev') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/armv4t/bin cp "$srcdir"/pkg-config.in "$pkgdir"/opt/devkitpro/portlibs/armv4t/bin/arm-none-eabi-pkg-config } ================================================ FILE: armv4t/pkg-config/pkg-config.in ================================================ #!/usr/bin/env bash command -v pkg-config >/dev/null 2>&1 || { echo >&2 "I require pkg-config but it's not installed. Aborting."; exit 1; } # reset pkg-config variables to ensure we're not polluted by host libraries export PKG_CONFIG_DIR= export PKG_CONFIG_PATH= export PKG_CONFIG_SYSROOT_DIR= export PKG_CONFIG_LIBDIR=${DEVKITPRO}/portlibs/armv4t/lib/pkgconfig [[ "$1" == '--version' ]] && exec pkg-config --version exec pkg-config --static "$@" ================================================ FILE: armv4t/zlib/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=armv4t-zlib pkgver=1.3 pkgrel=1 pkgdesc='Deflate compression method library' arch=('any') url='http://www.zlib.net' license=('zlib') options=(!strip libtool staticlibs) source=("${url}/zlib-${pkgver}.tar.xz") makedepends=('dkp-toolchain-vars') groups=('armv4t-portlibs') build() { cd zlib-$pkgver source /opt/devkitpro/armv4tvars.sh CHOST=arm-none-eabi \ ./configure --prefix="${PORTLIBS_PREFIX}" --static make libz.a # only build library, no programs # libminizip cd contrib/minizip autoreconf --force --verbose --install CFLAGS="${CFLAGS} -DUSE_FILE32API" ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd zlib-$pkgver source /opt/devkitpro/armv4tvars.sh make DESTDIR="$pkgdir" install # license install -d "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname tail -n 31 README > "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/LICENSE # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share # libminizip cd contrib/minizip make DESTDIR="$pkgdir" install } sha256sums=('8a9ba2898e1d0d774eca6ba5b4627a11e5588ba85c8851336eb38de4683050a7') ================================================ FILE: calico/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('calico') pkgver=1.2.0 pkgrel=1 pkgdesc="RTOS-like bare metal platform support library for Nintendo DS(i)" arch=('any') license=('Zope') url="http://github.com/devkitpro/${pkgname}" options=(!strip libtool staticlibs) source=( ${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz ) makedepends=('catnip' 'devkitARM' 'devkitarm-rules' 'devkitarm-crtls') groups=('nds-dev') package() { cd $srcdir/${pkgname}-${pkgver} DESTDIR=$pkgdir catnip install } sha256sums=('9f9988e99ad0ef3017547389f957d722445a9892074836cca3030ef80dcb2635') ================================================ FILE: citro2d/PKGBUILD ================================================ # Maintainer: fincs pkgname=('citro2d') pkgver=1.7.0 pkgrel=1 pkgdesc="Nintendo 3DS gpu 2d helper library." arch=('any') license=('custom') url="http://github.com/devkitpro/${pkgname}" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz) makedepends=('devkitARM') depends=('libctru' 'citro3d') groups=('3ds-dev') build() { cd ${srcdir}/${pkgname}-${pkgver} catnip } package() { cd ${srcdir}/${pkgname}-${pkgver} DESTDIR=$pkgdir catnip install } sha256sums=('f311d1decb64668980b7a7a917a9b936a40025265df921e251f5f0537b94b86b') ================================================ FILE: citro3d/PKGBUILD ================================================ # Maintainer: fincs pkgname=('citro3d') pkgver=1.7.1 pkgrel=2 pkgdesc="Nintendo 3DS gpu library." arch=('any') license=('custom') url="http://github.com/devkitPro/${pkgname}" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz) sha256sums=('4f4e816bdaca5a7bf4a905397226b3249026e2fa5ac63dfc0a73296dc83cbb52') makedepends=('devkitARM') depends=('libctru') groups=('3ds-dev') build() { make -C $srcdir/${pkgname}-${pkgver} } package() { make -C $srcdir/${pkgname}-${pkgver} DESTDIR=$pkgdir install } sha256sums=('c920515a791442e81e0c2c8867dde81bf14aca17eacb2709b4a3a3c61699250c') ================================================ FILE: cmake/3ds/3DS.cmake ================================================ cmake_minimum_required(VERSION 3.13) if(NOT CMAKE_SYSTEM_NAME) set(CMAKE_SYSTEM_NAME Nintendo3DS) endif() if(NOT CMAKE_SYSTEM_PROCESSOR) set(CMAKE_SYSTEM_PROCESSOR armv6k) endif() # Import devkitARM toolchain include(${CMAKE_CURRENT_LIST_DIR}/devkitARM.cmake) set(CTR_ROOT ${DEVKITPRO}/libctru) set(DKP_INSTALL_PREFIX_INIT ${DEVKITPRO}/portlibs/3ds) __dkp_platform_prefix( ${DEVKITPRO}/portlibs/3ds ${CTR_ROOT} ) find_program(PKG_CONFIG_EXECUTABLE NAMES arm-none-eabi-pkg-config HINTS "${DEVKITPRO}/portlibs/3ds/bin") if (NOT PKG_CONFIG_EXECUTABLE) message(FATAL_ERROR "Could not find arm-none-eabi-pkg-config: try installing 3ds-pkg-config") endif() find_program(CTR_SMDHTOOL_EXE NAMES smdhtool HINTS "${DEVKITPRO}/tools/bin") find_program(CTR_3DSXTOOL_EXE NAMES 3dsxtool HINTS "${DEVKITPRO}/tools/bin") find_program(CTR_PICASSO_EXE NAMES picasso HINTS "${DEVKITPRO}/tools/bin") find_program(CTR_TEX3DS_EXE NAMES tex3ds HINTS "${DEVKITPRO}/tools/bin") find_file(CTR_DEFAULT_ICON NAMES default_icon.png HINTS "${CTR_ROOT}" NO_CMAKE_FIND_ROOT_PATH) ================================================ FILE: cmake/3ds/Nintendo3DS.cmake ================================================ # ----------------------------------------------------------------------------- # Platform configuration cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) # Inherit default devkitPro platform configuration include(Platform/Generic-dkP) # Platform identification flags set(NINTENDO_3DS TRUE) # Platform settings set(CTR_ARCH_SETTINGS "-march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft") set(CTR_COMMON_FLAGS "-mword-relocations -ffunction-sections -D__3DS__") set(CTR_LINKER_FLAGS "-L${CTR_ROOT}/lib -L${DEVKITPRO}/portlibs/3ds/lib -specs=3dsx.specs") set(CTR_STANDARD_LIBRARIES "-lctru -lm") set(CTR_STANDARD_INCLUDE_DIRECTORIES "${CTR_ROOT}/include") __dkp_init_platform_settings(CTR) # ----------------------------------------------------------------------------- # Platform-specific helper utilities function(ctr_generate_smdh) cmake_parse_arguments(PARSE_ARGV 0 SMDH "" "OUTPUT;NAME;DESCRIPTION;AUTHOR;ICON" "") if (NOT CTR_SMDHTOOL_EXE) message(FATAL_ERROR "Could not find smdhtool: try installing 3ds-tools") endif() if (NOT DEFINED SMDH_OUTPUT) if(DEFINED SMDH_UNPARSED_ARGUMENTS) list(GET SMDH_UNPARSED_ARGUMENTS 0 SMDH_OUTPUT) else() message(FATAL_ERROR "ctr_generate_smdh: missing OUTPUT argument") endif() endif() if (NOT DEFINED SMDH_NAME) set(SMDH_NAME "${CMAKE_PROJECT_NAME}") endif() if (NOT DEFINED SMDH_DESCRIPTION) set(SMDH_DESCRIPTION "Built with devkitARM & libctru") endif() if (NOT DEFINED SMDH_AUTHOR) set(SMDH_AUTHOR "Unspecified Author") endif() if (NOT DEFINED SMDH_ICON) if(NOT CTR_DEFAULT_ICON) message(FATAL_ERROR "ctr_generate_smdh: could not find default icon, try installing libctru") endif() set(SMDH_ICON "${CTR_DEFAULT_ICON}") else() get_filename_component(SMDH_ICON "${SMDH_ICON}" ABSOLUTE) endif() get_filename_component(SMDH_OUTPUT "${SMDH_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") add_custom_command( OUTPUT "${SMDH_OUTPUT}" COMMAND ${CTR_SMDHTOOL_EXE} --create "${SMDH_NAME}" "${SMDH_DESCRIPTION}" "${SMDH_AUTHOR}" "${SMDH_ICON}" "${SMDH_OUTPUT}" DEPENDS "${SMDH_ICON}" VERBATIM ) endfunction() function(ctr_create_3dsx target) cmake_parse_arguments(PARSE_ARGV 1 CTR_3DSXTOOL "NOSMDH" "TARGET;OUTPUT;SMDH;ROMFS" "") if (NOT CTR_3DSXTOOL_EXE) message(FATAL_ERROR "Could not find 3dsxtool: try installing 3ds-tools") endif() if(DEFINED CTR_3DSXTOOL_TARGET) set(intarget "${CTR_3DSXTOOL_TARGET}") set(outtarget "${target}") else() set(intarget "${target}") set(outtarget "${target}_3dsx") endif() if(NOT TARGET "${intarget}") message(FATAL_ERROR "ctr_create_3dsx: target '${intarget}' not defined") endif() if(DEFINED CTR_3DSXTOOL_OUTPUT) get_filename_component(CTR_3DSXTOOL_OUTPUT "${CTR_3DSXTOOL_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") elseif(DEFINED CTR_3DSXTOOL_TARGET) set(CTR_3DSXTOOL_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${outtarget}.3dsx") else() __dkp_target_derive_name(CTR_3DSXTOOL_OUTPUT ${intarget} ".3dsx") endif() set(CTR_3DSXTOOL_ARGS "$" "${CTR_3DSXTOOL_OUTPUT}") set(CTR_3DSXTOOL_DEPS ${intarget}) if (DEFINED CTR_3DSXTOOL_SMDH AND CTR_3DSXTOOL_NOSMDH) message(FATAL_ERROR "ctr_create_3dsx: cannot specify SMDH and NOSMDH at the same time") endif() if (NOT DEFINED CTR_3DSXTOOL_SMDH AND NOT CTR_3DSXTOOL_NOSMDH) set(CTR_3DSXTOOL_SMDH "${CMAKE_CURRENT_BINARY_DIR}/${outtarget}.default.smdh") ctr_generate_smdh(OUTPUT "${CTR_3DSXTOOL_SMDH}") endif() if (DEFINED CTR_3DSXTOOL_SMDH) get_filename_component(CTR_3DSXTOOL_SMDH "${CTR_3DSXTOOL_SMDH}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") list(APPEND CTR_3DSXTOOL_ARGS "--smdh=${CTR_3DSXTOOL_SMDH}") list(APPEND CTR_3DSXTOOL_DEPS "${CTR_3DSXTOOL_SMDH}") endif() if (DEFINED CTR_3DSXTOOL_ROMFS) if (TARGET "${CTR_3DSXTOOL_ROMFS}") get_target_property(_folder "${CTR_3DSXTOOL_ROMFS}" DKP_ASSET_FOLDER) if (NOT _folder) message(FATAL_ERROR "ctr_create_3dsx: not a valid asset target") endif() list(APPEND CTR_3DSXTOOL_ARGS "--romfs=${_folder}") list(APPEND CTR_3DSXTOOL_DEPS ${CTR_3DSXTOOL_ROMFS} $) else() get_filename_component(CTR_3DSXTOOL_ROMFS "${CTR_3DSXTOOL_ROMFS}" ABSOLUTE) if (NOT IS_DIRECTORY "${CTR_3DSXTOOL_ROMFS}") message(FATAL_ERROR "ctr_create_3dsx: cannot find romfs dir: ${CTR_3DSXTOOL_ROMFS}") endif() list(APPEND CTR_3DSXTOOL_ARGS "--romfs=${CTR_3DSXTOOL_ROMFS}") endif() endif() add_custom_command( OUTPUT "${CTR_3DSXTOOL_OUTPUT}" COMMAND "${CTR_3DSXTOOL_EXE}" ${CTR_3DSXTOOL_ARGS} DEPENDS ${CTR_3DSXTOOL_DEPS} COMMENT "Building 3DSX executable target ${outtarget}" VERBATIM ) add_custom_target(${outtarget} ALL DEPENDS "${CTR_3DSXTOOL_OUTPUT}") dkp_set_target_file(${outtarget} "${CTR_3DSXTOOL_OUTPUT}") endfunction() function(ctr_add_shader_library target) cmake_parse_arguments(PARSE_ARGV 1 CTR_PICASSO "" "OUTPUT" "SOURCES") if (NOT CTR_PICASSO_EXE) message(FATAL_ERROR "Could not find picasso: try installing picasso") endif() if(DEFINED CTR_PICASSO_OUTPUT) get_filename_component(CTR_PICASSO_OUTPUT "${CTR_PICASSO_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") else() set(CTR_PICASSO_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}.shbin") endif() if(NOT DEFINED CTR_PICASSO_SOURCES AND DEFINED CTR_PICASSO_UNPARSED_ARGUMENTS) set(CTR_PICASSO_SOURCES "${CTR_PICASSO_UNPARSED_ARGUMENTS}") else() message(FATAL_ERROR "ctr_add_shader_library: must provide at least one source code file") endif() add_custom_command( OUTPUT "${CTR_PICASSO_OUTPUT}" COMMAND "${CTR_PICASSO_EXE}" -o "${CTR_PICASSO_OUTPUT}" ${CTR_PICASSO_SOURCES} DEPENDS ${CTR_PICASSO_SOURCES} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Building shader library ${target}" VERBATIM ) add_custom_target(${target} DEPENDS "${CTR_PICASSO_OUTPUT}") dkp_set_target_file(${target} "${CTR_PICASSO_OUTPUT}") endfunction() function(ctr_add_graphics_target target kind) cmake_parse_arguments(PARSE_ARGV 2 CTR_TEX3DS "" "OUTPUT" "INPUTS;OPTIONS") if (NOT CTR_TEX3DS_EXE) message(FATAL_ERROR "Could not find tex3ds: try installing tex3ds") endif() if(DEFINED CTR_TEX3DS_OUTPUT) get_filename_component(CTR_TEX3DS_OUTPUT "${CTR_TEX3DS_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") else() set(CTR_TEX3DS_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}.t3x") endif() set(CTR_TEX3DS_ARGS -o "${CTR_TEX3DS_OUTPUT}") set(CTR_TEX3DS_DEPS "") string(TOUPPER "${kind}" kind) if(kind STREQUAL "IMAGE") # Nothing on purpose elseif(kind STREQUAL "CUBEMAP") list(APPEND CTR_TEX3DS_ARGS "--cubemap") elseif(kind STREQUAL "SKYBOX") list(APPEND CTR_TEX3DS_ARGS "--skybox") elseif(kind STREQUAL "ATLAS") list(APPEND CTR_TEX3DS_ARGS "--atlas") else() message(FATAL_ERROR "ctr_add_graphics_target: invalid mode: ${kind}") endif() list(LENGTH CTR_TEX3DS_INPUTS numinputs) if(numinputs LESS 1) message(FATAL_ERROR "ctr_add_graphics_target: must provide at least one input") endif() if(NOT kind STREQUAL "ATLAS" AND numinputs GREATER 1) message(FATAL_ERROR "ctr_add_graphics_target: multiple inputs only supported with atlas mode") endif() list(APPEND CTR_TEX3DS_ARGS ${CTR_TEX3DS_OPTIONS}) foreach(input IN LISTS CTR_TEX3DS_INPUTS) dkp_resolve_file(infile "${input}") list(APPEND CTR_TEX3DS_ARGS "${infile}") if (TARGET "${input}") list(APPEND CTR_TEX3DS_DEPS ${input} "${infile}") else() list(APPEND CTR_TEX3DS_DEPS "${infile}") endif() endforeach() add_custom_command( OUTPUT "${CTR_TEX3DS_OUTPUT}" COMMAND "${CTR_TEX3DS_EXE}" ${CTR_TEX3DS_ARGS} DEPENDS ${CTR_TEX3DS_DEPS} COMMENT "Converting graphics target ${target}" VERBATIM ) add_custom_target(${target} DEPENDS "${CTR_TEX3DS_OUTPUT}") dkp_set_target_file(${target} "${CTR_TEX3DS_OUTPUT}") endfunction() ================================================ FILE: cmake/3ds/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=3ds-cmake pkgver=1.5.2 pkgrel=1 pkgdesc="CMake support for Nintendo 3DS" arch=('any') url='http://devkitpro.org/' source=( '3DS.cmake' 'Nintendo3DS.cmake' 'arm-none-eabi-cmake' ) options=('!strip') depends=('devkitarm-cmake' '3dstools' 'picasso' 'tex3ds' '3ds-pkg-config') groups=('3ds-dev') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/3ds/bin cp "$srcdir"/arm-none-eabi-cmake "$pkgdir"/opt/devkitpro/portlibs/3ds/bin/ install -d "$pkgdir"/opt/devkitpro/cmake cp "${srcdir}"/3DS.cmake "$pkgdir"/opt/devkitpro/cmake install -d "$pkgdir"/opt/devkitpro/cmake/Platform cp "${srcdir}"/Nintendo3DS.cmake "$pkgdir"/opt/devkitpro/cmake/Platform } sha256sums=('b60cadbc5b3f1647d107215309698f862ef0a06b3a8057b729b4cb7ff77e1c45' '63bba1bc5b65a61797d07fa8bbf8dc8ac135920db77d00ee1446d1c72100eabb' '1f0d0d843f460784481b231848906f4f773574567a625c60f46687cdae42d6d1') ================================================ FILE: cmake/3ds/arm-none-eabi-cmake ================================================ #!/usr/bin/env bash set -e exec env CMAKE_TOOLCHAIN_FILE="${DEVKITPRO}/cmake/3DS.cmake" cmake "$@" ================================================ FILE: cmake/catnip/PKGBUILD ================================================ # Maintainer: fincs pkgname=('catnip') pkgver=0.2.0 pkgrel=1 pkgdesc="Helper tool for devkitPro CMake" arch=('any') license=('custom') url="http://github.com/devkitPro/${pkgname}" options=(!strip libtool staticlibs) source=( ${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz ) depends=('dkp-cmake-common-utils') groups=('3ds-dev' 'switch-dev' 'wiiu-dev' 'gba-dev' 'nds-dev' 'gamecube-dev' 'wii-dev') package() { cd ${srcdir}/${pkgname}-${pkgver} install -d "$pkgdir"/opt/devkitpro/tools/bin install -d "$pkgdir"/opt/devkitpro/cmake install -d "$pkgdir"/opt/devkitpro/cmake/Catnip install -m 755 -t "$pkgdir"/opt/devkitpro/tools/bin catnip install -m 644 -t "$pkgdir"/opt/devkitpro/tools/bin catnip.cmd install -m 644 -t "$pkgdir"/opt/devkitpro/cmake cmake/*.cmake install -m 644 -t "$pkgdir"/opt/devkitpro/cmake/Catnip cmake/Catnip/*.cmake } sha256sums=('383b503f0826e123fa00680a7615b8d584f94d2ac28aa56b007a74079680f9c7') ================================================ FILE: cmake/common-utils/Generic-dkP.cmake ================================================ # ----------------------------------------------------------------------------- # Generic configuration for devkitPro platforms cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) # Set default build type set(CMAKE_BUILD_TYPE_INIT "Release") # Use .elf extension for compiled binaries set(CMAKE_EXECUTABLE_SUFFIX .elf) # Prevent standard build configurations from loading unwanted "default" flags if(DKP_NO_BUILTIN_CMAKE_CONFIGS) set(CMAKE_NOT_USING_CONFIG_FLAGS TRUE) endif() # Disable shared library support set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Shared libs not available") set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) # Helper macro for platform settings initialization macro(__dkp_init_platform_settings platform) foreach(lang IN ITEMS C CXX ASM) set(CMAKE_${lang}_FLAGS_INIT "${${platform}_ARCH_SETTINGS} ${${platform}_COMMON_FLAGS}") if(NOT DKP_PLATFORM_BOOTSTRAP) set(CMAKE_${lang}_STANDARD_LIBRARIES "${${platform}_STANDARD_LIBRARIES}" CACHE STRING "" FORCE) set(CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES "${${platform}_STANDARD_INCLUDE_DIRECTORIES}" CACHE STRING "") endif() endforeach() string(APPEND CMAKE_ASM_FLAGS_INIT " -x assembler-with-cpp") if(NOT DKP_PLATFORM_BOOTSTRAP) set(CMAKE_EXE_LINKER_FLAGS_INIT "${${platform}_LINKER_FLAGS}") else() set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) endif() if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND DEFINED DKP_INSTALL_PREFIX_INIT) set(CMAKE_INSTALL_PREFIX "${DKP_INSTALL_PREFIX_INIT}" CACHE PATH "Install path prefix, prepended onto install directories." FORCE) endif() if(NOT CMAKE_LIBRARY_ARCHITECTURE) string(REPLACE " " ";" _dkp_arch "${${platform}_ARCH_SETTINGS}") if(CMAKE_POSITION_INDEPENDENT_CODE) list(APPEND _dkp_arch "-fPIC") endif() execute_process( COMMAND "${CMAKE_C_COMPILER}" ${_dkp_arch} -print-multi-directory OUTPUT_VARIABLE _dkp_multidir RESULT_VARIABLE _dkp_retval OUTPUT_STRIP_TRAILING_WHITESPACE ) if(NOT _dkp_retval AND NOT _dkp_multidir STREQUAL ".") set(CMAKE_LIBRARY_ARCHITECTURE "${_dkp_multidir}" CACHE INTERNAL "abi") message(STATUS "Detected multilib folder: ${CMAKE_LIBRARY_ARCHITECTURE}") endif() endif() endmacro() # ----------------------------------------------------------------------------- # Helper utilities # Include common devkitPro bits and pieces include(dkp-impl-helpers) include(dkp-linker-utils) include(dkp-custom-target) include(dkp-embedded-binary) include(dkp-asset-folder) # Build tool hook if(DEFINED ENV{DKP_BUILD_TOOL_HOOK}) set(DKP_BUILD_TOOL_HOOK "$ENV{DKP_BUILD_TOOL_HOOK}" CACHE INTERNAL "") endif() if(DEFINED DKP_BUILD_TOOL_HOOK) include(${DKP_BUILD_TOOL_HOOK}) endif() ================================================ FILE: cmake/common-utils/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=dkp-cmake-common-utils pkgver=1.5.3 pkgrel=1 pkgdesc="Common utilities and infrastructure for devkitPro CMake" arch=('any') url='http://devkitpro.org/' source=( 'dkp-initialize-path.cmake' 'dkp-toolchain-common.cmake' 'dkp-impl-helpers.cmake' 'dkp-rule-overrides.cmake' 'dkp-linker-utils.cmake' 'dkp-custom-target.cmake' 'dkp-embedded-binary.cmake' 'dkp-asset-folder.cmake' 'Generic-dkP.cmake' ) sha256sums=('758b8cc680112d87870f84e8d69abfadc0cbcd1b0987e88329d1fafa7470f9f4' '07e6aba12cc3bbba8ede5e5cf27f0491b1deab221c35a622d0024c3a975044a5' 'b775c77dbc3128885f4db0a04f751ea592d3b8924b8c78e7f246f91b0e5b89b6' 'c52a1b59e132d18f432883ef748db7b2e2b15d9a7c75208e02a01f8d29149392' 'beabc5b2c53de05adbc26b7264080041c84578a76a5783f02d771ac0790f5db2' '0f0ac9a7a92c6dff4975c2204433d4b7515893bc461b3022a135b0ed4728b32d' 'b39f405f459b4e4aa55ad3a04d8d56ba567da2c02425e3b8d60f46bde55d5274' 'f24abd66dea5a2b60be52f1244c4523025828cc9fa71e14cf4c58f24a06007d0' '161873070c09b4ac759f25a9ba5d2ae72194ca66e2d577fd121fb835229536d3') package() { install -d "$pkgdir"/opt/devkitpro/cmake cp "$srcdir"/dkp-initialize-path.cmake "$pkgdir"/opt/devkitpro/cmake cp "$srcdir"/dkp-toolchain-common.cmake "$pkgdir"/opt/devkitpro/cmake cp "$srcdir"/dkp-impl-helpers.cmake "$pkgdir"/opt/devkitpro/cmake cp "$srcdir"/dkp-rule-overrides.cmake "$pkgdir"/opt/devkitpro/cmake cp "$srcdir"/dkp-linker-utils.cmake "$pkgdir"/opt/devkitpro/cmake cp "$srcdir"/dkp-custom-target.cmake "$pkgdir"/opt/devkitpro/cmake cp "$srcdir"/dkp-embedded-binary.cmake "$pkgdir"/opt/devkitpro/cmake cp "$srcdir"/dkp-asset-folder.cmake "$pkgdir"/opt/devkitpro/cmake install -d "$pkgdir"/opt/devkitpro/cmake/Platform cp "$srcdir"/Generic-dkP.cmake "$pkgdir"/opt/devkitpro/cmake/Platform } ================================================ FILE: cmake/common-utils/dkp-asset-folder.cmake ================================================ cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) include(dkp-custom-target) function(dkp_add_asset_target target folder) get_filename_component(folder "${folder}" ABSOLUTE) add_custom_target(${target}) set_target_properties(${target} PROPERTIES DKP_ASSET_FOLDER "${folder}" DKP_ASSET_FILES "" ) endfunction() function(dkp_install_assets target) get_target_property(_dest ${target} DKP_ASSET_FOLDER) if (NOT _dest) message(FATAL_ERROR "dkp_install_assets: ${target} is not a valid asset target") endif() cmake_parse_arguments(PARSE_ARGV 1 ASSET "" "DESTINATION" "TARGETS") if (DEFINED ASSET_DESTINATION) set(_dest "${_dest}/${ASSET_DESTINATION}") endif() if (NOT DEFINED ASSET_TARGETS) message(FATAL_ERROR "dkp_install_assets: must specify at least one target to install") endif() foreach (srctarget IN LISTS ASSET_TARGETS) if (NOT TARGET ${srctarget}) message(FATAL_ERROR "dkp_install_assets: target ${srctarget} not found") endif() if (TARGET ${srctarget}_install_to_${target}) message(WARNING "dkp_install_assets: target ${srctarget} already installed to ${target}, skipping") continue() endif() dkp_resolve_file(_srcfiles ${srctarget} MULTI) set(_destfiles "") set(_installcmds "") foreach(_srcfile IN LISTS _srcfiles) get_filename_component(_name "${_srcfile}" NAME) set(_destfile "${_dest}/${_name}") list(APPEND _destfiles "${_destfile}") list(APPEND _installcmds COMMAND ${CMAKE_COMMAND} -E copy "${_srcfile}" "${_destfile}" ) endforeach() add_custom_command( OUTPUT ${_destfiles} COMMAND ${CMAKE_COMMAND} -E make_directory "${_dest}" ${_installcmds} COMMENT "Installing ${srctarget} to ${target}" DEPENDS ${srctarget} ${_srcfiles} ) add_custom_target(${srctarget}_install_to_${target} DEPENDS ${_destfiles} ) add_dependencies(${target} ${srctarget}_install_to_${target}) set_property(TARGET ${target} APPEND PROPERTY DKP_ASSET_FILES ${_destfiles}) endforeach() endfunction() function(dkp_track_assets target) get_target_property(_dest ${target} DKP_ASSET_FOLDER) if (NOT _dest) message(FATAL_ERROR "dkp_track_assets: ${target} is not a valid asset target") endif() cmake_parse_arguments(PARSE_ARGV 1 ASSET "" "FOLDER" "FILES") if (DEFINED ASSET_FOLDER) set(_dest "${_dest}/${ASSET_FOLDER}") endif() if (NOT DEFINED ASSET_FILES) message(FATAL_ERROR "dkp_track_assets: must provide at least one input file") endif() foreach (file IN LISTS ASSET_FILES) set(file "${_dest}/${file}") if (NOT EXISTS "${file}") message(FATAL_ERROR "dkp_track_assets: file ${file} does not exist") endif() set_property(TARGET ${target} APPEND PROPERTY DKP_ASSET_FILES "${file}") endforeach() endfunction() ================================================ FILE: cmake/common-utils/dkp-custom-target.cmake ================================================ cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) function(dkp_set_target_file target) if (NOT ${ARGC} GREATER 1) message(FATAL_ERROR "dkp_set_target_file: must provide at least one input file") endif() set_target_properties(${target} PROPERTIES DKP_FILE "${ARGN}") endfunction() function(dkp_resolve_file outvar inname) cmake_parse_arguments(PARSE_ARGV 2 ARG "MULTI" "" "") if (TARGET "${inname}") get_target_property(_filename "${inname}" DKP_FILE) if (NOT _filename) message(FATAL_ERROR "dkp_resolve_file: target ${inname} does not have a registered file") endif() list(LENGTH _filename listlen) if(listlen GREATER 1 AND NOT ARG_MULTI) message(FATAL_ERROR "dkp_resolve_file: target ${inname} has more than one registered file") endif() set(${outvar} "${_filename}" PARENT_SCOPE) else() get_filename_component(innameabs "${inname}" ABSOLUTE) if(NOT EXISTS "${innameabs}") message(FATAL_ERROR "dkp_resolve_file: unable to resolve file: ${inname}") endif() set(${outvar} "${innameabs}" PARENT_SCOPE) endif() endfunction() ================================================ FILE: cmake/common-utils/dkp-embedded-binary.cmake ================================================ cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) include(dkp-impl-helpers) include(dkp-custom-target) function(dkp_add_embedded_binary_library target) if (NOT ${ARGC} GREATER 1) message(FATAL_ERROR "dkp_add_embedded_binary_library: must provide at least one input file") endif() if (NOT DKP_BIN2S) message(FATAL_ERROR "Could not find bin2s: try installing general-tools") endif() __dkp_asm_lang(lang dkp_add_embedded_binary_library) set(genfolder "${CMAKE_CURRENT_BINARY_DIR}/.dkp-generated/${target}") set(intermediates "") foreach (inname IN LISTS ARGN) dkp_resolve_file(infiles "${inname}" MULTI) foreach(infile IN LISTS infiles) get_filename_component(basename "${infile}" NAME) string(REPLACE "." "_" basename "${basename}") if (TARGET "${inname}") set(indeps ${inname} ${infile}) else() set(indeps ${infile}) endif() add_custom_command( OUTPUT "${genfolder}/${basename}.S" "${genfolder}/${basename}.h" COMMAND ${CMAKE_COMMAND} -E make_directory "${genfolder}" COMMAND ${DKP_BIN2S} -a ${DKP_BIN2S_ALIGNMENT} -H "${genfolder}/${basename}.h" "${infile}" > "${genfolder}/${basename}.S" DEPENDS ${indeps} COMMENT "Generating binary embedding source for ${inname}" ) list(APPEND intermediates "${genfolder}/${basename}.S" "${genfolder}/${basename}.h") set_source_files_properties("${genfolder}/${basename}.S" PROPERTIES LANGUAGE "${lang}") endforeach() endforeach() add_library(${target} OBJECT ${intermediates}) target_include_directories(${target} INTERFACE "${genfolder}") endfunction() function(dkp_target_use_embedded_binary_libraries target) message(DEPRECATION "dkp_target_use_embedded_binary_libraries is deprecated, please use target_link_libraries(${target} PRIVATE ...) instead") if (NOT ${ARGC} GREATER 1) message(FATAL_ERROR "dkp_target_use_embedded_binary_libraries: must provide at least one input library") endif() target_link_libraries(${target} PRIVATE ${ARGN}) endfunction() ================================================ FILE: cmake/common-utils/dkp-impl-helpers.cmake ================================================ cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) function(__dkp_target_derive_name outvar target suffix) get_target_property(dir ${target} BINARY_DIR) get_target_property(outname ${target} OUTPUT_NAME) if(NOT outname) set(outname "${target}") endif() set(${outvar} "${dir}/${outname}${suffix}" PARENT_SCOPE) endfunction() function(__dkp_asm_lang outvar func) get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) if("ASM" IN_LIST languages) set(${outvar} ASM PARENT_SCOPE) elseif("C" IN_LIST languages) set(${outvar} C PARENT_SCOPE) else() message(FATAL_ERROR "${func}: the ASM language is currently disabled, enable it in project() or with enable_language()") endif() endfunction() ================================================ FILE: cmake/common-utils/dkp-initialize-path.cmake ================================================ cmake_minimum_required(VERSION 3.13) if(CMAKE_HOST_WIN32) message(FATAL_ERROR "CMake must be installed and launched from msys2: pacman -S cmake") endif() if(NOT DEFINED ENV{DEVKITPRO}) set(DEVKITPRO "/opt/devkitpro") else() set(DEVKITPRO "$ENV{DEVKITPRO}") endif() list(APPEND CMAKE_MODULE_PATH "${DEVKITPRO}/cmake") ================================================ FILE: cmake/common-utils/dkp-linker-utils.cmake ================================================ cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) include(dkp-impl-helpers) function(dkp_target_generate_symbol_list target) __dkp_target_derive_name(prefix ${target} "") target_link_options(${target} PRIVATE -Wl,-Map,${prefix}.map ) add_custom_command( TARGET ${target} POST_BUILD COMMAND ${DKP_NM} -CSn $ > ${prefix}.lst BYPRODUCTS ${prefix}.lst ${prefix}.map ) endfunction() ================================================ FILE: cmake/common-utils/dkp-rule-overrides.cmake ================================================ foreach(lang IN ITEMS C CXX ASM) # Set object file extension back to the default for Unix-like platforms set(CMAKE_${lang}_OUTPUT_EXTENSION .o) if(NOT DKP_USE_DOUBLE_OBJECT_FILE_EXTENSIONS) # Disable usage of double object file extensions (.cpp.o -> .o) set(CMAKE_${lang}_OUTPUT_EXTENSION_REPLACE 1) endif() if(NOT DKP_NO_BUILTIN_CMAKE_CONFIGS) # Override CMake's built-in flags for GNU compilers with saner defaults: # - Define DEBUG for Debug (no idea why CMake doesn't do this by default) # - Use -Og for Debug (As per GCC docs: "It is a better choice than -O0 for producing debuggable # code because some compiler passes that collect debug information are disabled at -O0.") # - Use -Oz for MinSizeRel (Os no longer generates the "smallest possible size binaries") # - Use -O2 instead of -O3 for Release (O3 enables aggressive loop unrolling which can be # extremely detrimental to code size, especially for platforms such as GBA/DS) # - Emit debug metadata on all configurations set(CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -Og -DDEBUG") set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -g -Oz -DNDEBUG") set(CMAKE_${lang}_FLAGS_RELEASE_INIT " -g -O2 -DNDEBUG") set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -g -O2 -DNDEBUG") endif() endforeach() ================================================ FILE: cmake/common-utils/dkp-toolchain-common.cmake ================================================ cmake_minimum_required(VERSION 3.13) macro(__dkp_toolchain name arch triplet) set(${name} TRUE) if(NOT CMAKE_SYSTEM_NAME) # Set default platform if none was supplied. set(CMAKE_SYSTEM_NAME Generic-dkP) endif() if(NOT CMAKE_SYSTEM_VERSION) # Usually, this setting is unused in "non-standard" platforms. set(CMAKE_SYSTEM_VERSION 1) endif() if(NOT CMAKE_SYSTEM_PROCESSOR) # Set the correct processor name if no refinement was supplied. set(CMAKE_SYSTEM_PROCESSOR ${arch}) endif() if(NOT CMAKE_USER_MAKE_RULES_OVERRIDE) # Load platform information overrides set(CMAKE_USER_MAKE_RULES_OVERRIDE ${CMAKE_CURRENT_LIST_DIR}/dkp-rule-overrides.cmake) endif() set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES DKP_PLATFORM_BOOTSTRAP) # [CMake 3.15+] Start find_package in config mode set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.16) set(DKP_PREFIX_VAR CMAKE_SYSTEM_PREFIX_PATH) set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) string(REPLACE ":" ";" CMAKE_SYSTEM_PROGRAM_PATH "$ENV{PATH}") else() set(DKP_PREFIX_VAR CMAKE_FIND_ROOT_PATH) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_SYSTEM_INCLUDE_PATH /include) set(CMAKE_SYSTEM_LIBRARY_PATH /lib) set(CMAKE_SYSTEM_PROGRAM_PATH /bin) endif() set(${DKP_PREFIX_VAR} ${DEVKITPRO}/${name} ${DEVKITPRO}/${name}/${triplet} ${DEVKITPRO}/tools ) set(TOOL_HINT ${DEVKITPRO}/${name}/bin) find_program(CMAKE_ASM_COMPILER ${triplet}-gcc HINTS ${TOOL_HINT}) find_program(CMAKE_C_COMPILER ${triplet}-gcc HINTS ${TOOL_HINT}) find_program(CMAKE_CXX_COMPILER ${triplet}-g++ HINTS ${TOOL_HINT}) find_program(CMAKE_LINKER ${triplet}-ld HINTS ${TOOL_HINT}) find_program(CMAKE_AR ${triplet}-gcc-ar HINTS ${TOOL_HINT}) find_program(CMAKE_RANLIB ${triplet}-gcc-ranlib HINTS ${TOOL_HINT}) find_program(CMAKE_STRIP ${triplet}-strip HINTS ${TOOL_HINT}) find_program(DKP_OBJCOPY ${triplet}-objcopy HINTS ${TOOL_HINT}) find_program(DKP_NM ${triplet}-nm HINTS ${TOOL_HINT}) set(TOOL_HINT ${DEVKITPRO}/tools/bin) find_program(DKP_BIN2S NAMES bin2s HINTS ${TOOL_HINT}) endmacro() macro(__dkp_platform_prefix) list(INSERT ${DKP_PREFIX_VAR} 0 ${ARGN}) endmacro() ================================================ FILE: cmake/devkita64/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=devkita64-cmake pkgver=1.1.3 pkgrel=1 pkgdesc="CMake support files for devkitA64" arch=('any') url='http://devkitpro.org/' options=('!strip') source=( 'devkitA64.cmake' 'aarch64-none-elf-cmake' ) depends=('dkp-cmake-common-utils') groups=('switch-dev') package() { install -d "$pkgdir"/opt/devkitpro/devkitA64/bin cp "$srcdir"/aarch64-none-elf-cmake "$pkgdir"/opt/devkitpro/devkitA64/bin/ install -d "$pkgdir"/opt/devkitpro/cmake cp "${srcdir}"/devkitA64.cmake "$pkgdir"/opt/devkitpro/cmake } sha256sums=('f71682d3d6f6aa8ab54c7ec6ee2a5cfc0e5a7cca9724ae7ee55097ee69b6fbc9' '0409bc0eb82c6a7fe164a611a997e26ea3204af2a3eb80d35d445e2e310e692b') ================================================ FILE: cmake/devkita64/aarch64-none-elf-cmake ================================================ #!/usr/bin/env bash set -e exec env CMAKE_TOOLCHAIN_FILE="${DEVKITPRO}/cmake/devkitA64.cmake" cmake "$@" ================================================ FILE: cmake/devkita64/devkitA64.cmake ================================================ include(${CMAKE_CURRENT_LIST_DIR}/dkp-initialize-path.cmake) include(dkp-toolchain-common) set (DKP_BIN2S_ALIGNMENT 8) __dkp_toolchain(devkitA64 aarch64 aarch64-none-elf) ================================================ FILE: cmake/devkitarm/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=devkitarm-cmake pkgver=1.2.4 pkgrel=1 pkgdesc="CMake support files for devkitARM" arch=('any') url='http://devkitpro.org/' source=( 'devkitARM.cmake' 'arm-none-eabi-cmake' 'dkp-arm-mode-wrapper' 'dkp-gba-ds-common.cmake' 'dkp-gba-ds-utils.cmake' ) options=('!strip') groups=('gp32-dev' 'gp2x-dev' 'gba-dev' 'nds-dev' '3ds-dev') depends=('dkp-cmake-common-utils') package() { install -d "$pkgdir"/opt/devkitpro/devkitARM/bin cp "$srcdir"/arm-none-eabi-cmake "$pkgdir"/opt/devkitpro/devkitARM/bin/ install -d "$pkgdir"/opt/devkitpro/cmake cp "${srcdir}"/devkitARM.cmake "$pkgdir"/opt/devkitpro/cmake cp "${srcdir}"/dkp-arm-mode-wrapper "$pkgdir"/opt/devkitpro/cmake cp "${srcdir}"/dkp-gba-ds-common.cmake "$pkgdir"/opt/devkitpro/cmake cp "${srcdir}"/dkp-gba-ds-utils.cmake "$pkgdir"/opt/devkitpro/cmake } sha256sums=('f1029f9a04b2e543e5b49255fe501839dabe7f80e626dca0196531de744704db' '4c3e36904b48e270604c578d77890b3f0a1fa0d49fc2dbb6dddafdb29a3b2a58' 'a49c325d3a02425bfa9898b251232a3f3c5cce11a7edbf9adff9f140b02880b1' '0892748da89275191bba16b747faed6361b4f1fd09d2d3641160b44dc0b3a8e5' '1ef2d30b7dde4ef70164239f2a1feb57fd16c95f1e78f4cf9c3ee0031601001f') ================================================ FILE: cmake/devkitarm/arm-none-eabi-cmake ================================================ #!/usr/bin/env bash set -e exec env CMAKE_TOOLCHAIN_FILE="${DEVKITPRO}/cmake/devkitARM.cmake" cmake "$@" ================================================ FILE: cmake/devkitarm/devkitARM.cmake ================================================ include(${CMAKE_CURRENT_LIST_DIR}/dkp-initialize-path.cmake) include(dkp-toolchain-common) set (DKP_BIN2S_ALIGNMENT 4) __dkp_toolchain(devkitARM arm arm-none-eabi) ================================================ FILE: cmake/devkitarm/dkp-arm-mode-wrapper ================================================ #!/usr/bin/env bash set -e shopt -s extglob args=() argmode="" filemode="" while [[ $# -gt 0 ]]; do case "$1" in -marm|-mthumb) argmode="$1" ;; -*) args+=("$1") ;; *.@(32|arm|iwram|itcm).@(c|m|C|M|c++|cc|cpp|cxx|mm|CPP)) args+=("$1") filemode="-marm" ;; *.@(16|thumb).@(c|m|C|M|c++|cc|cpp|cxx|mm|CPP)) args+=("$1") filemode="-mthumb" ;; *) args+=("$1") ;; esac shift done if [ ! -z "$filemode" ]; then args+=("$filemode") elif [ ! -z "$argmode" ]; then args+=("$argmode") fi exec "${args[@]}" ================================================ FILE: cmake/devkitarm/dkp-gba-ds-common.cmake ================================================ cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES DKP_NO_ARM_MODE_WRAPPER) if(NOT DKP_NO_ARM_MODE_WRAPPER AND NOT CTEST_USE_LAUNCHERS) # Use this "internal" (but documented) global property instead of CMAKE__COMPILER_LAUNCHER # in order to allow users to specify their own compiler wrapper tools. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_CURRENT_LIST_DIR}/dkp-arm-mode-wrapper") endif() find_program(GRIT_EXE NAMES grit HINTS "${DEVKITPRO}/tools/bin") find_program(MMUTIL_EXE NAMES mmutil HINTS "${DEVKITPRO}/tools/bin") ================================================ FILE: cmake/devkitarm/dkp-gba-ds-utils.cmake ================================================ cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) include(dkp-impl-helpers) macro(__grit_parse_options_common) set(GRIT_ARGS -g) set(GRIT_DEPS "") set(GRIT_RENAME_CMDS "") if (NOT GRIT_EXE) message(FATAL_ERROR "Could not find grit: try installing grit") endif() if(GRIT_TEXTURE) set(GRIT_BITMAP TRUE) list(APPEND GRIT_ARGS -gb -gx) elseif(GRIT_BITMAP) list(APPEND GRIT_ARGS -gb) else() list(APPEND GRIT_ARGS -gt) endif() if(NOT DEFINED GRIT_DEPTH) if(GRIT_BITMAP) set(GRIT_DEPTH 8) else() set(GRIT_DEPTH 4) endif() endif() list(APPEND GRIT_ARGS -gB${GRIT_DEPTH}) if(NOT GRIT_BITMAP AND NOT GRIT_NO_MAP) list(APPEND GRIT_ARGS -m) else() set(GRIT_NO_MAP TRUE) list(APPEND GRIT_ARGS -m!) endif() # TODO: handle metatile output if(NOT GRIT_DEPTH EQUAL 16 AND NOT GRIT_NO_PALETTE) list(APPEND GRIT_ARGS -p) else() set(GRIT_NO_PALETTE TRUE) list(APPEND GRIT_ARGS -p!) endif() if(DEFINED GRIT_OPTIONS) list(APPEND GRIT_ARGS ${GRIT_OPTIONS}) endif() endmacro() macro(__grit_output_name var fext) if(DEFINED GRIT_${var}) get_filename_component(GRIT_${var} "${GRIT_${var}}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") else() set(GRIT_${var} "${CMAKE_CURRENT_BINARY_DIR}/${target}.${fext}") endif() endmacro() macro(__grit_rename_cmd from to) list(APPEND GRIT_RENAME_CMDS COMMAND ${CMAKE_COMMAND} -E rename "${from}" "${to}" ) endmacro() function(grit_add_grf_target target input) cmake_parse_arguments(PARSE_ARGV 1 GRIT "BITMAP;TEXTURE;NO_MAP;NO_PALETTE" "OUTPUT;DEPTH" "OPTIONS") __grit_parse_options_common() __grit_output_name(OUTPUT grf) __grit_rename_cmd("~$${target}.grf" "${GRIT_OUTPUT}") get_filename_component(input "${input}" ABSOLUTE) add_custom_command( OUTPUT "${GRIT_OUTPUT}" COMMAND ${GRIT_EXE} "${input}" ${GRIT_ARGS} -ftr -fh! -o "~$${target}.grf" ${GRIT_RENAME_CMDS} DEPENDS "${input}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" COMMENT "Converting graphics to GRF ${target}" VERBATIM ) add_custom_target(${target} DEPENDS "${GRIT_OUTPUT}") dkp_set_target_file(${target} "${GRIT_OUTPUT}") endfunction() macro(grit_add_nds_icon_target target input) grit_add_grf_target(${target} "${input}" NO_MAP DEPTH 4 OPTIONS -pe 16 -gT FF00FF ) endmacro() function(grit_add_binary_target target input) cmake_parse_arguments(PARSE_ARGV 1 GRIT "BITMAP;TEXTURE;NO_MAP;NO_PALETTE" "OUTPUT_GFX;OUTPUT_MAP;OUTPUT_PAL;DEPTH" "OPTIONS") __grit_parse_options_common() __grit_output_name(OUTPUT_GFX gfx) __grit_rename_cmd("~$${target}.img.bin" "${GRIT_OUTPUT_GFX}") set(GRIT_OUTPUTS "${GRIT_OUTPUT_GFX}") if(NOT GRIT_NO_MAP) __grit_output_name(OUTPUT_MAP map) __grit_rename_cmd("~$${target}.map.bin" "${GRIT_OUTPUT_MAP}") list(APPEND GRIT_OUTPUTS "${GRIT_OUTPUT_MAP}") endif() if(NOT GRIT_NO_PALETTE) __grit_output_name(OUTPUT_PAL pal) __grit_rename_cmd("~$${target}.pal.bin" "${GRIT_OUTPUT_PAL}") list(APPEND GRIT_OUTPUTS "${GRIT_OUTPUT_PAL}") endif() get_filename_component(input "${input}" ABSOLUTE) add_custom_command( OUTPUT ${GRIT_OUTPUTS} COMMAND ${GRIT_EXE} "${input}" ${GRIT_ARGS} -ftb -fh! -o "~$${target}.bin" ${GRIT_RENAME_CMDS} DEPENDS "${input}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" COMMENT "Converting graphics to binary ${target}" VERBATIM ) add_custom_target(${target} DEPENDS ${GRIT_OUTPUTS}) dkp_set_target_file(${target} ${GRIT_OUTPUTS}) endfunction() function(mm_add_soundbank_target target) cmake_parse_arguments(PARSE_ARGV 1 MMUTIL "" "OUTPUT;HEADER" "INPUTS;OPTIONS") set(MMUTIL_ARGS "") set(MMUTIL_OUTPUTS "") if (NOT MMUTIL_EXE) message(FATAL_ERROR "Could not find mmutil: try installing mmutil") endif() if(NINTENDO_GBA) # Nothing on purpose elseif(NINTENDO_DS) list(APPEND MMUTIL_ARGS -d) else() message(FATAL_ERROR "mm_add_soundbank_target: only supported on GBA and DS platforms") endif() if(DEFINED MMUTIL_OUTPUT) get_filename_component(MMUTIL_OUTPUT "${MMUTIL_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") else() set(MMUTIL_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}.bin") endif() list(APPEND MMUTIL_OUTPUTS "${MMUTIL_OUTPUT}") if(DEFINED MMUTIL_HEADER) get_filename_component(MMUTIL_HEADER "${MMUTIL_HEADER}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") list(APPEND MMUTIL_ARGS "-h${MMUTIL_HEADER}") list(APPEND MMUTIL_OUTPUTS "${MMUTIL_HEADER}") endif() if(NOT DEFINED MMUTIL_INPUTS) if(DEFINED MMUTIL_UNPARSED_ARGUMENTS) set(MMUTIL_INPUTS "${MMUTIL_UNPARSED_ARGUMENTS}") else() message(FATAL_ERROR "mm_add_soundbank_target: must provide at least one input file") endif() endif() add_custom_command( OUTPUT ${MMUTIL_OUTPUTS} COMMAND "${MMUTIL_EXE}" ${MMUTIL_ARGS} "-o${MMUTIL_OUTPUT}" ${MMUTIL_INPUTS} DEPENDS ${MMUTIL_INPUTS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Building maxmod soundbank ${target}" VERBATIM ) add_custom_target(${target} DEPENDS "${MMUTIL_OUTPUT}") dkp_set_target_file(${target} "${MMUTIL_OUTPUT}") endfunction() ================================================ FILE: cmake/devkitppc/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=devkitppc-cmake pkgver=1.1.4 pkgrel=1 pkgdesc="CMake support files for devkitPPC" arch=('any') url='http://devkitpro.org/' source=( 'devkitPPC.cmake' 'powerpc-eabi-cmake' ) groups=('gamecube-dev' 'wii-dev' 'wiiu-dev') depends=('dkp-cmake-common-utils') package() { install -d "$pkgdir"/opt/devkitpro/devkitPPC/bin cp "$srcdir"/powerpc-eabi-cmake "$pkgdir"/opt/devkitpro/devkitPPC/bin/ install -d "$pkgdir"/opt/devkitpro/cmake cp "${srcdir}"/devkitPPC.cmake "$pkgdir"/opt/devkitpro/cmake } sha256sums=('2bc44f78ca97764627620a2ca91917acbb4bb050ddfe9a8228de7e1ed8e92541' '84a270c9691cf772d9d76db52f9d9f25b981f40ef3630df973954a5d5c8ba9ed') ================================================ FILE: cmake/devkitppc/devkitPPC.cmake ================================================ include(${CMAKE_CURRENT_LIST_DIR}/dkp-initialize-path.cmake) include(dkp-toolchain-common) set (DKP_BIN2S_ALIGNMENT 32) __dkp_toolchain(devkitPPC ppc powerpc-eabi) set(DKP_INSTALL_PREFIX_INIT ${DEVKITPRO}/portlibs/ppc) ================================================ FILE: cmake/devkitppc/powerpc-eabi-cmake ================================================ #!/usr/bin/env bash set -e exec env CMAKE_TOOLCHAIN_FILE="${DEVKITPRO}/cmake/devkitPPC.cmake" cmake "$@" ================================================ FILE: cmake/gamecube/GameCube.cmake ================================================ cmake_minimum_required(VERSION 3.13) if(NOT CMAKE_SYSTEM_NAME) set(CMAKE_SYSTEM_NAME NintendoGameCube) endif() include(${CMAKE_CURRENT_LIST_DIR}/ogc-common.cmake) ================================================ FILE: cmake/gamecube/NintendoGameCube.cmake ================================================ # ----------------------------------------------------------------------------- # Platform configuration cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) # Platform identification flags set(NINTENDO_GAMECUBE TRUE) # Inherit libogc platform configuration include(Platform/libogc) ================================================ FILE: cmake/gamecube/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=gamecube-cmake pkgver=1.0.1 pkgrel=1 pkgdesc="CMake support for Nintendo GameCube" arch=('any') url='http://devkitpro.org/' source=( 'GameCube.cmake' 'NintendoGameCube.cmake' 'powerpc-eabi-cmake' ) options=('!strip') depends=('ogc-cmake' 'gamecube-pkg-config') groups=('gamecube-dev') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/gamecube/bin cp "$srcdir"/powerpc-eabi-cmake "$pkgdir"/opt/devkitpro/portlibs/gamecube/bin/ install -d "$pkgdir"/opt/devkitpro/cmake cp "${srcdir}"/GameCube.cmake "$pkgdir"/opt/devkitpro/cmake install -d "$pkgdir"/opt/devkitpro/cmake/Platform cp "${srcdir}"/NintendoGameCube.cmake "$pkgdir"/opt/devkitpro/cmake/Platform } sha256sums=('ee258d8dc60fc6526116563c755ede223916c883e9a5266270855bcabb9f8c81' '8f05eecc60bdfe6315e05be8cabbf7a5c882ce73e14a4d0efb4bcef4ece69553' '677f93cfda8f5579cd56e0c8bf9f1170c30f72dff4d7712d002ca421d23bdf93') ================================================ FILE: cmake/gamecube/powerpc-eabi-cmake ================================================ #!/usr/bin/env bash set -e exec env CMAKE_TOOLCHAIN_FILE="${DEVKITPRO}/cmake/GameCube.cmake" cmake "$@" ================================================ FILE: cmake/gba/GBA.cmake ================================================ cmake_minimum_required(VERSION 3.13) if(NOT CMAKE_SYSTEM_NAME) set(CMAKE_SYSTEM_NAME NintendoGBA) endif() if(NOT CMAKE_SYSTEM_PROCESSOR) set(CMAKE_SYSTEM_PROCESSOR armv4t) endif() if(NOT DKP_GBA_PLATFORM_LIBRARY) set(DKP_GBA_PLATFORM_LIBRARY libgba) endif() # Import devkitARM toolchain include(${CMAKE_CURRENT_LIST_DIR}/devkitARM.cmake) list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES DKP_GBA_PLATFORM_LIBRARY) if("${DKP_GBA_PLATFORM_LIBRARY}" STREQUAL "libgba") set(GBA_ROOT "${DEVKITPRO}/libgba") elseif("${DKP_GBA_PLATFORM_LIBRARY}" STREQUAL "libtonc") set(GBA_ROOT "${DEVKITPRO}/libtonc") else() message(FATAL_ERROR "Unsupported GBA platform library: '${DKP_GBA_PLATFORM_LIBRARY}'") endif() set(DKP_INSTALL_PREFIX_INIT ${DEVKITPRO}/portlibs/gba) __dkp_platform_prefix( ${DEVKITPRO}/portlibs/gba ${DEVKITPRO}/portlibs/armv4t ${GBA_ROOT} ) find_program(PKG_CONFIG_EXECUTABLE NAMES arm-none-eabi-pkg-config HINTS "${DEVKITPRO}/portlibs/gba/bin") if (NOT PKG_CONFIG_EXECUTABLE) message(FATAL_ERROR "Could not find arm-none-eabi-pkg-config: try installing gba-pkg-config") endif() find_program(GBA_GBAFIX_EXE NAMES gbafix HINTS "${DEVKITPRO}/tools/bin") include(dkp-gba-ds-common) ================================================ FILE: cmake/gba/NintendoGBA.cmake ================================================ # ----------------------------------------------------------------------------- # Platform configuration cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) # Inherit default devkitPro platform configuration include(Platform/Generic-dkP) # Platform identification flags set(NINTENDO_GBA TRUE) # Platform settings set(GBA_STANDARD_INCLUDE_DIRECTORIES "${GBA_ROOT}/include") set(GBA_ARCH_SETTINGS "-march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork") set(GBA_COMMON_FLAGS "-ffunction-sections -fdata-sections -D__GBA__ -DARM7") set(GBA_LINKER_FLAGS "-L${GBA_ROOT}/lib -L${DEVKITPRO}/portlibs/gba/lib -L${DEVKITPRO}/portlibs/armv4t/lib") set(GBA_LINKER_FLAGS_CART "-specs=gba.specs") set(GBA_LINKER_FLAGS_MB "-specs=gba_mb.specs") if("${DKP_GBA_PLATFORM_LIBRARY}" STREQUAL "libgba") set(GBA_STANDARD_LIBRARIES "-lgba") elseif("${DKP_GBA_PLATFORM_LIBRARY}" STREQUAL "libtonc") set(GBA_STANDARD_LIBRARIES "-ltonc") else() message(FATAL_ERROR "Unsupported GBA platform library: '${DKP_GBA_PLATFORM_LIBRARY}'") endif() __dkp_init_platform_settings(GBA) # ----------------------------------------------------------------------------- # Platform-specific helper utilities function(gba_create_rom target) cmake_parse_arguments(PARSE_ARGV 1 GBA "MULTIBOOT;PAD" "OUTPUT;TITLE;GAMECODE;MAKERCODE;VERSION;DEBUG" "") if (NOT GBA_GBAFIX_EXE) message(FATAL_ERROR "Could not find gbafix: try installing gba-tools") endif() if(NOT TARGET "${target}") message(FATAL_ERROR "gba_create_rom: target '${target}' not defined") endif() if(GBA_MULTIBOOT) target_link_options(${target} PRIVATE "${GBA_LINKER_FLAGS_MB}") else() target_link_options(${target} PRIVATE "${GBA_LINKER_FLAGS_CART}") endif() if(DEFINED GBA_OUTPUT) get_filename_component(GBA_OUTPUT "${GBA_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") else() __dkp_target_derive_name(GBA_OUTPUT ${target} ".gba") endif() set(GBA_ARGS "") if(GBA_PAD) list(APPEND GBA_ARGS "-p") endif() if(DEFINED GBA_TITLE) list(APPEND GBA_ARGS "-t${GBA_TITLE}") endif() if(DEFINED GBA_GAMECODE) list(APPEND GBA_ARGS "-c${GBA_GAMECODE}") endif() if(DEFINED GBA_MAKERCODE) list(APPEND GBA_ARGS "-m${GBA_MAKERCODE}") endif() if(DEFINED GBA_VERSION) list(APPEND GBA_ARGS "-v${GBA_VERSION}") endif() if(DEFINED GBA_DEBUG) list(APPEND GBA_ARGS "-d${GBA_DEBUG}") endif() add_custom_command(TARGET ${target} POST_BUILD COMMAND "${CMAKE_OBJCOPY}" -O binary "$" "${GBA_OUTPUT}" COMMAND "${GBA_GBAFIX_EXE}" "${GBA_OUTPUT}" ${GBA_ARGS} BYPRODUCTS "${GBA_OUTPUT}" COMMENT "Building GBA ROM for ${target}" VERBATIM ) dkp_set_target_file(${target} "${GBA_OUTPUT}") endfunction() include(dkp-gba-ds-utils) ================================================ FILE: cmake/gba/PKGBUILD ================================================ # Maintainer: fincs pkgname=gba-cmake pkgver=1.0.2 pkgrel=1 pkgdesc="CMake support for Nintendo GBA" arch=('any') url='https://devkitpro.org/' source=( 'arm-none-eabi-cmake' 'GBA.cmake' 'NintendoGBA.cmake' ) options=('!strip') depends=('devkitarm-cmake' 'gba-tools' 'grit' 'mmutil' 'gba-pkg-config') groups=('gba-dev') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/gba/bin cp "$srcdir"/arm-none-eabi-cmake "$pkgdir"/opt/devkitpro/portlibs/gba/bin/ install -d "$pkgdir"/opt/devkitpro/cmake cp "${srcdir}"/GBA.cmake "$pkgdir"/opt/devkitpro/cmake install -d "$pkgdir"/opt/devkitpro/cmake/Platform cp "${srcdir}"/NintendoGBA.cmake "$pkgdir"/opt/devkitpro/cmake/Platform } sha256sums=('54efe57deaa8f0de5212ad35dab0e2ce045642e86542b62e42b1621dbd567d47' '4f9df4fdb4b443754cb76871ebd46db1b2e3f297703687e9bfd4537531b2572e' '455e29d0a1dc9c45290070d38a68811fda9eddaab05183eb4e834322fc18fd9a') ================================================ FILE: cmake/gba/arm-none-eabi-cmake ================================================ #!/usr/bin/env bash set -e exec env CMAKE_TOOLCHAIN_FILE="${DEVKITPRO}/cmake/GBA.cmake" cmake "$@" ================================================ FILE: cmake/nds/NDS.cmake ================================================ cmake_minimum_required(VERSION 3.13) if(NOT CMAKE_SYSTEM_NAME) set(CMAKE_SYSTEM_NAME NintendoDS) endif() if(NOT CMAKE_SYSTEM_PROCESSOR) set(CMAKE_SYSTEM_PROCESSOR armv5te) endif() # Import devkitARM toolchain include(${CMAKE_CURRENT_LIST_DIR}/devkitARM.cmake) list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES NDS_ARCH_THUMB) set(CALICO_ROOT "${DEVKITPRO}/calico") set(NDS_ROOT "${DEVKITPRO}/libnds") set(DKP_INSTALL_PREFIX_INIT ${DEVKITPRO}/portlibs/nds) __dkp_platform_prefix( ${DEVKITPRO}/portlibs/nds ${DEVKITPRO}/portlibs/${CMAKE_SYSTEM_PROCESSOR} ${DEVKITPRO}/portlibs/armv4t ${NDS_ROOT} ${CALICO_ROOT} ) find_program(PKG_CONFIG_EXECUTABLE NAMES arm-none-eabi-pkg-config HINTS "${DEVKITPRO}/portlibs/nds/bin") if (NOT PKG_CONFIG_EXECUTABLE) message(FATAL_ERROR "Could not find arm-none-eabi-pkg-config: try installing nds-pkg-config") endif() find_program(NDS_NDSTOOL_EXE NAMES ndstool HINTS "${DEVKITPRO}/tools/bin") find_file(NDS_DEFAULT_ICON NAMES nds-icon.bmp HINTS "${CALICO_ROOT}/share" NO_CMAKE_FIND_ROOT_PATH) include(dkp-gba-ds-common) ================================================ FILE: cmake/nds/NintendoDS.cmake ================================================ # ----------------------------------------------------------------------------- # Platform configuration cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) # Inherit default devkitPro platform configuration include(Platform/Generic-dkP) # Platform identification flags set(NINTENDO_DS TRUE) if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv5te") set(ARM9 TRUE) elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv4t") set(ARM7 TRUE) else() message(FATAL_ERROR "Unknown value for CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") endif() set(NDS_LINKER_FLAGS_COMMON "-L${CALICO_ROOT}/lib -L${NDS_ROOT}/lib") set(NDS_LINKER_FLAGS_ARM9 "-specs=${CALICO_ROOT}/share/ds9.specs") set(NDS_LINKER_FLAGS_ARM7 "-specs=${CALICO_ROOT}/share/ds7.specs") set(NDS_STANDARD_LIBRARIES_ARM9 "-lnds9 -lcalico_ds9") set(NDS_STANDARD_LIBRARIES_ARM7 "-lnds7 -lcalico_ds7") # Platform settings set(NDS_STANDARD_INCLUDE_DIRECTORIES "${CALICO_ROOT}/include" "${NDS_ROOT}/include") if(ARM9) set(NDS_ARCH_SETTINGS "-march=armv5te -mtune=arm946e-s") set(NDS_COMMON_FLAGS "-ffunction-sections -fdata-sections -D__NDS__ -DARM9") set(NDS_LINKER_FLAGS "${NDS_LINKER_FLAGS_COMMON} -L${DEVKITPRO}/portlibs/nds/lib ${NDS_LINKER_FLAGS_ARM9}") set(NDS_STANDARD_LIBRARIES "${NDS_STANDARD_LIBRARIES_ARM9}") elseif(ARM7) set(NDS_ARCH_SETTINGS "-march=armv4t -mtune=arm7tdmi") set(NDS_COMMON_FLAGS "-ffunction-sections -fdata-sections -D__NDS__ -DARM7") set(NDS_LINKER_FLAGS "${NDS_LINKER_FLAGS_COMMON} ${NDS_LINKER_FLAGS_ARM7}") set(NDS_STANDARD_LIBRARIES "${NDS_STANDARD_LIBRARIES_ARM7}") endif() if(NOT DEFINED NDS_ARCH_THUMB AND ARM7) set(NDS_ARCH_THUMB TRUE) endif() if(NDS_ARCH_THUMB) string(APPEND NDS_ARCH_SETTINGS " -mthumb") endif() __dkp_init_platform_settings(NDS) # ----------------------------------------------------------------------------- # Platform-specific helper utilities if(ARM9) function(nds_create_rom target) cmake_parse_arguments(PARSE_ARGV 1 NDSTOOL "" "OUTPUT;ARM9;ARM7;NAME;SUBTITLE1;SUBTITLE2;ICON;NITROFS" "FLAGS") if (NOT NDS_NDSTOOL_EXE) message(FATAL_ERROR "Could not find ndstool: try installing ndstool") endif() if(DEFINED NDSTOOL_ARM9) set(intarget "${NDSTOOL_ARM9}") set(outtarget "${target}") else() set(intarget "${target}") set(outtarget "${target}_nds") endif() if(NOT DEFINED NDSTOOL_ARM7) set(NDSTOOL_ARM7_WAS_BLANK TRUE) set(NDSTOOL_ARM7 "maine") endif() if(NOT TARGET "${NDSTOOL_ARM7}" AND NOT IS_ABSOLUTE "${NDSTOOL_ARM7}") set(NDSTOOL_ARM7 "${CALICO_ROOT}/bin/ds7_${NDSTOOL_ARM7}.elf") if(NOT EXISTS "${NDSTOOL_ARM7}") if(NOT NDSTOOL_ARM7_WAS_BLANK) message(FATAL_ERROR "nds_create_rom: could not find default ARM7 component") else() message(FATAL_ERROR "nds_create_rom: ARM7 component must either be a default component name, an imported target or an absolute path") endif() endif() endif() if(NOT TARGET "${intarget}") message(FATAL_ERROR "nds_create_rom: ARM9 target '${intarget}' not defined") endif() if(DEFINED NDSTOOL_OUTPUT) get_filename_component(NDSTOOL_OUTPUT "${NDSTOOL_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") elseif(DEFINED NDSTOOL_ARM9) set(NDSTOOL_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${outtarget}.nds") else() __dkp_target_derive_name(NDSTOOL_OUTPUT ${intarget} ".nds") endif() set(NDSTOOL_ARGS -c "${NDSTOOL_OUTPUT}" -9 "$") set(NDSTOOL_DEPS ${intarget} "${NDSTOOL_ARM7}") if (TARGET "${NDSTOOL_ARM7}") list(APPEND NDSTOOL_ARGS -7 "$") else() list(APPEND NDSTOOL_ARGS -7 "${NDSTOOL_ARM7}") endif() if (NOT DEFINED NDSTOOL_NAME) set(NDSTOOL_NAME "${CMAKE_PROJECT_NAME}") endif() if (NOT DEFINED NDSTOOL_SUBTITLE1) set(NDSTOOL_SUBTITLE1 "Built with devkitARM") endif() if (NOT DEFINED NDSTOOL_SUBTITLE2) set(NDSTOOL_SUBTITLE2 "https://devkitpro.org") endif() if (NOT DEFINED NDSTOOL_ICON) if(NOT NDS_DEFAULT_ICON) message(FATAL_ERROR "nds_create_rom: could not find default icon, try installing libnds") endif() set(NDSTOOL_ICON "${NDS_DEFAULT_ICON}") else() if(TARGET "${NDSTOOL_ICON}") list(APPEND NDSTOOL_DEPS ${NDSTOOL_ICON}) endif() dkp_resolve_file(NDSTOOL_ICON "${NDSTOOL_ICON}") endif() list(APPEND NDSTOOL_ARGS -b "${NDSTOOL_ICON}" "${NDSTOOL_NAME}\;${NDSTOOL_SUBTITLE1}\;${NDSTOOL_SUBTITLE2}") list(APPEND NDSTOOL_DEPS "${NDSTOOL_ICON}") if (DEFINED NDSTOOL_NITROFS) if (TARGET "${NDSTOOL_NITROFS}") get_target_property(_folder "${NDSTOOL_NITROFS}" DKP_ASSET_FOLDER) if (NOT _folder) message(FATAL_ERROR "nds_create_rom: not a valid asset target") endif() list(APPEND NDSTOOL_ARGS -d "${_folder}") list(APPEND NDSTOOL_DEPS ${NDSTOOL_NITROFS} $) else() get_filename_component(NDSTOOL_NITROFS "${NDSTOOL_NITROFS}" ABSOLUTE) if (NOT IS_DIRECTORY "${NDSTOOL_NITROFS}") message(FATAL_ERROR "nds_create_rom: cannot find nitrofs dir: ${NDSTOOL_NITROFS}") endif() list(APPEND NDSTOOL_ARGS -d "${NDSTOOL_NITROFS}") endif() endif() if (DEFINED NDSTOOL_FLAGS) list(APPEND NDSTOOL_ARGS ${NDSTOOL_FLAGS}) endif() add_custom_command( OUTPUT "${NDSTOOL_OUTPUT}" COMMAND "${NDS_NDSTOOL_EXE}" ${NDSTOOL_ARGS} DEPENDS ${NDSTOOL_DEPS} COMMENT "Building NDS ROM target ${outtarget}" VERBATIM ) add_custom_target(${outtarget} ALL DEPENDS "${NDSTOOL_OUTPUT}") dkp_set_target_file(${outtarget} "${NDSTOOL_OUTPUT}") endfunction() endif() include(dkp-gba-ds-utils) ================================================ FILE: cmake/nds/PKGBUILD ================================================ # Contributor: Cameron Cawley pkgname=nds-cmake pkgver=1.3.1 pkgrel=1 pkgdesc="CMake support for Nintendo DS" arch=('any') url='https://devkitpro.org/' source=( 'arm-none-eabi-cmake' 'NDS.cmake' 'NintendoDS.cmake' ) options=('!strip') depends=('devkitarm-cmake' 'ndstool' 'grit' 'mmutil' 'nds-pkg-config') groups=('nds-dev') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/nds/bin cp "$srcdir"/arm-none-eabi-cmake "$pkgdir"/opt/devkitpro/portlibs/nds/bin/ install -d "$pkgdir"/opt/devkitpro/cmake cp "${srcdir}"/NDS.cmake "$pkgdir"/opt/devkitpro/cmake install -d "$pkgdir"/opt/devkitpro/cmake/Platform cp "${srcdir}"/NintendoDS.cmake "$pkgdir"/opt/devkitpro/cmake/Platform } sha256sums=('a3b1973c2a9e04047a568132f276de4e0b0669d28a7253c5ce064cb8017fc5c0' '718c74ee919c786e58f82d5a7f450eda6b18bf09cff526645db118fa160932c3' '416718d0693459863ff8c87e6040f8857bd3c8e5a980a3ce5f89e297591330eb') ================================================ FILE: cmake/nds/arm-none-eabi-cmake ================================================ #!/usr/bin/env bash set -e exec env CMAKE_TOOLCHAIN_FILE="${DEVKITPRO}/cmake/NDS.cmake" cmake "$@" ================================================ FILE: cmake/ogc/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=ogc-cmake pkgver=1.3.0 pkgrel=1 pkgdesc="CMake support for Nintendo GameCube and Wii" arch=('any') url='http://devkitpro.org/' source=( 'libogc.cmake' 'ogc-common.cmake' ) options=('!strip') depends=('devkitppc-cmake' 'gamecube-tools') groups=('wii-dev' 'gamecube-dev') sha256sums=('c803de37a9a220f9d9a368503e2a23642350c3070757c262764d8c33db0bf3c1' '2c8f97667ec4f5acd0fed5d0398a436eac1a397620a30a91d6fef823b7b616ef') package() { install -d "$pkgdir"/opt/devkitpro/cmake cp "${srcdir}"/ogc-common.cmake "$pkgdir"/opt/devkitpro/cmake install -d "$pkgdir"/opt/devkitpro/cmake/Platform cp "${srcdir}"/libogc.cmake "$pkgdir"/opt/devkitpro/cmake/Platform } ================================================ FILE: cmake/ogc/libogc.cmake ================================================ # ----------------------------------------------------------------------------- # Platform configuration cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) # Inherit default devkitPro platform configuration include(Platform/Generic-dkP) # Platform settings set(OGC_ARCH_SETTINGS "-m${OGC_MACHINE} -mcpu=750 -meabi -mhard-float") set(OGC_COMMON_FLAGS "-ffunction-sections -fdata-sections -D__${OGC_CONSOLE}__ -DGEKKO") set(OGC_LINKER_FLAGS "-L${OGC_ROOT}/lib/${OGC_SUBDIR} -L${DEVKITPRO}/portlibs/${OGC_CONSOLE}/lib -L${DEVKITPRO}/portlibs/ppc/lib") set(OGC_STANDARD_LIBRARIES "${OGC_EXTRA_LIBS} -logc -lm") set(OGC_STANDARD_INCLUDE_DIRECTORIES "${OGC_ROOT}/include") __dkp_init_platform_settings(OGC) set(CMAKE_ASM_FLAGS_INIT "${CMAKE_ASM_FLAGS_INIT} -mregnames") # ----------------------------------------------------------------------------- # Platform-specific helper utilities function(ogc_create_dol target) if (NOT ELF2DOL_EXE) message(FATAL_ERROR "Could not find elf2dol: try installing gamecube-tools") endif() __dkp_target_derive_name(DOL_OUTPUT ${target} ".dol") add_custom_command(TARGET ${target} POST_BUILD COMMAND "${ELF2DOL_EXE}" "$" "${DOL_OUTPUT}" BYPRODUCTS "${DOL_OUTPUT}" COMMENT "Converting ${target} to .dol format" VERBATIM ) dkp_set_target_file(${target} "${DOL_OUTPUT}") endfunction() function(ogc_add_dsp_binary target infile) if (NOT GCDSPTOOL_EXE) message(FATAL_ERROR "Could not find gcdsptool: try installing gamecube-tools") endif() cmake_parse_arguments(PARSE_ARGV 1 DSP "" "OUTPUT" "") if(DEFINED DSP_OUTPUT) get_filename_component(DSP_OUTPUT "${DSP_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") else() set(DSP_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}.bin") endif() add_custom_command( OUTPUT ${DSP_OUTPUT} COMMAND "${GCDSPTOOL_EXE}" -c ${infile} -o ${DSP_OUTPUT} DEPENDS ${infile} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Building DSP binary ${target}" VERBATIM ) add_custom_target(${target} DEPENDS "${DSP_OUTPUT}") dkp_set_target_file(${target} "${DSP_OUTPUT}") endfunction() ================================================ FILE: cmake/ogc/ogc-common.cmake ================================================ cmake_minimum_required(VERSION 3.13) if("${CMAKE_SYSTEM_NAME}" STREQUAL "NintendoWii") set(OGC_CONSOLE wii) set(OGC_SUBDIR wii) set(OGC_MACHINE rvl) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "NintendoGameCube") set(OGC_CONSOLE gamecube) set(OGC_SUBDIR cube) set(OGC_MACHINE ogc) else() message(FATAL_ERROR "Unsupported libogc platform") endif() # Import devkitPPC toolchain include(${CMAKE_CURRENT_LIST_DIR}/devkitPPC.cmake) set(OGC_ROOT ${DEVKITPRO}/libogc) set(DKP_INSTALL_PREFIX_INIT ${DEVKITPRO}/portlibs/${OGC_CONSOLE}) __dkp_platform_prefix( ${DEVKITPRO}/portlibs/${OGC_CONSOLE} ${DEVKITPRO}/portlibs/ppc ${OGC_ROOT} ) find_program(PKG_CONFIG_EXECUTABLE NAMES powerpc-eabi-pkg-config HINTS "${DEVKITPRO}/portlibs/${OGC_CONSOLE}/bin") if (NOT PKG_CONFIG_EXECUTABLE) message(FATAL_ERROR "Could not find powerpc-eabi-pkg-config: try installing ${OGC_CONSOLE}-pkg-config") endif() find_program(ELF2DOL_EXE NAMES elf2dol HINTS "${DEVKITPRO}/tools/bin") find_program(GCDSPTOOL_EXE NAMES gcdsptool HINTS "${DEVKITPRO}/tools/bin") find_program(GXTEXCONV_EXE NAMES gxtexconv HINTS "${DEVKITPRO}/tools/bin") ================================================ FILE: cmake/switch/NintendoSwitch.cmake ================================================ # ----------------------------------------------------------------------------- # Platform configuration cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) # Inherit default devkitPro platform configuration include(Platform/Generic-dkP) # Platform identification flags set(NINTENDO_SWITCH TRUE) # Platform settings set(NX_ARCH_SETTINGS "-march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -ftls-model=local-exec") set(NX_COMMON_FLAGS "-ffunction-sections -fdata-sections -D__SWITCH__") set(NX_LINKER_FLAGS "-L${NX_ROOT}/lib -L${DEVKITPRO}/portlibs/switch/lib -fPIE -specs=${NX_ROOT}/switch.specs") set(NX_STANDARD_LIBRARIES "-lnx -lm") set(NX_STANDARD_INCLUDE_DIRECTORIES "${NX_ROOT}/include") # Enable position-independent code set(CMAKE_POSITION_INDEPENDENT_CODE ON) __dkp_init_platform_settings(NX) # ----------------------------------------------------------------------------- # Platform-specific helper utilities function(nx_generate_nacp) cmake_parse_arguments(PARSE_ARGV 0 NACP "" "OUTPUT;NAME;AUTHOR;VERSION" "") if (NOT NX_NACPTOOL_EXE) message(FATAL_ERROR "Could not find nacptool: try installing switch-tools") endif() if (NOT DEFINED NACP_OUTPUT) if(DEFINED NACP_UNPARSED_ARGUMENTS) list(GET NACP_UNPARSED_ARGUMENTS 0 NACP_OUTPUT) else() message(FATAL_ERROR "nx_generate_nacp: missing OUTPUT argument") endif() endif() if (NOT DEFINED NACP_NAME) set(NACP_NAME "${CMAKE_PROJECT_NAME}") endif() if (NOT DEFINED NACP_AUTHOR) set(NACP_AUTHOR "Unspecified Author") endif() if (NOT DEFINED NACP_VERSION) if (PROJECT_VERSION) set(NACP_VERSION "${PROJECT_VERSION}") else() set(NACP_VERSION "1.0.0") endif() endif() get_filename_component(NACP_OUTPUT "${NACP_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") add_custom_command( OUTPUT "${NACP_OUTPUT}" COMMAND "${NX_NACPTOOL_EXE}" --create "${NACP_NAME}" "${NACP_AUTHOR}" "${NACP_VERSION}" "${NACP_OUTPUT}" VERBATIM ) endfunction() function(nx_create_nro target) cmake_parse_arguments(PARSE_ARGV 1 ELF2NRO "NOICON;NONACP" "TARGET;OUTPUT;ICON;NACP;ROMFS" "") if (NOT NX_ELF2NRO_EXE) message(FATAL_ERROR "Could not find elf2nro: try installing switch-tools") endif() if(DEFINED ELF2NRO_TARGET) set(intarget "${ELF2NRO_TARGET}") set(outtarget "${target}") else() set(intarget "${target}") set(outtarget "${target}_nro") endif() if(NOT TARGET "${intarget}") message(FATAL_ERROR "nx_create_nro: target '${intarget}' not defined") endif() if(DEFINED ELF2NRO_OUTPUT) get_filename_component(ELF2NRO_OUTPUT "${ELF2NRO_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") elseif(DEFINED ELF2NRO_TARGET) set(ELF2NRO_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${outtarget}.nro") else() __dkp_target_derive_name(ELF2NRO_OUTPUT ${intarget} ".nro") endif() set(ELF2NRO_ARGS "$" "${ELF2NRO_OUTPUT}") set(ELF2NRO_DEPS ${intarget}) if (DEFINED ELF2NRO_ICON AND ELF2NRO_NOICON) message(FATAL_ERROR "nx_create_nro: cannot specify ICON and NOICON at the same time") endif() if (DEFINED ELF2NRO_NACP AND ELF2NRO_NONACP) message(FATAL_ERROR "nx_create_nro: cannot specify NACP and NONACP at the same time") endif() if (NOT DEFINED ELF2NRO_ICON AND NOT ELF2NRO_NOICON) if(NOT NX_DEFAULT_ICON) message(FATAL_ERROR "nx_create_nro: could not find default icon, try installing libnx") endif() set(ELF2NRO_ICON "${NX_DEFAULT_ICON}") endif() if (NOT DEFINED ELF2NRO_NACP AND NOT ELF2NRO_NONACP) set(ELF2NRO_NACP "${CMAKE_CURRENT_BINARY_DIR}/${outtarget}.default.nacp") nx_generate_nacp(OUTPUT "${ELF2NRO_NACP}") endif() if (DEFINED ELF2NRO_ICON) get_filename_component(ELF2NRO_ICON "${ELF2NRO_ICON}" ABSOLUTE) list(APPEND ELF2NRO_ARGS "--icon=${ELF2NRO_ICON}") list(APPEND ELF2NRO_DEPS "${ELF2NRO_ICON}") endif() if (DEFINED ELF2NRO_NACP) get_filename_component(ELF2NRO_NACP "${ELF2NRO_NACP}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") list(APPEND ELF2NRO_ARGS "--nacp=${ELF2NRO_NACP}") list(APPEND ELF2NRO_DEPS "${ELF2NRO_NACP}") endif() if (DEFINED ELF2NRO_ROMFS) if (TARGET "${ELF2NRO_ROMFS}") get_target_property(_folder "${ELF2NRO_ROMFS}" DKP_ASSET_FOLDER) if (NOT _folder) message(FATAL_ERROR "nx_create_nro: not a valid asset target") endif() list(APPEND ELF2NRO_ARGS "--romfsdir=${_folder}") list(APPEND ELF2NRO_DEPS ${ELF2NRO_ROMFS} $) else() get_filename_component(ELF2NRO_ROMFS "${ELF2NRO_ROMFS}" ABSOLUTE) if (NOT IS_DIRECTORY "${ELF2NRO_ROMFS}") message(FATAL_ERROR "nx_create_nro: cannot find romfs dir: ${ELF2NRO_ROMFS}") endif() list(APPEND ELF2NRO_ARGS "--romfsdir=${ELF2NRO_ROMFS}") endif() endif() add_custom_command( OUTPUT "${ELF2NRO_OUTPUT}" COMMAND "${NX_ELF2NRO_EXE}" ${ELF2NRO_ARGS} DEPENDS ${ELF2NRO_DEPS} COMMENT "Building NRO executable target ${outtarget}" VERBATIM ) add_custom_target(${outtarget} ALL DEPENDS "${ELF2NRO_OUTPUT}") dkp_set_target_file(${outtarget} "${ELF2NRO_OUTPUT}") endfunction() function(nx_create_exefs target) cmake_parse_arguments(PARSE_ARGV 1 NX_EXEFS "" "TARGET;OUTPUT;CONFIG" "") if (NOT NX_ELF2NSO_EXE) message(FATAL_ERROR "Could not find elf2nso: try installing switch-tools") endif() if (NOT NX_NPDMTOOL_EXE) message(FATAL_ERROR "Could not find npdmtool: try installing switch-tools") endif() if (NOT NX_BUILD_PFS0_EXE) message(FATAL_ERROR "Could not find build_pfs0: try installing switch-tools") endif() if(DEFINED NX_EXEFS_TARGET) set(intarget "${NX_EXEFS_TARGET}") set(outtarget "${target}") else() set(intarget "${target}") set(outtarget "${target}_nsp") endif() if(NOT TARGET "${intarget}") message(FATAL_ERROR "nx_create_exefs: target '${intarget}' not defined") endif() if(DEFINED NX_EXEFS_OUTPUT) get_filename_component(NX_EXEFS_OUTPUT "${NX_EXEFS_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") elseif(DEFINED NX_EXEFS_TARGET) set(NX_EXEFS_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${outtarget}.nsp") else() __dkp_target_derive_name(NX_EXEFS_OUTPUT ${intarget} ".nsp") endif() if(DEFINED NX_EXEFS_CONFIG) get_filename_component(NX_EXEFS_CONFIG "${NX_EXEFS_CONFIG}" ABSOLUTE) else() message(FATAL_ERROR "nx_create_exefs: must provide a CONFIG file in json format") endif() set(NX_EXEFS_TEMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/.dkp-generated/${outtarget}") set(NX_EXEFS_MAIN "${NX_EXEFS_TEMP_DIR}/main") set(NX_EXEFS_NPDM "${NX_EXEFS_TEMP_DIR}/main.npdm") add_custom_command( OUTPUT "${NX_EXEFS_MAIN}" COMMAND ${CMAKE_COMMAND} -E make_directory "${NX_EXEFS_TEMP_DIR}" COMMAND ${NX_ELF2NSO_EXE} "$" "${NX_EXEFS_MAIN}" DEPENDS ${intarget} COMMENT "Converting ${intarget} to NSO format" VERBATIM ) add_custom_command( OUTPUT "${NX_EXEFS_NPDM}" COMMAND ${CMAKE_COMMAND} -E make_directory "${NX_EXEFS_TEMP_DIR}" COMMAND ${NX_NPDMTOOL_EXE} "${NX_EXEFS_CONFIG}" "${NX_EXEFS_NPDM}" DEPENDS "${NX_EXEFS_CONFIG}" COMMENT "Generating NPDM for ${outtarget}" VERBATIM ) add_custom_command( OUTPUT "${NX_EXEFS_OUTPUT}" COMMAND ${NX_BUILD_PFS0_EXE} "${NX_EXEFS_TEMP_DIR}" "${NX_EXEFS_OUTPUT}" DEPENDS "${NX_EXEFS_MAIN}" "${NX_EXEFS_NPDM}" COMMENT "Building ExeFS target ${outtarget}" VERBATIM ) add_custom_target(${outtarget} ALL DEPENDS "${NX_EXEFS_OUTPUT}") dkp_set_target_file(${outtarget} "${NX_EXEFS_OUTPUT}") endfunction() function(nx_create_kip target) cmake_parse_arguments(PARSE_ARGV 1 NX_ELF2KIP "" "TARGET;OUTPUT;CONFIG" "") if (NOT NX_ELF2KIP_EXE) message(FATAL_ERROR "Could not find elf2kip: try installing switch-tools") endif() if(DEFINED NX_ELF2KIP_TARGET) set(intarget "${NX_ELF2KIP_TARGET}") set(outtarget "${target}") else() set(intarget "${target}") set(outtarget "${target}_kip") endif() if(NOT TARGET "${intarget}") message(FATAL_ERROR "nx_create_kip: target '${intarget}' not defined") endif() if(DEFINED NX_ELF2KIP_OUTPUT) get_filename_component(NX_ELF2KIP_OUTPUT "${NX_ELF2KIP_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") elseif(DEFINED NX_ELF2KIP_TARGET) set(NX_ELF2KIP_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${outtarget}.kip") else() __dkp_target_derive_name(NX_ELF2KIP_OUTPUT ${intarget} ".kip") endif() if(DEFINED NX_ELF2KIP_CONFIG) get_filename_component(NX_ELF2KIP_CONFIG "${NX_ELF2KIP_CONFIG}" ABSOLUTE) else() message(FATAL_ERROR "nx_create_kip: must provide a CONFIG file in json format") endif() add_custom_command( OUTPUT "${NX_ELF2KIP_OUTPUT}" COMMAND ${NX_ELF2KIP_EXE} "$" "${NX_ELF2KIP_CONFIG}" "${NX_ELF2KIP_OUTPUT}" DEPENDS ${intarget} "${NX_ELF2KIP_CONFIG}" COMMENT "Building KIP target ${outtarget}" VERBATIM ) add_custom_target(${outtarget} ALL DEPENDS "${NX_ELF2KIP_OUTPUT}") dkp_set_target_file(${outtarget} "${NX_ELF2KIP_OUTPUT}") endfunction() function(nx_add_shader_program target source type) cmake_parse_arguments(PARSE_ARGV 3 NX_UAM "" "OUTPUT" "") if (NOT NX_UAM_EXE) message(FATAL_ERROR "Could not find uam: try installing uam") endif() if(DEFINED NX_UAM_OUTPUT) get_filename_component(NX_UAM_OUTPUT "${NX_UAM_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") else() set(NX_UAM_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}.dksh") endif() get_filename_component(source "${source}" ABSOLUTE) add_custom_command( OUTPUT "${NX_UAM_OUTPUT}" COMMAND "${NX_UAM_EXE}" -o "${NX_UAM_OUTPUT}" -s ${type} "${source}" DEPENDS "${source}" COMMENT "Building shader program ${target}" VERBATIM ) add_custom_target(${target} DEPENDS "${NX_UAM_OUTPUT}") dkp_set_target_file(${target} "${NX_UAM_OUTPUT}") endfunction() ================================================ FILE: cmake/switch/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=switch-cmake pkgver=1.5.2 pkgrel=1 pkgdesc="CMake support for Nintendo Switch" arch=('any') url='https://devkitpro.org/' source=( 'aarch64-none-elf-cmake' 'Switch.cmake' 'NintendoSwitch.cmake' ) depends=('devkita64-cmake' 'switch-tools' 'uam' 'switch-pkg-config') groups=('switch-dev') options=('!strip') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/switch/bin cp "$srcdir"/aarch64-none-elf-cmake "$pkgdir"/opt/devkitpro/portlibs/switch/bin/ install -d "$pkgdir"/opt/devkitpro/cmake cp "${srcdir}"/Switch.cmake "$pkgdir"/opt/devkitpro/cmake install -d "$pkgdir"/opt/devkitpro/cmake/Platform cp "${srcdir}"/NintendoSwitch.cmake "$pkgdir"/opt/devkitpro/cmake/Platform } sha256sums=('c6e861e5d12da69638e1fae7eb8b48e9632371fe34c3c37920a6aa178fab53df' 'c73bb5a328f33ff210228dd93d1257c88bc96722fd16b2dc0702aa57e962ebb0' 'db6cbc7f3e9bfcbe45f9745a9a5b9ed8ac54b358a7ac4c491f6850c6e3ee8287') ================================================ FILE: cmake/switch/Switch.cmake ================================================ cmake_minimum_required(VERSION 3.13) if(NOT CMAKE_SYSTEM_NAME) set(CMAKE_SYSTEM_NAME NintendoSwitch) endif() # Import devkitA64 toolchain include(${CMAKE_CURRENT_LIST_DIR}/devkitA64.cmake) set(NX_ROOT ${DEVKITPRO}/libnx) set(DKP_INSTALL_PREFIX_INIT ${DEVKITPRO}/portlibs/switch) __dkp_platform_prefix( ${DEVKITPRO}/portlibs/switch ${NX_ROOT} ) find_program(PKG_CONFIG_EXECUTABLE NAMES aarch64-none-elf-pkg-config HINTS "${DEVKITPRO}/portlibs/switch/bin") if (NOT PKG_CONFIG_EXECUTABLE) message(FATAL_ERROR "Could not find aarch64-none-elf-pkg-config: try installing switch-pkg-config") endif() find_program(NX_ELF2NRO_EXE NAMES elf2nro HINTS "${DEVKITPRO}/tools/bin") find_program(NX_ELF2KIP_EXE NAMES elf2kip HINTS "${DEVKITPRO}/tools/bin") find_program(NX_ELF2NSO_EXE NAMES elf2nso HINTS "${DEVKITPRO}/tools/bin") find_program(NX_BUILD_PFS0_EXE NAMES build_pfs0 HINTS "${DEVKITPRO}/tools/bin") find_program(NX_NACPTOOL_EXE NAMES nacptool HINTS "${DEVKITPRO}/tools/bin") find_program(NX_NPDMTOOL_EXE NAMES npdmtool HINTS "${DEVKITPRO}/tools/bin") find_program(NX_UAM_EXE NAMES uam HINTS "${DEVKITPRO}/tools/bin") find_file(NX_DEFAULT_ICON NAMES default_icon.jpg HINTS "${NX_ROOT}" NO_CMAKE_FIND_ROOT_PATH) ================================================ FILE: cmake/switch/aarch64-none-elf-cmake ================================================ #!/usr/bin/env bash set -e exec env CMAKE_TOOLCHAIN_FILE="${DEVKITPRO}/cmake/Switch.cmake" cmake "$@" ================================================ FILE: cmake/wii/NintendoWii.cmake ================================================ # ----------------------------------------------------------------------------- # Platform configuration cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) # Platform identification flags set(NINTENDO_WII TRUE) set(OGC_EXTRA_LIBS "-lwiiuse -lbte") # Inherit libogc platform configuration include(Platform/libogc) ================================================ FILE: cmake/wii/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=wii-cmake pkgver=1.0.1 pkgrel=1 pkgdesc="CMake support for Nintendo Wii" arch=('any') url='http://devkitpro.org/' source=( 'Wii.cmake' 'NintendoWii.cmake' 'powerpc-eabi-cmake' ) options=('!strip') depends=('ogc-cmake' 'wii-pkg-config') groups=('wii-dev') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/wii/bin cp "$srcdir"/powerpc-eabi-cmake "$pkgdir"/opt/devkitpro/portlibs/wii/bin/ install -d "$pkgdir"/opt/devkitpro/cmake cp "${srcdir}"/Wii.cmake "$pkgdir"/opt/devkitpro/cmake install -d "$pkgdir"/opt/devkitpro/cmake/Platform cp "${srcdir}"/NintendoWii.cmake "$pkgdir"/opt/devkitpro/cmake/Platform } sha256sums=('f9b17b4f5c3be859e5f9b6fa459049fbffbe7ea8c0a42a923de6323e3b797b02' 'e7b633ac937e2b790b948de11877c09c7f1c0d4d2531a2adfb418b8753e81e85' '987bbd468d13056cea0a8cd6eab2c23050f9decd05bc5962f6c4e5fa8b0c569a') ================================================ FILE: cmake/wii/Wii.cmake ================================================ cmake_minimum_required(VERSION 3.13) if(NOT CMAKE_SYSTEM_NAME) set(CMAKE_SYSTEM_NAME NintendoWii) endif() include(${CMAKE_CURRENT_LIST_DIR}/ogc-common.cmake) ================================================ FILE: cmake/wii/powerpc-eabi-cmake ================================================ #!/usr/bin/env bash set -e exec env CMAKE_TOOLCHAIN_FILE="${DEVKITPRO}/cmake/Wii.cmake" cmake "$@" ================================================ FILE: cmake/wiiu/CafeOS.cmake ================================================ # ----------------------------------------------------------------------------- # Platform configuration cmake_minimum_required(VERSION 3.13) include_guard(GLOBAL) # Inherit default devkitPro platform configuration include(Platform/Generic-dkP) # Platform identification flags set(CAFEOS TRUE) set(NINTENDO_WIIU TRUE) set(WIIU TRUE) set(WUT TRUE) # Platform settings set(WUT_ARCH_SETTINGS "-mcpu=750 -meabi -mhard-float") set(WUT_COMMON_FLAGS "-ffunction-sections -fdata-sections -DESPRESSO -D__WIIU__ -D__WUT__") set(WUT_LINKER_FLAGS "-L${WUT_ROOT}/lib -L${DEVKITPRO}/portlibs/wiiu/lib -L${DEVKITPRO}/portlibs/ppc/lib -specs=${WUT_ROOT}/share/wut.specs") set(WUT_STANDARD_LIBRARIES "-lwut -lm") set(WUT_STANDARD_INCLUDE_DIRECTORIES "${WUT_ROOT}/include") __dkp_init_platform_settings(WUT) # ----------------------------------------------------------------------------- # Platform-specific helper utilities function(wut_create_rpl target) cmake_parse_arguments(PARSE_ARGV 1 ELF2RPL "IS_RPX" "" "") if (NOT WUT_ELF2RPL_EXE) message(FATAL_ERROR "Could not find elf2rpl: try installing wut-tools") endif() set(ELF2RPL_FLAGS "") if(ELF2RPL_IS_RPX) # Do nothing - the defaults are good for RPX set(RPL_SUFFIX ".rpx") else() set(RPL_SUFFIX ".rpl") list(APPEND ELF2RPL_FLAGS "--rpl") target_link_options(${target} PRIVATE "-specs=${WUT_ROOT}/share/rpl.specs") endif() __dkp_target_derive_name(RPL_OUTPUT ${target} "${RPL_SUFFIX}") add_custom_command(TARGET ${target} POST_BUILD COMMAND ${WUT_ELF2RPL_EXE} ${ELF2RPL_FLAGS} "$" "${RPL_OUTPUT}" BYPRODUCTS "${RPL_OUTPUT}" COMMENT "Converting ${target} to ${RPL_SUFFIX} format" VERBATIM ) set_target_properties(${target} PROPERTIES WUT_RPL "${RPL_OUTPUT}") if(ELF2RPL_IS_RPX) set_target_properties(${target} PROPERTIES WUT_IS_RPX TRUE) endif() endfunction() function(wut_create_rpx) wut_create_rpl(${ARGV} IS_RPX) endfunction() function(wut_create_wuhb target) cmake_parse_arguments(PARSE_ARGV 1 WUHBTOOL "" "TARGET;OUTPUT;CONTENT;NAME;SHORTNAME;AUTHOR;ICON;TVSPLASH;DRCSPLASH" "") if (NOT WUT_WUHBTOOL_EXE) message(FATAL_ERROR "Could not find wuhbtool: try installing wut-tools") endif() if(DEFINED WUHBTOOL_TARGET) set(intarget "${WUHBTOOL_TARGET}") set(outtarget "${target}") else() set(intarget "${target}") set(outtarget "${target}_wuhb") endif() if(NOT TARGET "${intarget}") message(FATAL_ERROR "wut_create_wuhb: target '${intarget}' not defined") endif() get_target_property(RPL_PATH ${intarget} WUT_RPL) get_target_property(RPL_IS_RPX ${intarget} WUT_IS_RPX) if(NOT RPL_IS_RPX OR NOT RPL_PATH) message(FATAL_ERROR "wut_create_wuhb: target must be a valid .rpx (use wut_create_rpx)") endif() if(DEFINED WUHBTOOL_OUTPUT) get_filename_component(WUHBTOOL_OUTPUT "${WUHBTOOL_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") elseif(DEFINED WUHBTOOL_TARGET) set(WUHBTOOL_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${outtarget}.wuhb") else() __dkp_target_derive_name(WUHBTOOL_OUTPUT ${intarget} ".wuhb") endif() set(WUHBTOOL_ARGS "${RPL_PATH}" "${WUHBTOOL_OUTPUT}") set(WUHBTOOL_DEPS ${intarget}) if(DEFINED WUHBTOOL_CONTENT) if (TARGET "${WUHBTOOL_CONTENT}") get_target_property(_folder "${WUHBTOOL_CONTENT}" DKP_ASSET_FOLDER) if (NOT _folder) message(FATAL_ERROR "wut_create_wuhb: not a valid asset target") endif() list(APPEND WUHBTOOL_ARGS "--content=${_folder}") list(APPEND WUHBTOOL_DEPS ${WUHBTOOL_CONTENT} $) else() get_filename_component(WUHBTOOL_CONTENT "${WUHBTOOL_CONTENT}" ABSOLUTE) if (NOT IS_DIRECTORY "${WUHBTOOL_CONTENT}") message(FATAL_ERROR "wut_create_wuhb: cannot find content dir: ${WUHBTOOL_CONTENT}") endif() list(APPEND WUHBTOOL_ARGS "--content=${WUHBTOOL_CONTENT}") endif() endif() if(DEFINED WUHBTOOL_NAME) list(APPEND WUHBTOOL_ARGS "--name" "${WUHBTOOL_NAME}") endif() if(DEFINED WUHBTOOL_SHORTNAME) list(APPEND WUHBTOOL_ARGS "--short-name" "${WUHBTOOL_SHORTNAME}") endif() if(DEFINED WUHBTOOL_AUTHOR) list(APPEND WUHBTOOL_ARGS "--author" "${WUHBTOOL_AUTHOR}") endif() if(DEFINED WUHBTOOL_ICON) get_filename_component(WUHBTOOL_ICON "${WUHBTOOL_ICON}" ABSOLUTE) list(APPEND WUHBTOOL_ARGS "--icon=${WUHBTOOL_ICON}") list(APPEND WUHBTOOL_DEPS "${WUHBTOOL_ICON}") endif() if(DEFINED WUHBTOOL_TVSPLASH) get_filename_component(WUHBTOOL_TVSPLASH "${WUHBTOOL_TVSPLASH}" ABSOLUTE) list(APPEND WUHBTOOL_ARGS "--tv-image=${WUHBTOOL_TVSPLASH}") list(APPEND WUHBTOOL_DEPS "${WUHBTOOL_TVSPLASH}") endif() if(DEFINED WUHBTOOL_DRCSPLASH) get_filename_component(WUHBTOOL_DRCSPLASH "${WUHBTOOL_DRCSPLASH}" ABSOLUTE) list(APPEND WUHBTOOL_ARGS "--drc-image=${WUHBTOOL_DRCSPLASH}") list(APPEND WUHBTOOL_DEPS "${WUHBTOOL_DRCSPLASH}") endif() add_custom_command( OUTPUT "${WUHBTOOL_OUTPUT}" COMMAND "${WUT_WUHBTOOL_EXE}" ${WUHBTOOL_ARGS} DEPENDS ${WUHBTOOL_DEPS} COMMENT "Building WUHB bundle target ${outtarget}" VERBATIM ) add_custom_target(${outtarget} ALL DEPENDS "${WUHBTOOL_OUTPUT}") dkp_set_target_file(${outtarget} "${WUHBTOOL_OUTPUT}") endfunction() function(wut_add_exports target exports_file) get_filename_component(exports_file "${exports_file}" ABSOLUTE) get_target_property(RPL_BINARY_DIR ${target} BINARY_DIR) if (NOT WUT_RPLEXPORTGEN_EXE) message(FATAL_ERROR "Could not find rplexportgen: try installing wut-tools") endif() if (NOT WUT_RPLIMPORTGEN_EXE) message(FATAL_ERROR "Could not find rplimportgen: try installing wut-tools") endif() __dkp_asm_lang(lang wut_add_exports) set(genfolder "${RPL_BINARY_DIR}/.dkp-generated") set(genbase "${genfolder}/${target}") add_custom_command( OUTPUT "${genbase}_exports.s" "${genbase}_imports.s" "${genbase}_imports.ld" COMMAND ${CMAKE_COMMAND} -E make_directory "${genfolder}" COMMAND ${WUT_RPLEXPORTGEN_EXE} "${exports_file}" "${genbase}_exports.s" COMMAND ${WUT_RPLIMPORTGEN_EXE} "${exports_file}" "${genbase}_imports.s" "${genbase}_imports.ld" DEPENDS "${exports_file}" COMMENT "Generating import/export stubs for ${target}" VERBATIM ) target_sources(${target} PRIVATE "${genbase}_exports.s") set_source_files_properties("${genbase}_exports.s" PROPERTIES LANGUAGE "${lang}") add_library(${target}_imports OBJECT "${genbase}_imports.s") set_source_files_properties("${genbase}_imports.s" PROPERTIES LANGUAGE "${lang}") target_link_options(${target}_imports INTERFACE "-T${genbase}_imports.ld") endfunction() function(wut_link_rpl target) if(NOT ${ARGC} GREATER 1) message(FATAL_ERROR "wut_link_rpl: must provide at least one input RPL") endif() foreach(libname IN LISTS ARGN) if(NOT TARGET ${libname}_imports) message(FATAL_ERROR "wut_link_rpl: library ${libname} is not a valid target") endif() target_link_libraries(${target} PRIVATE ${libname}_imports) endforeach() endfunction() ================================================ FILE: cmake/wiiu/PKGBUILD ================================================ # Maintainer: fincs pkgname=wiiu-cmake pkgver=1.3.2 pkgrel=1 pkgdesc="CMake support for Nintendo Wii U" arch=('any') url='https://devkitpro.org/' source=( 'powerpc-eabi-cmake' 'WiiU.cmake' 'CafeOS.cmake' ) depends=('devkitppc-cmake' 'wut-tools' 'wiiu-pkg-config') groups=('wiiu-dev') options=('!strip') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/wiiu/bin cp "$srcdir"/powerpc-eabi-cmake "$pkgdir"/opt/devkitpro/portlibs/wiiu/bin/ install -d "$pkgdir"/opt/devkitpro/cmake cp "${srcdir}"/WiiU.cmake "$pkgdir"/opt/devkitpro/cmake install -d "$pkgdir"/opt/devkitpro/cmake/Platform cp "${srcdir}"/CafeOS.cmake "$pkgdir"/opt/devkitpro/cmake/Platform } sha256sums=('ee87536e1f4826f2f13008c3b935d5dfaaa901f9e1d64979642570070fd96786' '1e868f8e0b68253dc1c98d62b9934cc7fba359d2bc2cf0e484b417516e5a88cf' '24b954c35217653a205b550e12aceacf76d1c47a8abf62db0a6794bfc540fbb0') ================================================ FILE: cmake/wiiu/WiiU.cmake ================================================ cmake_minimum_required(VERSION 3.13) if(NOT CMAKE_SYSTEM_NAME) set(CMAKE_SYSTEM_NAME CafeOS) endif() # Import devkitPPC toolchain include(${CMAKE_CURRENT_LIST_DIR}/devkitPPC.cmake) set(WUT_ROOT ${DEVKITPRO}/wut) set(DKP_INSTALL_PREFIX_INIT ${DEVKITPRO}/portlibs/wiiu) __dkp_platform_prefix( ${DEVKITPRO}/portlibs/wiiu ${DEVKITPRO}/portlibs/ppc ${WUT_ROOT} ) find_program(PKG_CONFIG_EXECUTABLE NAMES powerpc-eabi-pkg-config HINTS "${DEVKITPRO}/portlibs/wiiu/bin") if (NOT PKG_CONFIG_EXECUTABLE) message(FATAL_ERROR "Could not find powerpc-eabi-pkg-config: try installing wiiu-pkg-config") endif() find_program(WUT_ELF2RPL_EXE NAMES elf2rpl HINTS "${DEVKITPRO}/tools/bin") find_program(WUT_WUHBTOOL_EXE NAMES wuhbtool HINTS "${DEVKITPRO}/tools/bin") find_program(WUT_RPLEXPORTGEN_EXE NAMES rplexportgen HINTS "${DEVKITPRO}/tools/bin") find_program(WUT_RPLIMPORTGEN_EXE NAMES rplimportgen HINTS "${DEVKITPRO}/tools/bin") ================================================ FILE: cmake/wiiu/powerpc-eabi-cmake ================================================ #!/usr/bin/env bash set -e exec env CMAKE_TOOLCHAIN_FILE="${DEVKITPRO}/cmake/WiiU.cmake" cmake "$@" ================================================ FILE: default-arm7/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('default-arm7') pkgver=0.8.4 pkgrel=4 pkgdesc="nds default arm7 binary" arch=('any') license=('zlib') url="http://github.com/devkitpro" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/${pkgname}/releases/download/v${pkgver}/${pkgname}-src-${pkgver}.tar.gz) makedepends=('devkitARM' 'maxmod-nds' 'libnds') groups=('nds-dev') package() { cd $srcdir/${pkgname}-${pkgver} DESTDIR=$pkgdir catnip install } sha256sums=('7219ef7d3eed204eefb145467511aa7e905b0ef8ee7bba4199af97299ac54894') ================================================ FILE: deko3d/PKGBUILD ================================================ # Maintainer: fincs pkgname=('deko3d') pkgver=0.5.0 pkgrel=1 pkgdesc="Homebrew low level graphics API for Nintendo Switch (Nvidia Tegra X1)" arch=('any') license=('custom') url="http://github.com/devkitPro/${pkgname}" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz) sha256sums=('f56af38ec84c008bd0141c203a72190b6bb91767030f34e4bd28c2b10951eb02') makedepends=('devkitA64') depends=('libnx') groups=('switch-dev') build() { make -C $srcdir/$pkgname-$pkgver } package() { make -C $srcdir/$pkgname-$pkgver DESTDIR=$pkgdir install } sha256sums=('ad2680618cb6fad8707f6841d4444e7daf3a974e083d6181581a478b78f618e3') ================================================ FILE: devkita64/devkitA64/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=devkitA64 pkgver=r29.2 pkgrel=1 pkgdesc='devkitA64 metapackage' url='https://devkitpro.org' arch=('any') license=('GPL') depends=( 'devkita64-binutils>=2.45.1-2' 'devkita64-gcc>=15.2.0-7' 'devkita64-newlib>=4.6.0.20260123-4' ) ================================================ FILE: devkita64/devkita64-rules/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('devkita64-rules') pkgver=1.1.1 pkgrel=1 pkgdesc="devkitA64 build rules." arch=('any') license=('custom') url="http://github.com/devkitpro/devkita64-rules" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz) depends=('general-tools>=1.3.1') package() { mkdir -p $pkgdir/opt/devkitpro/devkitA64 make -C ${pkgname}-${pkgver} DESTDIR=$pkgdir install } sha256sums=('bd47183a806e7721fd98cca00cb9fbbea0334551882074725de484e88e4b9d13') ================================================ FILE: devkita64/newlib/PKGBUILD ================================================ # Maintainer: Dave Murphy _realname=newlib _target=aarch64-none-elf pkgname=devkita64-${_realname} pkgver=4.6.0.20260123 pkgrel=4 pkgdesc='devkitA64 newlib' arch=('any') source=( "https://sourceware.org/pub/newlib/newlib-${pkgver}.tar.gz" "https://raw.githubusercontent.com/devkitPro/buildscripts/refs/tags/devkitA64_r29.2/patches/newlib-${pkgver}-${pkgrel}.patch" ) export _TOOLPATH=${TOOLPATH:-/opt/devkitpro/devkitA64} options=(!strip) prepare() { patch -p1 -d ${srcdir}/newlib-${pkgver} -i ${srcdir}/newlib-${pkgver}-${pkgrel}.patch } build() { export PATH=${_TOOLPATH}/bin:${PATH} mkdir -p ${srcdir}/_build_newlib cd ${srcdir}/_build_newlib CFLAGS_FOR_TARGET="-O2 -ffunction-sections -fdata-sections" \ ${srcdir}/newlib-${pkgver}/configure \ --target=${_target} \ --prefix=/opt/devkitpro/devkitA64/ \ --disable-newlib-supplied-syscalls \ --enable-newlib-mb \ --disable-newlib-wide-orient make } package() { cd ${srcdir}/_build_newlib make DESTDIR="${pkgdir}" install find ${pkgdir}/opt/devkitpro/devkitA64/${_target}/lib \( -name "*.a" -or -name "*.o" \) -exec ${_target}-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc '{}' \; } sha256sums=('6ff27e3bf022666f43f7802255be680eeff722ac181b1725d21e2e8318604ee3' 'b2dd30720f77f54f4f417434148112275612ef7130b190be2d87dbd0cf465cd3') sha256sums=('6ff27e3bf022666f43f7802255be680eeff722ac181b1725d21e2e8318604ee3' '6d5aba4356553c727765c98e7553d3784f31d361c856e220ef27cc26353fb88f') ================================================ FILE: devkitarm/devkitARM/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=devkitARM pkgver=r67.1 pkgrel=1 pkgdesc='devkitARM metapackage' url='https://devkitpro.org' arch=('any') license=('GPL') depends=( 'devkitarm-binutils>=2.45.1-2' 'devkitarm-gcc>=15.2.0-7' 'devkitarm-newlib>=4.6.0.20260123-4' ) groups=('gp32-dev' 'gp2x-dev' 'gba-dev' 'nds-dev' '3ds-dev') ================================================ FILE: devkitarm/devkitarm-crtls/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('devkitarm-crtls') pkgver=1.2.6 pkgrel=1 pkgdesc="devkitARM crtls." arch=('any') license=('custom') url="http://github.com/devkitpro/devkitarm-crtls" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz) makedepends=('devkitARM') groups=('gba-dev' 'gp32-dev' 'nds-dev' '3ds-dev') build() { cd $srcdir/$pkgname-$pkgver make } package() { cd $srcdir/$pkgname-$pkgver make DESTDIR=$pkgdir install } sha256sums=('0c7b991a2a8427bca0a64db37138ecc95276eef3958a9be6da6310afd1a1066f') ================================================ FILE: devkitarm/devkitarm-rules/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('devkitarm-rules') pkgver=1.6.0 pkgrel=4 pkgdesc="devkitARM build rules." arch=('any') license=('custom') url="http://github.com/devkitpro/devkitarm-rules" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz) depends=('general-tools>=1.3.1') package() { mkdir -p $pkgdir/opt/devkitpro/devkitARM make -C ${pkgname}-${pkgver} DESTDIR=$pkgdir install } sha256sums=('8682a98116fd70efaeb2c75a5e9f7a9029c7127f7ad9b58935077c716c622287') ================================================ FILE: devkitarm/newlib/PKGBUILD ================================================ # Maintainer: Dave Murphy _realname=newlib _target=arm-none-eabi pkgname=devkitarm-${_realname} pkgver=4.6.0.20260123 pkgrel=5 pkgdesc='devkitARM newlib' arch=('any') source=( "https://sourceware.org/pub/newlib/newlib-${pkgver}.tar.gz" "https://raw.githubusercontent.com/devkitPro/buildscripts/refs/tags/devkitARM_r67.2/patches/newlib-${pkgver}-${pkgrel}.patch" ) groups=('gp32-dev' 'gp2x-dev' 'gba-dev' 'nds-dev' '3ds-dev') options=(!strip) export _TOOLPATH=${TOOLPATH:-/opt/devkitpro/devkitARM} prepare() { patch -p1 -d ${srcdir}/newlib-${pkgver} -i ${srcdir}/newlib-${pkgver}-${pkgrel}.patch } build() { export PATH=${_TOOLPATH}/bin:${PATH} mkdir -p ${srcdir}/_build_newlib cd ${srcdir}/_build_newlib CFLAGS_FOR_TARGET="-O2 -ffunction-sections -fdata-sections" \ ${srcdir}/newlib-${pkgver}/configure \ --target=${_target} \ --prefix=/opt/devkitpro/devkitARM/ \ --disable-newlib-supplied-syscalls \ --enable-newlib-mb \ --disable-newlib-wide-orient \ make } package() { cd ${srcdir}/_build_newlib make DESTDIR="$pkgdir" install find ${pkgdir}/opt/devkitpro/devkitARM/${_target}/lib \( -name "*.a" -or -name "*.o" \) -exec ${_target}-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc '{}' \; } sha256sums=('6ff27e3bf022666f43f7802255be680eeff722ac181b1725d21e2e8318604ee3' '44edc33674524010c3e8469b6b0cbbc41dbe4c5f00b2a648950b2ab91c3d13fb') ================================================ FILE: devkitppc/devkitPPC/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=devkitPPC pkgver=r50 pkgrel=1 pkgdesc='devkitPPC metapackage' url='https://devkitpro.org' arch=('any') license=('GPL') depends=( 'devkitppc-binutils>=2.46.0-1' 'devkitppc-mn10200-binutils>=2.24-3' 'devkitppc-gcc>=16.1.0-1' 'devkitppc-newlib>=4.6.0.20260123-4' ) ================================================ FILE: devkitppc/devkitppc-crtls/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('devkitppc-crtls') pkgver=2.1.0 pkgrel=1 pkgdesc="devkitPPC crtls." arch=('any') license=('custom') url="http://github.com/devkitpro/devkitppc-crtls" source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz) options=(!strip libtool staticlibs) groups=('gamecube-dev' 'wii-dev') package() { cd $srcdir/$pkgname-$pkgver make DESTDIR=$pkgdir install } sha256sums=('3b9cd2470130ced277fc759d6c1dbe255ea20f2311a4d83bba8bc185b5285533') ================================================ FILE: devkitppc/devkitppc-rules/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('devkitppc-rules') pkgver=1.2.1 pkgrel=1 pkgdesc="devkitPPC build rules." arch=('any') license=('custom') url="http://github.com/devkitpro/devkitppc-rules" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz) sha256sums=('6e403ae7101d7349dd8029da83de2960aac10ac83c0b6a1c598a92fdb618efd1') depends=('general-tools>=1.3.1') groups=('gamecube-dev' 'wii-dev' 'wiiu-dev') package() { mkdir -p $pkgdir/opt/devkitpro/devkitPPC make -C ${pkgname}-${pkgver} DESTDIR=$pkgdir install } sha256sums=('c102e969807f77661eea7966ebb02e5386b0d78ae541a4fa4f1acce6d2f32afd') ================================================ FILE: devkitppc/newlib/PKGBUILD ================================================ # Maintainer: Dave Murphy _realname=newlib pkgname=devkitppc-${_realname} pkgver=4.6.0.20260123 pkgrel=4 pkgdesc='devkitPPC newlib' arch=('any') _target=powerpc-eabi export _TOOLPATH=${TOOLPATH:-/opt/devkitpro/devkitPPC} source=( "https://sourceware.org/pub/newlib/newlib-${pkgver}.tar.gz" "https://raw.githubusercontent.com/devkitPro/buildscripts/refs/tags/devkitPPC_r49.2/patches/newlib-${pkgver}-${pkgrel}.patch" ) options=(!strip) prepare() { patch -p1 -d ${srcdir}/newlib-${pkgver} -i ${srcdir}/newlib-${pkgver}-${pkgrel}.patch touch ${srcdir}/newlib-${pkgver}/libgloss/doc/porting.info } build() { export PATH=${_TOOLPATH}/bin:${PATH} mkdir -p ${srcdir}/_build_newlib cd ${srcdir}/_build_newlib CFLAGS_FOR_TARGET="-O2 -ffunction-sections -fdata-sections -DCUSTOM_MALLOC_LOCK" \ ${srcdir}/newlib-${pkgver}/configure \ --target=${_target} \ --prefix=/opt/devkitpro/devkitPPC/ \ --enable-newlib-mb \ --enable-newlib-register-fini \ --disable-newlib-wide-orient \ make } package() { cd ${srcdir}/_build_newlib make DESTDIR="$pkgdir" install -j1 find ${pkgdir}/opt/devkitpro/devkitPPC/${_target}/lib \( -name "*.a" -or -name "*.o" \) -exec ${_target}-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc '{}' \; } sha256sums=('6ff27e3bf022666f43f7802255be680eeff722ac181b1725d21e2e8318604ee3' '6d5aba4356553c727765c98e7553d3784f31d361c856e220ef27cc26353fb88f') ================================================ FILE: dkp-meson-scripts/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=dkp-meson-scripts pkgver=1.1.0 pkgrel=1 pkgdesc='makepkg helpers for devkitPro portlibs' arch=('any') url='http://devkitpro.org/' source=( 'meson-cross.sh' 'meson-toolchain.sh' ) options=(!strip) conflicts=('devkitpro-pkgbuild-helpers') package() { install -d "$pkgdir"/opt/devkitpro install -m755 meson-cross.sh meson-toolchain.sh "$pkgdir"/opt/devkitpro } sha256sums=('039d51cebb15ab7695a436344cbb0617c9c94d4d9a12758744d36e95acc851d6' '02f1929d9c10721b909c9959177a70233323af26a67b89f8d1d932eb3f6c89b7') ================================================ FILE: dkp-meson-scripts/meson-cross.sh ================================================ #!/usr/bin/env bash SCRIPTDIR="${BASH_SOURCE%/*}" if [ -z "$1" ]; then echo "No platform specified." 1>&2 exit 1 fi if [ -z "$2" ]; then echo "No cross file output filename specified." 1>&2 exit 1 fi PLATFORM="$1" CROSSFILE="$2" shift 2 PORTLIBS_PREFIX=$(${SCRIPTDIR}/portlibs_prefix.sh ${PLATFORM}) ${SCRIPTDIR}/meson-toolchain.sh ${PLATFORM} > ${CROSSFILE} || exit 1 meson setup --buildtype=plain --cross-file="${CROSSFILE}" --default-library=static --prefix="${PORTLIBS_PREFIX}" --libdir=lib "$@" ================================================ FILE: dkp-meson-scripts/meson-toolchain.sh ================================================ #!/usr/bin/env bash SCRIPTDIR="${BASH_SOURCE%/*}" make_flag_list() { while (( "$#" )); do echo -n "'$1'"; if [ $# -gt 1 ]; then echo -n ","; fi shift done } if [ -z "$1" ]; then echo "No platform specified." 1>&2 exit 1 fi case "$1" in "switch") PLAT_SYSTEM="horizon" PLAT_CPU_FAMILY="aarch64" PLAT_CPU="cortex-a57" PLAT_ENDIAN="little" source ${SCRIPTDIR}/switchvars.sh ;; "3ds") PLAT_SYSTEM="horizon" PLAT_CPU_FAMILY="arm" PLAT_CPU="arm11mpcore" PLAT_ENDIAN="little" source ${SCRIPTDIR}/3dsvars.sh ;; "nds") PLAT_SYSTEM="bare" PLAT_CPU_FAMILY="arm" PLAT_CPU="arm946e-s" PLAT_ENDIAN="little" source ${SCRIPTDIR}/ndsvars.sh ;; "ppc") PLAT_SYSTEM="bare" PLAT_CPU_FAMILY="ppc" PLAT_CPU="ppc750" PLAT_ENDIAN="big" source ${SCRIPTDIR}/ppcvars.sh ;; "gamecube") PLAT_SYSTEM="bare" PLAT_CPU_FAMILY="ppc" PLAT_CPU="ppc750" PLAT_ENDIAN="big" source ${SCRIPTDIR}/cubevars.sh ;; "wii") PLAT_SYSTEM="bare" PLAT_CPU_FAMILY="ppc" PLAT_CPU="ppc750" PLAT_ENDIAN="big" source ${SCRIPTDIR}/wiivars.sh ;; "wiiu") PLAT_SYSTEM="bare" PLAT_CPU_FAMILY="ppc" PLAT_CPU="ppc750" PLAT_ENDIAN="big" source ${SCRIPTDIR}/wiiuvars.sh ;; *) echo "Unsupported platform." 1>&2 exit 1 ;; esac echo "[binaries]" echo "c = '` which ${TOOL_PREFIX}gcc `'" echo "cpp = '` which ${TOOL_PREFIX}g++ `'" echo "ar = '` which ${TOOL_PREFIX}gcc-ar `'" echo "strip = '` which ${TOOL_PREFIX}strip `'" echo "pkgconfig = '` which ${TOOL_PREFIX}pkg-config `'" echo "" echo "[built-in options]" echo "c_args = [` make_flag_list $CPPFLAGS $CFLAGS `]" echo "c_link_args = [` make_flag_list $LDFLAGS $LIBS `]" echo "cpp_args = [` make_flag_list $CPPFLAGS $CXXFLAGS `]" echo "cpp_link_args = [` make_flag_list $LDFLAGS $LIBS `]" echo "" echo "[host_machine]" echo "system = '${PLAT_SYSTEM}'" echo "cpu_family = '${PLAT_CPU_FAMILY}'" echo "cpu = '${PLAT_CPU}'" echo "endian = '${PLAT_ENDIAN}'" echo "" echo "[target_machine]" echo "system = '${PLAT_SYSTEM}'" echo "cpu_family = '${PLAT_CPU_FAMILY}'" echo "cpu = '${PLAT_CPU}'" echo "endian = '${PLAT_ENDIAN}'" ================================================ FILE: dkp-toolchain-vars/3dsvars.sh ================================================ . ${DEVKITPRO}/devkitarm.sh PORTLIBS_PREFIX=${PORTLIBS_ROOT}/3ds PATH=$PORTLIBS_PREFIX/bin:$PATH export CFLAGS="-march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -O2 -mword-relocations -ffunction-sections -fdata-sections" export CXXFLAGS="${CFLAGS}" export CPPFLAGS="-D_3DS -D__3DS__ -I${PORTLIBS_PREFIX}/include -I${DEVKITPRO}/libctru/include" export LDFLAGS="-L${PORTLIBS_PREFIX}/lib -L${DEVKITPRO}/libctru/lib" export LIBS="-lctru" ================================================ FILE: dkp-toolchain-vars/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=dkp-toolchain-vars pkgver=1.0.5 pkgrel=1 pkgdesc='helper scripts to set variables for devkitPro toolchains' arch=('any') url='http://devkitpro.org/' source=( 'devkitarm.sh' '3dsvars.sh' 'ndsvars.sh' 'armv4tvars.sh' 'devkitppc.sh' 'ppcvars.sh' 'cubevars.sh' 'wiivars.sh' 'wiiuvars.sh' 'devkita64.sh' 'switchvars.sh' 'portlibs_prefix.sh' ) conflicts=('devkitpro-pkgbuild-helpers') options=(!strip) package() { install -d "$pkgdir"/opt/devkitpro/cmake install -Dm644 devkitarm.sh 3dsvars.sh ndsvars.sh armv4tvars.sh "$pkgdir"/opt/devkitpro install -Dm644 devkita64.sh switchvars.sh "$pkgdir"/opt/devkitpro install -Dm644 devkitppc.sh ppcvars.sh cubevars.sh wiivars.sh wiiuvars.sh "$pkgdir"/opt/devkitpro install -Dm755 portlibs_prefix.sh "$pkgdir"/opt/devkitpro } sha256sums=('000b49cce7a925cb096fbac43501ef1c89511861a3ea2091569ae71aa108369b' '679c9e428c6ee6f482299679c1f0b576cec628afb145e19def497894864dd509' '223f87989791295ef5170d33698390fb1389c4f3cfad735f47fec5757f13c452' '7bc0176c5dbea1ab6acaa98a055a1ab81989152d68b582fc57612972f394ac07' 'b69edeee95dfece986941531a7e2c314cc550ab578b300997e0d5de9e825597c' 'e3156d1e6671bfc9ad6a343d26da8cbddcfc4d8e5321ddc07cb2b4934e20ed66' '004fd94dfc9e7a19281fec19c0341686f4dbf00d1f3c9c5590a150e1faac2360' 'e35283a019b5e032c8085e3085b46ab80cea58851c087ba4269a502195ade359' '0f096b32a3216916553360948d2f91f92f4657844a1618cb84bf96a797c44979' 'f3caba3a8864a31a50ff50131f39d160013b6d0b8a2e7e6ac90ca44b591fcb57' '5ade1211e616a7eb540c3660839d17af050c41c7c9ee89242ce4fe7afac4df52' '7913cb3d38e78ede19673912f25970d678912404399e5c10c744726bbafd5f84') ================================================ FILE: dkp-toolchain-vars/armv4tvars.sh ================================================ . ${DEVKITPRO}/devkitarm.sh PORTLIBS_PREFIX=${PORTLIBS_ROOT}/armv4t PATH=$PORTLIBS_PREFIX/bin:$PATH export CFLAGS="-march=armv4t -O2 -ffunction-sections -fdata-sections" export CXXFLAGS="${CFLAGS}" export CPPFLAGS="-I${PORTLIBS_PREFIX}/include" export LDFLAGS="-L${PORTLIBS_PREFIX}/lib" export LIBS="" ================================================ FILE: dkp-toolchain-vars/cubevars.sh ================================================ . ${DEVKITPRO}/devkitppc.sh export PORTLIBS_PREFIX=${PORTLIBS_ROOT}/gamecube export PORTLIBS_PPC=${PORTLIBS_ROOT}/ppc export PORTLIBS_CUBE=${PORTLIBS_PREFIX} export CFLAGS="-O2 -mogc -mcpu=750 -meabi -mhard-float -ffunction-sections -fdata-sections" export CXXFLAGS="${CFLAGS}" export CPPFLAGS="-D__GAMECUBE__ -I${DEVKITPRO}/libogc/include -I${PORTLIBS_CUBE}/include -I${PORTLIBS_PPC}/include" export LDFLAGS="-L${PORTLIBS_CUBE}/lib -L${PORTLIBS_PPC}/lib" export PATH=${PORTLIBS_CUBE}/bin:${PORTLIBS_PPC}/bin:$PATH ================================================ FILE: dkp-toolchain-vars/devkita64.sh ================================================ #!/usr/bin/env bash export DEVKITPRO=/opt/devkitpro export PORTLIBS_ROOT=${DEVKITPRO}/portlibs export PATH=${DEVKITPRO}/tools/bin:${DEVKITPRO}/devkitA64/bin:$PATH export TOOL_PREFIX=aarch64-none-elf- export CC=${TOOL_PREFIX}gcc export CXX=${TOOL_PREFIX}g++ export AR=${TOOL_PREFIX}gcc-ar export RANLIB=${TOOL_PREFIX}gcc-ranlib ================================================ FILE: dkp-toolchain-vars/devkitarm.sh ================================================ #!/usr/bin/env bash export DEVKITPRO=/opt/devkitpro export DEVKITARM=${DEVKITPRO}/devkitARM export PORTLIBS_ROOT=${DEVKITPRO}/portlibs export PATH=${DEVKITPRO}/tools/bin:$DEVKITARM/bin:$PATH export TOOL_PREFIX=arm-none-eabi- export CC=${TOOL_PREFIX}gcc export CXX=${TOOL_PREFIX}g++ export AR=${TOOL_PREFIX}gcc-ar export RANLIB=${TOOL_PREFIX}gcc-ranlib ================================================ FILE: dkp-toolchain-vars/devkitppc.sh ================================================ #!/usr/bin/env bash export DEVKITPRO=/opt/devkitpro export DEVKITPPC=${DEVKITPRO}/devkitPPC export PORTLIBS_ROOT=${DEVKITPRO}/portlibs export PATH=${DEVKITPRO}/tools/bin:${DEVKITPRO}/devkitPPC/bin:$PATH export TOOL_PREFIX=powerpc-eabi- export CC=${TOOL_PREFIX}gcc export CXX=${TOOL_PREFIX}g++ export AR=${TOOL_PREFIX}gcc-ar export RANLIB=${TOOL_PREFIX}gcc-ranlib ================================================ FILE: dkp-toolchain-vars/ndsvars.sh ================================================ . ${DEVKITPRO}/devkitarm.sh PORTLIBS_PREFIX=${PORTLIBS_ROOT}/nds PATH=$PORTLIBS_PREFIX/bin:$PATH export CFLAGS="-march=armv5te -mtune=arm946e-s -O2 -ffunction-sections -fdata-sections" export CXXFLAGS="${CFLAGS}" export CPPFLAGS="-D__NDS__ -DARM9 -I${PORTLIBS_PREFIX}/include -I${DEVKITPRO}/libnds/include" export LDFLAGS="-L${PORTLIBS_PREFIX}/lib -L${DEVKITPRO}/libnds/lib" export LIBS="-lnds9" ================================================ FILE: dkp-toolchain-vars/portlibs_prefix.sh ================================================ #!/usr/bin/env bash if [ -z "$1" ]; then echo "No platform specified." 1>&2 exit 1 fi PLATFORM="$1" source ${DEVKITPRO}/${PLATFORM}vars.sh echo "${PORTLIBS_PREFIX}" ================================================ FILE: dkp-toolchain-vars/ppcvars.sh ================================================ . ${DEVKITPRO}/devkitppc.sh export PORTLIBS_PREFIX=${PORTLIBS_ROOT}/ppc export CFLAGS="-O2 -mcpu=750 -meabi -mhard-float -ffunction-sections -fdata-sections" export CXXFLAGS="${CFLAGS}" export CPPFLAGS="-I${PORTLIBS_PREFIX}/include" export LDFLAGS="-L${PORTLIBS_PREFIX}/lib" export PATH=${PORTLIBS_PREFIX}/bin:$PATH ================================================ FILE: dkp-toolchain-vars/switchvars.sh ================================================ . ${DEVKITPRO}/devkita64.sh export PORTLIBS_PREFIX=${DEVKITPRO}/portlibs/switch export PATH=$PORTLIBS_PREFIX/bin:$PATH export ARCH="-march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec" export CFLAGS="${ARCH} -O2 -ffunction-sections -fdata-sections" export CXXFLAGS="${CFLAGS}" export CPPFLAGS="-D__SWITCH__ -I${PORTLIBS_PREFIX}/include -isystem ${DEVKITPRO}/libnx/include" export LDFLAGS="${ARCH} -L${PORTLIBS_PREFIX}/lib -L${DEVKITPRO}/libnx/lib" export LIBS="-lnx" ================================================ FILE: dkp-toolchain-vars/wiiuvars.sh ================================================ . ${DEVKITPRO}/devkitppc.sh export PORTLIBS_PREFIX=${PORTLIBS_ROOT}/wiiu export PORTLIBS_PPC=${PORTLIBS_ROOT}/ppc export PORTLIBS_WIIU=${PORTLIBS_PREFIX} export CFLAGS="-mcpu=750 -meabi -mhard-float -O2 -ffunction-sections -fdata-sections" export CXXFLAGS="${CFLAGS}" export CPPFLAGS="-DESPRESSO -D__WIIU__ -D__WUT__ -I${PORTLIBS_WIIU}/include -I${PORTLIBS_PPC}/include -I${DEVKITPRO}/wut/include" export LDFLAGS="-L${PORTLIBS_WIIU}/lib -L${PORTLIBS_PPC}/lib -L${DEVKITPRO}/wut/lib -specs=${DEVKITPRO}/wut/share/wut.specs" export LIBS="-lwut -lm" export PATH=${PORTLIBS_WIIU}/bin:${PORTLIBS_PPC}/bin:$PATH ================================================ FILE: dkp-toolchain-vars/wiivars.sh ================================================ . ${DEVKITPRO}/devkitppc.sh export PORTLIBS_PREFIX=${PORTLIBS_ROOT}/wii export PORTLIBS_PPC=${PORTLIBS_ROOT}/ppc export PORTLIBS_WII=${PORTLIBS_PREFIX} export CFLAGS="-O2 -mrvl -mcpu=750 -meabi -mhard-float -ffunction-sections -fdata-sections" export CXXFLAGS="${CFLAGS}" export CPPFLAGS="-D__WII__ -I${DEVKITPRO}/libogc/include -I${PORTLIBS_WII}/include -I${PORTLIBS_PPC}/include" export LDFLAGS="-L${PORTLIBS_WII}/lib -L${PORTLIBS_PPC}/lib -L${DEVKITPRO}/libogc/lib/wii" export LIBS="-logc -lm" export PATH=${PORTLIBS_WII}/bin:${PORTLIBS_PPC}/bin:$PATH ================================================ FILE: dswifi/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('dswifi') pkgver=2.1.0 pkgrel=1 pkgdesc="Nintendo DS wifi library." arch=('any') license=('zlib') url="http://github.com/devkitpro/${pkgname}" options=(!strip libtool staticlibs) source=( ${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz ) makedepends=('catnip' 'devkitARM' 'devkitarm-rules' 'devkitarm-crtls' 'libnds') groups=('nds-dev') package() { cd $srcdir/${pkgname}-${pkgver} DESTDIR=$pkgdir catnip install -tnds } sha256sums=('359410535c6e693a3fea0652bf86faed843dff94e7db31466354075fa8b251a7') ================================================ FILE: gamecube/SDL/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Sergio Padrino pkgname=gamecube-sdl pkgver=1.2.15 pkgrel=21 pkgdesc="A library for portable low-level access to a video framebuffer, audio output, mouse, and keyboard." arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) makedepends=('gamecube-pkg-config' 'dkp-toolchain-vars') depends=('gamecube-opengx' 'libogc') source=("${url}/release/SDL-${pkgver}.tar.gz" "SDL-1.2.15.patch" "config.site") groups=('gamecube-portlibs' 'gamecube-sdl-libs') build() { cd SDL-$pkgver source /opt/devkitpro/cubevars.sh patch -p1 -i $srcdir/SDL-1.2.15.patch ./autogen.sh CONFIG_SITE=${srcdir}/config.site ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static --enable-nintendo-gamecube make } package() { cd SDL-$pkgver source /opt/devkitpro/cubevars.sh make DESTDIR="$pkgdir" install # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share sed -i'' -e "s/-lOpenGL//" "$pkgdir"${PORTLIBS_PREFIX}/lib/pkgconfig/sdl.pc } sha256sums=('d6d316a793e5e348155f0dd93b979798933fb98aa1edebcc108829d6474aad00' '01c7184f7f8db37ae0faa04c3fc59c99bfeb2aa6de9101fe81bf0ba9a959e82f' '7a5c15f9024100ed893689133746ca9e3ac2613fef9ee82339ac0a41c0192b1f') ================================================ FILE: gamecube/SDL/SDL-1.2.15.patch ================================================ diff --git a/README.ogc b/README.ogc new file mode 100644 index 0000000000..ccda9877c4 --- /dev/null +++ b/README.ogc @@ -0,0 +1,37 @@ +# SDL port for Nintendo GameCube/Wii + +This port uses the libogc library and the devkitPPC toolchain, available from +http://www.devkitpro.org + + +## Installation instructions + +We highly recommend using the devkitPro pre-built packages provided via pacman +(https://devkitpro.org/wiki/devkitPro_pacman) unless intending to contribute +changes to this port. + + +## Build instructions + +If you need to hack on libSDL itself then the best way to start is by cloning +the package repo at https://github.com/devkitPro/pacman-packages. The GameCube +package is found under gamecube/SDL and the wii one, surprisingly, under +wii/SDL. cd to the appropriate directory and run makepkg PKGDEST=. there +(on systems without a native pacman this will be dkp-pacman). This will produce +a .pkg.tar.zst file in the current directory which can then be installed for +testing with (dkp-)pacman -U ./.pkg.tar.zst. Once that's done you can +modify the code under src/SDL-1.2.15/. To build with your changes first source +the appropriate toolchain vars script - either /opt/devkitpro/wiivars.sh or +/opt/devkitpro/cubevars.sh then run make. To install you can run sudo -E make +install. + +The easiest way to contribute changes is to fork our SDL repo at +https://github.com/devkitPro/SDL/ then clone that to src/SDL-1.2.15, replacing +the extracted source. This port is on the ogc-sdl-1.2 branch. Create your own +branch from that, commit your changes and make a PR request to the devkitPro +repo. + +If you need further assistance with this then please ask on the forums at +https://devkitpro.org/viewforum.php?f=40 + +Happy hacking! \ No newline at end of file diff --git a/configure.in b/configure.in index 08c8e1e97c..be3f073d64 100644 --- a/configure.in +++ b/configure.in @@ -925,6 +925,99 @@ AC_HELP_STRING([--enable-ipod], [configure SDL to work with iPodLinux [[default= fi } +CheckOpenGX() +{ + AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + AC_MSG_CHECKING(for opengx) + if test x$PKG_CONFIG != xno; then + OPENGX_CFLAGS=`$PKG_CONFIG --cflags opengl` + OPENGX_LIBS=`$PKG_CONFIG --libs opengl` + opengx=yes + AC_DEFINE(SDL_VIDEO_OPENGL) + fi + AC_MSG_RESULT($opengx) +} + +CheckNintendoWii() +{ + AC_ARG_ENABLE(nintendo-wii, +AC_HELP_STRING([--enable-nintendo-wii], [configure SDL to work with Nintendo Wii [[default=no]]]), + , enable_nintendo_wii=no) + if test x$enable_nintendo_wii = xyes; then + ARCH=nintendo-wii + WII_CFLAGS="-mrvl -mcpu=750 -meabi -mhard-float \ + -Wall -O2 \ + -I${DEVKITPRO}/libogc/include -DGEKKO \ + -I${DEVKITPRO}/portlibs/wii/include \ + -I${DEVKITPRO}/portlibs/ppc/include" + EXTRA_CFLAGS="$EXTRA_CFLAGS $WII_CFLAGS" + CFLAGS="$CFLAGS $WII_CFLAGS $OPENGX_CFLAGS" + SDL_CFLAGS="$SDL_CFLAGS $WII_CFLAGS" + SDL_LIBS="-mrvl -mcpu=750 -meabi -mhard-float \ + -L${DEVKITPRO}/portlibs/wii/lib \ + -L${DEVKITPRO}/portlibs/ppc/lib -lSDLmain $SDL_LIBS $OPENGX_LIBS \ + -L${DEVKITPRO}/libogc/lib/wii -laesnd -lwiiuse -lbte -lwiikeyboard -lfat -lopengx -logc -lm" + AC_DEFINE(SDL_TIMER_OGC) + SOURCES="$SOURCES $srcdir/src/timer/ogc/*.c" + have_timers=yes + AC_DEFINE(SDL_AUDIO_DRIVER_OGC) + SOURCES="$SOURCES $srcdir/src/audio/ogc/*.c" + have_audio=yes + AC_DEFINE(SDL_JOYSTICK_OGC) + SOURCES="$SOURCES $srcdir/src/joystick/ogc/*.c" + have_joystick=yes + AC_DEFINE(SDL_THREAD_OGC) + SOURCES="$SOURCES $srcdir/src/thread/ogc/*.c" + have_threads=yes + AC_DEFINE(SDL_VIDEO_DRIVER_OGC) + SOURCES="$SOURCES $srcdir/src/video/wii/*.c" + SOURCES="$SOURCES $srcdir/src/video/ogc/*.c" + SDLMAIN_SOURCES="$srcdir/src/main/wii/*.c" + SDLMAIN_LDFLAGS="-static" + have_video=yes + fi +} + +CheckNintendoGamecube() +{ + AC_ARG_ENABLE(nintendo-gamecube, +AC_HELP_STRING([--enable-nintendo-gamecube], [configure SDL to work with Nintendo Gamecube [[default=no]]]), + , enable_nintendo_wii=no) + if test x$enable_nintendo_gamecube = xyes; then + ARCH=nintendo-gamecube + GAMECUBE_CFLAGS="-mogc -mcpu=750 -meabi -mhard-float \ + -Wall -O2 \ + -I${DEVKITPRO}/libogc/include -DGEKKO \ + -I${DEVKITPRO}/portlibs/gamecube/include \ + -I${DEVKITPRO}/portlibs/ppc/include" + EXTRA_CFLAGS="$EXTRA_CFLAGS $GAMECUBE_CFLAGS" + CFLAGS="$CFLAGS $GAMECUBE_CFLAGS $OPENGX_CFLAGS" + SDL_CFLAGS="$SDL_CFLAGS $GAMECUBE_CFLAGS" + SDL_LIBS="-mogc -mcpu=750 -meabi -mhard-float \ + -L${DEVKITPRO}/portlibs/gamecube/lib \ + -L${DEVKITPRO}/portlibs/ppc/lib -lSDLmain $SDL_LIBS $OPENGX_LIBS \ + -L${DEVKITPRO}/libogc/lib/cube -laesnd -lfat -logc -lm" + AC_DEFINE(SDL_TIMER_OGC) + SOURCES="$SOURCES $srcdir/src/timer/ogc/*.c" + have_timers=yes + AC_DEFINE(SDL_AUDIO_DRIVER_OGC) + SOURCES="$SOURCES $srcdir/src/audio/ogc/*.c" + have_audio=yes + AC_DEFINE(SDL_JOYSTICK_OGC) + SOURCES="$SOURCES $srcdir/src/joystick/ogc/*.c" + have_joystick=yes + AC_DEFINE(SDL_THREAD_OGC) + SOURCES="$SOURCES $srcdir/src/thread/ogc/*.c" + have_threads=yes + AC_DEFINE(SDL_VIDEO_DRIVER_OGC) + SOURCES="$SOURCES $srcdir/src/video/gamecube/*.c" + SOURCES="$SOURCES $srcdir/src/video/ogc/*.c" + SDLMAIN_SOURCES="$srcdir/src/main/gamecube/*.c" + SDLMAIN_LDFLAGS="-static" + have_video=yes + fi +} + dnl Find the nanox include and library directories CheckNANOX() { @@ -2314,6 +2407,11 @@ AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]] dnl Set up the configuration based on the host platform! case "$host" in + powerpc-*-eabi) + CheckOpenGX + CheckNintendoWii + CheckNintendoGamecube + ;; arm-*-elf*) # FIXME: Can we get more specific for iPodLinux? ARCH=linux CheckDummyVideo diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 8bb1773c0e..fa020eff5d 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -185,6 +185,7 @@ #undef SDL_AUDIO_DRIVER_SNDMGR #undef SDL_AUDIO_DRIVER_SUNAUDIO #undef SDL_AUDIO_DRIVER_WAVEOUT +#undef SDL_AUDIO_DRIVER_OGC /* Enable various cdrom drivers */ #undef SDL_CDROM_AIX @@ -215,6 +216,7 @@ #undef SDL_JOYSTICK_MINT #undef SDL_JOYSTICK_OS2 #undef SDL_JOYSTICK_RISCOS +#undef SDL_JOYSTICK_OGC #undef SDL_JOYSTICK_WINMM #undef SDL_JOYSTICK_USBHID #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H @@ -238,6 +240,7 @@ #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP #undef SDL_THREAD_SPROC +#undef SDL_THREAD_OGC #undef SDL_THREAD_WIN32 /* Enable various timer systems */ @@ -249,6 +252,7 @@ #undef SDL_TIMER_OS2 #undef SDL_TIMER_RISCOS #undef SDL_TIMER_UNIX +#undef SDL_TIMER_OGC #undef SDL_TIMER_WIN32 #undef SDL_TIMER_WINCE @@ -279,6 +283,7 @@ #undef SDL_VIDEO_DRIVER_SVGALIB #undef SDL_VIDEO_DRIVER_TOOLBOX #undef SDL_VIDEO_DRIVER_VGL +#undef SDL_VIDEO_DRIVER_OGC #undef SDL_VIDEO_DRIVER_WINDIB #undef SDL_VIDEO_DRIVER_WSCONS #undef SDL_VIDEO_DRIVER_X11 diff --git a/include/SDL_main.h b/include/SDL_main.h index ab50ef1e29..9824c50634 100644 --- a/include/SDL_main.h +++ b/include/SDL_main.h @@ -32,7 +32,8 @@ #if defined(__WIN32__) || \ (defined(__MWERKS__) && !defined(__BEOS__)) || \ defined(__MACOS__) || defined(__MACOSX__) || \ - defined(__SYMBIAN32__) || defined(QWS) + defined(__SYMBIAN32__) || defined(QWS) || \ + defined(__wii__) || defined(__gamecube__) #ifdef __cplusplus #define C_LINKAGE "C" diff --git a/src/SDL.c b/src/SDL.c index 87f1b1af2a..bcb53f7e0d 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -121,6 +121,10 @@ int SDL_InitSubSystem(Uint32 flags) if ( SDL_JoystickInit() < 0 ) { return(-1); } +// joystick 0 is used for mouse emulation on wii & cube. +#if defined (__wii__) || defined (__gamecube__) + SDL_JoystickOpen(0); +#endif SDL_initialized |= SDL_INIT_JOYSTICK; } #else @@ -155,6 +159,10 @@ int SDL_Init(Uint32 flags) } #endif +// On Wii & GameCube always initialise joysticks. +#if defined(__wii__) || defined (__gamecube__) + flags |= SDL_INIT_JOYSTICK; +#endif /* Clear the error message */ SDL_ClearError(); diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index beb26e0b4d..fbbeb459f7 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -112,6 +112,9 @@ static AudioBootStrap *bootstrap[] = { #endif #if SDL_AUDIO_DRIVER_EPOCAUDIO &EPOCAudio_bootstrap, +#endif +#if SDL_AUDIO_DRIVER_OGC + &OGCAUD_bootstrap, #endif NULL }; diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 74ac21df04..e701a570ac 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -179,6 +179,9 @@ extern AudioBootStrap DART_bootstrap; #if SDL_AUDIO_DRIVER_EPOCAUDIO extern AudioBootStrap EPOCAudio_bootstrap; #endif +#if SDL_AUDIO_DRIVER_OGC +extern AudioBootStrap OGCAUD_bootstrap; +#endif /* This is the current audio device */ extern SDL_AudioDevice *current_audio; diff --git a/src/audio/ogc/SDL_ogcAudio.c b/src/audio/ogc/SDL_ogcAudio.c new file mode 100644 index 0000000000..dab1c0134b --- /dev/null +++ b/src/audio/ogc/SDL_ogcAudio.c @@ -0,0 +1,293 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken at libsdl.or +*/ +#include "SDL_config.h" + +// Public includes. +#include "SDL_timer.h" + +// Audio internal includes. +#include "SDL_audio.h" +#include "../SDL_audiomem.h" +#include "../SDL_sysaudio.h" +#include "../SDL_audio_c.h" + +// Wii audio internal includes. +#include "SDL_ogcAudio.h" + +#include + +// for memalign +#include + +static const char OGCAUD_DRIVER_NAME[] = "ogc"; + +#define DMA_BUFFER_SIZE (SAMPLES_PER_DMA_BUFFER*2*sizeof(short)) + +static lwp_t athread; +static ogcAudio *current = NULL; + +/**************************************************************************** + * Audio Threading + ***************************************************************************/ +static void * +AudioThread (ogcAudio *private) +{ + u32 buffer_size; + Uint8 whichab = 1; + + while (1) + { + LWP_SuspendThread(athread); + if (private->stopaudio) + break; + + DCZeroRange(private->dma_buffers[whichab], DMA_BUFFER_SIZE); + buffer_size = DMA_BUFFER_SIZE; + + // Is the device ready? + if (current_audio && !current_audio->paused) + { + SDL_LockMutex(current_audio->mixer_lock); + + if (current_audio->convert.needed) + { + // Get the client to produce audio + current_audio->spec.callback( + current_audio->spec.userdata, + current_audio->convert.buf, + current_audio->convert.len); + + // Convert the audio + SDL_ConvertAudio(¤t_audio->convert); + + // Copy from SDL buffer to DMA buffer + memcpy(private->dma_buffers[whichab], current_audio->convert.buf, current_audio->convert.len_cvt); + buffer_size = current_audio->convert.len_cvt; + } else { + current_audio->spec.callback( + current_audio->spec.userdata, + (Uint8 *)(private->dma_buffers[whichab]), + DMA_BUFFER_SIZE); + buffer_size = DMA_BUFFER_SIZE; + } + + SDL_UnlockMutex(current_audio->mixer_lock); + } + else if (current_audio && (current_audio->spec.format&0x8000)==0) // hack + { + int i; + // if it's an unsigned format use 0x8000 for silence (16-bit) + short fill = 0x8000; + + // 0x80 for 8-bit formats + if (current_audio->spec.format&0x08) + fill |= 0x80; + + for (i=0; i < SAMPLES_PER_DMA_BUFFER*2; i++) + private->dma_buffers[whichab][i] = fill; + } + + AESND_SetVoiceBuffer(private->voice, private->dma_buffers[whichab], buffer_size); + whichab ^= 1; + } + return NULL; +} + +/**************************************************************************** + * DMACallback + * signal audio thread that more samples are required + ***************************************************************************/ +static void +DMACallback(AESNDPB *pb, u32 state) +{ + if (state == VOICE_STATE_STREAM) + LWP_ResumeThread(athread); +} + +void OGC_AudioStop(ogcAudio *private) +{ + if (private==NULL) { + if (current==NULL) + return; + private = current; + } + + if (private->voice) { + AESND_SetVoiceStop(private->voice, 1); + AESND_FreeVoice(private->voice); + private->voice = NULL; + } + + private->stopaudio = true; + if (athread != LWP_THREAD_NULL) { + LWP_ResumeThread(athread); + LWP_JoinThread(athread, NULL); + athread = LWP_THREAD_NULL; + } + + AESND_Pause(1); + // this function is broken + //AESND_Reset(); +} + +int OGC_AudioStart(ogcAudio *private) +{ + if (private==NULL) { + if (current==NULL) + return -1; + private = current; + } + + memset(private->dma_buffers, 0, sizeof(private->dma_buffers)); + private->stopaudio = false; + private->voice = AESND_AllocateVoice(DMACallback); + if (private->voice==NULL) + return -1; + + if (LWP_CreateThread(&athread, (void*(*)(void*))AudioThread, private, private->astack, AUDIOSTACK, 80) < 0) { + AESND_FreeVoice(private->voice); + private->voice = NULL; + return -1; + } + + // start audio + // this is retarded. Why isn't there one function to do all this shit? + AESND_SetVoiceFormat(private->voice, private->format); + AESND_SetVoiceFrequency(private->voice, private->freq); + AESND_SetVoiceBuffer(private->voice, private->dma_buffers[0], DMA_BUFFER_SIZE); + AESND_SetVoiceStream(private->voice, true); + AESND_SetVoiceStop(private->voice, 0); + AESND_Pause(0); + + current = private; + return 1; +} + +static int OGCAUD_OpenAudio(_THIS, SDL_AudioSpec *spec) +{ + u32 format; + ogcAudio *private = (ogcAudio*)(this->hidden); + + if (spec->freq <= 0 || spec->freq > 144000) + spec->freq = DSP_DEFAULT_FREQ; + + // default sample size = 1 byte (1 channel @ 8 bits) + spec->samples = DMA_BUFFER_SIZE; + + // no support for little endian or 16 bit unsigned + switch (spec->format) { + case AUDIO_U8: + format = VOICE_MONO8_UNSIGNED; + break; + case AUDIO_S8: + format = VOICE_MONO8; + break; + // anything else needs conversion to signed 16 big-endian + default: + case AUDIO_U16LSB: + case AUDIO_U16MSB: + case AUDIO_S16LSB: + spec->format = AUDIO_S16MSB; + // fallthrough + case AUDIO_S16MSB: + format = VOICE_MONO16; + // samples are 16 bits + spec->samples >>= 1; + } + + // support 2 channels max + if (spec->channels > 2) + spec->channels = 2; + + if (spec->channels == 2) { + ++format; + // 2 values for each sample + spec->samples >>= 1; + } + + spec->padding = 0; + SDL_CalculateAudioSpec(spec); + + private->format = format; + // AESND will convert frequency as required + private->freq = spec->freq; + + return OGC_AudioStart(private); +} + +static void OGCAUD_CloseAudio(_THIS) +{ + OGC_AudioStop((ogcAudio*)(this->hidden)); + current = NULL; +} + +static void OGCAUD_DeleteDevice(_THIS) +{ + OGC_AudioStop((ogcAudio*)(this->hidden)); + + free(this->hidden); + SDL_free(this); +} + +static SDL_AudioDevice *OGCAUD_CreateDevice(int devindex) +{ + SDL_AudioDevice *this; + + athread = LWP_THREAD_NULL; + + /* Initialize all variables that we clean on shutdown */ + this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); + if ( this ) { + SDL_memset(this, 0, (sizeof *this)); + this->hidden = (ogcAudio*)memalign(32, sizeof(ogcAudio)); + } + if ( (this == NULL) || (this->hidden == NULL) ) { + SDL_OutOfMemory(); + SDL_free(this); + return NULL; + } + SDL_memset(this->hidden, 0, sizeof(ogcAudio)); + + // Initialise the ogc side of the audio system + AESND_Init(); + AESND_Pause(1); + + /* Set the function pointers */ + this->OpenAudio = OGCAUD_OpenAudio; + //this->WaitAudio = WIIAUD_WaitAudio; + //this->PlayAudio = WIIAUD_PlayAudio; + //this->GetAudioBuf = WIIAUD_GetAudioBuf; + this->CloseAudio = OGCAUD_CloseAudio; + this->free = OGCAUD_DeleteDevice; + + return this; +} + +static int OGCAUD_Available(void) +{ + return 1; +} + +AudioBootStrap OGCAUD_bootstrap = { + OGCAUD_DRIVER_NAME, "SDL ogc audio driver", + OGCAUD_Available, OGCAUD_CreateDevice +}; diff --git a/src/audio/ogc/SDL_ogcAudio.h b/src/audio/ogc/SDL_ogcAudio.h new file mode 100644 index 0000000000..532db57424 --- /dev/null +++ b/src/audio/ogc/SDL_ogcAudio.h @@ -0,0 +1,49 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_ogcAudio_h +#define _SDL_ogcAudio_h + +#include +#include + +#include "../SDL_sysaudio.h" + +/* Hidden "this" pointer for the video functions */ +#define _THIS SDL_AudioDevice *this + +#define AUDIOSTACK 8192 +#define SAMPLES_PER_DMA_BUFFER (DSP_STREAMBUFFER_SIZE) + +typedef struct SDL_PrivateAudioData { + // these go first so they will be aligned + Uint8 astack[AUDIOSTACK]; + short dma_buffers[2][SAMPLES_PER_DMA_BUFFER*2]; + + AESNDPB* voice; + u32 format; + u32 freq; + volatile bool stopaudio; +} ogcAudio; + +#endif /* _SDL_dummyaudio_h */ diff --git a/src/joystick/ogc/SDL_sysjoystick.c b/src/joystick/ogc/SDL_sysjoystick.c new file mode 100644 index 0000000000..1ecf6df0ad --- /dev/null +++ b/src/joystick/ogc/SDL_sysjoystick.c @@ -0,0 +1,796 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org + */ +#include "SDL_config.h" + +#ifdef SDL_JOYSTICK_OGC + +#include "SDL_events.h" +#include "SDL_joystick.h" +#include "../SDL_sysjoystick.h" +#include "../SDL_joystick_c.h" + +#include +#include +#include +#include + +#define MAX_GC_JOYSTICKS 4 +#define MAX_WII_JOYSTICKS 4 + +#ifdef __wii__ +#define MAX_JOYSTICKS (MAX_GC_JOYSTICKS + MAX_WII_JOYSTICKS) +#else +#define MAX_JOYSTICKS MAX_GC_JOYSTICKS +#endif + +#define MAX_GC_AXES 6 +#define MAX_GC_BUTTONS 8 +#define MAX_GC_HATS 1 + +#define MAX_WII_AXES 9 +#define MAX_WII_BUTTONS 15 +#define MAX_WII_HATS 1 + +#define JOYNAMELEN 10 + +#define AXIS_MIN -32767 /* minimum value for axis coordinate */ +#define AXIS_MAX 32767 /* maximum value for axis coordinate */ + +extern SDL_Joystick **SDL_joysticks; + +typedef struct joystick_paddata_t +{ + u16 prev_buttons; + s8 stickX; + s8 stickY; + s8 substickX; + s8 substickY; + u8 triggerL; + u8 triggerR; +}joystick_paddata; + +typedef struct joystick_wpaddata_t +{ + u32 prev_buttons; + u32 exp; + s16 nunchuk_stickX; + s16 nunchuk_stickY; + s16 classicL_stickX; + s16 classicL_stickY; + s16 classicR_stickX; + s16 classicR_stickY; + u8 classic_triggerL; + u8 classic_triggerR; + u8 classic_calibrated; + s8 wiimote_pitch; + s8 wiimote_roll; + s8 wiimote_yaw; + s16 classic_cal[4][3]; // 4x axes, min/center/max +}joystick_wpaddata; + +static const u16 sdl_buttons_gc[] = +{ + PAD_BUTTON_A, + PAD_BUTTON_B, + PAD_BUTTON_X, + PAD_BUTTON_Y, + PAD_TRIGGER_L, + PAD_TRIGGER_R, + PAD_TRIGGER_Z, + PAD_BUTTON_START, +}; + +/* The private structure used to keep track of a joystick */ +typedef struct joystick_hwdata_t +{ + int index; + int type; +#ifdef __wii__ + union + { + joystick_paddata gamecube; + joystick_wpaddata wiimote; + }; +#else + joystick_paddata gamecube; +#endif +} joystick_hwdata; + +static const int __jspad_enabled = 1; +static const int __numgcjoysticks = 4; + +#ifdef __wii__ +#define GC_JOYSTICK_FROM_INDEX(index) (index - num_wii_joysticks) +#else +#define GC_JOYSTICK_FROM_INDEX(index) (index) +#endif + +#ifdef __wii__ +static const int __jswpad_enabled = 1; +static const int __numwiijoysticks = 4; +static int split_joysticks = 0; +static int num_wii_joysticks; + +static const u32 sdl_buttons_wii[] = +{ + WPAD_BUTTON_A|WPAD_CLASSIC_BUTTON_A, + WPAD_BUTTON_B|WPAD_CLASSIC_BUTTON_B, + WPAD_BUTTON_1, + WPAD_BUTTON_2, + WPAD_BUTTON_MINUS|WPAD_CLASSIC_BUTTON_MINUS, + WPAD_BUTTON_PLUS|WPAD_CLASSIC_BUTTON_PLUS, + WPAD_BUTTON_HOME|WPAD_CLASSIC_BUTTON_HOME, + WPAD_NUNCHUK_BUTTON_Z, /* 7 */ + WPAD_NUNCHUK_BUTTON_C, /* 8 */ + WPAD_CLASSIC_BUTTON_X, /* 9 */ + WPAD_CLASSIC_BUTTON_Y, + WPAD_CLASSIC_BUTTON_FULL_L, + WPAD_CLASSIC_BUTTON_FULL_R, + WPAD_CLASSIC_BUTTON_ZL, + WPAD_CLASSIC_BUTTON_ZR +}; +#define SDL_WII_NUM_BUTTONS_WII \ + (sizeof(sdl_buttons_wii) / sizeof(sdl_buttons_wii[0])) + +static const u32 sdl_buttons_wiimote[] = +{ + WPAD_BUTTON_A, + WPAD_BUTTON_B, + WPAD_BUTTON_1, + WPAD_BUTTON_2, + WPAD_BUTTON_MINUS, + WPAD_BUTTON_PLUS, + WPAD_BUTTON_HOME, +}; +#define SDL_WII_NUM_BUTTONS_WIIMOTE \ + (sizeof(sdl_buttons_wiimote) / sizeof(sdl_buttons_wiimote[0])) + +static const u32 sdl_buttons_nunchuck[] = +{ + WPAD_NUNCHUK_BUTTON_Z, + WPAD_NUNCHUK_BUTTON_C, +}; +#define SDL_WII_NUM_BUTTONS_NUNCHUCK \ + (sizeof(sdl_buttons_nunchuck) / sizeof(sdl_buttons_nunchuck[0])) + +static const u32 sdl_buttons_classic[] = +{ + WPAD_CLASSIC_BUTTON_A, + WPAD_CLASSIC_BUTTON_B, + WPAD_CLASSIC_BUTTON_X, + WPAD_CLASSIC_BUTTON_Y, + WPAD_CLASSIC_BUTTON_FULL_L, + WPAD_CLASSIC_BUTTON_FULL_R, + WPAD_CLASSIC_BUTTON_ZL, + WPAD_CLASSIC_BUTTON_ZR, + WPAD_CLASSIC_BUTTON_MINUS, + WPAD_CLASSIC_BUTTON_PLUS, + WPAD_CLASSIC_BUTTON_HOME, +}; +#define SDL_WII_NUM_BUTTONS_CLASSIC \ + (sizeof(sdl_buttons_classic) / sizeof(sdl_buttons_classic[0])) + +/* Helpers to separate nunchuk vs classic buttons which share the + * same scan codes. In particular, up on the classic controller is + * the same as Z on the nunchuk. The numbers refer to the sdl_buttons_wii + * list above. */ +static int wii_button_is_nunchuk(int idx) +{ + return idx == 7 || idx == 8; +} + +static int wii_button_is_classic(int idx) +{ + return idx >= 9; +} + +static s16 WPAD_Orient(WPADData *data, int motion) +{ + float out; + + if (motion == 0) + out = data->orient.pitch; + else if (motion == 1) + out = data->orient.roll; + else + out = data->orient.yaw; + + return (s16)((out / 180.0) * 128.0); +} + +static s16 WPAD_Pitch(WPADData *data) +{ + return WPAD_Orient(data, 0); +} + +static s16 WPAD_Roll(WPADData *data) +{ + return WPAD_Orient(data, 1); +} + +static s16 WPAD_Yaw(WPADData *data) +{ + return WPAD_Orient(data, 2); +} + +static s16 WPAD_Stick(s16 x, s16 min, s16 center, s16 max, int flip) +{ + s16 d; + int ret; + + x -= center; + + if (x < 0) + d = center - min; + else + d = max - center; + + if (center - min < 5) return 0; + if (max - center < 5) return 0; + + if (d) + ret = (x << 15) / d; + else + return 0; + + if (flip) + ret = -ret; + + if (ret < AXIS_MIN) + ret = AXIS_MIN; + else if (ret > AXIS_MAX) + ret = AXIS_MAX; + + return ret; +} + +static const u32 _buttons[8] = { + // wiimote + WPAD_BUTTON_UP, + WPAD_BUTTON_DOWN, + WPAD_BUTTON_LEFT, + WPAD_BUTTON_RIGHT, + // classic + WPAD_CLASSIC_BUTTON_UP, + WPAD_CLASSIC_BUTTON_DOWN, + WPAD_CLASSIC_BUTTON_LEFT, + WPAD_CLASSIC_BUTTON_RIGHT +}; + +static void HandleWiiHats(SDL_Joystick *joystick, + const u32 changed, const u32 pressed, + const u32 *buttons) +{ + if (changed & (buttons[0]|buttons[1]|buttons[2]|buttons[3])) + { + int hat = SDL_HAT_CENTERED; + + if (pressed & buttons[0]) hat |= SDL_HAT_UP; + if (pressed & buttons[1]) hat |= SDL_HAT_DOWN; + if (pressed & buttons[2]) hat |= SDL_HAT_LEFT; + if (pressed & buttons[3]) hat |= SDL_HAT_RIGHT; + SDL_PrivateJoystickHat(joystick, 0, hat); + } +} + +static void HandleWiiButtons(SDL_Joystick *joystick, + const u32 changed, + const WPADData *data, + const u32 *buttons, + size_t num_buttons) +{ + for (int i = 0; i < num_buttons; i++) + { + if (changed & buttons[i]) + { + if (!split_joysticks && + ((data->exp.type == WPAD_EXP_CLASSIC && wii_button_is_nunchuk(i)) || + (data->exp.type == WPAD_EXP_NUNCHUK && wii_button_is_classic(i)))) + continue; + + SDL_PrivateJoystickButton(joystick, i, + (data->btns_d & buttons[i]) ? SDL_PRESSED : SDL_RELEASED); + } + } +} + +static void HandleWiiMotion(SDL_Joystick* joystick, + joystick_hwdata *prev_state, + WPADData *data, + int start_index) +{ + int axis = WPAD_Pitch(data); + if(prev_state->wiimote.wiimote_pitch != axis) + { + SDL_PrivateJoystickAxis(joystick, start_index, -(axis << 8)); + prev_state->wiimote.wiimote_pitch = axis; + } + axis = WPAD_Roll(data); + if(prev_state->wiimote.wiimote_roll != axis) + { + SDL_PrivateJoystickAxis(joystick, start_index + 1, axis << 8); + prev_state->wiimote.wiimote_roll = axis; + } + axis = WPAD_Yaw(data); + if(prev_state->wiimote.wiimote_yaw != axis) + { + SDL_PrivateJoystickAxis(joystick, start_index + 2, axis << 8); + prev_state->wiimote.wiimote_yaw = axis; + } +} + +static void _HandleWiiJoystickUpdate(SDL_Joystick* joystick) +{ + u32 changed, pressed; + int axis, index; + joystick_hwdata *prev_state; + WPADData *data; + SDL_Joystick *joy_wiimote = NULL; + SDL_Joystick *joy_expansion = NULL; + + prev_state = (joystick_hwdata*)joystick->hwdata; + index = prev_state->index; + if (!WPAD_ReadPending(index, NULL)) + return; + data = WPAD_Data(index); + changed = data->btns_d | data->btns_u; + pressed = data->btns_d | data->btns_h; + + if (joystick->index >= __numwiijoysticks) { + /* we can get here if using the split joystick feature. But even in + * that case, we don't want to do anything here: the update operation + * on the wiimote must update the expansion joystick too. */ + return; + } + + if (split_joysticks) { + /* To find out the pointer to the linked joystick we use the knowledge + * that the SDL_Joystick structures are allocated in a continuous array + */ + joy_wiimote = joystick; + joy_expansion = SDL_joysticks[joystick->index + 4]; + } + + if (split_joysticks) { + HandleWiiHats(joy_wiimote, changed, pressed, _buttons); + if (data->exp.type == WPAD_EXP_CLASSIC) { // classic controller + HandleWiiHats(joy_expansion, changed, pressed, _buttons + 4); + } + } else { + if (data->exp.type == WPAD_EXP_CLASSIC) // classic controller + HandleWiiHats(joystick, changed, pressed, _buttons + 4); + HandleWiiHats(joystick, changed, pressed, _buttons); + } + + if (split_joysticks) { + HandleWiiButtons(joy_wiimote, changed, data, + sdl_buttons_wiimote, SDL_WII_NUM_BUTTONS_WIIMOTE); + if (data->exp.type == WPAD_EXP_CLASSIC) { + HandleWiiButtons(joy_expansion, changed, data, + sdl_buttons_classic, SDL_WII_NUM_BUTTONS_CLASSIC); + } else if (data->exp.type == WPAD_EXP_NUNCHUK) { + HandleWiiButtons(joy_expansion, changed, data, + sdl_buttons_nunchuck, SDL_WII_NUM_BUTTONS_NUNCHUCK); + } + } else { + HandleWiiButtons(joystick, changed, data, + sdl_buttons_wii, SDL_WII_NUM_BUTTONS_WII); + } + + if(data->exp.type == WPAD_EXP_CLASSIC) + { + if (prev_state->wiimote.exp != WPAD_EXP_CLASSIC) + { + prev_state->wiimote.classic_calibrated = 0; + prev_state->wiimote.classic_cal[0][0] = 5; // left x min + prev_state->wiimote.classic_cal[0][2] = 59; // left x max + prev_state->wiimote.classic_cal[1][0] = 5; // left y min + prev_state->wiimote.classic_cal[1][2] = 59; // left y max + prev_state->wiimote.classic_cal[2][0] = 5; // right x min + prev_state->wiimote.classic_cal[2][2] = 27; // right x max + prev_state->wiimote.classic_cal[3][0] = 5; // right y min + prev_state->wiimote.classic_cal[3][2] = 27; // right y max + + } + + // max/min checking + // left stick x + if (data->exp.classic.ljs.pos.x < prev_state->wiimote.classic_cal[0][0]) + prev_state->wiimote.classic_cal[0][0] = data->exp.classic.ljs.pos.x; + else if (data->exp.classic.ljs.pos.x > prev_state->wiimote.classic_cal[0][2]) + prev_state->wiimote.classic_cal[0][2] = data->exp.classic.ljs.pos.x; + // left stick y + if (data->exp.classic.ljs.pos.y < prev_state->wiimote.classic_cal[1][0]) + prev_state->wiimote.classic_cal[1][0] = data->exp.classic.ljs.pos.y; + else if (data->exp.classic.ljs.pos.y > prev_state->wiimote.classic_cal[1][2]) + prev_state->wiimote.classic_cal[1][2] = data->exp.classic.ljs.pos.y; + // right stick x + if (data->exp.classic.rjs.pos.x < prev_state->wiimote.classic_cal[2][0]) + prev_state->wiimote.classic_cal[2][0] = data->exp.classic.rjs.pos.x; + else if (data->exp.classic.rjs.pos.x > prev_state->wiimote.classic_cal[2][2]) + prev_state->wiimote.classic_cal[2][2] = data->exp.classic.rjs.pos.x; + // right stick y + if (data->exp.classic.rjs.pos.y < prev_state->wiimote.classic_cal[3][0]) + prev_state->wiimote.classic_cal[3][0] = data->exp.classic.rjs.pos.y; + else if (data->exp.classic.rjs.pos.y > prev_state->wiimote.classic_cal[3][2]) + prev_state->wiimote.classic_cal[3][2] = data->exp.classic.rjs.pos.y; + + // calibrate center positions + if (prev_state->wiimote.classic_calibrated < 5) + { + prev_state->wiimote.classic_cal[0][1] = data->exp.classic.ljs.pos.x; + prev_state->wiimote.classic_cal[1][1] = data->exp.classic.ljs.pos.y; + prev_state->wiimote.classic_cal[2][1] = data->exp.classic.rjs.pos.x; + prev_state->wiimote.classic_cal[3][1] = data->exp.classic.rjs.pos.y; + // this is zero if the expansion hasn't finished initializing + if (data->exp.classic.ljs.max.x) + prev_state->wiimote.classic_calibrated++; + } + } + + if (data->exp.type != prev_state->wiimote.exp) + { + SDL_Joystick *joy = split_joysticks ? joy_expansion : joystick; + // Reset the expansion axes + for (int i = 0; i < 6; i++) + SDL_PrivateJoystickAxis(joy, i, 0); + } + + if(data->exp.type == WPAD_EXP_CLASSIC) + { + SDL_Joystick *joy = split_joysticks ? joy_expansion : joystick; + + axis = WPAD_Stick(data->exp.classic.ljs.pos.x, prev_state->wiimote.classic_cal[0][0], + prev_state->wiimote.classic_cal[0][1], prev_state->wiimote.classic_cal[0][2], 0); + if(prev_state->wiimote.classicL_stickX != axis) + { + SDL_PrivateJoystickAxis(joy, 0, axis); + prev_state->wiimote.classicL_stickX = axis; + } + // y axes are reversed + axis = WPAD_Stick(data->exp.classic.ljs.pos.y, prev_state->wiimote.classic_cal[1][0], + prev_state->wiimote.classic_cal[1][1], prev_state->wiimote.classic_cal[1][2], 1); + if(prev_state->wiimote.classicL_stickY != axis) + { + SDL_PrivateJoystickAxis(joy, 1, axis); + prev_state->wiimote.classicL_stickY = axis; + } + axis = WPAD_Stick(data->exp.classic.rjs.pos.x, prev_state->wiimote.classic_cal[2][0], + prev_state->wiimote.classic_cal[2][1], prev_state->wiimote.classic_cal[2][2], 0); + if(prev_state->wiimote.classicR_stickX != axis) + { + SDL_PrivateJoystickAxis(joy, 2, axis); + prev_state->wiimote.classicR_stickX = axis; + } + axis = WPAD_Stick(data->exp.classic.rjs.pos.y, prev_state->wiimote.classic_cal[3][0], + prev_state->wiimote.classic_cal[3][1], prev_state->wiimote.classic_cal[3][2], 1); + if(prev_state->wiimote.classicR_stickY != axis) + { + SDL_PrivateJoystickAxis(joy, 3, axis); + prev_state->wiimote.classicR_stickY = axis; + } + axis = data->exp.classic.r_shoulder; + if(prev_state->wiimote.classic_triggerR != axis) + { + SDL_PrivateJoystickAxis(joy, 4, axis<<8); + prev_state->wiimote.classic_triggerR = axis; + } + axis = data->exp.classic.l_shoulder; + if(prev_state->wiimote.classic_triggerL != axis) + { + SDL_PrivateJoystickAxis(joy, 5, axis<<8); + prev_state->wiimote.classic_triggerL = axis; + } + } + else if(data->exp.type == WPAD_EXP_NUNCHUK) + { + SDL_Joystick *joy = split_joysticks ? joy_expansion : joystick; + + axis = WPAD_Stick(data->exp.nunchuk.js.pos.x, data->exp.nunchuk.js.min.x, + data->exp.nunchuk.js.center.x, data->exp.nunchuk.js.max.x, 0); + if(prev_state->wiimote.nunchuk_stickX != axis) + { + SDL_PrivateJoystickAxis(joy, 0, axis); + prev_state->wiimote.nunchuk_stickX = axis; + } + axis = WPAD_Stick(data->exp.nunchuk.js.pos.y, data->exp.nunchuk.js.min.y, + data->exp.nunchuk.js.center.y, data->exp.nunchuk.js.max.y, 1); + if(prev_state->wiimote.nunchuk_stickY != axis) + { + SDL_PrivateJoystickAxis(joy, 1, axis); + prev_state->wiimote.nunchuk_stickY = axis; + } + } + + prev_state->wiimote.exp = data->exp.type; + + if (split_joysticks) { + // also update the expansion + ((joystick_hwdata*)joy_expansion->hwdata)->wiimote.exp = data->exp.type; + } + + int start_index = split_joysticks ? 0 : 6; + HandleWiiMotion(split_joysticks ? joy_wiimote : joystick, prev_state, data, start_index); +} + +#endif + +/* Function to scan the system for joysticks. + * This function should return the number of available + * joysticks. Joystick 0 should be the system default joystick. + * It should return -1 on an unrecoverable fatal error. + */ +int SDL_SYS_JoystickInit(void) +{ +#ifdef __wii__ + const char *split_joystick_env = getenv("SDL_WII_JOYSTICK_SPLIT"); + split_joysticks = split_joystick_env && strcmp(split_joystick_env, "1") == 0; + /* Multiply by two because each wiimote might have an expansion connected */ + num_wii_joysticks = split_joysticks ? __numwiijoysticks * 2 : __numwiijoysticks; + return num_wii_joysticks + __numgcjoysticks; +#else + return MAX_JOYSTICKS; +#endif +} + +static char joy_name[64] = "Gamecube 0"; + +/* Function to get the device-dependent name of a joystick */ +const char *SDL_SYS_JoystickName(int index) +{ + if(index>=0) { +#ifdef __wii__ + if((__jswpad_enabled) && (index < num_wii_joysticks)) { + joystick_hwdata *hwdata = (joystick_hwdata*)SDL_joysticks[index]->hwdata; + char *name_ptr = joy_name; + if (index < __numwiijoysticks) { + name_ptr += sprintf(name_ptr, "Wiimote %d", index); + if (!split_joysticks) { + // Add expansion information + switch (hwdata->wiimote.exp) { + case WPAD_EXP_NUNCHUK: + strcpy(name_ptr, " + Nunchuk"); break; + case WPAD_EXP_CLASSIC: + strcpy(name_ptr, " + Classic"); break; + case WPAD_EXP_GUITARHERO3: + strcpy(name_ptr, " + Guitar Hero 3"); break; + case WPAD_EXP_WIIBOARD: + strcpy(name_ptr, " + Balance board"); break; + } + } + } else { + /* This is an expansion and we are using the split controllers + * option: show only the expansion name, then. */ + int idx = index - __numwiijoysticks; + switch (hwdata->wiimote.exp) { + case WPAD_EXP_NUNCHUK: + sprintf(name_ptr, "Nunchuk %d", idx); break; + case WPAD_EXP_CLASSIC: + sprintf(name_ptr, "Classic %d", idx); break; + case WPAD_EXP_GUITARHERO3: + sprintf(name_ptr, "Guitar Hero 3 %d", idx); break; + case WPAD_EXP_WIIBOARD: + sprintf(name_ptr, "Balance board %d", idx); break; + case WPAD_EXP_NONE: + strcpy(name_ptr, "Disconnected"); break; + default: + sprintf(name_ptr, "Unknown %d", idx); break; + } + } + } else if((__jspad_enabled) && (index < (num_wii_joysticks + __numgcjoysticks))) +#endif + sprintf(joy_name, "Gamecube %d", index); + } + return (const char *)joy_name; +} + +/* Function to open a joystick for use. + The joystick to open is specified by the index field of the joystick. + This should fill the nbuttons and naxes fields of the joystick structure. + It returns 0, or -1 if there is an error. + */ +int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) +{ + /* allocate memory for system specific hardware data */ + joystick->hwdata = SDL_malloc(sizeof(joystick_hwdata)); + if (joystick->hwdata == NULL) + { + SDL_OutOfMemory(); + return(-1); + } + SDL_memset(joystick->hwdata, 0, sizeof(joystick_hwdata)); +#ifdef __wii__ + if((joystick->index < num_wii_joysticks) && (__jswpad_enabled)) + { + int index = (joystick->index > __numwiijoysticks) ? (joystick->index - __numwiijoysticks) : joystick->index; + ((joystick_hwdata*)(joystick->hwdata))->index = index; + ((joystick_hwdata*)(joystick->hwdata))->type = 0; + if (split_joysticks) { + if (joystick->index < __numwiijoysticks) { + // wiimote + joystick->nbuttons = SDL_WII_NUM_BUTTONS_WIIMOTE; + joystick->naxes = 3; + joystick->nhats = 1; + } else { + // expansion + joystick->nbuttons = SDL_max(SDL_WII_NUM_BUTTONS_NUNCHUCK, + SDL_WII_NUM_BUTTONS_CLASSIC); + joystick->naxes = 6; + joystick->nhats = 1; + } + } else { + joystick->nbuttons = MAX_WII_BUTTONS; + joystick->naxes = MAX_WII_AXES; + joystick->nhats = MAX_WII_HATS; + } + } + else if((joystick->index < num_wii_joysticks + __numgcjoysticks) && (__jspad_enabled)) + { + ((joystick_hwdata*)(joystick->hwdata))->index = joystick->index - num_wii_joysticks; + ((joystick_hwdata*)(joystick->hwdata))->type = 1; + joystick->nbuttons = MAX_GC_BUTTONS; + joystick->naxes = MAX_GC_AXES; + joystick->nhats = MAX_GC_HATS; + } +#else + if((joystick->index < 4) && (__jspad_enabled)) + { + if(joystick->index < (__numgcjoysticks)) + { + ((joystick_hwdata*)(joystick->hwdata))->index = joystick->index - 4; + ((joystick_hwdata*)(joystick->hwdata))->type = 1; + joystick->nbuttons = MAX_GC_BUTTONS; + joystick->naxes = MAX_GC_AXES; + joystick->nhats = MAX_GC_HATS; + } + } +#endif + return(0); +} + + +static void _HandleGCJoystickUpdate(SDL_Joystick* joystick) +{ + u16 buttons, prev_buttons, changed; + int i; + int axis; + joystick_hwdata *prev_state; + int index = GC_JOYSTICK_FROM_INDEX(joystick->index); + + buttons = PAD_ButtonsHeld(index); + prev_state = (joystick_hwdata *)joystick->hwdata; + prev_buttons = prev_state->gamecube.prev_buttons; + changed = buttons ^ prev_buttons; + + if(changed & (PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT | PAD_BUTTON_DOWN | PAD_BUTTON_UP)) + { + int hat = SDL_HAT_CENTERED; + if(buttons & PAD_BUTTON_UP) hat |= SDL_HAT_UP; + if(buttons & PAD_BUTTON_DOWN) hat |= SDL_HAT_DOWN; + if(buttons & PAD_BUTTON_LEFT) hat |= SDL_HAT_LEFT; + if(buttons & PAD_BUTTON_RIGHT) hat |= SDL_HAT_RIGHT; + SDL_PrivateJoystickHat(joystick, 0, hat); + } + + for(i = 0; i < (sizeof(sdl_buttons_gc) / sizeof(sdl_buttons_gc[0])); i++) + { + if (changed & sdl_buttons_gc[i]) + SDL_PrivateJoystickButton(joystick, i, + (buttons & sdl_buttons_gc[i]) ? SDL_PRESSED : SDL_RELEASED); + } + prev_state->gamecube.prev_buttons = buttons; + axis = PAD_StickX(index); + if(prev_state->gamecube.stickX != axis) + { + SDL_PrivateJoystickAxis(joystick, 0, axis << 8); + prev_state->gamecube.stickX = axis; + } + + axis = PAD_StickY(index); + if(prev_state->gamecube.stickY != axis) + { + SDL_PrivateJoystickAxis(joystick, 1, (-axis) << 8); + prev_state->gamecube.stickY = axis; + } + + axis = PAD_SubStickX(index); + if(prev_state->gamecube.substickX != axis) + { + SDL_PrivateJoystickAxis(joystick, 2, axis << 8); + prev_state->gamecube.substickX = axis; + } + + axis = PAD_SubStickY(index); + if(prev_state->gamecube.substickY != axis) + { + SDL_PrivateJoystickAxis(joystick, 3, (-axis) << 8); + prev_state->gamecube.substickY = axis; + } + + axis = PAD_TriggerL(index); + if(prev_state->gamecube.triggerL != axis) + { + SDL_PrivateJoystickAxis(joystick, 4, axis << 7); + prev_state->gamecube.triggerL = axis; + } + + axis = PAD_TriggerR(index); + if(prev_state->gamecube.triggerR != axis) + { + SDL_PrivateJoystickAxis(joystick, 5, axis << 7); + prev_state->gamecube.triggerR = axis; + } +} + +/* Function to update the state of a joystick - called as a device poll. + * This function shouldn't update the joystick structure directly, + * but instead should call SDL_PrivateJoystick*() to deliver events + * and update joystick device state. + */ + +void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) +{ + if(!joystick || !joystick->hwdata) + return; + + PAD_ScanPads(); + + switch(((joystick_hwdata*)(joystick->hwdata))->type) + { +#ifdef __wii__ + case 0: + if(__jswpad_enabled) { + if (split_joysticks && joystick->index >= __numwiijoysticks) { + /* the actual joystick we want to update is always the wiimote + * one */ + joystick = SDL_joysticks[joystick->index - __numwiijoysticks]; + } + _HandleWiiJoystickUpdate(joystick); + } + break; +#endif + case 1: + if(__jspad_enabled) + _HandleGCJoystickUpdate(joystick); + break; + default: + break; + } +} + +/* Function to close a joystick after use */ +void SDL_SYS_JoystickClose(SDL_Joystick *joystick) +{ + if(!joystick || !joystick->hwdata) // joystick already closed + return; + + SDL_free(joystick->hwdata); + joystick->hwdata = NULL; +} + +/* Function to perform any system-specific joystick related cleanup */ +void SDL_SYS_JoystickQuit(void) +{ + +} + +#endif /* SDL_JOYSTICK_DC */ diff --git a/src/main/gamecube/SDL_gamecube_main.c b/src/main/gamecube/SDL_gamecube_main.c new file mode 100644 index 0000000000..1ad5a19bd5 --- /dev/null +++ b/src/main/gamecube/SDL_gamecube_main.c @@ -0,0 +1,26 @@ +/* Include the SDL main definition header */ +#include "SDL_main.h" +#undef main + +/* Standard includes */ +#include + +/* SDL includes */ +#include "../../video/ogc/SDL_ogc_video.h" + +/* OGC includes */ +#include +#include + +/* Do initialisation which has to be done first for the console to work */ +/* Entry point */ +int main(int argc, char *argv[]) +{ +// SYS_SetPowerCallback(ShutdownCB); +// SYS_SetResetCallback(ResetCB); + PAD_Init(); + OGC_InitVideoSystem(); + fatInitDefault(); + /* Call the user's main function */ + return(SDL_main(argc, argv)); +} diff --git a/src/main/wii/SDL_wii_main.c b/src/main/wii/SDL_wii_main.c new file mode 100644 index 0000000000..75851d4b1c --- /dev/null +++ b/src/main/wii/SDL_wii_main.c @@ -0,0 +1,76 @@ +/* Include the SDL main definition header */ +#include "SDL_main.h" +#undef main + +/* Standard includes */ +#include + +/* SDL includes */ +#include "../../video/ogc/SDL_ogc_video.h" + +/* OGC includes */ +#include +#include +#include +#include +#include + +bool TerminateRequested=false, ShutdownRequested=false, ResetRequested=false; + +void SDL_Quit(); +static void ShutdownCB() +{ + TerminateRequested = 1; + ShutdownRequested = 1; +} +static void ResetCB(u32, void*) +{ + TerminateRequested = 1; + ResetRequested = 1; +} +void ShutdownWii() +{ + TerminateRequested = 0; + SDL_Quit(); + SYS_ResetSystem(SYS_POWEROFF, 0, 0); +} +void RestartHomebrewChannel() +{ + TerminateRequested = 0; + SDL_Quit(); + exit(1); +} +void Terminate() +{ + if (ShutdownRequested) ShutdownWii(); + else if (ResetRequested) RestartHomebrewChannel(); +} + +/* Do initialisation which has to be done first for the console to work */ +/* Entry point */ +int main(int argc, char *argv[]) +{ + L2Enhance(); + u32 version = IOS_GetVersion(); + s32 preferred = IOS_GetPreferredVersion(); + + if(preferred > 0 && version != (u32)preferred) + IOS_ReloadIOS(preferred); + + // Wii Power/Reset buttons + WPAD_Init(); + WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB); + SYS_SetPowerCallback(ShutdownCB); + SYS_SetResetCallback(ResetCB); + PAD_Init(); + OGC_InitVideoSystem(); + WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); + WPAD_SetVRes(WPAD_CHAN_ALL, 640, 480); + + MOUSE_Init(); + KEYBOARD_Init(NULL); + fatInitDefault(); + /* Call the user's main function */ + return(SDL_main(argc, argv)); +} + diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index 8af6e52f41..e2c21bd6f6 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -43,6 +43,8 @@ #include "win32/SDL_systhread_c.h" #elif SDL_THREAD_SYMBIAN #include "symbian/SDL_systhread_c.h" +#elif SDL_THREAD_OGC +#include "ogc/SDL_systhread_c.h" #else #error Need thread implementation for this platform #include "generic/SDL_systhread_c.h" diff --git a/src/thread/ogc/SDL_syscond.c b/src/thread/ogc/SDL_syscond.c new file mode 100644 index 0000000000..70d76b97ec --- /dev/null +++ b/src/thread/ogc/SDL_syscond.c @@ -0,0 +1,139 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* An implementation of condition variables using semaphores and mutexes */ +/* + This implementation borrows heavily from the BeOS condition variable + implementation, written by Christopher Tate and Owen Smith. Thanks! + */ + +#include "SDL_thread.h" +#include "SDL_sysmutex_c.h" + +#include +#include + +struct SDL_cond +{ + cond_t cond; +}; + +/* Create a condition variable */ +SDL_cond * SDL_CreateCond(void) +{ + SDL_cond *cond; + + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); + if (cond) + { + if (LWP_CondInit(&(cond->cond)) < 0) + { + SDL_DestroyCond(cond); + cond = NULL; + } + } + else + { + SDL_OutOfMemory(); + } + return (cond); +} + +/* Destroy a condition variable */ +void SDL_DestroyCond(SDL_cond *cond) +{ + if (cond) + { + LWP_CondDestroy(cond->cond); + SDL_free(cond); + } +} + +/* Restart one of the threads that are waiting on the condition variable */ +int SDL_CondSignal(SDL_cond *cond) +{ + if (!cond) + { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + + return LWP_CondSignal(cond->cond) == 0 ? 0 : -1; + +} + +/* Restart all threads that are waiting on the condition variable */ +int SDL_CondBroadcast(SDL_cond *cond) +{ + if (!cond) + { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + + return LWP_CondBroadcast(cond->cond) == 0 ? 0 : -1; +} + +/* Wait on the condition variable for at most 'ms' milliseconds. + The mutex must be locked before entering this function! + The mutex is unlocked during the wait, and locked again after the wait. + + Typical use: + + Thread A: + SDL_LockMutex(lock); + while ( ! condition ) { + SDL_CondWait(cond); + } + SDL_UnlockMutex(lock); + + Thread B: + SDL_LockMutex(lock); + ... + condition = true; + ... + SDL_UnlockMutex(lock); + */ + + +int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) +{ + struct timespec time; + + if (!cond) + { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + //LWP_CondTimedWait expects relative timeout + time.tv_sec = (ms / 1000); + time.tv_nsec = (ms % 1000) * 1000000; + + return LWP_CondTimedWait(cond->cond, mutex->id, &time); +} + +/* Wait on the condition variable forever */ +int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) +{ + return LWP_CondWait(cond->cond, mutex->id); +} diff --git a/src/thread/ogc/SDL_sysmutex.c b/src/thread/ogc/SDL_sysmutex.c new file mode 100644 index 0000000000..9fc57496c8 --- /dev/null +++ b/src/thread/ogc/SDL_sysmutex.c @@ -0,0 +1,87 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* An implementation of mutexes using semaphores */ + +#include "SDL_thread.h" +#include "SDL_systhread_c.h" + +#include + +struct SDL_mutex +{ + u32 id; +}; + +/* Create a mutex */ +SDL_mutex *SDL_CreateMutex(void) +{ + SDL_mutex *mutex = NULL; + + /* Allocate mutex memory */ + mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); + if (mutex) + { + LWP_MutexInit(&mutex->id, 0); + } + else + { + SDL_OutOfMemory(); + } + return mutex; +} + +/* Free the mutex */ +void SDL_DestroyMutex(SDL_mutex *mutex) +{ + if (mutex) + { + LWP_MutexDestroy(mutex->id); + SDL_free(mutex); + } +} + +/* Lock the semaphore */ +int SDL_mutexP(SDL_mutex *mutex) +{ + if (mutex == NULL) + { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + return LWP_MutexLock(mutex->id); +} + +/* Unlock the mutex */ +int SDL_mutexV(SDL_mutex *mutex) +{ + if (mutex == NULL) + { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + return LWP_MutexUnlock(mutex->id); + +} diff --git a/src/thread/ogc/SDL_sysmutex_c.h b/src/thread/ogc/SDL_sysmutex_c.h new file mode 100644 index 0000000000..8fdac822a6 --- /dev/null +++ b/src/thread/ogc/SDL_sysmutex_c.h @@ -0,0 +1,26 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +struct SDL_mutex { + Uint32 id; +}; diff --git a/src/thread/ogc/SDL_syssem.c b/src/thread/ogc/SDL_syssem.c new file mode 100644 index 0000000000..4c68ac3ea9 --- /dev/null +++ b/src/thread/ogc/SDL_syssem.c @@ -0,0 +1,175 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* An implementation of semaphores using mutexes and condition variables */ + +#include "SDL_timer.h" +#include "SDL_thread.h" +#include "SDL_systhread_c.h" + +struct SDL_semaphore +{ + Uint32 count; + Uint32 waiters_count; + SDL_mutex *count_lock; + SDL_cond *count_nonzero; +}; + +SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) +{ + SDL_sem *sem; + + sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); + if (!sem) + { + SDL_OutOfMemory(); + return NULL; + } + sem->count = initial_value; + sem->waiters_count = 0; + + sem->count_lock = SDL_CreateMutex(); + sem->count_nonzero = SDL_CreateCond(); + if (!sem->count_lock || !sem->count_nonzero) + { + SDL_DestroySemaphore(sem); + return NULL; + } + + return sem; +} + +/* WARNING: + You cannot call this function when another thread is using the semaphore. + */ +void SDL_DestroySemaphore(SDL_sem *sem) +{ + if (sem) + { + sem->count = 0xFFFFFFFF; + while (sem->waiters_count > 0) + { + SDL_CondSignal(sem->count_nonzero); + SDL_Delay(10); + } + SDL_DestroyCond(sem->count_nonzero); + if (sem->count_lock) + { + SDL_mutexP(sem->count_lock); + SDL_mutexV(sem->count_lock); + SDL_DestroyMutex(sem->count_lock); + } + SDL_free(sem); + } +} + +int SDL_SemTryWait(SDL_sem *sem) +{ + int retval; + + if (!sem) + { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + retval = SDL_MUTEX_TIMEDOUT; + SDL_LockMutex(sem->count_lock); + if (sem->count > 0) + { + --sem->count; + retval = 0; + } + SDL_UnlockMutex(sem->count_lock); + + return retval; +} + +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) +{ + int retval; + + if (!sem) + { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + /* A timeout of 0 is an easy case */ + if (timeout == 0) + { + return SDL_SemTryWait(sem); + } + + SDL_LockMutex(sem->count_lock); + ++sem->waiters_count; + retval = 0; + while ((sem->count == 0) && (retval != SDL_MUTEX_TIMEDOUT)) + { + retval = SDL_CondWaitTimeout(sem->count_nonzero, sem->count_lock, + timeout); + } + --sem->waiters_count; + --sem->count; + SDL_UnlockMutex(sem->count_lock); + + return retval; +} + +int SDL_SemWait(SDL_sem *sem) +{ + return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); +} + +Uint32 SDL_SemValue(SDL_sem *sem) +{ + Uint32 value; + + value = 0; + if (sem) + { + SDL_LockMutex(sem->count_lock); + value = sem->count; + SDL_UnlockMutex(sem->count_lock); + } + return value; +} + +int SDL_SemPost(SDL_sem *sem) +{ + if (!sem) + { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + SDL_LockMutex(sem->count_lock); + if (sem->waiters_count > 0) + { + SDL_CondSignal(sem->count_nonzero); + } + ++sem->count; + SDL_UnlockMutex(sem->count_lock); + + return 0; +} diff --git a/src/thread/ogc/SDL_systhread.c b/src/thread/ogc/SDL_systhread.c new file mode 100644 index 0000000000..c546df05d0 --- /dev/null +++ b/src/thread/ogc/SDL_systhread.c @@ -0,0 +1,80 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* Thread management routines for SDL */ + +#include "SDL_thread.h" +#include "../SDL_systhread.h" +#include "../SDL_thread_c.h" + +#include + +/* +struct SDL_Thread { + Uint32 threadid; + SYS_ThreadHandle handle; + int status; + SDL_error errbuf; + void *data; +}; + + */ + +void *run_thread(void *data) +{ + SDL_RunThread(data); + return ((void *) 0); /* Prevent compiler warning */ +} + +int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) +{ + + if ( LWP_CreateThread(&thread->handle, run_thread, args, 0, 0, 16) != 0 ) { + SDL_SetError("Not enough resources to create thread"); + return(-1); + } + + return (0); +} + +void SDL_SYS_SetupThread(void) +{ + return; +} + +Uint32 SDL_ThreadID(void) +{ + return (Uint32) LWP_GetSelf(); +} + +void SDL_SYS_WaitThread(SDL_Thread *thread) +{ + void *v; + LWP_JoinThread(thread->handle, &v); + return; +} + +void SDL_SYS_KillThread(SDL_Thread *thread) +{ + return; +} diff --git a/src/thread/ogc/SDL_systhread_c.h b/src/thread/ogc/SDL_systhread_c.h new file mode 100644 index 0000000000..fc13572acc --- /dev/null +++ b/src/thread/ogc/SDL_systhread_c.h @@ -0,0 +1,26 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* Stub until we implement threads on this platform */ + +typedef Uint32 SYS_ThreadHandle; diff --git a/src/timer/ogc/SDL_systimer.c b/src/timer/ogc/SDL_systimer.c new file mode 100644 index 0000000000..144ad38df5 --- /dev/null +++ b/src/timer/ogc/SDL_systimer.c @@ -0,0 +1,105 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifdef SDL_TIMER_OGC + +#include +#include + +#include "SDL_timer.h" +#include "../SDL_timer_c.h" + +#include + +static Uint64 start; + +void SDL_StartTicks(void) +{ + start = gettime(); +} + +Uint32 SDL_GetTicks (void) +{ + const Uint64 ticks = gettime() - start; + const Uint64 ms = ticks / TB_TIMER_CLOCK; + return ms; +} + +void SDL_Delay (Uint32 ms) +{ + struct timespec elapsed, tv; + elapsed.tv_sec = ms/1000; + elapsed.tv_nsec = (ms%1000)*1000000; + tv.tv_sec = elapsed.tv_sec; + tv.tv_nsec = elapsed.tv_nsec; + nanosleep(&tv, &elapsed); +} + +#include "SDL_thread.h" + +/* Data to handle a single periodic alarm */ +static int timer_alive = 0; +static SDL_Thread *timer = NULL; + +static int RunTimer(void *unused) +{ + while ( timer_alive ) { + if ( SDL_timer_running ) { + SDL_ThreadedTimerCheck(); + } + SDL_Delay(1); + } + return(0); +} + +/* This is only called if the event thread is not running */ +int SDL_SYS_TimerInit(void) +{ + timer_alive = 1; + timer = SDL_CreateThread(RunTimer, NULL); + if ( timer == NULL ) + return(-1); + return(SDL_SetTimerThreaded(1)); +} + +void SDL_SYS_TimerQuit(void) +{ + timer_alive = 0; + if ( timer ) { + SDL_WaitThread(timer, NULL); + timer = NULL; + } +} + +int SDL_SYS_StartTimer(void) +{ + SDL_SetError("Internal logic error: threaded timer in use"); + return(-1); +} + +void SDL_SYS_StopTimer(void) +{ + return; +} + +#endif diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 436450e330..65d56a56bd 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -410,6 +410,9 @@ extern VideoBootStrap AALIB_bootstrap; #if SDL_VIDEO_DRIVER_CACA extern VideoBootStrap CACA_bootstrap; #endif +#if SDL_VIDEO_DRIVER_OGC +extern VideoBootStrap OGC_bootstrap; +#endif #if SDL_VIDEO_DRIVER_DUMMY extern VideoBootStrap DUMMY_bootstrap; #endif diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 46285c990e..bf379f4b61 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -126,6 +126,9 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_CACA &CACA_bootstrap, #endif +#if SDL_VIDEO_DRIVER_OGC + &OGC_bootstrap, +#endif #if SDL_VIDEO_DRIVER_DUMMY &DUMMY_bootstrap, #endif diff --git a/src/video/gamecube/SDL_gamecube_events.c b/src/video/gamecube/SDL_gamecube_events.c new file mode 100644 index 0000000000..e44a84a9eb --- /dev/null +++ b/src/video/gamecube/SDL_gamecube_events.c @@ -0,0 +1,13 @@ +#include "SDL_config.h" + + +#include "SDL.h" +#include "../../events/SDL_sysevents.h" +#include "../../events/SDL_events_c.h" + +#include "../ogc/SDL_ogc_video.h" +#include "SDL_gamecube_events_c.h" + +void GAMECUBE_PumpEvents(_THIS) {} + +void GAMECUBE_InitOSKeymap(_THIS) {} diff --git a/src/video/gamecube/SDL_gamecube_events_c.h b/src/video/gamecube/SDL_gamecube_events_c.h new file mode 100644 index 0000000000..5084d26f56 --- /dev/null +++ b/src/video/gamecube/SDL_gamecube_events_c.h @@ -0,0 +1,4 @@ +#include "SDL_config.h" + +extern void GAMECUBE_InitOSKeymap(_THIS); +extern void GAMECUBE_PumpEvents(_THIS); diff --git a/src/video/gamecube/SDL_gamecube_mouse.c b/src/video/gamecube/SDL_gamecube_mouse.c new file mode 100644 index 0000000000..9511d820b0 --- /dev/null +++ b/src/video/gamecube/SDL_gamecube_mouse.c @@ -0,0 +1,8 @@ +#include "SDL_config.h" + +#include "SDL_mouse.h" +#include "../../events/SDL_events_c.h" + +struct WMcursor { + int unused; +}; diff --git a/src/video/ogc/SDL_ogc_video.c b/src/video/ogc/SDL_ogc_video.c new file mode 100644 index 0000000000..69a3842c42 --- /dev/null +++ b/src/video/ogc/SDL_ogc_video.c @@ -0,0 +1,923 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Tantric, 2009 +*/ +#include "SDL_config.h" + +// Standard includes. +#include + +// SDL internal includes. +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "SDL_timer.h" +#include "SDL_thread.h" + +// SDL ogc specifics. +#include +#include +#include +#include +#include +#include "SDL_ogc_video.h" + +#ifdef __wii__ +#include "../wii/SDL_wiievents_c.h" +#endif + +#ifdef __gamecube__ +#include "../gamecube/SDL_gamecube_events_c.h" +#endif + + +#include + +static const char OGCVID_DRIVER_NAME[] = "ogc-video"; +static lwp_t videothread = LWP_THREAD_NULL; +static SDL_mutex *videomutex = NULL; +static SDL_cond *videocond = NULL; +static ogcVideo *current = NULL; + +int vresx=0, vresy=0; + +/*** SDL ***/ +static SDL_Rect mode_320, mode_640; +#ifdef __wii__ +static SDL_Rect mode_848; +#endif + +static SDL_Rect* modes_descending[] = +{ +#ifdef __wii__ + &mode_848, +#endif + &mode_640, + &mode_320, + NULL +}; + + +/*** 2D Video ***/ +#define HASPECT 320 +#define VASPECT 240 + +unsigned char *xfb = NULL; +GXRModeObj* vmode = 0; +static int quit_flip_thread = 0; +static GXTexObj texobj_a, texobj_b; +static GXTlutObj texpalette_a, texpalette_b; + +/*** GX ***/ +#define DEFAULT_FIFO_SIZE 256 * 1024 +static unsigned char gp_fifo[DEFAULT_FIFO_SIZE] __attribute__((aligned(32))); + +/* New texture based scaler */ +typedef struct tagcamera +{ + guVector pos; + guVector up; + guVector view; +} +camera; + +/*** Square Matrix + This structure controls the size of the image on the screen. + Think of the output as a -80 x 80 by -60 x 60 graph. +***/ +static s16 square[] ATTRIBUTE_ALIGN (32) = +{ + /* + * X, Y, Z + * Values set are for roughly 4:3 aspect + */ + -HASPECT, VASPECT, 0, // 0 + HASPECT, VASPECT, 0, // 1 + HASPECT, -VASPECT, 0, // 2 + -HASPECT, -VASPECT, 0 // 3 +}; + +static const f32 tex_pos[] ATTRIBUTE_ALIGN(32) = { + 0.0, 0.0, + 1.0, 0.0, + 1.0, 1.0, + 0.0, 1.0, +}; + +static camera cam = { + {0.0F, 0.0F, 0.0F}, + {0.0F, 0.5F, 0.0F}, + {0.0F, 0.0F, -0.5F} +}; + +/**************************************************************************** + * Scaler Support Functions + ***************************************************************************/ +static int currentwidth; +static int currentheight; +static int currentbpp; + +static void +draw_init(void *palette, void *tex) +{ + Mtx m, mv, view; + + GX_ClearVtxDesc (); + GX_SetVtxDesc (GX_VA_POS, GX_INDEX8); + GX_SetVtxDesc (GX_VA_TEX0, GX_INDEX8); + + GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0); + GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); + + GX_SetArray (GX_VA_POS, square, 3 * sizeof (s16)); + GX_SetArray (GX_VA_TEX0, (void*)tex_pos, 2 * sizeof (f32)); + GX_SetNumTexGens (1); + GX_SetNumChans (0); + + GX_SetTexCoordGen (GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); + + GX_SetTevOp (GX_TEVSTAGE0, GX_REPLACE); + GX_SetTevOrder (GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL); + + memset(&view, 0, sizeof (Mtx)); + guLookAt(view, &cam.pos, &cam.up, &cam.view); + guMtxIdentity(m); + guMtxTransApply(m, m, 0, 0, -100); + guMtxConcat(view, m, mv); + GX_LoadPosMtxImm(mv, GX_PNMTX0); + + GX_InvVtxCache (); // update vertex cache + + if (currentbpp == 8) { + GX_InitTlutObj(&texpalette_a, palette, GX_TL_IA8, 256); + GX_InitTlutObj(&texpalette_b, (Uint16*)palette+256, GX_TL_IA8, 256); + DCStoreRange(palette, sizeof(512*sizeof(Uint16))); + GX_LoadTlut(&texpalette_a, GX_TLUT0); + GX_LoadTlut(&texpalette_b, GX_TLUT1); + + GX_InitTexObjCI(&texobj_a, tex, currentwidth, currentheight, GX_TF_CI8, GX_CLAMP, GX_CLAMP, 0, GX_TLUT0); + GX_InitTexObjCI(&texobj_b, tex, currentwidth, currentheight, GX_TF_CI8, GX_CLAMP, GX_CLAMP, 0, GX_TLUT1); + GX_LoadTexObj(&texobj_b, GX_TEXMAP1); + + // Setup TEV to combine Red+Green and Blue paletted images + GX_SetTevColor(GX_TEVREG0, (GXColor){255, 255, 0, 0}); + GX_SetTevSwapModeTable(GX_TEV_SWAP1, GX_CH_RED, GX_CH_ALPHA, GX_CH_BLUE, GX_CH_ALPHA); + GX_SetTevSwapModeTable(GX_TEV_SWAP2, GX_CH_ALPHA, GX_CH_ALPHA, GX_CH_BLUE, GX_CH_ALPHA); + // first stage = red and green + GX_SetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP1); + GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_C0, GX_CC_ZERO); + // second stage = add blue (and opaque alpha) + GX_SetTevOp(GX_TEVSTAGE1, GX_BLEND); + GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD0, GX_TEXMAP1, GX_COLORNULL); + GX_SetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP2); + GX_SetTevColorIn(GX_TEVSTAGE1, GX_CC_TEXC, GX_CC_ZERO, GX_CC_ZERO, GX_CC_CPREV); + GX_SetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_KONST); + + GX_SetNumTevStages(2); + } + else if (currentbpp == 16) + GX_InitTexObj(&texobj_a, tex, currentwidth, currentheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); + else + GX_InitTexObj(&texobj_a, tex, currentwidth, currentheight, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); + + GX_LoadTexObj(&texobj_a, GX_TEXMAP0); // load texture object so its ready to use +} + +static inline void +draw_vert (u8 index) +{ + GX_Position1x8 (index); + GX_TexCoord1x8 (index); +} + +static inline void +draw_square () +{ + GX_Begin(GX_QUADS, GX_VTXFMT0, 4); + draw_vert(0); + draw_vert(1); + draw_vert(2); + draw_vert(3); + GX_End(); +} + +static void * flip_thread (void *arg) +{ + u32 *tex = (u32*)arg; + + GX_SetCurrentGXThread(); + + // clear EFB + GX_CopyDisp(xfb, GX_TRUE); + + SDL_mutexP(videomutex); + + while(!quit_flip_thread) + { + // update texture + DCStoreRange((void*)tex[0], tex[1]); + // clear texture objects + GX_InvalidateTexAll(); + draw_square(); // render textured quad + + VIDEO_WaitVSync(); + GX_CopyDisp(xfb, GX_FALSE); + + GX_DrawDone(); + + SDL_CondWait(videocond, videomutex); + } + SDL_mutexV(videomutex); + + return NULL; +} + +static void +SetupGX() +{ + Mtx44 p; + int df = 1; // deflicker on/off + + GX_SetCurrentGXThread(); + GX_SetViewport (0, 0, vmode->fbWidth, vmode->efbHeight, 0, 1); + GX_SetDispCopyYScale ((f32) vmode->xfbHeight / (f32) vmode->efbHeight); + GX_SetScissor (0, 0, vmode->fbWidth, vmode->efbHeight); + + GX_SetDispCopySrc(0, 0, vmode->fbWidth, vmode->efbHeight); + GX_SetDispCopyDst(vmode->fbWidth, vmode->xfbHeight); + GX_SetCopyFilter (vmode->aa, vmode->sample_pattern, (df == 1) ? GX_TRUE : GX_FALSE, vmode->vfilter); + + GX_SetFieldMode (vmode->field_rendering, ((vmode->viHeight == 2 * vmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); + GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR); + GX_SetDispCopyGamma (GX_GM_1_0); + GX_SetCullMode (GX_CULL_NONE); + GX_SetBlendMode(GX_BM_NONE,GX_BL_DSTALPHA,GX_BL_INVSRCALPHA,GX_LO_CLEAR); + + GX_SetZMode (GX_FALSE, GX_LEQUAL, GX_TRUE); + GX_SetColorUpdate (GX_TRUE); + GX_SetAlphaUpdate(GX_FALSE); + + guOrtho(p, VASPECT, -VASPECT, -HASPECT, HASPECT, 100, 1000); // matrix, t, b, l, r, n, f + GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC); + GX_Flush(); +} + +static void +StartVideoThread(void *args) +{ + if(videothread == LWP_THREAD_NULL) + { + quit_flip_thread = 0; + LWP_CreateThread(&videothread, flip_thread, args, NULL, 0, 68); + } +} + +void OGC_VideoStart(ogcVideo *private, Uint32 flags) +{ + if (private==NULL) { + if (current==NULL) + return; + private = current; + } + + SetupGX(); + draw_init(private->palette, private->texturemem); + if (!(flags & SDL_OPENGL)) { + StartVideoThread(&private->texturemem); + } +#ifdef __wii__ + WPAD_SetVRes(WPAD_CHAN_0, vresx+vresx/4, vresy+vresy/4); +#endif + current = private; +} + +void OGC_VideoStop() +{ + if(videothread == LWP_THREAD_NULL) + return; + + SDL_LockMutex(videomutex); + quit_flip_thread = 1; + SDL_CondSignal(videocond); + SDL_UnlockMutex(videomutex); + + LWP_JoinThread(videothread, NULL); + videothread = LWP_THREAD_NULL; +} + +static int OGC_VideoInit(_THIS, SDL_PixelFormat *vformat) +{ + // Set up the modes. +#ifdef __wii__ + mode_848.w = 848; + mode_848.h = 480; +#endif + mode_640.w = 640; + mode_640.h = 480; + mode_320.w = 320; + mode_320.h = 240; + + // Set the current format. + vformat->BitsPerPixel = 16; + vformat->BytesPerPixel = 2; + + this->hidden->buffer = NULL; + this->hidden->texturemem = NULL; + this->hidden->width = 0; + this->hidden->height = 0; + this->hidden->pitch = 0; + + this->gl_config.driver_loaded = 1; + this->gl_config.driver_path[0] = '\0'; + + /* We're done! */ + return 0; +} + +static SDL_Rect **OGC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) +{ + return modes_descending; +} + +static SDL_Surface *OGC_SetVideoMode(_THIS, SDL_Surface *current, + int width, int height, int bpp, Uint32 flags) +{ + SDL_Rect* mode; + size_t bytes_per_pixel; + Uint32 r_mask = 0; + Uint32 b_mask = 0; + Uint32 g_mask = 0; + + // Find a mode big enough to store the requested resolution + mode = modes_descending[0]; + while (mode) + { + if (mode->w == width && mode->h == height) + break; + else + ++mode; + } + + // Didn't find a mode? + if (!mode) + { + SDL_SetError("Display mode (%dx%d) is unsupported.", + width, height); + return NULL; + } + + if(bpp != 8 && bpp != 16 && bpp != 24 && bpp != 32) + { + SDL_SetError("Resolution (%d bpp) is unsupported (8/16/24/32 bpp only).", + bpp); + return NULL; + } + + bytes_per_pixel = bpp / 8; + + OGC_VideoStop(); + + free(this->hidden->buffer); + free(this->hidden->texturemem); + + // Allocate the new buffer. + this->hidden->buffer = memalign(32, width * height * bytes_per_pixel); + if (!this->hidden->buffer ) + { + this->hidden->texturemem = NULL; + SDL_SetError("Couldn't allocate buffer for requested mode"); + return(NULL); + } + + // Allocate texture memory + if (bytes_per_pixel > 2) + this->hidden->texturemem_size = width * height * 4; + else + this->hidden->texturemem_size = width * height * bytes_per_pixel; + + this->hidden->texturemem = memalign(32, this->hidden->texturemem_size); + if (this->hidden->texturemem == NULL) + { + free(this->hidden->buffer); + this->hidden->buffer = NULL; + SDL_SetError("Couldn't allocate memory for texture"); + return NULL; + } + + // Allocate the new pixel format for the screen + if (!SDL_ReallocFormat(current, bpp, r_mask, g_mask, b_mask, 0)) + { + free(this->hidden->buffer); + this->hidden->buffer = NULL; + free(this->hidden->texturemem); + this->hidden->texturemem = NULL; + + SDL_UnlockMutex(videomutex); + SDL_SetError("Couldn't allocate new pixel format for requested mode"); + return NULL; + } + + // Clear the buffer + SDL_memset(this->hidden->buffer, 0, width * height * bytes_per_pixel); + SDL_memset(this->hidden->texturemem, 0, this->hidden->texturemem_size); + + // Set up the new mode framebuffer + current->flags = flags & (SDL_FULLSCREEN | SDL_HWPALETTE | SDL_NOFRAME | SDL_OPENGL); + // Our surface is always double buffered + current->flags |= SDL_PREALLOC | SDL_DOUBLEBUF; + current->w = width; + current->h = height; + current->pitch = current->w * bytes_per_pixel; + current->pixels = this->hidden->buffer; + + /* Set the hidden data */ + this->hidden->width = current->w; + this->hidden->height = current->h; + this->hidden->pitch = current->w * (bytes_per_pixel > 2 ? 4 : bytes_per_pixel); + + currentwidth = current->w; + currentheight = current->h; + currentbpp = bpp; + vresx = currentwidth; + vresy = currentheight; + + OGC_VideoStart(this->hidden, flags); + + return current; +} + +/* We don't actually allow hardware surfaces other than the main one */ +static int OGC_AllocHWSurface(_THIS, SDL_Surface *surface) +{ + return(-1); +} + +static void OGC_FreeHWSurface(_THIS, SDL_Surface *surface) +{ + return; +} + +static int OGC_LockHWSurface(_THIS, SDL_Surface *surface) +{ + return(0); +} + +static void OGC_UnlockHWSurface(_THIS, SDL_Surface *surface) +{ + return; +} + +static inline void Set_RGBAPixel(_THIS, int x, int y, u32 color) +{ + u8 *truc = this->hidden->texturemem; + int width = this->hidden->width; + u32 offset; + + offset = (((y >> 2) << 4) * width) + ((x >> 2) << 6) + ((((y & 3) << 2) + (x & 3)) << 1); + + *(truc + offset) = color; + *(truc + offset + 1) = color >> 24; + *(truc + offset + 32) = color >> 16; + *(truc + offset + 33) = color >> 8; +} + +static inline void Set_RGB565Pixel(_THIS, int x, int y, u16 color) +{ + u8 *truc = this->hidden->texturemem; + int width = this->hidden->width; + u32 offset; + + offset = (((y >> 2) << 3) * width) + ((x >> 2) << 5) + ((((y & 3) << 2) + (x & 3)) << 1); + + *(truc + offset) = color >> 8; + *(truc + offset + 1) = color; +} + +static inline void Set_PalPixel(_THIS, int x, int y, u8 color) +{ + u8 *truc = this->hidden->texturemem; + int width = this->hidden->pitch; + u32 offset; + + offset = ((y & ~3) * width) + ((x & ~7) << 2) + ((y & 3) << 3) + (x & 7); + + truc[offset] = color; +} + +static void UpdateRect_8(_THIS, SDL_Rect *rect) +{ + u8 *src; + u8 color; + int i, j; + + for (i = 0; i < rect->h; i++) + { + src = (this->hidden->buffer + (this->hidden->width * (i + rect->y)) + rect->x); + for (j = 0; j < rect->w; j++) + { + color = src[j]; + Set_PalPixel(this, rect->x + j, rect->y + i, color); + } + } +} + +static void UpdateRect_16(_THIS, SDL_Rect *rect) +{ + u8 *src; + u8 *ptr; + u16 color; + int i, j; + for (i = 0; i < rect->h; i++) + { + src = (this->hidden->buffer + (this->hidden->width * 2 * (i + rect->y)) + (rect->x * 2)); + for (j = 0; j < rect->w; j++) + { + ptr = src + (j * 2); + color = (ptr[0] << 8) | ptr[1]; + Set_RGB565Pixel(this, rect->x + j, rect->y + i, color); + } + } +} + +static void UpdateRect_24(_THIS, SDL_Rect *rect) +{ + u8 *src; + u8 *ptr; + u32 color; + int i, j; + for (i = 0; i < rect->h; i++) + { + src = (this->hidden->buffer + (this->hidden->width * 3 * (i + rect->y)) + (rect->x * 3)); + for (j = 0; j < rect->w; j++) + { + ptr = src + (j * 3); + color = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | 0xff; + Set_RGBAPixel(this, rect->x + j, rect->y + i, color); + } + } +} + +static void UpdateRect_32(_THIS, SDL_Rect *rect) +{ + u8 *src; + u8 *ptr; + u32 color; + int i, j; + for (i = 0; i < rect->h; i++) + { + src = (this->hidden->buffer + (this->hidden->width * 4 * (i + rect->y)) + (rect->x * 4)); + for (j = 0; j < rect->w; j++) + { + ptr = src + (j * 4); + color = (ptr[1] << 24) | (ptr[2] << 16) | (ptr[3] << 8) | ptr[0]; + Set_RGBAPixel(this, rect->x + j, rect->y + i, color); + } + } +} + +static void flipHWSurface_16_16(_THIS, const SDL_Surface* const surface) +{ + int h, w; + long long int *dst = (long long int *) this->hidden->texturemem; + long long int *src1 = (long long int *) this->hidden->buffer; + long long int *src2 = (long long int *) (this->hidden->buffer + (this->hidden->pitch * 1)); + long long int *src3 = (long long int *) (this->hidden->buffer + (this->hidden->pitch * 2)); + long long int *src4 = (long long int *) (this->hidden->buffer + (this->hidden->pitch * 3)); + int rowpitch = (this->hidden->pitch >> 3) * 3; + + SDL_mutexP(videomutex); + for (h = 0; h < this->hidden->height; h += 4) + { + for (w = 0; w < this->hidden->pitch; w += 8) + { + *dst++ = *src1++; + *dst++ = *src2++; + *dst++ = *src3++; + *dst++ = *src4++; + } + + src1 = src4; + src2 += rowpitch; + src3 += rowpitch; + src4 += rowpitch; + } + SDL_CondSignal(videocond); + SDL_mutexV(videomutex); +} + +static void OGC_UpdateRect(_THIS, SDL_Rect *rect) +{ + const SDL_Surface* const screen = this->screen; + + switch(screen->format->BytesPerPixel) { + case 1: + UpdateRect_8(this, rect); + break; + case 2: + UpdateRect_16(this, rect); + break; + case 3: + UpdateRect_24(this, rect); + break; + case 4: + UpdateRect_32(this, rect); + break; + default: + fprintf(stderr, "Invalid BPP %d\n", screen->format->BytesPerPixel); + break; + } +} + +static void OGC_UpdateRects(_THIS, int numrects, SDL_Rect *rects) +{ + int i; + + // note that this function doesn't lock - we don't care if this isn't + // rendered now, that's what Flip is for + + for (i = 0; i < numrects; i++) + { + OGC_UpdateRect(this, rects+i); + } + + SDL_CondSignal(videocond); +} + +static void flipHWSurface_24_16(_THIS, SDL_Surface *surface) +{ + SDL_Rect screen_rect = {0, 0, this->hidden->width, this->hidden->height}; + OGC_UpdateRects(this, 1, &screen_rect); +} + +static void flipHWSurface_32_16(_THIS, SDL_Surface *surface) +{ + SDL_Rect screen_rect = {0, 0, this->hidden->width, this->hidden->height}; + OGC_UpdateRects(this, 1, &screen_rect); +} + +static int OGC_FlipHWSurface(_THIS, SDL_Surface *surface) +{ + switch(surface->format->BytesPerPixel) + { + case 1: + case 2: + // 8 and 16 bit use the same tile format + flipHWSurface_16_16(this, surface); + break; + case 3: + flipHWSurface_24_16(this, surface); + break; + case 4: + flipHWSurface_32_16(this, surface); + break; + default: + return -1; + } + return 0; +} + +static int OGC_SetColors(_THIS, int first_color, int color_count, SDL_Color *colors) +{ + const int last_color = first_color + color_count; + Uint16* const palette = this->hidden->palette; + int component; + + SDL_LockMutex(videomutex); + + /* Build the RGB24 palette. */ + for (component = first_color; component != last_color; ++component, ++colors) + { + palette[component] = (colors->g << 8) | colors->r; + palette[component+256] = colors->b; + } + + DCStoreRangeNoSync(palette+first_color, color_count*sizeof(Uint16)); + DCStoreRange(palette+first_color+256, color_count*sizeof(Uint16)); + GX_LoadTlut(&texpalette_a, GX_TLUT0); + GX_LoadTlut(&texpalette_b, GX_TLUT1); + GX_LoadTexObj(&texobj_a, GX_TEXMAP0); + GX_LoadTexObj(&texobj_b, GX_TEXMAP1); + + SDL_UnlockMutex(videomutex); + + return(1); +} + +static void OGC_VideoQuit(_THIS) +{ + OGC_VideoStop(); + GX_AbortFrame(); + GX_Flush(); + + current = NULL; + + VIDEO_SetBlack(TRUE); + VIDEO_Flush(); + + free(this->hidden->buffer); + this->hidden->buffer = NULL; + free(this->hidden->texturemem); + this->hidden->texturemem = NULL; +} + +static void OGC_DeleteDevice(SDL_VideoDevice *device) +{ + free(device->hidden); + SDL_free(device); + + SDL_DestroyCond(videocond); + videocond = 0; + SDL_DestroyMutex(videomutex); + videomutex=0; +} + +/* Weak symbols for the opengx functions used by SDL, so that the client does + * not need to link to opengx, unless it actually uses OpenGL. */ +void __attribute__((weak)) ogx_initialize(void) +{ +} + +void __attribute__((weak)) *ogx_get_proc_address(const char *) +{ + return NULL; +} + +int SDL_OGC_GL_LoadLibrary(_THIS, const char *path) +{ + return 0; +} + +void *SDL_OGC_GL_GetProcAddress(_THIS, const char *proc) +{ + void *ptr = ogx_get_proc_address(proc); + if (!ptr) { + fprintf(stderr, "GetProcAddress %s\n", proc); + } + return ptr; +} + +int SDL_OGC_GL_MakeCurrent(_THIS) +{ + ogx_initialize(); + return 0; +} + +void SDL_OGC_GL_SwapBuffers(_THIS) +{ + VIDEO_WaitVSync(); + GX_CopyDisp(xfb, GX_FALSE); + + GX_DrawDone(); +} + +static SDL_VideoDevice *OGC_CreateDevice(int devindex) +{ + SDL_VideoDevice *device; + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); + if ( device ) { + SDL_memset(device, 0, (sizeof *device)); + device->hidden = (struct SDL_PrivateVideoData *) + memalign(32, sizeof(struct SDL_PrivateVideoData)); + } + if ( (device == NULL) || (device->hidden == NULL) ) { + SDL_OutOfMemory(); + if ( device ) { + SDL_free(device); + } + return(0); + } + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + + videomutex = SDL_CreateMutex(); + videocond = SDL_CreateCond(); + + /* Set the function pointers */ + device->VideoInit = OGC_VideoInit; + device->ListModes = OGC_ListModes; + device->SetVideoMode = OGC_SetVideoMode; + device->SetColors = OGC_SetColors; + device->UpdateRects = OGC_UpdateRects; + device->VideoQuit = OGC_VideoQuit; + device->AllocHWSurface = OGC_AllocHWSurface; + device->LockHWSurface = OGC_LockHWSurface; + device->UnlockHWSurface = OGC_UnlockHWSurface; + device->FlipHWSurface = OGC_FlipHWSurface; + device->FreeHWSurface = OGC_FreeHWSurface; +#ifdef __wii__ + device->InitOSKeymap = WII_InitOSKeymap; + device->PumpEvents = WII_PumpEvents; +#endif +#ifdef __gamecube__ + device->InitOSKeymap = GAMECUBE_InitOSKeymap; + device->PumpEvents = GAMECUBE_PumpEvents; +#endif + device->input_grab = SDL_GRAB_ON; + + device->GL_LoadLibrary = SDL_OGC_GL_LoadLibrary; + device->GL_GetProcAddress = SDL_OGC_GL_GetProcAddress; + device->GL_MakeCurrent = SDL_OGC_GL_MakeCurrent; + device->GL_SwapBuffers = SDL_OGC_GL_SwapBuffers; + + device->free = OGC_DeleteDevice; + + OGC_InitVideoSystem(); + return device; +} + +static int OGC_Available(void) +{ + return(1); +} + +VideoBootStrap OGC_bootstrap = { + OGCVID_DRIVER_NAME, "ogc video driver", + OGC_Available, OGC_CreateDevice +}; + +void +OGC_InitVideoSystem() +{ + /* Initialise the video system */ + VIDEO_Init(); + vmode = VIDEO_GetPreferredMode(NULL); + + /* Set up the video system with the chosen mode */ + if (vmode == &TVPal528IntDf) + vmode = &TVPal576IntDfScale; + + VIDEO_Configure(vmode); + + // Allocate the video buffer + if (xfb) free(MEM_K1_TO_K0(xfb)); + xfb = (unsigned char*) MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode)); + + VIDEO_ClearFrameBuffer(vmode, xfb, COLOR_BLACK); + VIDEO_SetNextFramebuffer(xfb); + + // Show the screen. + VIDEO_SetBlack(FALSE); + VIDEO_Flush(); + VIDEO_WaitVSync(); VIDEO_WaitVSync(); + + //CON_Init(xfb,20,20,vmode->fbWidth,vmode->xfbHeight,vmode->fbWidth*VI_DISPLAY_PIX_SZ); + + /*** Clear out FIFO area ***/ + memset(&gp_fifo, 0, DEFAULT_FIFO_SIZE); + + /*** Initialise GX ***/ + GX_Init(&gp_fifo, DEFAULT_FIFO_SIZE); + + GXColor background = { 0, 0, 0, 0xff }; + GX_SetCopyClear (background, GX_MAX_Z24); + + SetupGX(); +} + +void OGC_SetWidescreen(int wide) +{ + int width; + if(wide) { + width = 678; + } + else + width = 640; + + vmode->viWidth = width; + vmode->viXOrigin = (VI_MAX_WIDTH_NTSC - width) / 2; + + VIDEO_Configure (vmode); + + if (xfb) + VIDEO_ClearFrameBuffer(vmode, xfb, COLOR_BLACK); + + VIDEO_Flush(); + + VIDEO_WaitVSync(); VIDEO_WaitVSync(); +} + +void OGC_ChangeSquare(int xscale, int yscale, int xshift, int yshift) +{ + square[6] = square[3] = xscale + xshift; + square[0] = square[9] = -xscale + xshift; + square[4] = square[1] = yscale - yshift; + square[7] = square[10] = -yscale - yshift; + DCFlushRange (square, 32); // update memory BEFORE the GPU accesses it! + GX_InvVtxCache(); +} diff --git a/src/video/ogc/SDL_ogc_video.h b/src/video/ogc/SDL_ogc_video.h new file mode 100644 index 0000000000..a86ad89b45 --- /dev/null +++ b/src/video/ogc/SDL_ogc_video.h @@ -0,0 +1,37 @@ +#include "SDL_config.h" + +#ifndef _SDL_ogc_video_h +#define _SDL_ogc_video_h + +/* SDL internal includes */ +#include "../SDL_sysvideo.h" + +/* OGC includes */ +#include + +/* Hidden "this" pointer for the video functions */ +#define _THIS SDL_VideoDevice *this + +/* Private display data */ +typedef struct SDL_PrivateVideoData +{ + // 2x256x16bit palettes = 1x256x24(32)bit palette + // first 256 entries are for Red/Green + // last 256 entries are for Green + Uint16 palette[2*256]; + + Uint8* buffer; + + // these two fields MUST be in this order + Uint8* texturemem; + size_t texturemem_size; + + int width; + int height; + int pitch; +} ogcVideo; + +void OGC_InitVideoSystem(); +void OGC_ChangeSquare(int xscale, int yscale, int xshift, int yshift); + +#endif /* _SDL_wiivideo_h */ diff --git a/src/video/wii/SDL_wiievents.c b/src/video/wii/SDL_wiievents.c new file mode 100644 index 0000000000..2688bda3f2 --- /dev/null +++ b/src/video/wii/SDL_wiievents.c @@ -0,0 +1,264 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + + Yohanes Nugroho (yohanes@gmail.com) + Tantric +*/ +#include "SDL_config.h" + +#include "../../events/SDL_sysevents.h" +#include "../../events/SDL_events_c.h" +#include +#include +#include +#include +#include +#include + +#include "SDL_wiievents_c.h" + +static SDLKey keymap[232]; + +static int posted; + +extern bool TerminateRequested; +extern void Terminate(); +extern int vresx, vresy; + +void PumpEvents() +{ + s32 stat; +#ifdef HW_RVL + keyboard_event ke; + mouse_event me; + + if (TerminateRequested) Terminate(); +#endif + + // this will only work if Joystick 0 has been opened and has been polled + WPADData *wd = WPAD_Data(WPAD_CHAN_0); + + static Uint8 lastButtonStateA = SDL_RELEASED; + static Uint8 lastButtonStateB = SDL_RELEASED; + + Uint8 stateA = (wd->btns_h & WPAD_BUTTON_A) ? SDL_PRESSED : SDL_RELEASED; + Uint8 stateB = (wd->btns_h & WPAD_BUTTON_B) ? SDL_PRESSED : SDL_RELEASED; + + if (stateA != lastButtonStateA) + { + lastButtonStateA = stateA; + posted += SDL_PrivateMouseButton(stateA, SDL_BUTTON_LEFT, 0, 0); + } + + if (stateB != lastButtonStateB) + { + lastButtonStateB = stateB; + posted += SDL_PrivateMouseButton(stateB, SDL_BUTTON_RIGHT, 0, 0); + } + + + if (wd && wd->exp.type != WPAD_EXP_CLASSIC && wd->ir.valid) { + + // use SDL_BUTTON_X2 to signal that this is the wiimote acting as a mouse + Uint8 Buttons = SDL_GetMouseState(NULL, NULL)|SDL_BUTTON_X2MASK; + + if (wd->ir.x < vresx/8) + wd->ir.x = vresx/8; + else if (wd->ir.x > (vresx + vresx/8)) + wd->ir.x = vresx + vresx/8; + if (wd->ir.y < vresy/8) + wd->ir.y = vresy/8; + else if (wd->ir.y > (vresy + vresy/8)) + wd->ir.y = vresy + vresy/8; + posted += SDL_PrivateMouseMotion(Buttons, 0, wd->ir.x - vresx/8, wd->ir.y - vresy/8); + // most apps will ignore this (hopefully) + posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_X2, 0, 0); + wd->ir.valid = 0; + } + + stat = KEYBOARD_GetEvent(&ke); + if (stat && (ke.type == KEYBOARD_RELEASED || ke.type == KEYBOARD_PRESSED)) + { + SDL_keysym keysym; + memset(&keysym, 0, sizeof(keysym)); + Uint8 keystate = (ke.type == KEYBOARD_PRESSED) ? SDL_PRESSED : SDL_RELEASED; + keysym.sym = keymap[ke.keycode]; + keysym.unicode = ke.symbol; + keysym.mod = 0; + posted += SDL_PrivateKeyboard(keystate, &keysym); + } + + stat = MOUSE_GetEvent(&me); + if (stat) + { + u8 button = me.button; + Uint8 mouse_state = SDL_GetMouseState(NULL, NULL); + + posted += SDL_PrivateMouseMotion(0, 1, me.rx*2, me.ry*2); + + if (button & 0x1) { + if (!(mouse_state & SDL_BUTTON_LMASK)) + posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); + } + else if (mouse_state & SDL_BUTTON_LMASK) + posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); + + if (button & 0x2) { + if (!(mouse_state & SDL_BUTTON_RMASK)) + posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0); + } + else if (mouse_state & SDL_BUTTON_RMASK) + posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0); + + if (button & 0x4) { + if (!(mouse_state & SDL_BUTTON_MMASK)) + posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0); + } + else if (mouse_state & SDL_BUTTON_MMASK) + posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0); + + // mouse wheel actions are single events (rz==1(up) or rz==-1(down)) + // send SDL_PRESSED immediately followed by SDL_RELEASED + if (me.rz > 0) { + posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0); + posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0); + } + else if (me.rz < 0) { + posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0); + posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0); + } + } +} + +void WII_PumpEvents(_THIS) +{ + do + { + posted = 0; + PumpEvents(); + usleep(100); + } while (posted); +} + +void WII_InitOSKeymap(_THIS) +{ + int i; + + for (i = 0; i < 232; ++i) + keymap[i] = SDLK_UNKNOWN; + + // a-z + for (i = 0; i < 27; i++) + keymap[4 + i] = SDLK_a + i; + + // 1-9 + for (i = 0; i < 9; i++) + keymap[30 + i] = SDLK_1 + i; + + keymap[39] = SDLK_0; + keymap[40] = SDLK_RETURN; + keymap[41] = SDLK_ESCAPE; + keymap[42] = SDLK_BACKSPACE; + keymap[43] = SDLK_TAB; + keymap[44] = SDLK_SPACE; + keymap[45] = SDLK_MINUS; + keymap[46] = SDLK_EQUALS; + keymap[47] = SDLK_LEFTBRACKET; + keymap[48] = SDLK_RIGHTBRACKET; + keymap[49] = SDLK_BACKSLASH; + keymap[50] = SDLK_UNKNOWN; // unused + keymap[51] = SDLK_SEMICOLON; + keymap[52] = SDLK_QUOTE; + keymap[53] = SDLK_BACKQUOTE; + keymap[54] = SDLK_COMMA; + keymap[55] = SDLK_PERIOD; + keymap[56] = SDLK_SLASH; + keymap[57] = SDLK_CAPSLOCK; + + // F1 to F12 + for (i = 0; i < 12; i++) + keymap[58 + i] = SDLK_F1 + i; + + keymap[70] = SDLK_PRINT; + keymap[71] = SDLK_SCROLLOCK; + keymap[72] = SDLK_PAUSE; + keymap[73] = SDLK_INSERT; + keymap[74] = SDLK_HOME; + keymap[75] = SDLK_PAGEUP; + keymap[76] = SDLK_DELETE; + keymap[77] = SDLK_END; + keymap[78] = SDLK_PAGEDOWN; + + keymap[79] = SDLK_RIGHT; + keymap[80] = SDLK_LEFT; + keymap[81] = SDLK_DOWN; + keymap[82] = SDLK_UP; + keymap[83] = SDLK_NUMLOCK; + + keymap[84] = SDLK_KP_DIVIDE; + keymap[85] = SDLK_KP_MULTIPLY; + keymap[86] = SDLK_KP_MINUS; + keymap[87] = SDLK_KP_PLUS; + + keymap[88] = SDLK_KP_ENTER; + + // keypad 1-9 + for (i = 0; i < 9; i++) + keymap[89 + i] = SDLK_KP1 + i; + + keymap[98] = SDLK_KP0; + keymap[99] = SDLK_KP_PERIOD; + keymap[100] = SDLK_UNKNOWN; // unused + keymap[101] = SDLK_UNKNOWN; // Applic + keymap[102] = SDLK_POWER; + keymap[103] = SDLK_KP_EQUALS; + keymap[104] = SDLK_F13; + keymap[105] = SDLK_F14; + keymap[106] = SDLK_F15; + keymap[107] = SDLK_UNKNOWN; // F16 + keymap[108] = SDLK_UNKNOWN; // F17 + keymap[109] = SDLK_UNKNOWN; // F18 + keymap[110] = SDLK_UNKNOWN; // F19 + keymap[111] = SDLK_UNKNOWN; // F20 + keymap[112] = SDLK_UNKNOWN; // F21 + keymap[113] = SDLK_UNKNOWN; // F22 + keymap[114] = SDLK_UNKNOWN; // F23 + keymap[115] = SDLK_UNKNOWN; // F24 + keymap[116] = SDLK_UNKNOWN; // Execute + keymap[117] = SDLK_HELP; + keymap[118] = SDLK_MENU; + keymap[119] = SDLK_UNKNOWN; // Select + keymap[120] = SDLK_UNKNOWN; // Stop + keymap[121] = SDLK_UNKNOWN; // Again + keymap[122] = SDLK_UNDO; + + keymap[134] = SDLK_KP_EQUALS; + // 135-143 - International + // 144-152 - Language + keymap[154] = SDLK_SYSREQ; + + keymap[224] = SDLK_LCTRL; + keymap[225] = SDLK_LSHIFT; + keymap[226] = SDLK_LALT; + keymap[227] = SDLK_LMETA; + keymap[228] = SDLK_RCTRL; + keymap[229] = SDLK_RSHIFT; + keymap[230] = SDLK_RALT; + keymap[231] = SDLK_RMETA; +} diff --git a/src/video/wii/SDL_wiievents_c.h b/src/video/wii/SDL_wiievents_c.h new file mode 100644 index 0000000000..030cb06c09 --- /dev/null +++ b/src/video/wii/SDL_wiievents_c.h @@ -0,0 +1,33 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "../ogc/SDL_ogc_video.h" + +/* Variables and functions exported by SDL_sysevents.c to other parts + of the native video subsystem (SDL_sysvideo.c) +*/ +extern void WII_InitOSKeymap(_THIS); +extern void WII_PumpEvents(_THIS); + +/* end of SDL_wiievents_c.h ... */ + diff --git a/src/video/wii/SDL_wiimouse.c b/src/video/wii/SDL_wiimouse.c new file mode 100644 index 0000000000..cd41fbf7b6 --- /dev/null +++ b/src/video/wii/SDL_wiimouse.c @@ -0,0 +1,33 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_mouse.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_wiimouse_c.h" + + +/* The implementation dependent data for the window manager cursor */ +struct WMcursor { + int unused; +}; diff --git a/src/video/wii/SDL_wiimouse_c.h b/src/video/wii/SDL_wiimouse_c.h new file mode 100644 index 0000000000..b4c260e6f1 --- /dev/null +++ b/src/video/wii/SDL_wiimouse_c.h @@ -0,0 +1,26 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "../ogc/SDL_ogc_video.h" + +/* Functions to be exported */ diff --git a/src/video/wincommon/SDL_sysevents.c b/src/video/wincommon/SDL_sysevents.c index 090f6f161c..76c67a1ccd 100644 --- a/src/video/wincommon/SDL_sysevents.c +++ b/src/video/wincommon/SDL_sysevents.c @@ -310,8 +310,8 @@ LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if ( WINDIB_FULLSCREEN() ) { appstate |= SDL_APPMOUSEFOCUS; SDL_RestoreDesktopMode(); - /* A fullscreen app gets hidden but will not get a minimize event */ - appstate |= (SDL_APPACTIVE | SDL_APPMOUSEFOCUS); + /* A fullscreen app gets hidden but will not get a minimize event */ + appstate |= (SDL_APPACTIVE | SDL_APPMOUSEFOCUS); #if defined(_WIN32_WCE) LoadAygshell(); if( SHFullScreen ) ================================================ FILE: gamecube/SDL/config.site ================================================ ac_cv_header_signal=no ac_cv_header_signal_h=no ac_cv_func_sigaction=no ac_cv_func_iconv=no ================================================ FILE: gamecube/SDL2/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=gamecube-sdl2 pkgver=2.28.5 pkgrel=17 pkgdesc="A library for portable low-level access to a video framebuffer, audio output, mouse, and keyboard" arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) makedepends=('wii-pkg-config' 'dkp-toolchain-vars') depends=('gamecube-opengx' 'libogc') source=("${url}/release/SDL2-${pkgver}.tar.gz" "SDL2-${pkgver}.patch") groups=('gamecube-portlibs' 'gamecube-sdl2-libs') build() { cd SDL2-$pkgver patch -Np1 -i $srcdir/SDL2-${pkgver}.patch /opt/devkitpro/portlibs/gamecube/bin/powerpc-eabi-cmake -S. -B _build -DCMAKE_BUILD_TYPE=Release -G Ninja cmake --build _build --parallel } package() { cd SDL2-$pkgver DESTDIR=${pkgdir} cmake --install _build } sha256sums=('332cb37d0be20cb9541739c61f79bae5a477427d79ae85e352089afdaf6666e4' '605c3065e6848a7f9754229ef675e10f9a5d9f99d8a1f46eea147c85d6e62d94') ================================================ FILE: gamecube/SDL2/SDL2-2.28.5.patch ================================================ diff --git a/.github/workflows/ngc.yml b/.github/workflows/ngc.yml new file mode 100644 index 0000000000..aeaf6b9269 --- /dev/null +++ b/.github/workflows/ngc.yml @@ -0,0 +1,47 @@ +name: Build (Nintendo GameCube) + +on: [push, pull_request] + +jobs: + ngcn: + runs-on: ubuntu-latest + container: + image: devkitpro/devkitppc:latest + steps: + - uses: actions/checkout@v4 + - name: Install build requirements + run: | + apt update + apt install ninja-build + - name: Configure CMake + run: | + /opt/devkitpro/portlibs/gamecube/bin/powerpc-eabi-cmake -S . -B build -G Ninja \ + -DCMAKE_INSTALL_PREFIX=prefix + - name: Build + run: cmake --build build --verbose --parallel + - name: Install CMake + run: | + echo "SDL2_DIR=$(pwd)/prefix" >> $GITHUB_ENV + cmake --install build/ + ( cd prefix; find ) | LC_ALL=C sort -u + - name: Verify CMake configuration files + run: | + /opt/devkitpro/portlibs/gamecube/bin/powerpc-eabi-cmake -S cmake/test -B cmake_config_build -G Ninja \ + -DTEST_SHARED=FALSE \ + -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} \ + -DCMAKE_BUILD_TYPE=Release + cmake --build cmake_config_build --verbose + - name: Extract CC/CXX/CFLAGS/CXXFLAGS from CMake toolchain + run: | + /opt/devkitpro/portlibs/gamecube/bin/powerpc-eabi-cmake -S .github/cmake -B /tmp/cmake_extract \ + -DCMAKE_BUILD_TYPE=Release \ + -DVAR_PATH=/tmp/ngc_env.txt + cat /tmp/ngc_env.txt >> $GITHUB_ENV + - name: Verify sdl2-config + run: | + export PATH=${{ env.SDL2_DIR }}/bin:$PATH + cmake/test/test_sdlconfig.sh + - name: Verify sdl2.pc + run: | + export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig + cmake/test/test_pkgconfig.sh diff --git a/.github/workflows/nwii.yml b/.github/workflows/nwii.yml new file mode 100644 index 0000000000..625de93b93 --- /dev/null +++ b/.github/workflows/nwii.yml @@ -0,0 +1,47 @@ +name: Build (Nintendo Wii) + +on: [push, pull_request] + +jobs: + nwii: + runs-on: ubuntu-latest + container: + image: devkitpro/devkitppc:latest + steps: + - uses: actions/checkout@v4 + - name: Install build requirements + run: | + apt update + apt install ninja-build + - name: Configure CMake + run: | + /opt/devkitpro/portlibs/wii/bin/powerpc-eabi-cmake -S . -B build -G Ninja \ + -DCMAKE_INSTALL_PREFIX=prefix + - name: Build + run: cmake --build build --verbose --parallel + - name: Install CMake + run: | + echo "SDL2_DIR=$(pwd)/prefix" >> $GITHUB_ENV + cmake --install build/ + ( cd prefix; find ) | LC_ALL=C sort -u + - name: Verify CMake configuration files + run: | + /opt/devkitpro/portlibs/wii/bin/powerpc-eabi-cmake -S cmake/test -B cmake_config_build -G Ninja \ + -DTEST_SHARED=FALSE \ + -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} \ + -DCMAKE_BUILD_TYPE=Release + cmake --build cmake_config_build --verbose + - name: Extract CC/CXX/CFLAGS/CXXFLAGS from CMake toolchain + run: | + /opt/devkitpro/portlibs/wii/bin/powerpc-eabi-cmake -S .github/cmake -B /tmp/cmake_extract \ + -DCMAKE_BUILD_TYPE=Release \ + -DVAR_PATH=/tmp/ngc_env.txt + cat /tmp/ngc_env.txt >> $GITHUB_ENV + - name: Verify sdl2-config + run: | + export PATH=${{ env.SDL2_DIR }}/bin:$PATH + cmake/test/test_sdlconfig.sh + - name: Verify sdl2.pc + run: | + export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig + cmake/test/test_pkgconfig.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index b38a8bbc11..b127adb242 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,7 @@ check_cpu_architecture(x64 SDL_CPU_X64) check_cpu_architecture(arm32 SDL_CPU_ARM32) check_cpu_architecture(arm64 SDL_CPU_ARM64) check_cpu_architecture(loongarch64 SDL_CPU_LOONGARCH64) +check_cpu_architecture(powerpc SDL_CPU_POWERPC) # Check for 64 or 32 bit set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P}) @@ -238,7 +239,7 @@ if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC) endif() # Default option knobs -if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS) +if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS OR OGC) set(OPT_DEF_LIBC ON) endif() @@ -350,7 +351,7 @@ if(EMSCRIPTEN) set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF) endif() -if(VITA OR PSP OR PS2 OR N3DS) +if(VITA OR PSP OR PS2 OR N3DS OR OGC) set(SDL_SHARED_ENABLED_BY_DEFAULT OFF) set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF) endif() @@ -840,7 +841,7 @@ if(SDL_ASSEMBLY) check_include_file("immintrin.h" HAVE_IMMINTRIN_H) - if(SDL_ALTIVEC) + if(SDL_ALTIVEC AND NOT OGC) set(CMAKE_REQUIRED_FLAGS "-maltivec") check_c_source_compiles(" #include @@ -1082,7 +1083,7 @@ if(SDL_LIBC) endforeach() if(HAVE_LIBM) set(CMAKE_REQUIRED_LIBRARIES) - if(NOT VITA) + if(NOT VITA AND NOT NINTENDO_SWITCH AND NOT NINTENDO_WII) list(APPEND EXTRA_LIBS m) endif() endif() @@ -2883,6 +2884,75 @@ elseif(N3DS) endif() list(APPEND EXTRA_LIBS ${lib}) endforeach() + +elseif(OGC) + if(CMAKE_SYSTEM_NAME MATCHES "NintendoWii") + file(GLOB OGC_MAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/wii/*.c) + else() + file(GLOB OGC_MAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/gamecube/*.c) + endif() + set(SDLMAIN_SOURCES ${SDLMAIN_SOURCES} ${OGC_MAIN_SOURCES}) + + if(SDL_AUDIO) + set(SDL_AUDIO_DRIVER_OGC 1) + file(GLOB OGC_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/ogc/*.c) + list(APPEND SOURCE_FILES ${OGC_AUDIO_SOURCES}) + set(HAVE_SDL_AUDIO TRUE) + list(APPEND EXTRA_LIBS "aesnd") + endif() + + if(SDL_FILESYSTEM) + set(SDL_FILESYSTEM_OGC 1) + file(GLOB OGC_FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/ogc/*.c) + list(APPEND SOURCE_FILES ${OGC_FILESYSTEM_SOURCES}) + set(HAVE_SDL_FILESYSTEM TRUE) + endif() + + if(SDL_JOYSTICK) + set(SDL_JOYSTICK_OGC 1) + file(GLOB OGC_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/ogc/*.c) + list(APPEND SOURCE_FILES ${OGC_JOYSTICK_SOURCES}) + set(HAVE_SDL_JOYSTICK TRUE) + endif() + + if(SDL_TIMERS) + set(SDL_TIMER_OGC 1) + file(GLOB OGC_TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/ogc/*.c) + list(APPEND SOURCE_FILES ${OGC_TIMER_SOURCES}) + set(HAVE_SDL_TIMERS TRUE) + endif() + + if(SDL_VIDEO) + set(SDL_VIDEO_DRIVER_OGC 1) + set(SDL_VIDEO_RENDER_OGC 1) + file(GLOB OGC_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/ogc/*.c ${SDL2_SOURCE_DIR}/src/render/ogc/*.c) + list(APPEND SOURCE_FILES ${OGC_VIDEO_SOURCES}) + set(SDL_VIDEO_OPENGL 0) + set(HAVE_SDL_VIDEO TRUE) + if(SDL_OPENGL) + pkg_search_module(OPENGX opengl REQUIRED IMPORTED_TARGET) + set(SDL_VIDEO_OPENGL 1) + set(HAVE_OPENGL TRUE) + list(APPEND EXTRA_LIBS "opengx") + target_include_directories(sdl-build-options INTERFACE ${OPENGX_INCLUDE_DIRS}) + endif() + endif() + + set(SDL_PTHREADS ON) + set(SDL_THREADS ON) + set(PTHREADS_SEM ON) + message(STATUS "pthread") + CheckPTHREAD() + + if(NOT SDL2_DISABLE_SDL2MAIN) + list(INSERT SDL_LIBS 0 "-lSDL2main") + list(APPEND EXTRA_LIBS "fat") + endif() + list(APPEND EXTRA_LDFLAGS "${OGC_ARCH_SETTINGS} ${OGC_LINKER_FLAGS}") + if(NINTENDO_WII) + list(APPEND EXTRA_LIBS "wiiuse;bte;wiikeyboard") + endif() + list(APPEND EXTRA_LIBS "ogc;m") endif() if(HAVE_VULKAN AND NOT SDL_LOADSO) diff --git a/cmake/CheckCPUArchitecture.cmake b/cmake/CheckCPUArchitecture.cmake index 7e3e459470..64ddea7440 100644 --- a/cmake/CheckCPUArchitecture.cmake +++ b/cmake/CheckCPUArchitecture.cmake @@ -34,6 +34,8 @@ function(check_cpu_architecture ARCH VARIABLE) _internal_check_cpu_architecture("defined(__aarch64__) || defined(_M_ARM64)" arm64 ${VARIABLE}) elseif(ARCH STREQUAL "loongarch64") _internal_check_cpu_architecture("defined(__loongarch64)" loongarch64 ${VARIABLE}) + elseif(ARCH STREQUAL "powerpc") + _internal_check_cpu_architecture("defined(PPC)" powerpc ${VARIABLE}) else() message(WARNING "Unknown CPU architectures (${ARCH}).") set(${VARIABLE} FALSE) diff --git a/cmake/sdlplatform.cmake b/cmake/sdlplatform.cmake index 6d8ece6ac5..ea0b7dd8d6 100644 --- a/cmake/sdlplatform.cmake +++ b/cmake/sdlplatform.cmake @@ -50,6 +50,8 @@ macro(SDL_DetectCMakePlatform) set(SDL_CMAKE_PLATFORM HAIKU) elseif(NINTENDO_3DS) set(SDL_CMAKE_PLATFORM N3DS) + elseif(CMAKE_SYSTEM_NAME MATCHES "NintendoWii|NintendoGameCube") + set(SDL_CMAKE_PLATFORM OGC) elseif(OS2) set(SDL_CMAKE_PLATFORM OS2) endif() diff --git a/docs/README-ogc.md b/docs/README-ogc.md new file mode 100644 index 0000000000..619c87a0dc --- /dev/null +++ b/docs/README-ogc.md @@ -0,0 +1,22 @@ +# Nintendo GameCube/Nintendo Wii + +SDL port for the Nintendo GameCube and Nintendo Wii [Homebrew toolchain](https://devkitpro.org/). + +Credits to: + +- The awesome people who ported SDL to other homebrew platforms. +- The Devkitpro team for making all the tools necessary to achieve this. + +## Building + +To build for the Nintendo GameCube or Wii, make sure you have devkitPPC and cmake installed and run: + +```bash +cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/Wii.cmake" -DCMAKE_BUILD_TYPE=Release +cmake --build build +cmake --install build +``` + +## Notes + +- Currently only software rendering is supported. diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index 35923d0207..13f9a6022f 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -329,6 +329,7 @@ #cmakedefine SDL_AUDIO_DRIVER_PSP @SDL_AUDIO_DRIVER_PSP@ #cmakedefine SDL_AUDIO_DRIVER_PS2 @SDL_AUDIO_DRIVER_PS2@ #cmakedefine SDL_AUDIO_DRIVER_N3DS @SDL_AUDIO_DRIVER_N3DS@ +#cmakedefine SDL_AUDIO_DRIVER_OGC @SDL_AUDIO_DRIVER_OGC@ /* Enable various input drivers */ #cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@ @@ -355,6 +356,7 @@ #cmakedefine SDL_JOYSTICK_PSP @SDL_JOYSTICK_PSP@ #cmakedefine SDL_JOYSTICK_PS2 @SDL_JOYSTICK_PS2@ #cmakedefine SDL_JOYSTICK_N3DS @SDL_JOYSTICK_N3DS@ +#cmakedefine SDL_JOYSTICK_OGC @SDL_JOYSTICK_OGC@ #cmakedefine SDL_HAPTIC_DUMMY @SDL_HAPTIC_DUMMY@ #cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@ #cmakedefine SDL_HAPTIC_IOKIT @SDL_HAPTIC_IOKIT@ @@ -390,6 +392,7 @@ #cmakedefine SDL_THREAD_PSP @SDL_THREAD_PSP@ #cmakedefine SDL_THREAD_PS2 @SDL_THREAD_PS2@ #cmakedefine SDL_THREAD_N3DS @SDL_THREAD_N3DS@ +#cmakedefine SDL_THREAD_OGC @SDL_THREAD_OGC@ /* Enable various timer systems */ #cmakedefine SDL_TIMER_HAIKU @SDL_TIMER_HAIKU@ @@ -401,6 +404,7 @@ #cmakedefine SDL_TIMER_PSP @SDL_TIMER_PSP@ #cmakedefine SDL_TIMER_PS2 @SDL_TIMER_PS2@ #cmakedefine SDL_TIMER_N3DS @SDL_TIMER_N3DS@ +#cmakedefine SDL_TIMER_OGC @SDL_TIMER_OGC@ /* Enable various video drivers */ #cmakedefine SDL_VIDEO_DRIVER_ANDROID @SDL_VIDEO_DRIVER_ANDROID@ @@ -455,6 +459,7 @@ #cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM @SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM@ #cmakedefine SDL_VIDEO_DRIVER_VITA @SDL_VIDEO_DRIVER_VITA@ #cmakedefine SDL_VIDEO_DRIVER_N3DS @SDL_VIDEO_DRIVER_N3DS@ +#cmakedefine SDL_VIDEO_DRIVER_OGC @SDL_VIDEO_DRIVER_OGC@ #cmakedefine SDL_VIDEO_RENDER_D3D @SDL_VIDEO_RENDER_D3D@ #cmakedefine SDL_VIDEO_RENDER_D3D11 @SDL_VIDEO_RENDER_D3D11@ @@ -467,6 +472,7 @@ #cmakedefine SDL_VIDEO_RENDER_VITA_GXM @SDL_VIDEO_RENDER_VITA_GXM@ #cmakedefine SDL_VIDEO_RENDER_PS2 @SDL_VIDEO_RENDER_PS2@ #cmakedefine SDL_VIDEO_RENDER_PSP @SDL_VIDEO_RENDER_PSP@ +#cmakedefine SDL_VIDEO_RENDER_OGC @SDL_VIDEO_RENDER_OGC@ /* Enable OpenGL support */ #cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@ @@ -514,6 +520,7 @@ #cmakedefine SDL_FILESYSTEM_PSP @SDL_FILESYSTEM_PSP@ #cmakedefine SDL_FILESYSTEM_PS2 @SDL_FILESYSTEM_PS2@ #cmakedefine SDL_FILESYSTEM_N3DS @SDL_FILESYSTEM_N3DS@ +#cmakedefine SDL_FILESYSTEM_OGC @SDL_FILESYSTEM_OGC@ /* Enable misc subsystem */ #cmakedefine SDL_MISC_DUMMY @SDL_MISC_DUMMY@ diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index d6460b783e..026c63bad9 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -355,6 +355,7 @@ /* Enable various threading systems */ #undef SDL_THREAD_GENERIC_COND_SUFFIX +#undef SDL_THREAD_OGC #undef SDL_THREAD_PTHREAD #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP diff --git a/include/SDL_main.h b/include/SDL_main.h index 5cc8e5913a..8416fb2df7 100644 --- a/include/SDL_main.h +++ b/include/SDL_main.h @@ -117,6 +117,14 @@ */ #define SDL_MAIN_AVAILABLE +#elif defined(__wii__) || defined(__gamecube__) +/* + On Wii and GameCube, SDL provides a main function that sets up the system. + + If you provide this yourself, you may define SDL_MAIN_HANDLED +*/ +#define SDL_MAIN_AVAILABLE + #endif #endif /* SDL_MAIN_HANDLED */ diff --git a/src/SDL.c b/src/SDL.c index 56049adf0b..6d164b2485 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -610,6 +610,10 @@ const char *SDL_GetPlatform(void) return "Nokia N-Gage"; #elif __3DS__ return "Nintendo 3DS"; +#elif defined(__gamecube__) + return "Nintendo GameCube"; +#elif defined(__wii__) + return "Nintendo Wii"; #else return "Unknown (see SDL_platform.h)"; #endif diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 60242e60a0..0dd55916d4 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -108,6 +108,9 @@ static const AudioBootStrap *const bootstrap[] = { #if SDL_AUDIO_DRIVER_N3DS &N3DSAUDIO_bootstrap, #endif +#if SDL_AUDIO_DRIVER_OGC + &OGCAUDIO_bootstrap, +#endif #if SDL_AUDIO_DRIVER_EMSCRIPTEN &EMSCRIPTENAUDIO_bootstrap, #endif diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index c755d43415..9da933290b 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -207,6 +207,7 @@ extern AudioBootStrap PS2AUDIO_bootstrap; extern AudioBootStrap PSPAUDIO_bootstrap; extern AudioBootStrap VITAAUD_bootstrap; extern AudioBootStrap N3DSAUDIO_bootstrap; +extern AudioBootStrap OGCAUDIO_bootstrap; extern AudioBootStrap EMSCRIPTENAUDIO_bootstrap; extern AudioBootStrap OS2AUDIO_bootstrap; diff --git a/src/audio/ogc/SDL_ogcaudio.c b/src/audio/ogc/SDL_ogcaudio.c new file mode 100644 index 0000000000..7a770f1abc --- /dev/null +++ b/src/audio/ogc/SDL_ogcaudio.c @@ -0,0 +1,270 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_AUDIO_DRIVER_OGC + +#include "SDL_audio.h" + +/* OGC Audio driver */ + +#include "../SDL_sysaudio.h" +#include "SDL_ogcaudio.h" +#include "SDL_timer.h" + +#include + +#define OGCAUDIO_DRIVER_NAME "ogc" + +/** + * Cleans up all allocated memory, safe to call with null pointers + */ +static void FreePrivateData(_THIS) +{ + if (!this->hidden) { + return; + } + + SDL_free(this->hidden); + this->hidden = NULL; +} + +static int FindAudioFormat(_THIS) +{ + SDL_bool found_valid_format = SDL_FALSE; + Uint16 test_format = SDL_FirstAudioFormat(this->spec.format); + + while (!found_valid_format && test_format) { + this->spec.format = test_format; + SDL_LogDebug(SDL_LOG_CATEGORY_AUDIO, "Trying format %x", test_format); + switch (test_format) { + case AUDIO_S8: + this->hidden->format = VOICE_MONO8; + this->hidden->bytes_per_sample = this->spec.channels; + found_valid_format = SDL_TRUE; + break; + case AUDIO_U8: + this->hidden->format = VOICE_MONO8_UNSIGNED; + this->hidden->bytes_per_sample = this->spec.channels; + found_valid_format = SDL_TRUE; + break; + case AUDIO_S16LSB: + case AUDIO_S16MSB: + this->hidden->format = VOICE_MONO16; + this->hidden->bytes_per_sample = this->spec.channels * 2; + this->spec.format = AUDIO_S16MSB; + found_valid_format = SDL_TRUE; + break; + case AUDIO_U16LSB: + case AUDIO_U16MSB: + this->hidden->format = VOICE_MONO16_UNSIGNED; + this->hidden->bytes_per_sample = this->spec.channels * 2; + this->spec.format = AUDIO_U16MSB; + found_valid_format = SDL_TRUE; + break; + default: + test_format = SDL_NextAudioFormat(); + break; + } + } + + if (found_valid_format && this->spec.channels == 2) { + this->hidden->format++; + } + + return found_valid_format ? 0 : -1; +} + +/* fully local functions related to the wavebufs / DSP, not the same as the SDL-wide mixer lock */ +static SDL_INLINE void contextLock(_THIS) +{ + LWP_MutexLock(this->hidden->lock); +} + +static SDL_INLINE void contextUnlock(_THIS) +{ + LWP_MutexUnlock(this->hidden->lock); +} + +static void audio_frame_finished(AESNDPB *pb, u32 state, void *arg) +{ + SDL_AudioDevice *this = (SDL_AudioDevice *)arg; + + if (state == VOICE_STATE_STREAM) { + const size_t buffer_size = DMA_BUFFER_SIZE; + s8 playing_buffer; + void *buffer; + + /* Immediately send the next buffer to the DSP. It's important that + * AESND_SetVoiceBuffer() gets called before this callback returns, or + * some audio gaps might be audible. */ + contextLock(this); + playing_buffer = (this->hidden->playing_buffer + 1) % NUM_BUFFERS; + buffer = this->hidden->dma_buffers[playing_buffer]; + AESND_SetVoiceBuffer(pb, buffer, buffer_size); + this->hidden->playing_buffer = playing_buffer; + contextUnlock(this); + + /* If a frame has finished playing, it means that the corresponding + * buffer is no longer in use and can be filled up again. We signal + * this event to the audio thread via a semaphore. */ + LWP_SemPost(this->hidden->available_buffers); + } if (state == VOICE_STATE_STOPPED) { + contextLock(this); + this->hidden->playing_buffer = -1; + contextUnlock(this); + } +} + +static int OGCAUDIO_OpenDevice(_THIS, const char *devname) +{ + struct SDL_PrivateAudioData *hidden = + memalign(32, sizeof(struct SDL_PrivateAudioData)); + if (!hidden) { + return SDL_OutOfMemory(); + } + + SDL_LogDebug(SDL_LOG_CATEGORY_AUDIO, + "OGCAUDIO_OpenDevice, name=%s, freq=%d, channels=%d\n", + devname, this->spec.freq, this->spec.channels); + + memset(hidden, 0, sizeof(*hidden)); + hidden->playing_buffer = -1; + this->hidden = hidden; + + AESND_Init(); + AESND_Pause(1); + + /* Initialise internal state */ + LWP_MutexInit(&hidden->lock, false); + /* We set the initial number of available buffers to NUM_BUFFERS - 1, since + * SDL first calls GetDeviceBuf() and starts filling it without first + * calling WaitDevice(). So we consider the first buffer to be busy already + * at start. */ + LWP_SemInit(&hidden->available_buffers, NUM_BUFFERS - 1, NUM_BUFFERS); + + if (this->spec.freq <= 0 || this->spec.freq > 144000) + this->spec.freq = DSP_DEFAULT_FREQ; + + if (this->spec.channels > 2) { + this->spec.channels = 2; + } + + /* Should not happen but better be safe. */ + if (FindAudioFormat(this) < 0) { + return SDL_SetError("No supported audio format found."); + } + + this->spec.samples = DMA_BUFFER_SIZE / this->hidden->bytes_per_sample; + + /* Update the fragment size as size in bytes */ + SDL_CalculateAudioSpec(&this->spec); + + hidden->voice = AESND_AllocateVoiceWithArg(audio_frame_finished, this); + if (hidden->voice == NULL) + return -1; + + // start audio + AESND_SetVoiceFormat(hidden->voice, hidden->format); + AESND_SetVoiceFrequency(hidden->voice, this->spec.freq); + AESND_SetVoiceBuffer(hidden->voice, hidden->dma_buffers[0], DMA_BUFFER_SIZE); + AESND_SetVoiceStream(hidden->voice, true); + AESND_SetVoiceStop(hidden->voice, 0); + AESND_Pause(0); + + return 0; +} + +static void OGCAUDIO_PlayDevice(_THIS) +{ + void *buffer; + + /* This only sends the first audio buffer. The following ones will always + * be send from the audio_frame_finished() callback, without having to + * switch between threads. */ + contextLock(this); + if (this->hidden->playing_buffer < 0) { + buffer = this->hidden->dma_buffers[++this->hidden->playing_buffer]; + AESND_SetVoiceBuffer(this->hidden->voice, buffer, DMA_BUFFER_SIZE); + } + contextUnlock(this); +} + +static void OGCAUDIO_WaitDevice(_THIS) +{ + s8 nextbuf; + + /* This will block until at least one buffer is available for writing. */ + LWP_SemWait(this->hidden->available_buffers); + + nextbuf = this->hidden->nextbuf; + this->hidden->nextbuf = (nextbuf + 1) % NUM_BUFFERS; +} + +static Uint8 *OGCAUDIO_GetDeviceBuf(_THIS) +{ + return this->hidden->dma_buffers[this->hidden->nextbuf]; +} + +static void OGCAUDIO_CloseDevice(_THIS) +{ + struct SDL_PrivateAudioData *hidden = this->hidden; + + LWP_SemDestroy(hidden->available_buffers); + if (hidden->voice) { + AESND_SetVoiceStop(hidden->voice, true); + AESND_FreeVoice(hidden->voice); + hidden->voice = NULL; + } + + AESND_Pause(1); + FreePrivateData(this); +} + +static void OGCAUDIO_ThreadInit(_THIS) +{ + LWP_SetThreadPriority(LWP_THREAD_NULL, 80); +} + +static SDL_bool OGCAUDIO_Init(SDL_AudioDriverImpl *impl) +{ + /* Set the function pointers */ + impl->OpenDevice = OGCAUDIO_OpenDevice; + impl->PlayDevice = OGCAUDIO_PlayDevice; + impl->WaitDevice = OGCAUDIO_WaitDevice; + impl->GetDeviceBuf = OGCAUDIO_GetDeviceBuf; + impl->CloseDevice = OGCAUDIO_CloseDevice; + impl->ThreadInit = OGCAUDIO_ThreadInit; + impl->OnlyHasDefaultOutputDevice = SDL_TRUE; + + return SDL_TRUE; /* this audio target is available. */ +} + +AudioBootStrap OGCAUDIO_bootstrap = { + OGCAUDIO_DRIVER_NAME, + "SDL OGC audio driver", + OGCAUDIO_Init, + 0 +}; + +#endif /* SDL_AUDIO_DRIVER_OGC */ + +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/audio/ogc/SDL_ogcaudio.h b/src/audio/ogc/SDL_ogcaudio.h new file mode 100644 index 0000000000..a575ac5aaa --- /dev/null +++ b/src/audio/ogc/SDL_ogcaudio.h @@ -0,0 +1,54 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_ogcaudio_h_ +#define _SDL_ogcaudio_h_ + +#include +#include + +#include +#include + +/* Hidden "this" pointer for the audio functions */ +#define _THIS SDL_AudioDevice *this + +#define NUM_BUFFERS 4 /* -- Minimum 2! */ +#define SAMPLES_PER_DMA_BUFFER (DSP_STREAMBUFFER_SIZE) +#define DMA_BUFFER_SIZE (SAMPLES_PER_DMA_BUFFER * 2 * sizeof(short)) + +struct SDL_PrivateAudioData +{ + /* these go first so they will be aligned */ + Uint8 dma_buffers[NUM_BUFFERS][DMA_BUFFER_SIZE]; + AESNDPB *voice; + + /* Speaker data */ + Uint32 format; + Uint8 bytes_per_sample; + s8 nextbuf; + s8 playing_buffer; + mutex_t lock; + sem_t available_buffers; +}; + +#endif /* _SDL_ogcaudio_h_ */ +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/dynapi/SDL_dynapi.h b/src/dynapi/SDL_dynapi.h index 99ca08008f..d261a33f07 100644 --- a/src/dynapi/SDL_dynapi.h +++ b/src/dynapi/SDL_dynapi.h @@ -67,6 +67,8 @@ #define SDL_DYNAMIC_API 0 /* The N-Gage doesn't support dynamic linking either */ #elif defined(__3DS__) #define SDL_DYNAMIC_API 0 /* devkitARM doesn't support dynamic linking */ +#elif defined(__wii__) || defined(__gamecube__) +#define SDL_DYNAMIC_API 0 /* devkitPPC doesn't support dynamic linking */ #elif defined(DYNAPI_NEEDS_DLOPEN) && !defined(HAVE_DLOPEN) #define SDL_DYNAMIC_API 0 /* we need dlopen(), but don't have it.... */ #endif diff --git a/src/filesystem/ogc/SDL_sysfilesystem.c b/src/filesystem/ogc/SDL_sysfilesystem.c new file mode 100644 index 0000000000..cf42b99f1e --- /dev/null +++ b/src/filesystem/ogc/SDL_sysfilesystem.c @@ -0,0 +1,86 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_FILESYSTEM_OGC + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include +#include +#include + +#include "SDL_error.h" +#include "SDL_filesystem.h" + +static inline int create_dir(const char *dirname) +{ + int result = mkdir(dirname, 0666); + + if (result == -1 && errno != EEXIST) { + return SDL_SetError("Failed to create '%s' (%s)", dirname, strerror(errno)); + } + return 0; +} + +char *SDL_GetBasePath(void) +{ + char buffer[256]; + size_t len; + + if (!getcwd(buffer, sizeof(buffer) - 1)) { + return "/"; + } + + len = strlen(buffer); + if (len > 0 && buffer[len - 1] != '/') { + buffer[len] = '/'; + buffer[len + 1] = '\0'; + } + + return SDL_strdup(buffer); +} + +char *SDL_GetPrefPath(const char *org, const char *app) +{ + char *pref_path = NULL; + if (!app) { + SDL_InvalidParamError("app"); + return NULL; + } + + SDL_asprintf(&pref_path, "/apps/%s/", app); + if (!pref_path) { + return NULL; + } + + if (create_dir(pref_path) < 0) { + SDL_free(pref_path); + return NULL; + } + + return pref_path; +} + +#endif /* SDL_FILESYSTEM_OGC */ + +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 834e83d99e..65dc3ce685 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -105,6 +105,9 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = { #ifdef SDL_JOYSTICK_N3DS &SDL_N3DS_JoystickDriver #endif +#ifdef SDL_JOYSTICK_OGC + &SDL_OGC_JoystickDriver +#endif #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED) &SDL_DUMMY_JoystickDriver #endif diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h index a93fa662ca..3d3329ae5a 100644 --- a/src/joystick/SDL_sysjoystick.h +++ b/src/joystick/SDL_sysjoystick.h @@ -249,6 +249,7 @@ extern SDL_JoystickDriver SDL_PS2_JoystickDriver; extern SDL_JoystickDriver SDL_PSP_JoystickDriver; extern SDL_JoystickDriver SDL_VITA_JoystickDriver; extern SDL_JoystickDriver SDL_N3DS_JoystickDriver; +extern SDL_JoystickDriver SDL_OGC_JoystickDriver; /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/joystick/ogc/SDL_sysjoystick.c b/src/joystick/ogc/SDL_sysjoystick.c new file mode 100644 index 0000000000..56d5beccc4 --- /dev/null +++ b/src/joystick/ogc/SDL_sysjoystick.c @@ -0,0 +1,1328 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" + +#ifdef SDL_JOYSTICK_OGC + +#include "../SDL_joystick_c.h" +#include "../SDL_sysjoystick.h" +#include "../usb_ids.h" +#include "SDL_events.h" +#include "SDL_hints.h" +#include "../../SDL_hints_c.h" +#include "SDL_joystick.h" + +#include +#include +#include +#include + +#define PI 3.14159265f + +#define MAX_GC_JOYSTICKS 4 +#define MAX_WII_JOYSTICKS 4 + +#define GC_JOYSTICKS_START 0 +#define GC_JOYSTICKS_END MAX_GC_JOYSTICKS +#define WII_JOYSTICKS_START GC_JOYSTICKS_END +#define WII_WIIMOTES_START WII_JOYSTICKS_START +#define WII_WIIMOTES_END (WII_WIIMOTES_START + MAX_WII_JOYSTICKS) +#define WII_EXP_START WII_WIIMOTES_END +#define WII_EXP_END (WII_EXP_START + MAX_WII_JOYSTICKS) +#define WII_JOYSTICKS_END WII_EXP_END + +#define MAX_JOYSTICKS WII_EXP_END + +#define MAX_GC_AXES 6 +#define MAX_GC_BUTTONS 8 +#define MAX_GC_HATS 1 + +#define MAX_WII_AXES 9 +#define MAX_WII_BUTTONS 15 +#define MAX_WII_HATS 1 + +#define JOYNAMELEN 10 + +#define AXIS_MIN -32767 /* minimum value for axis coordinate */ +#define AXIS_MAX 32767 /* maximum value for axis coordinate */ + +#define MAX_RUMBLE 8 + +typedef struct joystick_paddata_t +{ + u16 prev_buttons; + s8 stickX; + s8 stickY; + s8 substickX; + s8 substickY; + u8 triggerL; + u8 triggerR; +} joystick_paddata; + +typedef struct joystick_wpaddata_t +{ + u32 prev_buttons; + u32 exp; + s16 nunchuk_stickX; + s16 nunchuk_stickY; + s16 classicL_stickX; + s16 classicL_stickY; + s16 classicR_stickX; + s16 classicR_stickY; + u8 classic_triggerL; + u8 classic_triggerR; + u8 classic_calibrated; + s8 wiimote_pitch; + s8 wiimote_roll; + s8 wiimote_yaw; + s16 classic_cal[4][3]; // 4x axes, min/center/max +} joystick_wpaddata; + +/* The private structure used to keep track of a joystick */ +typedef struct joystick_hwdata +{ + int index; + char sensors_disabled; + /* This must be big enough for MAX_RUMBLE */ + char rumble_intensity; + u16 rumble_loop; + union + { + joystick_paddata gamecube; + joystick_wpaddata wiimote; + }; +} joystick_hwdata; + +#ifdef __wii__ +static const u32 sdl_buttons_wii[] = { + WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, + WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, + WPAD_BUTTON_1, + WPAD_BUTTON_2, + WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, + WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, + WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, + WPAD_NUNCHUK_BUTTON_Z, /* 7 */ + WPAD_NUNCHUK_BUTTON_C, /* 8 */ + WPAD_CLASSIC_BUTTON_X, /* 9 */ + WPAD_CLASSIC_BUTTON_Y, + WPAD_CLASSIC_BUTTON_FULL_L, + WPAD_CLASSIC_BUTTON_FULL_R, + WPAD_CLASSIC_BUTTON_ZL, + WPAD_CLASSIC_BUTTON_ZR +}; +#define SDL_WII_NUM_BUTTONS_WII \ + (sizeof(sdl_buttons_wii) / sizeof(sdl_buttons_wii[0])) + +static const u32 sdl_buttons_wiimote[] = { + WPAD_BUTTON_A, + WPAD_BUTTON_B, + WPAD_BUTTON_1, + WPAD_BUTTON_2, + WPAD_BUTTON_MINUS, + WPAD_BUTTON_PLUS, + WPAD_BUTTON_HOME, +}; +#define SDL_WII_NUM_BUTTONS_WIIMOTE \ + (sizeof(sdl_buttons_wiimote) / sizeof(sdl_buttons_wiimote[0])) + +static const u32 sdl_buttons_nunchuck[] = { + WPAD_NUNCHUK_BUTTON_Z, + WPAD_NUNCHUK_BUTTON_C, +}; +#define SDL_WII_NUM_BUTTONS_NUNCHUCK \ + (sizeof(sdl_buttons_nunchuck) / sizeof(sdl_buttons_nunchuck[0])) + +static const u32 sdl_buttons_classic[] = { + WPAD_CLASSIC_BUTTON_A, + WPAD_CLASSIC_BUTTON_B, + WPAD_CLASSIC_BUTTON_X, + WPAD_CLASSIC_BUTTON_Y, + WPAD_CLASSIC_BUTTON_FULL_L, + WPAD_CLASSIC_BUTTON_FULL_R, + WPAD_CLASSIC_BUTTON_ZL, + WPAD_CLASSIC_BUTTON_ZR, + WPAD_CLASSIC_BUTTON_MINUS, + WPAD_CLASSIC_BUTTON_PLUS, + WPAD_CLASSIC_BUTTON_HOME, +}; +#define SDL_WII_NUM_BUTTONS_CLASSIC \ + (sizeof(sdl_buttons_classic) / sizeof(sdl_buttons_classic[0])) +#endif /* __wii__ */ + +static const u16 sdl_buttons_gc[] = { + PAD_BUTTON_A, + PAD_BUTTON_B, + PAD_BUTTON_X, + PAD_BUTTON_Y, + PAD_TRIGGER_L, + PAD_TRIGGER_R, + PAD_TRIGGER_Z, + PAD_BUTTON_START, +}; + +static int split_joysticks = 0; + +static SDL_JoystickID s_connected_instances[MAX_JOYSTICKS]; +/* Value is 0 if controller is not present, otherwise 1 + extension enum */ +static char s_detected_devices[MAX_JOYSTICKS]; +static char s_gc_failed_reads = 0; +static u32 s_gc_last_scanpads = 0; +static bool s_hardware_queried = false; + + +#ifdef __wii__ +static bool s_wii_has_new_data[MAX_WII_JOYSTICKS]; +static bool s_accelerometers_as_axes = false; +static bool s_wiimote_sideways = false; + +static void SDLCALL +on_hint_accel_as_joystick_cb(void *userdata, const char *name, + const char *oldValue, const char *hint) +{ + s_accelerometers_as_axes = SDL_GetStringBoolean(hint, SDL_FALSE); +} + +#endif + +/* Joypad index is 0-11: 4 GC, 4 Wiimotes and (if split_joysticks) 4 expansions + */ +static int device_index_to_joypad_index(int device_index) +{ + int count = 0; + + for (int i = 0; i < MAX_JOYSTICKS; i++) { + if (s_connected_instances[i] >= 0) { + if (count == device_index) + return i; + count++; + } + } + + SDL_LogError(SDL_LOG_CATEGORY_INPUT, + "Cannot find device index %d", device_index); + return -1; +} + +static int device_index_to_instance(int device_index) +{ + int index = device_index_to_joypad_index(device_index); + if (index < 0) + return -1; + return s_connected_instances[index]; +} + +static void scan_hardware(void) +{ + /* Scan the GameCube and Wii controllers, but only if this was not done + * before during this update cycle. + * The Detect() callback, resets the s_hardware_queried variable. */ + if (!s_hardware_queried) { + s_gc_last_scanpads = PAD_ScanPads(); +#ifdef __wii__ + for (int i = 0; i < MAX_WII_JOYSTICKS; i++) { + s_wii_has_new_data[i] = WPAD_ReadPending(i, NULL); + } +#endif + s_hardware_queried = true; + } +} + +static void report_joystick(int index, int connected) +{ + printf("Controller %d was %s (%d)\n", + index, connected ? "connected" : "removed", connected); + + /* First, if the joystick was connected with a different expansion, remove + * it */ + if (s_connected_instances[index] >= 0) { + SDL_PrivateJoystickRemoved(s_connected_instances[index]); + s_connected_instances[index] = -1; + } + + if (connected) { + s_connected_instances[index] = SDL_GetNextJoystickInstanceID(); + SDL_PrivateJoystickAdded(s_connected_instances[index]); + } +} + +static inline bool enable_rumble(int index, bool enable) +{ + if (index >= GC_JOYSTICKS_START && index < GC_JOYSTICKS_END) { + PAD_ControlMotor(index - GC_JOYSTICKS_START, + enable ? PAD_MOTOR_RUMBLE : PAD_MOTOR_STOP); + return true; +#ifdef __wii__ + } else if (index >= WII_WIIMOTES_START && index < WII_JOYSTICKS_END) { + WPAD_Rumble(index - WII_WIIMOTES_START, enable); + return true; +#endif + } else { + return false; + } +} + +static void update_rumble(SDL_Joystick *joystick) +{ + char intensity = joystick->hwdata->rumble_intensity; + s16 loop; + int rest_frames; + bool rumble; + if (intensity == 0 || intensity == MAX_RUMBLE - 1) return; + + loop = ++joystick->hwdata->rumble_loop; + + /* The rest_frames constant should probably be set according to the current + * framerate; or we should rework the logic to be completely time-based. + * It may also be that we need different values depending on the controller + * type. */ + rest_frames = 2; + if (loop == 1) { + rumble = false; + } else if (loop > (MAX_RUMBLE - 1 - intensity) * rest_frames) { + rumble = true; + joystick->hwdata->rumble_loop = 0; + } else { + /* Keep the engine stopped until our time comes again */ + return; + } + + enable_rumble(joystick->hwdata->index, rumble); +} + +/* Function to scan the system for joysticks. + * This function should return the number of available + * joysticks. Joystick 0 should be the system default joystick. + * It should return -1 on an unrecoverable fatal error. + */ +static int OGC_JoystickInit(void) +{ + const char *split_joystick_env = getenv("SDL_WII_JOYSTICK_SPLIT"); + split_joysticks = split_joystick_env && strcmp(split_joystick_env, "1") == 0; + + PAD_Init(); + /* We don't call WPAD_Init() here, since it's already been called by + * SDL_main for the Wii */ + +#ifdef __wii__ + SDL_AddHintCallback(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, + on_hint_accel_as_joystick_cb, NULL); + /* If this is set, the Wiimote directional keys will be translated. */ + { + const char *sideways_joystick_env = getenv("SDL_WII_JOYSTICK_SIDEWAYS"); + s_wiimote_sideways = + sideways_joystick_env && strcmp(sideways_joystick_env, "1") == 0; + } +#endif + + /* Initialize the needed variables */ + for (int i = 0; i < MAX_JOYSTICKS; i++) { + s_connected_instances[i] = -1; + } + return 0; +} + +static int OGC_JoystickGetCount(void) +{ + int count = 0; + + for (int i = 0; i < MAX_JOYSTICKS; i++) { + if (s_connected_instances[i] >= 0) + count++; + } + return count; +} + +static void OGC_JoystickDetect(void) +{ + scan_hardware(); + + /* Ignore individual disconnected statuses, since they might just + * happen because the controller is not ready. */ + if (s_gc_last_scanpads == 0 && s_gc_failed_reads < 4) { + s_gc_failed_reads++; + s_hardware_queried = false; + } else { + s_gc_failed_reads = 0; + for (int i = 0; i < MAX_GC_JOYSTICKS; i++) { + bool connected = s_gc_last_scanpads & (1 << i); + bool was_connected = s_detected_devices[i]; + if (connected == was_connected) + continue; + + report_joystick(i, connected); + s_detected_devices[i] = connected; + } + } + +#ifdef __wii__ + for (int i = 0; i < MAX_WII_JOYSTICKS; i++) { + int connected, was_connected, index; + WPADData *data; + + if (!s_wii_has_new_data[i]) + continue; + + data = WPAD_Data(i); + index = WII_JOYSTICKS_START + i; + connected = data->err != WPAD_ERR_NO_CONTROLLER && + data->data_present != 0; + if (split_joysticks) { + int exp_index = WII_EXP_START + i; + int exp_connected = + (connected && data->exp.type != WPAD_EXP_NONE) ? (1 + data->exp.type) : 0; + int exp_was_connected = s_detected_devices[exp_index]; + if (exp_connected != exp_was_connected) { + s_detected_devices[exp_index] = exp_connected; + report_joystick(exp_index, exp_connected); + } + } else if (connected) { + connected += data->exp.type; + } + + was_connected = s_detected_devices[index]; + if (connected != was_connected) { + s_detected_devices[index] = connected; + report_joystick(index, connected); + } + } +#endif + + /* This is to force a refresh, the next time that Update() or Detect() are + * called. This relies on the fact that SDL calls Detect() after Update(). + */ + s_hardware_queried = false; +} + +static char joy_name[128]; + +/* Function to get the device-dependent name of a joystick */ +static const char *OGC_JoystickGetDeviceName(int device_index) +{ + int index = device_index_to_joypad_index(device_index); + if (index < 0) + return NULL; + + if (index >= GC_JOYSTICKS_START && index < GC_JOYSTICKS_END) { + sprintf(joy_name, "Gamecube %d", index); +#ifdef __wii__ + } else if (index >= WII_WIIMOTES_START && index < WII_WIIMOTES_END) { + char *name_ptr = joy_name; + int expansion = s_detected_devices[index] - 1; + name_ptr += sprintf(name_ptr, "Wiimote %d", index - WII_WIIMOTES_START); + if (!split_joysticks) { + // Add expansion information + switch (expansion) { + case WPAD_EXP_NUNCHUK: + strcpy(name_ptr, " + Nunchuk"); + break; + case WPAD_EXP_CLASSIC: + strcpy(name_ptr, " + Classic"); + break; + case WPAD_EXP_GUITARHERO3: + strcpy(name_ptr, " + Guitar Hero 3"); + break; + case WPAD_EXP_WIIBOARD: + strcpy(name_ptr, " + Balance board"); + break; + } + } + } else if (split_joysticks) { + /* This is an expansion and we are using the split controllers + * option: show only the expansion name, then. */ + int expansion = s_detected_devices[index] - 1; + int idx = index - WII_EXP_START; + switch (expansion) { + case WPAD_EXP_NUNCHUK: + sprintf(joy_name, "Nunchuk %d", idx); + break; + case WPAD_EXP_CLASSIC: + sprintf(joy_name, "Classic %d", idx); + break; + case WPAD_EXP_GUITARHERO3: + sprintf(joy_name, "Guitar Hero 3 %d", idx); + break; + case WPAD_EXP_WIIBOARD: + sprintf(joy_name, "Balance board %d", idx); + break; + case WPAD_EXP_NONE: + strcpy(joy_name, "Disconnected"); + break; + default: + sprintf(joy_name, "Unknown %d", idx); + break; + } +#endif + } else { + sprintf(joy_name, "Invalid device index: %d", device_index); + } + return joy_name; +} + +static const char *OGC_JoystickGetDevicePath(int index) +{ + return NULL; +} + +static int OGC_JoystickGetDevicePlayerIndex(int device_index) +{ + return -1; +} + +static void OGC_JoystickSetDevicePlayerIndex(int device_index, int player_index) +{ +} + +static SDL_JoystickGUID OGC_JoystickGetDeviceGUID(int device_index) +{ + int index = device_index_to_joypad_index(device_index); + Uint16 bus, product, version; + Uint8 driver_signature, driver_data; + const char *name; + + /* We invent our own product IDs, to tell our joysticks apart. + * Since we want the gamepads to appear with the numeric ID in their + * name, we make them unique by assigning a different product depending on + * the port. */ + product = (index + 1) << 8; + if (index >= GC_JOYSTICKS_START && index < GC_JOYSTICKS_END) { + bus = SDL_HARDWARE_BUS_UNKNOWN; + } else { + bus = SDL_HARDWARE_BUS_BLUETOOTH; + product += s_detected_devices[index]; + } + version = 1; + driver_signature = 0; + driver_data = 0; + + name = OGC_JoystickGetDeviceName(device_index); + return SDL_CreateJoystickGUID(bus, USB_VENDOR_NINTENDO, product, version, + name, driver_signature, driver_data); +} + +static SDL_JoystickID OGC_JoystickGetDeviceInstanceID(int device_index) +{ + return device_index_to_instance(device_index); +} + +static int OGC_JoystickOpen(SDL_Joystick *joystick, int device_index) +{ + int index = device_index_to_joypad_index(device_index); + + printf("Open joystick %d (our index: %d)\n", device_index, index); + + if (index < 0) + return -1; + + /* allocate memory for system specific hardware data */ + joystick->hwdata = SDL_malloc(sizeof(joystick_hwdata)); + if (joystick->hwdata == NULL) { + SDL_OutOfMemory(); + return -1; + } + joystick->instance_id = s_connected_instances[index]; + + SDL_memset(joystick->hwdata, 0, sizeof(joystick_hwdata)); + joystick->hwdata->index = index; + if (index >= GC_JOYSTICKS_START && index < GC_JOYSTICKS_END) { + joystick->nbuttons = MAX_GC_BUTTONS; + joystick->naxes = MAX_GC_AXES; + joystick->nhats = MAX_GC_HATS; +#ifdef __wii__ + } else { + if (split_joysticks) { + if (index < WII_WIIMOTES_END) { + // wiimote + joystick->nbuttons = SDL_WII_NUM_BUTTONS_WIIMOTE; + joystick->naxes = 3; + joystick->nhats = 1; + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 100.0f); + } else { + // expansion + joystick->nbuttons = SDL_max(SDL_WII_NUM_BUTTONS_NUNCHUCK, + SDL_WII_NUM_BUTTONS_CLASSIC); + joystick->naxes = 6; + joystick->nhats = 1; + if (s_detected_devices[index] == 1 + WPAD_EXP_NUNCHUK) { + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL_L, 100.0f); + } + } + } else { + joystick->nbuttons = MAX_WII_BUTTONS; + joystick->naxes = MAX_WII_AXES; + joystick->nhats = MAX_WII_HATS; + /* Add the accelerometer only if there is no expansion connected */ + if (s_detected_devices[index] == 1) { + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 100.0f); + } else if (s_detected_devices[index] == 1 + WPAD_EXP_NUNCHUK) { + /* Or, if the nunchuck is connected, add the wiimote, and the + * nunchuk on the left */ + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 100.0f); + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL_L, 100.0f); + } + } +#endif + } + return 0; +} + +static int OGC_JoystickRumble(SDL_Joystick *joystick, + Uint16 low_frequency_rumble, + Uint16 high_frequency_rumble) +{ + int index = joystick->hwdata->index; + /* The Wii and GameCube controllers do not support setting the frequency of + * the rumble, so we use a hack where we periodically stop and start the + * motors during Update(). */ + char intensity = MAX_RUMBLE * + ((low_frequency_rumble + high_frequency_rumble) / 2) / + 0xffff; + /* We don't accept MAX_RUMBLE itself */ + if (intensity >= MAX_RUMBLE) + intensity = MAX_RUMBLE - 1; + + /* If it's the same as the current value, do nothing */ + if (intensity == joystick->hwdata->rumble_intensity) { + return 0; + } + + if (!enable_rumble(index, intensity > 0)) { + return SDL_Unsupported(); + } + + /* Save the current rumble status, we need it in update_rumble() */ + joystick->hwdata->rumble_intensity = intensity; + joystick->hwdata->rumble_loop = 0; + + return 0; +} + +static int OGC_JoystickRumbleTriggers(SDL_Joystick *joystick, + Uint16 left_rumble, Uint16 right_rumble) +{ + return SDL_Unsupported(); +} + +static Uint32 OGC_JoystickGetCapabilities(SDL_Joystick *joystick) +{ + Uint32 capabilities = 0; + + int index = joystick->hwdata->index; + if ((index >= GC_JOYSTICKS_START && index < GC_JOYSTICKS_END) || + /* Rumble is supported on the wiimotes, but it makes sense only if no + * expansion is attached, of if we are in split mode. */ + (index >= WII_WIIMOTES_START && index < WII_WIIMOTES_END && + (s_detected_devices[index] == 1 || split_joysticks))) { + capabilities |= SDL_JOYCAP_RUMBLE; + } + return capabilities; +} + +static int OGC_JoystickSetLED(SDL_Joystick *joystick, + Uint8 red, Uint8 green, Uint8 blue) +{ + return SDL_Unsupported(); +} + +static int OGC_JoystickSendEffect(SDL_Joystick *joystick, + const void *data, int size) +{ + return SDL_Unsupported(); +} + +static int OGC_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +{ + int index = joystick->hwdata->index; + if (index >= WII_WIIMOTES_START && index < WII_WIIMOTES_END) { + joystick->hwdata->sensors_disabled = !enabled; + return 0; + } + return SDL_Unsupported(); +} + +#ifdef __wii__ + +static s16 WPAD_Orient(WPADData *data, int motion) +{ + float out; + + if (motion == 0) + out = data->orient.pitch; + else if (motion == 1) + out = data->orient.roll; + else + out = data->orient.yaw; + + return (s16)((out / 180.0) * 128.0); +} + +static s16 WPAD_Pitch(WPADData *data) +{ + return WPAD_Orient(data, 0); +} + +static s16 WPAD_Roll(WPADData *data) +{ + return WPAD_Orient(data, 1); +} + +static s16 WPAD_Yaw(WPADData *data) +{ + return WPAD_Orient(data, 2); +} + +static s16 WPAD_Stick(s16 x, s16 min, s16 center, s16 max, int flip) +{ + s16 d; + int ret; + + x -= center; + + if (x < 0) + d = center - min; + else + d = max - center; + + if (center - min < 5) + return 0; + if (max - center < 5) + return 0; + + if (d) + ret = (x << 15) / d; + else + return 0; + + if (flip) + ret = -ret; + + if (ret < AXIS_MIN) + ret = AXIS_MIN; + else if (ret > AXIS_MAX) + ret = AXIS_MAX; + + return ret; +} + +static const u32 _buttons[8] = { + // wiimote + WPAD_BUTTON_UP, + WPAD_BUTTON_DOWN, + WPAD_BUTTON_LEFT, + WPAD_BUTTON_RIGHT, + // classic + WPAD_CLASSIC_BUTTON_UP, + WPAD_CLASSIC_BUTTON_DOWN, + WPAD_CLASSIC_BUTTON_LEFT, + WPAD_CLASSIC_BUTTON_RIGHT +}; + +static void HandleWiiHats(SDL_Joystick *joystick, + const u32 changed, const u32 pressed, + const u32 *buttons) +{ + if (changed & (buttons[0] | buttons[1] | buttons[2] | buttons[3])) { + int hat = SDL_HAT_CENTERED; + + if (pressed & buttons[0]) + hat |= s_wiimote_sideways ? SDL_HAT_LEFT : SDL_HAT_UP; + if (pressed & buttons[1]) + hat |= s_wiimote_sideways ? SDL_HAT_RIGHT : SDL_HAT_DOWN; + if (pressed & buttons[2]) + hat |= s_wiimote_sideways ? SDL_HAT_DOWN : SDL_HAT_LEFT; + if (pressed & buttons[3]) + hat |= s_wiimote_sideways ? SDL_HAT_UP : SDL_HAT_RIGHT; + SDL_PrivateJoystickHat(joystick, 0, hat); + } +} + +/* Helpers to separate nunchuk vs classic buttons which share the + * same scan codes. In particular, up on the classic controller is + * the same as Z on the nunchuk. The numbers refer to the sdl_buttons_wii + * list above. */ +static int wii_button_is_nunchuk(int idx) +{ + return idx == 7 || idx == 8; +} + +static int wii_button_is_classic(int idx) +{ + return idx >= 9; +} + +static void HandleWiiButtons(SDL_Joystick *joystick, + const u32 changed, + const WPADData *data, + const u32 *buttons, + size_t num_buttons) +{ + for (int i = 0; i < num_buttons; i++) { + if (changed & buttons[i]) { + if (!split_joysticks && + ((data->exp.type == WPAD_EXP_CLASSIC && wii_button_is_nunchuk(i)) || + (data->exp.type == WPAD_EXP_NUNCHUK && wii_button_is_classic(i)))) + continue; + + SDL_PrivateJoystickButton(joystick, i, + (data->btns_d & buttons[i]) ? SDL_PRESSED : SDL_RELEASED); + } + } +} + +static void HandleWiiMotion(SDL_Joystick *joystick, + joystick_hwdata *prev_state, + WPADData *data, + int start_index) +{ + int axis = WPAD_Pitch(data); + if (prev_state->wiimote.wiimote_pitch != axis) { + SDL_PrivateJoystickAxis(joystick, start_index, -(axis << 8)); + prev_state->wiimote.wiimote_pitch = axis; + } + axis = WPAD_Roll(data); + if (prev_state->wiimote.wiimote_roll != axis) { + SDL_PrivateJoystickAxis(joystick, start_index + 1, axis << 8); + prev_state->wiimote.wiimote_roll = axis; + } + axis = WPAD_Yaw(data); + if (prev_state->wiimote.wiimote_yaw != axis) { + SDL_PrivateJoystickAxis(joystick, start_index + 2, axis << 8); + prev_state->wiimote.wiimote_yaw = axis; + } +} + +static void HandleNunchuckSensors(SDL_Joystick *joystick, + const nunchuk_t *data) +{ + float values[3]; + SDL_SensorType type; + + if (joystick->hwdata->sensors_disabled) return; + + type = split_joysticks ? SDL_SENSOR_ACCEL : SDL_SENSOR_ACCEL_L; + values[0] = data->gforce.x * SDL_STANDARD_GRAVITY; + values[1] = data->gforce.z * SDL_STANDARD_GRAVITY; + values[2] = -data->gforce.y * SDL_STANDARD_GRAVITY; + SDL_PrivateJoystickSensor(joystick, type, 0, values, 3); +} + +static void HandleWiimoteSensors(SDL_Joystick *joystick, + WPADData *data) +{ + float values[3]; + + if (joystick->hwdata->sensors_disabled) return; + + values[0] = data->gforce.x * SDL_STANDARD_GRAVITY; + values[1] = data->gforce.z * SDL_STANDARD_GRAVITY; + values[2] = -data->gforce.y * SDL_STANDARD_GRAVITY; + SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_ACCEL, 0, values, 3); +} + +static void _HandleWiiJoystickUpdate(SDL_Joystick *joystick) +{ + u32 changed, pressed; + int axis, wpad_index; + joystick_hwdata *prev_state; + WPADData *data; + bool update_wiimote, update_expansion; + + prev_state = joystick->hwdata; + if (split_joysticks) { + if (joystick->hwdata->index >= WII_EXP_START) { + wpad_index = joystick->hwdata->index - WII_EXP_START; + update_wiimote = false; + update_expansion = true; + } else { + wpad_index = joystick->hwdata->index - WII_WIIMOTES_START; + update_wiimote = true; + update_expansion = false; + } + } else { + wpad_index = joystick->hwdata->index - WII_WIIMOTES_START; + update_wiimote = true; + update_expansion = true; + } + + if (update_wiimote) { + update_rumble(joystick); + } + + if (!s_wii_has_new_data[wpad_index]) + return; + + data = WPAD_Data(wpad_index); + changed = data->btns_d | data->btns_u; + pressed = data->btns_d | data->btns_h; + + if (update_wiimote) { + HandleWiiHats(joystick, changed, pressed, _buttons); + } + if (update_expansion) { + if (data->exp.type == WPAD_EXP_CLASSIC) { + HandleWiiHats(joystick, changed, pressed, _buttons + 4); + } + } + + if (split_joysticks) { + if (update_wiimote) { + HandleWiiButtons(joystick, changed, data, + sdl_buttons_wiimote, SDL_WII_NUM_BUTTONS_WIIMOTE); + } + if (update_expansion) { + if (data->exp.type == WPAD_EXP_CLASSIC) { + HandleWiiButtons(joystick, changed, data, + sdl_buttons_classic, SDL_WII_NUM_BUTTONS_CLASSIC); + } else if (data->exp.type == WPAD_EXP_NUNCHUK) { + HandleWiiButtons(joystick, changed, data, + sdl_buttons_nunchuck, SDL_WII_NUM_BUTTONS_NUNCHUCK); + } + } + } else { + HandleWiiButtons(joystick, changed, data, + sdl_buttons_wii, SDL_WII_NUM_BUTTONS_WII); + } + + if (update_expansion) { + if (data->exp.type == WPAD_EXP_CLASSIC) { + if (prev_state->wiimote.exp != WPAD_EXP_CLASSIC) { + prev_state->wiimote.classic_calibrated = 0; + prev_state->wiimote.classic_cal[0][0] = 5; // left x min + prev_state->wiimote.classic_cal[0][2] = 59; // left x max + prev_state->wiimote.classic_cal[1][0] = 5; // left y min + prev_state->wiimote.classic_cal[1][2] = 59; // left y max + prev_state->wiimote.classic_cal[2][0] = 5; // right x min + prev_state->wiimote.classic_cal[2][2] = 27; // right x max + prev_state->wiimote.classic_cal[3][0] = 5; // right y min + prev_state->wiimote.classic_cal[3][2] = 27; // right y max + } + + // max/min checking + // left stick x + if (data->exp.classic.ljs.pos.x < prev_state->wiimote.classic_cal[0][0]) + prev_state->wiimote.classic_cal[0][0] = data->exp.classic.ljs.pos.x; + else if (data->exp.classic.ljs.pos.x > prev_state->wiimote.classic_cal[0][2]) + prev_state->wiimote.classic_cal[0][2] = data->exp.classic.ljs.pos.x; + // left stick y + if (data->exp.classic.ljs.pos.y < prev_state->wiimote.classic_cal[1][0]) + prev_state->wiimote.classic_cal[1][0] = data->exp.classic.ljs.pos.y; + else if (data->exp.classic.ljs.pos.y > prev_state->wiimote.classic_cal[1][2]) + prev_state->wiimote.classic_cal[1][2] = data->exp.classic.ljs.pos.y; + // right stick x + if (data->exp.classic.rjs.pos.x < prev_state->wiimote.classic_cal[2][0]) + prev_state->wiimote.classic_cal[2][0] = data->exp.classic.rjs.pos.x; + else if (data->exp.classic.rjs.pos.x > prev_state->wiimote.classic_cal[2][2]) + prev_state->wiimote.classic_cal[2][2] = data->exp.classic.rjs.pos.x; + // right stick y + if (data->exp.classic.rjs.pos.y < prev_state->wiimote.classic_cal[3][0]) + prev_state->wiimote.classic_cal[3][0] = data->exp.classic.rjs.pos.y; + else if (data->exp.classic.rjs.pos.y > prev_state->wiimote.classic_cal[3][2]) + prev_state->wiimote.classic_cal[3][2] = data->exp.classic.rjs.pos.y; + + // calibrate center positions + if (prev_state->wiimote.classic_calibrated < 5) { + prev_state->wiimote.classic_cal[0][1] = data->exp.classic.ljs.pos.x; + prev_state->wiimote.classic_cal[1][1] = data->exp.classic.ljs.pos.y; + prev_state->wiimote.classic_cal[2][1] = data->exp.classic.rjs.pos.x; + prev_state->wiimote.classic_cal[3][1] = data->exp.classic.rjs.pos.y; + // this is zero if the expansion hasn't finished initializing + if (data->exp.classic.ljs.max.x) + prev_state->wiimote.classic_calibrated++; + } + } + + if (data->exp.type != prev_state->wiimote.exp) { + // Reset the expansion axes + for (int i = 0; i < 6; i++) + SDL_PrivateJoystickAxis(joystick, i, 0); + } + + if (data->exp.type == WPAD_EXP_CLASSIC) { + axis = WPAD_Stick(data->exp.classic.ljs.pos.x, prev_state->wiimote.classic_cal[0][0], + prev_state->wiimote.classic_cal[0][1], prev_state->wiimote.classic_cal[0][2], 0); + if (prev_state->wiimote.classicL_stickX != axis) { + SDL_PrivateJoystickAxis(joystick, 0, axis); + prev_state->wiimote.classicL_stickX = axis; + } + // y axes are reversed + axis = WPAD_Stick(data->exp.classic.ljs.pos.y, prev_state->wiimote.classic_cal[1][0], + prev_state->wiimote.classic_cal[1][1], prev_state->wiimote.classic_cal[1][2], 1); + if (prev_state->wiimote.classicL_stickY != axis) { + SDL_PrivateJoystickAxis(joystick, 1, axis); + prev_state->wiimote.classicL_stickY = axis; + } + axis = WPAD_Stick(data->exp.classic.rjs.pos.x, prev_state->wiimote.classic_cal[2][0], + prev_state->wiimote.classic_cal[2][1], prev_state->wiimote.classic_cal[2][2], 0); + if (prev_state->wiimote.classicR_stickX != axis) { + SDL_PrivateJoystickAxis(joystick, 2, axis); + prev_state->wiimote.classicR_stickX = axis; + } + axis = WPAD_Stick(data->exp.classic.rjs.pos.y, prev_state->wiimote.classic_cal[3][0], + prev_state->wiimote.classic_cal[3][1], prev_state->wiimote.classic_cal[3][2], 1); + if (prev_state->wiimote.classicR_stickY != axis) { + SDL_PrivateJoystickAxis(joystick, 3, axis); + prev_state->wiimote.classicR_stickY = axis; + } + axis = data->exp.classic.r_shoulder; + if (prev_state->wiimote.classic_triggerR != axis) { + SDL_PrivateJoystickAxis(joystick, 4, axis << 8); + prev_state->wiimote.classic_triggerR = axis; + } + axis = data->exp.classic.l_shoulder; + if (prev_state->wiimote.classic_triggerL != axis) { + SDL_PrivateJoystickAxis(joystick, 5, axis << 8); + prev_state->wiimote.classic_triggerL = axis; + } + } else if (data->exp.type == WPAD_EXP_NUNCHUK) { + axis = WPAD_Stick(data->exp.nunchuk.js.pos.x, data->exp.nunchuk.js.min.x, + data->exp.nunchuk.js.center.x, data->exp.nunchuk.js.max.x, 0); + if (prev_state->wiimote.nunchuk_stickX != axis) { + SDL_PrivateJoystickAxis(joystick, 0, axis); + prev_state->wiimote.nunchuk_stickX = axis; + } + axis = WPAD_Stick(data->exp.nunchuk.js.pos.y, data->exp.nunchuk.js.min.y, + data->exp.nunchuk.js.center.y, data->exp.nunchuk.js.max.y, 1); + if (prev_state->wiimote.nunchuk_stickY != axis) { + SDL_PrivateJoystickAxis(joystick, 1, axis); + prev_state->wiimote.nunchuk_stickY = axis; + } + + HandleNunchuckSensors(joystick, &data->exp.nunchuk); + } + } + + prev_state->wiimote.exp = data->exp.type; + + if (update_wiimote) { + if (s_accelerometers_as_axes) { + int start_index = split_joysticks ? 0 : 6; + HandleWiiMotion(joystick, prev_state, data, start_index); + } + HandleWiimoteSensors(joystick, data); + } +} +#endif /* __wii__ */ + +static void _HandleGCJoystickUpdate(SDL_Joystick *joystick) +{ + u16 buttons, prev_buttons, changed; + int i; + int axis; + joystick_hwdata *prev_state; + int index = joystick->hwdata->index - GC_JOYSTICKS_START; + + update_rumble(joystick); + + buttons = PAD_ButtonsHeld(index); + prev_state = joystick->hwdata; + prev_buttons = prev_state->gamecube.prev_buttons; + changed = buttons ^ prev_buttons; + + if (changed & (PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT | PAD_BUTTON_DOWN | PAD_BUTTON_UP)) { + int hat = SDL_HAT_CENTERED; + if (buttons & PAD_BUTTON_UP) + hat |= SDL_HAT_UP; + if (buttons & PAD_BUTTON_DOWN) + hat |= SDL_HAT_DOWN; + if (buttons & PAD_BUTTON_LEFT) + hat |= SDL_HAT_LEFT; + if (buttons & PAD_BUTTON_RIGHT) + hat |= SDL_HAT_RIGHT; + SDL_PrivateJoystickHat(joystick, 0, hat); + } + + for (i = 0; i < (sizeof(sdl_buttons_gc) / sizeof(sdl_buttons_gc[0])); i++) { + if (changed & sdl_buttons_gc[i]) + SDL_PrivateJoystickButton(joystick, i, + (buttons & sdl_buttons_gc[i]) ? SDL_PRESSED : SDL_RELEASED); + } + prev_state->gamecube.prev_buttons = buttons; + axis = PAD_StickX(index); + if (prev_state->gamecube.stickX != axis) { + SDL_PrivateJoystickAxis(joystick, 0, axis << 8); + prev_state->gamecube.stickX = axis; + } + + axis = PAD_StickY(index); + if (prev_state->gamecube.stickY != axis) { + SDL_PrivateJoystickAxis(joystick, 1, (-axis) << 8); + prev_state->gamecube.stickY = axis; + } + + axis = PAD_SubStickX(index); + if (prev_state->gamecube.substickX != axis) { + SDL_PrivateJoystickAxis(joystick, 2, axis << 8); + prev_state->gamecube.substickX = axis; + } + + axis = PAD_SubStickY(index); + if (prev_state->gamecube.substickY != axis) { + SDL_PrivateJoystickAxis(joystick, 3, (-axis) << 8); + prev_state->gamecube.substickY = axis; + } + + axis = PAD_TriggerL(index); + if (prev_state->gamecube.triggerL != axis) { + SDL_PrivateJoystickAxis(joystick, 4, axis << 7); + prev_state->gamecube.triggerL = axis; + } + + axis = PAD_TriggerR(index); + if (prev_state->gamecube.triggerR != axis) { + SDL_PrivateJoystickAxis(joystick, 5, axis << 7); + prev_state->gamecube.triggerR = axis; + } +} + +static void OGC_JoystickUpdate(SDL_Joystick *joystick) +{ + if (!joystick || !joystick->hwdata) + return; + + scan_hardware(); + + if (joystick->hwdata->index >= GC_JOYSTICKS_START && + joystick->hwdata->index < GC_JOYSTICKS_END) { + _HandleGCJoystickUpdate(joystick); +#ifdef __wii__ + } else { + _HandleWiiJoystickUpdate(joystick); +#endif + } +} + +static void OGC_JoystickClose(SDL_Joystick *joystick) +{ + if (!joystick || !joystick->hwdata) // joystick already closed + return; + + SDL_free(joystick->hwdata); + joystick->hwdata = NULL; +} + +void OGC_JoystickQuit(void) +{ +#ifdef __wii__ + SDL_DelHintCallback(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, + on_hint_accel_as_joystick_cb, NULL); +#endif +} + +static SDL_bool OGC_JoystickGetGamepadMapping(int device_index, + SDL_GamepadMapping *out) +{ + int index = device_index_to_joypad_index(device_index); + SDL_bool is_gamepad = SDL_FALSE; + + if (index >= GC_JOYSTICKS_START && index < GC_JOYSTICKS_END) { + *out = (SDL_GamepadMapping){ + .a = { EMappingKind_Button, 0 }, + .b = { EMappingKind_Button, 2 }, + .x = { EMappingKind_Button, 1 }, + .y = { EMappingKind_Button, 3 }, + .back = { EMappingKind_Button, 6 }, + .guide = { EMappingKind_None, 255 }, + .start = { EMappingKind_Button, 7 }, + .leftstick = { EMappingKind_None, 255 }, + .rightstick = { EMappingKind_None, 255 }, + .leftshoulder = { EMappingKind_Button, 4 }, + .rightshoulder = { EMappingKind_Button, 5 }, + .dpup = { EMappingKind_Hat, 0x01 }, + .dpdown = { EMappingKind_Hat, 0x04 }, + .dpleft = { EMappingKind_Hat, 0x08 }, + .dpright = { EMappingKind_Hat, 0x02 }, + .misc1 = { EMappingKind_None, 255 }, + .paddle1 = { EMappingKind_None, 255 }, + .paddle2 = { EMappingKind_None, 255 }, + .paddle3 = { EMappingKind_None, 255 }, + .paddle4 = { EMappingKind_None, 255 }, + .leftx = { EMappingKind_Axis, 0 }, + .lefty = { EMappingKind_Axis, 1 }, + .rightx = { EMappingKind_Axis, 2 }, + .righty = { EMappingKind_Axis, 3 }, + .lefttrigger = { EMappingKind_Axis, 4 }, + .righttrigger = { EMappingKind_Axis, 5 }, + }; + is_gamepad = SDL_TRUE; +#ifdef __wii__ + } else if (index >= WII_WIIMOTES_START && index < WII_WIIMOTES_END) { + int expansion = s_detected_devices[index] - 1; + if (split_joysticks || expansion == 0) { + /* Wiimote alone; assume it's being held sideways */ + *out = (SDL_GamepadMapping){ + .a = { EMappingKind_Button, 2 }, + .b = { EMappingKind_Button, 3 }, + .x = { EMappingKind_Button, 0 }, + .y = { EMappingKind_Button, 1 }, + .back = { EMappingKind_Button, 6 }, + .guide = { EMappingKind_Button, 4 }, + .start = { EMappingKind_Button, 5 }, + .leftstick = { EMappingKind_None, 255 }, + .rightstick = { EMappingKind_None, 255 }, + .leftshoulder = { EMappingKind_None, 255 }, + .rightshoulder = { EMappingKind_None, 255 }, + .dpup = { EMappingKind_Hat, 0x02 }, + .dpdown = { EMappingKind_Hat, 0x08 }, + .dpleft = { EMappingKind_Hat, 0x01 }, + .dpright = { EMappingKind_Hat, 0x04 }, + .misc1 = { EMappingKind_None, 255 }, + .paddle1 = { EMappingKind_None, 255 }, + .paddle2 = { EMappingKind_None, 255 }, + .paddle3 = { EMappingKind_None, 255 }, + .paddle4 = { EMappingKind_None, 255 }, + .leftx = { EMappingKind_Axis, 0 }, + .lefty = { EMappingKind_Axis, 1 }, + .rightx = { EMappingKind_None, 255 }, + .righty = { EMappingKind_None, 255 }, + .lefttrigger = { EMappingKind_None, 255 }, + .righttrigger = { EMappingKind_None, 255 }, + }; + is_gamepad = SDL_TRUE; + } else if (expansion == WPAD_EXP_NUNCHUK) { + /* Wiimote with nunchuck; assume nunchuck on left hand, wiimote + * pointed at screen */ + *out = (SDL_GamepadMapping){ + .a = { EMappingKind_Button, 0 }, + .b = { EMappingKind_Button, 1 }, + .x = { EMappingKind_Button, 7 }, + .y = { EMappingKind_Button, 8 }, + .back = { EMappingKind_Button, 6 }, + .guide = { EMappingKind_Button, 4 }, + .start = { EMappingKind_Button, 5 }, + .leftstick = { EMappingKind_None, 255 }, + .rightstick = { EMappingKind_None, 255 }, + .leftshoulder = { EMappingKind_None, 255 }, + .rightshoulder = { EMappingKind_None, 255 }, + .dpup = { EMappingKind_Hat, 0x01 }, + .dpdown = { EMappingKind_Hat, 0x04 }, + .dpleft = { EMappingKind_Hat, 0x08 }, + .dpright = { EMappingKind_Hat, 0x02 }, + .misc1 = { EMappingKind_None, 255 }, + .paddle1 = { EMappingKind_None, 255 }, + .paddle2 = { EMappingKind_None, 255 }, + .paddle3 = { EMappingKind_None, 255 }, + .paddle4 = { EMappingKind_None, 255 }, + .leftx = { EMappingKind_Axis, 0 }, + .lefty = { EMappingKind_Axis, 1 }, + .rightx = { EMappingKind_Axis, 2 }, + .righty = { EMappingKind_Axis, 3 }, + .lefttrigger = { EMappingKind_None, 255 }, + .righttrigger = { EMappingKind_None, 255 }, + }; + is_gamepad = SDL_TRUE; + } else if (expansion == WPAD_EXP_CLASSIC) { + *out = (SDL_GamepadMapping){ + .a = { EMappingKind_Button, 1 }, + .b = { EMappingKind_Button, 0 }, + .x = { EMappingKind_Button, 10 }, + .y = { EMappingKind_Button, 9 }, + .back = { EMappingKind_Button, 6 }, + .guide = { EMappingKind_Button, 4 }, + .start = { EMappingKind_Button, 5 }, + .leftstick = { EMappingKind_None, 255 }, + .rightstick = { EMappingKind_None, 255 }, + .leftshoulder = { EMappingKind_Button, 11 }, + .rightshoulder = { EMappingKind_Button, 12 }, + .dpup = { EMappingKind_Hat, 0x01 }, + .dpdown = { EMappingKind_Hat, 0x04 }, + .dpleft = { EMappingKind_Hat, 0x08 }, + .dpright = { EMappingKind_Hat, 0x02 }, + .misc1 = { EMappingKind_None, 255 }, + .paddle1 = { EMappingKind_None, 255 }, + .paddle2 = { EMappingKind_None, 255 }, + .paddle3 = { EMappingKind_None, 255 }, + .paddle4 = { EMappingKind_None, 255 }, + .leftx = { EMappingKind_Axis, 0 }, + .lefty = { EMappingKind_Axis, 1 }, + .rightx = { EMappingKind_Axis, 2 }, + .righty = { EMappingKind_Axis, 3 }, + .lefttrigger = { EMappingKind_Button, 13 }, + .righttrigger = { EMappingKind_Button, 14 }, + }; + is_gamepad = SDL_TRUE; + } + } else if (index >= WII_EXP_START && index < WII_EXP_END) { + /* Wiimote + Extension: only support the classic controller, any other + * device is useless as a gamepad. */ + int expansion = s_detected_devices[index] - 1; + if (expansion != WPAD_EXP_CLASSIC) + return SDL_FALSE; + *out = (SDL_GamepadMapping){ + .a = { EMappingKind_Button, 1 }, + .b = { EMappingKind_Button, 0 }, + .x = { EMappingKind_Button, 3 }, + .y = { EMappingKind_Button, 2 }, + .back = { EMappingKind_Button, 10 }, + .guide = { EMappingKind_Button, 8 }, + .start = { EMappingKind_Button, 9 }, + .leftstick = { EMappingKind_None, 255 }, + .rightstick = { EMappingKind_None, 255 }, + .leftshoulder = { EMappingKind_Button, 4 }, + .rightshoulder = { EMappingKind_Button, 5 }, + .dpup = { EMappingKind_Hat, 0x01 }, + .dpdown = { EMappingKind_Hat, 0x04 }, + .dpleft = { EMappingKind_Hat, 0x08 }, + .dpright = { EMappingKind_Hat, 0x02 }, + .misc1 = { EMappingKind_None, 255 }, + .paddle1 = { EMappingKind_None, 255 }, + .paddle2 = { EMappingKind_None, 255 }, + .paddle3 = { EMappingKind_None, 255 }, + .paddle4 = { EMappingKind_None, 255 }, + .leftx = { EMappingKind_Axis, 0 }, + .lefty = { EMappingKind_Axis, 1 }, + .rightx = { EMappingKind_Axis, 2 }, + .righty = { EMappingKind_Axis, 3 }, + .lefttrigger = { EMappingKind_Button, 6 }, + .righttrigger = { EMappingKind_Button, 7 }, + }; + is_gamepad = SDL_TRUE; +#endif /* __wii__ */ + } + return is_gamepad; +} + +SDL_JoystickDriver SDL_OGC_JoystickDriver = { + .Init = OGC_JoystickInit, + .GetCount = OGC_JoystickGetCount, + .Detect = OGC_JoystickDetect, + .GetDeviceName = OGC_JoystickGetDeviceName, + .GetDevicePath = OGC_JoystickGetDevicePath, + .GetDevicePlayerIndex = OGC_JoystickGetDevicePlayerIndex, + .SetDevicePlayerIndex = OGC_JoystickSetDevicePlayerIndex, + .GetDeviceGUID = OGC_JoystickGetDeviceGUID, + .GetDeviceInstanceID = OGC_JoystickGetDeviceInstanceID, + .Open = OGC_JoystickOpen, + .Rumble = OGC_JoystickRumble, + .RumbleTriggers = OGC_JoystickRumbleTriggers, + .GetCapabilities = OGC_JoystickGetCapabilities, + .SetLED = OGC_JoystickSetLED, + .SendEffect = OGC_JoystickSendEffect, + .SetSensorsEnabled = OGC_JoystickSetSensorsEnabled, + .Update = OGC_JoystickUpdate, + .Close = OGC_JoystickClose, + .Quit = OGC_JoystickQuit, + .GetGamepadMapping = OGC_JoystickGetGamepadMapping +}; + +#endif /* SDL_JOYSTICK_OGC */ + +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/main/gamecube/SDL_gamecube_main.c b/src/main/gamecube/SDL_gamecube_main.c new file mode 100644 index 0000000000..f0d42bed96 --- /dev/null +++ b/src/main/gamecube/SDL_gamecube_main.c @@ -0,0 +1,54 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" + +#ifdef __gamecube__ + +#include "SDL_main.h" + +#ifdef main +#undef main +#endif + +/* Standard includes */ +#include + +/* OGC includes */ +#include +#include + +/* Do initialisation which has to be done first for the console to work */ +/* Entry point */ +int main(int argc, char *argv[]) +{ + // SYS_SetPowerCallback(ShutdownCB); + // SYS_SetResetCallback(ResetCB); + fatInitDefault(); + /* Temporarily while developing SDL */ + SDL_LogSetAllPriority(SDL_LOG_PRIORITY_DEBUG); + /* Call the user's main function */ + return (SDL_main(argc, argv)); +} + +#endif /* __gamecube__ */ + +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/main/wii/SDL_wii_main.c b/src/main/wii/SDL_wii_main.c new file mode 100644 index 0000000000..ec6329d5f0 --- /dev/null +++ b/src/main/wii/SDL_wii_main.c @@ -0,0 +1,91 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" + +#ifdef __wii__ + +#include "SDL_main.h" + +#include "../../video/ogc/SDL_ogcevents_c.h" + +#ifdef main +#undef main +#endif + +/* Standard includes */ +#include + +/* OGC includes */ +#include +#include +#include +#include +#include + +static void ShutdownCB() +{ + OGC_PowerOffRequested = true; +} + +static void ResetCB(u32, void *) +{ + OGC_ResetRequested = true; +} + +int main(int argc, char *argv[]) +{ + u32 version; + s32 preferred; + + L2Enhance(); + version = IOS_GetVersion(); + preferred = IOS_GetPreferredVersion(); + + if (preferred > 0 && version != (u32)preferred) + IOS_ReloadIOS(preferred); + + // Wii Power/Reset buttons + WPAD_Init(); + WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB); + SYS_SetPowerCallback(ShutdownCB); + SYS_SetResetCallback(ResetCB); + // TODO OGC_InitVideoSystem(); + WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR); + WPAD_SetVRes(WPAD_CHAN_ALL, 640, 480); + + MOUSE_Init(); + KEYBOARD_Init(NULL); + fatInitDefault(); + + /* Call the user's main function. Make sure that argv contains at least one + * element. */ + if (!argv || argv[0] == NULL) { + static const char *dummy_argv[2] = { "app", NULL }; + argc = 1; + argv = (char**)dummy_argv; + } + return SDL_main(argc, argv); +} + +#endif /* __wii__ */ + +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index b650c6ac40..dc7a5b0b26 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -124,6 +124,9 @@ static const SDL_RenderDriver *render_drivers[] = { #if SDL_VIDEO_RENDER_VITA_GXM &VITA_GXM_RenderDriver, #endif +#ifdef SDL_VIDEO_RENDER_OGC + &OGC_RenderDriver, +#endif #if SDL_VIDEO_RENDER_SW &SW_RenderDriver #endif diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h index 36e9555bb1..d3db2b3879 100644 --- a/src/render/SDL_sysrender.h +++ b/src/render/SDL_sysrender.h @@ -307,6 +307,7 @@ extern SDL_RenderDriver PS2_RenderDriver; extern SDL_RenderDriver PSP_RenderDriver; extern SDL_RenderDriver SW_RenderDriver; extern SDL_RenderDriver VITA_GXM_RenderDriver; +extern SDL_RenderDriver OGC_RenderDriver; /* Blend mode functions */ extern SDL_BlendFactor SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode); diff --git a/src/render/ogc/SDL_render_ogc.c b/src/render/ogc/SDL_render_ogc.c new file mode 100644 index 0000000000..39996c8aec --- /dev/null +++ b/src/render/ogc/SDL_render_ogc.c @@ -0,0 +1,786 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_VIDEO_RENDER_OGC + +#include "../SDL_sysrender.h" +#include "SDL_hints.h" + +#include "../../video/ogc/SDL_ogcgxcommon.h" +#include "../../video/ogc/SDL_ogcpixels.h" +#include "../../video/ogc/SDL_ogcvideo.h" + +#include +#include +#include +#include + +#define MAX_EFB_WIDTH 640 +#define MAX_EFB_HEIGHT 528 + +typedef struct +{ + SDL_BlendMode current_blend_mode; + int ops_after_present; + bool vsync; + u8 efb_pixel_format; + SDL_Texture *render_target; + SDL_Texture *saved_efb_texture; +} OGC_RenderData; + +typedef struct +{ + void *texels; + void *pixels; + SDL_Rect pixels_rect; + u16 pitch; + u16 pixels_pitch; + u8 format; + u8 needed_stages; // Normally 1, set to 2 for palettized formats +} OGC_TextureData; + +static void OGC_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); + +static void OGC_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) +{ +} + +static void set_blend_mode_real(SDL_Renderer *renderer, SDL_BlendMode blend_mode) +{ + switch (blend_mode) { + case SDL_BLENDMODE_NONE: + GX_SetBlendMode(GX_BM_NONE, GX_BL_ONE, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + break; + case SDL_BLENDMODE_BLEND: + GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + break; + case SDL_BLENDMODE_ADD: + GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_ONE, GX_LO_CLEAR); + break; + case SDL_BLENDMODE_MOD: + GX_SetBlendMode(GX_BM_BLEND, GX_BL_DSTCLR, GX_BL_ZERO, GX_LO_CLEAR); + break; + case SDL_BLENDMODE_MUL: + GX_SetBlendMode(GX_BM_BLEND, GX_BL_DSTCLR, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + break; + default: + return; + } +} + +static inline void OGC_SetBlendMode(SDL_Renderer *renderer, SDL_BlendMode blend_mode) +{ + OGC_RenderData *data = renderer->driverdata; + + if (blend_mode == data->current_blend_mode) { + /* Nothing to do */ + return; + } + + set_blend_mode_real(renderer, blend_mode); + data->current_blend_mode = blend_mode; +} + +static void load_efb_from_texture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + OGC_TextureData *ogc_tex = texture->driverdata; + + OGC_load_texture(ogc_tex->texels, texture->w, texture->h, + ogc_tex->format, SDL_ScaleModeNearest); + OGC_SetBlendMode(renderer, SDL_BLENDMODE_NONE); + + /* The viewport is reset when OGC_SetRenderTarget() returns. */ + OGC_set_viewport(0, 0, texture->w, texture->h); + + GX_ClearVtxDesc(); + GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_S16, 0); + + GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_U8, 0); + GX_SetNumTexGens(1); + GX_SetNumChans(0); + + GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); + GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL); + GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE); + GX_SetNumTevStages(1); + + GX_Begin(GX_QUADS, GX_VTXFMT0, 4); + GX_Position2s16(0, 0); + GX_TexCoord2u8(0, 0); + GX_Position2s16(texture->w, 0); + GX_TexCoord2u8(1, 0); + GX_Position2s16(texture->w, texture->h); + GX_TexCoord2u8(1, 1); + GX_Position2s16(0, texture->h); + GX_TexCoord2u8(0, 1); + GX_End(); +} + +static void save_efb_to_texture(SDL_Texture *texture, bool must_clear) +{ + OGC_TextureData *ogc_tex = texture->driverdata; + u32 texture_size; + + texture_size = GX_GetTexBufferSize(texture->w, texture->h, ogc_tex->format, + GX_FALSE, 0); + DCInvalidateRange(ogc_tex->texels, texture_size); + + GX_SetTexCopySrc(0, 0, texture->w, texture->h); + GX_SetTexCopyDst(texture->w, texture->h, ogc_tex->format, GX_FALSE); + GX_CopyTex(ogc_tex->texels, must_clear ? GX_TRUE : GX_FALSE); + GX_PixModeSync(); +} + +static void update_texture(SDL_Texture *texture, const SDL_Rect *rect, + const void *pixels, int pitch) +{ + OGC_TextureData *ogc_tex = texture->driverdata; + u32 texture_size; + + OGC_pixels_to_texture((void*)pixels, texture->format, rect, + pitch, ogc_tex->texels, texture->w); + texture_size = GX_GetTexBufferSize(texture->w, texture->h, ogc_tex->format, + GX_FALSE, 0); + /* It would be more effective if we updated only the changed range here, + * but the complexity is probably not worth the effort. */ + DCStoreRange(ogc_tex->texels, texture_size); + GX_InvalidateTexAll(); +} + +static int OGC_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + u32 texture_size; + OGC_TextureData *ogc_tex; + + ogc_tex = SDL_calloc(1, sizeof(OGC_TextureData)); + if (!ogc_tex) { + return SDL_OutOfMemory(); + } + + ogc_tex->format = OGC_texture_format_from_SDL(texture->format); + ogc_tex->needed_stages = (ogc_tex->format == GX_TF_CI8) ? 2 : 1; + texture_size = GX_GetTexBufferSize(texture->w, texture->h, ogc_tex->format, + GX_FALSE, 0); + ogc_tex->texels = memalign(32, texture_size); + if (!ogc_tex->texels) { + SDL_free(ogc_tex); + return SDL_OutOfMemory(); + } + + texture->driverdata = ogc_tex; + return 0; +} + +static int OGC_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch) +{ + OGC_TextureData *ogc_tex = texture->driverdata; + + ogc_tex->pixels = SDL_malloc(rect->w * rect->h * SDL_BYTESPERPIXEL(texture->format)); + ogc_tex->pixels_pitch = rect->w * SDL_BYTESPERPIXEL(texture->format); + ogc_tex->pixels_rect = *rect; + *pixels = ogc_tex->pixels; + *pitch = ogc_tex->pixels_pitch; + return 0; +} + +static void OGC_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + OGC_TextureData *ogc_tex = texture->driverdata; + + update_texture(texture, &ogc_tex->pixels_rect, + ogc_tex->pixels, ogc_tex->pixels_pitch); + + if (ogc_tex->pixels) { + SDL_free(ogc_tex->pixels); + ogc_tex->pixels = NULL; + } +} + +static int OGC_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *pixels, int pitch) +{ + update_texture(texture, rect, pixels, pitch); + return 0; +} + +static void OGC_SetTextureScaleMode(SDL_Renderer *renderer, + SDL_Texture *texture, + SDL_ScaleMode scaleMode) +{ + /* Nothing to do here: the scale mode is applied to the texture when + * loading it in OGC_load_texture(). */ +} + +static SDL_Texture *create_efb_texture(OGC_RenderData *data, SDL_Window *window) +{ + /* Note: we do return a SDL_Texture, but not via SDL's API, since that does + * a bunch of other stuffs we don't care about. We create this texture for + * our internal use, so we initialize only those fields we care about. */ + SDL_Texture *texture; + OGC_TextureData *ogc_tex; + u32 texture_size; + + texture = SDL_calloc(1, sizeof(*texture)); + if (!texture) goto fail_texture_alloc; + + ogc_tex = SDL_calloc(1, sizeof(OGC_TextureData)); + if (!ogc_tex) goto fail_ogc_tex_alloc; + + ogc_tex->format = data->efb_pixel_format == GX_PF_RGBA6_Z24 ? + GX_TF_RGBA8 : GX_TF_RGB565; + texture->w = window->w; + texture->h = window->h; + texture_size = GX_GetTexBufferSize(texture->w, texture->h, ogc_tex->format, + GX_FALSE, 0); + ogc_tex->texels = memalign(32, texture_size); + if (!ogc_tex->texels) goto fail_texels_alloc; + + texture->driverdata = ogc_tex; + return texture; + +fail_texels_alloc: + SDL_free(ogc_tex->texels); +fail_ogc_tex_alloc: + SDL_free(texture); +fail_texture_alloc: + SDL_OutOfMemory(); + return NULL; +} + +static int OGC_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) +{ + OGC_RenderData *data = renderer->driverdata; + u8 desired_efb_pixel_format = GX_PF_RGB8_Z24; + + if (data->render_target) { + save_efb_to_texture(data->render_target, false); + } else if (data->ops_after_present > 0) { + /* Save the current EFB contents if we already drew something onto + * it. We'll restore it later, when the rendering target is reset + * to NULL (the screen). */ + if (!data->saved_efb_texture) + data->saved_efb_texture = create_efb_texture(data, renderer->window); + save_efb_to_texture(data->saved_efb_texture, false); + } + + if (texture) { + if (texture->w > MAX_EFB_WIDTH || texture->h > MAX_EFB_HEIGHT) { + return SDL_SetError("Render target (%dx%d) bigger than EFB", texture->w, texture->h); + } + + if (SDL_ISPIXELFORMAT_ALPHA(texture->format)) { + desired_efb_pixel_format = GX_PF_RGBA6_Z24; + } + } + + data->render_target = texture; + + if (desired_efb_pixel_format != data->efb_pixel_format) { + data->efb_pixel_format = desired_efb_pixel_format; + GX_SetPixelFmt(data->efb_pixel_format, GX_ZC_LINEAR); + } + + if (texture) { + load_efb_from_texture(renderer, texture); + } else if (data->saved_efb_texture) { + /* Restore the EFB to how it was before the we started to render to a + * texture. */ + load_efb_from_texture(renderer, data->saved_efb_texture); + /* We don't free data->saved_efb_texture, it will be reused */ + } + + return 0; +} + +static int OGC_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +{ + return 0; /* nothing to do in this backend. */ +} + +static int OGC_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, + const SDL_FPoint *points, int count) +{ + size_t size = count * sizeof(SDL_FPoint); + SDL_FPoint *vertices = SDL_AllocateRenderVertices(renderer, size, + 4, &cmd->data.draw.first); + if (!vertices) { + return -1; + } + + cmd->data.draw.count = count; + SDL_memcpy(vertices, points, size); + return 0; +} + +static int OGC_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, + const SDL_FRect *rects, int count) +{ + size_t size = count * sizeof(SDL_FPoint) * 4; + SDL_FPoint *vertices = SDL_AllocateRenderVertices(renderer, size, + 4, &cmd->data.draw.first); + if (!vertices) { + return -1; + } + + cmd->data.draw.count = count; + for (int i = 0; i < count; i++) { + vertices[i].x = rects[i].x; + vertices[i].y = rects[i].y; + vertices[i+1].x = rects[i].x + rects[i].w; + vertices[i+1].y = rects[i].y; + vertices[i+2].x = rects[i].x + rects[i].w; + vertices[i+2].y = rects[i].y + rects[i].h; + vertices[i+3].x = rects[i].x; + vertices[i+3].y = rects[i].y + rects[i].h; + } + return 0; +} + +static int OGC_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, + const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) +{ + int i; + int count = indices ? num_indices : num_vertices; + size_t size_per_element; + char *vertices; + + cmd->data.draw.count = count; + size_indices = indices ? size_indices : 0; + + size_per_element = sizeof(SDL_FPoint) + sizeof(SDL_Color); + if (texture) { + size_per_element += sizeof(SDL_FPoint); + } + + vertices = SDL_AllocateRenderVertices(renderer, count * size_per_element, + 4, &cmd->data.draw.first); + if (!vertices) { + return -1; + } + + for (i = 0; i < count; i++) { + int j; + float *xy_; + float *uv_; + SDL_Color col; + char *vertex; + SDL_FPoint *vertex_xy; + if (size_indices == 4) { + j = ((const Uint32 *)indices)[i]; + } else if (size_indices == 2) { + j = ((const Uint16 *)indices)[i]; + } else if (size_indices == 1) { + j = ((const Uint8 *)indices)[i]; + } else { + j = i; + } + + xy_ = (float *)((char *)xy + j * xy_stride); + col = *(SDL_Color *)((char *)color + j * color_stride); + uv_ = (float *)((char *)uv + j * uv_stride); + + vertex = vertices + size_per_element * i; + + vertex_xy = (SDL_FPoint *)vertex; + vertex_xy->x = xy_[0] * scale_x; + vertex_xy->y = xy_[1] * scale_x; + + *(SDL_Color *)(vertex + sizeof(SDL_FPoint)) = col; + + if (texture) { + SDL_FPoint *vertex_uv = (SDL_FPoint *)(vertex + sizeof(SDL_FPoint) + sizeof(SDL_Color)); + vertex_uv->x = uv_[0]; + vertex_uv->y = uv_[1]; + } + } + + return 0; +} + +static int OGC_RenderSetViewPort(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +{ + const SDL_Rect *viewport = &cmd->data.viewport.rect; + + OGC_set_viewport(viewport->x, viewport->y, viewport->w, viewport->h); + return 0; +} + +static int OGC_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +{ + const SDL_Rect *rect = &cmd->data.cliprect.rect; + + if (cmd->data.cliprect.enabled) { + GX_SetScissor(renderer->viewport.x + rect->x, + renderer->viewport.y + rect->y, + rect->w, rect->h); + } else { + GX_SetScissor(renderer->viewport.x, + renderer->viewport.y, + renderer->viewport.w, + renderer->viewport.h); + } + + return 0; +} + +static int OGC_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +{ + OGC_RenderData *data = renderer->driverdata; + + GXColor c = { + cmd->data.color.r, + cmd->data.color.g, + cmd->data.color.b, + cmd->data.color.a + }; + int16_t x1 = 0; + int16_t y1 = 0; + int16_t x2 = renderer->window->w; + int16_t y2 = renderer->window->h; + OGC_set_viewport(0, 0, renderer->window->w, renderer->window->h); + OGC_SetBlendMode(renderer, SDL_BLENDMODE_NONE); + + GX_ClearVtxDesc(); + GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_S16, 0); + GX_SetTevColor(GX_TEVREG0, c); + GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_C0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO); + GX_SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO); + GX_SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GX_SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GX_SetNumTevStages(1); + GX_SetNumChans(0); + + GX_Begin(GX_QUADS, GX_VTXFMT0, 4); + GX_Position2s16(x1, y1); + GX_Position2s16(x2, y1); + GX_Position2s16(x2, y2); + GX_Position2s16(x1, y2); + GX_End(); + data->ops_after_present++; + + /* Restore the viewport */ + OGC_set_viewport(renderer->viewport.x, renderer->viewport.y, + renderer->viewport.w, renderer->viewport.h); + return 0; +} + +static int OGC_RenderGeometry(SDL_Renderer *renderer, void *vertices, + SDL_RenderCommand *cmd) +{ + OGC_RenderData *data = renderer->driverdata; + const size_t count = cmd->data.draw.count; + SDL_Texture *texture = cmd->data.draw.texture; + size_t size_per_element; + + data->ops_after_present++; + OGC_SetBlendMode(renderer, cmd->data.draw.blend); + + size_per_element = sizeof(SDL_FPoint) + sizeof(SDL_Color); + + GX_ClearVtxDesc(); + GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); + GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_F32, 0); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); + if (texture) { + OGC_TextureData *ogc_tex = texture->driverdata; + u8 stage; + + size_per_element += sizeof(SDL_FPoint); + OGC_load_texture(ogc_tex->texels, texture->w, texture->h, + ogc_tex->format, texture->scaleMode); + stage = GX_TEVSTAGE0 + ogc_tex->needed_stages - 1; + + GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); + GX_SetNumTexGens(1); + + GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); + GX_SetTevOrder(stage, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); + GX_SetTevOp(stage, GX_MODULATE); + GX_SetNumTevStages(stage - GX_TEVSTAGE0 + 1); + } else { + GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); + GX_SetNumTevStages(1); + } + GX_SetNumChans(1); + + GX_Begin(GX_TRIANGLES, GX_VTXFMT0, count); + for (int i = 0; i < count; i++) { + void *vertex = vertices + cmd->data.draw.first + size_per_element * i; + SDL_FPoint *vertex_xy = vertex; + SDL_Color *c = (SDL_Color*)(vertex + sizeof(SDL_FPoint)); + + GX_Position2f32(vertex_xy->x, vertex_xy->y); + GX_Color4u8(c->r, c->g, c->b, c->a); + if (texture) { + SDL_FPoint *vertex_uv = (SDL_FPoint *)(vertex + sizeof(SDL_FPoint) + sizeof(SDL_Color)); + GX_TexCoord2f32(vertex_uv->x, vertex_uv->y); + } + } + GX_End(); + return 0; +} + +int OGC_RenderPrimitive(SDL_Renderer *renderer, u8 primitive, + void *vertices, SDL_RenderCommand *cmd) +{ + OGC_RenderData *data = renderer->driverdata; + size_t count = cmd->data.draw.count; + const SDL_FPoint *verts = (SDL_FPoint *)(vertices + cmd->data.draw.first); + Mtx mv; + bool did_change_matrix = false; + GXColor c = { + cmd->data.draw.r, + cmd->data.draw.g, + cmd->data.draw.b, + cmd->data.draw.a + }; + + data->ops_after_present++; + OGC_SetBlendMode(renderer, cmd->data.draw.blend); + + if (primitive == GX_LINESTRIP || primitive == GX_POINTS) { + float adjustment = 0.5; + guMtxIdentity(mv); + guMtxTransApply(mv, mv, adjustment, adjustment, 0); + GX_LoadPosMtxImm(mv, GX_PNMTX0); + did_change_matrix = true; + } + + /* TODO: optimize state changes. */ + GX_SetTevColor(GX_TEVREG0, c); + GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_C0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO); + GX_SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO); + GX_SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GX_SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + + GX_ClearVtxDesc(); + GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_F32, 0); + + if (primitive == GX_QUADS) count *= 4; + + GX_Begin(primitive, GX_VTXFMT0, count); + for (int i = 0; i < count; i++) { + GX_Position2f32(verts[i].x, verts[i].y); + } + GX_End(); + + /* The last point is not drawn */ + if (primitive == GX_LINESTRIP) { + GX_Begin(GX_POINTS, GX_VTXFMT0, count); + for (int i = 0; i < count; i++) { + GX_Position2f32(verts[i].x, verts[i].y); + } + GX_End(); + } + + if (did_change_matrix) { + guMtxIdentity(mv); + GX_LoadPosMtxImm(mv, GX_PNMTX0); + } + + return 0; +} + +static int OGC_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +{ + while (cmd) { + switch (cmd->command) { + case SDL_RENDERCMD_SETVIEWPORT: + OGC_RenderSetViewPort(renderer, cmd); + break; + case SDL_RENDERCMD_SETCLIPRECT: + OGC_RenderSetClipRect(renderer, cmd); + break; + case SDL_RENDERCMD_SETDRAWCOLOR: + /* This is a no-op, since every command carries the color, and + * setting it on the FIFO is not expensive. */ + break; + case SDL_RENDERCMD_CLEAR: + OGC_RenderClear(renderer, cmd); + break; + case SDL_RENDERCMD_DRAW_POINTS: + OGC_RenderPrimitive(renderer, GX_POINTS, vertices, cmd); + break; + case SDL_RENDERCMD_DRAW_LINES: + OGC_RenderPrimitive(renderer, GX_LINESTRIP, vertices, cmd); + break; + case SDL_RENDERCMD_FILL_RECTS: + OGC_RenderPrimitive(renderer, GX_QUADS, vertices, cmd); + break; + case SDL_RENDERCMD_COPY: /* unused */ + break; + case SDL_RENDERCMD_COPY_EX: /* unused */ + break; + case SDL_RENDERCMD_GEOMETRY: + OGC_RenderGeometry(renderer, vertices, cmd); + break; + case SDL_RENDERCMD_NO_OP: + break; + } + cmd = cmd->next; + } + + GX_DrawDone(); + return 0; +} + +static int OGC_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 format, void *pixels, int pitch) +{ + return SDL_Unsupported(); +} + +static int OGC_RenderPresent(SDL_Renderer *renderer) +{ + OGC_RenderData *data = renderer->driverdata; + + GX_DrawDone(); + + OGC_video_flip(SDL_GetVideoDevice(), data->vsync); + + /* Mouse cursor and OSK can change the blending mode; restore it. */ + set_blend_mode_real(renderer, data->current_blend_mode); + + data->ops_after_present = 0; + return 0; +} + +static void OGC_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + OGC_TextureData *ogc_tex = texture->driverdata; + + if (ogc_tex) { + free(ogc_tex->texels); + SDL_free(ogc_tex); + texture->driverdata = NULL; + } +} + +static void OGC_DestroyRenderer(SDL_Renderer *renderer) +{ + OGC_RenderData *data = renderer->driverdata; + + if (data) { + GX_DrawDone(); + if (data->saved_efb_texture) { + OGC_DestroyTexture(renderer, data->saved_efb_texture); + SDL_free(data->saved_efb_texture); + } + + SDL_free(data); + } + + SDL_free(renderer); +} + +static int OGC_SetVSync(SDL_Renderer *renderer, const int vsync) +{ + OGC_RenderData *data = (OGC_RenderData *)renderer->driverdata; + data->vsync = vsync ? 1 : 0; + return 0; +} + +static SDL_Renderer *OGC_CreateRenderer(SDL_Window *window, Uint32 flags) +{ + SDL_Renderer *renderer; + OGC_RenderData *data; + + renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + data = (OGC_RenderData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + OGC_DestroyRenderer(renderer); + SDL_OutOfMemory(); + return NULL; + } + + data->efb_pixel_format = GX_PF_RGB8_Z24; + data->current_blend_mode = SDL_BLENDMODE_INVALID; + data->vsync = true; + + renderer->WindowEvent = OGC_WindowEvent; + renderer->CreateTexture = OGC_CreateTexture; + renderer->UpdateTexture = OGC_UpdateTexture; + renderer->LockTexture = OGC_LockTexture; + renderer->UnlockTexture = OGC_UnlockTexture; + renderer->SetTextureScaleMode = OGC_SetTextureScaleMode; + renderer->SetRenderTarget = OGC_SetRenderTarget; + renderer->QueueSetViewport = OGC_QueueSetViewport; + renderer->QueueSetDrawColor = OGC_QueueSetViewport; + renderer->QueueDrawPoints = OGC_QueueDrawPoints; + renderer->QueueDrawLines = OGC_QueueDrawPoints; + renderer->QueueFillRects = OGC_QueueFillRects; + renderer->QueueGeometry = OGC_QueueGeometry; + renderer->RunCommandQueue = OGC_RunCommandQueue; + renderer->RenderReadPixels = OGC_RenderReadPixels; + renderer->RenderPresent = OGC_RenderPresent; + renderer->DestroyTexture = OGC_DestroyTexture; + renderer->DestroyRenderer = OGC_DestroyRenderer; + renderer->SetVSync = OGC_SetVSync; + renderer->info = OGC_RenderDriver.info; + renderer->driverdata = data; + renderer->window = window; + + if (!SDL_GetHint(SDL_HINT_RENDER_LINE_METHOD)) { + /* SDL sets the default one to point drawing, but we prefer lines */ + SDL_SetHint(SDL_HINT_RENDER_LINE_METHOD, "2"); + } + + return renderer; +} + +SDL_RenderDriver OGC_RenderDriver = { + .CreateRenderer = OGC_CreateRenderer, + .info = { + .name = "ogc", + .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE, + .num_texture_formats = 5, + .texture_formats = { + [0] = SDL_PIXELFORMAT_RGB565, + [1] = SDL_PIXELFORMAT_RGBA8888, + [2] = SDL_PIXELFORMAT_ARGB8888, + [3] = SDL_PIXELFORMAT_RGB24, + [4] = SDL_PIXELFORMAT_XRGB8888, + // TODO: add more + }, + .max_texture_width = 1024, + .max_texture_height = 1024, + } +}; + +#endif /* SDL_VIDEO_RENDER_OGC */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index 278a680268..f2791f1ffa 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -32,7 +32,9 @@ #include "pthread/SDL_systhread_c.h" #elif SDL_THREAD_WINDOWS #include "windows/SDL_systhread_c.h" -#elif SDL_THREAD_PS2 +#elif defined(SDL_THREAD_OGC) +#include "ogc/SDL_systhread_c.h" +#elif defined(SDL_THREAD_PS2) #include "ps2/SDL_systhread_c.h" #elif SDL_THREAD_PSP #include "psp/SDL_systhread_c.h" diff --git a/src/thread/ogc/SDL_syscond.c b/src/thread/ogc/SDL_syscond.c new file mode 100644 index 0000000000..352fd7bf66 --- /dev/null +++ b/src/thread/ogc/SDL_syscond.c @@ -0,0 +1,131 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* An implementation of condition variables using semaphores and mutexes */ +/* + This implementation borrows heavily from the BeOS condition variable + implementation, written by Christopher Tate and Owen Smith. Thanks! + */ + +#include "SDL_thread.h" +#include "SDL_sysmutex_c.h" + +#include +#include + +struct SDL_cond +{ + cond_t cond; +}; + +/* Create a condition variable */ +SDL_cond * SDL_CreateCond(void) +{ + SDL_cond *cond; + + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); + if (cond) { + if (LWP_CondInit(&(cond->cond)) < 0) { + SDL_DestroyCond(cond); + cond = NULL; + } + } else { + SDL_OutOfMemory(); + } + return (cond); +} + +/* Destroy a condition variable */ +void SDL_DestroyCond(SDL_cond *cond) +{ + if (cond) { + LWP_CondDestroy(cond->cond); + SDL_free(cond); + } +} + +/* Restart one of the threads that are waiting on the condition variable */ +int SDL_CondSignal(SDL_cond *cond) +{ + if (!cond) { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + + return LWP_CondSignal(cond->cond) == 0 ? 0 : -1; + +} + +/* Restart all threads that are waiting on the condition variable */ +int SDL_CondBroadcast(SDL_cond *cond) +{ + if (!cond) { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + + return LWP_CondBroadcast(cond->cond) == 0 ? 0 : -1; +} + +/* Wait on the condition variable for at most 'ms' milliseconds. + The mutex must be locked before entering this function! + The mutex is unlocked during the wait, and locked again after the wait. + + Typical use: + + Thread A: + SDL_LockMutex(lock); + while ( ! condition ) { + SDL_CondWait(cond); + } + SDL_UnlockMutex(lock); + + Thread B: + SDL_LockMutex(lock); + ... + condition = true; + ... + SDL_UnlockMutex(lock); + */ + + +int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) +{ + struct timespec time; + + if (!cond) { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + //LWP_CondTimedWait expects relative timeout + time.tv_sec = (ms / 1000); + time.tv_nsec = (ms % 1000) * 1000000; + + return LWP_CondTimedWait(cond->cond, mutex->id, &time); +} + +/* Wait on the condition variable forever */ +int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) +{ + return LWP_CondWait(cond->cond, mutex->id); +} diff --git a/src/thread/ogc/SDL_sysmutex.c b/src/thread/ogc/SDL_sysmutex.c new file mode 100644 index 0000000000..be3ba470ae --- /dev/null +++ b/src/thread/ogc/SDL_sysmutex.c @@ -0,0 +1,81 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* An implementation of mutexes using semaphores */ + +#include "SDL_thread.h" +#include "SDL_systhread_c.h" + +#include + +struct SDL_mutex +{ + u32 id; +}; + +/* Create a mutex */ +SDL_mutex *SDL_CreateMutex(void) +{ + SDL_mutex *mutex = NULL; + + /* Allocate mutex memory */ + mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); + if (mutex) { + LWP_MutexInit(&mutex->id, 1); + } else { + SDL_OutOfMemory(); + } + return mutex; +} + +/* Free the mutex */ +void SDL_DestroyMutex(SDL_mutex *mutex) +{ + if (mutex) { + LWP_MutexDestroy(mutex->id); + SDL_free(mutex); + } +} + +/* Lock the semaphore */ +int SDL_mutexP(SDL_mutex *mutex) +{ + if (mutex == NULL) { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + return LWP_MutexLock(mutex->id); +} + +/* Unlock the mutex */ +int SDL_mutexV(SDL_mutex *mutex) +{ + if (mutex == NULL) { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + return LWP_MutexUnlock(mutex->id); + +} diff --git a/src/thread/ogc/SDL_sysmutex_c.h b/src/thread/ogc/SDL_sysmutex_c.h new file mode 100644 index 0000000000..fe692acc05 --- /dev/null +++ b/src/thread/ogc/SDL_sysmutex_c.h @@ -0,0 +1,26 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +struct SDL_mutex { + Uint32 id; +}; diff --git a/src/thread/ogc/SDL_syssem.c b/src/thread/ogc/SDL_syssem.c new file mode 100644 index 0000000000..825de911fb --- /dev/null +++ b/src/thread/ogc/SDL_syssem.c @@ -0,0 +1,162 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* An implementation of semaphores using mutexes and condition variables */ + +#include "SDL_timer.h" +#include "SDL_thread.h" +#include "SDL_systhread_c.h" + +struct SDL_semaphore +{ + Uint32 count; + Uint32 waiters_count; + SDL_mutex *count_lock; + SDL_cond *count_nonzero; +}; + +SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) +{ + SDL_sem *sem; + + sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); + if (!sem) { + SDL_OutOfMemory(); + return NULL; + } + sem->count = initial_value; + sem->waiters_count = 0; + + sem->count_lock = SDL_CreateMutex(); + sem->count_nonzero = SDL_CreateCond(); + if (!sem->count_lock || !sem->count_nonzero) { + SDL_DestroySemaphore(sem); + return NULL; + } + + return sem; +} + +/* WARNING: + You cannot call this function when another thread is using the semaphore. + */ +void SDL_DestroySemaphore(SDL_sem *sem) +{ + if (sem) { + sem->count = 0xFFFFFFFF; + while (sem->waiters_count > 0) { + SDL_CondSignal(sem->count_nonzero); + SDL_Delay(10); + } + SDL_DestroyCond(sem->count_nonzero); + if (sem->count_lock) { + SDL_mutexP(sem->count_lock); + SDL_mutexV(sem->count_lock); + SDL_DestroyMutex(sem->count_lock); + } + SDL_free(sem); + } +} + +int SDL_SemTryWait(SDL_sem *sem) +{ + int retval; + + if (!sem) { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + retval = SDL_MUTEX_TIMEDOUT; + SDL_LockMutex(sem->count_lock); + if (sem->count > 0) { + --sem->count; + retval = 0; + } + SDL_UnlockMutex(sem->count_lock); + + return retval; +} + +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) +{ + int retval; + + if (!sem) { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + /* A timeout of 0 is an easy case */ + if (timeout == 0) { + return SDL_SemTryWait(sem); + } + + SDL_LockMutex(sem->count_lock); + ++sem->waiters_count; + retval = 0; + while ((sem->count == 0) && (retval != SDL_MUTEX_TIMEDOUT)) { + retval = SDL_CondWaitTimeout(sem->count_nonzero, sem->count_lock, + timeout); + } + --sem->waiters_count; + --sem->count; + SDL_UnlockMutex(sem->count_lock); + + return retval; +} + +int SDL_SemWait(SDL_sem *sem) +{ + return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); +} + +Uint32 SDL_SemValue(SDL_sem *sem) +{ + Uint32 value; + + value = 0; + if (sem) { + SDL_LockMutex(sem->count_lock); + value = sem->count; + SDL_UnlockMutex(sem->count_lock); + } + return value; +} + +int SDL_SemPost(SDL_sem *sem) +{ + if (!sem) { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + SDL_LockMutex(sem->count_lock); + if (sem->waiters_count > 0) { + SDL_CondSignal(sem->count_nonzero); + } + ++sem->count; + SDL_UnlockMutex(sem->count_lock); + + return 0; +} diff --git a/src/thread/ogc/SDL_systhread.c b/src/thread/ogc/SDL_systhread.c new file mode 100644 index 0000000000..558cce7e9f --- /dev/null +++ b/src/thread/ogc/SDL_systhread.c @@ -0,0 +1,92 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* Thread management routines for SDL */ + +#include "SDL_thread.h" +#include "../SDL_systhread.h" +#include "../SDL_thread_c.h" + +#include + +void *run_thread(void *data) +{ + SDL_RunThread(data); + return (void *) 0; /* Prevent compiler warning */ +} + +int SDL_SYS_CreateThread(SDL_Thread *thread) +{ + if (LWP_CreateThread(&thread->handle, run_thread, + thread, 0, 0, 64) != 0 ) { + SDL_SetError("Not enough resources to create thread"); + return -1; + } + + return 0; +} + +void SDL_SYS_SetupThread(const char *name) +{ +} + +int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) +{ + u8 value; + + /* Range is 0 (lowest) to 127 (highest) */ + if (priority == SDL_THREAD_PRIORITY_LOW) { + value = 0; + } else if (priority == SDL_THREAD_PRIORITY_HIGH) { + value = 80; + } else if (priority == SDL_THREAD_PRIORITY_TIME_CRITICAL) { + value = 127; + } else { + value = 64; + } + LWP_SetThreadPriority(LWP_THREAD_NULL, value); + return 0; +} + +SDL_threadID SDL_ThreadID(void) +{ + return (SDL_threadID)LWP_GetSelf(); +} + +void SDL_SYS_WaitThread(SDL_Thread *thread) +{ + void *v; + LWP_JoinThread(thread->handle, &v); + return; +} + +void SDL_SYS_DetachThread(SDL_Thread *thread) +{ + /* Do nothing. */ + thread->handle = LWP_THREAD_NULL; +} + +void SDL_SYS_KillThread(SDL_Thread *thread) +{ + return; +} diff --git a/src/thread/ogc/SDL_systhread_c.h b/src/thread/ogc/SDL_systhread_c.h new file mode 100644 index 0000000000..43caca7ebc --- /dev/null +++ b/src/thread/ogc/SDL_systhread_c.h @@ -0,0 +1,24 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +typedef Uint32 SYS_ThreadHandle; diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index 5316807058..0effd6138e 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -162,7 +162,7 @@ void SDL_SYS_SetupThread(const char *name) } /* NativeClient does not yet support signals.*/ -#if !defined(__NACL__) +#if !defined(__NACL__) && !defined(__wii__) && !defined(__gamecube__) /* Mask asynchronous signals for this thread */ sigemptyset(&mask); for (i = 0; sig_list[i]; ++i) { @@ -188,7 +188,7 @@ SDL_threadID SDL_ThreadID(void) int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { -#if __NACL__ || __RISCOS__ || __OS2__ +#if __NACL__ || __RISCOS__ || __OS2__ || __wii__ || __gamecube__ /* FIXME: Setting thread priority does not seem to be supported in NACL */ return 0; #else diff --git a/src/timer/ogc/SDL_systimer.c b/src/timer/ogc/SDL_systimer.c new file mode 100644 index 0000000000..664e495c5f --- /dev/null +++ b/src/timer/ogc/SDL_systimer.c @@ -0,0 +1,76 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" + +#ifdef SDL_TIMER_OGC + +#include +#include + +static SDL_bool ticks_started = SDL_FALSE; +static u64 start; + +void SDL_TicksInit(void) +{ + if (ticks_started) { + return; + } + ticks_started = SDL_TRUE; + + start = gettime(); +} + +void SDL_TicksQuit(void) +{ + ticks_started = SDL_FALSE; +} + +Uint64 SDL_GetTicks64(void) +{ + const u64 ticks = gettime() - start; + const u64 ms = ticks / TB_TIMER_CLOCK; + return ms; +} + +Uint64 SDL_GetPerformanceCounter(void) +{ + return gettime(); +} + +Uint64 SDL_GetPerformanceFrequency(void) +{ + return secs_to_ticks(1); +} + +void SDL_Delay(Uint32 ms) +{ + struct timespec elapsed, tv; + elapsed.tv_sec = ms / 1000; + elapsed.tv_nsec = (ms % 1000) * 1000000; + tv.tv_sec = elapsed.tv_sec; + tv.tv_nsec = elapsed.tv_nsec; + nanosleep(&tv, &elapsed); +} + +#endif /* SDL_TIMER_OGC */ + +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index d7a42cc64d..db2cb54c85 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -468,6 +468,7 @@ extern VideoBootStrap PSP_bootstrap; extern VideoBootStrap VITA_bootstrap; extern VideoBootStrap RISCOS_bootstrap; extern VideoBootStrap N3DS_bootstrap; +extern VideoBootStrap OGC_bootstrap; extern VideoBootStrap RPI_bootstrap; extern VideoBootStrap KMSDRM_bootstrap; extern VideoBootStrap KMSDRM_LEGACY_bootstrap; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 8065a0b8cf..e5412450c7 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -110,6 +110,9 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_N3DS &N3DS_bootstrap, #endif +#if SDL_VIDEO_DRIVER_OGC + &OGC_bootstrap, +#endif #if SDL_VIDEO_DRIVER_KMSDRM &KMSDRM_bootstrap, #endif diff --git a/src/video/ogc/SDL_ogccursors.h b/src/video/ogc/SDL_ogccursors.h new file mode 100644 index 0000000000..24d0608c37 --- /dev/null +++ b/src/video/ogc/SDL_ogccursors.h @@ -0,0 +1,480 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +typedef struct _OGC_Cursor { + uint16_t width; + uint16_t height; + uint8_t hot_x; + uint8_t hot_y; + uint8_t bytes_per_pixel; + uint8_t pixel_data[]; +} OGC_Cursor; + +static const OGC_Cursor OGC_cursor_hand = { + 37, 52, 11, 0, 4, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000Q\000" + "\000\000\262\000\000\000\337\000\000\000\345\000\000\000\313\000\000\000\203\000\000\000\032\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\005" + "\000\000\000\224\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000" + "\000\000\330\000\000\000\062\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\177\000\000\000\377\000\000\000\377\026\026\026\377bbb\377ttt\377" + "<<<\377\000\000\000\377\000\000\000\377\000\000\000\334\000\000\000\030\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000%\000\000\000\364\000\000\000\377...\377\327\327" + "\327\377\377\377\377\377\377\377\377\377\373\373\373\377\177\177\177\377" + "\000\000\000\377\000\000\000\377\000\000\000\206\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000n\000\000\000\377\005\005\005\377\277\277\277\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377BBB\377\000" + "\000\000\377\000\000\000\323\000\000\000\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\225\000\000\000\377###\377\366\366\366\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\206\206\206\377\000\000" + "\000\377\000\000\000\356\000\000\000\033\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\231\000\000\000\377+++\377\370\370\370\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\217\217\217\377\000\000\000\377" + "\000\000\000\361\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\230\000\000\000\377***\377\367\367\367\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\215\215\215\377\000\000\000\377\000" + "\000\000\360\000\000\000\037\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230" + "\000\000\000\377***\377\367\367\367\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000" + "\360\000\000\000\037\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000" + "\000\000\377***\377\367\367\367\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000\360" + "\000\000\000\037\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000" + "\377***\377\367\367\367\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000\360\000\000" + "\000\037\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000\377" + "***\377\367\367\367\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000\360\000\000\000\037" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000\377***\377" + "\367\367\367\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000\360\000\000\000\037\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000\377***\377\367" + "\367\367\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000\357\000\000\000\026\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000\377***\377\367\367" + "\367\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000\370\000\000\000\244\000\000\000\223" + "\000\000\000e\000\000\000\032\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000\377***\377\367\367" + "\367\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + "\000\000\000\377\000\000\000\340\000\000\000Z\000\000\000\000\000\000\000\003\000\000\000\022\000\000\000\006\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000\377***\377\367" + "\367\367\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\215\215\215\377\000\000\000\377\001\001\001\377%%%\377\036\036\036" + "\377\000\000\000\377\000\000\000\377\000\000\000\373\000\000\000\244\000\000\000\310\000\000\000\341\000\000\000\320" + "\000\000\000\220\000\000\000*\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000" + "\377***\377\367\367\367\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\210\210\210\377\022\022\022\377\270\270\270" + "\377\356\356\356\377\351\351\351\377\236\236\236\377\022\022\022\377\000\000\000\377" + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\357\000\000\000[\000\000\000" + "\030\000\000\000<\000\000\000B\000\000\000(\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\227\000\000\000\377***\377\367\367\367\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\202\202\202\377\065\065\065\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\246\246\246\377\001\001\001\377\003\003\003\377@@@\377iii\377DD" + "D\377\002\002\002\377\000\000\000\377\000\000\000\372\000\000\000\342\000\000\000\375\000\000\000\377\000\000\000\360" + "\000\000\000\264\000\000\000:\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\233\000\000\000\377***\377\367\367\367\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\203\203\203\377\061\061\061" + "\377\375\375\375\377\377\377\377\377\377\377\377\377\377\377\377\377\372" + "\372\372\377\036\036\036\377kkk\377\375\375\375\377\377\377\377\377\377\377" + "\377\377\253\253\253\377\015\015\015\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000" + "\377\000\000\000\377\000\000\000\377\000\000\000\366\000\000\000U\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\016" + "\000\000\000n\000\000\000\272\000\000\000\360\000\000\000\377***\377\367\367\367\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\203" + "\203\203\377\061\061\061\377\375\375\375\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\376\376\376\377\063\063\063\377\211\211\211\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\177\177\177\377\000\000" + "\000\377AAA\377\236\236\236\377\256\256\256\377lll\377\011\011\011\377\000\000\000\377" + "\000\000\000\360\000\000\000)\000\000\000\000\000\000\000!\000\000\000\304\000\000\000\377\000\000\000\377\000\000\000\377" + "\000\000\000\377***\377\367\367\367\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\203\203\203\377\061\061\061\377\375" + "\375\375\377\377\377\377\377\377\377\377\377\377\377\377\377\375\375\375" + "\377\061\061\061\377\203\203\203\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\304\304\304\377\011\011\011\377\327\327\327\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\247\247\247\377\006\006\006\377\000" + "\000\000\377\000\000\000\225\000\000\000\016\000\000\000\312\000\000\000\377\000\000\000\377(((\377aaa\377\067" + "\067\067\377'''\377\366\366\366\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\203\203\203\377\061\061\061\377\375" + "\375\375\377\377\377\377\377\377\377\377\377\377\377\377\377\375\375\375" + "\377\061\061\061\377\203\203\203\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\313\313\313\377\015\015\015\377\323\323\323\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377NNN\377\000\000\000" + "\377\000\000\000\324\000\000\000s\000\000\000\377\000\000\000\377fff\377\357\357\357\377\377\377" + "\377\377\244\244\244\377###\377\365\365\365\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377|||\377&&&\377\375\375" + "\375\377\377\377\377\377\377\377\377\377\377\377\377\377\375\375\375\377" + "&&&\377|||\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\306\306\306\377\001\001\001\377\317\317\317\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\200\200\200\377\000\000\000\377\000\000\000\345" + "\000\000\000\305\000\000\000\377\062\062\062\377\371\371\371\377\377\377\377\377\377\377" + "\377\377\235\235\235\377###\377\365\365\365\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\274\274\274\377\221" + "\221\221\377\376\376\376\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\376\376\376\377\221\221\221\377\274\274\274\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\342\342\340\377\200\200\200" + "\377\347\347\347\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\202\202\202\377\000\000\000\377\000\000\000\345\000\000\000\342\000\000\000\377www\377" + "\377\377\377\377\376\376\376\377\377\377\377\377\235\235\235\377!##\377\365" + "\365\365\377\377\377\377\377\374\376\376\377\374\376\376\377\374\376\376" + "\377\374\376\376\377\377\377\377\377\377\377\377\377\374\376\376\377\374" + "\376\376\377\374\376\376\377\374\376\376\377\374\376\376\377\377\377\377" + "\377\377\377\377\377\374\376\376\377\374\376\376\377\374\376\376\377\374" + "\376\376\377\377\377\377\377\377\377\377\377\377\377\377\377\374\376\376" + "\377\374\376\376\377\374\376\376\377\377\377\377\377\201\201\201\377\000\000" + "\000\377\000\000\000\345\000\000\000\346\000\000\000\377\203\203\203\377\377\377\377\377\375" + "\373\375\377\377\377\377\377\233\233\235\377!!#\377\363\363\365\377\377\377" + "\377\377\373\373\376\377\373\373\376\377\373\373\376\377\373\373\376\377" + "\373\373\376\377\373\373\376\377\373\373\376\377\373\373\375\377\373\373" + "\376\377\373\373\376\377\373\373\376\377\373\373\375\377\373\373\376\377" + "\373\373\376\377\373\373\376\377\373\373\376\377\373\373\376\377\373\373" + "\376\377\373\373\375\377\373\373\375\377\373\373\375\377\373\373\376\377" + "\373\374\376\377\377\377\377\377\201\201\201\377\000\000\000\377\000\000\000\345\000\000" + "\000\345\000\000\000\377\177\201\201\377\377\377\377\377\371\373\376\377\377\377" + "\377\377\233\233\235\377\"\"\"\377\361\363\366\377\375\377\377\377\371\373" + "\376\377\371\373\376\377\371\373\376\377\367\372\376\377\367\372\376\377" + "\371\371\376\377\371\371\376\377\371\373\376\377\371\373\376\377\371\373" + "\376\377\371\373\376\377\367\372\376\377\367\372\376\377\371\373\376\377" + "\367\372\376\377\367\372\376\377\371\373\376\377\367\372\376\377\371\373" + "\376\377\371\373\376\377\367\372\376\377\367\372\376\377\371\373\376\377" + "\377\377\377\377\177\201\201\377\000\000\000\377\000\000\000\345\000\000\000\345\000\000\000\377" + "\177\177\201\377\377\377\377\377\365\370\377\377\377\377\377\377\234\234" + "\234\377\"\"\"\377\356\361\365\377\372\375\377\377\365\370\375\377\365\370" + "\375\377\365\370\375\377\365\370\375\377\365\370\375\377\365\370\375\377" + "\365\370\375\377\365\370\375\377\365\370\375\377\365\370\375\377\365\370" + "\375\377\365\370\375\377\365\370\375\377\365\370\375\377\365\370\375\377" + "\365\370\375\377\365\370\375\377\365\370\375\377\365\370\375\377\365\370" + "\375\377\365\370\375\377\365\370\375\377\366\371\376\377\377\377\377\377" + "\177\177\201\377\000\000\000\377\000\000\000\345\000\000\000\345\000\000\000\377}\200\202\377\377" + "\377\377\377\363\366\375\377\377\377\377\377\232\234\234\377\"\"\"\377\355" + "\357\364\377\370\372\377\377\363\366\375\377\363\366\375\377\363\366\375" + "\377\363\366\375\377\363\366\375\377\363\366\375\377\363\366\375\377\363" + "\366\375\377\363\366\375\377\363\366\375\377\363\366\375\377\363\366\375" + "\377\363\366\375\377\363\366\375\377\363\366\375\377\363\366\375\377\363" + "\366\375\377\363\366\375\377\363\366\375\377\363\366\375\377\363\366\375" + "\377\363\366\375\377\364\367\376\377\377\377\377\377~\177\201\377\000\000\000\377" + "\000\000\000\345\000\000\000\345\000\000\000\377|~\201\377\377\377\377\377\357\362\374\377" + "\377\377\377\377\231\232\234\377\"\"\"\377\352\355\364\377\364\370\377\377" + "\357\362\374\377\357\364\374\377\357\364\374\377\357\364\374\377\357\362" + "\374\377\357\364\374\377\357\364\374\377\357\364\374\377\357\364\374\377" + "\357\362\374\377\357\364\374\377\357\364\374\377\357\364\374\377\357\364" + "\374\377\357\364\374\377\357\364\374\377\357\364\374\377\357\364\374\377" + "\357\364\374\377\357\364\374\377\357\362\374\377\357\364\374\377\360\363" + "\375\377\377\377\377\377|~\201\377\000\000\000\377\000\000\000\345\000\000\000\345\000\000\000\377" + "z|\201\377\377\377\377\377\353\360\374\377\375\377\377\377\230\232\235\377" + "\"\"\"\377\347\352\364\377\360\364\377\377\353\360\374\377\355\360\374\377" + "\355\360\374\377\355\360\374\377\353\360\374\377\355\360\374\377\353\360" + "\374\377\353\360\374\377\353\360\374\377\355\360\374\377\355\360\374\377" + "\355\360\374\377\355\362\374\377\355\360\374\377\353\360\374\377\353\360" + "\374\377\355\360\374\377\353\360\374\377\355\360\374\377\355\360\374\377" + "\355\360\374\377\353\360\374\377\355\362\374\377\377\377\377\377z|\201\377" + "\000\000\000\377\000\000\000\345\000\000\000\345\000\000\000\377y{\201\377\377\377\377\377\351\356" + "\372\377\373\377\377\377\220\223\230\377\026\026\026\377\344\351\363\377\353" + "\362\377\377\350\357\374\377\350\357\372\377\350\357\372\377\350\357\374" + "\377\350\357\374\377\350\357\372\377\350\357\374\377\350\357\372\377\350" + "\357\372\377\350\357\374\377\350\357\374\377\350\357\374\377\350\357\372" + "\377\350\357\372\377\350\357\372\377\350\357\374\377\350\357\374\377\350" + "\357\372\377\350\357\372\377\350\357\372\377\350\357\372\377\350\357\372" + "\377\351\360\373\377\377\377\377\377y{\201\377\000\000\000\377\000\000\000\345\000\000\000" + "\345\000\000\000\377xz\200\377\375\377\377\377\346\354\373\377\352\362\376\377" + "\304\313\325\377\226\233\243\377\343\353\370\377\345\355\374\377\345\355" + "\372\377\345\355\372\377\345\353\372\377\345\353\372\377\345\355\372\377" + "\345\355\372\377\345\353\372\377\345\353\372\377\345\353\372\377\345\355" + "\372\377\345\355\372\377\345\353\372\377\345\353\372\377\345\353\372\377" + "\345\353\372\377\345\353\372\377\345\353\372\377\345\353\372\377\345\353" + "\372\377\345\353\372\377\345\353\372\377\345\353\372\377\344\354\373\377" + "\375\377\377\377xz\200\377\000\000\000\377\000\000\000\345\000\000\000\345\000\000\000\377ux\201" + "\377\373\377\377\377\342\352\373\377\340\350\371\377\350\360\377\377\362" + "\370\377\377\341\351\373\377\341\351\372\377\341\351\372\377\341\351\372" + "\377\341\351\372\377\341\351\372\377\341\351\372\377\341\351\372\377\341" + "\351\372\377\341\351\372\377\341\351\372\377\341\351\372\377\341\351\372" + "\377\341\351\372\377\341\351\372\377\341\351\372\377\341\351\372\377\341" + "\351\372\377\341\351\372\377\341\351\372\377\341\351\372\377\341\351\372" + "\377\341\351\372\377\341\351\372\377\342\352\373\377\373\377\377\377ux\201" + "\377\000\000\000\377\000\000\000\345\000\000\000\345\000\000\000\377ty\200\377\367\375\377\377\336" + "\346\372\377\334\346\372\377\334\346\372\377\334\346\370\377\335\345\371" + "\377\335\345\371\377\335\345\371\377\335\345\371\377\335\345\371\377\335" + "\345\371\377\335\345\371\377\335\345\371\377\335\345\371\377\335\345\371" + "\377\335\345\371\377\335\345\371\377\335\345\371\377\334\346\372\377\335" + "\345\371\377\335\345\371\377\335\345\371\377\335\345\371\377\335\345\371" + "\377\335\345\371\377\335\345\371\377\334\346\372\377\335\345\371\377\335" + "\345\371\377\335\347\373\377\367\375\377\377ty\200\377\000\000\000\377\000\000\000\345" + "\000\000\000\345\000\000\000\377sx\200\377\366\373\377\377\334\344\372\377\331\344\370" + "\377\330\343\371\377\331\344\370\377\330\343\371\377\330\343\371\377\331" + "\344\370\377\331\344\370\377\331\344\370\377\331\344\370\377\330\343\371" + "\377\331\344\370\377\331\344\370\377\331\344\370\377\331\344\370\377\331" + "\344\370\377\330\343\371\377\330\343\371\377\330\343\371\377\331\344\370" + "\377\331\344\370\377\331\344\370\377\330\343\371\377\330\342\371\377\331" + "\344\370\377\331\343\370\377\331\344\370\377\331\343\370\377\334\344\370" + "\377\366\373\377\377sx\200\377\000\000\000\377\000\000\000\345\000\000\000\346\000\000\000\377QV" + "[\377\365\373\377\377\334\346\372\377\325\341\370\377\325\337\370\377\325" + "\341\370\377\325\341\370\377\325\341\370\377\325\341\370\377\325\341\370" + "\377\325\341\370\377\325\341\370\377\325\341\370\377\325\341\370\377\325" + "\341\370\377\325\341\370\377\325\341\370\377\325\341\370\377\325\341\370" + "\377\325\341\370\377\325\341\370\377\325\341\370\377\325\341\370\377\325" + "\341\370\377\325\341\370\377\325\341\370\377\325\341\370\377\325\341\370" + "\377\324\341\370\377\324\341\370\377\334\346\372\377\365\373\377\377PU\\" + "\377\000\000\000\377\000\000\000\346\000\000\000\314\000\000\000\377\012\012\014\377\254\264\301\377" + "\362\370\377\377\325\341\370\377\321\335\367\377\320\335\370\377\320\335" + "\370\377\320\335\370\377\320\335\370\377\320\335\370\377\320\335\370\377" + "\320\335\370\377\320\335\370\377\321\335\367\377\320\335\370\377\320\335" + "\370\377\320\335\370\377\320\335\370\377\320\335\370\377\321\335\367\377" + "\321\335\367\377\320\335\370\377\320\335\370\377\320\335\370\377\320\335" + "\370\377\320\335\370\377\321\335\367\377\320\335\370\377\321\335\367\377" + "\326\340\371\377\362\370\377\377\254\264\301\377\012\012\014\377\000\000\000\377\000" + "\000\000\314\000\000\000d\000\000\000\377\000\000\000\377\024\025\027\377\262\274\314\377\355\365" + "\377\377\323\336\367\377\315\334\366\377\315\334\366\377\314\333\367\377" + "\315\334\366\377\314\333\367\377\314\333\367\377\314\333\367\377\314\333" + "\367\377\316\333\367\377\314\333\367\377\314\333\367\377\315\334\366\377" + "\315\334\366\377\315\334\366\377\316\333\367\377\316\333\367\377\314\333" + "\367\377\314\333\367\377\315\334\366\377\315\334\366\377\314\333\367\377" + "\314\333\367\377\314\333\367\377\323\340\367\377\356\365\377\377\262\274" + "\314\377\024\025\027\377\000\000\000\377\000\000\000\377\000\000\000d\000\000\000\002\000\000\000\220\000\000\000" + "\377\000\000\000\377\025\027\032\377\261\273\315\377\352\362\377\377\317\333\367\377" + "\311\326\366\377\311\330\366\377\311\330\366\377\311\330\366\377\311\330" + "\366\377\311\330\366\377\311\330\366\377\311\330\366\377\311\330\366\377" + "\311\330\366\377\311\330\366\377\311\330\366\377\311\330\366\377\311\330" + "\366\377\311\330\366\377\311\330\366\377\311\330\366\377\311\330\366\377" + "\311\330\366\377\311\330\366\377\311\330\366\377\317\333\367\377\352\362" + "\377\377\261\271\315\377\025\027\032\377\000\000\000\377\000\000\000\377\000\000\000\220\000\000\000" + "\002\000\000\000\000\000\000\000\002\000\000\000\224\000\000\000\377\000\000\000\377\025\030\032\377\257\272\320" + "\377\346\356\377\377\313\330\366\377\305\325\365\377\305\324\365\377\305" + "\324\365\377\305\325\365\377\305\324\365\377\305\324\365\377\305\325\365" + "\377\305\325\365\377\305\324\365\377\305\325\365\377\305\325\365\377\305" + "\324\365\377\305\325\365\377\305\325\365\377\305\325\365\377\305\325\365" + "\377\305\325\365\377\305\324\365\377\305\324\365\377\313\332\366\377\346" + "\356\377\377\257\272\320\377\025\027\032\377\000\000\000\377\000\000\000\377\000\000\000\224\000" + "\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\235\000\000\000\377\000\000\000\377\031\032" + "\034\377\267\304\335\377\327\345\377\377\307\326\365\377\302\322\365\377\302" + "\322\365\377\302\322\365\377\302\322\365\377\302\322\365\377\302\322\365" + "\377\302\322\365\377\302\322\365\377\302\322\365\377\302\322\365\377\302" + "\322\365\377\302\322\365\377\302\322\365\377\302\322\365\377\302\322\365" + "\377\302\322\365\377\302\322\365\377\305\326\367\377\327\343\377\377\267" + "\304\335\377\031\032\034\377\000\000\000\377\000\000\000\377\000\000\000\235\000\000\000\004\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\006\000\000\000\241\000\000\000\377\000\000\000\377GJV\377" + "\327\345\377\377\311\330\367\377\275\317\365\377\276\317\365\377\276\320" + "\365\377\276\320\365\377\276\320\365\377\276\320\365\377\276\320\365\377" + "\276\320\365\377\276\320\365\377\276\320\365\377\276\320\365\377\276\320" + "\365\377\276\320\365\377\276\320\365\377\276\320\365\377\276\320\365\377" + "\275\317\365\377\311\330\367\377\326\345\377\377GJV\377\000\000\000\377\000\000\000\377" + "\000\000\000\241\000\000\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\011\000\000\000\313\000\000\000\377\015\015\017\377\270\305\341\377\312\334\374" + "\377\271\315\364\377\272\314\364\377\272\316\364\377\272\316\364\377\272" + "\316\364\377\272\316\364\377\272\316\364\377\272\316\364\377\272\316\364" + "\377\272\316\364\377\272\316\364\377\272\316\364\377\272\316\364\377\272" + "\316\364\377\272\316\364\377\272\316\364\377\271\316\364\377\312\334\374" + "\377\270\305\341\377\015\015\017\377\000\000\000\377\000\000\000\313\000\000\000\011\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000s\000\000" + "\000\377\004\004\006\377\254\270\324\377\311\332\376\377\267\313\364\377\270\312" + "\363\377\270\314\363\377\270\314\363\377\270\314\363\377\270\314\363\377" + "\270\312\363\377\270\312\363\377\270\314\363\377\270\314\363\377\270\314" + "\363\377\270\314\363\377\270\312\363\377\270\314\363\377\270\314\363\377" + "\270\314\363\377\267\313\364\377\311\332\376\377\254\270\324\377\004\004\006\377" + "\000\000\000\377\000\000\000s\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000a\000\000\000\377\005\005\007\377\253\270\324\377\306\332" + "\376\377\263\310\363\377\264\311\363\377\264\311\363\377\264\311\363\377" + "\264\311\363\377\264\311\363\377\264\311\364\377\264\311\364\377\264\311" + "\363\377\264\311\363\377\264\311\363\377\264\311\363\377\264\311\363\377" + "\264\311\363\377\264\311\364\377\264\311\364\377\263\310\363\377\306\332" + "\376\377\253\270\324\377\005\005\007\377\000\000\000\377\000\000\000a\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000d\000\000\000\377" + "\005\005\007\377\255\274\332\377\306\330\376\377\261\306\363\377\262\307\362\377" + "\262\307\362\377\262\307\362\377\262\307\362\377\262\307\362\377\262\307" + "\362\377\262\307\362\377\262\307\362\377\262\307\362\377\262\307\362\377" + "\262\307\362\377\262\307\362\377\262\307\362\377\262\307\362\377\262\307" + "\362\377\261\306\363\377\306\330\376\377\255\274\332\377\005\005\007\377\000\000\000" + "\377\000\000\000d\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000W\000\000\000\377\002\002\002\377\205\220\251\377\341\354\377" + "\377\313\333\377\377\311\333\377\377\311\333\377\377\311\333\377\377\311" + "\333\377\377\311\333\377\377\311\333\377\377\311\333\377\377\311\333\377" + "\377\311\333\377\377\310\332\377\377\311\333\377\377\311\333\377\377\311" + "\333\377\377\310\332\377\377\310\332\377\377\313\333\377\377\340\354\377" + "\377\205\220\251\377\002\002\002\377\000\000\000\377\000\000\000W\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\034\000\000\000\354" + "\000\000\000\377\020\022\025\377RZi\377]ev\377Zdt\377Zdt\377[ct\377[ct\377Zdt\377" + "Zdt\377Zdt\377[ct\377[ct\377Zds\377[ct\377[ct\377Zdt\377[cr\377Zds\377]e" + "v\377RZi\377\020\022\025\377\000\000\000\377\000\000\000\354\000\000\000\034\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000f\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000" + "\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000" + "\000\377\000\000\000\377\000\000\000f\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000R\000\000\000\275\000" + "\000\000\344\000\000\000\345\000\000\000\344\000\000\000\344\000\000\000\344\000\000\000\344\000\000\000\344\000\000" + "\000\344\000\000\000\344\000\000\000\344\000\000\000\344\000\000\000\344\000\000\000\344\000\000\000\344\000\000\000" + "\344\000\000\000\344\000\000\000\344\000\000\000\345\000\000\000\344\000\000\000\275\000\000\000R\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", +}; + +static const OGC_Cursor OGC_cursor_arrow = { + 24, 31, 0, 0, 4, + "\002\002\002\337\000\000\000\224\000\000\000\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\000\000\000\377" + "\005\005\005\321\000\000\000$\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377ddd\377\037\037\037\373\003\003\003\364" + "\000\000\000V\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\377\225\225\225\377\361\361\361\377VVV\376\000\000\000\377" + "\002\002\002\243\000\000\000\012\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\377\225\225\225\377\377\377\377\377\377\377\377\377\241" + "\241\241\377\007\007\007\375\005\005\005\322\000\000\000%\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\225\225\225\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\315\315\315\377!!!\373\003\003\003\365\000\000\000Y\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\225\225\225\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\362\362\362\377" + "WWW\376\000\000\000\377\002\002\002\243\000\000\000\012\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\377\225\225\225\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\241\241\241\377\007\007\007\375\005" + "\005\005\331\000\000\000+\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\225\225\225\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\316\316\316\377!!!\373\003\003\003\365\000\000\000Z" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\377\225\225\225\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\362\362\362\377XXX\376\000\000\000\377\002\002\002\243\000\000\000" + "\012\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\377\225\225\225\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\375\375\377\377\373\374\376\377\235\236\240\377\007\007\007\374\005" + "\005\005\331\000\000\000+\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\377\225\225\225\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\375\375\377\377" + "\373\374\376\377\371\373\376\377\367\371\376\377\366\370\375\377\305\310" + "\314\377\037!\"\373\003\003\003\366\000\000\000[\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\377\225\225\225\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\375\375\377\377\373\374\376\377\371" + "\373\376\377\367\371\376\377\366\370\375\377\364\367\375\377\362\365\375" + "\377\360\364\374\377\342\347\357\377QSW\376\000\000\000\377\002\002\002\243\000\000\000\012" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\225\225\225\377\377\377" + "\377\377\377\377\377\377\375\375\377\377\373\374\376\377\371\373\376\377" + "\367\371\376\377\366\370\375\377\364\367\375\377\362\365\375\377\360\364" + "\374\377\356\363\374\377\354\362\374\377\353\360\374\377\351\357\373\377" + "\222\226\236\377\007\007\007\374\004\005\005\331\000\000\000+\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\377\225\225\225\377\375\375\377\377\373\374\376\377\371\373\376" + "\377\367\371\376\377\366\370\375\377\364\367\375\377\362\365\375\377\360" + "\364\374\377\356\363\374\377\354\362\374\377\353\360\374\377\351\357\373" + "\377\347\356\373\377\345\354\373\377\343\353\372\377\275\303\321\377#%'\373" + "\003\003\003\366\000\000\000[\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\223\223\224\377\371\373" + "\376\377\367\371\376\377\366\370\375\377\364\367\375\377\362\365\375\377" + "\360\364\374\377\356\363\374\377\354\362\374\377\353\360\374\377\351\357" + "\373\377\347\356\373\377\345\354\373\377\343\353\372\377\342\352\372\377" + "\340\350\372\377\336\347\371\377\321\332\354\377LOW\376\000\000\000\377\002\002\002\243" + "\000\000\000\012\000\000\000\000\000\000\000\377\220\221\224\377\366\370\375\377\364\367\375\377" + "\362\365\375\377\360\364\374\377\356\363\374\377\354\362\374\377\353\360" + "\374\377\351\357\373\377\347\356\373\377\345\354\373\377\343\353\372\377" + "\342\352\372\377\340\350\372\377\336\347\371\377\334\346\371\377\332\344" + "\371\377\330\343\370\377\327\342\370\377\206\215\235\377\006\006\007\374\004\004\005" + "\332\000\000\000,\000\000\000\377\217\220\224\377\362\365\375\377\360\364\374\377\356" + "\363\374\377\354\361\374\377\353\360\374\377\351\357\373\377\347\356\373" + "\377\345\354\373\377\343\353\372\377\342\352\372\377\340\350\372\377\336" + "\347\371\377\334\346\371\377\332\344\371\377\330\343\370\377\327\342\370" + "\377\325\340\370\377\323\337\370\377\321\336\367\377pw\206\377\000\000\000\377" + "\001\001\001\347\000\000\000\377\214\217\223\377\356\363\374\377\354\361\374\377\353" + "\360\374\377\351\357\373\377\347\356\373\377\345\354\373\377\343\353\372" + "\377\342\352\372\377\340\350\372\377\336\347\371\377\334\346\371\377\332" + "\344\371\377\330\343\370\377\327\342\370\377\325\340\370\377\323\337\370" + "\377\321\336\367\377\225\236\261\377,/\065\374\000\000\000\377\004\004\005\316\000\000\000F" + "\000\000\000\377\212\215\223\377\353\360\374\377\351\357\373\377\347\356\373\377" + "\345\354\373\377\343\353\372\377\342\352\372\377\340\350\372\377\336\347" + "\371\377\334\346\371\377\332\344\371\377\330\343\370\377\327\342\370\377" + "\325\340\370\377\323\337\370\377\321\336\367\377\236\250\275\377\062\065<\374" + "\000\000\000\377\002\004\004\323\000\000\000U\000\000\000\001\000\000\000\000\000\000\000\377\210\214\223\377\347" + "\356\373\377\345\354\373\377\343\353\372\377\342\352\372\377\340\350\372" + "\377\336\347\371\377\334\346\371\377\332\344\371\377\330\343\370\377\327" + "\342\370\377\325\340\370\377\323\337\370\377\321\336\367\377\230\241\265" + "\377,/\064\374\000\000\000\377\002\004\004\323\000\000\000U\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\377\206\212\223\377\343\353\372\377\341\352\372\377\340\350\372\377" + "\336\347\371\377\334\346\371\377\332\344\371\377\330\343\370\377\327\342" + "\370\377\325\340\370\377\323\337\370\377\321\336\367\377\317\334\367\377" + "DHQ\374\000\000\000\377\004\004\004\314\000\000\000J\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\377\203\211\222\377\340\350\372\377\336\347\371\377\334" + "\346\371\377\332\344\371\377\330\343\370\377\327\342\370\377\325\340\370" + "\377\323\337\370\377\321\336\367\377\317\334\367\377\315\333\367\377\314" + "\332\366\377JOZ\376\002\002\003\362\000\000\000\012\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\202\207\221\377\334\346\371\377\332\344" + "\371\377\330\343\370\377\327\342\370\377\325\340\370\377\323\337\370\377" + "\321\336\367\377\316\333\366\377\315\333\367\377\314\332\366\377\312\330" + "\366\377\310\327\366\377\250\266\320\377\002\002\002\376\000\000\000r\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\177\205\221\377\330\343" + "\370\377\327\342\370\377\325\340\370\377\323\337\370\377\321\336\367\377" + "\223\234\257\377),\062\374\036\040$\374\306\324\361\377\310\327\366\377\306" + "\326\365\377\304\324\365\377\303\323\365\377FLX\376\003\003\004\354\000\000\000\012\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377~\204\221\377\325" + "\340\370\377\323\337\370\377\321\336\367\377\222\233\256\377)-\063\374\000\000" + "\000\377\002\004\004\321\000\000\000\376y\203\226\377\304\324\365\377\303\323\365\377\301" + "\322\364\377\277\320\364\377\242\261\321\377\001\002\002\376\000\000\000s\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377{\202\221\377\321\336\367\377" + "\222\233\256\377),\062\374\000\000\000\377\004\004\005\313\000\000\000I\000\000\000\000\001\001\003\263\026" + "\030\034\373\275\316\357\377\277\320\364\377\275\317\364\377\273\316\364\377" + "\271\314\363\377CJY\376\003\003\004\354\000\000\000\012\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\377INW\377)+\061\373\000\000\000\377\004\004\004\312\000\000\000H\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\062\000\000\000\376t\177\225\377\273\316\364\377\271\314\363" + "\377\270\313\363\377\212\232\271\377(,\066\375\000\000\000\377\000\000\000F\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\000\000\000\377\004\004\004\311\000\000\000H\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\003\003\262\025\027\034\373\264\307" + "\356\377\212\232\271\377.\063>\374\000\000\000\377\004\004\005\330\000\000\000V\000\000\000\001\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000t\000\000\000G\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\062\000\000\000\376\032\035$\375" + "\000\000\000\377\004\004\005\327\000\000\000V\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\003\003\247\004\004\005\325\000\000\000U\000\000\000\002\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", +}; + diff --git a/src/video/ogc/SDL_ogcevents.c b/src/video/ogc/SDL_ogcevents.c new file mode 100644 index 0000000000..4e4440d12d --- /dev/null +++ b/src/video/ogc/SDL_ogcevents.c @@ -0,0 +1,113 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_OGC + +#include "SDL.h" + +#include "../../events/SDL_events_c.h" + +#include "SDL_ogcevents_c.h" +#include "SDL_ogckeyboard.h" +#include "SDL_ogcmouse.h" +#include "SDL_ogcvideo.h" + +#include +#include + +/* These variables can be set from the handlers registered in SDL_main() */ +bool OGC_PowerOffRequested = false; +bool OGC_ResetRequested = false; + +#ifdef __wii__ +#define MAX_WII_MOUSE_BUTTONS 2 +static const struct { + int wii; + int mouse; +} s_mouse_button_map[MAX_WII_MOUSE_BUTTONS] = { + { WPAD_BUTTON_B, SDL_BUTTON_LEFT }, + { WPAD_BUTTON_A, SDL_BUTTON_RIGHT }, +}; + +static void pump_ir_events(_THIS) +{ + int screen_w, screen_h; + + if (!_this->windows) return; + + if (!SDL_WasInit(SDL_INIT_JOYSTICK)) { + /* Get events from WPAD; we don't need to do this if the joystick + * system was initialized, because in that case this operation is done + * there at every event loop iteration. */ + WPAD_ReadPending(WPAD_CHAN_ALL, NULL); + } + + screen_w = _this->displays[0].current_mode.w; + screen_h = _this->displays[0].current_mode.h; + + for (int i = 0; i < 4; i++) { + WPADData *data = WPAD_Data(i); + + if (!data->ir.valid) continue; + + SDL_SendMouseMotion(_this->windows, i, 0, + data->ir.x * screen_w / 640, + data->ir.y * screen_h / 480); + + for (int b = 0; b < MAX_WII_MOUSE_BUTTONS; b++) { + if (data->btns_d & s_mouse_button_map[b].wii) { + SDL_SendMouseButton(_this->windows, i, + SDL_PRESSED, s_mouse_button_map[b].mouse); + } + if (data->btns_u & s_mouse_button_map[b].wii) { + SDL_SendMouseButton(_this->windows, i, + SDL_RELEASED, s_mouse_button_map[b].mouse); + } + } + } + + if (OGC_prep_draw_cursor(_this)) { + OGC_video_flip(_this, false); + } +} +#endif + +void OGC_PumpEvents(_THIS) +{ + if (OGC_ResetRequested || OGC_PowerOffRequested) { + SDL_Event ev; + ev.type = SDL_QUIT; + SDL_PushEvent(&ev); + if (OGC_PowerOffRequested) { + SYS_ResetSystem(SYS_POWEROFF, 0, 0); + } + } + +#ifdef __wii__ + pump_ir_events(_this); + OGC_PumpKeyboardEvents(_this); +#endif +} + +#endif /* SDL_VIDEO_DRIVER_OGC */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcevents_c.h b/src/video/ogc/SDL_ogcevents_c.h new file mode 100644 index 0000000000..6bc6b91e68 --- /dev/null +++ b/src/video/ogc/SDL_ogcevents_c.h @@ -0,0 +1,36 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_ogcevents_c_h_ +#define SDL_ogcevents_c_h_ + +#include "../../SDL_internal.h" + +#include "SDL_ogcvideo.h" + +extern bool OGC_ResetRequested; +extern bool OGC_PowerOffRequested; + +extern void OGC_PumpEvents(_THIS); + +#endif /* SDL_ogcevents_c_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcframebuffer.c b/src/video/ogc/SDL_ogcframebuffer.c new file mode 100644 index 0000000000..21fb7ee0cb --- /dev/null +++ b/src/video/ogc/SDL_ogcframebuffer.c @@ -0,0 +1,129 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_OGC + +#include "../SDL_sysvideo.h" +#include "SDL_ogcframebuffer_c.h" +#include "SDL_ogcgxcommon.h" +#include "SDL_ogcpixels.h" +#include "SDL_ogcvideo.h" + +#include +#include +#include +#include +#include + +static void draw_screen_rect(SDL_Window *window) +{ + s16 z = 0; + + GX_Begin(GX_QUADS, GX_VTXFMT0, 4); + GX_Position3s16(0, 0, z); + GX_TexCoord1x8(0); + GX_Position3s16(window->w, 0, z); + GX_TexCoord1x8(1); + GX_Position3s16(window->w, window->h, z); + GX_TexCoord1x8(2); + GX_Position3s16(0, window->h, z); + GX_TexCoord1x8(3); + GX_End(); +} + +static void free_window_data(SDL_Window *window) +{ + SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata; + if (windowdata) { + if (windowdata->pixels) { + SDL_free(windowdata->pixels); + } + if (windowdata->texels) { + free(windowdata->texels); + } + SDL_free(windowdata); + window->driverdata = NULL; + } +} + +int SDL_OGC_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) +{ + SDL_WindowData *windowdata; + int bytes_per_pixel = 4; + size_t texture_size; + int w, h; + + free_window_data(window); + windowdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); + if (!windowdata) { + SDL_OutOfMemory(); + return -1; + } + + w = window->w; + h = window->h; + windowdata->pixels = SDL_malloc(w * h * bytes_per_pixel); + texture_size = GX_GetTexBufferSize(w, h, GX_TF_RGBA8, GX_FALSE, 0); + windowdata->texels = memalign(32, texture_size); + windowdata->surface_format = SDL_PIXELFORMAT_RGBA8888; + window->driverdata = windowdata; + + *pitch = w * bytes_per_pixel; + *format = windowdata->surface_format; + *pixels = windowdata->pixels; + return 0; +} + +int SDL_OGC_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects) +{ + SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata; + u32 texture_size; + u8 gx_format; + + gx_format = OGC_texture_format_from_SDL(windowdata->surface_format); + for (int i = 0; i < numrects; i++) { + OGC_pixels_to_texture(windowdata->pixels, windowdata->surface_format, &rects[i], + window->surface->pitch, windowdata->texels, window->w); + } + texture_size = GX_GetTexBufferSize(window->w, window->h, gx_format, + GX_FALSE, 0); + DCStoreRange(windowdata->texels, texture_size); + GX_InvalidateTexAll(); + OGC_load_texture(windowdata->texels, window->w, window->h, gx_format, + SDL_ScaleModeNearest); + draw_screen_rect(window); + GX_DrawDone(); + + OGC_video_flip(_this, true); + + return 0; +} + +void SDL_OGC_DestroyWindowFramebuffer(_THIS, SDL_Window *window) +{ + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Destroying window"); + free_window_data(window); +} + +#endif /* SDL_VIDEO_DRIVER_OGC */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcframebuffer_c.h b/src/video/ogc/SDL_ogcframebuffer_c.h new file mode 100644 index 0000000000..af58bbcc14 --- /dev/null +++ b/src/video/ogc/SDL_ogcframebuffer_c.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_ogcframebuffer_c_h_ +#define SDL_ogcframebuffer_c_h_ + +#include "../../SDL_internal.h" + +extern int SDL_OGC_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch); +extern int SDL_OGC_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void SDL_OGC_DestroyWindowFramebuffer(_THIS, SDL_Window *window); + +#endif /* SDL_ogcframebuffer_c_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcgl.c b/src/video/ogc/SDL_ogcgl.c new file mode 100644 index 0000000000..fd26d690e9 --- /dev/null +++ b/src/video/ogc/SDL_ogcgl.c @@ -0,0 +1,134 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_OGC) && defined(SDL_VIDEO_OPENGL) + +#include "../SDL_sysvideo.h" + +#include "SDL_ogcgl.h" +#include "SDL_ogcvideo.h" + +#include + +typedef struct +{ + SDL_Window *window; + int swap_interval; +} OGC_GL_Context; + +/* Weak symbols for the opengx functions used by SDL, so that the client does + * not need to link to opengx, unless it actually uses OpenGL. */ +void __attribute__((weak)) ogx_initialize(void) +{ + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "%s() called but opengx not used in build!", __func__); +} + +void __attribute__((weak)) ogx_stencil_create(OgxStencilFlags) +{ + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "%s() called but opengx not used in build!", __func__); +} + +void __attribute__((weak)) *ogx_get_proc_address(const char *) +{ + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "%s() called but opengx not used in build!", __func__); + return NULL; +} + +int __attribute__((weak)) ogx_prepare_swap_buffers() +{ + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "%s() called but opengx not used in build!", __func__); + return 0; +} + +int SDL_OGC_GL_LoadLibrary(_THIS, const char *path) +{ + return 0; +} + +void *SDL_OGC_GL_GetProcAddress(_THIS, const char *proc) +{ + return ogx_get_proc_address(proc); +} + +void SDL_OGC_GL_UnloadLibrary(_THIS) +{ + // nothing to do +} + +SDL_GLContext SDL_OGC_GL_CreateContext(_THIS, SDL_Window * window) +{ + OGC_GL_Context *context = SDL_calloc(1, sizeof(*context)); + context->window = window; + context->swap_interval = 1; + ogx_initialize(); + if (_this->gl_config.stencil_size > 0) { + OgxStencilFlags flags = 0; /* Don't care if Z gets dirty on discarded fragments */ + if (_this->gl_config.stencil_size > 4) flags |= OGX_STENCIL_8BIT; + ogx_stencil_create(flags); + } + return context; +} + +int SDL_OGC_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) +{ + return 0; +} + +int SDL_OGC_GL_SetSwapInterval(_THIS, int interval) +{ + OGC_GL_Context *context = _this->current_glctx; + context->swap_interval = interval; + return 0; +} + +int SDL_OGC_GL_GetSwapInterval(_THIS) +{ + OGC_GL_Context *context = _this->current_glctx; + return context->swap_interval; +} + +int SDL_OGC_GL_SwapWindow(_THIS, SDL_Window * window) +{ + OGC_GL_Context *context = _this->current_glctx; + + bool vsync = context->swap_interval == 1; + OGC_video_flip(_this, vsync); + return 0; +} + +void SDL_OGC_GL_DeleteContext(_THIS, SDL_GLContext context) +{ + SDL_free(context); +} + +void SDL_OGC_GL_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor) +{ + *mask = SDL_GL_CONTEXT_PROFILE_COMPATIBILITY; + *major = 1; + *minor = 1; +} + +#endif /* SDL_VIDEO_DRIVER_OGC */ diff --git a/src/video/ogc/SDL_ogcgl.h b/src/video/ogc/SDL_ogcgl.h new file mode 100644 index 0000000000..dcaee41880 --- /dev/null +++ b/src/video/ogc/SDL_ogcgl.h @@ -0,0 +1,44 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_OGC_gl_h_ +#define SDL_OGC_gl_h_ + +#ifdef SDL_VIDEO_OPENGL + +#include "../SDL_sysvideo.h" + +int SDL_OGC_GL_LoadLibrary(_THIS, const char *path); +void *SDL_OGC_GL_GetProcAddress(_THIS, const char *proc); +void SDL_OGC_GL_UnloadLibrary(_THIS); +SDL_GLContext SDL_OGC_GL_CreateContext(_THIS, SDL_Window * window); +int SDL_OGC_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +int SDL_OGC_GL_SetSwapInterval(_THIS, int interval); +int SDL_OGC_GL_GetSwapInterval(_THIS); +int SDL_OGC_GL_SwapWindow(_THIS, SDL_Window * window); +void SDL_OGC_GL_DeleteContext(_THIS, SDL_GLContext context); +void SDL_OGC_GL_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor); + +#endif /* SDL_VIDEO_OPENGL */ + +#endif /* SDL_OGC_gl_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcgxcommon.c b/src/video/ogc/SDL_ogcgxcommon.c new file mode 100644 index 0000000000..ed7e096369 --- /dev/null +++ b/src/video/ogc/SDL_ogcgxcommon.c @@ -0,0 +1,129 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_OGC + +#include "SDL_ogcgxcommon.h" +#include "SDL_ogcpixels.h" + +#include +#include +#include + +static const f32 tex_pos[] __attribute__((aligned(32))) = { + 0.0, + 0.0, + 1.0, + 0.0, + 1.0, + 1.0, + 0.0, + 1.0, +}; + +void OGC_set_viewport(int x, int y, int w, int h) +{ + Mtx44 proj; + + GX_SetViewport(x, y, w, h, 0, 1); + GX_SetScissor(x, y, w, h); + + // matrix, t, b, l, r, n, f + guOrtho(proj, 0, h, 0, w, 0, 1); + GX_LoadProjectionMtx(proj, GX_ORTHOGRAPHIC); +} + +void OGC_draw_init(int w, int h) +{ + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "OGC_draw_init called with %d, %d", w, h); + + GX_ClearVtxDesc(); + GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); + GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX8); + + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); + + GX_SetArray(GX_VA_TEX0, (void *)tex_pos, 2 * sizeof(f32)); + GX_SetNumTexGens(1); + GX_SetNumChans(1); + GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, 0, + GX_DF_NONE, GX_AF_NONE); + + GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); + + GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE); + GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); + + OGC_set_viewport(0, 0, w, h); + + GX_InvVtxCache(); // update vertex cache +} + +void OGC_load_texture(void *texels, int w, int h, u8 format, + SDL_ScaleMode scale_mode) +{ + GXTexObj texobj_a, texobj_b; + + if (format == GX_TF_CI8) { + GX_InitTexObjCI(&texobj_a, texels, w, h, GX_TF_CI8, GX_CLAMP, GX_CLAMP, 0, GX_TLUT0); + GX_InitTexObjCI(&texobj_b, texels, w, h, GX_TF_CI8, GX_CLAMP, GX_CLAMP, 0, GX_TLUT1); + GX_LoadTexObj(&texobj_b, GX_TEXMAP1); + + // Setup TEV to combine Red+Green and Blue paletted images + GX_SetTevColor(GX_TEVREG0, (GXColor){ 255, 255, 0, 0 }); + GX_SetTevSwapModeTable(GX_TEV_SWAP1, GX_CH_RED, GX_CH_ALPHA, GX_CH_BLUE, GX_CH_ALPHA); + GX_SetTevSwapModeTable(GX_TEV_SWAP2, GX_CH_ALPHA, GX_CH_ALPHA, GX_CH_BLUE, GX_CH_ALPHA); + // first stage = red and green + GX_SetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP1); + GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_C0, GX_CC_ZERO); + // second stage = add blue (and opaque alpha) + GX_SetTevOp(GX_TEVSTAGE1, GX_BLEND); + GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD0, GX_TEXMAP1, GX_COLORNULL); + GX_SetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP2); + GX_SetTevColorIn(GX_TEVSTAGE1, GX_CC_TEXC, GX_CC_ZERO, GX_CC_ZERO, GX_CC_CPREV); + GX_SetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_KONST); + + GX_SetNumTevStages(2); + } else { + GX_InitTexObj(&texobj_a, texels, w, h, format, GX_CLAMP, GX_CLAMP, GX_FALSE); + } + + switch (scale_mode) { + case SDL_ScaleModeLinear: + GX_InitTexObjLOD(&texobj_a, GX_LINEAR, GX_LINEAR, + 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); + break; + case SDL_ScaleModeBest: + GX_InitTexObjLOD(&texobj_a, GX_LIN_MIP_LIN, GX_LINEAR, + 0.0f, 10.0f, 0.0f, 0, GX_ENABLE, GX_ANISO_4); + break; + default: + GX_InitTexObjLOD(&texobj_a, GX_NEAR, GX_NEAR, + 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); + } + GX_LoadTexObj(&texobj_a, GX_TEXMAP0); // load texture object so its ready to use +} + +#endif /* SDL_VIDEO_DRIVER_OGC */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcgxcommon.h b/src/video/ogc/SDL_ogcgxcommon.h new file mode 100644 index 0000000000..1b2ed5b321 --- /dev/null +++ b/src/video/ogc/SDL_ogcgxcommon.h @@ -0,0 +1,39 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifndef SDL_ogcgxcommon_h_ +#define SDL_ogcgxcommon_h_ + +#include "SDL_render.h" + +#include + +#define GX_COLOR_AS_U32(c) *((u32*)&c) + +void OGC_draw_init(int w, int h); +void OGC_set_viewport(int x, int y, int w, int h); +void OGC_load_texture(void *texels, int w, int h, u8 gx_format, + SDL_ScaleMode scale_mode); + +#endif /* SDL_ogcgxcommon_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogckeyboard.c b/src/video/ogc/SDL_ogckeyboard.c new file mode 100644 index 0000000000..1ebf0f8fc5 --- /dev/null +++ b/src/video/ogc/SDL_ogckeyboard.c @@ -0,0 +1,59 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_ogckeyboard.h" +#include "../../events/SDL_keyboard_c.h" + +#if defined(SDL_VIDEO_DRIVER_OGC) && defined(__wii__) +#include +#include + +void OGC_PumpKeyboardEvents(_THIS) { + keyboard_event ke; + + s32 res = KEYBOARD_GetEvent(&ke); + if (res && (ke.type == KEYBOARD_RELEASED || ke.type == KEYBOARD_PRESSED)) { + SDL_SendKeyboardKey((ke.type == KEYBOARD_PRESSED) ? SDL_PRESSED : SDL_RELEASED, (SDL_Scancode)ke.keycode); + + if (ke.type == KEYBOARD_PRESSED) { + const Uint16 symbol = ke.symbol; + char utf8[4] = {'\0'}; + + /* ignore private symbols, used by wiikeyboard for special keys */ + if ((symbol >= 0xE000 && symbol <= 0xF8FF) || symbol == 0xFFFF) + return; + + /* convert UCS-2 to UTF-8 */ + if (symbol < 0x80) { + utf8[0] = symbol; + } else if (symbol < 0x800) { + utf8[0] = 0xC0 | (symbol >> 6); + utf8[1] = 0x80 | (symbol & 0x3F); + } else { + utf8[0] = 0xE0 | (symbol >> 12); + utf8[1] = 0x80 | ((symbol >> 6) & 0x3F); + utf8[2] = 0x80 | (symbol & 0x3F); + } + + SDL_SendKeyboardText(utf8); + } + } +} +#endif diff --git a/src/video/ogc/SDL_ogckeyboard.h b/src/video/ogc/SDL_ogckeyboard.h new file mode 100644 index 0000000000..ca8c0464df --- /dev/null +++ b/src/video/ogc/SDL_ogckeyboard.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_OGC_keyboard_h_ +#define SDL_OGC_keyboard_h_ + +#include "../../SDL_internal.h" +#include "SDL_ogcvideo.h" + +#ifdef __wii__ +void OGC_PumpKeyboardEvents(_THIS); +#endif + +#endif /* SDL_OGC_keyboard_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcmouse.c b/src/video/ogc/SDL_ogcmouse.c new file mode 100644 index 0000000000..6e3bda2565 --- /dev/null +++ b/src/video/ogc/SDL_ogcmouse.c @@ -0,0 +1,416 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_OGC) && defined(__wii__) + +#include "SDL_surface.h" +#include "SDL_hints.h" + +#include "SDL_ogccursors.h" +#include "SDL_ogcgxcommon.h" +#include "SDL_ogcmouse.h" +#include "SDL_ogcpixels.h" + +#include "../SDL_sysvideo.h" +#include "../../render/SDL_sysrender.h" + +#include +#include +#include +#include +#include +#include +#include + +typedef struct _OGC_CursorData +{ + void *texels; + int hot_x, hot_y; + int w, h; +} OGC_CursorData; + +typedef struct +{ + void *texels; + int16_t x, y; + uint16_t w, h, maxside; +} OGC_CursorBackground; + +static OGC_CursorBackground s_cursor_background; +static int s_draw_counter = 0; +static bool s_extra_draw_enabled = false; +static bool s_2d_viewport_setup = false; + +static void draw_rect(s16 x, s16 y, u16 w, u16 h) +{ + GX_Begin(GX_QUADS, GX_VTXFMT0, 4); + GX_Position2s16(x, y); + GX_TexCoord2u8(0, 0); + GX_Position2s16(x + w, y); + GX_TexCoord2u8(1, 0); + GX_Position2s16(x + w, h + y); + GX_TexCoord2u8(1, 1); + GX_Position2s16(x, h + y); + GX_TexCoord2u8(0, 1); + GX_End(); +} + +static void draw_cursor_rect(OGC_CursorData *curdata) +{ + draw_rect(-curdata->hot_x, -curdata->hot_y, curdata->w, curdata->h); +} + +static void setup_2d_viewport(_THIS) +{ + int screen_w, screen_h; + + if (s_2d_viewport_setup) return; + + screen_w = _this->displays[0].current_mode.w; + screen_h = _this->displays[0].current_mode.h; + + OGC_set_viewport(0, 0, screen_w, screen_h); + + GX_ClearVtxDesc(); + GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); + GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_S16, 0); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_U8, 0); + GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); + + GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE); + GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); + GX_SetNumTevStages(1); + GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GX_SetZMode(GX_DISABLE, GX_ALWAYS, GX_FALSE); + GX_SetCullMode(GX_CULL_NONE); + GX_SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0); + + GX_SetNumTexGens(1); + GX_SetCurrentMtx(GX_PNMTX1); + + s_2d_viewport_setup = true; +} + +/* Create a cursor from a surface */ +static SDL_Cursor *OGC_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) +{ + OGC_CursorData *curdata; + SDL_Cursor *cursor; + u32 texture_size; + SDL_Rect rect; + + SDL_assert(surface->pitch == surface->w * 4); + + cursor = SDL_calloc(1, sizeof(*cursor)); + if (!cursor) { + SDL_OutOfMemory(); + return NULL; + } + + curdata = SDL_calloc(1, sizeof(*curdata)); + if (!curdata) { + SDL_OutOfMemory(); + SDL_free(cursor); + return NULL; + } + + curdata->hot_x = hot_x; + curdata->hot_y = hot_y; + curdata->w = surface->w; + curdata->h = surface->h; + + texture_size = GX_GetTexBufferSize(surface->w, surface->h, GX_TF_RGBA8, + GX_FALSE, 0); + curdata->texels = memalign(32, texture_size); + if (!curdata->texels) { + SDL_OutOfMemory(); + SDL_free(curdata); + SDL_free(cursor); + return NULL; + } + + rect.x = rect.y = 0; + rect.w = surface->w; + rect.h = surface->h; + OGC_pixels_to_texture(surface->pixels, surface->format->format, &rect, + surface->pitch, curdata->texels, surface->w); + DCStoreRange(curdata->texels, texture_size); + GX_InvalidateTexAll(); + + cursor->driverdata = curdata; + + return cursor; +} + +SDL_Cursor *OGC_CreateSystemCursor(SDL_SystemCursor id) +{ + const OGC_Cursor *cursor; + SDL_Surface *surface; + SDL_Cursor *c; + + switch (id) { + case SDL_SYSTEM_CURSOR_ARROW: + cursor = &OGC_cursor_arrow; + break; + case SDL_SYSTEM_CURSOR_HAND: + cursor = &OGC_cursor_hand; + break; + default: + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "System cursor %d not implemented", id); + return NULL; + } + surface = + SDL_CreateRGBSurfaceWithFormatFrom((void*)cursor->pixel_data, + cursor->width, + cursor->height, + cursor->bytes_per_pixel * 8, + cursor->width * cursor->bytes_per_pixel, + SDL_PIXELFORMAT_RGBA8888); + c = OGC_CreateCursor(surface, cursor->hot_x, cursor->hot_y); + SDL_FreeSurface(surface); + return c; +} + +/* Free a window manager cursor */ +static void OGC_FreeCursor(SDL_Cursor *cursor) +{ + OGC_CursorData *curdata = cursor->driverdata; + + if (curdata) { + if (curdata->texels) { + free(curdata->texels); + } + SDL_free(curdata); + } + + SDL_free(cursor); +} + +void OGC_InitMouse(_THIS) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->CreateCursor = OGC_CreateCursor; + mouse->CreateSystemCursor = OGC_CreateSystemCursor; + mouse->FreeCursor = OGC_FreeCursor; + + SDL_SetDefaultCursor(OGC_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND)); +} + +void OGC_QuitMouse(_THIS) +{ +} + +void OGC_draw_cursor(_THIS) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + OGC_CursorData *curdata; + Mtx mv; + int screen_w, screen_h; + float angle = 0.0f; + + s_draw_counter++; + + /* mark the texture as invalid */ + s_cursor_background.x = SHRT_MIN; + + if (!mouse || !mouse->cursor_shown || + !mouse->cur_cursor || !mouse->cur_cursor->driverdata) { + return; + } + + /* If this is the default cursor, rotate it, and if it's not pointed at the + * screen, hide it */ + if (mouse->cur_cursor == mouse->def_cursor) { + WPADData *data = WPAD_Data(mouse->mouseID); + angle = data->ir.angle; + if (!data->ir.valid) return; + } + + screen_w = _this->displays[0].current_mode.w; + screen_h = _this->displays[0].current_mode.h; + + curdata = mouse->cur_cursor->driverdata; + + if (s_extra_draw_enabled) { + /* Save the are behind the cursor. We could use GX_ReadBoundingBox() to + * figure out which area to save, but that would require calling the + * drawing function once mode. So, let's just take a guess at the area, + * taking into account possible cursor rotation. */ + s16 x, y; + u16 w, h, radius, side; + u32 texture_size; + + /* +1 is for the rounding of x and y */ + radius = MAX(curdata->w, curdata->h) + 1; + x = mouse->x - radius; + y = mouse->y - radius; + /* x and y must be multiples of 2 */ + if (x % 2) x--; + if (y % 2) y--; + w = h = side = radius * 2; + if (x < 0) { + w += x; + x = 0; + } else if (x + w > screen_w) { + w = screen_w - x; + } + + if (y < 0) { + h += y; + y = 0; + } else if (y + h > screen_h) { + h = screen_h - y; + } + + /* Make sure all our variables are properly aligned */ + while (side % 4) side++; + while (w % 4) w++; + while (h % 4) h++; + + if (w > 0 && h > 0) { + texture_size = GX_GetTexBufferSize(side, side, GX_TF_RGBA8, + GX_FALSE, 0); + if (!s_cursor_background.texels || side > s_cursor_background.maxside) { + free(s_cursor_background.texels); + s_cursor_background.texels = memalign(32, texture_size); + s_cursor_background.maxside = side; + } + DCInvalidateRange(s_cursor_background.texels, texture_size); + GX_SetTexCopySrc(x, y, w, h); + GX_SetTexCopyDst(w, h, GX_TF_RGBA8, GX_FALSE); + GX_CopyTex(s_cursor_background.texels, GX_FALSE); + s_cursor_background.x = x; + s_cursor_background.y = y; + s_cursor_background.w = w; + s_cursor_background.h = h; + } + } + + OGC_load_texture(curdata->texels, curdata->w, curdata->h, GX_TF_RGBA8, + SDL_ScaleModeNearest); + + guMtxIdentity(mv); + guMtxScaleApply(mv, mv, screen_w / 640.0f, screen_h / 480.0f, 1.0f); + if (angle != 0.0f) { + Mtx rot; + guMtxRotDeg(rot, 'z', angle); + guMtxConcat(mv, rot, mv); + } + guMtxTransApply(mv, mv, mouse->x, mouse->y, 0); + GX_LoadPosMtxImm(mv, GX_PNMTX1); + + setup_2d_viewport(_this); + + draw_cursor_rect(curdata); + GX_DrawDone(); +} + +void OGC_restore_viewport(_THIS) +{ + /* Restore default state for SDL (opengx restores it at every frame, so we + * don't care about it) */ + s_2d_viewport_setup = false; + GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); + GX_SetCurrentMtx(GX_PNMTX0); + if (_this->windows) { + /* Restore previous viewport for the renderer */ + SDL_Renderer *renderer = SDL_GetRenderer(_this->windows); + if (renderer) { + OGC_set_viewport(renderer->viewport.x, renderer->viewport.y, + renderer->viewport.w, renderer->viewport.h); + } + } +} + +bool OGC_prep_draw_cursor(_THIS) +{ + GXTexObj background; + Mtx mv; + static u32 last_draw_ms = 0; + u32 current_time_ms, elapsed_ms; + static int call_counter = 0; + static int last_draw_counter = 0; + + /* Ignore calls when a render target is set or OpenGL is not ready to swap + * the framebuffer */ + SDL_Renderer *renderer = SDL_GetRenderer(_this->windows); + if (renderer && renderer->target) return false; + + if (_this->gl_config.driver_loaded && + ogx_prepare_swap_buffers() < 0) return false; + + /* If this function is called repeatedly during the same frame, we assume + * that this is one of those applications that call SDL_OGC_GL_SwapWindow, + * SDL_UpdateWindowSurface or SDL_RenderPresent only if the video contents + * have actually changed. + * If that's the case, we toggle a flag that makes us redraw the screen + * when the mouse position has changed. + */ + if (!s_extra_draw_enabled) { + if (last_draw_counter != s_draw_counter) { + call_counter = 1; + last_draw_counter = s_draw_counter; + return false; + } + + if (call_counter++ > 10) { + s_extra_draw_enabled = true; + } else { + return false; + } + } + + /* Avoid drawing too often. 30 FPS should be enough */ + current_time_ms = gettime() / TB_TIMER_CLOCK; + elapsed_ms = current_time_ms - last_draw_ms; + if (elapsed_ms < 33) return false; + + /* If we have a texture for the cursor background, restore it; otherwise, + * we shouldn't draw the cursor. */ + if (!s_cursor_background.texels) return false; + + if (s_cursor_background.x != SHRT_MIN) { + setup_2d_viewport(_this); + + GX_PixModeSync(); + GX_InitTexObj(&background, s_cursor_background.texels, + s_cursor_background.w, s_cursor_background.h, + GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); + GX_InitTexObjLOD(&background, GX_NEAR, GX_NEAR, + 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); + GX_LoadTexObj(&background, GX_TEXMAP0); + GX_InvalidateTexAll(); + + guMtxIdentity(mv); + GX_LoadPosMtxImm(mv, GX_PNMTX1); + draw_rect(s_cursor_background.x, s_cursor_background.y, + s_cursor_background.w, s_cursor_background.h); + last_draw_ms = current_time_ms; + } + return true; +} +#endif /* SDL_VIDEO_DRIVER_OGC */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcmouse.h b/src/video/ogc/SDL_ogcmouse.h new file mode 100644 index 0000000000..aa9ff173fe --- /dev/null +++ b/src/video/ogc/SDL_ogcmouse.h @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_OGC_mouse_h_ +#define SDL_OGC_mouse_h_ + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_mouse_c.h" + +void OGC_InitMouse(_THIS); +void OGC_QuitMouse(_THIS); +void OGC_draw_cursor(_THIS); +void OGC_restore_viewport(_THIS); +bool OGC_prep_draw_cursor(_THIS); +SDL_Cursor *OGC_CreateSystemCursor(SDL_SystemCursor id); + +#endif /* SDL_OGC_mouse_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcpixels.c b/src/video/ogc/SDL_ogcpixels.c new file mode 100644 index 0000000000..2d87b40d95 --- /dev/null +++ b/src/video/ogc/SDL_ogcpixels.c @@ -0,0 +1,355 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#include "SDL_ogcpixels.h" + +#include + +#define PIXELS_TO_TEXTURE_32(format_func) \ + static void pixels_to_texture_ ## format_func( \ + void *pixels, const SDL_Rect *rect, int16_t pitch, void *texture, int16_t tex_width) \ + { \ + int16_t tex_pitch = (tex_width + 3) / 4 * 4; \ + for (int row = 0; row < rect->h; row++) { \ + int y = rect->y + row; \ + u32 *src = (u32 *)((u8 *)pixels + pitch * row); \ + for (int col = 0; col < rect->w; col++) { \ + int x = rect->x + col; \ + u32 offset = (((y >> 2) << 4) * tex_pitch) + \ + ((x >> 2) << 6) + (((y % 4 << 2) + x % 4) << 1); \ + set_pixel_to_texture_ ## format_func(texture, offset, *src++); \ + } \ + } \ + } + +#define PIXELS_FROM_TEXTURE_32(format_func) \ + static void pixels_from_texture_ ## format_func( \ + void *pixels, int16_t w, int16_t h, int16_t pitch, void *texture) \ + { \ + int tex_width = (w + 3) / 4 * 4; \ + for (int y = 0; y < h; y++) { \ + u32 *dst = (u32 *)((u8 *)pixels + pitch * y); \ + for (int x = 0; x < w; x++) { \ + u32 offset = (((y >> 2) << 4) * tex_width) + \ + ((x >> 2) << 6) + (((y % 4 << 2) + x % 4) << 1); \ + *dst++ = get_pixel_from_texture_ ## format_func(texture, offset); \ + } \ + } \ + } + +static u8 texture_format_from_SDL(const SDL_PixelFormatEnum format) +{ + switch (format) { + case SDL_PIXELFORMAT_INDEX8: + return GX_TF_CI8; + case SDL_PIXELFORMAT_RGB565: + return GX_TF_RGB565; + case SDL_PIXELFORMAT_RGB24: + case SDL_PIXELFORMAT_RGBA8888: + case SDL_PIXELFORMAT_ARGB8888: + case SDL_PIXELFORMAT_XRGB8888: + return GX_TF_RGBA8; + default: + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, + "(texture_format_from_SDL) Unsupported SDL pixel format %d", + format); + } + return 0xff; // invalid +} + +static inline void set_pixel_to_texture_ARGB(void *texture, u32 offset, u32 color) +{ + *(u16*)(texture + offset) = color >> 16; + *(u16*)(texture + offset + 32) = color; +} + +static inline u32 get_pixel_from_texture_ARGB(void *texture, u32 offset) +{ + return *(u16*)(texture + offset) << 16 | + *(u16*)(texture + offset + 32); +} + +static inline void set_pixel_to_texture_RGBA(void *texture, u32 offset, u32 color) +{ + set_pixel_to_texture_ARGB(texture, offset, (color << 24) | (color >> 8)); +} + +static inline u32 get_pixel_from_texture_32(int x, int y, void *texture, int tex_width) +{ + u8 *tex = texture; + u32 offset; + + offset = (((y >> 2) << 4) * tex_width) + ((x >> 2) << 6) + (((y % 4 << 2) + x % 4) << 1); + + return *(tex + offset) | + *(tex + offset + 1) << 24 | + *(tex + offset + 32) << 16 | + *(tex + offset + 33) << 8; +} + +PIXELS_TO_TEXTURE_32(RGBA) + +static void pixels_RGBA_from_texture(void *pixels, int16_t w, int16_t h, + int16_t pitch, void *texture) +{ + u32 *dst = pixels; + + int tex_width = (w + 3) / 4 * 4; + for (int y = 0; y < h; y++) { + dst = (u32 *)((u8 *)pixels + pitch * y); + for (int x = 0; x < w; x++) { + *dst++ = get_pixel_from_texture_32(x, y, texture, tex_width); + } + } +} + +PIXELS_TO_TEXTURE_32(ARGB) +PIXELS_FROM_TEXTURE_32(ARGB) + +static inline void set_pixel_to_texture_XRGB(void *texture, u32 offset, u32 color) +{ + set_pixel_to_texture_ARGB(texture, offset, 0xff000000 | color); +} + +PIXELS_TO_TEXTURE_32(XRGB) + +static void pixels_XRGB_from_texture(void *pixels, int16_t w, int16_t h, + int16_t pitch, void *texture) +{ + u32 *dst = pixels; + + int tex_width = (w + 3) / 4 * 4; + for (int y = 0; y < h; y++) { + dst = (u32 *)((u8 *)pixels + pitch * y); + for (int x = 0; x < w; x++) { + *dst++ = get_pixel_from_texture_32(x, y, texture, tex_width) >> 8; + } + } +} + +static void pixels_RGB_to_texture(void *pixels, const SDL_Rect *rect, + int16_t pitch, void *texture, int16_t tex_width) +{ + u8 *src = pixels; + + int tex_pitch = (tex_width + 3) / 4 * 4; + for (int row = 0; row < rect->h; row++) { + int y = rect->y + row; + src = (u8 *)pixels + pitch * row; + for (int col = 0; col < rect->w; col++) { + int x = rect->x + col; + u32 offset = (((y >> 2) << 4) * tex_pitch) + + ((x >> 2) << 6) + (((y % 4 << 2) + x % 4) << 1); + u8 r = *src++; + u8 g = *src++; + u8 b = *src++; + set_pixel_to_texture_ARGB(texture, offset, 0xff000000 | r << 16 | g << 8 | b); + } + } +} + +static void pixels_RGB_from_texture(void *pixels, int16_t w, int16_t h, + int16_t pitch, void *texture) +{ + u8 *dst = pixels; + + int tex_width = (w + 3) / 4 * 4; + for (int y = 0; y < h; y++) { + dst = (u8 *)pixels + pitch * y; + for (int x = 0; x < w; x++) { + u32 color = get_pixel_from_texture_32(x, y, texture, tex_width); + *dst++ = color >> 24; + *dst++ = color >> 16; + *dst++ = color >> 8; + } + } +} + +static void pixels_16_to_texture(void *pixels, const SDL_Rect *rect, int16_t pitch, + void *texture, int16_t tex_width) +{ + /* We only support coordinates multiple of 4. While we don't add support + * for arbitrary coordinates (TODO), let's restrict the paint area to the + * full 4x4 cells covered by the rect. In the future we can add code to + * fill up the remaining borders. */ + int x0 = (rect->x + 3) & ~0x3; + int x1 = (rect->x + rect->w) & ~0x3; + int y0 = (rect->y + 3) & ~0x3; + int y1 = (rect->y + rect->h) & ~0x3; + int skipped_bytes_left = (x0 - rect->x) * 2; + int tex_pitch = tex_width * 2; + + + for (int row = 0; row < y1 - y0; row += 4) { + u64 *src1 = pixels + (skipped_bytes_left + row * pitch); + u64 *src2 = (void*)src1 + (pitch * 1); + u64 *src3 = (void*)src1 + (pitch * 2); + u64 *src4 = (void*)src1 + (pitch * 3); + u64 *dst = texture + (x0 * 8 + (y0 + row) * tex_pitch); + for (int col = x0; col < x1; col += 4) { + *dst++ = *src1++; + *dst++ = *src2++; + *dst++ = *src3++; + *dst++ = *src4++; + } + } +} + +static void pixels_16_from_texture(void *pixels, int16_t pitch, int16_t h, + void *texture) +{ + long long int *src = texture; + long long int *dst1 = pixels; + long long int *dst2 = (long long int *)((char *)pixels + (pitch * 1)); + long long int *dst3 = (long long int *)((char *)pixels + (pitch * 2)); + long long int *dst4 = (long long int *)((char *)pixels + (pitch * 3)); + int rowpitch = (pitch >> 3) * 3; + + for (int y = 0; y < h; y += 4) { + for (int x = 0; x < pitch; x += 8) { + *dst1++ = *src++; + *dst2++ = *src++; + *dst3++ = *src++; + *dst4++ = *src++; + } + + dst1 = dst4; + dst2 += rowpitch; + dst3 += rowpitch; + dst4 += rowpitch; + } +} + +static inline void set_pixel_8_to_texture(int x, int y, u8 color, void *texture, int tex_width) +{ + u8 *tex = texture; + u32 offset; + + offset = ((y & ~3) * tex_width) + ((x & ~7) << 2) + ((y & 3) << 3) + (x & 7); + + tex[offset] = color; +} + +static inline u8 get_pixel_8_from_texture(int x, int y, void *texture, int tex_width) +{ + u8 *tex = texture; + u32 offset; + + offset = ((y & ~3) * tex_width) + ((x & ~7) << 2) + ((y & 3) << 3) + (x & 7); + + return tex[offset]; +} + +static void pixels_8_to_texture(void *pixels, int16_t w, int16_t h, + int16_t pitch, void *texture) +{ + u8 *src = pixels; + int tex_width = (w + 7) / 8 * 8; + + for (int y = 0; y < h; y++) { + src = (u8 *)pixels + pitch * y; + for (int x = 0; x < w; x++) { + set_pixel_8_to_texture(x, y, *src++, texture, tex_width); + } + } +} + +static void pixels_8_from_texture(void *pixels, int16_t w, int16_t h, + int16_t pitch, void *texture) +{ + u8 *dst = pixels; + int tex_width = (w + 7) / 8 * 8; + + for (int y = 0; y < h; y++) { + dst = (u8 *)pixels + pitch * y; + for (int x = 0; x < w; x++) { + *dst++ = get_pixel_8_from_texture(x, y, texture, tex_width); + } + } +} + +void OGC_pixels_to_texture(void *pixels, const SDL_PixelFormatEnum format, + const SDL_Rect *rect, int16_t pitch, + void *texture, int16_t tex_width) +{ + switch (format) { + case SDL_PIXELFORMAT_INDEX8: + pixels_8_to_texture(pixels, rect->w, rect->h, pitch, texture); + break; + case SDL_PIXELFORMAT_RGB565: + pixels_16_to_texture(pixels, rect, pitch, texture, tex_width); + break; + case SDL_PIXELFORMAT_RGB24: + pixels_RGB_to_texture(pixels, rect, pitch, texture, tex_width); + break; + case SDL_PIXELFORMAT_RGBA8888: + pixels_to_texture_RGBA(pixels, rect, pitch, texture, tex_width); + break; + case SDL_PIXELFORMAT_ARGB8888: + pixels_to_texture_ARGB(pixels, rect, pitch, texture, tex_width); + break; + case SDL_PIXELFORMAT_XRGB8888: + pixels_to_texture_XRGB(pixels, rect, pitch, texture, tex_width); + break; + default: + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, + "ptt: unsupported SDL pixel format %d", format); + // TODO support more formats + } +} + +void OGC_pixels_from_texture(void *pixels, const SDL_PixelFormatEnum format, + int16_t w, int16_t h, int16_t pitch, + void *texture) +{ + switch (format) { + case SDL_PIXELFORMAT_INDEX8: + pixels_8_from_texture(pixels, w, h, pitch, texture); + break; + case SDL_PIXELFORMAT_RGB565: + pixels_16_from_texture(pixels, pitch, h, texture); + break; + case SDL_PIXELFORMAT_RGB24: + pixels_RGB_from_texture(pixels, w, h, pitch, texture); + break; + case SDL_PIXELFORMAT_RGBA8888: + pixels_RGBA_from_texture(pixels, w, h, pitch, texture); + break; + case SDL_PIXELFORMAT_ARGB8888: + pixels_from_texture_ARGB(pixels, w, h, pitch, texture); + break; + case SDL_PIXELFORMAT_XRGB8888: + pixels_XRGB_from_texture(pixels, w, h, pitch, texture); + break; + default: + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, + "pft: unsupported SDL pixel format %d", format); + // TODO support more formats + } +} + +u8 OGC_texture_format_from_SDL(const SDL_PixelFormatEnum format) +{ + return texture_format_from_SDL(format); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcpixels.h b/src/video/ogc/SDL_ogcpixels.h new file mode 100644 index 0000000000..c92d032aa4 --- /dev/null +++ b/src/video/ogc/SDL_ogcpixels.h @@ -0,0 +1,42 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifndef SDL_ogcpixels_h_ +#define SDL_ogcpixels_h_ + +#include "SDL_pixels.h" +#include "SDL_rect.h" + +#include + +void OGC_pixels_to_texture(void *pixels, SDL_PixelFormatEnum format, + const SDL_Rect *rect, int16_t pitch, + void *texels, int16_t tex_width); +void OGC_pixels_from_texture(void *pixels, SDL_PixelFormatEnum format, + int16_t w, int16_t h, int16_t pitch, + void *texels); + +u8 OGC_texture_format_from_SDL(const SDL_PixelFormatEnum format); + +#endif /* SDL_ogcpixels_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcvideo.c b/src/video/ogc/SDL_ogcvideo.c new file mode 100644 index 0000000000..5653700f73 --- /dev/null +++ b/src/video/ogc/SDL_ogcvideo.c @@ -0,0 +1,380 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_OGC + +#include "../../events/SDL_events_c.h" +#include "../SDL_pixels_c.h" +#include "../SDL_sysvideo.h" +#include "SDL_mouse.h" +#include "SDL_video.h" + +#include "SDL_hints.h" +#include "SDL_ogcevents_c.h" +#include "SDL_ogcframebuffer_c.h" +#include "SDL_ogcgl.h" +#include "SDL_ogcgxcommon.h" +#include "SDL_ogcmouse.h" +#include "SDL_ogcvideo.h" + +#include +#include +#include +#include +#include + +#include + +#define DEFAULT_FIFO_SIZE 256 * 1024 + +// Inverse of the VI_TVMODE macro +#define VI_FORMAT_FROM_MODE(tvmode) (tvmode >> 2) + +/* A video mode with a 320 width; we'll build it programmatically. */ +static GXRModeObj s_mode320; + +static const GXRModeObj *s_ntsc_modes[] = { + &TVNtsc240Ds, + &TVNtsc480Prog, + NULL, +}; + +static const GXRModeObj *s_mpal_modes[] = { + &TVMpal240Ds, + &TVMpal480Prog, + NULL, +}; + +static const GXRModeObj *s_eurgb60_modes[] = { + &TVEurgb60Hz240Ds, + &TVEurgb60Hz480Prog, + // Also add some PAL modes, since EURGB60 supports them too + &TVPal264Ds, + &TVPal528Prog, + &TVPal576ProgScale, + NULL, +}; + +static const GXRModeObj *s_pal_modes[] = { + &TVPal264Ds, + &TVPal528Prog, + &TVPal576ProgScale, + NULL, +}; + +/* Initialization/Query functions */ +static int OGC_VideoInit(_THIS); +static void OGC_VideoQuit(_THIS); + +static void init_display_mode(SDL_DisplayMode *mode, const GXRModeObj *vmode) +{ + u32 format = VI_FORMAT_FROM_MODE(vmode->viTVMode); + + /* Use a fake 32-bpp desktop mode */ + SDL_zero(*mode); + mode->format = SDL_PIXELFORMAT_ARGB8888; + mode->w = vmode->fbWidth; + mode->h = vmode->efbHeight; + switch (format) { + case VI_DEBUG: + case VI_NTSC: + case VI_EURGB60: + case VI_MPAL: + mode->refresh_rate = 60; + break; + case VI_PAL: + case VI_DEBUG_PAL: + mode->refresh_rate = 50; + break; + } + mode->driverdata = (GXRModeObj*)vmode; +} + +static void add_supported_modes(SDL_VideoDisplay *display, u32 tv_format) +{ + const GXRModeObj **gx_modes; + SDL_DisplayMode mode; + + switch (tv_format) { + case VI_DEBUG: + case VI_NTSC: + gx_modes = s_ntsc_modes; + break; + case VI_MPAL: + gx_modes = s_mpal_modes; + break; + case VI_EURGB60: + gx_modes = s_eurgb60_modes; + break; + case VI_PAL: + case VI_DEBUG_PAL: + gx_modes = s_pal_modes; + break; + default: + return; + } + + /* All libogc video modes are 640 pixel wide, even the 240p ones. While + * this can be useful for some applications, others might prefer a video + * mode with less elongated pixels, such as 320x240. Therefore, let's + * create one: we take the first video mode in the array (which has always + * a height of approximately 240p) and we use it as template to build the + * "mode320": we just set the fbWidth field to 320: the VI interface will + * take care of the horizontal scale for us. */ + memcpy(&s_mode320, gx_modes[0], sizeof(s_mode320)); + s_mode320.fbWidth = 320; + init_display_mode(&mode, &s_mode320); + SDL_AddDisplayMode(display, &mode); + + /* Now add all the "standard" modes from libogc */ + while (*gx_modes) { + init_display_mode(&mode, *gx_modes); + SDL_AddDisplayMode(display, &mode); + gx_modes++; + } +} + +static void setup_video_mode(_THIS, GXRModeObj *vmode) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; + + VIDEO_SetBlack(true); + VIDEO_Configure(vmode); + + /* Allocate the XFB */ + videodata->xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode)); + videodata->xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode)); + + VIDEO_ClearFrameBuffer(vmode, videodata->xfb[0], COLOR_BLACK); + VIDEO_SetNextFramebuffer(videodata->xfb[0]); + VIDEO_SetBlack(false); + VIDEO_Flush(); + + VIDEO_WaitVSync(); + if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); + + /* Setup the EFB -> XFB copy operation */ + GX_SetDispCopySrc(0, 0, vmode->fbWidth, vmode->efbHeight); + GX_SetDispCopyDst(vmode->fbWidth, vmode->xfbHeight); + GX_SetDispCopyYScale((f32)vmode->xfbHeight / (f32)vmode->efbHeight); + GX_SetCopyFilter(vmode->aa, vmode->sample_pattern, GX_FALSE, vmode->vfilter); + GX_SetFieldMode(vmode->field_rendering, + ((vmode->viHeight == 2 * vmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); + + OGC_draw_init(vmode->fbWidth, vmode->efbHeight); +} + +static int OGC_SetDisplayMode(_THIS, SDL_VideoDisplay *display, + SDL_DisplayMode *mode) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; + /* The GX video mode is stored in the driverdata pointer */ + GXRModeObj *vmode = mode->driverdata; + + if (videodata->xfb[0]) + free(MEM_K1_TO_K0(videodata->xfb[0])); + if (videodata->xfb[1]) + free(MEM_K1_TO_K0(videodata->xfb[1])); + + setup_video_mode(_this, vmode); + return 0; +} + +static void OGC_ShowWindow(_THIS, SDL_Window *window) +{ + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); +} + +static int OGC_ShowMessageBox(_THIS, const SDL_MessageBoxData *messageboxdata, + int *buttonid) +{ + /* Unimplemented, but at least show the message in the log */ + SDL_SetError("ShowMessageBox unimplemented: \"%s\", \"%s\"", + messageboxdata->title, messageboxdata->message); + return 0; +} + +/* OGC driver bootstrap functions */ + +static void OGC_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_free(device->driverdata); + SDL_free(device); +} + +static SDL_VideoDevice *OGC_CreateDevice(void) +{ + SDL_VideoDevice *device; + SDL_VideoData *videodata; + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + SDL_OutOfMemory(); + return NULL; + } + + videodata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); + if (!videodata) { + SDL_OutOfMemory(); + SDL_free(device); + return NULL; + } + + device->driverdata = videodata; + + /* Set the function pointers */ + device->VideoInit = OGC_VideoInit; + device->VideoQuit = OGC_VideoQuit; + device->SetDisplayMode = OGC_SetDisplayMode; + device->PumpEvents = OGC_PumpEvents; + device->ShowWindow = OGC_ShowWindow; + device->CreateWindowFramebuffer = SDL_OGC_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = SDL_OGC_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = SDL_OGC_DestroyWindowFramebuffer; + device->ShowMessageBox = OGC_ShowMessageBox; + +#ifdef SDL_VIDEO_OPENGL + device->GL_LoadLibrary = SDL_OGC_GL_LoadLibrary; + device->GL_GetProcAddress = SDL_OGC_GL_GetProcAddress; + device->GL_UnloadLibrary = SDL_OGC_GL_UnloadLibrary; + device->GL_CreateContext = SDL_OGC_GL_CreateContext; + device->GL_MakeCurrent = SDL_OGC_GL_MakeCurrent; + device->GL_SetSwapInterval = SDL_OGC_GL_SetSwapInterval; + device->GL_GetSwapInterval = SDL_OGC_GL_GetSwapInterval; + device->GL_SwapWindow = SDL_OGC_GL_SwapWindow; + device->GL_DeleteContext = SDL_OGC_GL_DeleteContext; + device->GL_DefaultProfileConfig = SDL_OGC_GL_DefaultProfileConfig; +#endif + + device->free = OGC_DeleteDevice; + + return device; +} + +VideoBootStrap OGC_bootstrap = { + "ogc-video", "ogc video driver", + OGC_CreateDevice +}; + +int OGC_VideoInit(_THIS) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; + SDL_DisplayMode mode; + GXRModeObj *vmode; + static const GXColor background = { 0, 0, 0, 255 }; + + VIDEO_Init(); + + vmode = VIDEO_GetPreferredMode(NULL); + + videodata->gp_fifo = memalign(32, DEFAULT_FIFO_SIZE); + memset(videodata->gp_fifo, 0, DEFAULT_FIFO_SIZE); + GX_Init(videodata->gp_fifo, DEFAULT_FIFO_SIZE); + + setup_video_mode(_this, vmode); + GX_SetCopyClear(background, GX_MAX_Z24); + + GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); + GX_SetCullMode(GX_CULL_NONE); + GX_SetBlendMode(GX_BM_NONE, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + + GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); + + GX_Flush(); + + init_display_mode(&mode, vmode); + if (SDL_AddBasicVideoDisplay(&mode) < 0) { + return -1; + } + + SDL_AddDisplayMode(&_this->displays[0], &mode); + add_supported_modes(&_this->displays[0], VI_FORMAT_FROM_MODE(vmode->viTVMode)); + + videodata->vmode = vmode; + +#ifdef __wii__ + OGC_InitMouse(_this); +#endif + return 0; +} + +void OGC_VideoQuit(_THIS) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; + SDL_VideoDisplay *display; + +#ifdef __wii__ + OGC_QuitMouse(_this); +#endif + + SDL_free(videodata->gp_fifo); + if (videodata->xfb[0]) + free(MEM_K1_TO_K0(videodata->xfb[0])); + if (videodata->xfb[1]) + free(MEM_K1_TO_K0(videodata->xfb[1])); + + /* During shutdown, SDL_ResetDisplayModes() will be called and will invoke + * SDL_free() on driverdata. Nullify the pointers in order to avoid a + * crash, since we didn't actually allocate this memory. */ + display = &_this->displays[0]; + for (int i = display->num_display_modes; i--;) { + display->display_modes[i].driverdata = NULL; + } + display->desktop_mode.driverdata = NULL; +} + +void *OGC_video_get_xfb(_THIS) +{ + SDL_VideoData *videodata = _this->driverdata; + return videodata->xfb[videodata->fb_index]; +} + +void OGC_video_flip(_THIS, bool vsync) +{ + SDL_VideoData *videodata = _this->driverdata; + void *xfb = OGC_video_get_xfb(_this); + + if (_this->gl_config.driver_loaded && + ogx_prepare_swap_buffers() < 0) return; + +#ifdef __wii__ + OGC_draw_cursor(_this); + OGC_restore_viewport(_this); +#endif + GX_CopyDisp(xfb, GX_FALSE); + GX_DrawDone(); + GX_Flush(); + + VIDEO_SetNextFramebuffer(xfb); + VIDEO_Flush(); + if (vsync) { + VIDEO_WaitVSync(); + } + + videodata->fb_index ^= 1; +} + +#endif /* SDL_VIDEO_DRIVER_OGC */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcvideo.h b/src/video/ogc/SDL_ogcvideo.h new file mode 100644 index 0000000000..3821d1966c --- /dev/null +++ b/src/video/ogc/SDL_ogcvideo.h @@ -0,0 +1,50 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifndef SDL_ogcvideo_h_ +#define SDL_ogcvideo_h_ + +#include "../SDL_sysvideo.h" + +#include + +typedef struct SDL_VideoData +{ + GXRModeObj *vmode; + u8 *gp_fifo; + void *xfb[2]; + u8 fb_index; +} SDL_VideoData; + +typedef struct SDL_WindowData +{ + void *pixels; + u8 *texels; + SDL_PixelFormatEnum surface_format; +} SDL_WindowData; + +void *OGC_video_get_xfb(SDL_VideoDevice *device); +void OGC_video_flip(SDL_VideoDevice *device, bool vsync); + +#endif /* SDL_ogcvideo_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 52a268561c..4cf924dd90 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -36,6 +36,10 @@ if(N3DS) link_libraries(SDL2::SDL2main) endif() +if(OGC) + link_libraries(SDL2::SDL2main) +endif() + if(PSP) link_libraries( SDL2::SDL2main ================================================ FILE: gamecube/SDL2_gfx/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: TurtleP pkgname=gamecube-sdl2_gfx pkgver=1.0.4 pkgrel=4 pkgdesc="SDL2 graphics drawing primitives." arch=('any') url="https://libsdl.org" license=("zlib") options=(!strip libtool staticlibs) makedepends=('wii-pkg-config' 'dkp-toolchain-vars') depends=('gamecube-sdl2') source=("http://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-1.0.4.tar.gz") groups=('gamecube-portlibs' 'gamecube-sdl2-libs') build() { cd SDL2_gfx-$pkgver source /opt/devkitpro/cubevars.sh ./configure --prefix="${PORTLIBS_PREFIX}" \ --enable-mmx=no \ --host=powerpc-eabi \ --disable-shared --enable-static \ --with-sdl-prefix=${PORTLIBS_PREFIX} make } package() { cd SDL2_gfx-$pkgver source /opt/devkitpro/cubevars.sh make DESTDIR="$pkgdir" install } sha256sums=('63e0e01addedc9df2f85b93a248f06e8a04affa014a835c2ea34bfe34e576262') ================================================ FILE: gamecube/SDL2_image/Makefile.in.patch ================================================ --- Makefile.in.orig 2018-10-31 09:59:00.000000000 -0500 +++ Makefile.in 2019-06-26 01:23:45.000000000 -0500 @@ -95,7 +95,6 @@ host_triplet = @host@ @USE_VERSION_RC_FALSE@libSDL2_image_la_DEPENDENCIES = \ @USE_VERSION_RC_FALSE@ $(am__DEPENDENCIES_1) -noinst_PROGRAMS = showimage$(EXEEXT) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude/libtool.m4 \ @@ -164,9 +163,6 @@ libSDL2_image_la_LINK = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(OBJCLD) $(AM_OBJCFLAGS) \ $(OBJCFLAGS) $(libSDL2_image_la_LDFLAGS) $(LDFLAGS) -o $@ -showimage_SOURCES = showimage.c -showimage_OBJECTS = showimage.$(OBJEXT) -showimage_DEPENDENCIES = libSDL2_image.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -476,7 +472,6 @@ @USE_VERSION_RC_TRUE@libSDL2_image_la_DEPENDENCIES = version.o pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = SDL2_image.pc -showimage_LDADD = libSDL2_image.la all: all-am .SUFFIXES: @@ -566,10 +561,6 @@ libSDL2_image.la: $(libSDL2_image_la_OBJECTS) $(libSDL2_image_la_DEPENDENCIES) $(EXTRA_libSDL2_image_la_DEPENDENCIES) $(AM_V_OBJCLD)$(libSDL2_image_la_LINK) -rpath $(libdir) $(libSDL2_image_la_OBJECTS) $(libSDL2_image_la_LIBADD) $(LIBS) -showimage$(EXEEXT): $(showimage_OBJECTS) $(showimage_DEPENDENCIES) $(EXTRA_showimage_DEPENDENCIES) - @rm -f showimage$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(showimage_OBJECTS) $(showimage_LDADD) $(LIBS) - mostlyclean-compile: -rm -f *.$(OBJEXT) ================================================ FILE: gamecube/SDL2_image/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Cpasjuste # Contributor: carstene1ns pkgname=gamecube-sdl2_image pkgver=2.8.2 pkgrel=1 pkgdesc="SDL2 image loading library." arch=('any') url="https://libsdl.org/projects/SDL_image/" license=("zlib") options=(!strip libtool staticlibs) makedepends=('wii-pkg-config' 'dkp-toolchain-vars') depends=( 'gamecube-sdl2' 'ppc-libpng' 'ppc-libjpeg-turbo' ) source=("${url}release/SDL2_image-${pkgver}.tar.gz") groups=('gamecube-portlibs' 'gamecube-sdl2-libs') build() { cd SDL2_image-$pkgver source ${DEVKITPRO}/cubevars.sh sed '/^noinst_PROGRAMS/d' -i Makefile.in ./configure --prefix="${PORTLIBS_PREFIX}" \ --host=powerpc-eabi --disable-shared --enable-static \ --disable-sdltest \ --with-sdl-prefix=${PORTLIBS_PREFIX} make } package() { cd SDL2_image-$pkgver source /opt/devkitpro/cubevars.sh make DESTDIR="$pkgdir" install # add our static libs echo "Requires.private: libpng libjpeg" >> "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/SDL2_image.pc" # License #install -Dm644 "COPYING.txt" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/COPYING.txt" } sha256sums=('8f486bbfbcf8464dd58c9e5d93394ab0255ce68b51c5a966a918244820a76ddc') ================================================ FILE: gamecube/SDL2_mixer/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Cpasjuste # Contributor: carstene1ns pkgname=gamecube-sdl2_mixer pkgver=2.6.3 pkgrel=2 pkgdesc="A sample multi-channel audio mixer library." arch=('any') url="https://libsdl.org/projects/SDL_mixer/" license=("zlib") options=(!strip libtool staticlibs) makedepends=('gamecube-pkg-config' 'dkp-toolchain-vars') depends=( 'gamecube-sdl2' 'ppc-flac' 'ppc-libvorbisidec' 'ppc-libmodplug' 'ppc-mpg123' 'ppc-opusfile' ) source=( "${url}release/SDL2_mixer-${pkgver}.tar.gz" "sdl2_mixer-config.cmake.in.patch" ) groups=('gamecube-portlibs' 'gamecube-sdl2-libs') build() { cd SDL2_mixer-$pkgver source /opt/devkitpro/cubevars.sh # patch out compiling playwave and playmus sed 's|\$(objects)/play.*mus\$(EXE)||' -i Makefile.in patch -Np0 -i ${srcdir}/sdl2_mixer-config.cmake.in.patch LIBS="-lm" ./configure --prefix="${PORTLIBS_PREFIX}" \ --host=powerpc-eabi --disable-shared --enable-static \ --disable-music-cmd \ --enable-music-ogg-tremor \ --enable-music-mod-modplug make } package() { cd SDL2_mixer-$pkgver source /opt/devkitpro/cubevars.sh make DESTDIR="$pkgdir" install # add our static libs echo "Requires.private: vorbisidec libmodplug libmpg123 opusfile flac" >> "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/SDL2_mixer.pc" # License install -Dm644 "LICENSE.txt" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/LICENSE.txt" } sha256sums=('7a6ba86a478648ce617e3a5e9277181bc67f7ce9876605eea6affd4a0d6eea8f' '124baf871d39dbceb31ff71beccd2c4f0497ae7cfcfd9f11d99b57e28a151da1') ================================================ FILE: gamecube/SDL2_mixer/sdl2_mixer-config.cmake.in.patch ================================================ --- sdl2_mixer-config.cmake.in.orig 2024-11-03 13:41:46.831470270 +0000 +++ sdl2_mixer-config.cmake.in 2024-11-03 13:42:39.540513604 +0000 @@ -79,7 +79,7 @@ set(_sdl2mixer_incdir "${includedir}/SDL2") # Convert _sdl2mixer_extra_static_libraries to list and keep only libraries -string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)" _sdl2mixer_extra_static_libraries "${_sdl2mixer_extra_static_libraries}") +string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._+]+))|(-Wl,[^ ]*framework[^ ]*)" _sdl2mixer_extra_static_libraries "${_sdl2mixer_extra_static_libraries}") string(REGEX REPLACE "^-l" "" _sdl2mixer_extra_static_libraries "${_sdl2mixer_extra_static_libraries}") string(REGEX REPLACE ";-l" ";" _sdl2mixer_extra_static_libraries "${_sdl2mixer_extra_static_libraries}") ================================================ FILE: gamecube/SDL2_ttf/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Cpasjuste # Contributor: carstene1ns pkgname=gamecube-sdl2_ttf pkgver=2.22.0 pkgrel=2 pkgdesc="SDL2 TrueType font library." arch=('any') url="https://libsdl.org/projects/SDL_ttf/" license=("zlib") options=(!strip libtool staticlibs) makedepends=('wii-pkg-config' 'dkp-toolchain-vars') depends=( 'gamecube-sdl2' 'ppc-freetype' ) source=("${url}release/SDL2_ttf-${pkgver}.tar.gz") sha256sums=('a9eceb1ad88c1f1545cd7bd28e7cbc0b2c14191d40238f531a15b01b1b22cd33') groups=('gamecube-portlibs' 'gamecube-sdl2-libs') build() { cd SDL2_ttf-$pkgver source ${DEVKITPRO}/cubevars.sh # patch out compiling showfont and glfont sed '/^noinst_PROGRAMS/d' -i Makefile.in ./configure --prefix="${PORTLIBS_PREFIX}" \ --host=powerpc-eabi --disable-shared --enable-static \ --disable-harfbuzz-builtin \ --disable-freetype-builtin \ --disable-sdltest --without-x make } package() { cd SDL2_ttf-$pkgver source /opt/devkitpro/cubevars.sh make DESTDIR="$pkgdir" install # License #install -Dm644 "COPYING.txt" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/COPYING.txt" } sha256sums=('d48cbd1ce475b9e178206bf3b72d56b66d84d44f64ac05803328396234d67723') ================================================ FILE: gamecube/SDL_gfx/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=gamecube-sdl_gfx pkgver=2.0.27 pkgrel=1 pkgdesc="Graphics drawing primitives and other support functions wrapped up in an add-on, C-based library for the Simple Direct Media (SDL) cross-platform API layer" arch=('any') url="http://www.ferzkopp.net/wordpress/2016/01/02/sdl_gfx-sdl2_gfx/" license=("LGPL") options=(!strip libtool staticlibs) depends=( 'gamecube-sdl' ) makedepends=( 'gamecube-pkg-config' 'dkp-toolchain-vars' ) source=( "https://sourceforge.net/projects/sdlgfx/files/SDL_gfx-${pkgver}.tar.gz" ) groups=('gamecube-portlibs' 'gamecube-sdl-libs') build() { cd SDL_gfx-$pkgver source /opt/devkitpro/cubevars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static \ --disable-mmx make } package() { cd SDL_gfx-$pkgver source /opt/devkitpro/cubevars.sh make DESTDIR="$pkgdir" install } sha256sums=('dfb15ac5f8ce7a4952dc12d2aed9747518c5e6b335c0e31636d23f93c630f419') ================================================ FILE: gamecube/SDL_gfx/SDL_gfx-2.0.25.patch ================================================ --- SDL_gfx-2.0.25/SDL_rotozoom.c~ 2023-12-09 21:24:48.317633493 +0000 +++ SDL_gfx-2.0.25/SDL_rotozoom.c 2023-12-09 21:23:31.163959705 +0000 @@ -841,8 +841,8 @@ if (SDL_MUSTLOCK(dst)) { SDL_LockSurface(dst); } - if (SDL_MUSTLOCK(dst)) { - SDL_LockSurface(dst); + if (SDL_MUSTLOCK(src)) { + SDL_LockSurface(src); } /* Calculate int-per-row */ ================================================ FILE: gamecube/SDL_image/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=gamecube-sdl_image pkgver=1.2.12 pkgrel=6 pkgdesc="A simple library to load images of various formats as SDL surfaces (Nintendo Gamecube port)" arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) depends=( 'gamecube-sdl' 'ppc-libpng' 'ppc-libjpeg-turbo' ) makedepends=( 'gamecube-pkg-config' 'dkp-toolchain-vars' ) groups=('gamecube-portlibs' 'gamecube-sdl-libs') source=("${url}/projects/SDL_image/release/SDL_image-${pkgver}.tar.gz") sha256sums=( '0b90722984561004de84847744d566809dbb9daf732a9e503b91a1b5a84e5699' ) build() { cd SDL_image-$pkgver sed -i 's,showimage\$(EXEEXT),,g' Makefile.in source /opt/devkitpro/cubevars.sh CPPFLAGS="${CPPFLAGS} -Wno-incompatible-pointer-types" \ ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static make } package() { cd SDL_image-$pkgver source /opt/devkitpro/cubevars.sh make DESTDIR="$pkgdir" install # add our static libs echo "Requires.private: libpng libjpeg" >> "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/SDL_image.pc" } ================================================ FILE: gamecube/SDL_mixer/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Sergio Padrino pkgname=gamecube-sdl_mixer pkgver=1.2.12 pkgrel=2 pkgdesc="A sample multi-channel audio mixer library (Nintendo Gamecube/Wii port)" arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) depends=( 'gamecube-sdl' 'ppc-libvorbis' 'ppc-libogg' 'ppc-libmad' 'ppc-libmodplug' ) groups=('gamecube-portlibs' 'gamecube-sdl-libs') makedepends=( 'gamecube-pkg-config' 'dkp-toolchain-vars' ) source=("${url}/projects/SDL_mixer/release/SDL_mixer-${pkgver}.tar.gz" "SDL_mixer-1.2.12.patch") sha256sums=( '1644308279a975799049e4826af2cfc787cad2abb11aa14562e402521f86992a' 'fb64421673349aeefe8071e6aad0b1d69345bff9227ba5dfb9ba077c9acb7312' ) build() { cd SDL_mixer-$pkgver source /opt/devkitpro/gamecubevars.sh patch -p1 -i $srcdir/SDL_mixer-1.2.12.patch ./autogen.sh LIBS="-lvorbis -logg -lm" ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static \ --enable-music-ogg \ --disable-music-cmd \ --enable-music-mod-modplug \ --enable-music-mp3-mad-gpl make } package() { cd SDL_mixer-$pkgver source /opt/devkitpro/gamecubevars.sh make DESTDIR="$pkgdir" install # add our static libs echo "Requires.private: libmodplug mad vorbisfile vorbis ogg" >> "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/SDL_mixer.pc" } ================================================ FILE: gamecube/SDL_mixer/SDL_mixer-1.2.12.patch ================================================ diff --git a/Makefile.in b/Makefile.in index 3d10565..833ef35 100644 --- a/Makefile.in +++ b/Makefile.in @@ -47,7 +47,7 @@ LT_RELEASE = @LT_RELEASE@ LT_REVISION = @LT_REVISION@ LT_LDFLAGS = -no-undefined -rpath $(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET) $(objects)/playwave$(EXE) $(objects)/playmus$(EXE) +all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET) $(srcdir)/configure: $(srcdir)/configure.in @echo "Warning, configure.in is out of date" @@ -60,18 +60,12 @@ Makefile: $(srcdir)/Makefile.in $(objects): $(SHELL) $(auxdir)/mkinstalldirs $@ -.PHONY: all install install-hdrs install-lib install-bin uninstall uninstall-hdrs uninstall-lib uninstall-bin clean distclean dist +.PHONY: all install install-hdrs install-lib uninstall uninstall-hdrs uninstall-lib clean distclean dist $(objects)/$(TARGET): $(OBJECTS) $(VERSION_OBJECTS) $(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS) -$(objects)/playwave$(EXE): $(objects)/playwave.lo $(objects)/$(TARGET) - $(LIBTOOL) --mode=link $(CC) -o $@ $(objects)/playwave.lo $(SDL_CFLAGS) $(SDL_LIBS) $(objects)/$(TARGET) - -$(objects)/playmus$(EXE): $(objects)/playmus.lo $(objects)/$(TARGET) - $(LIBTOOL) --mode=link $(CC) -o $@ $(objects)/playmus.lo $(SDL_CFLAGS) $(SDL_LIBS) $(objects)/$(TARGET) - -install: all install-hdrs install-lib #install-bin +install: all install-hdrs install-lib install-hdrs: $(SHELL) $(auxdir)/mkinstalldirs $(includedir)/SDL for src in $(srcdir)/SDL_mixer.h; do \ @@ -83,12 +77,8 @@ install-hdrs: install-lib: $(objects) $(objects)/$(TARGET) $(SHELL) $(auxdir)/mkinstalldirs $(libdir) $(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(TARGET) $(libdir)/$(TARGET) -install-bin: - $(SHELL) $(auxdir)/mkinstalldirs $(bindir) - $(LIBTOOL) --mode=install $(INSTALL) -m 755 $(objects)/playwave$(EXE) $(bindir)/playwave$(EXE) - $(LIBTOOL) --mode=install $(INSTALL) -m 755 $(objects)/playmus$(EXE) $(bindir)/playmus$(EXE) -uninstall: uninstall-hdrs uninstall-lib uninstall-bin +uninstall: uninstall-hdrs uninstall-lib uninstall-hdrs: for src in $(srcdir)/SDL_mixer.h; do \ file=`echo $$src | sed -e 's|^.*/||'`; \ @@ -99,9 +89,6 @@ uninstall-hdrs: -rmdir $(libdir)/pkgconfig uninstall-lib: $(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(TARGET) -uninstall-bin: - rm -f $(bindir)/playwave$(EXE) - rm -f $(bindir)/playmus$(EXE) clean: rm -rf $(objects) diff --git a/load_ogg.c b/load_ogg.c index 2d0ee65..1e94fa6 100644 --- a/load_ogg.c +++ b/load_ogg.c @@ -105,7 +105,7 @@ SDL_AudioSpec *Mix_LoadOGG_RW (SDL_RWops *src, int freesrc, *audio_len = 0; memset(spec, '\0', sizeof (SDL_AudioSpec)); - spec->format = AUDIO_S16; + spec->format = AUDIO_S16SYS; spec->channels = info->channels; spec->freq = info->rate; spec->samples = 4096; /* buffer size */ @@ -124,9 +124,9 @@ SDL_AudioSpec *Mix_LoadOGG_RW (SDL_RWops *src, int freesrc, read > 0; read = vorbis.ov_read(&vf, (char *)buf, to_read, &bitstream)) #else - for (read = vorbis.ov_read(&vf, (char *)buf, to_read, 0/*LE*/, 2/*16bit*/, 1/*signed*/, &bitstream); + for (read = vorbis.ov_read(&vf, (char *)buf, to_read, SDL_BYTEORDER == SDL_BIG_ENDIAN/*BE?*/, 2/*16bit*/, 1/*signed*/, &bitstream); read > 0; - read = vorbis.ov_read(&vf, (char *)buf, to_read, 0, 2, 1, &bitstream)) + read = vorbis.ov_read(&vf, (char *)buf, to_read, SDL_BYTEORDER == SDL_BIG_ENDIAN, 2, 1, &bitstream)) #endif { if (read == OV_HOLE || read == OV_EBADLINK) diff --git a/music_modplug.h b/music_modplug.h index 92cbafd..555227b 100644 --- a/music_modplug.h +++ b/music_modplug.h @@ -1,6 +1,6 @@ #ifdef MODPLUG_MUSIC -#include "modplug.h" +#include #include "SDL_rwops.h" #include "SDL_audio.h" #include "SDL_mixer.h" diff --git a/music_ogg.c b/music_ogg.c index 18a094b..269a197 100644 --- a/music_ogg.c +++ b/music_ogg.c @@ -135,7 +135,7 @@ static void OGG_getsome(OGG_music *music) #ifdef OGG_USE_TREMOR len = vorbis.ov_read(&music->vf, data, sizeof(data), §ion); #else - len = vorbis.ov_read(&music->vf, data, sizeof(data), 0, 2, 1, §ion); + len = vorbis.ov_read(&music->vf, data, sizeof(data), SDL_BYTEORDER == SDL_BIG_ENDIAN, 2, 1, §ion); #endif if ( len <= 0 ) { if ( len == 0 ) { @@ -148,7 +148,7 @@ static void OGG_getsome(OGG_music *music) vorbis_info *vi; vi = vorbis.ov_info(&music->vf, -1); - SDL_BuildAudioCVT(cvt, AUDIO_S16, vi->channels, vi->rate, + SDL_BuildAudioCVT(cvt, AUDIO_S16SYS, vi->channels, vi->rate, mixer.format,mixer.channels,mixer.freq); if ( cvt->buf ) { SDL_free(cvt->buf); ================================================ FILE: gamecube/SDL_ttf/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=gamecube-sdl_ttf pkgver=2.0.11 pkgrel=5 pkgdesc="A sample library which allows you to use TrueType fonts in your SDL applications" arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) depends=( 'ppc-freetype' 'gamecube-sdl' ) makedepends=( 'gamecube-pkg-config' 'dkp-toolchain-vars' ) source=( "${url}/projects/SDL_ttf/release/SDL_ttf-${pkgver}.tar.gz" SDL_ttf-${pkgver}.patch ) groups=('gamecube-portlibs' 'gamecube-sdl-libs') build() { cd SDL_ttf-$pkgver source /opt/devkitpro/cubevars.sh patch -p1 -i ${srcdir}/SDL_ttf-${pkgver}.patch ./autogen.sh sed '/^noinst_PROGRAMS/d' -i Makefile.in ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static make } package() { cd SDL_ttf-$pkgver source /opt/devkitpro/cubevars.sh make DESTDIR="$pkgdir" install # add our static libs echo "Requires.private: freetype2" >> "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/SDL_ttf.pc" } sha256sums=('724cd895ecf4da319a3ef164892b72078bd92632a5d812111261cde248ebcdb7' 'd0076b03127a5e74cc03677d44a6d74a2201a1809c0a4b44e7a136c5ca6ec975') ================================================ FILE: gamecube/SDL_ttf/SDL_ttf-2.0.11.patch ================================================ diff -NBaur SDL_ttf-2.0.11.old/configure.in SDL_ttf-2.0.11.new/configure.in --- SDL_ttf-2.0.11.old/configure.in 2012-01-15 04:44:08.000000000 +0000 +++ SDL_ttf-2.0.11.new/configure.in 2026-01-27 03:21:46.888291721 +0000 @@ -91,39 +91,13 @@ AM_CONDITIONAL(USE_VERSION_RC, test x$use_version_rc = xtrue) dnl Check for the FreeType 2 library -dnl -dnl Get the cflags and libraries from the freetype-config script -dnl -AC_ARG_WITH(freetype-prefix,[ --with-freetype-prefix=PFX Prefix where FREETYPE is -installed (optional)], - freetype_prefix="$withval", freetype_prefix="") -AC_ARG_WITH(freetype-exec-prefix,[ --with-freetype-exec-prefix=PFX Exec prefix -where FREETYPE is installed (optional)], - freetype_exec_prefix="$withval", freetype_exec_prefix="") - -if test x$freetype_exec_prefix != x ; then - freetype_args="$freetype_args --exec-prefix=$freetype_exec_prefix" - if test x${FREETYPE_CONFIG+set} != xset ; then - FREETYPE_CONFIG=$freetype_exec_prefix/bin/freetype-config - fi -fi -if test x$freetype_prefix != x ; then - freetype_args="$freetype_args --prefix=$freetype_prefix" - if test x${FREETYPE_CONFIG+set} != xset ; then - FREETYPE_CONFIG=$freetype_prefix/bin/freetype-config - fi -fi -AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no) -no_freetype="" -if test "$FREETYPE_CONFIG" = "no" ; then - AC_MSG_ERROR([ -*** Unable to find FreeType2 library (http://www.freetype.org/) -]) -else - CFLAGS="$CFLAGS `$FREETYPE_CONFIG $freetypeconf_args --cflags`" - LIBS="$LIBS `$FREETYPE_CONFIG $freetypeconf_args --libs`" -fi +PKG_CHECK_MODULES([FT2], + [freetype2],,AC_MSG_ERROR([*** freetype2 not found!]) +) +CFLAGS="$CFLAGS $FT2_CFLAGS" +LIBS="$LIBS $FT2_LIBS" +AC_SUBST(FT2_LIBS) dnl Check for SDL SDL_VERSION=1.2.4 AC_SUBST(SDL_VERSION) diff -NBaur SDL_ttf-2.0.11.old/SDL_ttf.pc.in SDL_ttf-2.0.11.new/SDL_ttf.pc.in --- SDL_ttf-2.0.11.old/SDL_ttf.pc.in 2012-01-15 04:44:08.000000000 +0000 +++ SDL_ttf-2.0.11.new/SDL_ttf.pc.in 2026-01-27 03:22:14.604837684 +0000 @@ -7,6 +7,7 @@ Description: ttf library for Simple DirectMedia Layer with FreeType 2 support Version: @VERSION@ Requires: sdl >= @SDL_VERSION@ -Libs: -L${libdir} -lSDL_ttf +Libs: -L${libdir} -lSDL_ttf @FT2_LIBS@ +Libs.private: -L${libdir} -lSDL_ttf @FT2_LIBS@ Cflags: -I${includedir}/SDL ================================================ FILE: gamecube/freeglut/PKGBUILD ================================================ _realname=freeglut pkgname=gamecube-${_realname} pkgver=3.6.0 pkgrel=4 pkgdesc='gamecube freeglut' arch=('any') url='https://github.com/freeglut/freeglut/' license=('MIT') options=(!strip libtool staticlibs) makedepends=('catnip') depends=('libogc' 'gamecube-opengx' 'gamecube-glu') groups=('gamecube-portlibs') source=( "${_realname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz" "freeglut-3.6.0.patch" ) build() { cd ${_realname}-${pkgver} patch -Np1 -i $srcdir/freeglut-${pkgver}.patch catnip -t gamecube -DFREEGLUT_BUILD_DEMOS=OFF } package() { cd ${_realname}-${pkgver} DESTDIR=${pkgdir} catnip install } sha256sums=('16de4f51dc1efd663a1a58ba5552e54f8783b77478289c95dca474a4d39ddd02' 'a2f17db1bf0d52fb72b1d2abff431946d579310e41582c3532bf2bb9d993bd18') ================================================ FILE: gamecube/freeglut/freeglut-3.6.0.patch ================================================ diff --git a/src/mswin/fg_spaceball_mswin.c b/src/mswin/fg_spaceball_mswin.c index 5cb97450..fce4acdb 100644 --- a/src/mswin/fg_spaceball_mswin.c +++ b/src/mswin/fg_spaceball_mswin.c @@ -36,12 +36,12 @@ * six degree of freedom navigator. */ -#if(_WIN32_WINNT >= 0x0501) - #include #include #include "../fg_internal.h" +#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0501) + enum { SPNAV_EVENT_ANY, SPNAV_EVENT_MOTION_TRANSLATION, @@ -66,28 +66,40 @@ struct fgRAWHID { }; +typedef BOOL(*RegRawInpDevFunc)(PCRAWINPUTDEVICE, UINT, UINT); +typedef UINT(*GetRawInpDataFunc)(HRAWINPUT, UINT, LPVOID, PUINT, UINT); +typedef UINT(*GetRawInpDevInfoFunc)(HANDLE, UINT, LPVOID, PUINT); + +static RegRawInpDevFunc fgRegisterRawInputDevices; +static GetRawInpDataFunc fgGetRawInputData; +static GetRawInpDevInfoFunc fgGetRawInputDeviceInfo; + + void fgPlatformInitializeSpaceball(void) { - HWND hwnd; - fg_sball_initialized = 1; - if (!fgStructure.CurrentWindow) - { - fg_sball_initialized = 0; + HMODULE dllmod; + + if(!fgStructure.CurrentWindow) return; + + if(!(dllmod = GetModuleHandle("user32.dll"))) { return; } - hwnd = fgStructure.CurrentWindow->Window.Handle; + fgRegisterRawInputDevices = (RegRawInpDevFunc)GetProcAddress(dllmod, "RegisterRawInputDevices"); + fgGetRawInputData = (GetRawInpDataFunc)GetProcAddress(dllmod, "GetRawInputData"); + fgGetRawInputDeviceInfo = (GetRawInpDevInfoFunc)GetProcAddress(dllmod, "GetRawInputDeviceInfoA"); - { - BOOL ok; - UINT cbSize = sizeof(__fgSpaceball); - __fgSpaceball.hwndTarget = hwnd; - ok = RegisterRawInputDevices(&__fgSpaceball, 1, cbSize); + if(!fgRegisterRawInputDevices || !fgGetRawInputData || !fgGetRawInputDeviceInfo) { + return; + } - if (!ok){ - __fgSpaceball.hwndTarget = NULL; - fg_sball_initialized = 0; - } + __fgSpaceball.hwndTarget = fgStructure.CurrentWindow->Window.Handle; + + if(!fgRegisterRawInputDevices(&__fgSpaceball, 1, sizeof __fgSpaceball)) { + __fgSpaceball.hwndTarget = NULL; + return; } + + fg_sball_initialized = 1; } void fgPlatformSpaceballClose(void) @@ -115,98 +127,142 @@ int fgIsSpaceballWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam) return 0; } +#define VID_LOGITECH 0x46d +#define VID_3DCONN 0x256f + void fgSpaceballHandleWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam) { - #define LOGITECH_VENDOR_ID 0x46d + int i, x, y, z; + short *dataptr; + unsigned long keystate; HRAWINPUT hRawInput = (HRAWINPUT)lParam; UINT size; BYTE *rawInputBuffer; PRAWINPUT pRawInput; - UINT res; RID_DEVICE_INFO sRidDeviceInfo; + SFG_Window *window; - if (!fg_sball_initialized) - { + if(!fg_sball_initialized) { fgPlatformInitializeSpaceball(); - if (!fg_sball_initialized) - { - return; - } + if(!fg_sball_initialized) return; } - res = GetRawInputData(hRawInput, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)); - if (res == -1) + if(fgGetRawInputData(hRawInput, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)) == -1) { return; + } - rawInputBuffer = malloc(size * sizeof *rawInputBuffer); + if(!(rawInputBuffer = malloc(size * sizeof *rawInputBuffer))) { + return; + } pRawInput = (PRAWINPUT)rawInputBuffer; - res = GetRawInputData(hRawInput, RID_INPUT, pRawInput, &size, sizeof(RAWINPUTHEADER)); - if (res == -1) + if(fgGetRawInputData(hRawInput, RID_INPUT, pRawInput, &size, sizeof(RAWINPUTHEADER)) == -1) { + free(rawInputBuffer); return; - if (pRawInput->header.dwType != RIM_TYPEHID) + } + if(pRawInput->header.dwType != RIM_TYPEHID) { + free(rawInputBuffer); return; + } sRidDeviceInfo.cbSize = sizeof(RID_DEVICE_INFO); size = sizeof(RID_DEVICE_INFO); - res = GetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICEINFO, &sRidDeviceInfo, &size); - if (res == -1) + if(fgGetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICEINFO, &sRidDeviceInfo, &size) == -1) { + free(rawInputBuffer); return; - { - SFG_Window* window = fgWindowByHandle(hwnd); - if ((window == NULL)) - return; - - if (sRidDeviceInfo.hid.dwVendorId == LOGITECH_VENDOR_ID) - { - /* see definition of fgRAWHID at the top of this file, for an - * explanation of why we're doing this. - */ - struct fgRAWHID *hid = (struct fgRAWHID*)&pRawInput->data.hid; - - /* Motion data comes in two parts: motion type and */ - /* displacement/rotation along three axis. */ - /* Orientation is a right handed coordinate system with */ - /* X goes right, Y goes up and Z goes towards viewer, e.g. */ - /* the one used in OpenGL */ - if (hid->bRawData[0] == SPNAV_EVENT_MOTION_TRANSLATION) - { /* Translation vector */ - short* pnData = (short*)(&hid->bRawData[1]); - short X = pnData[0]; - short Y = -pnData[2]; - short Z = pnData[1]; - INVOKE_WCB(*window, SpaceMotion, (X, Y, Z)); - } - else if (hid->bRawData[0] == SPNAV_EVENT_MOTION_ROTATION) - { /* Axis aligned rotation vector */ - short* pnData = (short*)(&hid->bRawData[1]); - short rX = pnData[0]; - short rY = -pnData[2]; - short rZ = pnData[1]; - INVOKE_WCB(*window, SpaceRotation, (rX, rY, rZ)); - } - else if (hid->bRawData[0] == SPNAV_EVENT_BUTTON) - { /* State of the keys */ - unsigned long dwKeystate = *(unsigned long*)(&hid->bRawData[1]); - if (FETCH_WCB(*window, SpaceButton)) - { - int i; - for (i = 0; i < 32; i++) - { - unsigned long stateBefore = __fgSpaceKeystate&(1 << i); - unsigned long stateNow = dwKeystate&(1 << i); - - if (stateBefore && !stateNow) - INVOKE_WCB(*window, SpaceButton, (stateBefore, GLUT_UP)); - if (!stateBefore && stateNow) - INVOKE_WCB(*window, SpaceButton, (stateNow, GLUT_DOWN)); + } + if(!(window = fgWindowByHandle(hwnd))) { + return; + } + + if(sRidDeviceInfo.hid.dwVendorId == VID_LOGITECH || sRidDeviceInfo.hid.dwVendorId == VID_3DCONN) { + /* see definition of fgRAWHID at the top of this file, for an + * explanation of why we're doing this. + */ + struct fgRAWHID *hid = (struct fgRAWHID*)&pRawInput->data.hid; + + /* Motion data comes in two parts: motion type and */ + /* displacement/rotation along three axis. */ + /* Orientation is a right handed coordinate system with */ + /* X goes right, Y goes up and Z goes towards viewer, e.g. */ + /* the one used in OpenGL */ + switch(hid->bRawData[0]) { + case SPNAV_EVENT_MOTION_TRANSLATION: + /* Translation vector */ + dataptr = (short*)(&hid->bRawData[1]); + x = dataptr[0]; + y = -dataptr[2]; + z = dataptr[1]; + INVOKE_WCB(*window, SpaceMotion, (x, y, z)); + break; + + case SPNAV_EVENT_MOTION_ROTATION: + /* Axis aligned rotation vector */ + dataptr = (short*)(&hid->bRawData[1]); + x = dataptr[0]; + y = -dataptr[2]; + z = dataptr[1]; + INVOKE_WCB(*window, SpaceRotation, (x, y, z)); + + case SPNAV_EVENT_BUTTON: + /* State of the keys */ + keystate = *(unsigned long*)(&hid->bRawData[1]); + if(FETCH_WCB(*window, SpaceButton)) { + for(i=0; i<32; i++) { + unsigned long stateBefore = __fgSpaceKeystate & (1 << i); + unsigned long stateNow = keystate & (1 << i); + + if(stateBefore && !stateNow) { + INVOKE_WCB(*window, SpaceButton, (stateBefore, GLUT_UP)); + } + if(!stateBefore && stateNow) { + INVOKE_WCB(*window, SpaceButton, (stateNow, GLUT_DOWN)); } } - __fgSpaceKeystate = dwKeystate; } + __fgSpaceKeystate = keystate; + break; } } } +#else +/* windows versions older than winxp don't have the raw HID support used by this + * spaceball implementation. For now just leave the functions blank to make it + * build without spaceball support on older versions of windows, until we can + * investigate a fallback route. + */ + +void fgPlatformInitializeSpaceball(void) +{ +} + +void fgPlatformSpaceballClose(void) +{ +} + +int fgPlatformHasSpaceball(void) +{ + return 0; +} + +int fgPlatformSpaceballNumButtons(void) +{ + return 0; +} + +void fgPlatformSpaceballSetWindow(SFG_Window *window) +{ +} + +int fgIsSpaceballWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + return 0; +} + +void fgSpaceballHandleWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam) +{ +} + #endif diff --git a/src/ogc/fg_display_ogc.c b/src/ogc/fg_display_ogc.c index e7a5a793..233818e0 100644 --- a/src/ogc/fg_display_ogc.c +++ b/src/ogc/fg_display_ogc.c @@ -47,6 +47,10 @@ void fgOgcDisplaySetupXfb() fgDisplay.pDisplay.xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode)); } + + if (fgState.DisplayMode & GLUT_STENCIL) { + ogx_stencil_create(OGX_STENCIL_DIRTY_Z); + } } void fgOgcDisplaySetupVideoMode() diff --git a/src/ogc/fg_main_ogc.c b/src/ogc/fg_main_ogc.c index 499ec8dc..502bcc4a 100644 --- a/src/ogc/fg_main_ogc.c +++ b/src/ogc/fg_main_ogc.c @@ -206,14 +206,21 @@ fg_time_t fgPlatformSystemTime(void) void fgPlatformSleepForEvents(fg_time_t ms) { - fgWarning("%s() : sleeping for %lld ms", __func__, ms); - /* FreeGlut does not offer a hook for redrawing the window in single-buffer * mode, so let's to it here. */ if (!(fgState.DisplayMode & GLUT_DOUBLE)) { fgOgcDisplayShowEFB(); } + /* If the mouse is active, reduce the sleep time to a few milliseconds + * only, since our mouse is emulated via the Wiimote, which must be + * regularly polled */ + if (ms > 10 && fgStructure.CurrentWindow && + (FETCH_WCB(*fgStructure.CurrentWindow, Motion) || + FETCH_WCB(*fgStructure.CurrentWindow, Mouse))) { + ms = 10; + } + struct timespec tv; tv.tv_sec = ms / 1000; tv.tv_nsec = (ms % 1000) * 1000000; @@ -261,7 +268,7 @@ void fgPlatformPosResZordWork(SFG_Window *window, unsigned int workMask) void fgPlatformVisibilityWork(SFG_Window *window) { - fgWarning("%s() : not implemented", __func__); + INVOKE_WCB(*window, WindowStatus, (GLUT_FULLY_RETAINED)); } void fgPlatformSetColor(int idx, float r, float g, float b) diff --git a/src/ogc/fg_state_ogc.c b/src/ogc/fg_state_ogc.c index 876644c9..91235498 100644 --- a/src/ogc/fg_state_ogc.c +++ b/src/ogc/fg_state_ogc.c @@ -29,6 +29,8 @@ int fgPlatformGlutDeviceGet(GLenum eWhat) int fgPlatformGlutGet(GLenum eWhat) { + GLint ret = -1; + switch (eWhat) { case GLUT_WINDOW_WIDTH: return fgStructure.CurrentWindow ? @@ -36,10 +38,13 @@ int fgPlatformGlutGet(GLenum eWhat) case GLUT_WINDOW_HEIGHT: return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.Height : 0; + case GLUT_WINDOW_STENCIL_SIZE: + glGetIntegerv(GL_STENCIL_BITS, &ret); + break; default: fgWarning("%s() : not implemented for %d", __func__, eWhat); } - return -1; + return ret; } int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size) diff --git a/src/ogc/fg_window_ogc.c b/src/ogc/fg_window_ogc.c index 34dca9d8..4051a2fe 100644 --- a/src/ogc/fg_window_ogc.c +++ b/src/ogc/fg_window_ogc.c @@ -37,7 +37,7 @@ void fgPlatformOpenWindow(SFG_Window *window, const char *title, window->State.Xpos = 0; window->State.Ypos = 0; - window->State.WorkMask |= GLUT_INIT_WORK; + window->State.WorkMask |= GLUT_INIT_WORK | GLUT_VISIBILITY_WORK; window->State.Visible = GL_TRUE; /* This sets up the XFB for the chosen buffering scheme */ diff --git a/src/x11/fg_spaceball_x11.c b/src/x11/fg_spaceball_x11.c index 155d24b1..eb825bb7 100644 --- a/src/x11/fg_spaceball_x11.c +++ b/src/x11/fg_spaceball_x11.c @@ -17,29 +17,29 @@ extern int fg_sball_initialized; enum { - SPNAV_EVENT_ANY, /* used by spnav_remove_events() */ - SPNAV_EVENT_MOTION, - SPNAV_EVENT_BUTTON /* includes both press and release */ + SPNAV_EVENT_ANY, /* used by spnav_remove_events() */ + SPNAV_EVENT_MOTION, + SPNAV_EVENT_BUTTON /* includes both press and release */ }; struct spnav_event_motion { - int type; - int x, y, z; - int rx, ry, rz; - unsigned int period; - int *data; + int type; + int x, y, z; + int rx, ry, rz; + unsigned int period; + int *data; }; struct spnav_event_button { - int type; - int press; - int bnum; + int type; + int press; + int bnum; }; typedef union spnav_event { - int type; - struct spnav_event_motion motion; - struct spnav_event_button button; + int type; + struct spnav_event_motion motion; + struct spnav_event_button button; } spnav_event; @@ -54,96 +54,97 @@ static SFG_Window *spnav_win; void fgPlatformInitializeSpaceball(void) { - Window w; - - fg_sball_initialized = 1; - if(!fgStructure.CurrentWindow) - { - fg_sball_initialized = -1; - return; - } - - w = fgStructure.CurrentWindow->Window.Handle; - if(spnav_x11_open(fgDisplay.pDisplay.Display, w) == -1) - { - fg_sball_initialized = -1; - return; - } + Window w; + + fg_sball_initialized = 1; + if(!fgStructure.CurrentWindow) + { + fg_sball_initialized = -1; + return; + } + + w = fgStructure.CurrentWindow->Window.Handle; + if(spnav_x11_open(fgDisplay.pDisplay.Display, w) == -1) + { + fg_sball_initialized = -1; + return; + } } -void fgPlatformSpaceballClose(void) +void fgPlatformSpaceballClose(void) { - spnav_close(); + spnav_close(); } -int fgPlatformHasSpaceball(void) +int fgPlatformHasSpaceball(void) { - /* XXX this function should somehow query the driver if there's a device - * plugged in, as opposed to just checking if there's a driver to talk to. - */ - return spnav_fd() == -1 ? 0 : 1; + /* XXX this function should somehow query the driver if there's a device + * plugged in, as opposed to just checking if there's a driver to talk to. + */ + return spnav_fd() == -1 ? 0 : 1; } -int fgPlatformSpaceballNumButtons(void) { - return 2; +int fgPlatformSpaceballNumButtons(void) +{ + return 2; } -void fgPlatformSpaceballSetWindow(SFG_Window *window) +void fgPlatformSpaceballSetWindow(SFG_Window *window) { - if(spnav_win != window) { - spnav_x11_window(window->Window.Handle); - spnav_win = window; - } + if(spnav_win != window) { + spnav_x11_window(window->Window.Handle); + spnav_win = window; + } } int fgIsSpaceballXEvent(const XEvent *xev) { - spnav_event sev; + spnav_event sev; - if(spnav_win != fgStructure.CurrentWindow) { - /* this will also initialize spaceball if needed (first call) */ - fgSpaceballSetWindow(fgStructure.CurrentWindow); - } + if(spnav_win != fgStructure.CurrentWindow) { + /* this will also initialize spaceball if needed (first call) */ + fgSpaceballSetWindow(fgStructure.CurrentWindow); + } - if(fg_sball_initialized != 1) { - return 0; - } + if(fg_sball_initialized != 1) { + return 0; + } - return spnav_x11_event(xev, &sev); + return spnav_x11_event(xev, &sev); } void fgSpaceballHandleXEvent(const XEvent *xev) { - spnav_event sev; - - if(fg_sball_initialized == 0) { - fgInitialiseSpaceball(); - if(fg_sball_initialized != 1) { - return; - } - } - - if(spnav_x11_event(xev, &sev)) { - switch(sev.type) { - case SPNAV_EVENT_MOTION: - if(sev.motion.x | sev.motion.y | sev.motion.z) { - INVOKE_WCB(*spnav_win, SpaceMotion, (sev.motion.x, sev.motion.y, sev.motion.z)); - } - if(sev.motion.rx | sev.motion.ry | sev.motion.rz) { - INVOKE_WCB(*spnav_win, SpaceRotation, (sev.motion.rx, sev.motion.ry, sev.motion.rz)); - } - spnav_remove_events(SPNAV_EVENT_MOTION); - break; - - case SPNAV_EVENT_BUTTON: - /* button numbers are 1-based in glutSpaceballButtonFunc */ - INVOKE_WCB(*spnav_win, SpaceButton, (sev.button.bnum + 1, sev.button.press ? GLUT_DOWN : GLUT_UP)); - break; - - default: - break; - } - } + spnav_event sev; + + if(fg_sball_initialized == 0) { + fgInitialiseSpaceball(); + if(fg_sball_initialized != 1) { + return; + } + } + + if(spnav_x11_event(xev, &sev)) { + switch(sev.type) { + case SPNAV_EVENT_MOTION: + if(sev.motion.x | sev.motion.y | sev.motion.z) { + INVOKE_WCB(*spnav_win, SpaceMotion, (sev.motion.x, sev.motion.y, sev.motion.z)); + } + if(sev.motion.rx | sev.motion.ry | sev.motion.rz) { + INVOKE_WCB(*spnav_win, SpaceRotation, (sev.motion.rx, sev.motion.ry, sev.motion.rz)); + } + spnav_remove_events(SPNAV_EVENT_MOTION); + break; + + case SPNAV_EVENT_BUTTON: + /* button numbers are 1-based in glutSpaceballButtonFunc */ + INVOKE_WCB(*spnav_win, SpaceButton, (sev.button.bnum + 1, sev.button.press ? GLUT_DOWN : GLUT_UP)); + break; + + default: + break; + } + } } /* @@ -188,226 +189,226 @@ static Window app_win; static Atom motion_event, button_press_event, button_release_event, command_event; enum { - CMD_APP_WINDOW = 27695, - CMD_APP_SENS + CMD_APP_WINDOW = 27695, + CMD_APP_SENS }; -#define IS_OPEN dpy +#define IS_OPEN dpy struct event_node { - spnav_event event; - struct event_node *next; + spnav_event event; + struct event_node *next; }; static int spnav_x11_open(Display *display, Window win) { - if(IS_OPEN) { - return -1; - } + if(IS_OPEN) { + return -1; + } - dpy = display; + dpy = display; - motion_event = XInternAtom(dpy, "MotionEvent", True); - button_press_event = XInternAtom(dpy, "ButtonPressEvent", True); - button_release_event = XInternAtom(dpy, "ButtonReleaseEvent", True); - command_event = XInternAtom(dpy, "CommandEvent", True); + motion_event = XInternAtom(dpy, "MotionEvent", True); + button_press_event = XInternAtom(dpy, "ButtonPressEvent", True); + button_release_event = XInternAtom(dpy, "ButtonReleaseEvent", True); + command_event = XInternAtom(dpy, "CommandEvent", True); - if(!motion_event || !button_press_event || !button_release_event || !command_event) { - dpy = 0; - return -1; /* daemon not started */ - } + if(!motion_event || !button_press_event || !button_release_event || !command_event) { + dpy = 0; + return -1; /* daemon not started */ + } - if(spnav_x11_window(win) == -1) { - dpy = 0; - return -1; /* daemon not started */ - } + if(spnav_x11_window(win) == -1) { + dpy = 0; + return -1; /* daemon not started */ + } - app_win = win; - return 0; + app_win = win; + return 0; } static int spnav_close(void) { - if(dpy) { - spnav_x11_window(DefaultRootWindow(dpy)); - app_win = 0; - dpy = 0; - return 0; - } - return -1; + if(dpy) { + spnav_x11_window(DefaultRootWindow(dpy)); + app_win = 0; + dpy = 0; + return 0; + } + return -1; } static int spnav_x11_window(Window win) { - int (*prev_xerr_handler)(Display*, XErrorEvent*); - XEvent xev; - Window daemon_win; - - if(!IS_OPEN) { - return -1; - } - - if(!(daemon_win = get_daemon_window(dpy))) { - return -1; - } - - prev_xerr_handler = XSetErrorHandler(catch_badwin); - - xev.type = ClientMessage; - xev.xclient.send_event = False; - xev.xclient.display = dpy; - xev.xclient.window = win; - xev.xclient.message_type = command_event; - xev.xclient.format = 16; - xev.xclient.data.s[0] = ((unsigned int)win & 0xffff0000) >> 16; - xev.xclient.data.s[1] = (unsigned int)win & 0xffff; - xev.xclient.data.s[2] = CMD_APP_WINDOW; - - XSendEvent(dpy, daemon_win, False, 0, &xev); - XSync(dpy, False); - - XSetErrorHandler(prev_xerr_handler); - return 0; + int (*prev_xerr_handler)(Display*, XErrorEvent*); + XEvent xev; + Window daemon_win; + + if(!IS_OPEN) { + return -1; + } + + if(!(daemon_win = get_daemon_window(dpy))) { + return -1; + } + + prev_xerr_handler = XSetErrorHandler(catch_badwin); + + xev.type = ClientMessage; + xev.xclient.send_event = False; + xev.xclient.display = dpy; + xev.xclient.window = win; + xev.xclient.message_type = command_event; + xev.xclient.format = 16; + xev.xclient.data.s[0] = ((unsigned int)win & 0xffff0000) >> 16; + xev.xclient.data.s[1] = (unsigned int)win & 0xffff; + xev.xclient.data.s[2] = CMD_APP_WINDOW; + + XSendEvent(dpy, daemon_win, False, 0, &xev); + XSync(dpy, False); + + XSetErrorHandler(prev_xerr_handler); + return 0; } static int spnav_fd(void) { - if(dpy) { - return ConnectionNumber(dpy); - } - return -1; + if(dpy) { + return ConnectionNumber(dpy); + } + return -1; } /*static int spnav_wait_event(spnav_event *event) { - if(dpy) { - for(;;) { - XEvent xev; - XNextEvent(dpy, &xev); - - if(spnav_x11_event(&xev, event) > 0) { - return event->type; - } - } - } - return 0; + if(dpy) { + for(;;) { + XEvent xev; + XNextEvent(dpy, &xev); + + if(spnav_x11_event(&xev, event) > 0) { + return event->type; + } + } + } + return 0; } static int spnav_poll_event(spnav_event *event) { - if(dpy) { - if(XPending(dpy)) { - XEvent xev; - XNextEvent(dpy, &xev); - - return spnav_x11_event(&xev, event); - } - } - return 0; + if(dpy) { + if(XPending(dpy)) { + XEvent xev; + XNextEvent(dpy, &xev); + + return spnav_x11_event(&xev, event); + } + } + return 0; }*/ static Bool match_events(Display *dpy, XEvent *xev, char *arg) { - int evtype = *(int*)arg; - - if(xev->type != ClientMessage) { - return False; - } - - if(xev->xclient.message_type == motion_event) { - return !evtype || evtype == SPNAV_EVENT_MOTION ? True : False; - } - if(xev->xclient.message_type == button_press_event || - xev->xclient.message_type == button_release_event) { - return !evtype || evtype == SPNAV_EVENT_BUTTON ? True : False; - } - return False; + int evtype = *(int*)arg; + + if(xev->type != ClientMessage) { + return False; + } + + if(xev->xclient.message_type == motion_event) { + return !evtype || evtype == SPNAV_EVENT_MOTION ? True : False; + } + if(xev->xclient.message_type == button_press_event || + xev->xclient.message_type == button_release_event) { + return !evtype || evtype == SPNAV_EVENT_BUTTON ? True : False; + } + return False; } static int spnav_remove_events(int type) { - int rm_count = 0; + int rm_count = 0; - if(dpy) { - XEvent xev; + if(dpy) { + XEvent xev; - while(XCheckIfEvent(dpy, &xev, match_events, (char*)&type)) { - rm_count++; - } - return rm_count; - } - return 0; + while(XCheckIfEvent(dpy, &xev, match_events, (char*)&type)) { + rm_count++; + } + return rm_count; + } + return 0; } static int spnav_x11_event(const XEvent *xev, spnav_event *event) { - int i; - int xmsg_type; - - if(xev->type != ClientMessage) { - return 0; - } - - xmsg_type = xev->xclient.message_type; - - if(xmsg_type != motion_event && xmsg_type != button_press_event && - xmsg_type != button_release_event) { - return 0; - } - - if(xmsg_type == motion_event) { - event->type = SPNAV_EVENT_MOTION; - event->motion.data = &event->motion.x; - - for(i=0; i<6; i++) { - event->motion.data[i] = xev->xclient.data.s[i + 2]; - } - event->motion.period = xev->xclient.data.s[8]; - } else { - event->type = SPNAV_EVENT_BUTTON; - event->button.press = xmsg_type == button_press_event ? 1 : 0; - event->button.bnum = xev->xclient.data.s[2]; - } - return event->type; + int i; + int xmsg_type; + + if(xev->type != ClientMessage) { + return 0; + } + + xmsg_type = xev->xclient.message_type; + + if(xmsg_type != motion_event && xmsg_type != button_press_event && + xmsg_type != button_release_event) { + return 0; + } + + if(xmsg_type == motion_event) { + event->type = SPNAV_EVENT_MOTION; + event->motion.data = &event->motion.x; + + for(i=0; i<6; i++) { + event->motion.data[i] = xev->xclient.data.s[i + 2]; + } + event->motion.period = xev->xclient.data.s[8]; + } else { + event->type = SPNAV_EVENT_BUTTON; + event->button.press = xmsg_type == button_press_event ? 1 : 0; + event->button.bnum = xev->xclient.data.s[2]; + } + return event->type; } static Window get_daemon_window(Display *dpy) { - Window win, root_win; - XTextProperty wname; - Atom type; - int fmt; - unsigned long nitems, bytes_after; - unsigned char *prop; + Window win, root_win; + XTextProperty wname; + Atom type; + int fmt; + unsigned long nitems, bytes_after; + unsigned char *prop; - root_win = DefaultRootWindow(dpy); + root_win = DefaultRootWindow(dpy); - XGetWindowProperty(dpy, root_win, command_event, 0, 1, False, AnyPropertyType, &type, &fmt, &nitems, &bytes_after, &prop); - if(!prop) { - return 0; - } + XGetWindowProperty(dpy, root_win, command_event, 0, 1, False, AnyPropertyType, &type, &fmt, &nitems, &bytes_after, &prop); + if(!prop) { + return 0; + } - win = *(Window*)prop; - XFree(prop); + win = *(Window*)prop; + XFree(prop); - if(!XGetWMName(dpy, win, &wname) || strcmp("Magellan Window", (char*)wname.value) != 0) { - return 0; - } + if(!XGetWMName(dpy, win, &wname) || strcmp("Magellan Window", (char*)wname.value) != 0) { + return 0; + } - return win; + return win; } static int catch_badwin(Display *dpy, XErrorEvent *err) { - char buf[256]; - - if(err->error_code == BadWindow) { - /* do nothing? */ - } else { - XGetErrorText(dpy, err->error_code, buf, sizeof buf); - fprintf(stderr, "Caught unexpected X error: %s\n", buf); - } - return 0; + char buf[256]; + + if(err->error_code == BadWindow) { + /* do nothing? */ + } else { + XGetErrorText(dpy, err->error_code, buf, sizeof buf); + fprintf(stderr, "Caught unexpected X error: %s\n", buf); + } + return 0; } ================================================ FILE: gamecube/glu/LICENSE ================================================ SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice including the dates of first publication and either this permission notice or a reference to http://oss.sgi.com/projects/FreeB/ shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of Silicon Graphics, Inc. shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Silicon Graphics, Inc. ================================================ FILE: gamecube/glu/PKGBUILD ================================================ pkgbasename=glu pkgname=gamecube-$pkgbasename pkgver=9.0.3 pkgrel=1 pkgdesc='SGI implementation of the OpenGL Utility library' arch=('any') url='https://mesa.freedesktop.org/archive/glu/' license=('custom') options=(!strip libtool staticlibs) source=( "${url}/${pkgbasename}-${pkgver}.tar.xz" "LICENSE" ) depends=('gamecube-opengx') makedepends=("gamecube-pkg-config" "dkp-toolchain-vars" "dkp-meson-scripts") groups=('gamecube-portlibs') build() { cd ${pkgbasename}-${pkgver} source /opt/devkitpro/cubevars.sh /opt/devkitpro/meson-cross.sh gamecube ../crossfile.txt \ build } package() { cd ${pkgbasename}-${pkgver} DESTDIR="$pkgdir" meson install -C build install -dm755 "$pkgdir"/opt/devkitpro/portlibs/gamecube/licenses/$pkgname install -m644 "${srcdir}"/LICENSE "$pkgdir"/opt/devkitpro/portlibs/gamecube/licenses/$pkgname/ } sha256sums=('bd43fe12f374b1192eb15fe20e45ff456b9bc26ab57f0eee919f96ca0f8a330f' '0d27597d42ef0c1ad0e52887de19d3c985608daa60581e9c075c1a978aa5bf40') ================================================ FILE: gamecube/opengx/PKGBUILD ================================================ pkgname=gamecube-opengx pkgver=0.17.0 pkgrel=2 pkgdesc='opengl/gx translation library' arch=('any') url='https://github.com/devkitPro/opengx' license=('BSD') options=(!strip libtool staticlibs) makedepends=('catnip') depends=('libogc') groups=('gamecube-portlibs') source=( "opengx-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz" ) build() { cd opengx-${pkgver} catnip -t gamecube } package() { cd opengx-${pkgver} DESTDIR=${pkgdir} catnip install } sha256sums=('ff23d8b8752e8bbfd0396d0a7ba6868fa114fd98c7829a12ee95a12be1a94bbf') sha256sums=('cbf4cdc4df792e8ac1a0aa95b40008d14892faf23e9de882aad86676c3ea8474') ================================================ FILE: gamecube/physfs/PKGBUILD ================================================ _realname=physfs pkgname=gamecube-${_realname} pkgver=3.2.0 pkgrel=3 pkgdesc='A library to provide abstract access to various archives.' arch=('any') url='https://icculus.org/physfs/' license=('zlib') options=(!strip libtool staticlibs) source=( "${_realname}-${pkgver}.tar.gz::https://github.com/icculus/physfs/archive/refs/tags/release-${pkgver}.tar.gz" "physfs-${pkgver}.patch") makedepends=('devkitPPC' 'dkp-toolchain-vars' 'gamecube-cmake') groups=('gamecube-portlibs') build() { cd physfs-release-$pkgver patch -Np1 -i "$srcdir"/physfs-${pkgver}.patch source ${DEVKITPRO}/cubevars.sh powerpc-eabi-cmake -GNinja \ -DCMAKE_INSTALL_PREFIX=/opt/devkitpro/portlibs/gamecube \ -DPHYSFS_BUILD_STATIC=ON -DPHYSFS_BUILD_SHARED=OFF \ -DPHYSFS_BUILD_TEST=OFF \ -B _build -S . cmake --build _build } package() { cd physfs-release-$pkgver DESTDIR="$pkgdir" cmake --install _build } sha256sums=('1991500eaeb8d5325e3a8361847ff3bf8e03ec89252b7915e1f25b3f8ab5d560' '4f63dd63d38e8784ded3666403acffa3a128d888f656c0808df19e34794287ba') ================================================ FILE: gamecube/physfs/physfs-3.2.0.patch ================================================ diff --git a/CMakeLists.txt b/CMakeLists.txt index b3291cc..f017cca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,7 @@ set(PHYSFS_SRCS src/physfs_platform_posix.c src/physfs_platform_unix.c src/physfs_platform_windows.c + src/physfs_platform_ogc.c src/physfs_platform_os2.c src/physfs_platform_qnx.c src/physfs_platform_android.c diff --git a/src/physfs_internal.h b/src/physfs_internal.h index 2200d4d..5fb938c 100644 --- a/src/physfs_internal.h +++ b/src/physfs_internal.h @@ -38,7 +38,7 @@ #include #endif -#if defined(PHYSFS_PLATFORM_SOLARIS) || defined(PHYSFS_PLATFORM_LINUX) +#if defined(PHYSFS_PLATFORM_SOLARIS) || defined(PHYSFS_PLATFORM_LINUX) || defined(PHYSFS_PLATFORM_OGC) #include #endif diff --git a/src/physfs_platform_ogc.c b/src/physfs_platform_ogc.c new file mode 100644 index 0000000..53694cb --- /dev/null +++ b/src/physfs_platform_ogc.c @@ -0,0 +1,440 @@ +/* + * Wii/GameCube support routines for PhysicsFS. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#define __PHYSICSFS_INTERNAL__ +#include "physfs_platforms.h" + +#ifdef PHYSFS_PLATFORM_OGC + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include + +#include "physfs_internal.h" + + +static PHYSFS_ErrorCode errcodeFromErrnoError(const int err) +{ + switch (err) + { + case 0: return PHYSFS_ERR_OK; + case EACCES: return PHYSFS_ERR_PERMISSION; + case EPERM: return PHYSFS_ERR_PERMISSION; + case EDQUOT: return PHYSFS_ERR_NO_SPACE; + case EIO: return PHYSFS_ERR_IO; + case ELOOP: return PHYSFS_ERR_SYMLINK_LOOP; + case EMLINK: return PHYSFS_ERR_NO_SPACE; + case ENAMETOOLONG: return PHYSFS_ERR_BAD_FILENAME; + case ENOENT: return PHYSFS_ERR_NOT_FOUND; + case ENOSPC: return PHYSFS_ERR_NO_SPACE; + case ENOTDIR: return PHYSFS_ERR_NOT_FOUND; + case EISDIR: return PHYSFS_ERR_NOT_A_FILE; + case EROFS: return PHYSFS_ERR_READ_ONLY; + case ETXTBSY: return PHYSFS_ERR_BUSY; + case EBUSY: return PHYSFS_ERR_BUSY; + case ENOMEM: return PHYSFS_ERR_OUT_OF_MEMORY; + case ENOTEMPTY: return PHYSFS_ERR_DIR_NOT_EMPTY; + default: return PHYSFS_ERR_OS_ERROR; + } /* switch */ +} /* errcodeFromErrnoError */ + + +static inline PHYSFS_ErrorCode errcodeFromErrno(void) +{ + return errcodeFromErrnoError(errno); +} /* errcodeFromErrno */ + + +static inline char *buildSubdirPath(const char *subdir, size_t subdir_length) +{ + const char *baseDir; + char *retval; + size_t length; + + baseDir = PHYSFS_getBaseDir(); + length = strlen(baseDir); + + retval = allocator.Malloc(length + subdir_length); + BAIL_IF(!retval, PHYSFS_ERR_OUT_OF_MEMORY, NULL); + strcpy(retval, baseDir); + strcpy(retval + length, subdir); + + return retval; +} + +char *__PHYSFS_platformCalcUserDir(void) +{ + static const char subdir[] = "userdata/"; + + /* We don't have users on the Wii/GameCube. Just create a userdata folder + * in the application's directory. */ + return buildSubdirPath(subdir, sizeof(subdir)); +} /* __PHYSFS_platformCalcUserDir */ + + +PHYSFS_EnumerateCallbackResult __PHYSFS_platformEnumerate(const char *dirname, + PHYSFS_EnumerateCallback callback, + const char *origdir, void *callbackdata) +{ + DIR *dir; + struct dirent *ent; + PHYSFS_EnumerateCallbackResult retval = PHYSFS_ENUM_OK; + + dir = opendir(dirname); + BAIL_IF(dir == NULL, errcodeFromErrno(), PHYSFS_ENUM_ERROR); + + while ((retval == PHYSFS_ENUM_OK) && ((ent = readdir(dir)) != NULL)) + { + const char *name = ent->d_name; + if (name[0] == '.') /* ignore "." and ".." */ + { + if ((name[1] == '\0') || ((name[1] == '.') && (name[2] == '\0'))) + continue; + } /* if */ + + retval = callback(callbackdata, origdir, name); + if (retval == PHYSFS_ENUM_ERROR) + PHYSFS_setErrorCode(PHYSFS_ERR_APP_CALLBACK); + } /* while */ + + closedir(dir); + + return retval; +} /* __PHYSFS_platformEnumerate */ + + +int __PHYSFS_platformMkDir(const char *path) +{ + const int rc = mkdir(path, S_IRWXU); + BAIL_IF(rc == -1, errcodeFromErrno(), 0); + return 1; +} /* __PHYSFS_platformMkDir */ + + +#if !defined(O_CLOEXEC) && defined(FD_CLOEXEC) +static inline void set_CLOEXEC(int fildes) +{ + int flags = fcntl(fildes, F_GETFD); + if (flags != -1) { + fcntl(fildes, F_SETFD, flags | FD_CLOEXEC); + } +} +#endif + +static void *doOpen(const char *filename, int mode) +{ + const int appending = (mode & O_APPEND); + int fd; + int *retval; + + errno = 0; + + /* O_APPEND doesn't actually behave as we'd like. */ + mode &= ~O_APPEND; + +#ifdef O_CLOEXEC + /* Add O_CLOEXEC if defined */ + mode |= O_CLOEXEC; +#endif + + do { + fd = open(filename, mode, S_IRUSR | S_IWUSR); + } while ((fd < 0) && (errno == EINTR)); + BAIL_IF(fd < 0, errcodeFromErrno(), NULL); + +#if !defined(O_CLOEXEC) && defined(FD_CLOEXEC) + set_CLOEXEC(fd); +#endif + + if (appending) + { + if (lseek(fd, 0, SEEK_END) < 0) + { + const int err = errno; + close(fd); + BAIL(errcodeFromErrnoError(err), NULL); + } /* if */ + } /* if */ + + retval = (int *) allocator.Malloc(sizeof (int)); + if (!retval) + { + close(fd); + BAIL(PHYSFS_ERR_OUT_OF_MEMORY, NULL); + } /* if */ + + *retval = fd; + return ((void *) retval); +} /* doOpen */ + + +void *__PHYSFS_platformOpenRead(const char *filename) +{ + return doOpen(filename, O_RDONLY); +} /* __PHYSFS_platformOpenRead */ + + +void *__PHYSFS_platformOpenWrite(const char *filename) +{ + return doOpen(filename, O_WRONLY | O_CREAT | O_TRUNC); +} /* __PHYSFS_platformOpenWrite */ + + +void *__PHYSFS_platformOpenAppend(const char *filename) +{ + return doOpen(filename, O_WRONLY | O_CREAT | O_APPEND); +} /* __PHYSFS_platformOpenAppend */ + + +PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer, + PHYSFS_uint64 len) +{ + const int fd = *((int *) opaque); + ssize_t rc = 0; + + if (!__PHYSFS_ui64FitsAddressSpace(len)) + BAIL(PHYSFS_ERR_INVALID_ARGUMENT, -1); + + do { + rc = read(fd, buffer, (size_t) len); + } while ((rc == -1) && (errno == EINTR)); + BAIL_IF(rc == -1, errcodeFromErrno(), -1); + assert(rc >= 0); + assert(rc <= len); + return (PHYSFS_sint64) rc; +} /* __PHYSFS_platformRead */ + + +PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer, + PHYSFS_uint64 len) +{ + const int fd = *((int *) opaque); + ssize_t rc = 0; + + if (!__PHYSFS_ui64FitsAddressSpace(len)) + BAIL(PHYSFS_ERR_INVALID_ARGUMENT, -1); + + do { + rc = write(fd, (void *) buffer, (size_t) len); + } while ((rc == -1) && (errno == EINTR)); + BAIL_IF(rc == -1, errcodeFromErrno(), rc); + assert(rc >= 0); + assert(rc <= len); + return (PHYSFS_sint64) rc; +} /* __PHYSFS_platformWrite */ + + +int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos) +{ + const int fd = *((int *) opaque); + const off_t rc = lseek(fd, (off_t) pos, SEEK_SET); + BAIL_IF(rc == -1, errcodeFromErrno(), 0); + return 1; +} /* __PHYSFS_platformSeek */ + + +PHYSFS_sint64 __PHYSFS_platformTell(void *opaque) +{ + const int fd = *((int *) opaque); + PHYSFS_sint64 retval; + retval = (PHYSFS_sint64) lseek(fd, 0, SEEK_CUR); + BAIL_IF(retval == -1, errcodeFromErrno(), -1); + return retval; +} /* __PHYSFS_platformTell */ + + +PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque) +{ + const int fd = *((int *) opaque); + struct stat statbuf; + BAIL_IF(fstat(fd, &statbuf) == -1, errcodeFromErrno(), -1); + return ((PHYSFS_sint64) statbuf.st_size); +} /* __PHYSFS_platformFileLength */ + + +int __PHYSFS_platformFlush(void *opaque) +{ + const int fd = *((int *) opaque); + int rc = -1; + if ((fcntl(fd, F_GETFL) & O_ACCMODE) != O_RDONLY) { + do { + rc = fsync(fd); + } while ((rc == -1) && (errno == EINTR)); + BAIL_IF(rc == -1, errcodeFromErrno(), 0); + } + return 1; +} /* __PHYSFS_platformFlush */ + + +void __PHYSFS_platformClose(void *opaque) +{ + const int fd = *((int *) opaque); + int rc = -1; + do { + rc = close(fd); /* we don't check this. You should have used flush! */ + } while ((rc == -1) && (errno == EINTR)); + allocator.Free(opaque); +} /* __PHYSFS_platformClose */ + + +int __PHYSFS_platformDelete(const char *path) +{ + BAIL_IF(remove(path) == -1, errcodeFromErrno(), 0); + return 1; +} /* __PHYSFS_platformDelete */ + + +int __PHYSFS_platformStat(const char *fname, PHYSFS_Stat *st, const int follow) +{ + struct stat statbuf; + const int rc = follow ? stat(fname, &statbuf) : lstat(fname, &statbuf); + BAIL_IF(rc == -1, errcodeFromErrno(), 0); + + if (S_ISREG(statbuf.st_mode)) + { + st->filetype = PHYSFS_FILETYPE_REGULAR; + st->filesize = statbuf.st_size; + } /* if */ + + else if(S_ISDIR(statbuf.st_mode)) + { + st->filetype = PHYSFS_FILETYPE_DIRECTORY; + st->filesize = 0; + } /* else if */ + + else if(S_ISLNK(statbuf.st_mode)) + { + st->filetype = PHYSFS_FILETYPE_SYMLINK; + st->filesize = 0; + } /* else if */ + + else + { + st->filetype = PHYSFS_FILETYPE_OTHER; + st->filesize = statbuf.st_size; + } /* else */ + + st->modtime = statbuf.st_mtime; + st->createtime = statbuf.st_ctime; + st->accesstime = statbuf.st_atime; + + st->readonly = (access(fname, W_OK) == -1); + return 1; +} /* __PHYSFS_platformStat */ + + +void *__PHYSFS_platformGetThreadID(void) +{ + return (void *) LWP_GetSelf(); +} /* __PHYSFS_platformGetThreadID */ + + +void *__PHYSFS_platformCreateMutex(void) +{ + mutex_t m; + LWP_MutexInit(&m, true); + return (void *) m; +} /* __PHYSFS_platformCreateMutex */ + + +void __PHYSFS_platformDestroyMutex(void *mutex) +{ + mutex_t m = (mutex_t) mutex; + + LWP_MutexDestroy(m); +} /* __PHYSFS_platformDestroyMutex */ + + +int __PHYSFS_platformGrabMutex(void *mutex) +{ + mutex_t m = (mutex_t) mutex; + return LWP_MutexLock(m) == 0 ? 1 : 0; +} /* __PHYSFS_platformGrabMutex */ + + +void __PHYSFS_platformReleaseMutex(void *mutex) +{ + mutex_t m = (mutex_t) mutex; + LWP_MutexUnlock(m); +} /* __PHYSFS_platformReleaseMutex */ + + + +int __PHYSFS_platformInit(void) +{ + return 1; /* always succeed. */ +} /* __PHYSFS_platformInit */ + + +void __PHYSFS_platformDeinit(void) +{ + /* no-op */ +} /* __PHYSFS_platformDeinit */ + + +void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data) +{ +} /* __PHYSFS_platformDetectAvailableCDs */ + + +char *__PHYSFS_platformCalcBaseDir(const char *argv0) +{ + char *retval = NULL; + const size_t bufsize = 128; + + retval = allocator.Realloc(retval, bufsize); + if (retval) + { + if (getcwd(retval, bufsize - 1)) + { + /* Make sure the path is slash-terminated */ + size_t length = strlen(retval); + if (length > 0 && retval[length - 1] != '/') + { + retval[length++] = '/'; + retval[length] = '\0'; + } + } + else + { + strcpy(retval, "/"); + } + } + + return retval; +} /* __PHYSFS_platformCalcBaseDir */ + + +char *__PHYSFS_platformCalcPrefDir(const char *org, const char *app) +{ + static const char subdir[] = "data/"; + + /* We don't have users on the Wii/GameCube. Just create a userdata folder + * in the application's directory. */ + return buildSubdirPath(subdir, sizeof(subdir)); +} /* __PHYSFS_platformCalcPrefDir */ + +/* end of physfs_platform_unix.c ... */ + +#endif /* PHYSFS_PLATFORM_OGC */ + +/* end of physfs_platform_ogc.c ... */ + diff --git a/src/physfs_platforms.h b/src/physfs_platforms.h index 1ac17d9..36119b3 100644 --- a/src/physfs_platforms.h +++ b/src/physfs_platforms.h @@ -72,6 +72,9 @@ #elif defined(unix) || defined(__unix__) # define PHYSFS_PLATFORM_UNIX 1 # define PHYSFS_PLATFORM_POSIX 1 +#elif defined(__wii__) || defined(__gamecube__) +# define PHYSFS_PLATFORM_OGC 1 +# define PHYSFS_NO_CDROM_SUPPORT 1 // TODO #else # error Unknown platform. #endif ================================================ FILE: gamecube/pkg-config/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=gamecube-pkg-config pkgver=0.28 pkgrel=5 pkgdesc='pkg-config wrapper (for Nintendo Wii homebrew development)' arch=('any') url='http://devkitpro.org/' source=('pkg-config.in') sha256sums=('d241fb15ac9f209290cdd44863a217cef13ebdeff1cfe4a146cacfb3e46e260c') groups=('gamecube-dev') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/gamecube/bin cp "$srcdir"/pkg-config.in "$pkgdir"/opt/devkitpro/portlibs/gamecube/bin/powerpc-eabi-pkg-config } ================================================ FILE: gamecube/pkg-config/pkg-config.in ================================================ #!/usr/bin/env bash command -v pkg-config >/dev/null 2>&1 || { echo >&2 "I require pkg-config but it's not installed. Aborting."; exit 1; } # reset pkg-config variables to ensure we're not polluted by host libraries export PKG_CONFIG_DIR= export PKG_CONFIG_PATH= export PKG_CONFIG_SYSROOT_DIR= export PKG_CONFIG_LIBDIR=/opt/devkitpro/portlibs/gamecube/lib/pkgconfig:/opt/devkitpro/portlibs/ppc/lib/pkgconfig [[ "$1" == '--version' ]] && exec pkg-config --version exec pkg-config --static "$@" ================================================ FILE: gamecube-examples/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('gamecube-examples') pkgver=20260125 pkgrel=1 pkgdesc="Nintendo Gamecube example code." arch=('any') license=('custom') url="http://github.com/devkitpro/${pkgname}" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz) sha256sums=('f4ef3cc50eae60b4917411360251999caf3ac585b96e155510a8080dd3986edc') depends=('devkitPPC' 'libogc') groups=('gamecube-dev') package() { mkdir -p "$pkgdir"/opt/devkitpro/examples/gamecube cp -R $srcdir/${pkgname}-${pkgver}/* "$pkgdir"/opt/devkitpro/examples/gamecube } sha256sums=('9f504404795048e386d19b00d6eb156afd124d163bd778e9d22dd2d2774b8094') ================================================ FILE: gba/pkg-config/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=gba-pkg-config pkgver=0.28 pkgrel=4 pkgdesc='pkg-config wrapper (for Nintendo GBA homebrew development)' arch=('any') url='http://devkitpro.org/' source=('pkg-config.in') sha256sums=('25604f805c33ac129188a16863ffc36a7d8f4a762c238c8a2e068bd538c1e0cf') groups=('gba-dev') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/gba/bin cp "$srcdir"/pkg-config.in "$pkgdir"/opt/devkitpro/portlibs/gba/bin/arm-none-eabi-pkg-config } ================================================ FILE: gba/pkg-config/pkg-config.in ================================================ #!/usr/bin/env bash command -v pkg-config >/dev/null 2>&1 || { echo >&2 "I require pkg-config but it's not installed. Aborting."; exit 1; } # reset pkg-config variables to ensure we're not polluted by host libraries export PKG_CONFIG_DIR= export PKG_CONFIG_PATH= export PKG_CONFIG_SYSROOT_DIR= export PKG_CONFIG_LIBDIR=${DEVKITPRO}/portlibs/gba/lib/pkgconfig [[ "$1" == '--version' ]] && exec pkg-config --version exec pkg-config --static "$@" ================================================ FILE: gba-examples/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('gba-examples') pkgver=20240626 pkgrel=1 pkgdesc="Nintendo GBA example code." arch=('any') license=('custom') url="http://github.com/devkitpro/${pkgname}" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz) makedepends=('devkitARM') groups=('gba-dev') package() { mkdir -p "$pkgdir"/opt/devkitpro/examples/gba cp -R $srcdir/${pkgname}-${pkgver}/* "$pkgdir"/opt/devkitpro/examples/gba } sha256sums=('8b33160c18158a51dbafc024efe367374ddcc4cfda30542fb197ebca5cb45a1c') ================================================ FILE: gp2x/gp2x-core/PKGBUILD ================================================ # Maintainer: Adan Scotney pkgbasename=('libfat') pkgname=("libfat-gp2x") pkgver=1.2.0 pkgrel=1 pkgdesc="GP2X FAT library." arch=('any') license=('custom') url="http://github.com/devkitpro" options=(!strip libtool staticlibs) source=(${pkgbasename}-${pkgver}.tar.gz::${url}/${pkgbasename}/archive/v${pkgver}/${pkgbasename}-${pkgver}.tar.gz) sha256sums=('6bb461dd128b09abbf1a895249dd59c22da98557939930e0483e8b5b36988e10') makedepends=('devkitARM' 'orcus') groups=('gp2x-dev') build() { make -C $srcdir/${pkgbasename}-${pkgver} gp2x-release } package() { make -C $srcdir/${pkgbasename}-${pkgver} DESTDIR=$pkgdir gp2x-install } ================================================ FILE: gp2x/liborcus/PKGBUILD ================================================ # Maintainer: Adan Scotney pkgname=gp2x-pkg-config pkgver=0.29 pkgrel=1 pkgdesc='pkg-config wrapper (for GP2X homebrew development)' arch=('any') url='http://devkitpro.org/' source=('pkg-config.in') sha256sums=('11a50121b620ba57e64f453c0c32f632149a9b831e8968058be4a5d14177c527') groups=('gp2x-dev') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/gp2x/bin cp "$srcdir"/pkg-config.in "$pkgdir"/opt/devkitpro/portlibs/gp2x/bin/arm-none-eabi-pkg-config } ================================================ FILE: gp2x/pkg-config/pkg-config.in ================================================ #!/usr/bin/env bash command -v pkg-config >/dev/null 2>&1 || { echo >&2 "I require pkg-config but it's not installed. Aborting."; exit 1; } # reset pkg-config variables to ensure we're not polluted by host libraries export PKG_CONFIG_DIR= export PKG_CONFIG_PATH= export PKG_CONFIG_SYSROOT_DIR= export PKG_CONFIG_LIBDIR=${DEVKITPRO}/portlibs/gp2x/lib/pkgconfig:${DEVKITPRO}/portlibs/armv4t/lib/pkgconfig [[ "$1" == '--version' ]] && exec pkg-config --version exec pkg-config --static "$@" ================================================ FILE: gp32-examples/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('gp32-examples') pkgver=20051021 pkgrel=2 pkgdesc="Nintendo GP32 example code." arch=('any') license=('custom') url="http://github.com/devkitpro/${pkgname}" options=(!strip libtool staticlibs) source=(${url}/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.bz2) sha256sums=('7d542f3771cc6bdfef385d82aedf1bb8acf854fc96468b061e84b8dcbae1a755') makedepends=('devkitARM') groups=('gp32-dev') package() { rm $srcdir/${pkgname}-${pkgver}.tar.bz2 mkdir -p "$pkgdir"/opt/devkitpro/examples/gp32 cp -R $srcdir/* "$pkgdir"/opt/devkitpro/examples/gp32 } ================================================ FILE: libctru/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('libctru') pkgver=2.7.0 pkgrel=1 pkgdesc="Nintendo 3DS userland library." arch=('any') license=('custom') url="http://github.com/devkitPro/${pkgname}" options=(!strip libtool staticlibs) source=( ${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz ) depends=('devkitARM') groups=('3ds-dev') build() { cd ${srcdir}/${pkgname}-${pkgver}/libctru make } package() { cd ${srcdir}/libctru-${pkgver}/libctru make -j DESTDIR=$pkgdir install } sha256sums=('c0b8a5048e15a0ae02772e6db0188f5571e8c26d064d7962212a40681f0d18b3') ================================================ FILE: libfat/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgbasename=('libfat') pkgname=${pkgbasename}-${PLATFORM} pkgver=2.1.0 pkgrel=4 pkgdesc="libdvm" arch=('any') license=('ZPL') if [ -z "$PLATFORM" ];then PLATFORM=nds fi if [ "$PLATFORM" = "gba" ]; then platdesc="Nintendo GBA" depends=('devkitARM' 'libgba') groups=('gba-dev') _target=gba elif [ "$PLATFORM" = "nds" ]; then platdesc="Nintendo NDS" depends=('libnds') groups=('nds-dev') _target=ds elif [ "$PLATFORM" = "ogc" ]; then platdesc="Nintendo GameCube/Wii" depends=('libogc') groups=('wii-dev' 'gamecube-dev') _target="wii cube" else echo "$PLATFORM unsupported" exit 1 fi url="http://github.com/devkitpro/" options=(!strip libtool staticlibs) fatfs_mod_ver=0.15.3 libdvm_ver=2.1.0 source=( libdvm-${libdvm_ver}.tar.gz::${url}/libdvm/archive/v${libdvm_ver}.tar.gz fatfs-mod-${fatfs_mod_ver}.tar.gz::${url}/fatfs-mod/archive/v${fatfs_mod_ver}.tar.gz ) makedepends=('catnip') if [ "$PLATFORM" = "nds" ]; then replaces+=('libfilesystem') conflicts+=('libfilesystem') provides=('libfilesystem') fi prepare() { mv ${srcdir}/fatfs-mod-${fatfs_mod_ver} ${srcdir}/libdvm-${libdvm_ver}/fatfs } package() { cd $srcdir/libdvm-${libdvm_ver} DESTDIR=$pkgdir catnip install ${_target} } sha256sums=('f3fc17671c8234b345a8b742252d4f26bbe481d8f73b6f990b0d820e97a0616f' '26f55e648df6b5cc05204d9288b0c93d30572872c834c2a861b591bad1a3997f') ================================================ FILE: libfilesystem/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('libfilesystem') pkgver=0.9.14 pkgrel=2 pkgdesc="Nintendo DS filesystem support library." arch=('any') license=('zlib') url="http://github.com/devkitpro" options=(!strip libtool staticlibs) source=(${url}/${pkgname}/releases/download/v${pkgver}/${pkgname}-src-${pkgver}.tar.bz2) sha256sums=('291ed40873e7a0b6882c7bcd7ed6b9991a9c0434b7678404c8d53e13f1885274') makedepends=('devkitARM') groups=('nds-dev') build() { make -C $srcdir } package() { make -C $srcdir DESTDIR=$pkgdir install } ================================================ FILE: libgba/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('libgba') pkgver=0.5.4 pkgrel=1 pkgdesc="Nintendo GBA library." arch=('any') license=('LGPL') url="http://github.com/devkitpro" options=(!strip libtool staticlibs) #https://github.com/devkitPro/libgba/archive/refs/tags/v0.5.3.tar.gz source=(${pkgname}-${pkgver}.tar.gz::${url}/${pkgname}/archive/refs/tags/v${pkgver}.tar.gz) sha256sums=('1eb1289510d3ddc7729ecf977c93b77bde1dff71c135bc2700fa230bd493c388') depends=('devkitARM' 'devkitarm-rules' 'devkitarm-crtls') groups=('gba-dev') build() { make -C $srcdir/${pkgname}-${pkgver} } package() { make -C $srcdir/${pkgname}-${pkgver} DESTDIR=$pkgdir install } sha256sums=('0058a7d506029cc52aa24ed6a16c88c3be6c5a6674e8c2fd2fa129a5cc3142f7') ================================================ FILE: libgxflux/PKGBUILD ================================================ # Maintainer: TurtleP pkgname=libgxflux pkgver=20230423 _snapshot=91430ea pkgrel=3 pkgdesc="libgxflux" arch=("any") url="https://repo.or.cz/libgxflux.git" license=("GPL2") options=("staticlibs" "!strip") source=( "libgxflux-${snapshot}.tar.gx::${url}/snapshot/${_snapshot}.tar.gz" "libgxflux-destdir.patch" ) sha256sums=('07b7453f7c2eb54aa049498245bea2694feb0a7ae6d7eeb94c3e625d927ac885' '85a819135fd777a00ff7dde8f8370a35f2aaadff8a8afec6791ac9fb19b0e4ce') makedepends=("dkp-toolchain-vars") groups=("wii-dev" "gamecube-dev") package() { source /opt/devkitpro/ppcvars.sh cd libgxflux-${_snapshot} patch -Np1 -i ${srcdir}/libgxflux-destdir.patch make -C src install DESTDIR=${pkgdir} make -C src clean make -C src install GAMECUBE=1 DESTDIR=${pkgdir} } ================================================ FILE: libgxflux/libgxflux-destdir.patch ================================================ diff --git a/src/Makefile b/src/Makefile index 42bd5c2..f6ae9fb 100644 --- a/src/Makefile +++ b/src/Makefile @@ -7,16 +7,17 @@ HEADERS = gfx.h gfx_types.h gfx_tex.h gfx_color.h gfx_con.h gfx_con_esc.h include ../common.mk ifeq ($(GAMECUBE),1) -INSTALLLIB = $(DEVKITPRO)/libogc/lib/cube +INSTALLLIB = ${DESTDIR}$(DEVKITPRO)/libogc/lib/cube/ else -INSTALLLIB = $(DEVKITPRO)/libogc/lib/wii +INSTALLLIB = ${DESTDIR}$(DEVKITPRO)/libogc/lib/wii/ endif -INSTALLINCLUDE = $(DEVKITPRO)/libogc/include/gxflux +INSTALLINCLUDE = ${DESTDIR}$(DEVKITPRO)/libogc/include/gxflux/ install: all @echo " INSTALL $(INSTALLLIB)" - @install -m 644 $(TARGET) $(INSTALLLIB) + @mkdir -p $(INSTALLLIB) + @install -m 644 $(TARGET) $(INSTALLLIB)/$(TARGET) @mkdir -p $(INSTALLINCLUDE) @install -m 644 $(HEADERS) $(INSTALLINCLUDE) ================================================ FILE: libmirko/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('libmirko') pkgver=0.9.8 pkgrel=1 pkgdesc="Nintendo GP32 library." arch=('any') license=('zlib') url="http://github.com/devkitpro" options=(!strip libtool staticlibs) source=(${url}/${pkgname}/releases/download/v${pkgver}/${pkgname}-src-${pkgver}.tar.bz2) sha256sums=('6bce393798b0b89dde9d273c2ccab22e62af3075c6d7805cf3a5338c1921743e') makedepends=('devkitARM') groups=('gp32-dev') build() { make -C $srcdir } package() { make -C $srcdir DESTDIR=$pkgdir install } ================================================ FILE: libnds/0001-fix-within-comment.patch ================================================ From 154a21cc3d57716f773ff2b10f815511c1b8ba9f Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Mon, 27 Jul 2020 03:29:04 +0100 Subject: [PATCH] fix /* within comment --- include/gl2d.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/include/gl2d.h b/include/gl2d.h index 43295ce..a2c9348 100644 --- a/include/gl2d.h +++ b/include/gl2d.h @@ -2,7 +2,7 @@ Easy GL2D - Relminator 2010 + Relminator 2010 Richard Eric M. Lope BSN RN http://rel.betterwebber.com @@ -11,17 +11,13 @@ ---------------------------------------------------------------------------------*/ -/*! +/*! \file gl2d.h + \brief A very small and simple DS rendering lib using the 3d core to render 2D stuff. - \section gl2d API - \ref gl2d.h "Reference" - - -/*! \file gl2d.h - \brief A very small and simple DS rendering lib using the 3d core to render 2D stuff. */ -- 2.11.0 ================================================ FILE: libnds/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('libnds') pkgver=2.0.2 pkgrel=1 pkgdesc="Nintendo DS library." arch=('any') license=('zlib') url="http://github.com/devkitpro/${pkgname}" options=(!strip libtool staticlibs) source=( ${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz ) depends=('devkitARM' 'devkitarm-rules' 'devkitarm-crtls') groups=('nds-dev') package() { make -C $srcdir/${pkgname}-${pkgver} DESTDIR=$pkgdir install } sha256sums=('7bd4acd777b4f0fb5087897c16ed4087642fb0e2c0ac1970a9079b255d5865d4') ================================================ FILE: libnx/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('libnx') pkgver=4.12.0 pkgrel=1 pkgdesc="Nintendo Switch AArch64-only userland library." arch=('any') license=('custom') url="http://github.com/switchbrew" options=(!strip libtool staticlibs) source=( ${pkgname}-${pkgver}.tar.gz::${url}/${pkgname}/archive/v${pkgver}.tar.gz ) makedepends=('devkitA64') groups=('switch-dev') build() { cd ${srcdir}/${pkgname}-${pkgver}/nx make } package() { cd ${srcdir}/${pkgname}-${pkgver}/nx make DESTDIR=$pkgdir install } sha256sums=('1665209994d67b4b236d80fa200499853473a7e2bb502d5045d00fc0170f90ef') ================================================ FILE: libogc/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('libogc') pkgver=3.1.0 pkgrel=1 pkgdesc="Nintendo Gamecube & Wii library." arch=('any') license=('custom') url="http://github.com/devkitpro/${pkgname}" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz) makedepends=('devkitPPC') groups=('wii-dev' 'gamecube-dev') build() { cd ${srcdir}/libogc-${pkgver} LIBOGC_VER=v${pkgver} catnip } package() { cd ${srcdir}/libogc-${pkgver} LIBOGC_VER=v${pkgver} DESTDIR=$pkgdir catnip install } sha256sums=('e8106f4006752146eff9bb7f7ff7c74c56aff8c7f348942533f4fcb03b8b731e') ================================================ FILE: libtonc/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('libtonc') pkgver=1.4.5 pkgrel=1 pkgdesc="Nintendo GBA library ." arch=('any') license=('mit') url="http://www.coranac.com/projects/#tonc" options=(!strip libtool staticlibs) source=(${pkgver}-${pkgver}.tar.gz::https://github.com/devkitpro/${pkgname}/archive/refs/tags/v${pkgver}.tar.gz) sha256sums=('6a696d19a2f1bb0e456d241c2a438a96c791fa8daf753a87906a14cc7ae8cabd') depends=('devkitARM' 'devkitarm-rules' 'devkitarm-crtls') groups=('gba-dev') build() { make -C $srcdir/${pkgname}-${pkgver} } package() { make -C $srcdir/${pkgname}-${pkgver} DESTDIR=$pkgdir install } sha256sums=('d326c1b2b982f1375ff8c9118f463e75af8fccdd23916d7e98b1a3bbfbcffac0') ================================================ FILE: maxmod/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgbasename=('maxmod') if [ -z "$PLATFORM" ];then PLATFORM=nds fi if [ "$PLATFORM" = "gba" ]; then platdesc="Nintendo GBA" depends=('devkitARM' 'libgba') groups=('gba-dev') elif [ "$PLATFORM" = "nds" ]; then platdesc="Nintendo NDS" depends=('libnds') groups=('nds-dev') else echo "$PLATFORM unsupported" exit 1 fi pkgname=("${pkgbasename}-${PLATFORM}") pkgver=2.1.0 pkgrel=2 pkgdesc="${platdesc} Audio library." arch=('any') license=('custom') url="http://github.com/devkitpro" options=(!strip libtool staticlibs) source=($pkgbasename-$pkgver.tar.gz::${url}/${pkgbasename}/archive/v${pkgver}.tar.gz) sha256sums=( '023d5a4b3a012451f14bff56c26af0b35bf1bd88e37d2c304a018431fb4b2b88' ) package() { cd $srcdir/${pkgbasename}-${pkgver} DESTDIR=$pkgdir catnip install } sha256sums=('1d5c76245855704dd4b88de8265885183de32c6a1988b93f7c22bf1ea96ef8b0') ================================================ FILE: nds/bzip2/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('nds-bzip2') pkgver=1.0.8 pkgrel=1 pkgdesc="A high-quality data compression program" arch=('any') license=('custom') url="https://sourceware.org/bzip2/" options=(!strip libtool staticlibs) source=(https://sourceware.org/pub/bzip2/bzip2-${pkgver}.tar.gz) sha256sums=( 'ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269' ) makedepends=('3ds-pkg-config' 'dkp-toolchain-vars') groups=('nds-portlibs') build() { source /opt/devkitpro/ndsvars.sh make -C "$srcdir/bzip2-$pkgver" \ CC=arm-none-eabi-gcc \ AR=arm-none-eabi-ar \ RANLIB=arm-none-eabi-ranlib \ CPPFLAGS="${CPPFLAGS}" \ CFLAGS="-D_FILE_OFFSET_BITS=64 -Winline ${CFLAGS}" libbz2.a } package() { source /opt/devkitpro/ndsvars.sh install -Dm 644 "$srcdir/bzip2-$pkgver"/LICENSE -t "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}" install -Dm 644 "$srcdir/bzip2-$pkgver"/bzlib.h -t "${pkgdir}/${PORTLIBS_PREFIX}/include/" install -Dm 644 "$srcdir/bzip2-$pkgver"/libbz2.a -t "${pkgdir}/${PORTLIBS_PREFIX}/lib" } ================================================ FILE: nds/freetype/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=nds-freetype pkgver=2.13.2 pkgrel=1 pkgdesc='FreeType is a freely available software library to render fonts.' arch=('any') url='https://www.freetype.org/' license=(GPL2+ custom:FreeType) options=(!strip libtool staticlibs) depends=("nds-bzip2" "nds-libpng" "nds-zlib" ) makedepends=('ppc-pkg-config' 'dkp-toolchain-vars') source=("http://download.savannah.gnu.org/releases/freetype/freetype-$pkgver.tar.xz") groups=("nds-portlibs") build() { cd freetype-$pkgver source /opt/devkitpro/ndsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --enable-freetype-config \ --disable-shared --enable-static \ --without-harfbuzz \ --with-zlib \ --with-bzip2 \ --with-png make } package() { cd freetype-$pkgver source /opt/devkitpro/ndsvars.sh make DESTDIR="$pkgdir" install # patch the config script to always output static libraries when not relying on pkg-config sed 's/\$show_static/yes/' -i "${pkgdir}/${PORTLIBS_PREFIX}/bin/freetype-config" # Licenses install -Dm644 "LICENSE.TXT" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/LICENSE.TXT" install -Dm644 "docs/GPLv2.TXT" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/GPLv2.TXT" install -Dm644 "docs/FTL.TXT" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/FTL.TXT" # remove useless stuff rm -r "${pkgdir}/${PORTLIBS_PREFIX}/share" } sha256sums=('12991c4e55c506dd7f9b765933e62fd2be2e06d421505d7950a132e4f1bb484d') ================================================ FILE: nds/libexpat/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=nds-libexpat pkgver=2.2.5 pkgrel=1 pkgdesc='Expat, a stream-oriented XML parser library written in C.' arch=('any') url='https://libexpat.github.io/' license=(MIT/X) options=(!strip libtool staticlibs) source=("https://github.com/libexpat/libexpat/releases/download/R_2_2_5/expat-$pkgver.tar.bz2") sha256sums=('d9dc32efba7e74f788fcc4f212a43216fc37cf5f23f4c2339664d473353aedf6') makedepends=('nds-pkg-config' 'dkp-toolchain-vars') groups=('nds-portlibs') build() { cd expat-$pkgver source /opt/devkitpro/ndsvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd expat-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: nds/libmad/PKGBUILD ================================================ # Maintainer: WinterMute # Contributor: Cameron Cawley pkgname=nds-libmad pkgver=0.15.1b pkgrel=1 pkgdesc='A high-quality MPEG audio decoder. (for Nintendo DS homebrew development)' arch=('any') url='https://www.underbit.com' license=('GPL') options=(!strip libtool staticlibs) source=( "https://sourceforge.net/projects/mad/files/libmad/${pkgver}/libmad-${pkgver}.tar.gz" "libmad-0.15.1b.patch" ) sha256sums=( 'bbfac3ed6bfbc2823d3775ebb931087371e142bb0e9bb1bee51a76a6e0078690' '2b7c29f4383b6f92b3b33144ce445f9558ff3e3fa4f185cec13d44969c7c9b11' ) makedepends=('nds-pkg-config' 'dkp-toolchain-vars') groups=('nds-portlibs') build() { cd libmad-$pkgver patch -Np1 -i "$srcdir/libmad-0.15.1b.patch" source /opt/devkitpro/ndsvars.sh rm -f Makefile.in aclocal.m4 config.guess config.h.in config.sub configure depcomp install-sh ltmain.sh mad.h missing mkinstalldirs msvc++/Makefile.in touch AUTHORS NEWS ChangeLog autoreconf -fi ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi --disable-shared --enable-static \ --enable-fpm=arm --enable-speed --enable-sso make } package() { cd libmad-$pkgver source /opt/devkitpro/ndsvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: nds/libmad/libmad-0.15.1b.patch ================================================ diff -ur libmad-0.15.1b/configure.ac libmad-0.15.1b-patched/configure.ac --- libmad-0.15.1b/configure.ac 2004-01-23 09:41:32.000000000 +0000 +++ libmad-0.15.1b-patched/configure.ac 2020-08-12 11:51:45.776476110 +0100 @@ -140,7 +140,7 @@ case "$optimize" in -O|"-O "*) optimize="-O" - optimize="$optimize -fforce-mem" + optimize="$optimize" optimize="$optimize -fforce-addr" : #x optimize="$optimize -finline-functions" : #- optimize="$optimize -fstrength-reduce" ================================================ FILE: nds/libpng/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=nds-libpng pkgver=1.6.39 pkgrel=3 pkgdesc='PNG format graphic files library.' arch=('any') url='http://www.libpng.org' license=('custom') options=(!strip libtool staticlibs) depends=('nds-zlib') groups=('nds-portlibs') makedepends=('nds-pkg-config' 'dkp-toolchain-vars') groups=('nds-portlibs') source=("https://download.sourceforge.net/libpng/libpng-$pkgver.tar.xz") sha256sums=( '1f4696ce70b4ee5f85f1e1623dc1229b210029fa4b7aee573df3e2ba7b036937' ) build() { cd libpng-$pkgver source /opt/devkitpro/ndsvars.sh sed -i 's/^bin_PROGRAMS = .*//' Makefile.in ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd libpng-$pkgver source /opt/devkitpro/ndsvars.sh make LN_S=cp DESTDIR="$pkgdir" install # license install -Dm644 LICENSE "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/LICENSE # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share } ================================================ FILE: nds/pkg-config/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=nds-pkg-config pkgver=0.28 pkgrel=4 pkgdesc='pkg-config wrapper (for Nintendo DS homebrew development)' arch=('any') url='http://devkitpro.org/' source=('pkg-config.in') sha256sums=('020238b87d79f1d5e25ff08df89b9761a14fbe47b1ea2ec8435472d36ce3d3e7') groups=('nds-dev') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/nds/bin cp "$srcdir"/pkg-config.in "$pkgdir"/opt/devkitpro/portlibs/nds/bin/arm-none-eabi-pkg-config } ================================================ FILE: nds/pkg-config/pkg-config.in ================================================ #!/usr/bin/env bash command -v pkg-config >/dev/null 2>&1 || { echo >&2 "I require pkg-config but it's not installed. Aborting."; exit 1; } # reset pkg-config variables to ensure we're not polluted by host libraries export PKG_CONFIG_DIR= export PKG_CONFIG_PATH= export PKG_CONFIG_SYSROOT_DIR= export PKG_CONFIG_LIBDIR=${DEVKITPRO}/portlibs/nds/lib/pkgconfig [[ "$1" == '--version' ]] && exec pkg-config --version exec pkg-config --static "$@" ================================================ FILE: nds/zlib/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=nds-zlib pkgver=1.3 pkgrel=1 pkgdesc='Deflate compression method library' arch=('any') url='http://www.zlib.net' license=('zlib') options=(!strip libtool staticlibs) source=("${url}/zlib-$pkgver.tar.xz") makedepends=('dkp-toolchain-vars') groups=('nds-portlibs') build() { cd zlib-$pkgver source /opt/devkitpro/ndsvars.sh CHOST=arm-none-eabi \ ./configure --prefix="${PORTLIBS_PREFIX}" --static make libz.a # only build library, no programs # libminizip cd contrib/minizip autoreconf --force --verbose --install CFLAGS="${CFLAGS} -DUSE_FILE32API" ./configure --prefix="${PORTLIBS_PREFIX}" --host=arm-none-eabi \ --disable-shared --enable-static make } package() { cd zlib-$pkgver source /opt/devkitpro/ndsvars.sh make DESTDIR="$pkgdir" install # license install -d "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname tail -n 31 README > "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/LICENSE # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share # libminizip cd contrib/minizip make DESTDIR="$pkgdir" install } sha256sums=('8a9ba2898e1d0d774eca6ba5b4627a11e5588ba85c8851336eb38de4683050a7') ================================================ FILE: nds-examples/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('nds-examples') pkgver=20241110 pkgrel=1 pkgdesc="Nintendo NDS example code." arch=('any') license=('custom') url="http://github.com/devkitpro/${pkgname}" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz) sha256sums=('de37bd64b317935f428f6cda75231143787f8d751cb9cd7b728804911e105f63') makedepends=('devkitARM') groups=('nds-dev') package() { mkdir -p "$pkgdir"/opt/devkitpro/examples/nds cp -R $srcdir/${pkgname}-${pkgver}/* "$pkgdir"/opt/devkitpro/examples/nds } sha256sums=('5d97f533ee398049cecdddda743ea395c756fa3805cd683b0af595312d0a140a') ================================================ FILE: pkgbuild-scripts/.gitignore ================================================ devkitpro-pkgbuild-helpers ================================================ FILE: pkgbuild-scripts/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=devkitpro-pkgbuild-helpers pkgver=3.0.0 pkgrel=1 pkgdesc='deprecated package' arch=('any') url='http://devkitpro.org/' options=(!strip) install=pkgbuild-scripts.install ================================================ FILE: pkgbuild-scripts/pkgbuild-scripts.install ================================================ post_install() { echo "This package is no longer being used" echo "Please use dkp-toolchain-vars and the cmake packages instead" } ================================================ FILE: ppc/TinyXML2/PKGBUILD ================================================ pkgname=ppc-tinyxml2 pkgver=10.0.0 pkgrel=1 pkgdesc='A simple, small, efficient, C++ XML parser that can be easily integrated into other programs (for Gamecube/Wii/WiiU homebrew development)' arch=('any') url='http://leethomason.github.io/tinyxml2/' license=('zlib') options=(!strip libtool staticlibs) source=( "https://github.com/leethomason/tinyxml2/archive/${pkgver}.tar.gz" ) makedepends=('ppc-pkg-config' 'dkp-toolchain-vars' 'devkitppc-cmake') sha256sums=('3bdf15128ba16686e69bce256cc468e76c7b94ff2c7f391cc5ec09e40bff3839') groups=('ppc-portlibs') build() { cd tinyxml2-$pkgver source /opt/devkitpro/ppcvars.sh powerpc-eabi-cmake \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DCMAKE_C_FLAGS="$CFLAGS $CPPFLAGS" \ -DCMAKE_CXX_FLAGS="$CFLAGS" \ -DBUILD_TESTING:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=OFF \ -G"Unix Makefiles" \ . make } package() { cd tinyxml2-$pkgver source /opt/devkitpro/ppcvars.sh make install DESTDIR="$pkgdir" } ================================================ FILE: ppc/box2d/PKGBUILD ================================================ # Maintainer: TurtleP pkgbasename=box2d pkgname=ppc-$pkgbasename pkgver=2.4.1 pkgrel=2 pkgdesc='Box2D is a 2D physics engine for games.' arch=('any') url='https://github.com/erincatto/box2d' license=(MIT) options=(!strip libtool staticlibs) source=("${url}/archive/refs/tags/v${pkgver}.zip") sha256sums=('0cb512dfa5be79ca227cd881b279adee61249c85c8b51caf5aa036b71e943002') makedepends=('dkp-toolchain-vars' 'devkitppc-cmake') groups=('ppc-portlibs') build() { cd ${pkgbasename}-${pkgver} /opt/devkitpro/devkitPPC/bin/powerpc-eabi-cmake -G"Unix Makefiles" \ -DCMAKE_INSTALL_PREFIX=/opt/devkitpro/portlibs/ppc \ -DBOX2D_BUILD_DOCS=OFF -DBOX2D_BUILD_UNIT_TESTS=OFF -DBOX2D_BUILD_TESTBED=OFF \ . make } package() { cd ${pkgbasename}-${pkgver} make install DESTDIR="$pkgdir" } ================================================ FILE: ppc/brotli/PKGBUILD ================================================ _pkgname=brotli pkgname=ppc-${_pkgname} pkgver=1.2.0 pkgrel=1 provides=("ppc-lib${_pkgname}=${pkgver}") conflicts=("ppc-lib${_pkgname}") pkgdesc='Brotli compression library.' arch=('any') url='https://github.com/google/brotli' license=('MIT') groups=('ppc-portlibs') options=(!buildflags !strip staticlibs) depends=('devkitPPC') makedepends=( 'devkitppc-cmake' 'dkp-toolchain-vars' ) source=( "${_pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz" "${_pkgname}-${pkgver}.patch" ) prepare() { patch -Np 0 -i "${_pkgname}-${pkgver}.patch" } build() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" powerpc-eabi-cmake \ -B build \ -DCMAKE_INSTALL_PREFIX="${PORTLIBS_PREFIX}" \ -DBROTLI_BUILD_TOOLS=OFF make -C build } package() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" make -C build install DESTDIR="$pkgdir" # Remove man pages. rm -r "${pkgdir}${PORTLIBS_PREFIX}/share" install -Dm 644 -t "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}" LICENSE } sha256sums=('816c96e8e8f193b40151dad7e8ff37b1221d019dbcb9c35cd3fadbfe6477dfec' 'f2249e6aa41b7c6b3e557036324ee4ebcd3240e1b6c4d582666e55480e4f4039') ================================================ FILE: ppc/brotli/brotli-1.2.0.patch ================================================ --- brotli-1.2.0/c/common/platform.h.orig 2025-10-27 13:07:48.000000000 +0000 +++ brotli-1.2.0/c/common/platform.h 2025-10-27 13:07:48.000000000 +0000 @@ -191,6 +191,10 @@ #define BROTLI_TARGET_X64 #endif +#if defined(__PPC__) +#define BROTLI_TARGET_POWERPC +#endif + #if defined(__PPC64__) #define BROTLI_TARGET_POWERPC64 #endif @@ -267,7 +271,8 @@ #define BROTLI_UNALIGNED_READ_FAST (!!0) #elif defined(BROTLI_TARGET_X86) || defined(BROTLI_TARGET_X64) || \ defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8_ANY) || \ - defined(BROTLI_TARGET_RISCV64) || defined(BROTLI_TARGET_LOONGARCH64) + defined(BROTLI_TARGET_POWERPC) || defined(BROTLI_TARGET_RISCV64) || \ + defined(BROTLI_TARGET_LOONGARCH64) /* These targets are known to generate efficient code for unaligned reads * (e.g. a single instruction, not multiple 1-byte loads, shifted and or'd * together). */ ================================================ FILE: ppc/bzip2/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('ppc-bzip2') pkgver=1.0.8 pkgrel=2 pkgdesc="A high-quality data compression program" arch=('any') license=('custom') url="https://sourceware.org/bzip2/" options=(!strip libtool staticlibs) source=(https://sourceware.org/pub/bzip2/bzip2-${pkgver}.tar.gz) sha256sums=( 'ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269' ) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') groups=('ppc-portlibs') build() { source /opt/devkitpro/ppcvars.sh make -C "$srcdir/bzip2-$pkgver" \ CC=${TOOL_PREFIX}gcc \ AR=${TOOL_PREFIX}ar \ RANLIB=${TOOL_PREFIX}ranlib \ CPPFLAGS="${CPPFLAGS}" \ CFLAGS="-D_FILE_OFFSET_BITS=64 -Winline ${CFLAGS}" libbz2.a } package() { source /opt/devkitpro/ppcvars.sh install -Dm 644 "$srcdir/bzip2-$pkgver"/LICENSE -t "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}" install -Dm 644 "$srcdir/bzip2-$pkgver"/bzlib.h -t "${pkgdir}/${PORTLIBS_PREFIX}/include/" install -Dm 644 "$srcdir/bzip2-$pkgver"/libbz2.a -t "${pkgdir}/${PORTLIBS_PREFIX}/lib" } ================================================ FILE: ppc/faad2/PKGBUILD ================================================ _pkgname=faad2 pkgname=ppc-${_pkgname} pkgver=2.11.2 pkgrel=1 pkgdesc='Freeware Advanced Audio (AAC) Decoder.' arch=('any') url='https://github.com/knik0/faad2' license=('GPLv2') options=(!strip libtool staticlibs) groups=('ppc-portlibs') source=("${_pkgname}-${pkgver}::${url}/archive/refs/tags/${pkgver}.tar.gz") build() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" powerpc-eabi-cmake \ -B build \ -DCMAKE_INSTALL_PREFIX="$PORTLIBS_PREFIX" \ -DCMAKE_BUILD_TYPE=Release \ -DFAAD_BUILD_CLI=OFF make -C build } package() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" make -C build install DESTDIR="$pkgdir" # install license install -Dm 644 -t "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}" COPYING # remove man pages rm -rfv "${pkgdir}${PORTLIBS_PREFIX}/share" } sha256sums=('3fcbd305e4abd34768c62050e18ca0986f7d9c5eca343fb98275418013065c0e') ================================================ FILE: ppc/flac/PKGBUILD ================================================ # Maintainer: Dave Murphy _pkgname=flac pkgname=ppc-${_pkgname} pkgver=1.5.0 pkgrel=1 pkgdesc='Free Lossless Audio Codec (FLAC) library.' arch=('any') url='https://xiph.org/flac/' license=(Xiph.org) options=(!strip libtool staticlibs) groups=('ppc-portlibs') depends=( 'ppc-libogg' ) makedepends=( 'dkp-toolchain-vars' ) source=("https://github.com/xiph/flac/releases/download/${pkgver}/${_pkgname}-${pkgver}.tar.xz") build() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" ./configure \ --prefix="${PORTLIBS_PREFIX}" \ --host=powerpc-eabi \ --disable-shared \ --enable-static \ --without-pic \ --disable-doxygen-docs \ --disable-examples \ --disable-oggtest \ --disable-programs \ --disable-thorough-tests \ --enable-cpplibs make } package() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" make install DESTDIR="$pkgdir" # copy license for libFLAC/libFLAC++ install -Dm 644 -t "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}" COPYING.Xiph # remove extra files rm -rfv "${pkgdir}${PORTLIBS_PREFIX}/share" } sha256sums=('f2c1c76592a82ffff8413ba3c4a1299b6c7ab06c734dee03fd88630485c2b920') ================================================ FILE: ppc/freetype/PKGBUILD ================================================ # Maintainer: Dave Murphy _pkgname=freetype pkgname=ppc-${_pkgname} pkgver=2.14.1 pkgrel=1 pkgdesc='FreeType is a freely available software library to render fonts.' arch=('any') url='https://www.freetype.org/' license=(GPL-2.0-only FTL) options=(!strip libtool staticlibs) groups=('ppc-portlibs') depends=( 'ppc-brotli' 'ppc-bzip2' 'ppc-libpng' 'ppc-zlib' ) makedepends=( 'dkp-toolchain-vars' 'ppc-pkg-config' ) source=("http://download.savannah.gnu.org/releases/freetype/${_pkgname}-${pkgver}.tar.xz") build() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" ./configure \ --host=powerpc-eabi \ --prefix="$PORTLIBS_PREFIX" \ --disable-shared \ --enable-static \ --disable-pic \ --disable-mmap \ --enable-year2038 \ --with-brotli=yes \ --with-bzip2=yes \ --with-png=yes \ --with-zlib=yes \ --without-harfbuzz make } package() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" make install DESTDIR="$pkgdir" # Licenses install -Dm 644 -t "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}" LICENSE.TXT docs/GPLv2.TXT docs/FTL.TXT # Remove extra files rm -rfv "${pkgdir}${PORTLIBS_PREFIX}/share" } sha256sums=('32427e8c471ac095853212a37aef816c60b42052d4d9e48230bab3bdf2936ccc') ================================================ FILE: ppc/giflib/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Colin969 pkgname=ppc-giflib pkgver=5.1.4 pkgrel=2 pkgdesc='A library for reading and writing gif images' arch=('any') url='http://sourceforge.net/projects/giflib' license=('MIT') options=(!strip libtool staticlibs) source=("http://downloads.sourceforge.net/sourceforge/giflib/giflib-${pkgver}.tar.bz2") sha256sums=('df27ec3ff24671f80b29e6ab1c4971059c14ac3db95406884fc26574631ba8d5') makedepends=('dkp-toolchain-vars') groups=('ppc-portlibs') build() { source /opt/devkitpro/ppcvars.sh cd giflib-$pkgver ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi make } package() { cd giflib-$pkgver source /opt/devkitpro/ppcvars.sh make DESTDIR="${pkgdir}" install # MIT License install -Dm644 COPYING "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/COPYING" } ================================================ FILE: ppc/glm/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Ash Logan pkgname=ppc-glm pkgver=1.0.2 pkgrel=1 pkgdesc='OpenGL Mathematics (GLM) header only C++ library' arch=('any') url='https://github.com/g-truc/glm' license=(MIT) options=(!strip libtool staticlibs) source=("${url}/releases/download/${pkgver}/glm-${pkgver}.zip" "glm-${pkgver}-ppc.patch") makedepends=('dkp-toolchain-vars' 'devkitppc-cmake') groups=('ppc-portlibs') build() { patch -Np1 -i ${srcdir}/glm-${pkgver}-ppc.patch -d ${srcdir}/glm source $DEVKITPRO/ppcvars.sh powerpc-eabi-cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DCMAKE_INSTALL_LIBDIR=lib \ -DCMAKE_CXX_FLAGS="$CFLAGS $CPPFLAGS" \ -DGLM_ENABLE_CXX_20=ON \ -DGLM_ENABLE_LANG_EXTENSIONS=ON \ -DGLM_BUILD_TESTS=OFF \ -S ${srcdir}/glm -B _build cmake --build _build } package() { DESTDIR="$pkgdir" cmake --install _build } sha256sums=('203b64abc82e4d8697cc5aeedc93117fc1ee52d36e7cdcfc0854fa2c607edaae' 'e07e962989b43c93df568941a8b7410465e5b232b5d6aeaa503b74f0cb01ddfe') ================================================ FILE: ppc/glm/glm-1.0.2-ppc.patch ================================================ diff -Nur glm-1.0.2-original/CMakeLists.txt glm-1.0.2-ppc/CMakeLists.txt --- glm-1.0.2-original/CMakeLists.txt 2025-10-15 08:07:40.000000000 -0300 +++ glm-1.0.2-ppc/CMakeLists.txt 2025-10-19 00:09:15.312057716 -0300 @@ -296,6 +296,17 @@ IMMEDIATE @ONLY ) + if (GLM_BUILD_LIBRARY) + set(PC_LIBS_LINE "Libs: -L\${libdir} -lglm") + else() + set(PC_LIBS_LINE "") + endif() + configure_file(glm.pc.in glm.pc @ONLY) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/glm.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig + ) + add_custom_target( uninstall "${CMAKE_COMMAND}" -P Binary files glm-1.0.2-original/.git/index and glm-1.0.2-ppc/.git/index differ diff -Nur glm-1.0.2-original/glm.pc.in glm-1.0.2-ppc/glm.pc.in --- glm-1.0.2-original/glm.pc.in 1969-12-31 21:00:00.000000000 -0300 +++ glm-1.0.2-ppc/glm.pc.in 2025-10-19 00:16:51.008077897 -0300 @@ -0,0 +1,9 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +includedir=${prefix}/include +libdir=${prefix}/lib + +Name: @PROJECT_NAME@ +Description: OpenGL Mathematics +Version: @PROJECT_VERSION@ +Cflags: -I${includedir} +@PC_LIBS_LINE@ ================================================ FILE: ppc/harfbuzz/PKGBUILD ================================================ _pkgname=harfbuzz pkgname=ppc-${_pkgname} pkgver=12.3.2 pkgrel=1 pkgdesc='HarfBuzz text shaping engine library.' arch=('any') url='https://harfbuzz.github.io/' license=(LGPL) groups=('ppc-portlibs') makedepends=( 'dkp-meson-scripts' 'ppc-pkg-config' ) depends=('ppc-freetype') options=(!buildflags !strip staticlibs) source=("https://github.com/harfbuzz/harfbuzz/releases/download/${pkgver}/${_pkgname}-${pkgver}.tar.xz") build() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" ${DEVKITPRO}/meson-cross.sh \ ppc \ ../crossfile.txt \ build \ -Dutilities=disabled \ -Dtests=disabled \ -Ddocs=disabled \ -Db_staticpic=false meson compile -C build -j 1 } package() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" meson install -C build --destdir "$pkgdir" # license install -Dm 644 -t "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}" COPYING } sha256sums=('6f6db164359a2da5a84ef826615b448b33e6306067ad829d85d5b0bf936f1bb8') ================================================ FILE: ppc/jansson/.gitignore ================================================ ppc-jansson ================================================ FILE: ppc/jansson/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Crayon pkgname=ppc-jansson pkgver=2.14 pkgrel=1 pkgdesc='A C library for encoding, decoding and manipulating JSON data.' arch=('any') url='http://www.digip.org/jansson/' license=('custom') options=(!strip libtool staticlibs) makedepends=('dkp-toolchain-vars') source=("https://github.com/akheron/jansson/releases/download/v${pkgver}/jansson-${pkgver}.tar.gz") sha256sums=('5798d010e41cf8d76b66236cfb2f2543c8d082181d16bc3085ab49538d4b9929') groups=('ppc-portlibs') build() { cd jansson-$pkgver source /opt/devkitpro/ppcvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static make } package() { cd jansson-$pkgver source /opt/devkitpro/ppcvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 LICENSE "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/LICENSE } ================================================ FILE: ppc/json-cpp/PKGBUILD ================================================ # Maintainer: Dave Murphy _realname=jsoncpp pkgname=ppc-${_realname} pkgver=1.9.5 pkgrel=1 pkgdesc="A C++ library for interacting with JSON" arch=('any') url='https://github.com/open-source-parsers/jsoncpp' license=('zlib') options=(!strip libtool staticlibs) source=( ${_realname}-${pkgver}.tar.gz::${url}/archive/refs/tags/${pkgver}.tar.gz) makedepends=('devkitPPC' 'devkitppc-cmake') groups=('ppc-portlibs') build() { /opt/devkitpro/devkitPPC/bin/powerpc-eabi-cmake \ -B _build -S ${_realname}-${pkgver} \ -DCMAKE_INSTALL_PREFIX=/opt/devkitpro/portlibs/ppc \ -DJSONCPP_WITH_TESTS=OFF \ -GNinja cmake --build _build --parallel } package() { DESTDIR="${pkgdir}" cmake --install _build } sha256sums=('fbe74bbdcee21d656715688706da3c8becfd946d92cd44705cc6098bb23b3a16') sha256sums=('f409856e5920c18d0c2fb85276e24ee607d2a09b5e7d5f0a371368903c275da2') ================================================ FILE: ppc/libconfig/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=ppc-libconfig pkgver=1.8.1 pkgrel=1 pkgdesc='C/C++ Configuration File Library' arch=('any') url="https://www.hyperrealm.com/libconfig/libconfig.html" license=('LGPL') options=(!strip libtool staticlibs) source=("libconfig-${pkgver}.tar.gz::https://github.com/hyperrealm/libconfig/archive/refs/tags/v${pkgver}.tar.gz") makedepends=('ppc-pkg-config' 'dkp-toolchain-vars') groups=('ppc-portlibs') prepare() { cd libconfig-${pkgver} source /opt/devkitpro/ppcvars.sh powerpc-eabi-cmake -B _build -S . -GNinja \ -DCMAKE_INSTALL_PREFIX=${PORTLIBS_PREFIX} \ -DBUILD_EXAMPLES=OFF \ -DBUILD_TESTS=OFF \ -DBUILD_SHARED_LIBS=OFF } build() { cd libconfig-${pkgver} source /opt/devkitpro/ppcvars.sh powerpc-eabi-cmake --build _build } package() { cd libconfig-$pkgver source /opt/devkitpro/ppcvars.sh DESTDIR="$pkgdir" powerpc-eabi-cmake --install _build # license install -Dm644 COPYING.LIB "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING.LIB } sha256sums=('e95798d2992a66ecd547ce3651d7e10642ff2211427c43a7238186ff4c372627') ================================================ FILE: ppc/libexpat/PKGBUILD ================================================ pkgname=ppc-libexpat pkgver=2.5.0 pkgrel=1 pkgdesc="Expat, a stream-oriented XML parser library written in C." arch=('any') url="https://libexpat.github.io/" license=('MIT') options=(!strip libtool staticlibs) groups=("ppc-portlibs") source=("https://github.com/libexpat/libexpat/releases/download/R_${pkgver//./_}/expat-$pkgver.tar.bz2") sha256sums=('6f0e6e01f7b30025fa05c85fdad1e5d0ec7fd35d9f61b22f34998de11969ff67') makedepends=('dkp-toolchain-vars' 'ppc-pkg-config') build() { cd expat-$pkgver source /opt/devkitpro/ppcvars.sh ./configure \ --prefix="${PORTLIBS_PREFIX}" \ --host="powerpc-eabi" \ --disable-shared --enable-static make } package() { cd expat-$pkgver source /opt/devkitpro/ppcvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: ppc/libfribidi/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: carstene1ns pkgname=ppc-libfribidi pkgver=1.0.16 pkgrel=1 pkgdesc='Free Implementation of the Unicode Bidirectional Algorithm (for Nintendo Gamecube/Wii homebrew development)' arch=('any') url="https://github.com/fribidi/fribidi" license=('LGPL2.1') options=(!strip staticlibs) makedepends=('ppc-pkg-config' 'dkp-toolchain-vars' 'dkp-meson-scripts') source=( "https://github.com/fribidi/fribidi/releases/download/v$pkgver/fribidi-$pkgver.tar.xz" "fribidi-ansi.patch::https://github.com/fribidi/fribidi/commit/b28f43bd3e8e31a5967830f721bab218c1aa114c.patch" ) groups=('ppc-portlibs') prepare() { cd fribidi-$pkgver patch -Np1 -i $srcdir/fribidi-ansi.patch } build() { cd fribidi-$pkgver source /opt/devkitpro/ppcvars.sh /opt/devkitpro/meson-cross.sh ppc ../crossfile.txt \ -Dbin=false -Dtests=false -Ddeprecated=false -Ddocs=false \ build } package() { cd fribidi-$pkgver source /opt/devkitpro/ppcvars.sh DESTDIR="$pkgdir" meson install -C build # remove documentation rm -fr "$pkgdir"${PORTLIBS_PREFIX}/share } sha256sums=('1b1cde5b235d40479e91be2f0e88a309e3214c8ab470ec8a2744d82a5a9ea05c' '8165dea3622f8e99611ff32d18bca284f41c1f5b105b3988f87c1dc5e9e7fafa') ================================================ FILE: ppc/libgd/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Ash Logan pkgname=ppc-libgd pkgver=2.3.3 pkgrel=3 pkgdesc="Library for the dynamic creation of images" url="https://libgd.github.io" license=("custom") arch=("any") depends=("devkitPPC" "ppc-libjpeg-turbo" "ppc-libpng" "ppc-freetype" "ppc-harfbuzz") makedepends=("ppc-pkg-config" "dkp-toolchain-vars") options=("!buildflags" "staticlibs" "libtool" "!strip") source=("https://github.com/libgd/libgd/releases/download/gd-$pkgver/libgd-$pkgver.tar.xz" "libgd-${pkgver}.patch") groups=('ppc-portlibs') prepare() { cd libgd-$pkgver patch -Np1 -i ${srcdir}/libgd-${pkgver}.patch ./bootstrap.sh } build() { cd libgd-$pkgver source /opt/devkitpro/ppcvars.sh export CPPFLAGS="$(CPPFLAGS) -DSSIZE_MAX=INT_MAX" ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi --disable-shared --enable-static make } package() { cd libgd-$pkgver source /opt/devkitpro/ppcvars.sh make DESTDIR="$pkgdir" install install -Dm644 COPYING "$pkgdir/$PORTLIBS_PREFIX/licenses/$pkgname/COPYING" # These binaries all end up for PowerPC, so we shouldn't keep them rm -rf "$pkgdir/$PORTLIBS_PREFIX/bin" } sha256sums=('3fe822ece20796060af63b7c60acb151e5844204d289da0ce08f8fdf131e5a61' '87eee942a5b8de80b9f91f4c98220335bcc7fb4d80fcbecea5704e76ac067517') ================================================ FILE: ppc/libgd/libgd-2.3.3.patch ================================================ diff -NBaur libgd-2.3.3.orig/src/gd_errors.h libgd-2.3.3/src/gd_errors.h --- libgd-2.3.3.orig/src/gd_errors.h 2021-09-11 05:41:44.000000000 +0100 +++ libgd-2.3.3/src/gd_errors.h 2023-05-01 10:58:32.797327239 +0100 @@ -1,9 +1,6 @@ #ifndef GD_ERRORS_H #define GD_ERRORS_H -#ifndef _WIN32 -# include -#else /* * priorities/facilities are encoded into a single 32-bit quantity, where the * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility @@ -21,7 +18,6 @@ # define LOG_NOTICE 5 /* normal but significant condition */ # define LOG_INFO 6 /* informational */ # define LOG_DEBUG 7 /* debug-level messages */ -#endif /* LOG_EMERG system is unusable diff -NBaur libgd-2.3.3.orig/src/Makefile.am libgd-2.3.3/src/Makefile.am --- libgd-2.3.3.orig/src/Makefile.am 2021-09-11 05:43:11.000000000 +0100 +++ libgd-2.3.3/src/Makefile.am 2023-05-01 10:59:31.674301747 +0100 @@ -1,44 +1,7 @@ ## Process this file with automake to produce Makefile.in -*-Makefile-*- -bin_PROGRAMS = gdcmpgif -check_PROGRAMS = gifanimtest - -if HAVE_LIBPNG -bin_PROGRAMS += gdtopng pngtogd webpng -check_PROGRAMS += circletexttest fontsizetest fontwheeltest gddemo testac -if HAVE_LIBZ -bin_PROGRAMS += gdparttopng gd2topng pngtogd2 -check_PROGRAMS += gdtest -endif -endif - -if HAVE_LIBJPEG -if !HAVE_LIBPNG -check_PROGRAMS += fontsizetest fontwheeltest -endif -endif - -if HAVE_LIBFONTCONFIG -check_PROGRAMS += fontconfigtest -endif - -if HAVE_LIBFREETYPE -if HAVE_LIBJPEG -bin_PROGRAMS += annotate -endif -check_PROGRAMS += gdtestft testtr -endif - -if HAVE_LIBZ -bin_PROGRAMS += gd2copypal gd2togif giftogd2 -endif - bin_SCRIPTS = bdftogd -if HAVE_LIBZ -check_PROGRAMS += gd2time -endif - EXTRA_DIST = \ bdftogd \ demoin.png \ ================================================ FILE: ppc/libjpeg-turbo/.gitignore ================================================ ppc-libjpeg-turbo ================================================ FILE: ppc/libjpeg-turbo/PKGBUILD ================================================ # Maintainer: WinterMute _libname=libjpeg-turbo pkgname=ppc-${_libname} pkgver=3.1.4.1 pkgrel=1 pkgdesc='The TurboJPEG library.' arch=('any') url='https://github.com/libjpeg-turbo/libjpeg-turbo' license=('IJG') options=(!buildflags !strip staticlibs) source=("${_libname}-${pkgver}.tar.gz::${url}/archive/refs/tags/${pkgver}.tar.gz") makedepends=( 'devkitppc-cmake' 'dkp-toolchain-vars' 'ppc-pkg-config' ) groups=('ppc-portlibs') build() { cd "${_libname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" powerpc-eabi-cmake \ -B build \ -DCMAKE_INSTALL_PREFIX="${PORTLIBS_PREFIX}" \ -DENABLE_SHARED=OFF \ -DHAVE_THREAD_LOCAL=OFF \ -DWITH_SIMD=OFF \ -DWITH_TESTS=OFF \ -DWITH_TOOLS=OFF make -C build } package() { cd "${_libname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" make -C build install DESTDIR="${pkgdir}" # license install -Dm 644 -t "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}" LICENSE.md # remove useless stuff rm -r "${pkgdir}${PORTLIBS_PREFIX}/share" } sha256sums=('a7da42b640377c2a9a9665e2c4b0ea60cd5599afb48c2521e6df0c9dc9d15a25') ================================================ FILE: ppc/liblzma/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=ppc-liblzma pkgver=5.8.2 pkgrel=1 pkgdesc='A compression library with an API similar to that of zlib.' arch=('any') url='https://tukaani.org' license=('GPL') options=(!strip libtool staticlibs) source=("https://tukaani.org/xz/xz-${pkgver}.tar.xz") makedepends=('ppc-pkg-config' 'dkp-toolchain-vars') groups=('ppc-portlibs') build() { cd xz-$pkgver source /opt/devkitpro/ppcvars.sh ./configure --prefix=${PORTLIBS_PREFIX} --host=powerpc-eabi \ --enable-static --disable-shared --disable-threads \ --disable-lzma-links --disable-xz --disable-xzdec \ --disable-lzmadec --disable-lzmainfo --disable-nls \ --disable-scripts --disable-doc make } package() { cd xz-$pkgver source /opt/devkitpro/ppcvars.sh make DESTDIR="$pkgdir" install rm -fr "$pkgdir"${PORTLIBS_PREFIX}/bin } sha256sums=('890966ec3f5d5cc151077879e157c0593500a522f413ac50ba26d22a9a145214') ================================================ FILE: ppc/libmad/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Ash Logan pkgname=ppc-libmad pkgver=0.15.1b pkgrel=2 pkgdesc="High-quality MPEG audio decoder" url="https://www.underbit.com/products/mad/" license=("GPLv2") arch=("any") depends=("devkitPPC") makedepends=("ppc-pkg-config" "dkp-toolchain-vars") options=("!buildflags" "staticlibs" "libtool" "!strip") source=("ftp://ftp.mars.org/pub/mpeg/libmad-${pkgver}.tar.gz" "frame_length.patch" "pkg-config.patch" "optimise.diff") sha256sums=("bbfac3ed6bfbc2823d3775ebb931087371e142bb0e9bb1bee51a76a6e0078690" "e54439c7efa6fc7272923d8507d79ee2992b115225baed1c47d1704e442e3c24" "0d22d5fe2785502ab1a731e185ad7ccbcdd575220337a99a36683aa9aaeb8072" "269505f22d700f3f00bcc97706f75889fbc6f7acf99cf068f0939b287bb50966") groups=('ppc-portlibs') prepare() { cd libmad-$pkgver patch -p1 -i "$srcdir/pkg-config.patch" patch -p1 -i "$srcdir/frame_length.patch" patch -p1 -i "$srcdir/optimise.diff" autoreconf -fi } build() { cd libmad-$pkgver source /opt/devkitpro/ppcvars.sh ./configure --prefix="$PORTLIBS_PREFIX" --host=powerpc-eabi --disable-shared make } package() { cd libmad-$pkgver source /opt/devkitpro/ppcvars.sh make DESTDIR="$pkgdir" install install -Dm644 COPYRIGHT "$pkgdir/$PORTLIBS_PREFIX/licenses/$pkgname/COPYRIGHT" } ================================================ FILE: ppc/libmad/frame_length.patch ================================================ ; https://git.archlinux.org/svntogit/packages.git/tree/trunk/frame_length.diff?h=packages/libmad ; You can calculate where the next frame will start depending on things ; like the bitrate. See mad_header_decode(). It seems that when decoding ; the frame you can go past that boundary. This attempts to catch those cases, ; but might not catch all of them. ; For more info see http://bugs.debian.org/508133 Index: libmad-0.15.1b/layer12.c =================================================================== --- libmad-0.15.1b.orig/layer12.c 2008-12-23 21:38:07.000000000 +0100 +++ libmad-0.15.1b/layer12.c 2008-12-23 21:38:12.000000000 +0100 @@ -134,6 +134,12 @@ for (sb = 0; sb < bound; ++sb) { for (ch = 0; ch < nch; ++ch) { nb = mad_bit_read(&stream->ptr, 4); + if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame) + { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } if (nb == 15) { stream->error = MAD_ERROR_BADBITALLOC; @@ -146,6 +152,12 @@ for (sb = bound; sb < 32; ++sb) { nb = mad_bit_read(&stream->ptr, 4); + if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame) + { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } if (nb == 15) { stream->error = MAD_ERROR_BADBITALLOC; @@ -162,6 +174,12 @@ for (ch = 0; ch < nch; ++ch) { if (allocation[ch][sb]) { scalefactor[ch][sb] = mad_bit_read(&stream->ptr, 6); + if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame) + { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } # if defined(OPT_STRICT) /* @@ -187,6 +205,12 @@ frame->sbsample[ch][s][sb] = nb ? mad_f_mul(I_sample(&stream->ptr, nb), sf_table[scalefactor[ch][sb]]) : 0; + if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame) + { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } } } @@ -195,6 +219,12 @@ mad_fixed_t sample; sample = I_sample(&stream->ptr, nb); + if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame) + { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } for (ch = 0; ch < nch; ++ch) { frame->sbsample[ch][s][sb] = @@ -403,7 +433,15 @@ nbal = bitalloc_table[offsets[sb]].nbal; for (ch = 0; ch < nch; ++ch) + { allocation[ch][sb] = mad_bit_read(&stream->ptr, nbal); + if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame) + { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } + } } for (sb = bound; sb < sblimit; ++sb) { @@ -411,6 +449,13 @@ allocation[0][sb] = allocation[1][sb] = mad_bit_read(&stream->ptr, nbal); + + if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame) + { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } } /* decode scalefactor selection info */ @@ -419,6 +464,12 @@ for (ch = 0; ch < nch; ++ch) { if (allocation[ch][sb]) scfsi[ch][sb] = mad_bit_read(&stream->ptr, 2); + if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame) + { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } } } @@ -442,6 +493,12 @@ for (ch = 0; ch < nch; ++ch) { if (allocation[ch][sb]) { scalefactor[ch][sb][0] = mad_bit_read(&stream->ptr, 6); + if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame) + { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } switch (scfsi[ch][sb]) { case 2: @@ -452,11 +509,23 @@ case 0: scalefactor[ch][sb][1] = mad_bit_read(&stream->ptr, 6); + if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame) + { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } /* fall through */ case 1: case 3: scalefactor[ch][sb][2] = mad_bit_read(&stream->ptr, 6); + if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame) + { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } } if (scfsi[ch][sb] & 1) @@ -488,6 +557,12 @@ index = offset_table[bitalloc_table[offsets[sb]].offset][index - 1]; II_samples(&stream->ptr, &qc_table[index], samples); + if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame) + { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } for (s = 0; s < 3; ++s) { frame->sbsample[ch][3 * gr + s][sb] = @@ -506,6 +581,12 @@ index = offset_table[bitalloc_table[offsets[sb]].offset][index - 1]; II_samples(&stream->ptr, &qc_table[index], samples); + if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame) + { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } for (ch = 0; ch < nch; ++ch) { for (s = 0; s < 3; ++s) { Index: libmad-0.15.1b/layer3.c =================================================================== --- libmad-0.15.1b.orig/layer3.c 2008-12-23 21:38:07.000000000 +0100 +++ libmad-0.15.1b/layer3.c 2008-12-23 21:38:12.000000000 +0100 @@ -2608,6 +2608,12 @@ next_md_begin = 0; md_len = si.main_data_begin + frame_space - next_md_begin; + if (md_len + MAD_BUFFER_GUARD > MAD_BUFFER_MDLEN) + { + stream->error = MAD_ERROR_LOSTSYNC; + stream->sync = 0; + return -1; + } frame_used = 0; ================================================ FILE: ppc/libmad/optimise.diff ================================================ ; https://git.archlinux.org/svntogit/packages.git/tree/trunk/optimize.diff?h=packages/libmad Index: libmad-0.15.1b/configure.ac =================================================================== --- libmad-0.15.1b.orig/configure.ac 2008-03-07 20:31:23.000000000 +0000 +++ libmad-0.15.1b/configure.ac 2008-03-07 20:34:26.000000000 +0000 @@ -124,71 +124,7 @@ if test "$GCC" = yes then - if test -z "$arch" - then - case "$host" in - i386-*) ;; - i?86-*) arch="-march=i486" ;; - arm*-empeg-*) arch="-march=armv4 -mtune=strongarm1100" ;; - armv4*-*) arch="-march=armv4 -mtune=strongarm" ;; - powerpc-*) ;; - mips*-agenda-*) arch="-mcpu=vr4100" ;; - mips*-luxsonor-*) arch="-mips1 -mcpu=r3000 -Wa,-m4010" ;; - esac - fi - - case "$optimize" in - -O|"-O "*) - optimize="-O" - optimize="$optimize -fforce-mem" - optimize="$optimize -fforce-addr" - : #x optimize="$optimize -finline-functions" - : #- optimize="$optimize -fstrength-reduce" - optimize="$optimize -fthread-jumps" - optimize="$optimize -fcse-follow-jumps" - optimize="$optimize -fcse-skip-blocks" - : #x optimize="$optimize -frerun-cse-after-loop" - : #x optimize="$optimize -frerun-loop-opt" - : #x optimize="$optimize -fgcse" - optimize="$optimize -fexpensive-optimizations" - optimize="$optimize -fregmove" - : #* optimize="$optimize -fdelayed-branch" - : #x optimize="$optimize -fschedule-insns" - optimize="$optimize -fschedule-insns2" - : #? optimize="$optimize -ffunction-sections" - : #? optimize="$optimize -fcaller-saves" - : #> optimize="$optimize -funroll-loops" - : #> optimize="$optimize -funroll-all-loops" - : #x optimize="$optimize -fmove-all-movables" - : #x optimize="$optimize -freduce-all-givs" - : #? optimize="$optimize -fstrict-aliasing" - : #* optimize="$optimize -fstructure-noalias" - - case "$host" in - arm*-*) - optimize="$optimize -fstrength-reduce" - ;; - mips*-*) - optimize="$optimize -fstrength-reduce" - optimize="$optimize -finline-functions" - ;; - i?86-*) - optimize="$optimize -fstrength-reduce" - ;; - powerpc-apple-*) - # this triggers an internal compiler error with gcc2 - : #optimize="$optimize -fstrength-reduce" - - # this is really only beneficial with gcc3 - : #optimize="$optimize -finline-functions" - ;; - *) - # this sometimes provokes bugs in gcc 2.95.2 - : #optimize="$optimize -fstrength-reduce" - ;; - esac - ;; - esac + optimize="-O2" fi case "$host" in ================================================ FILE: ppc/libmad/pkg-config.patch ================================================ diff -Naur libmad-0.15.1b.orig/configure.ac libmad-0.15.1b/configure.ac --- libmad-0.15.1b.orig/configure.ac 2004-01-23 10:41:32.000000000 +0100 +++ libmad-0.15.1b/configure.ac 2015-10-12 05:51:12.514078692 +0200 @@ -26,7 +26,7 @@ AC_CONFIG_SRCDIR([decoder.h]) -AM_INIT_AUTOMAKE +AM_INIT_AUTOMAKE([foreign]) AM_CONFIG_HEADER([config.h]) @@ -429,5 +429,5 @@ dnl AC_SUBST(LTLIBOBJS) AC_CONFIG_FILES([Makefile msvc++/Makefile \ - libmad.list]) + libmad.list mad.pc]) AC_OUTPUT diff -Naur libmad-0.15.1b.orig/mad.pc.in libmad-0.15.1b/mad.pc.in --- libmad-0.15.1b.orig/mad.pc.in 1970-01-01 01:00:00.000000000 +0100 +++ libmad-0.15.1b/mad.pc.in 2015-10-12 05:31:43.851805494 +0200 @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: MAD +Description: libmad - MPEG audio decoder library +Version: @VERSION@ +Libs: -L${libdir} -lmad +Cflags: diff -Naur libmad-0.15.1b.orig/Makefile.am libmad-0.15.1b/Makefile.am --- libmad-0.15.1b.orig/Makefile.am 2004-02-17 03:02:03.000000000 +0100 +++ libmad-0.15.1b/Makefile.am 2015-10-12 05:31:43.831805227 +0200 @@ -33,9 +33,12 @@ minimad_INCLUDES = minimad_LDADD = libmad.la -EXTRA_DIST = mad.h.sed \ +EXTRA_DIST = mad.h.sed mad.pc.in \ CHANGES COPYRIGHT CREDITS README TODO VERSION +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA= mad.pc + exported_headers = version.h fixed.h bit.h timer.h stream.h frame.h \ synth.h decoder.h ================================================ FILE: ppc/libmodplug/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=ppc-libmodplug pkgver=0.8.9.0 pkgrel=3 pkgdesc='Play various .mod formats' arch=('any') url='http://modplug-xmms.sourceforge.net/' license=(public domain) options=(!strip libtool staticlibs) depends=("ppc-zlib") source=( "https://sourceforge.net/projects/modplug-xmms/files/libmodplug/$pkgver/libmodplug-$pkgver.tar.gz" ) sha256sums=( '457ca5a6c179656d66c01505c0d95fafaead4329b9dbaa0f997d00a3508ad9de' ) groups=("ppc-portlibs") build() { cd libmodplug-$pkgver source /opt/devkitpro/ppcvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static make } package() { cd libmodplug-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: ppc/libogg/PKGBUILD ================================================ # Maintainer: Dave Murphy _pkgname=libogg pkgname=ppc-${_pkgname} pkgver=1.3.6 pkgrel=1 pkgdesc='Library to parse Ogg files.' arch=('any') url='https://wiki.xiph.org/Ogg' license=(Xiph.org) options=(!buildflags !strip libtool staticlibs) groups=('ppc-portlibs') makedepends=( 'dkp-toolchain-vars' 'ppc-pkg-config' ) source=("https://downloads.xiph.org/releases/ogg/${_pkgname}-${pkgver}.tar.gz") build() { cd "${_pkgname}-$pkgver" source "${DEVKITPRO}/ppcvars.sh" ./configure \ --prefix="${PORTLIBS_PREFIX}" \ --host=powerpc-eabi \ --disable-shared \ --enable-static make } package() { cd "${_pkgname}-$pkgver" source "${DEVKITPRO}/ppcvars.sh" make install DESTDIR="$pkgdir" install -Dm644 -t "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}" COPYING # remove useless documentation rm -r "${pkgdir}${PORTLIBS_PREFIX}/share/doc" } sha256sums=('83e6704730683d004d20e21b8f7f55dcb3383cdf84c0daedf30bde175f774638') ================================================ FILE: ppc/libopus/PKGBUILD ================================================ _pkgname=opus pkgname=ppc-lib${_pkgname} pkgver=1.6.1 pkgrel=1 pkgdesc='Reference implementation of the Opus codec' arch=('any') url='https://opus-codec.org/' license=(BSD) options=(!buildflags !strip libtool staticlibs) depends=('devkitPPC') makedepends=( 'dkp-toolchain-vars' 'ppc-pkg-config' ) groups=('ppc-portlibs') source=("https://downloads.xiph.org/releases/${_pkgname}/${_pkgname}-${pkgver}.tar.gz") build() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" ./configure \ --host=powerpc-eabi \ --prefix="${PORTLIBS_PREFIX}" \ --disable-shared \ --enable-static \ --disable-doc \ --disable-extra-programs make } package() { cd "${_pkgname}-${pkgver}" make install DESTDIR="$pkgdir" # install license install -Dm 644 -t "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}" COPYING # remove autoconf macros rm -rfv "${pkgdir}${PORTLIBS_PREFIX}/share" } sha256sums=('6ffcb593207be92584df15b32466ed64bbec99109f007c82205f0194572411a1') ================================================ FILE: ppc/libpng/.gitignore ================================================ ppc-libpng ================================================ FILE: ppc/libpng/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: carstene1ns - http://git.io/ctPKG # Contributor: Aaron Lindsay _libname=libpng pkgname=ppc-${_libname} pkgver=1.6.55 pkgrel=1 pkgdesc='PNG format graphic files library (for Nintendo Gamecube/Wii homebrew development)' arch=('any') url='http://www.libpng.org' license=('libpng-2.0') options=(!strip libtool staticlibs) depends=('ppc-zlib') makedepends=( 'dkp-toolchain-vars' 'ppc-pkg-config' ) groups=('ppc-portlibs') source=("https://download.sourceforge.net/libpng/${_libname}-${pkgver}.tar.gz") build() { cd "${_libname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" ./configure \ --prefix="${PORTLIBS_PREFIX}" \ --host=powerpc-eabi \ --disable-tools \ --disable-tests \ --disable-shared \ --enable-static make } package() { cd "${_libname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" make install LN_S=cp DESTDIR="$pkgdir" # license install -Dm644 LICENSE "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}/LICENSE" # remove useless stuff rm -r "${pkgdir}${PORTLIBS_PREFIX}/share" } sha256sums=('4b0abab6d219e95690ebe4db7fc9aa95f4006c83baaa022373c0c8442271283d') ================================================ FILE: ppc/libtheora/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=ppc-libtheora pkgver=1.2.0alpha1 pkgrel=1 pkgdesc='Free and open video compression codec from the Xiph.org Foundation' arch=('any') url='https://www.theora.org/' license=(Xiph.org) options=(!strip libtool staticlibs) source=("https://ftp.osuosl.org/pub/xiph/releases/theora/libtheora-${pkgver}.tar.gz" "config.sub" "config.guess") sha256sums=( '538305e6efa484ba740616b521f0d8c4428a0a995193c5e6af9b20f488f3c497' '72e02ea93447038f8ced24f296b31e0f397bbcc6b32abdcf9b38c80f153433fd' 'fbc2337aa59a204f5d74743b82c8be7aab8b39853b4e54a888008f70430c4305' ) makedepends=('ppc-pkg-config' 'dkp-toolchain-vars') depends=('ppc-libogg' 'ppc-libvorbis' 'ppc-libpng') groups=('ppc-portlibs') build() { cd libtheora-$pkgver source /opt/devkitpro/ppcvars.sh cp $srcdir/config.sub $srcdir/config.guess . ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static \ --disable-encode --disable-examples make } package() { cd libtheora-$pkgver source /opt/devkitpro/ppcvars.sh make DESTDIR="$pkgdir" install install -Dm644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING # remove useless documentation rm -r "$pkgdir"${PORTLIBS_PREFIX}/share/doc } ================================================ FILE: ppc/libtheora/config.guess ================================================ #! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2015 Free Software Foundation, Inc. timestamp='2015-08-20' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ /sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || \ echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` machine=${arch}${endian}-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case "${UNAME_MACHINE_ARCH}" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; *:Sortix:*:*) echo ${UNAME_MACHINE}-unknown-sortix exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; e2k:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: ================================================ FILE: ppc/libtheora/config.sub ================================================ #! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2015 Free Software Foundation, Inc. timestamp='2015-08-20' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | e2k | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; asmjs) basic_machine=asmjs-unknown ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; leon-*|leon[3-9]-*) basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: ================================================ FILE: ppc/libvorbis/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=ppc-libvorbis pkgver=1.3.7 pkgrel=1 pkgdesc='A patent-clear, fully open, general purpose audio encoding format standard that rivals or even surpasses the 'upcoming' generation of proprietary codecs (AAC and TwinVQ, also known as VQF).' arch=('any') url='https://wiki.xiph.org/Vorbis' license=(Xiph.org) options=(!strip libtool staticlibs) depends=('ppc-libogg') makedepends=('dkp-toolchain-vars' 'ppc-pkg-config') groups=('ppc-portlibs') source=("https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-$pkgver.tar.gz") sha256sums=('0e982409a9c3fc82ee06e08205b1355e5c6aa4c36bca58146ef399621b0ce5ab') build() { cd libvorbis-$pkgver source /opt/devkitpro/ppcvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static make } package() { cd libvorbis-$pkgver source /opt/devkitpro/ppcvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: ppc/libvorbisidec/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=ppc-libvorbisidec pkgver=1.2.1 pkgrel=2 pkgdesc='Fixed-point version of the Ogg Vorbis decoder (for Nintendo Gamecube/wii homebrew development)' arch=('any') url="http://xiph.org" license=('LGPL') options=(!strip libtool staticlibs) source=("https://downloads.devkitpro.org/packages/sources/libvorbisidec-${pkgver}.tar.bz2") sha256sums=('1afbc18e0104ca8c9e9943cfcfa995ea0100bf246c425962770d455d4ad03c65') makedepends=('ppc-pkg-config' 'dkp-toolchain-vars') depends=('ppc-libogg') groups=('ppc-portlibs') build() { cd libvorbisidec-$pkgver source /opt/devkitpro/ppcvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi make } package() { cd libvorbisidec-$pkgver source /opt/devkitpro/ppcvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING } ================================================ FILE: ppc/libwebp/PKGBUILD ================================================ _pkgname=libwebp pkgname=ppc-${_pkgname} pkgver=1.6.0 pkgrel=1 pkgdesc='A library to encode and decode images in WebP format.' arch=('any') url='https://chromium.googlesource.com/webm/libwebp/' license=('BSD') options=(!buildflags !strip libtool staticlibs) depends=('devkitPPC') makedepends=('dkp-toolchain-vars') groups=('ppc-portlibs') source=("https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-$pkgver.tar.gz") build() { cd "${srcdir}/${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" ./configure \ --prefix="${PORTLIBS_PREFIX}" \ --host=powerpc-eabi \ --disable-shared \ --enable-static \ --enable-libwebpdecoder \ --enable-libwebpdemux \ --enable-libwebpmux make } package() { cd "${srcdir}/${_pkgname}-${pkgver}" make install DESTDIR="${pkgdir}" install -Dm 644 COPYING -t "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}" # Remove example programs and manual. rm -rfv "${pkgdir}/${PORTLIBS_PREFIX}/bin" rm -rfv "${pkgdir}/${PORTLIBS_PREFIX}/share" } sha256sums=('e4ab7009bf0629fd11982d4c2aa83964cf244cffba7347ecd39019a9e38c4564') ================================================ FILE: ppc/libzip/.gitignore ================================================ ppc-libzip ================================================ FILE: ppc/libzip/PKGBUILD ================================================ pkgname=ppc-libzip pkgver=1.10.1 pkgrel=1 pkgdesc='Library for reading, creating, and modifying zip archives' arch=('any') url='https://libzip.org/' license=('BSD') options=(!strip libtool staticlibs) groups=('ppc-portlibs') source=("https://libzip.org/download/libzip-${pkgver}.tar.gz") sha256sums=('9669ae5dfe3ac5b3897536dc8466a874c8cf2c0e3b1fdd08d75b273884299363') makedepends=('dkp-toolchain-vars' 'devkitppc-cmake') depends=('ppc-zlib' 'ppc-bzip2') build() { cd libzip-$pkgver source /opt/devkitpro/devkitppc.sh source /opt/devkitpro/ppcvars.sh /opt/devkitpro/devkitPPC/bin/powerpc-eabi-cmake \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DCMAKE_PREFIX_PATH=$PORTLIBS_PREFIX \ -DENABLE_BZIP2=ON \ -DENABLE_LZMA=OFF \ -DENABLE_ZSTD=OFF \ -DENABLE_GNUTLS=OFF \ -DENABLE_OPENSSL=OFF \ -DENABLE_MBEDTLS=OFF \ -DBUILD_TOOLS=OFF \ -DBUILD_REGRESS=OFF \ -DBUILD_EXAMPLES=OFF \ -DBUILD_DOC=OFF \ . make } package() { cd libzip-$pkgver source /opt/devkitpro/devkitppc.sh make DESTDIR="$pkgdir" install install -Dm644 LICENSE "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/LICENSE } ================================================ FILE: ppc/lua51/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgsuffix=51 pkgname=("ppc-liblua${pkgsuffix}") pkgvermaj=5.1 pkgver=${pkgvermaj}.5 pkgrel=2 pkgdesc="Powerful lightweight programming language designed for extending applications" arch=('any') license=('MIT') url="https://www.lua.org/" options=(!strip libtool staticlibs) source=(${url}/ftp//lua-${pkgver}.tar.gz) makedepends=('devkitPPC' 'ppc-pkg-config' 'dkp-toolchain-vars') groups=('ppc-portlibs') build() { source /opt/devkitpro/ppcvars.sh make -C "${srcdir}/lua-${pkgver}" \ CC=powerpc-eabi-gcc \ AR="powerpc-eabi-ar rcu" \ RANLIB=powerpc-eabi-ranlib \ LUA_A=liblua${pkgvermaj}.a \ ALL_T=liblua${pkgvermaj}.a \ CPPFLAGS="${CPPFLAGS} ${CFLAGS}" \ PLAT=generic } package() { source /opt/devkitpro/ppcvars.sh cd ${srcdir}/lua-${pkgver} echo $pkgdir echo $PORTLIBS_PREFIX install -dm 755 ${pkgdir}/${PORTLIBS_PREFIX}/include/lua${pkgvermaj} install -m 644 src/lua.h src/luaconf.h src/lualib.h src/lauxlib.h ${pkgdir}/${PORTLIBS_PREFIX}/include/lua${pkgvermaj} sed -i "s,prefix= /usr/local,prefix= ${PORTLIBS_PREFIX}," etc/lua.pc sed -i "s,includedir=\${prefix}/include,includedir=\${prefix}/include/lua${pkgvermaj}," etc/lua.pc sed -i "s,-llua,-llua${pkgvermaj}," etc/lua.pc install -dm 755 ${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig install -m 644 etc/lua.pc ${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/lua${pkgsuffix}.pc install -m 644 src/liblua${pkgvermaj}.a ${pkgdir}/${PORTLIBS_PREFIX}/lib } sha256sums=('2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333') ================================================ FILE: ppc/lz4/PKGBUILD ================================================ # Maintainer: TurtleP pkgname=ppc-lz4 pkgver=1.9.3 pkgrel=1 pkgdesc="Very fast lossless compression algorithm" arch=("any") url="https://lz4.github.io/lz4/" license=("BSD" "GPL2") options=("staticlibs" "!strip") source=("https://github.com/lz4/lz4/archive/refs/tags/v${pkgver}.zip") sha256sums=("4ec935d99aa4950eadfefbd49c9fad863185ac24c32001162c44a683ef61b580") makedepends=("dkp-toolchain-vars") groups=("ppc-portlibs") package() { source /opt/devkitpro/ppcvars.sh cd lz4-${pkgver}/lib make BUILD_SHARED=no \ PREFIX=${PORTLIBS_PREFIX} \ DESTDIR=${pkgdir} \ install } ================================================ FILE: ppc/mpg123/.gitignore ================================================ ================================================ FILE: ppc/mpg123/PKGBUILD ================================================ # Maintainer: Gabriel Kind _pkgname=mpg123 pkgname=ppc-${_pkgname} pkgver=1.33.4 pkgrel=1 pkgdesc="A real time MPEG audio decoder for layer 1, 2 and 3" arch=('any') url="http://sourceforge.net/projects/mpg123" license=('LGPL-2.1-only') options=(!buildflags !strip libtool staticlibs) makedepends=( 'devkitPPC' 'dkp-toolchain-vars' 'ppc-pkg-config' ) groups=('ppc-portlibs') source=("http://downloads.sourceforge.net/sourceforge/mpg123/${_pkgname}-${pkgver}.tar.bz2") build() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" ./configure \ --prefix="${PORTLIBS_PREFIX}" \ --host=powerpc-eabi \ --disable-shared \ --enable-static \ --disable-components \ --enable-libmpg123 \ --enable-libsyn123 \ --disable-fifo \ --disable-int-quality \ --disable-ipv6 \ --disable-network \ --with-cpu=generic make } package() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" make install DESTDIR="$pkgdir" # install license install -Dm 644 -t "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}" COPYING # remove empty bin dir rm -rfv "${pkgdir}${PORTLIBS_PREFIX}/bin" } sha256sums=('3ae8c9ff80a97bfc0e22e89fbcd74687eca4fc1db315b12607f27f01cb5a47d9') ================================================ FILE: ppc/mxml/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: carstene1ns - http://git.io/ctPKG # Contributor: Aaron Lindsay pkgname=ppc-mxml pkgver=3.3.1 pkgrel=1 pkgdesc='XML parsing library' arch=('any') url='https://github.com/michaelrsweet/mxml' license=('custom') options=(!strip libtool staticlibs) source=("${url}/releases/download/v${pkgver}/mxml-${pkgver}.tar.gz") sha256sums=('0c663ed1fe393b5619f80101798202eea43534abd7c8aff389022fd8c1dacc32') makedepends=('ppc-pkg-config' 'dkp-toolchain-vars') groups=('ppc-portlibs') build() { cd mxml-${pkgver} source /opt/devkitpro/ppcvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static --disable-threads make } package() { source /opt/devkitpro/ppcvars.sh cd mxml-${pkgver} make BUILDROOT="$pkgdir" install # license install -Dm644 LICENSE "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/LICENSE # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share } ================================================ FILE: ppc/ode/PKGBUILD ================================================ # Maintainer: davidgfnet pkgname=ppc-ode pkgver=0.16.4 pkgrel=1 pkgdesc='High performance library for simulating rigid body dynamics' arch=('any') url='http://ode.org/' license=('BSD') options=(!strip libtool staticlibs) source=("https://bitbucket.org/odedevs/ode/downloads/ode-${pkgver}.tar.gz") makedepends=('dkp-toolchain-vars') sha256sums=('c741dbf49bfc468ce2964824e5bc3f906ea956b1ae3594c50d351c383f03c413') groups=('ppc-portlibs') build() { cd ode-$pkgver source /opt/devkitpro/ppcvars.sh # Demos depend on GL and X11, disable since they are not useful to us. # Disable threads since there's no pthread support on Wii/GC ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-demos --enable-static --disable-threading-intf } package() { cd ode-$pkgver source /opt/devkitpro/ppcvars.sh make install DESTDIR="$pkgdir" } sha256sums=('71037b8281c6c86b0a55729f90d5db697abe4cbec1d8118157e00d48ec253467') ================================================ FILE: ppc/opusfile/PKGBUILD ================================================ # Maintainer: Dave Murphy _pkgname=opusfile pkgname=ppc-${_pkgname} pkgver=0.12 pkgrel=2 pkgdesc='Library for opening, seeking, and decoding .opus files' arch=('any') url='https://opus-codec.org/' license=(BSD-3-Clause) options=(!buildflags !strip libtool staticlibs) groups=('ppc-portlibs') depends=( 'ppc-libogg' 'ppc-libopus' ) makedepends=( 'dkp-toolchain-vars' 'ppc-pkg-config' ) source=("https://downloads.xiph.org/releases/opus/${_pkgname}-${pkgver}.tar.gz") build() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" ./configure \ --prefix="${PORTLIBS_PREFIX}" \ --host=powerpc-eabi \ --disable-shared \ --enable-static \ --enable-fixed-point \ --disable-examples \ --disable-doc \ --disable-http make } package() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" make install DESTDIR="$pkgdir" # install license install -Dm 644 -t "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}" COPYING # remove docs rm -rfv "${pkgdir}${PORTLIBS_PREFIX}/share" } sha256sums=('118d8601c12dd6a44f52423e68ca9083cc9f2bfe72da7a8c1acb22a80ae3550b') ================================================ FILE: ppc/pkg-config/.gitignore ================================================ ppc-pkg-config ================================================ FILE: ppc/pkg-config/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=ppc-pkg-config pkgver=0.28 pkgrel=5 pkgdesc='pkg-config wrapper (for Nintendo Gamecube/Wii homebrew development)' arch=('any') url='http://devkitpro.org/' source=('pkg-config.in') sha256sums=('e435edc486112e1bdb0c96061760bd8bc62b99b2a3f3ce59d819f39e734f9bd3') groups=('ppc-dev' 'gamecube-dev' 'wii-dev' 'wiiu-dev') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/ppc/bin cp "$srcdir"/pkg-config.in "$pkgdir"/opt/devkitpro/portlibs/ppc/bin/powerpc-eabi-pkg-config } ================================================ FILE: ppc/pkg-config/pkg-config.in ================================================ #!/usr/bin/env bash command -v pkg-config >/dev/null 2>&1 || { echo >&2 "I require pkg-config but it's not installed. Aborting."; exit 1; } # reset pkg-config variables to ensure we're not polluted by host libraries export PKG_CONFIG_DIR= export PKG_CONFIG_PATH= export PKG_CONFIG_SYSROOT_DIR= export PKG_CONFIG_LIBDIR=${DEVKITPRO}/portlibs/ppc/lib/pkgconfig [[ "$1" == '--version' ]] && exec pkg-config --version exec pkg-config --static "$@" ================================================ FILE: ppc/yaml_cpp/PKGBUILD ================================================ _realname=yaml_cpp pkgname=ppc-${_realname} pkgver=0.8.0 pkgrel=1 pkgdesc='A YAML parser and emitter in C++ matching the YAML 1.2 spec.' arch=('any') url='https://github.com/jbeder/yaml-cpp' license=('zlib') options=(!strip libtool staticlibs) source=( ${_realname}-${pkgver}.tar.gz::${url}/archive/refs/tags/${pkgver}.tar.gz) makedepends=('devkitPPC' 'devkitppc-cmake') groups=('ppc-portlibs') build() { cd yaml-cpp-${pkgver} /opt/devkitpro/devkitPPC/bin/powerpc-eabi-cmake -B _build -S . -DCMAKE_INSTALL_PREFIX=/opt/devkitpro/portlibs/ppc -DYAML_CPP_BUILD_TOOLS=OFF -GNinja cmake --build _build --parallel } package() { cd yaml-cpp-${pkgver} DESTDIR="${pkgdir}" cmake --install _build } sha256sums=('fbe74bbdcee21d656715688706da3c8becfd946d92cd44705cc6098bb23b3a16') ================================================ FILE: ppc/zlib/.gitignore ================================================ ppc-zlib ================================================ FILE: ppc/zlib/PKGBUILD ================================================ # Maintainer: WinterMute _libname=zlib pkgname=ppc-${_libname} pkgver=1.3.1 pkgrel=1 pkgdesc='The zlib compresion library.' arch=('any') url='http://www.zlib.net' license=('zlib') options=(!strip libtool staticlibs) makedepends=('dkp-toolchain-vars') groups=('ppc-portlibs') source=("${url}/${_libname}-${pkgver}.tar.gz") build() { cd "${_libname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" CHOST=powerpc-eabi \ ./configure \ --prefix="${PORTLIBS_PREFIX}" \ --static make libz.a # only build library, no programs } package() { cd "${_libname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" make install DESTDIR="$pkgdir" # license install -Dm644 LICENSE "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}/LICENSE" # remove useless stuff rm -r "${pkgdir}${PORTLIBS_PREFIX}/share" } sha256sums=('9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23') ================================================ FILE: ppc/zstd/PKGBUILD ================================================ _pkgname=zstd pkgname=ppc-${_pkgname} pkgver=1.5.7 pkgrel=1 provides=("ppc-lib${_pkgname}=${pkgver}") conflicts=("ppc-lib${_pkgname}") pkgdesc='The Zstandard (zstd) compression library.' arch=('any') url='https://facebook.github.io/zstd/' license=('BSD' 'GPLv2') options=(!buildflags !strip staticlibs) depends=('devkitPPC') makedepends=( 'devkitppc-cmake' 'dkp-toolchain-vars' ) groups=('ppc-portlibs') source=( "https://github.com/facebook/zstd/releases/download/v${pkgver}/${_pkgname}-${pkgver}.tar.gz" "${_pkgname}-${pkgver}.patch" ) prepare() { patch -N -p 0 -i "${_pkgname}-${pkgver}.patch" } build() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" powerpc-eabi-cmake \ -DCMAKE_INSTALL_PREFIX="${PORTLIBS_PREFIX}" \ -DCMAKE_BUILD_TYPE=Release \ -DZSTD_BUILD_PROGRAMS=OFF \ -DZSTD_BUILD_SHARED=OFF \ -DZSTD_BUILD_STATIC=ON \ build/cmake make } package() { cd "${_pkgname}-${pkgver}" source "${DEVKITPRO}/ppcvars.sh" make install DESTDIR="$pkgdir" install -Dm 644 -t "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}" COPYING LICENSE } sha256sums=('eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3' '42eb0d49a01cab8cefcc4972a334c550a9572e1feee985baaa9af113d98a2425') ================================================ FILE: ppc/zstd/zstd-1.5.7.patch ================================================ --- zstd-1.5.7/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake.orig 2025-02-19 00:04:24.000000000 +0000 +++ zstd-1.5.7/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake 2025-02-19 00:04:24.000000000 +0000 @@ -50,10 +50,6 @@ endfunction() macro(ADD_ZSTD_COMPILATION_FLAGS) - # We set ZSTD_HAS_NOEXECSTACK if we are certain we've set all the required - # compiler flags to mark the stack as non-executable. - set(ZSTD_HAS_NOEXECSTACK false) - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" OR MINGW) #Not only UNIX but also WIN32 for MinGW # It's possible to select the exact standard used for compilation. # It's not necessary, but can be employed for specific purposes. @@ -77,24 +73,6 @@ if (CMAKE_BUILD_TYPE MATCHES "Debug") EnableCompilerFlag("-DDEBUGLEVEL=1" true true false) endif () - # Add noexecstack flags - # LDFLAGS - EnableCompilerFlag("-Wl,-z,noexecstack" false false true) - # CFLAGS & CXXFLAGS - EnableCompilerFlag("-Qunused-arguments" true true false) - EnableCompilerFlag("-Wa,--noexecstack" true true false) - # NOTE: Using 3 nested ifs because the variables are sometimes - # empty if the condition is false, and sometimes equal to false. - # This implicitly converts them to truthy values. There may be - # a better way to do this, but this reliably works. - if (${LD_FLAG_WL_Z_NOEXECSTACK}) - if (${C_FLAG_WA_NOEXECSTACK}) - if (${CXX_FLAG_WA_NOEXECSTACK}) - # We've succeeded in marking the stack as non-executable - set(ZSTD_HAS_NOEXECSTACK true) - endif() - endif() - endif() elseif (MSVC) # Add specific compilation flags for Windows Visual set(ACTIVATE_MULTITHREADED_COMPILATION "ON" CACHE BOOL "activate multi-threaded compilation (/MP flag)") --- zstd-1.5.7/build/cmake/lib/CMakeLists.txt.orig 2025-02-19 00:04:24.000000000 +0000 +++ zstd-1.5.7/build/cmake/lib/CMakeLists.txt 2025-02-19 00:04:24.000000000 +0000 @@ -39,7 +39,7 @@ if (MSVC) add_compile_options(-DZSTD_DISABLE_ASM) else () - if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|AMD64.*|x86_64.*|X86_64.*" AND ${ZSTD_HAS_NOEXECSTACK}) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|AMD64.*|x86_64.*|X86_64.*") set(DecompressSources ${DecompressSources} ${LIBRARY_DIR}/decompress/huf_decompress_amd64.S) else() add_compile_options(-DZSTD_DISABLE_ASM) @@ -233,7 +233,6 @@ set_target_properties( libzstd_static PROPERTIES - POSITION_INDEPENDENT_CODE On OUTPUT_NAME ${STATIC_LIBRARY_BASE_NAME}) if (ZSTD_FRAMEWORK) --- zstd-1.5.7/lib/common/xxhash.h.orig 2025-02-19 00:04:24.000000000 +0000 +++ zstd-1.5.7/lib/common/xxhash.h 2025-02-19 00:04:24.000000000 +0000 @@ -2253,9 +2253,9 @@ #ifndef XXH_FORCE_ALIGN_CHECK /* can be defined externally */ /* don't check on sizeopt, x86, aarch64, or arm when unaligned access is available */ -# if XXH_SIZE_OPT >= 1 || \ - defined(__i386) || defined(__x86_64__) || defined(__aarch64__) || defined(__ARM_FEATURE_UNALIGNED) \ - || defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM64) || defined(_M_ARM) /* visual */ +# if XXH_SIZE_OPT >= 1 \ + || defined(__i386) || defined(__x86_64__) || defined(__aarch64__) || defined(__ARM_FEATURE_UNALIGNED) || defined(__PPC__) \ + || defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM64) || defined(_M_ARM) || defined(_M_PPC) /* visual */ # define XXH_FORCE_ALIGN_CHECK 0 # else # define XXH_FORCE_ALIGN_CHECK 1 ================================================ FILE: switch/SDL2/.gitignore ================================================ switch-sdl2 ================================================ FILE: switch/SDL2/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=switch-sdl2 pkgver=2.28.5 pkgrel=4 pkgdesc="A library for portable low-level access to a video framebuffer, audio output, mouse, and keyboard (Nintendo Switch port)" arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') depends=('switch-mesa' 'libnx') source=("${url}/release/SDL2-${pkgver}.tar.gz" "SDL2-${pkgver}.patch") groups=('switch-portlibs' 'switch-sdl2') build() { cd SDL2-$pkgver source /opt/devkitpro/switchvars.sh patch -p1 -i $srcdir/SDL2-${pkgver}.patch ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static \ --enable-audio \ --enable-joystick \ --disable-power \ --disable-filesystem \ --enable-cpuinfo \ --enable-pthreads \ --enable-timers \ --enable-video make } package() { cd SDL2-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share } sha256sums=('332cb37d0be20cb9541739c61f79bae5a477427d79ae85e352089afdaf6666e4' 'eb2da665a014dc540ad3dfeb62b3f7c5e15ae090ebdd631fe8b78c1f272c7aa0') ================================================ FILE: switch/SDL2/SDL2-2.28.5.patch ================================================ diff --git a/.github/workflows/switch.yml b/.github/workflows/switch.yml new file mode 100644 index 000000000..f6e5babab --- /dev/null +++ b/.github/workflows/switch.yml @@ -0,0 +1,32 @@ +name: Build (Nintendo Switch) + +on: [push, pull_request] + +jobs: + switch: + runs-on: ubuntu-latest + container: + image: devkitpro/devkita64:latest + steps: + - uses: actions/checkout@v4 + - name: Configure + run: | + . /opt/devkitpro/switchvars.sh + ./configure --prefix=`pwd`/switch-sdl2 --host=aarch64-none-elf \ + --disable-shared --enable-static \ + --enable-audio \ + --enable-joystick \ + --disable-power \ + --disable-filesystem \ + --enable-cpuinfo \ + --enable-pthreads \ + --enable-timers \ + --enable-video + - name: Build + run: | + . /opt/devkitpro/switchvars.sh + make + - name: Install + run: | + . /opt/devkitpro/switchvars.sh + make install diff --git a/CMakeLists.txt b/CMakeLists.txt index b38a8bbc1..9c97b5f13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -238,7 +238,13 @@ if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC) endif() # Default option knobs -if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS) +if(APPLE OR ARCH_64 OR MSVC_CLANG) + if(NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm") + set(OPT_DEF_SSEMATH ON) + endif() +endif() + +if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS OR NINTENDO_SWITCH) set(OPT_DEF_LIBC ON) endif() @@ -355,6 +361,13 @@ if(VITA OR PSP OR PS2 OR N3DS) set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF) endif() +if(NINTENDO_SWITCH) + set(SDL_SHARED_ENABLED_BY_DEFAULT OFF) + set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF) + set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF) + set(SDL_DLOPEN_ENABLED_BY_DEFAULT OFF) +endif() + # When defined, respect CMake's BUILD_SHARED_LIBS setting: set(SDL_STATIC_ENABLED_BY_DEFAULT ON) if (NOT DEFINED SDL_SHARED_ENABLED_BY_DEFAULT) @@ -2883,6 +2896,57 @@ elseif(N3DS) endif() list(APPEND EXTRA_LIBS ${lib}) endforeach() + +elseif(NINTENDO_SWITCH) + if(SDL_AUDIO) + set(SDL_AUDIO_DRIVER_SWITCH 1) + file(GLOB SWITCH_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/switch/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${SWITCH_AUDIO_SOURCES}) + set(HAVE_SDL_AUDIO TRUE) + endif() + if(SDL_FILESYSTEM) + set(SDL_FILESYSTEM_SWITCH 1) + file(GLOB SWITCH_FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/switch/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${SWITCH_FILESYSTEM_SOURCES}) + set(HAVE_SDL_FILESYSTEM TRUE) + endif() + if(SDL_JOYSTICK) + set(SDL_JOYSTICK_SWITCH 1) + file(GLOB SWITCH_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/switch/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${SWITCH_JOYSTICK_SOURCES}) + set(HAVE_SDL_JOYSTICK TRUE) + endif() + if(SDL_POWER) + set(SDL_POWER_SWITCH 1) + file(GLOB SWITCH_POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/switch/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${SWITCH_POWER_SOURCES}) + set(HAVE_SDL_POWER TRUE) + endif() + if(SDL_TIMERS) + set(SDL_TIMER_SWITCH 1) + file(GLOB SWITCH_TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/switch/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${SWITCH_TIMER_SOURCES}) + set(HAVE_SDL_TIMERS TRUE) + endif() + if(SDL_VIDEO) + set(SDL_VIDEO_DRIVER_SWITCH 1) + file(GLOB SWITCH_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/switch/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${SWITCH_VIDEO_SOURCES}) + set(HAVE_SDL_VIDEO TRUE) + set(SDL_VIDEO_OPENGL_EGL 1) + set(HAVE_VIDEO_OPENGLES TRUE) + set(SDL_VIDEO_OPENGL_ES2 1) + set(SDL_VIDEO_RENDER_OGL_ES2 1) + set(SDL_VIDEO_OPENGL 1) + set(HAVE_VIDEO_OPENGL TRUE) + endif() + set(SDL_STATIC_PIC ON) + list(APPEND EXTRA_LIBS EGL glapi drm_nouveau nx m) + add_definitions(-DSDL_VIDEO_STATIC_ANGLE) + set(HAVE_CLOCK_GETTIME 1) + set(PTHREADS ON) + set(PTHREADS_SEM ON) + CheckPTHREAD() endif() if(HAVE_VULKAN AND NOT SDL_LOADSO) diff --git a/configure b/configure index c5b466b5f..6ac3205c3 100755 --- a/configure +++ b/configure @@ -1,10 +1,9 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71. +# Generated by GNU Autoconf 2.69. # # -# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, -# Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -15,16 +14,14 @@ # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -as_nop=: -if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 -then : +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST -else $as_nop +else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( @@ -34,46 +31,46 @@ esac fi - -# Reset variables that may have inherited troublesome values from -# the environment. - -# IFS needs to be set, to space, tab, and newline, in precisely that order. -# (If _AS_PATH_WALK were called with IFS unset, it would have the -# side effect of setting IFS to empty, thus disabling word splitting.) -# Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl -IFS=" "" $as_nl" - -PS1='$ ' -PS2='> ' -PS4='+ ' - -# Ensure predictable behavior from utilities with locale-dependent output. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# We cannot yet rely on "unset" to work, but we need these variables -# to be unset--not just set to an empty or harmless value--now, to -# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct -# also avoids known problems related to "unset" and subshell syntax -# in other old shells (e.g. bash 2.01 and pdksh 5.2.14). -for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH -do eval test \${$as_var+y} \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done - -# Ensure that fds 0, 1, and 2 are open. -if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi -if (exec 3>&2) ; then :; else exec 2>/dev/null; fi +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi # The user is always right. -if ${PATH_SEPARATOR+false} :; then +if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || @@ -82,6 +79,13 @@ if ${PATH_SEPARATOR+false} :; then fi +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( @@ -90,12 +94,8 @@ case $0 in #(( for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - test -r "$as_dir$0" && as_myself=$as_dir$0 && break + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS @@ -107,10 +107,30 @@ if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then - printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. @@ -132,22 +152,20 @@ esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. -printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="as_nop=: -if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 -then : + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST -else \$as_nop +else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( @@ -167,15 +185,12 @@ as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ) -then : +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : -else \$as_nop +else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 -blah=\$(echo \$(echo blah)) -test x\"\$blah\" = xblah || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO @@ -190,38 +205,30 @@ test -x / || exit 1" test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" - if (eval "$as_required") 2>/dev/null -then : + if (eval "$as_required") 2>/dev/null; then : as_have_required=yes -else $as_nop +else as_have_required=no fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null -then : + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : -else $as_nop +else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. - as_shell=$as_dir$as_base + as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null -then : + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes - if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null -then : + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi @@ -229,21 +236,14 @@ fi esac as_found=false done -IFS=$as_save_IFS -if $as_found -then : - -else $as_nop - if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null -then : +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes -fi -fi +fi; } +IFS=$as_save_IFS - if test "x$CONFIG_SHELL" != x -then : + if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also @@ -261,19 +261,18 @@ esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. -printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi - if test x$as_have_required = xno -then : - printf "%s\n" "$0: This script requires a shell more modern than all" - printf "%s\n" "$0: the shells that I found on your system." - if test ${ZSH_VERSION+y} ; then - printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should" - printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later." + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." else - printf "%s\n" "$0: Please tell bug-autoconf@gnu.org about your system, + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." @@ -300,7 +299,6 @@ as_fn_unset () } as_unset=as_fn_unset - # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. @@ -318,14 +316,6 @@ as_fn_exit () as_fn_set_status $1 exit $1 } # as_fn_exit -# as_fn_nop -# --------- -# Do nothing but, unlike ":", preserve the value of $?. -as_fn_nop () -{ - return $? -} -as_nop=as_fn_nop # as_fn_mkdir_p # ------------- @@ -340,7 +330,7 @@ as_fn_mkdir_p () as_dirs= while :; do case $as_dir in #( - *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" @@ -349,7 +339,7 @@ $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X"$as_dir" | +$as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -388,13 +378,12 @@ as_fn_executable_p () # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null -then : +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' -else $as_nop +else as_fn_append () { eval $1=\$$1\$2 @@ -406,27 +395,18 @@ fi # as_fn_append # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null -then : +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' -else $as_nop +else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith -# as_fn_nop -# --------- -# Do nothing but, unlike ":", preserve the value of $?. -as_fn_nop () -{ - return $? -} -as_nop=as_fn_nop # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- @@ -438,9 +418,9 @@ as_fn_error () as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - printf "%s\n" "$as_me: error: $2" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -467,7 +447,7 @@ as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X/"$0" | +$as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q @@ -511,7 +491,7 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || - { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall @@ -525,10 +505,6 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits exit } - -# Determine whether it's possible to make 'echo' print without a newline. -# These variables are no longer used directly by Autoconf, but are AC_SUBSTed -# for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) @@ -542,13 +518,6 @@ case `echo -n x` in #((((( ECHO_N='-n';; esac -# For backward compatibility with old third-party macros, we provide -# the shell variables $as_echo and $as_echo_n. New code should use -# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. -as_echo='printf %s\n' -as_echo_n='printf %s' - - rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file @@ -616,46 +585,50 @@ MFLAGS= MAKEFLAGS= # Identity of this package. -PACKAGE_NAME='' -PACKAGE_TARNAME='' -PACKAGE_VERSION='' -PACKAGE_STRING='' -PACKAGE_BUGREPORT='' -PACKAGE_URL='' +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= +PACKAGE_URL= ac_unique_file="src/SDL.c" # Factoring default headers for most tests. ac_includes_default="\ -#include -#ifdef HAVE_STDIO_H -# include +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include #endif -#ifdef HAVE_STDLIB_H +#ifdef STDC_HEADERS # include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif #endif #ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif # include #endif +#ifdef HAVE_STRINGS_H +# include +#endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif #ifdef HAVE_UNISTD_H # include #endif" -ac_header_c_list= ac_subst_vars='LTLIBOBJS LIBOBJS WAYLAND_SCANNER_CODE_MODE @@ -724,7 +697,6 @@ JACK_CFLAGS ALSA_LIBS ALSA_CFLAGS ALLOCA -CPP LIBTOOLLINKERTAG LINKER SORT @@ -744,6 +716,7 @@ LT_REVISION LT_CURRENT LT_RELEASE RC +CPP LT_SYS_LIBRARY_PATH OTOOL64 OTOOL @@ -967,6 +940,7 @@ LDFLAGS LIBS CPPFLAGS LT_SYS_LIBRARY_PATH +CPP CXX CXXFLAGS CCC @@ -974,7 +948,6 @@ CXXCPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR -CPP JACK_CFLAGS JACK_LIBS ESD_CFLAGS @@ -1072,6 +1045,8 @@ do *) ac_optarg=yes ;; esac + # Accept the important Cygnus configure options, so we can diagnose typos. + case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; @@ -1112,9 +1087,9 @@ do ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: \`$ac_useropt'" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt - ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" @@ -1138,9 +1113,9 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: \`$ac_useropt'" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt - ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" @@ -1351,9 +1326,9 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: \`$ac_useropt'" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt - ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" @@ -1367,9 +1342,9 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: \`$ac_useropt'" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt - ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" @@ -1413,9 +1388,9 @@ Try \`$0 --help' for more information" *) # FIXME: should be removed in autoconf 3.0. - printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2 + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2 + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; @@ -1431,7 +1406,7 @@ if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1495,7 +1470,7 @@ $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X"$as_myself" | +$as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -1814,6 +1789,7 @@ Some influential environment variables: you have headers in a nonstandard directory LT_SYS_LIBRARY_PATH User-defined run-time library search path. + CPP C preprocessor CXX C++ compiler command CXXFLAGS C++ compiler flags CXXCPP C++ preprocessor @@ -1822,7 +1798,6 @@ Some influential environment variables: directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path - CPP C preprocessor JACK_CFLAGS C compiler flags for JACK, overriding pkg-config JACK_LIBS linker flags for JACK, overriding pkg-config ESD_CFLAGS C compiler flags for ESD, overriding pkg-config @@ -1885,9 +1860,9 @@ if test "$ac_init_help" = "recursive"; then case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) - ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; @@ -1915,8 +1890,7 @@ esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } - # Check for configure.gnu first; this name is used for a wrapper for - # Metaconfig's "Configure" on case-insensitive file systems. + # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive @@ -1924,7 +1898,7 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix echo && $SHELL "$ac_srcdir/configure" --help=recursive else - printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done @@ -1934,9 +1908,9 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure -generated by GNU Autoconf 2.71 +generated by GNU Autoconf 2.69 -Copyright (C) 2021 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1953,14 +1927,14 @@ fi ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest.beam + rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -1968,15 +1942,14 @@ printf "%s\n" "$ac_try_echo"; } >&5 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest.$ac_objext -then : + } && test -s conftest.$ac_objext; then : ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 +else + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 @@ -1992,14 +1965,14 @@ fi ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext + rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -2007,18 +1980,17 @@ printf "%s\n" "$ac_try_echo"; } >&5 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext - } -then : + }; then : ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 +else + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 @@ -2040,44 +2012,120 @@ fi ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -printf %s "checking for $2... " >&6; } -if eval test \${$3+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" -else $as_nop +else eval "$3=no" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -printf %s "checking for $2... " >&6; } -if eval test \${$3+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. @@ -2085,9 +2133,16 @@ else $as_nop #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. */ + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif -#include #undef $2 /* Override any GCC internal prototype to avoid an error. @@ -2105,25 +2160,24 @@ choke me #endif int -main (void) +main () { return $2 (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" -else $as_nop +else eval "$3=no" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func @@ -2134,14 +2188,14 @@ printf "%s\n" "$ac_res" >&6; } ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest.beam + rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -2149,15 +2203,14 @@ printf "%s\n" "$ac_try_echo"; } >&5 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err - } && test -s conftest.$ac_objext -then : + } && test -s conftest.$ac_objext; then : ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 +else + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 @@ -2179,7 +2232,7 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -2187,15 +2240,14 @@ printf "%s\n" "$ac_try_echo"; } >&5 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err - } -then : + }; then : ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 +else + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 @@ -2211,14 +2263,14 @@ fi ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext + rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -2226,18 +2278,17 @@ printf "%s\n" "$ac_try_echo"; } >&5 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext - } -then : + }; then : ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 +else + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 @@ -2252,6 +2303,93 @@ fi } # ac_fn_cxx_try_link +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache @@ -2259,18 +2397,17 @@ fi ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -printf %s "checking for $2... " >&6; } -if eval test \${$3+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int -main (void) +main () { if (sizeof ($2)) return 0; @@ -2278,13 +2415,12 @@ if (sizeof ($2)) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int -main (void) +main () { if (sizeof (($2))) return 0; @@ -2292,122 +2428,39 @@ if (sizeof (($2))) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : -else $as_nop +else eval "$3=yes" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () +# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES +# ---------------------------------------------------- +# Tries to find if the field MEMBER exists in type AGGR, after including +# INCLUDES, setting cache variable VAR accordingly. +ac_fn_c_check_member () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - } -then : - ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that -# executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; } -then : - ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: program exited with status $ac_status" >&5 - printf "%s\n" "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES -# ---------------------------------------------------- -# Tries to find if the field MEMBER exists in type AGGR, after including -# INCLUDES, setting cache variable VAR accordingly. -ac_fn_c_check_member () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 -printf %s "checking for $2.$3... " >&6; } -if eval test \${$4+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main (void) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 +$as_echo_n "checking for $2.$3... " >&6; } +if eval \${$4+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () { static $2 ac_aggr; if (ac_aggr.$3) @@ -2416,15 +2469,14 @@ return 0; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : eval "$4=yes" -else $as_nop +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int -main (void) +main () { static $2 ac_aggr; if (sizeof ac_aggr.$3) @@ -2433,45 +2485,41 @@ return 0; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : eval "$4=yes" -else $as_nop +else eval "$4=no" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$4 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member -# ac_fn_check_decl LINENO SYMBOL VAR INCLUDES EXTRA-OPTIONS FLAG-VAR -# ------------------------------------------------------------------ +# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES +# --------------------------------------------- # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR -# accordingly. Pass EXTRA-OPTIONS to the compiler, using FLAG-VAR. -ac_fn_check_decl () +# accordingly. +ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 -printf %s "checking whether $as_decl_name is declared... " >&6; } -if eval test \${$3+y} -then : - printf %s "(cached) " >&6 -else $as_nop as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` - eval ac_save_FLAGS=\$$6 - as_fn_append $6 " $5" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 +$as_echo_n "checking whether $as_decl_name is declared... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int -main (void) +main () { #ifndef $as_decl_name #ifdef __cplusplus @@ -2485,50 +2533,27 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" -else $as_nop +else eval "$3=no" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - eval $6=\$ac_save_FLAGS - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno -} # ac_fn_check_decl -ac_configure_args_raw= -for ac_arg -do - case $ac_arg in - *\'*) - ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append ac_configure_args_raw " '$ac_arg'" -done - -case $ac_configure_args_raw in - *$as_nl*) - ac_safe_unquote= ;; - *) - ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab. - ac_unsafe_a="$ac_unsafe_z#~" - ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g" - ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;; -esac - +} # ac_fn_c_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was -generated by GNU Autoconf 2.71. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was - $ $0$ac_configure_args_raw + $ $0 $@ _ACEOF exec 5>>config.log @@ -2561,12 +2586,8 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - printf "%s\n" "PATH: $as_dir" + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" done IFS=$as_save_IFS @@ -2601,7 +2622,7 @@ do | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) - ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; @@ -2636,13 +2657,11 @@ done # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? - # Sanitize IFS. - IFS=" "" $as_nl" # Save into config.log some information that might help in debugging. { echo - printf "%s\n" "## ---------------- ## + $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo @@ -2653,8 +2672,8 @@ trap 'exit_status=$? case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( @@ -2678,7 +2697,7 @@ printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ) echo - printf "%s\n" "## ----------------- ## + $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo @@ -2686,14 +2705,14 @@ printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} do eval ac_val=\$$ac_var case $ac_val in - *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac - printf "%s\n" "$ac_var='\''$ac_val'\''" + $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then - printf "%s\n" "## ------------------- ## + $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo @@ -2701,15 +2720,15 @@ printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} do eval ac_val=\$$ac_var case $ac_val in - *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac - printf "%s\n" "$ac_var='\''$ac_val'\''" + $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then - printf "%s\n" "## ----------- ## + $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo @@ -2717,8 +2736,8 @@ printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} echo fi test "$ac_signal" != 0 && - printf "%s\n" "$as_me: caught signal $ac_signal" - printf "%s\n" "$as_me: exit $exit_status" + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && @@ -2732,48 +2751,63 @@ ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h -printf "%s\n" "/* confdefs.h */" > confdefs.h +$as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. -printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF -printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF -printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF -printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF -printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF -printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - ac_site_files="$CONFIG_SITE" + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac elif test "x$prefix" != xNONE; then - ac_site_files="$prefix/share/config.site $prefix/etc/config.site" + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site else - ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site fi - -for ac_site_file in $ac_site_files +for ac_site_file in "$ac_site_file1" "$ac_site_file2" do - case $ac_site_file in #( - */*) : - ;; #( - *) : - ac_site_file=./$ac_site_file ;; -esac - if test -f "$ac_site_file" && test -r "$ac_site_file"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;} + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ - || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi @@ -2783,1081 +2817,446 @@ if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -printf "%s\n" "$as_me: loading cache $cache_file" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -printf "%s\n" "$as_me: creating cache $cache_file" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi -# Test code for whether the C compiler supports C89 (global declarations) -ac_c_conftest_c89_globals=' -/* Does the compiler advertise C89 conformance? - Do not test the value of __STDC__, because some compilers set it to 0 - while being otherwise adequately conformant. */ -#if !defined __STDC__ -# error "Compiler does not advertise C89 conformance" -#endif +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */ -struct buf { int x; }; -struct buf * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not \xHH hex character constants. - These do not provoke an error unfortunately, instead are silently treated - as an "x". The following induces an error, until -std is added to get - proper ANSI mode. Curiously \x00 != x always comes out true, for an - array size at least. It is necessary to write \x00 == 0 to get something - that is true only with -std. */ -int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1]; -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) '\''x'\'' -int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1]; -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int), - int, int);' +ac_config_headers="$ac_config_headers include/SDL_config.h" -# Test code for whether the C compiler supports C89 (body of main). -ac_c_conftest_c89_main=' -ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]); -' +ac_aux_dir= +for ac_dir in build-scripts "$srcdir"/build-scripts; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in build-scripts \"$srcdir\"/build-scripts" "$LINENO" 5 +fi -# Test code for whether the C compiler supports C99 (global declarations) -ac_c_conftest_c99_globals=' -// Does the compiler advertise C99 conformance? -#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L -# error "Compiler does not advertise C99 conformance" -#endif +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. -#include -extern int puts (const char *); -extern int printf (const char *, ...); -extern int dprintf (int, const char *, ...); -extern void *malloc (size_t); - -// Check varargs macros. These examples are taken from C99 6.10.3.5. -// dprintf is used instead of fprintf to avoid needing to declare -// FILE and stderr. -#define debug(...) dprintf (2, __VA_ARGS__) -#define showlist(...) puts (#__VA_ARGS__) -#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) -static void -test_varargs_macros (void) -{ - int x = 1234; - int y = 5678; - debug ("Flag"); - debug ("X = %d\n", x); - showlist (The first, second, and third items.); - report (x>y, "x is %d but y is %d", x, y); -} - -// Check long long types. -#define BIG64 18446744073709551615ull -#define BIG32 4294967295ul -#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) -#if !BIG_OK - #error "your preprocessor is broken" -#endif -#if BIG_OK -#else - #error "your preprocessor is broken" -#endif -static long long int bignum = -9223372036854775807LL; -static unsigned long long int ubignum = BIG64; -struct incomplete_array -{ - int datasize; - double data[]; -}; -struct named_init { - int number; - const wchar_t *name; - double average; -}; -typedef const char *ccp; +orig_CFLAGS="$CFLAGS" -static inline int -test_restrict (ccp restrict text) -{ - // See if C++-style comments work. - // Iterate through items via the restricted pointer. - // Also check for declarations in for loops. - for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i) - continue; - return 0; -} +# See docs/release_checklist.md +SDL_MAJOR_VERSION=2 +SDL_MINOR_VERSION=28 +SDL_MICRO_VERSION=5 +SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION -// Check varargs and va_copy. -static bool -test_varargs (const char *format, ...) -{ - va_list args; - va_start (args, format); - va_list args_copy; - va_copy (args_copy, args); +SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION` +case "$SDL_MINOR_VERSION" in #( + *[02468]) : + SDL_INTERFACE_AGE="$SDL_MICRO_VERSION" ;; #( + *) : + SDL_INTERFACE_AGE=0 ;; #( + *) : + ;; +esac - const char *str = ""; - int number = 0; - float fnumber = 0; - while (*format) - { - switch (*format++) - { - case '\''s'\'': // string - str = va_arg (args_copy, const char *); - break; - case '\''d'\'': // int - number = va_arg (args_copy, int); - break; - case '\''f'\'': // float - fnumber = va_arg (args_copy, double); - break; - default: - break; - } - } - va_end (args_copy); - va_end (args); - return *str && number && fnumber; -} -' -# Test code for whether the C compiler supports C99 (body of main). -ac_c_conftest_c99_main=' - // Check bool. - _Bool success = false; - success |= (argc != 0); - - // Check restrict. - if (test_restrict ("String literal") == 0) - success = true; - char *restrict newvar = "Another string"; - - // Check varargs. - success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234); - test_varargs_macros (); - - // Check flexible array members. - struct incomplete_array *ia = - malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); - ia->datasize = 10; - for (int i = 0; i < ia->datasize; ++i) - ia->data[i] = i * 1.234; - - // Check named initializers. - struct named_init ni = { - .number = 34, - .name = L"Test wide string", - .average = 543.34343, - }; - - ni.number = 58; - - int dynamic_array[ni.number]; - dynamic_array[0] = argv[0][0]; - dynamic_array[ni.number - 1] = 543; - - // work around unused variable warnings - ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\'' - || dynamic_array[ni.number - 1] != 543); -' -# Test code for whether the C compiler supports C11 (global declarations) -ac_c_conftest_c11_globals=' -// Does the compiler advertise C11 conformance? -#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L -# error "Compiler does not advertise C11 conformance" -#endif -// Check _Alignas. -char _Alignas (double) aligned_as_double; -char _Alignas (0) no_special_alignment; -extern char aligned_as_int; -char _Alignas (0) _Alignas (int) aligned_as_int; -// Check _Alignof. -enum -{ - int_alignment = _Alignof (int), - int_array_alignment = _Alignof (int[100]), - char_alignment = _Alignof (char) -}; -_Static_assert (0 < -_Alignof (int), "_Alignof is signed"); -// Check _Noreturn. -int _Noreturn does_not_return (void) { for (;;) continue; } +# libtool versioning +case `pwd` in + *\ * | *\ *) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 +$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; +esac -// Check _Static_assert. -struct test_static_assert -{ - int x; - _Static_assert (sizeof (int) <= sizeof (long int), - "_Static_assert does not work in struct"); - long int y; -}; -// Check UTF-8 literals. -#define u8 syntax error! -char const utf8_literal[] = u8"happens to be ASCII" "another string"; -// Check duplicate typedefs. -typedef long *long_ptr; -typedef long int *long_ptr; -typedef long_ptr long_ptr; +macro_version='2.4.6' +macro_revision='2.4.6' -// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1. -struct anonymous -{ - union { - struct { int i; int j; }; - struct { int k; long int l; } w; - }; - int m; -} v1; -' -# Test code for whether the C compiler supports C11 (body of main). -ac_c_conftest_c11_main=' - _Static_assert ((offsetof (struct anonymous, i) - == offsetof (struct anonymous, w.k)), - "Anonymous union alignment botch"); - v1.i = 2; - v1.w.k = 5; - ok |= v1.i != 5; -' -# Test code for whether the C compiler supports C11 (complete). -ac_c_conftest_c11_program="${ac_c_conftest_c89_globals} -${ac_c_conftest_c99_globals} -${ac_c_conftest_c11_globals} -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_c_conftest_c89_main} - ${ac_c_conftest_c99_main} - ${ac_c_conftest_c11_main} - return ok; -} -" -# Test code for whether the C compiler supports C99 (complete). -ac_c_conftest_c99_program="${ac_c_conftest_c89_globals} -${ac_c_conftest_c99_globals} -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_c_conftest_c89_main} - ${ac_c_conftest_c99_main} - return ok; -} -" -# Test code for whether the C compiler supports C89 (complete). -ac_c_conftest_c89_program="${ac_c_conftest_c89_globals} -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_c_conftest_c89_main} - return ok; -} -" -as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H" -as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H" -as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H" -as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H" -as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H" -as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H" -as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H" -as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" -as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" -# Test code for whether the C++ compiler supports C++98 (global declarations) -ac_cxx_conftest_cxx98_globals=' -// Does the compiler advertise C++98 conformance? -#if !defined __cplusplus || __cplusplus < 199711L -# error "Compiler does not advertise C++98 conformance" -#endif -// These inclusions are to reject old compilers that -// lack the unsuffixed header files. -#include -#include -// and are *not* freestanding headers in C++98. -extern void assert (int); -namespace std { - extern int strcmp (const char *, const char *); -} -// Namespaces, exceptions, and templates were all added after "C++ 2.0". -using std::exception; -using std::strcmp; -namespace { +ltmain=$ac_aux_dir/ltmain.sh -void test_exception_syntax() -{ - try { - throw "test"; - } catch (const char *s) { - // Extra parentheses suppress a warning when building autoconf itself, - // due to lint rules shared with more typical C programs. - assert (!(strcmp) (s, "test")); - } -} +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 -template struct test_template -{ - T const val; - explicit test_template(T t) : val(t) {} - template T add(U u) { return static_cast(u) + val; } -}; +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 -} // anonymous namespace -' +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac -# Test code for whether the C++ compiler supports C++98 (body of main) -ac_cxx_conftest_cxx98_main=' - assert (argc); - assert (! argv[0]); -{ - test_exception_syntax (); - test_template tt (2.0); - assert (tt.add (4) == 6.0); - assert (true && !false); -} -' -# Test code for whether the C++ compiler supports C++11 (global declarations) -ac_cxx_conftest_cxx11_globals=' -// Does the compiler advertise C++ 2011 conformance? -#if !defined __cplusplus || __cplusplus < 201103L -# error "Compiler does not advertise C++11 conformance" -#endif +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if ${ac_cv_host+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi -namespace cxx11test -{ - constexpr int get_val() { return 20; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - struct testinit - { - int i; - double d; - }; - class delegate - { - public: - delegate(int n) : n(n) {} - delegate(): delegate(2354) {} +# Backslashify metacharacters that are still active within +# double-quoted strings. +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' - virtual int getval() { return this->n; }; - protected: - int n; - }; +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' - class overridden : public delegate - { - public: - overridden(int n): delegate(n) {} - virtual int getval() override final { return this->n * 2; } - }; +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - class nocopy - { - public: - nocopy(int i): i(i) {} - nocopy() = default; - nocopy(const nocopy&) = delete; - nocopy & operator=(const nocopy&) = delete; - private: - int i; - }; - - // for testing lambda expressions - template Ret eval(Fn f, Ret v) - { - return f(v); - } +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - // for testing variadic templates and trailing return types - template auto sum(V first) -> V - { - return first; - } - template auto sum(V first, Args... rest) -> V - { - return first + sum(rest...); - } -} -' +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' -# Test code for whether the C++ compiler supports C++11 (body of main) -ac_cxx_conftest_cxx11_main=' -{ - // Test auto and decltype - auto a1 = 6538; - auto a2 = 48573953.4; - auto a3 = "String literal"; +ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - int total = 0; - for (auto i = a3; *i; ++i) { total += *i; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 +$as_echo_n "checking how to print strings... " >&6; } +# Test print first, because it will be a builtin if present. +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ + test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='print -r --' +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='printf %s\n' +else + # Use this function as a fallback that always works. + func_fallback_echo () + { + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' + } + ECHO='func_fallback_echo' +fi - decltype(a2) a4 = 34895.034; -} -{ - // Test constexpr - short sa[cxx11test::get_val()] = { 0 }; -} -{ - // Test initializer lists - cxx11test::testinit il = { 4323, 435234.23544 }; -} -{ - // Test range-based for - int array[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, - 14, 19, 17, 8, 6, 20, 16, 2, 11, 1}; - for (auto &x : array) { x += 23; } -} -{ - // Test lambda expressions - using cxx11test::eval; - assert (eval ([](int x) { return x*2; }, 21) == 42); - double d = 2.0; - assert (eval ([&](double x) { return d += x; }, 3.0) == 5.0); - assert (d == 5.0); - assert (eval ([=](double x) mutable { return d += x; }, 4.0) == 9.0); - assert (d == 5.0); -} -{ - // Test use of variadic templates - using cxx11test::sum; - auto a = sum(1); - auto b = sum(1, 2); - auto c = sum(1.0, 2.0, 3.0); -} -{ - // Test constructor delegation - cxx11test::delegate d1; - cxx11test::delegate d2(); - cxx11test::delegate d3(45); -} -{ - // Test override and final - cxx11test::overridden o1(55464); -} -{ - // Test nullptr - char *c = nullptr; -} -{ - // Test template brackets - test_template<::test_template> v(test_template(12)); -} +# func_echo_all arg... +# Invoke $ECHO with all args, space-separated. +func_echo_all () { - // Unicode literals - char const *utf8 = u8"UTF-8 string \u2500"; - char16_t const *utf16 = u"UTF-8 string \u2500"; - char32_t const *utf32 = U"UTF-32 string \u2500"; + $ECHO "" } -' -# Test code for whether the C compiler supports C++11 (complete). -ac_cxx_conftest_cxx11_program="${ac_cxx_conftest_cxx98_globals} -${ac_cxx_conftest_cxx11_globals} +case $ECHO in + printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 +$as_echo "printf" >&6; } ;; + print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 +$as_echo "print -r" >&6; } ;; + *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 +$as_echo "cat" >&6; } ;; +esac + -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_cxx_conftest_cxx98_main} - ${ac_cxx_conftest_cxx11_main} - return ok; -} -" -# Test code for whether the C compiler supports C++98 (complete). -ac_cxx_conftest_cxx98_program="${ac_cxx_conftest_cxx98_globals} -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_cxx_conftest_cxx98_main} - return ok; -} -" -# Auxiliary files required by this configure script. -ac_aux_files="install-sh config.guess config.sub ltmain.sh" -# Locations in which to look for auxiliary files. -ac_aux_dir_candidates="${srcdir}/build-scripts" -# Search for a directory containing all of the required auxiliary files, -# $ac_aux_files, from the $PATH-style list $ac_aux_dir_candidates. -# If we don't find one directory that contains all the files we need, -# we report the set of missing files from the *first* directory in -# $ac_aux_dir_candidates and give up. -ac_missing_aux_files="" -ac_first_candidate=: -printf "%s\n" "$as_me:${as_lineno-$LINENO}: looking for aux files: $ac_aux_files" >&5 -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in $ac_aux_dir_candidates -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - as_found=: - printf "%s\n" "$as_me:${as_lineno-$LINENO}: trying $as_dir" >&5 - ac_aux_dir_found=yes - ac_install_sh= - for ac_aux in $ac_aux_files - do - # As a special case, if "install-sh" is required, that requirement - # can be satisfied by any of "install-sh", "install.sh", or "shtool", - # and $ac_install_sh is set appropriately for whichever one is found. - if test x"$ac_aux" = x"install-sh" - then - if test -f "${as_dir}install-sh"; then - printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install-sh found" >&5 - ac_install_sh="${as_dir}install-sh -c" - elif test -f "${as_dir}install.sh"; then - printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install.sh found" >&5 - ac_install_sh="${as_dir}install.sh -c" - elif test -f "${as_dir}shtool"; then - printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}shtool found" >&5 - ac_install_sh="${as_dir}shtool install -c" - else - ac_aux_dir_found=no - if $ac_first_candidate; then - ac_missing_aux_files="${ac_missing_aux_files} install-sh" - else - break - fi - fi - else - if test -f "${as_dir}${ac_aux}"; then - printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}${ac_aux} found" >&5 - else - ac_aux_dir_found=no - if $ac_first_candidate; then - ac_missing_aux_files="${ac_missing_aux_files} ${ac_aux}" - else - break - fi - fi - fi - done - if test "$ac_aux_dir_found" = yes; then - ac_aux_dir="$as_dir" - break - fi - ac_first_candidate=false - as_found=false -done -IFS=$as_save_IFS -if $as_found -then : -else $as_nop - as_fn_error $? "cannot find required auxiliary files:$ac_missing_aux_files" "$LINENO" 5 -fi -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -if test -f "${ac_aux_dir}config.guess"; then - ac_config_guess="$SHELL ${ac_aux_dir}config.guess" -fi -if test -f "${ac_aux_dir}config.sub"; then - ac_config_sub="$SHELL ${ac_aux_dir}config.sub" -fi -if test -f "$ac_aux_dir/configure"; then - ac_configure="$SHELL ${ac_aux_dir}configure" -fi -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -printf "%s\n" "$as_me: former value: \`$ac_old_val'" >&2;} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;} - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file' - and start over" "$LINENO" 5 -fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi -ac_config_headers="$ac_config_headers include/SDL_config.h" - - - - -orig_CFLAGS="$CFLAGS" +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS -# See docs/release_checklist.md -SDL_MAJOR_VERSION=2 -SDL_MINOR_VERSION=28 -SDL_MICRO_VERSION=5 -SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi -SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION` -case "$SDL_MINOR_VERSION" in #( - *[02468]) : - SDL_INTERFACE_AGE="$SDL_MICRO_VERSION" ;; #( - *) : - SDL_INTERFACE_AGE=0 ;; #( - *) : - ;; + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS - - - - - - -# libtool versioning - - -case `pwd` in - *\ * | *\ *) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 -printf "%s\n" "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; -esac - - - -macro_version='2.4.6' -macro_revision='2.4.6' - - - - - - - - - - - - - - -ltmain=$ac_aux_dir/ltmain.sh - - - - # Make sure we can run config.sub. -$SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL ${ac_aux_dir}config.sub" "$LINENO" 5 - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -printf %s "checking build system type... " >&6; } -if test ${ac_cv_build+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"` -test "x$ac_build_alias" = x && - as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed" "$LINENO" 5 - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -printf "%s\n" "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -printf %s "checking host system type... " >&6; } -if test ${ac_cv_host+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` || - as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $host_alias failed" "$LINENO" 5 -fi - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -printf "%s\n" "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - - -# Backslashify metacharacters that are still active within -# double-quoted strings. -sed_quote_subst='s/\(["`$\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\(["`\\]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO -ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 -printf %s "checking how to print strings... " >&6; } -# Test print first, because it will be a builtin if present. -if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ - test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='print -r --' -elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then - ECHO='printf %s\n' -else - # Use this function as a fallback that always works. - func_fallback_echo () - { - eval 'cat <<_LTECHO_EOF -$1 -_LTECHO_EOF' - } - ECHO='func_fallback_echo' -fi - -# func_echo_all arg... -# Invoke $ECHO with all args, space-separated. -func_echo_all () -{ - $ECHO "" -} - -case $ECHO in - printf*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: printf" >&5 -printf "%s\n" "printf" >&6; } ;; - print*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 -printf "%s\n" "print -r" >&6; } ;; - *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: cat" >&5 -printf "%s\n" "cat" >&6; } ;; -esac - - - - - - - - - - - - - - - - - - - - - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -printf "%s\n" "$ac_ct_CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi fi @@ -3865,12 +3264,11 @@ fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else @@ -3879,19 +3277,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3907,18 +3301,18 @@ if test $ac_prog_rejected = yes; then # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift - ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@" + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -3929,12 +3323,11 @@ if test -z "$CC"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else @@ -3942,15 +3335,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3961,11 +3350,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -3978,12 +3367,11 @@ if test -z "$CC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else @@ -3991,15 +3379,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -4010,11 +3394,11 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -printf "%s\n" "$ac_ct_CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -4026,138 +3410,34 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args. -set dummy ${ac_tool_prefix}clang; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}clang" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "clang", so it can be a program name with args. -set dummy clang; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="clang" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -printf "%s\n" "$ac_ct_CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } fi - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi -fi - - -test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. -printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 -for ac_option in --version -v -V -qversion -version; do +for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -4167,7 +3447,7 @@ printf "%s\n" "$ac_try_echo"; } >&5 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done @@ -4175,7 +3455,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; @@ -4187,9 +3467,9 @@ ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -printf %s "checking whether the C compiler works... " >&6; } -ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" @@ -4210,12 +3490,11 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -then : + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, @@ -4232,7 +3511,7 @@ do # certainly right. break;; *.* ) - if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no; + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi @@ -4248,46 +3527,44 @@ do done test "$ac_cv_exeext" = no && ac_cv_exeext= -else $as_nop +else ac_file='' fi -if test -z "$ac_file" -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -printf "%s\n" "$as_me: failed program was:" >&5 +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -printf %s "checking for C compiler default output file name... " >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -printf "%s\n" "$ac_file" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -printf %s "checking for suffix of executables... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -then : + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with @@ -4301,15 +3578,15 @@ for ac_file in conftest.exe conftest conftest.*; do * ) break;; esac done -else $as_nop - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -printf "%s\n" "$ac_cv_exeext" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext @@ -4318,7 +3595,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; @@ -4330,8 +3607,8 @@ _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -printf %s "checking whether we are cross compiling... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in @@ -4339,10 +3616,10 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in @@ -4350,40 +3627,39 @@ printf "%s\n" "$ac_try_echo"; } >&5 *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot run C compiled programs. + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -printf "%s\n" "$cross_compiling" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -printf %s "checking for suffix of object files... " >&6; } -if test ${ac_cv_objext+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; @@ -4397,12 +3673,11 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -then : + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in @@ -4411,32 +3686,31 @@ then : break;; esac done -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 +else + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -printf "%s\n" "$ac_cv_objext" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5 -printf %s "checking whether the compiler supports GNU C... " >&6; } -if test ${ac_cv_c_compiler_gnu+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { #ifndef __GNUC__ choke me @@ -4446,33 +3720,29 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes -else $as_nop +else ac_compiler_gnu=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; } -ac_compiler_gnu=$ac_cv_c_compiler_gnu - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi -ac_test_CFLAGS=${CFLAGS+y} +ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -printf %s "checking whether $CC accepts -g... " >&6; } -if test ${ac_cv_prog_cc_g+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no @@ -4481,60 +3751,57 @@ else $as_nop /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes -else $as_nop +else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : -else $as_nop +else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -printf "%s\n" "$ac_cv_prog_cc_g" >&6; } -if test $ac_test_CFLAGS; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then @@ -4549,144 +3816,94 @@ else CFLAGS= fi fi -ac_prog_cc_stdc=no -if test x$ac_prog_cc_stdc = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5 -printf %s "checking for $CC option to enable C11 features... " >&6; } -if test ${ac_cv_prog_cc_c11+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cc_c11=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -$ac_c_conftest_c11_program -_ACEOF -for ac_arg in '' -std=gnu11 -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_prog_cc_c11=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cc_c11" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC -fi +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} -if test "x$ac_cv_prog_cc_c11" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c11" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 -printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } - CC="$CC $ac_cv_prog_cc_c11" -fi - ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11 - ac_prog_cc_stdc=c11 -fi -fi -if test x$ac_prog_cc_stdc = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5 -printf %s "checking for $CC option to enable C99 features... " >&6; } -if test ${ac_cv_prog_cc_c99+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cc_c99=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_c_conftest_c99_program -_ACEOF -for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99= -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_prog_cc_c99=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cc_c99" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC -fi +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; -if test "x$ac_cv_prog_cc_c99" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c99" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 -printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } - CC="$CC $ac_cv_prog_cc_c99" -fi - ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 - ac_prog_cc_stdc=c99 -fi -fi -if test x$ac_prog_cc_stdc = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5 -printf %s "checking for $CC option to enable C89 features... " >&6; } -if test ${ac_cv_prog_cc_c89+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_c_conftest_c89_program +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} _ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO" -then : + if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi -rm -f core conftest.err conftest.$ac_objext conftest.beam +rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC -fi -if test "x$ac_cv_prog_cc_c89" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c89" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } - CC="$CC $ac_cv_prog_cc_c89" -fi - ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 - ac_prog_cc_stdc=c89 fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + fi ac_ext=c @@ -4695,12 +3912,11 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 -printf %s "checking for a sed that does not truncate output... " >&6; } -if test ${ac_cv_path_SED+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 +$as_echo_n "checking for a sed that does not truncate output... " >&6; } +if ${ac_cv_path_SED+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" @@ -4714,15 +3930,10 @@ else $as_nop for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_prog in sed gsed - do + test -z "$as_dir" && as_dir=. + for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_SED="$as_dir$ac_prog$ac_exec_ext" + ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED @@ -4731,13 +3942,13 @@ case `"$ac_path_SED" --version 2>&1` in ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 - printf %s 0123456789 >"conftest.in" + $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" - printf "%s\n" '' >> "conftest.nl" + $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val @@ -4765,8 +3976,8 @@ else fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 -printf "%s\n" "$ac_cv_path_SED" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 +$as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed @@ -4783,12 +3994,11 @@ Xsed="$SED -e 1s/^X//" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -printf %s "checking for grep that handles long lines and -e... " >&6; } -if test ${ac_cv_path_GREP+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST @@ -4796,15 +4006,10 @@ else $as_nop for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_prog in grep ggrep - do + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir$ac_prog$ac_exec_ext" + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP @@ -4813,13 +4018,13 @@ case `"$ac_path_GREP" --version 2>&1` in ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 - printf %s 0123456789 >"conftest.in" + $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" - printf "%s\n" 'GREP' >> "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val @@ -4847,17 +4052,16 @@ else fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -printf "%s\n" "$ac_cv_path_GREP" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -printf %s "checking for egrep... " >&6; } -if test ${ac_cv_path_EGREP+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else @@ -4868,15 +4072,10 @@ else $as_nop for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_prog in egrep - do + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext" + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP @@ -4885,13 +4084,13 @@ case `"$ac_path_EGREP" --version 2>&1` in ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 - printf %s 0123456789 >"conftest.in" + $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" - printf "%s\n" 'EGREP' >> "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val @@ -4920,17 +4119,16 @@ fi fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -printf "%s\n" "$ac_cv_path_EGREP" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 -printf %s "checking for fgrep... " >&6; } -if test ${ac_cv_path_FGREP+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 +$as_echo_n "checking for fgrep... " >&6; } +if ${ac_cv_path_FGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else @@ -4941,15 +4139,10 @@ else $as_nop for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_prog in fgrep - do + test -z "$as_dir" && as_dir=. + for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_FGREP="$as_dir$ac_prog$ac_exec_ext" + ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP @@ -4958,13 +4151,13 @@ case `"$ac_path_FGREP" --version 2>&1` in ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 - printf %s 0123456789 >"conftest.in" + $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" - printf "%s\n" 'FGREP' >> "conftest.nl" + $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val @@ -4993,8 +4186,8 @@ fi fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 -printf "%s\n" "$ac_cv_path_FGREP" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 +$as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" @@ -5019,18 +4212,17 @@ test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. -if test ${with_gnu_ld+y} -then : +if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes -else $as_nop +else with_gnu_ld=no fi ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 -printf %s "checking for ld used by $CC... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 +$as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw @@ -5059,16 +4251,15 @@ printf %s "checking for ld used by $CC... " >&6; } ;; esac elif test yes = "$with_gnu_ld"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 -printf %s "checking for GNU ld... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 -printf %s "checking for non-GNU ld... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } fi -if test ${lt_cv_path_LD+y} -then : - printf %s "(cached) " >&6 -else $as_nop +if ${lt_cv_path_LD+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do @@ -5097,19 +4288,18 @@ fi LD=$lt_cv_path_LD if test -n "$LD"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 -printf "%s\n" "$LD" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 +$as_echo "$LD" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 -printf %s "checking if the linker ($LD) is GNU ld... " >&6; } -if test ${lt_cv_prog_gnu_ld+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if ${lt_cv_prog_gnu_ld+:} false; then : + $as_echo_n "(cached) " >&6 +else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &1 &5 -printf "%s\n" "$lt_cv_prog_gnu_ld" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5 +$as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld @@ -5132,12 +4322,11 @@ with_gnu_ld=$lt_cv_prog_gnu_ld -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 -printf %s "checking for BSD- or MS-compatible name lister (nm)... " >&6; } -if test ${lt_cv_path_NM+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 +$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } +if ${lt_cv_path_NM+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM=$NM @@ -5187,8 +4376,8 @@ else : ${lt_cv_path_NM=no} fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 -printf "%s\n" "$lt_cv_path_NM" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 +$as_echo "$lt_cv_path_NM" >&6; } if test no != "$lt_cv_path_NM"; then NM=$lt_cv_path_NM else @@ -5201,12 +4390,11 @@ else do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_DUMPBIN+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DUMPBIN+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else @@ -5214,15 +4402,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -5233,11 +4417,11 @@ fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 -printf "%s\n" "$DUMPBIN" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 +$as_echo "$DUMPBIN" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -5250,12 +4434,11 @@ if test -z "$DUMPBIN"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_DUMPBIN+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else @@ -5263,15 +4446,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -5282,11 +4461,11 @@ fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 -printf "%s\n" "$ac_ct_DUMPBIN" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 +$as_echo "$ac_ct_DUMPBIN" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -5298,8 +4477,8 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN @@ -5327,12 +4506,11 @@ test -z "$NM" && NM=nm -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 -printf %s "checking the name lister ($NM) interface... " >&6; } -if test ${lt_cv_nm_interface+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 +$as_echo_n "checking the name lister ($NM) interface... " >&6; } +if ${lt_cv_nm_interface+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) @@ -5348,27 +4526,26 @@ else $as_nop fi rm -f conftest* fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 -printf "%s\n" "$lt_cv_nm_interface" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 +$as_echo "$lt_cv_nm_interface" >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 -printf %s "checking whether ln -s works... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 -printf "%s\n" "no, using $LN_S" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 -printf %s "checking the maximum length of command line arguments... " >&6; } -if test ${lt_cv_sys_max_cmd_len+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 +$as_echo_n "checking the maximum length of command line arguments... " >&6; } +if ${lt_cv_sys_max_cmd_len+:} false; then : + $as_echo_n "(cached) " >&6 +else i=0 teststring=ABCD @@ -5495,11 +4672,11 @@ else $as_nop fi if test -n "$lt_cv_sys_max_cmd_len"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 -printf "%s\n" "$lt_cv_sys_max_cmd_len" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 +$as_echo "$lt_cv_sys_max_cmd_len" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5 -printf "%s\n" "none" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 +$as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len @@ -5543,12 +4720,11 @@ esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 -printf %s "checking how to convert $build file names to $host format... " >&6; } -if test ${lt_cv_to_host_file_cmd+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 +$as_echo_n "checking how to convert $build file names to $host format... " >&6; } +if ${lt_cv_to_host_file_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else case $host in *-*-mingw* ) case $build in @@ -5584,19 +4760,18 @@ esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 -printf "%s\n" "$lt_cv_to_host_file_cmd" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 +$as_echo "$lt_cv_to_host_file_cmd" >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 -printf %s "checking how to convert $build file names to toolchain format... " >&6; } -if test ${lt_cv_to_tool_file_cmd+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 +$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } +if ${lt_cv_to_tool_file_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in @@ -5612,23 +4787,22 @@ esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 -printf "%s\n" "$lt_cv_to_tool_file_cmd" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 +$as_echo "$lt_cv_to_tool_file_cmd" >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 -printf %s "checking for $LD option to reload object files... " >&6; } -if test ${lt_cv_ld_reload_flag+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 +$as_echo_n "checking for $LD option to reload object files... " >&6; } +if ${lt_cv_ld_reload_flag+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_ld_reload_flag='-r' fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 -printf "%s\n" "$lt_cv_ld_reload_flag" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 +$as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; @@ -5661,12 +4835,11 @@ esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_OBJDUMP+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else @@ -5674,15 +4847,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -5693,11 +4862,11 @@ fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 -printf "%s\n" "$OBJDUMP" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 +$as_echo "$OBJDUMP" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -5706,12 +4875,11 @@ if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_OBJDUMP+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else @@ -5719,15 +4887,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -5738,11 +4902,11 @@ fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 -printf "%s\n" "$ac_ct_OBJDUMP" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 +$as_echo "$ac_ct_OBJDUMP" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then @@ -5750,8 +4914,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP @@ -5767,12 +4931,11 @@ test -z "$OBJDUMP" && OBJDUMP=objdump -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 -printf %s "checking how to recognize dependent libraries... " >&6; } -if test ${lt_cv_deplibs_check_method+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 +$as_echo_n "checking how to recognize dependent libraries... " >&6; } +if ${lt_cv_deplibs_check_method+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' @@ -5970,8 +5133,8 @@ os2*) esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 -printf "%s\n" "$lt_cv_deplibs_check_method" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 +$as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no @@ -6015,12 +5178,11 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_DLLTOOL+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else @@ -6028,15 +5190,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6047,11 +5205,11 @@ fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 -printf "%s\n" "$DLLTOOL" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 +$as_echo "$DLLTOOL" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -6060,12 +5218,11 @@ if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_DLLTOOL+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else @@ -6073,15 +5230,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6092,11 +5245,11 @@ fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 -printf "%s\n" "$ac_ct_DLLTOOL" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 +$as_echo "$ac_ct_DLLTOOL" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then @@ -6104,8 +5257,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL @@ -6122,12 +5275,11 @@ test -z "$DLLTOOL" && DLLTOOL=dlltool -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 -printf %s "checking how to associate runtime and link libraries... " >&6; } -if test ${lt_cv_sharedlib_from_linklib_cmd+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 +$as_echo_n "checking how to associate runtime and link libraries... " >&6; } +if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in @@ -6150,8 +5302,8 @@ cygwin* | mingw* | pw32* | cegcc*) esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 -printf "%s\n" "$lt_cv_sharedlib_from_linklib_cmd" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 +$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO @@ -6167,12 +5319,11 @@ if test -n "$ac_tool_prefix"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_AR+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else @@ -6180,15 +5331,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6199,11 +5346,11 @@ fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 -printf "%s\n" "$AR" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -6216,12 +5363,11 @@ if test -z "$AR"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_AR+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else @@ -6229,15 +5375,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6248,11 +5390,11 @@ fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 -printf "%s\n" "$ac_ct_AR" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -6264,8 +5406,8 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR @@ -6285,32 +5427,30 @@ fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 -printf %s "checking for archiver @FILE support... " >&6; } -if test ${lt_cv_ar_at_file+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 +$as_echo_n "checking for archiver @FILE support... " >&6; } +if ${lt_cv_ar_at_file+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. @@ -6318,7 +5458,7 @@ then : { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ @@ -6327,11 +5467,11 @@ then : rm -f conftest.* libconftest.a fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 -printf "%s\n" "$lt_cv_ar_at_file" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 +$as_echo "$lt_cv_ar_at_file" >&6; } if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= @@ -6348,12 +5488,11 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_STRIP+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else @@ -6361,15 +5500,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6380,11 +5515,11 @@ fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 -printf "%s\n" "$STRIP" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -6393,12 +5528,11 @@ if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_STRIP+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else @@ -6406,15 +5540,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6425,11 +5555,11 @@ fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 -printf "%s\n" "$ac_ct_STRIP" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then @@ -6437,8 +5567,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP @@ -6457,12 +5587,11 @@ test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_RANLIB+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else @@ -6470,15 +5599,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6489,11 +5614,11 @@ fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 -printf "%s\n" "$RANLIB" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -6502,12 +5627,11 @@ if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_RANLIB+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else @@ -6515,15 +5639,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6534,11 +5654,11 @@ fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 -printf "%s\n" "$ac_ct_RANLIB" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then @@ -6546,8 +5666,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB @@ -6611,12 +5731,11 @@ for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_AWK+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else @@ -6624,15 +5743,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6643,11 +5758,11 @@ fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 -printf "%s\n" "$AWK" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -6683,12 +5798,11 @@ compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 -printf %s "checking command to parse $NM output from $compiler object... " >&6; } -if test ${lt_cv_sys_global_symbol_pipe+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 +$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } +if ${lt_cv_sys_global_symbol_pipe+:} false; then : + $as_echo_n "(cached) " >&6 +else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] @@ -6840,14 +5954,14 @@ _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then @@ -6916,7 +6030,7 @@ _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest$ac_exeext; then pipe_works=yes fi @@ -6951,11 +6065,11 @@ if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 -printf "%s\n" "failed" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 +$as_echo "failed" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -printf "%s\n" "ok" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } fi # Response file support. @@ -7001,14 +6115,13 @@ fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 -printf %s "checking for sysroot... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 +$as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. -if test ${with_sysroot+y} -then : +if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; -else $as_nop +else with_sysroot=no fi @@ -7026,25 +6139,24 @@ case $with_sysroot in #( no|'') ;; #( *) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 -printf "%s\n" "$with_sysroot" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 +$as_echo "$with_sysroot" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 -printf "%s\n" "${lt_sysroot:-no}" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 +$as_echo "${lt_sysroot:-no}" >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 -printf %s "checking for a working dd... " >&6; } -if test ${ac_cv_path_lt_DD+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 +$as_echo_n "checking for a working dd... " >&6; } +if ${ac_cv_path_lt_DD+:} false; then : + $as_echo_n "(cached) " >&6 +else printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i : ${lt_DD:=$DD} @@ -7055,15 +6167,10 @@ if test -z "$lt_DD"; then for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_prog in dd - do + test -z "$as_dir" && as_dir=. + for ac_prog in dd; do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_lt_DD="$as_dir$ac_prog$ac_exec_ext" + ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_lt_DD" || continue if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ @@ -7083,16 +6190,15 @@ fi rm -f conftest.i conftest2.i conftest.out fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 -printf "%s\n" "$ac_cv_path_lt_DD" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 +$as_echo "$ac_cv_path_lt_DD" >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 -printf %s "checking how to truncate binary pipes... " >&6; } -if test ${lt_cv_truncate_bin+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 +$as_echo_n "checking how to truncate binary pipes... " >&6; } +if ${lt_cv_truncate_bin+:} false; then : + $as_echo_n "(cached) " >&6 +else printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i lt_cv_truncate_bin= @@ -7103,8 +6209,8 @@ fi rm -f conftest.i conftest2.i conftest.out test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 -printf "%s\n" "$lt_cv_truncate_bin" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 +$as_echo "$lt_cv_truncate_bin" >&6; } @@ -7127,8 +6233,7 @@ func_cc_basename () } # Check whether --enable-libtool-lock was given. -if test ${enable_libtool_lock+y} -then : +if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi @@ -7144,7 +6249,7 @@ ia64-*-hpux*) if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) @@ -7164,7 +6269,7 @@ ia64-*-hpux*) if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test yes = "$lt_cv_prog_gnu_ld"; then case `/usr/bin/file conftest.$ac_objext` in @@ -7202,7 +6307,7 @@ mips64*-*linux*) if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then emul=elf case `/usr/bin/file conftest.$ac_objext` in @@ -7243,7 +6348,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) @@ -7306,12 +6411,11 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 -printf %s "checking whether the C compiler needs -belf... " >&6; } -if test ${lt_cv_cc_needs_belf+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 +$as_echo_n "checking whether the C compiler needs -belf... " >&6; } +if ${lt_cv_cc_needs_belf+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -7322,20 +6426,19 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes -else $as_nop +else lt_cv_cc_needs_belf=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -7344,8 +6447,8 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 -printf "%s\n" "$lt_cv_cc_needs_belf" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 +$as_echo "$lt_cv_cc_needs_belf" >&6; } if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS=$SAVE_CFLAGS @@ -7358,7 +6461,7 @@ printf "%s\n" "$lt_cv_cc_needs_belf" >&6; } if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) @@ -7395,12 +6498,11 @@ need_locks=$enable_libtool_lock if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_MANIFEST_TOOL+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else @@ -7408,15 +6510,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7427,11 +6525,11 @@ fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 -printf "%s\n" "$MANIFEST_TOOL" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 +$as_echo "$MANIFEST_TOOL" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -7440,12 +6538,11 @@ if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_MANIFEST_TOOL+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else @@ -7453,15 +6550,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7472,11 +6565,11 @@ fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 -printf "%s\n" "$ac_ct_MANIFEST_TOOL" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 +$as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then @@ -7484,8 +6577,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL @@ -7495,12 +6588,11 @@ else fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 -printf %s "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } -if test ${lt_cv_path_mainfest_tool+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 +$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } +if ${lt_cv_path_mainfest_tool+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out @@ -7510,8 +6602,8 @@ else $as_nop fi rm -f conftest* fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 -printf "%s\n" "$lt_cv_path_mainfest_tool" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 +$as_echo "$lt_cv_path_mainfest_tool" >&6; } if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi @@ -7526,12 +6618,11 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_DSYMUTIL+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DSYMUTIL+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else @@ -7539,15 +6630,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7558,11 +6645,11 @@ fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 -printf "%s\n" "$DSYMUTIL" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 +$as_echo "$DSYMUTIL" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -7571,12 +6658,11 @@ if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_DSYMUTIL+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else @@ -7584,15 +6670,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7603,11 +6685,11 @@ fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 -printf "%s\n" "$ac_ct_DSYMUTIL" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 +$as_echo "$ac_ct_DSYMUTIL" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then @@ -7615,8 +6697,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL @@ -7628,12 +6710,11 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_NMEDIT+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_NMEDIT+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else @@ -7641,15 +6722,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7660,11 +6737,11 @@ fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 -printf "%s\n" "$NMEDIT" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 +$as_echo "$NMEDIT" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -7673,12 +6750,11 @@ if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_NMEDIT+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else @@ -7686,15 +6762,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7705,11 +6777,11 @@ fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 -printf "%s\n" "$ac_ct_NMEDIT" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 +$as_echo "$ac_ct_NMEDIT" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then @@ -7717,8 +6789,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT @@ -7730,12 +6802,11 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_LIPO+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_LIPO+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else @@ -7743,15 +6814,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7762,11 +6829,11 @@ fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 -printf "%s\n" "$LIPO" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 +$as_echo "$LIPO" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -7775,12 +6842,11 @@ if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_LIPO+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_LIPO+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else @@ -7788,15 +6854,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7807,11 +6869,11 @@ fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 -printf "%s\n" "$ac_ct_LIPO" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 +$as_echo "$ac_ct_LIPO" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then @@ -7819,8 +6881,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO @@ -7832,12 +6894,11 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_OTOOL+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else @@ -7845,15 +6906,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7864,11 +6921,11 @@ fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 -printf "%s\n" "$OTOOL" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 +$as_echo "$OTOOL" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -7877,12 +6934,11 @@ if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_OTOOL+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else @@ -7890,15 +6946,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7909,11 +6961,11 @@ fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 -printf "%s\n" "$ac_ct_OTOOL" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 +$as_echo "$ac_ct_OTOOL" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then @@ -7921,8 +6973,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL @@ -7934,12 +6986,11 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_OTOOL64+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OTOOL64+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else @@ -7947,15 +6998,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7966,11 +7013,11 @@ fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 -printf "%s\n" "$OTOOL64" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 +$as_echo "$OTOOL64" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -7979,12 +7026,11 @@ if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_OTOOL64+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else @@ -7992,15 +7038,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -8011,11 +7053,11 @@ fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 -printf "%s\n" "$ac_ct_OTOOL64" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 +$as_echo "$ac_ct_OTOOL64" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then @@ -8023,8 +7065,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 @@ -8059,12 +7101,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 -printf %s "checking for -single_module linker flag... " >&6; } -if test ${lt_cv_apple_cc_single_mod+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 +$as_echo_n "checking for -single_module linker flag... " >&6; } +if ${lt_cv_apple_cc_single_mod+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_apple_cc_single_mod=no if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override @@ -8093,15 +7134,14 @@ else $as_nop rm -f conftest.* fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 -printf "%s\n" "$lt_cv_apple_cc_single_mod" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 +$as_echo "$lt_cv_apple_cc_single_mod" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 -printf %s "checking for -exported_symbols_list linker flag... " >&6; } -if test ${lt_cv_ld_exported_symbols_list+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 +$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } +if ${lt_cv_ld_exported_symbols_list+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym @@ -8110,33 +7150,31 @@ else $as_nop /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes -else $as_nop +else lt_cv_ld_exported_symbols_list=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 -printf "%s\n" "$lt_cv_ld_exported_symbols_list" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 +$as_echo "$lt_cv_ld_exported_symbols_list" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 -printf %s "checking for -force_load linker flag... " >&6; } -if test ${lt_cv_ld_force_load+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 +$as_echo_n "checking for -force_load linker flag... " >&6; } +if ${lt_cv_ld_force_load+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} @@ -8164,8 +7202,8 @@ _LT_EOF rm -rf conftest.dSYM fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 -printf "%s\n" "$lt_cv_ld_force_load" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 +$as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; @@ -8231,43 +7269,286 @@ func_munge_path_list () esac } -ac_header= ac_cache= -for ac_item in $ac_header_c_list +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes do - if test $ac_cache; then - ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default" - if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then - printf "%s\n" "#define $ac_item 1" >> confdefs.h - fi - ac_header= ac_cache= - elif test $ac_header; then - ac_cache=$ac_item - else - ac_header=$ac_item - fi -done + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then +$as_echo "#define STDC_HEADERS 1" >>confdefs.h -if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes -then : +fi -printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF fi -ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default + +done + + +for ac_header in dlfcn.h +do : + ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " -if test "x$ac_cv_header_dlfcn_h" = xyes -then : - printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h +if test "x$ac_cv_header_dlfcn_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_DLFCN_H 1 +_ACEOF fi +done + @@ -8280,12 +7561,11 @@ case $host in if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_AS+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AS+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$AS"; then ac_cv_prog_AS="$AS" # Let the user override the test. else @@ -8293,15 +7573,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AS="${ac_tool_prefix}as" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -8312,11 +7588,11 @@ fi fi AS=$ac_cv_prog_AS if test -n "$AS"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 -printf "%s\n" "$AS" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 +$as_echo "$AS" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -8325,12 +7601,11 @@ if test -z "$ac_cv_prog_AS"; then ac_ct_AS=$AS # Extract the first word of "as", so it can be a program name with args. set dummy as; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_AS+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AS+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_AS"; then ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. else @@ -8338,15 +7613,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AS="as" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -8357,11 +7628,11 @@ fi fi ac_ct_AS=$ac_cv_prog_ac_ct_AS if test -n "$ac_ct_AS"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 -printf "%s\n" "$ac_ct_AS" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 +$as_echo "$ac_ct_AS" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_AS" = x; then @@ -8369,8 +7640,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AS=$ac_ct_AS @@ -8382,12 +7653,11 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_DLLTOOL+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else @@ -8395,15 +7665,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -8414,11 +7680,11 @@ fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 -printf "%s\n" "$DLLTOOL" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 +$as_echo "$DLLTOOL" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -8427,12 +7693,11 @@ if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_DLLTOOL+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else @@ -8440,15 +7705,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -8459,11 +7720,11 @@ fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 -printf "%s\n" "$ac_ct_DLLTOOL" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 +$as_echo "$ac_ct_DLLTOOL" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then @@ -8471,8 +7732,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL @@ -8484,12 +7745,11 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_OBJDUMP+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else @@ -8497,15 +7757,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -8516,11 +7772,11 @@ fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 -printf "%s\n" "$OBJDUMP" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 +$as_echo "$OBJDUMP" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -8529,12 +7785,11 @@ if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_OBJDUMP+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else @@ -8542,15 +7797,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -8561,11 +7812,11 @@ fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 -printf "%s\n" "$ac_ct_OBJDUMP" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 +$as_echo "$ac_ct_OBJDUMP" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then @@ -8573,8 +7824,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP @@ -8611,8 +7862,7 @@ test -z "$OBJDUMP" && OBJDUMP=objdump # Check whether --enable-shared was given. -if test ${enable_shared+y} -then : +if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; @@ -8630,7 +7880,7 @@ then : IFS=$lt_save_ifs ;; esac -else $as_nop +else enable_shared=yes fi @@ -8643,8 +7893,7 @@ fi # Check whether --enable-static was given. -if test ${enable_static+y} -then : +if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; @@ -8662,7 +7911,7 @@ then : IFS=$lt_save_ifs ;; esac -else $as_nop +else enable_static=yes fi @@ -8676,8 +7925,7 @@ fi # Check whether --with-pic was given. -if test ${with_pic+y} -then : +if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; @@ -8694,7 +7942,7 @@ then : IFS=$lt_save_ifs ;; esac -else $as_nop +else pic_mode=default fi @@ -8706,8 +7954,7 @@ fi # Check whether --enable-fast-install was given. -if test ${enable_fast_install+y} -then : +if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; @@ -8725,7 +7972,7 @@ then : IFS=$lt_save_ifs ;; esac -else $as_nop +else enable_fast_install=yes fi @@ -8739,12 +7986,11 @@ fi shared_archive_member_spec= case $host,$enable_shared in power*-*-aix[5-9]*,yes) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 -printf %s "checking which variant of shared library versioning to provide... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 +$as_echo_n "checking which variant of shared library versioning to provide... " >&6; } # Check whether --with-aix-soname was given. -if test ${with_aix_soname+y} -then : +if test "${with_aix_soname+set}" = set; then : withval=$with_aix_soname; case $withval in aix|svr4|both) ;; @@ -8753,19 +7999,18 @@ then : ;; esac lt_cv_with_aix_soname=$with_aix_soname -else $as_nop - if test ${lt_cv_with_aix_soname+y} -then : - printf %s "(cached) " >&6 -else $as_nop +else + if ${lt_cv_with_aix_soname+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_with_aix_soname=aix fi with_aix_soname=$lt_cv_with_aix_soname fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 -printf "%s\n" "$with_aix_soname" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 +$as_echo "$with_aix_soname" >&6; } if test aix != "$with_aix_soname"; then # For the AIX way of multilib, we name the shared archive member # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', @@ -8847,12 +8092,11 @@ if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 -printf %s "checking for objdir... " >&6; } -if test ${lt_cv_objdir+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 +$as_echo_n "checking for objdir... " >&6; } +if ${lt_cv_objdir+:} false; then : + $as_echo_n "(cached) " >&6 +else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then @@ -8863,15 +8107,17 @@ else fi rmdir .libs 2>/dev/null fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 -printf "%s\n" "$lt_cv_objdir" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 +$as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir -printf "%s\n" "#define LT_OBJDIR \"$lt_cv_objdir/\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define LT_OBJDIR "$lt_cv_objdir/" +_ACEOF @@ -8917,12 +8163,11 @@ test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 -printf %s "checking for ${ac_tool_prefix}file... " >&6; } -if test ${lt_cv_path_MAGIC_CMD+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 +$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } +if ${lt_cv_path_MAGIC_CMD+:} false; then : + $as_echo_n "(cached) " >&6 +else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. @@ -8971,11 +8216,11 @@ fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 -printf "%s\n" "$MAGIC_CMD" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -8984,12 +8229,11 @@ fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for file" >&5 -printf %s "checking for file... " >&6; } -if test ${lt_cv_path_MAGIC_CMD+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 +$as_echo_n "checking for file... " >&6; } +if ${lt_cv_path_MAGIC_CMD+:} false; then : + $as_echo_n "(cached) " >&6 +else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. @@ -9038,11 +8282,11 @@ fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 -printf "%s\n" "$MAGIC_CMD" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -9127,12 +8371,11 @@ if test yes = "$GCC"; then lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 -printf %s "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } -if test ${lt_cv_prog_compiler_rtti_exceptions+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } +if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext @@ -9163,8 +8406,8 @@ else $as_nop $RM conftest* fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 -printf "%s\n" "$lt_cv_prog_compiler_rtti_exceptions" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" @@ -9521,28 +8764,26 @@ case $host_os in ;; esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 -printf %s "checking for $compiler option to produce PIC... " >&6; } -if test ${lt_cv_prog_compiler_pic+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; } +if ${lt_cv_prog_compiler_pic+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 -printf "%s\n" "$lt_cv_prog_compiler_pic" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 +$as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 -printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } -if test ${lt_cv_prog_compiler_pic_works+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } +if ${lt_cv_prog_compiler_pic_works+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext @@ -9573,8 +8814,8 @@ else $as_nop $RM conftest* fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 -printf "%s\n" "$lt_cv_prog_compiler_pic_works" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 +$as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test yes = "$lt_cv_prog_compiler_pic_works"; then case $lt_prog_compiler_pic in @@ -9602,12 +8843,11 @@ fi # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 -printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } -if test ${lt_cv_prog_compiler_static_works+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if ${lt_cv_prog_compiler_static_works+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_prog_compiler_static_works=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" @@ -9631,8 +8871,8 @@ else $as_nop LDFLAGS=$save_LDFLAGS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 -printf "%s\n" "$lt_cv_prog_compiler_static_works" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 +$as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test yes = "$lt_cv_prog_compiler_static_works"; then : @@ -9646,12 +8886,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if test ${lt_cv_prog_compiler_c_o+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if ${lt_cv_prog_compiler_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest @@ -9694,20 +8933,19 @@ else $as_nop $RM conftest* fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 -printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if test ${lt_cv_prog_compiler_c_o+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if ${lt_cv_prog_compiler_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest @@ -9750,8 +8988,8 @@ else $as_nop $RM conftest* fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 -printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } @@ -9759,19 +8997,19 @@ printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; } hard_links=nottested if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 -printf %s "checking if we can lock with hard links... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 +$as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 -printf "%s\n" "$hard_links" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 +$as_echo "$hard_links" >&6; } if test no = "$hard_links"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 -printf "%s\n" "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 +$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else @@ -9783,8 +9021,8 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= @@ -10340,23 +9578,21 @@ _LT_EOF if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else - if test ${lt_cv_aix_libpath_+y} -then : - printf %s "(cached) " >&6 -else $as_nop + if ${lt_cv_aix_libpath_+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { @@ -10371,7 +9607,7 @@ then : lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib @@ -10395,23 +9631,21 @@ fi if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else - if test ${lt_cv_aix_libpath_+y} -then : - printf %s "(cached) " >&6 -else $as_nop + if ${lt_cv_aix_libpath_+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { @@ -10426,7 +9660,7 @@ then : lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib @@ -10677,12 +9911,11 @@ fi # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 -printf %s "checking if $CC understands -b... " >&6; } -if test ${lt_cv_prog_compiler__b+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 +$as_echo_n "checking if $CC understands -b... " >&6; } +if ${lt_cv_prog_compiler__b+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_prog_compiler__b=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -b" @@ -10706,8 +9939,8 @@ else $as_nop LDFLAGS=$save_LDFLAGS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 -printf "%s\n" "$lt_cv_prog_compiler__b" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 +$as_echo "$lt_cv_prog_compiler__b" >&6; } if test yes = "$lt_cv_prog_compiler__b"; then archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' @@ -10747,30 +9980,28 @@ fi # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 -printf %s "checking whether the $host_os linker accepts -exported_symbol... " >&6; } -if test ${lt_cv_irix_exported_symbol+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 +$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } +if ${lt_cv_irix_exported_symbol+:} false; then : + $as_echo_n "(cached) " >&6 +else save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes -else $as_nop +else lt_cv_irix_exported_symbol=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 -printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 +$as_echo "$lt_cv_irix_exported_symbol" >&6; } if test yes = "$lt_cv_irix_exported_symbol"; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi @@ -11051,8 +10282,8 @@ printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; } fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 -printf "%s\n" "$ld_shlibs" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 +$as_echo "$ld_shlibs" >&6; } test no = "$ld_shlibs" && can_build_shared=no with_gnu_ld=$with_gnu_ld @@ -11088,19 +10319,18 @@ x|xyes) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 -printf %s "checking whether -lc should be explicitly linked in... " >&6; } -if test ${lt_cv_archive_cmds_need_lc+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 +$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } +if ${lt_cv_archive_cmds_need_lc+:} false; then : + $as_echo_n "(cached) " >&6 +else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest @@ -11118,7 +10348,7 @@ else $as_nop if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no @@ -11132,8 +10362,8 @@ else $as_nop $RM conftest* fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 -printf "%s\n" "$lt_cv_archive_cmds_need_lc" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 +$as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac @@ -11292,8 +10522,8 @@ esac - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 -printf %s "checking dynamic linker characteristics... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 +$as_echo_n "checking dynamic linker characteristics... " >&6; } if test yes = "$GCC"; then case $host_os in @@ -11856,10 +11086,9 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH - if test ${lt_cv_shlibpath_overrides_runpath+y} -then : - printf %s "(cached) " >&6 -else $as_nop + if ${lt_cv_shlibpath_overrides_runpath+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir @@ -11869,21 +11098,19 @@ else $as_nop /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : - if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null -then : +if ac_fn_c_try_link "$LINENO"; then : + if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir @@ -12120,8 +11347,8 @@ uts4*) dynamic_linker=no ;; esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 -printf "%s\n" "$dynamic_linker" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 +$as_echo "$dynamic_linker" >&6; } test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" @@ -12242,8 +11469,8 @@ configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 -printf %s "checking how to hardcode library paths into programs... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 +$as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || @@ -12267,8 +11494,8 @@ else # directories. hardcode_action=unsupported fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 -printf "%s\n" "$hardcode_action" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 +$as_echo "$hardcode_action" >&6; } if test relink = "$hardcode_action" || test yes = "$inherit_rpath"; then @@ -12312,12 +11539,11 @@ else darwin*) # if libdl is installed we need to link against it - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -printf %s "checking for dlopen in -ldl... " >&6; } -if test ${ac_cv_lib_dl_dlopen+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if ${ac_cv_lib_dl_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -12326,31 +11552,32 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char dlopen (); int -main (void) +main () { return dlopen (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes -else $as_nop +else ac_cv_lib_dl_dlopen=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl -else $as_nop +else lt_cv_dlopen=dyld lt_cv_dlopen_libs= @@ -12370,16 +11597,14 @@ fi *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" -if test "x$ac_cv_func_shl_load" = xyes -then : +if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen=shl_load -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 -printf %s "checking for shl_load in -ldld... " >&6; } -if test ${ac_cv_lib_dld_shl_load+y} -then : - printf %s "(cached) " >&6 -else $as_nop +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 +$as_echo_n "checking for shl_load in -ldld... " >&6; } +if ${ac_cv_lib_dld_shl_load+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -12388,42 +11613,41 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char shl_load (); int -main (void) +main () { return shl_load (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes -else $as_nop +else ac_cv_lib_dld_shl_load=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 -printf "%s\n" "$ac_cv_lib_dld_shl_load" >&6; } -if test "x$ac_cv_lib_dld_shl_load" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 +$as_echo "$ac_cv_lib_dld_shl_load" >&6; } +if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld -else $as_nop +else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" -if test "x$ac_cv_func_dlopen" = xyes -then : +if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen=dlopen -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -printf %s "checking for dlopen in -ldl... " >&6; } -if test ${ac_cv_lib_dl_dlopen+y} -then : - printf %s "(cached) " >&6 -else $as_nop +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if ${ac_cv_lib_dl_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -12432,37 +11656,37 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char dlopen (); int -main (void) +main () { return dlopen (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes -else $as_nop +else ac_cv_lib_dl_dlopen=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 -printf %s "checking for dlopen in -lsvld... " >&6; } -if test ${ac_cv_lib_svld_dlopen+y} -then : - printf %s "(cached) " >&6 -else $as_nop +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 +$as_echo_n "checking for dlopen in -lsvld... " >&6; } +if ${ac_cv_lib_svld_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -12471,37 +11695,37 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char dlopen (); int -main (void) +main () { return dlopen (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes -else $as_nop +else ac_cv_lib_svld_dlopen=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 -printf "%s\n" "$ac_cv_lib_svld_dlopen" >&6; } -if test "x$ac_cv_lib_svld_dlopen" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 +$as_echo "$ac_cv_lib_svld_dlopen" >&6; } +if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 -printf %s "checking for dld_link in -ldld... " >&6; } -if test ${ac_cv_lib_dld_dld_link+y} -then : - printf %s "(cached) " >&6 -else $as_nop +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 +$as_echo_n "checking for dld_link in -ldld... " >&6; } +if ${ac_cv_lib_dld_dld_link+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -12510,29 +11734,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char dld_link (); int -main (void) +main () { return dld_link (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes -else $as_nop +else ac_cv_lib_dld_dld_link=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 -printf "%s\n" "$ac_cv_lib_dld_dld_link" >&6; } -if test "x$ac_cv_lib_dld_dld_link" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 +$as_echo "$ac_cv_lib_dld_dld_link" >&6; } +if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld fi @@ -12571,12 +11796,11 @@ fi save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 -printf %s "checking whether a program can dlopen itself... " >&6; } -if test ${lt_cv_dlopen_self+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 +$as_echo_n "checking whether a program can dlopen itself... " >&6; } +if ${lt_cv_dlopen_self+:} false; then : + $as_echo_n "(cached) " >&6 +else if test yes = "$cross_compiling"; then : lt_cv_dlopen_self=cross else @@ -12655,7 +11879,7 @@ _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? @@ -12673,17 +11897,16 @@ rm -fr conftest* fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 -printf "%s\n" "$lt_cv_dlopen_self" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 +$as_echo "$lt_cv_dlopen_self" >&6; } if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 -printf %s "checking whether a statically linked program can dlopen itself... " >&6; } -if test ${lt_cv_dlopen_self_static+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 +$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } +if ${lt_cv_dlopen_self_static+:} false; then : + $as_echo_n "(cached) " >&6 +else if test yes = "$cross_compiling"; then : lt_cv_dlopen_self_static=cross else @@ -12762,7 +11985,7 @@ _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? @@ -12780,8 +12003,8 @@ rm -fr conftest* fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 -printf "%s\n" "$lt_cv_dlopen_self_static" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 +$as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS=$save_CPPFLAGS @@ -12819,40 +12042,40 @@ fi striplib= old_striplib= -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 -printf %s "checking whether stripping libraries is possible... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 +$as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -z "$STRIP"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } else if $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then old_striplib="$STRIP --strip-debug" striplib="$STRIP --strip-unneeded" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } else case $host_os in darwin*) # FIXME - insert some real tests, host_os isn't really good enough striplib="$STRIP -x" old_striplib="$STRIP -S" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } ;; freebsd*) if $STRIP -V 2>&1 | $GREP "elftoolchain" >/dev/null; then old_striplib="$STRIP --strip-debug" striplib="$STRIP --strip-unneeded" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi ;; *) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } ;; esac fi @@ -12870,13 +12093,13 @@ fi # Report what library types will actually be built - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 -printf %s "checking if libtool supports shared libraries... " >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 -printf "%s\n" "$can_build_shared" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 +$as_echo_n "checking if libtool supports shared libraries... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 +$as_echo "$can_build_shared" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 -printf %s "checking whether to build shared libraries... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 +$as_echo_n "checking whether to build shared libraries... " >&6; } test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and @@ -12900,15 +12123,15 @@ printf %s "checking whether to build shared libraries... " >&6; } fi ;; esac - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 -printf "%s\n" "$enable_shared" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 +$as_echo "$enable_shared" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 -printf %s "checking whether to build static libraries... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 +$as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 -printf "%s\n" "$enable_static" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 +$as_echo "$enable_static" >&6; } @@ -12947,12 +12170,11 @@ CC=$lt_save_CC if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args. set dummy ${ac_tool_prefix}windres; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_RC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$RC"; then ac_cv_prog_RC="$RC" # Let the user override the test. else @@ -12960,15 +12182,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RC="${ac_tool_prefix}windres" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -12979,11 +12197,11 @@ fi fi RC=$ac_cv_prog_RC if test -n "$RC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RC" >&5 -printf "%s\n" "$RC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RC" >&5 +$as_echo "$RC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -12992,12 +12210,11 @@ if test -z "$ac_cv_prog_RC"; then ac_ct_RC=$RC # Extract the first word of "windres", so it can be a program name with args. set dummy windres; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_RC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_RC"; then ac_cv_prog_ac_ct_RC="$ac_ct_RC" # Let the user override the test. else @@ -13005,15 +12222,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RC="windres" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -13024,11 +12237,11 @@ fi fi ac_ct_RC=$ac_cv_prog_ac_ct_RC if test -n "$ac_ct_RC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RC" >&5 -printf "%s\n" "$ac_ct_RC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RC" >&5 +$as_echo "$ac_ct_RC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_RC" = x; then @@ -13036,8 +12249,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RC=$ac_ct_RC @@ -13148,12 +12361,11 @@ for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_AWK+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else @@ -13161,15 +12373,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -13180,11 +12388,11 @@ fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 -printf "%s\n" "$AWK" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -13199,12 +12407,11 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else @@ -13212,15 +12419,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -13231,11 +12434,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -13244,12 +12447,11 @@ if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else @@ -13257,15 +12459,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -13276,11 +12474,11 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -printf "%s\n" "$ac_ct_CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then @@ -13288,8 +12486,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC @@ -13302,12 +12500,11 @@ if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else @@ -13315,15 +12512,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -13334,11 +12527,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -13347,12 +12540,11 @@ fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else @@ -13361,19 +12553,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -13389,18 +12577,18 @@ if test $ac_prog_rejected = yes; then # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift - ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@" + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -13411,12 +12599,11 @@ if test -z "$CC"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else @@ -13424,15 +12611,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -13443,11 +12626,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -13460,12 +12643,11 @@ if test -z "$CC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else @@ -13473,15 +12655,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -13492,11 +12670,11 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -printf "%s\n" "$ac_ct_CC" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -13508,138 +12686,34 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args. -set dummy ${ac_tool_prefix}clang; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}clang" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "clang", so it can be a program name with args. -set dummy clang; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="clang" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -printf "%s\n" "$ac_ct_CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - fi -test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. -printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 -for ac_option in --version -v -V -qversion -version; do +for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -13649,21 +12723,20 @@ printf "%s\n" "$ac_try_echo"; } >&5 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5 -printf %s "checking whether the compiler supports GNU C... " >&6; } -if test ${ac_cv_c_compiler_gnu+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { #ifndef __GNUC__ choke me @@ -13673,33 +12746,29 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes -else $as_nop +else ac_compiler_gnu=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; } -ac_compiler_gnu=$ac_cv_c_compiler_gnu - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi -ac_test_CFLAGS=${CFLAGS+y} +ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -printf %s "checking whether $CC accepts -g... " >&6; } -if test ${ac_cv_prog_cc_g+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no @@ -13708,60 +12777,57 @@ else $as_nop /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes -else $as_nop +else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : -else $as_nop +else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -printf "%s\n" "$ac_cv_prog_cc_g" >&6; } -if test $ac_test_CFLAGS; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then @@ -13776,144 +12842,94 @@ else CFLAGS= fi fi -ac_prog_cc_stdc=no -if test x$ac_prog_cc_stdc = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5 -printf %s "checking for $CC option to enable C11 features... " >&6; } -if test ${ac_cv_prog_cc_c11+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cc_c11=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -$ac_c_conftest_c11_program -_ACEOF -for ac_arg in '' -std=gnu11 -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_prog_cc_c11=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cc_c11" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC -fi +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} -if test "x$ac_cv_prog_cc_c11" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c11" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 -printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } - CC="$CC $ac_cv_prog_cc_c11" -fi - ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11 - ac_prog_cc_stdc=c11 -fi -fi -if test x$ac_prog_cc_stdc = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5 -printf %s "checking for $CC option to enable C99 features... " >&6; } -if test ${ac_cv_prog_cc_c99+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cc_c99=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_c_conftest_c99_program -_ACEOF -for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99= -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_prog_cc_c99=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cc_c99" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC -fi +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; -if test "x$ac_cv_prog_cc_c99" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c99" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 -printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } - CC="$CC $ac_cv_prog_cc_c99" -fi - ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 - ac_prog_cc_stdc=c99 -fi -fi -if test x$ac_prog_cc_stdc = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5 -printf %s "checking for $CC option to enable C89 features... " >&6; } -if test ${ac_cv_prog_cc_c89+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_c_conftest_c89_program +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} _ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO" -then : + if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi -rm -f core conftest.err conftest.$ac_objext conftest.beam +rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC -fi -if test "x$ac_cv_prog_cc_c89" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c89" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } - CC="$CC $ac_cv_prog_cc_c89" -fi - ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 - ac_prog_cc_stdc=c89 fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + fi ac_ext=c @@ -13922,12 +12938,6 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - - - - ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -13938,16 +12948,15 @@ if test -z "$CXX"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++ + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CXX+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else @@ -13955,15 +12964,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -13974,11 +12979,11 @@ fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 -printf "%s\n" "$CXX" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -13987,16 +12992,15 @@ fi fi if test -z "$CXX"; then ac_ct_CXX=$CXX - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++ + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CXX+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else @@ -14004,15 +13008,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -14023,11 +13023,11 @@ fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 -printf "%s\n" "$ac_ct_CXX" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -14039,8 +13039,8 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX @@ -14050,7 +13050,7 @@ fi fi fi # Provide some information about the compiler. -printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do @@ -14060,7 +13060,7 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -14070,21 +13070,20 @@ printf "%s\n" "$ac_try_echo"; } >&5 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C++" >&5 -printf %s "checking whether the compiler supports GNU C++... " >&6; } -if test ${ac_cv_cxx_compiler_gnu+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if ${ac_cv_cxx_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { #ifndef __GNUC__ choke me @@ -14094,33 +13093,29 @@ main (void) return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : +if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes -else $as_nop +else ac_compiler_gnu=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 -printf "%s\n" "$ac_cv_cxx_compiler_gnu" >&6; } -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi -ac_test_CXXFLAGS=${CXXFLAGS+y} +ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 -printf %s "checking whether $CXX accepts -g... " >&6; } -if test ${ac_cv_prog_cxx_g+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if ${ac_cv_prog_cxx_g+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no @@ -14129,60 +13124,57 @@ else $as_nop /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : +if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes -else $as_nop +else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : +if ac_fn_cxx_try_compile "$LINENO"; then : -else $as_nop +else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : +if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 -printf "%s\n" "$ac_cv_prog_cxx_g" >&6; } -if test $ac_test_CXXFLAGS; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then @@ -14197,100 +13189,6 @@ else CXXFLAGS= fi fi -ac_prog_cxx_stdcxx=no -if test x$ac_prog_cxx_stdcxx = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5 -printf %s "checking for $CXX option to enable C++11 features... " >&6; } -if test ${ac_cv_prog_cxx_11+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cxx_11=no -ac_save_CXX=$CXX -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_cxx_conftest_cxx11_program -_ACEOF -for ac_arg in '' -std=gnu++11 -std=gnu++0x -std=c++11 -std=c++0x -qlanglvl=extended0x -AA -do - CXX="$ac_save_CXX $ac_arg" - if ac_fn_cxx_try_compile "$LINENO" -then : - ac_cv_prog_cxx_cxx11=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cxx_cxx11" != "xno" && break -done -rm -f conftest.$ac_ext -CXX=$ac_save_CXX -fi - -if test "x$ac_cv_prog_cxx_cxx11" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cxx_cxx11" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx11" >&5 -printf "%s\n" "$ac_cv_prog_cxx_cxx11" >&6; } - CXX="$CXX $ac_cv_prog_cxx_cxx11" -fi - ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11 - ac_prog_cxx_stdcxx=cxx11 -fi -fi -if test x$ac_prog_cxx_stdcxx = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5 -printf %s "checking for $CXX option to enable C++98 features... " >&6; } -if test ${ac_cv_prog_cxx_98+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cxx_98=no -ac_save_CXX=$CXX -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_cxx_conftest_cxx98_program -_ACEOF -for ac_arg in '' -std=gnu++98 -std=c++98 -qlanglvl=extended -AA -do - CXX="$ac_save_CXX $ac_arg" - if ac_fn_cxx_try_compile "$LINENO" -then : - ac_cv_prog_cxx_cxx98=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cxx_cxx98" != "xno" && break -done -rm -f conftest.$ac_ext -CXX=$ac_save_CXX -fi - -if test "x$ac_cv_prog_cxx_cxx98" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cxx_cxx98" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx98" >&5 -printf "%s\n" "$ac_cv_prog_cxx_cxx98" >&6; } - CXX="$CXX $ac_cv_prog_cxx_cxx98" -fi - ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98 - ac_prog_cxx_stdcxx=cxx98 -fi -fi - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -14315,32 +13213,36 @@ ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 -printf %s "checking how to run the C++ preprocessor... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 +$as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then - if test ${ac_cv_prog_CXXCPP+y} -then : - printf %s "(cached) " >&6 -else $as_nop - # Double quotes because $CXX needs to be expanded - for CXXCPP in "$CXX -E" cpp /lib/cpp + if ${ac_cv_prog_CXXCPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CXXCPP needs to be expanded + for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include +#ifdef __STDC__ +# include +#else +# include +#endif Syntax error _ACEOF -if ac_fn_cxx_try_cpp "$LINENO" -then : +if ac_fn_cxx_try_cpp "$LINENO"; then : -else $as_nop +else # Broken: fails on valid input. continue fi @@ -14352,11 +13254,10 @@ rm -f conftest.err conftest.i conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if ac_fn_cxx_try_cpp "$LINENO" -then : +if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue -else $as_nop +else # Passes both tests. ac_preproc_ok=: break @@ -14366,8 +13267,7 @@ rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok -then : +if $ac_preproc_ok; then : break fi @@ -14379,24 +13279,29 @@ fi else ac_cv_prog_CXXCPP=$CXXCPP fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 -printf "%s\n" "$CXXCPP" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 +$as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include +#ifdef __STDC__ +# include +#else +# include +#endif Syntax error _ACEOF -if ac_fn_cxx_try_cpp "$LINENO" -then : +if ac_fn_cxx_try_cpp "$LINENO"; then : -else $as_nop +else # Broken: fails on valid input. continue fi @@ -14408,11 +13313,10 @@ rm -f conftest.err conftest.i conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if ac_fn_cxx_try_cpp "$LINENO" -then : +if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue -else $as_nop +else # Passes both tests. ac_preproc_ok=: break @@ -14422,12 +13326,11 @@ rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok -then : +if $ac_preproc_ok; then : -else $as_nop - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi @@ -14563,18 +13466,17 @@ cc_basename=$func_cc_basename_result # Check whether --with-gnu-ld was given. -if test ${with_gnu_ld+y} -then : +if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes -else $as_nop +else with_gnu_ld=no fi ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 -printf %s "checking for ld used by $CC... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 +$as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw @@ -14603,16 +13505,15 @@ printf %s "checking for ld used by $CC... " >&6; } ;; esac elif test yes = "$with_gnu_ld"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 -printf %s "checking for GNU ld... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 -printf %s "checking for non-GNU ld... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } fi -if test ${lt_cv_path_LD+y} -then : - printf %s "(cached) " >&6 -else $as_nop +if ${lt_cv_path_LD+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do @@ -14641,19 +13542,18 @@ fi LD=$lt_cv_path_LD if test -n "$LD"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 -printf "%s\n" "$LD" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 +$as_echo "$LD" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 -printf %s "checking if the linker ($LD) is GNU ld... " >&6; } -if test ${lt_cv_prog_gnu_ld+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if ${lt_cv_prog_gnu_ld+:} false; then : + $as_echo_n "(cached) " >&6 +else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &1 &5 -printf "%s\n" "$lt_cv_prog_gnu_ld" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5 +$as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld @@ -14719,8 +13619,8 @@ with_gnu_ld=$lt_cv_prog_gnu_ld fi # PORTME: fill in a description of your system's C++ link characteristics - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } ld_shlibs_CXX=yes case $host_os in aix3*) @@ -14858,23 +13758,21 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else - if test ${lt_cv_aix_libpath__CXX+y} -then : - printf %s "(cached) " >&6 -else $as_nop + if ${lt_cv_aix_libpath__CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_cxx_try_link "$LINENO" -then : +if ac_fn_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { @@ -14889,7 +13787,7 @@ then : lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=/usr/lib:/lib @@ -14914,23 +13812,21 @@ fi if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else - if test ${lt_cv_aix_libpath__CXX+y} -then : - printf %s "(cached) " >&6 -else $as_nop + if ${lt_cv_aix_libpath__CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_cxx_try_link "$LINENO" -then : +if ac_fn_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { @@ -14945,7 +13841,7 @@ then : lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=/usr/lib:/lib @@ -15797,8 +14693,8 @@ fi ;; esac - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 -printf "%s\n" "$ld_shlibs_CXX" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 +$as_echo "$ld_shlibs_CXX" >&6; } test no = "$ld_shlibs_CXX" && can_build_shared=no GCC_CXX=$GXX @@ -15836,7 +14732,7 @@ esac if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Parse the compiler output and extract the necessary # objects, libraries and library flags. @@ -16318,28 +15214,26 @@ case $host_os in ;; esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 -printf %s "checking for $compiler option to produce PIC... " >&6; } -if test ${lt_cv_prog_compiler_pic_CXX+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; } +if ${lt_cv_prog_compiler_pic_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5 -printf "%s\n" "$lt_cv_prog_compiler_pic_CXX" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5 +$as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; } lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_CXX"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 -printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } -if test ${lt_cv_prog_compiler_pic_works_CXX+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 +$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } +if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_prog_compiler_pic_works_CXX=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext @@ -16370,8 +15264,8 @@ else $as_nop $RM conftest* fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 -printf "%s\n" "$lt_cv_prog_compiler_pic_works_CXX" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 +$as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; } if test yes = "$lt_cv_prog_compiler_pic_works_CXX"; then case $lt_prog_compiler_pic_CXX in @@ -16393,12 +15287,11 @@ fi # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 -printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } -if test ${lt_cv_prog_compiler_static_works_CXX+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if ${lt_cv_prog_compiler_static_works_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_prog_compiler_static_works_CXX=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" @@ -16422,8 +15315,8 @@ else $as_nop LDFLAGS=$save_LDFLAGS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 -printf "%s\n" "$lt_cv_prog_compiler_static_works_CXX" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 +$as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; } if test yes = "$lt_cv_prog_compiler_static_works_CXX"; then : @@ -16434,12 +15327,11 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if test ${lt_cv_prog_compiler_c_o_CXX+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest @@ -16482,17 +15374,16 @@ else $as_nop $RM conftest* fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 -printf "%s\n" "$lt_cv_prog_compiler_c_o_CXX" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 +$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if test ${lt_cv_prog_compiler_c_o_CXX+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest @@ -16535,8 +15426,8 @@ else $as_nop $RM conftest* fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 -printf "%s\n" "$lt_cv_prog_compiler_c_o_CXX" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 +$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } @@ -16544,19 +15435,19 @@ printf "%s\n" "$lt_cv_prog_compiler_c_o_CXX" >&6; } hard_links=nottested if test no = "$lt_cv_prog_compiler_c_o_CXX" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 -printf %s "checking if we can lock with hard links... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 +$as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 -printf "%s\n" "$hard_links" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 +$as_echo "$hard_links" >&6; } if test no = "$hard_links"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 -printf "%s\n" "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 +$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else @@ -16565,8 +15456,8 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' @@ -16605,8 +15496,8 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries ;; esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 -printf "%s\n" "$ld_shlibs_CXX" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 +$as_echo "$ld_shlibs_CXX" >&6; } test no = "$ld_shlibs_CXX" && can_build_shared=no with_gnu_ld_CXX=$with_gnu_ld @@ -16633,19 +15524,18 @@ x|xyes) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 -printf %s "checking whether -lc should be explicitly linked in... " >&6; } -if test ${lt_cv_archive_cmds_need_lc_CXX+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 +$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } +if ${lt_cv_archive_cmds_need_lc_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest @@ -16663,7 +15553,7 @@ else $as_nop if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc_CXX=no @@ -16677,8 +15567,8 @@ else $as_nop $RM conftest* fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5 -printf "%s\n" "$lt_cv_archive_cmds_need_lc_CXX" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5 +$as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; } archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX ;; esac @@ -16747,8 +15637,8 @@ esac - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 -printf %s "checking dynamic linker characteristics... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 +$as_echo_n "checking dynamic linker characteristics... " >&6; } library_names_spec= libname_spec='lib$name' @@ -17238,10 +16128,9 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH - if test ${lt_cv_shlibpath_overrides_runpath+y} -then : - printf %s "(cached) " >&6 -else $as_nop + if ${lt_cv_shlibpath_overrides_runpath+:} false; then : + $as_echo_n "(cached) " >&6 +else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir @@ -17251,21 +16140,19 @@ else $as_nop /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_cxx_try_link "$LINENO" -then : - if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null -then : +if ac_fn_cxx_try_link "$LINENO"; then : + if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir @@ -17502,8 +16389,8 @@ uts4*) dynamic_linker=no ;; esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 -printf "%s\n" "$dynamic_linker" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 +$as_echo "$dynamic_linker" >&6; } test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" @@ -17567,8 +16454,8 @@ configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 -printf %s "checking how to hardcode library paths into programs... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 +$as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action_CXX= if test -n "$hardcode_libdir_flag_spec_CXX" || test -n "$runpath_var_CXX" || @@ -17592,8 +16479,8 @@ else # directories. hardcode_action_CXX=unsupported fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 -printf "%s\n" "$hardcode_action_CXX" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 +$as_echo "$hardcode_action_CXX" >&6; } if test relink = "$hardcode_action_CXX" || test yes = "$inherit_rpath_CXX"; then @@ -17632,12 +16519,11 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -printf %s "checking for egrep... " >&6; } -if test ${ac_cv_path_EGREP+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else @@ -17648,15 +16534,10 @@ else $as_nop for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_prog in egrep - do + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext" + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP @@ -17665,13 +16546,13 @@ case `"$ac_path_EGREP" --version 2>&1` in ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 - printf %s 0123456789 >"conftest.in" + $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" - printf "%s\n" 'EGREP' >> "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val @@ -17700,17 +16581,16 @@ fi fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -printf "%s\n" "$ac_cv_path_EGREP" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 -printf %s "checking for fgrep... " >&6; } -if test ${ac_cv_path_FGREP+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 +$as_echo_n "checking for fgrep... " >&6; } +if ${ac_cv_path_FGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else @@ -17721,15 +16601,10 @@ else $as_nop for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_prog in fgrep - do + test -z "$as_dir" && as_dir=. + for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_FGREP="$as_dir$ac_prog$ac_exec_ext" + ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP @@ -17738,13 +16613,13 @@ case `"$ac_path_FGREP" --version 2>&1` in ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 - printf %s 0123456789 >"conftest.in" + $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" - printf "%s\n" 'FGREP' >> "conftest.nl" + $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val @@ -17773,13 +16648,12 @@ fi fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 -printf "%s\n" "$ac_cv_path_FGREP" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 +$as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" - - # Find a good install program. We prefer a C program (faster), +# Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install @@ -17793,25 +16667,20 @@ printf "%s\n" "$ac_cv_path_FGREP" >&6; } # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 -printf %s "checking for a BSD-compatible install... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if test ${ac_cv_path_install+y} -then : - printf %s "(cached) " >&6 -else $as_nop +if ${ac_cv_path_install+:} false; then : + $as_echo_n "(cached) " >&6 +else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - # Account for fact that we put trailing slashes in our PATH walk. -case $as_dir in #(( - ./ | /[cC]/* | \ + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; @@ -17821,13 +16690,13 @@ case $as_dir in #(( # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && - grep dspmsg "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && - grep pwplus "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else @@ -17835,12 +16704,12 @@ case $as_dir in #(( echo one > conftest.one echo two > conftest.two mkdir conftest.dir - if "$as_dir$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir/" && + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then - ac_cv_path_install="$as_dir$ac_prog$ac_exec_ext -c" + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi @@ -17856,7 +16725,7 @@ IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi - if test ${ac_cv_path_install+y}; then + if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a @@ -17866,8 +16735,8 @@ fi INSTALL=$ac_install_sh fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 -printf "%s\n" "$INSTALL" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. @@ -17877,14 +16746,13 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -printf %s "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} -ac_make=`printf "%s\n" "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval test \${ac_cv_prog_make_${ac_make}_set+y} -then : - printf %s "(cached) " >&6 -else $as_nop +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @@ -17900,12 +16768,12 @@ esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } SET_MAKE= else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi @@ -17920,12 +16788,11 @@ if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_path_PKG_CONFIG+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. @@ -17935,15 +16802,11 @@ else $as_nop for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_path_PKG_CONFIG="$as_dir$ac_word$ac_exec_ext" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -17955,11 +16818,11 @@ esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 -printf "%s\n" "$PKG_CONFIG" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -17968,12 +16831,11 @@ if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_path_ac_pt_PKG_CONFIG+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. @@ -17983,15 +16845,11 @@ else $as_nop for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_path_ac_pt_PKG_CONFIG="$as_dir$ac_word$ac_exec_ext" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -18003,11 +16861,11 @@ esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 -printf "%s\n" "$ac_pt_PKG_CONFIG" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 +$as_echo "$ac_pt_PKG_CONFIG" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then @@ -18015,8 +16873,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG @@ -18028,14 +16886,14 @@ fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 -printf %s "checking pkg-config is at least version $_pkg_min_version... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } PKG_CONFIG="" fi fi @@ -18048,12 +16906,11 @@ for ac_prog in gsort sort do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_SORT+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_SORT+:} false; then : + $as_echo_n "(cached) " >&6 +else if test -n "$SORT"; then ac_cv_prog_SORT="$SORT" # Let the user override the test. else @@ -18061,15 +16918,11 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_SORT="$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -18080,11 +16933,11 @@ fi fi SORT=$ac_cv_prog_SORT if test -n "$SORT"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SORT" >&5 -printf "%s\n" "$SORT" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SORT" >&5 +$as_echo "$SORT" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -18092,26 +16945,23 @@ fi done test -n "$SORT" || SORT="false" -if ! "$SORT" -V /dev/null -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: sort(1) that supports the -V option is required to find dynamic libraries" >&5 -printf "%s\n" "$as_me: WARNING: sort(1) that supports the -V option is required to find dynamic libraries" >&2;} +if ! "$SORT" -V /dev/null; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: sort(1) that supports the -V option is required to find dynamic libraries" >&5 +$as_echo "$as_me: WARNING: sort(1) that supports the -V option is required to find dynamic libraries" >&2;} fi # Check whether --enable-largefile was given. -if test ${enable_largefile+y} -then : +if test "${enable_largefile+set}" = set; then : enableval=$enable_largefile; fi if test "$enable_largefile" != no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 -printf %s "checking for special C compiler options needed for large files... " >&6; } -if test ${ac_cv_sys_largefile_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 +$as_echo_n "checking for special C compiler options needed for large files... " >&6; } +if ${ac_cv_sys_largefile_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC @@ -18125,47 +16975,44 @@ else $as_nop We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int -main (void) +main () { ; return 0; } _ACEOF - if ac_fn_c_try_compile "$LINENO" -then : + if ac_fn_c_try_compile "$LINENO"; then : break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam +rm -f core conftest.err conftest.$ac_objext CC="$CC -n32" - if ac_fn_c_try_compile "$LINENO" -then : + if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_largefile_CC=' -n32'; break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam +rm -f core conftest.err conftest.$ac_objext break done CC=$ac_save_CC rm -f conftest.$ac_ext fi fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 -printf "%s\n" "$ac_cv_sys_largefile_CC" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 +$as_echo "$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 -printf %s "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } -if test ${ac_cv_sys_file_offset_bits+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } +if ${ac_cv_sys_file_offset_bits+:} false; then : + $as_echo_n "(cached) " >&6 +else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -18174,23 +17021,22 @@ else $as_nop We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=no; break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 @@ -18199,43 +17045,43 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=64; break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_file_offset_bits=unknown break done fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 -printf "%s\n" "$ac_cv_sys_file_offset_bits" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 +$as_echo "$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; *) -printf "%s\n" "#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits +_ACEOF ;; esac rm -rf conftest* if test $ac_cv_sys_file_offset_bits = unknown; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 -printf %s "checking for _LARGE_FILES value needed for large files... " >&6; } -if test ${ac_cv_sys_large_files+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 +$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } +if ${ac_cv_sys_large_files+:} false; then : + $as_echo_n "(cached) " >&6 +else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -18244,23 +17090,22 @@ else $as_nop We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=no; break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGE_FILES 1 @@ -18269,37 +17114,40 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=1; break fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_large_files=unknown break done fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 -printf "%s\n" "$ac_cv_sys_large_files" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 +$as_echo "$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; *) -printf "%s\n" "#define _LARGE_FILES $ac_cv_sys_large_files" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files +_ACEOF ;; esac rm -rf conftest* fi + + fi @@ -18350,28 +17198,27 @@ case "$host" in # We build SDL on cygwin without the UNIX emulation layer save_CFLAGS="$CFLAGS" have_no_cygwin=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -mno-cygwin option" >&5 -printf %s "checking for GCC -mno-cygwin option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -mno-cygwin option" >&5 +$as_echo_n "checking for GCC -mno-cygwin option... " >&6; } CFLAGS="$save_CFLAGS -mno-cygwin" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_no_cygwin=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_no_cygwin" >&5 -printf "%s\n" "$have_no_cygwin" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_no_cygwin" >&5 +$as_echo "$have_no_cygwin" >&6; } CFLAGS="$save_CFLAGS" if test x$have_no_cygwin = xyes; then @@ -18435,17 +17282,16 @@ find_lib() done } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 -printf %s "checking for an ANSI C-conforming const... " >&6; } -if test ${ac_cv_c_const+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 +$as_echo_n "checking for an ANSI C-conforming const... " >&6; } +if ${ac_cv_c_const+:} false; then : + $as_echo_n "(cached) " >&6 +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { #ifndef __cplusplus @@ -18458,7 +17304,7 @@ main (void) /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; - /* IBM XL C 1.02.0.0 rejects this. + /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ @@ -18486,7 +17332,7 @@ main (void) iptr p = 0; ++p; } - { /* IBM XL C 1.02.0.0 rejects this sort of thing, saying + { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; } bx; struct s *b = &bx; b->j = 5; @@ -18495,1566 +17341,787 @@ main (void) const int foo = 10; if (!foo) return 0; } - return !cs[0] && !zero.x; -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_c_const=yes -else $as_nop - ac_cv_c_const=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 -printf "%s\n" "$ac_cv_c_const" >&6; } -if test $ac_cv_c_const = no; then - -printf "%s\n" "#define const /**/" >>confdefs.h - -fi - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 -printf %s "checking for inline... " >&6; } -if test ${ac_cv_c_inline+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_c_inline=no -for ac_kw in inline __inline__ __inline; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifndef __cplusplus -typedef int foo_t; -static $ac_kw foo_t static_foo (void) {return 0; } -$ac_kw foo_t foo (void) {return 0; } -#endif - -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_c_inline=$ac_kw -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - test "$ac_cv_c_inline" != no && break -done - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 -printf "%s\n" "$ac_cv_c_inline" >&6; } - -case $ac_cv_c_inline in - inline | yes) ;; - *) - case $ac_cv_c_inline in - no) ac_val=;; - *) ac_val=$ac_cv_c_inline;; - esac - cat >>confdefs.h <<_ACEOF -#ifndef __cplusplus -#define inline $ac_val -#endif -_ACEOF - ;; -esac - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working volatile" >&5 -printf %s "checking for working volatile... " >&6; } -if test ${ac_cv_c_volatile+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - -volatile int x; -int * volatile y = (int *) 0; -return !x && !y; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_c_volatile=yes -else $as_nop - ac_cv_c_volatile=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_volatile" >&5 -printf "%s\n" "$ac_cv_c_volatile" >&6; } -if test $ac_cv_c_volatile = no; then - -printf "%s\n" "#define volatile /**/" >>confdefs.h - -fi - - -# Check whether --enable-assertions was given. -if test ${enable_assertions+y} -then : - enableval=$enable_assertions; -else $as_nop - enable_assertions=auto -fi - -case "$enable_assertions" in - auto) # Use optimization settings to determine assertion level - ;; - disabled) - -printf "%s\n" "#define SDL_DEFAULT_ASSERT_LEVEL 0" >>confdefs.h - - ;; - release) - -printf "%s\n" "#define SDL_DEFAULT_ASSERT_LEVEL 1" >>confdefs.h - - ;; - enabled) - -printf "%s\n" "#define SDL_DEFAULT_ASSERT_LEVEL 2" >>confdefs.h - - ;; - paranoid) - -printf "%s\n" "#define SDL_DEFAULT_ASSERT_LEVEL 3" >>confdefs.h - - ;; - *) - as_fn_error $? "*** unknown assertion level. stop." "$LINENO" 5 - ;; -esac - -EXTRA_CFLAGS="$EXTRA_CFLAGS -DSDL_BUILD_MAJOR_VERSION=$SDL_MAJOR_VERSION -DSDL_BUILD_MINOR_VERSION=$SDL_MINOR_VERSION -DSDL_BUILD_MICRO_VERSION=$SDL_MICRO_VERSION" - -# Check whether --enable-dependency-tracking was given. -if test ${enable_dependency_tracking+y} -then : - enableval=$enable_dependency_tracking; -else $as_nop - enable_dependency_tracking=yes -fi - -if test x$enable_dependency_tracking = xyes; then - have_gcc_mmd_mt=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -MMD -MT option" >&5 -printf %s "checking for GCC -MMD -MT option... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #if !defined(__GNUC__) || __GNUC__ < 3 - #error Dependency tracking requires GCC 3.0 or newer - #endif - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - have_gcc_mmd_mt=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_mmd_mt" >&5 -printf "%s\n" "$have_gcc_mmd_mt" >&6; } - - if test x$have_gcc_mmd_mt = xyes; then - DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@" - fi -fi - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for linker option --no-undefined" >&5 -printf %s "checking for linker option --no-undefined... " >&6; } -have_no_undefined=no -case "$host" in - *-*-openbsd*) - ;; - *) - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -Wl,--no-undefined" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - - have_no_undefined=yes - BUILD_LDFLAGS="$BUILD_LDFLAGS -Wl,--no-undefined" - -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" - ;; -esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_no_undefined" >&5 -printf "%s\n" "$have_no_undefined" >&6; } - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for linker option --dynamicbase" >&5 -printf %s "checking for linker option --dynamicbase... " >&6; } -have_dynamicbase=no -case "$host" in - *) - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -Wl,--dynamicbase" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - - have_dynamicbase=yes - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--dynamicbase" - -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" - ;; -esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_dynamicbase" >&5 -printf "%s\n" "$have_dynamicbase" >&6; } - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for linker option --nxcompat" >&5 -printf %s "checking for linker option --nxcompat... " >&6; } -have_nxcompat=no -case "$host" in - *) - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -Wl,--nxcompat" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - - have_nxcompat=yes - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--nxcompat" - -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" - ;; -esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_nxcompat" >&5 -printf "%s\n" "$have_nxcompat" >&6; } - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for linker option --high-entropy-va" >&5 -printf %s "checking for linker option --high-entropy-va... " >&6; } -have_high_entropy_va=no -case "$host" in - *) - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -Wl,--high-entropy-va" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - - have_high_entropy_va=yes - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--high-entropy-va" - -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" - ;; -esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_high_entropy_va" >&5 -printf "%s\n" "$have_high_entropy_va" >&6; } - -# Check whether --enable-libc was given. -if test ${enable_libc+y} -then : - enableval=$enable_libc; -else $as_nop - enable_libc=yes -fi - - -# Check whether --enable-system-iconv was given. -if test ${enable_system_iconv+y} -then : - enableval=$enable_system_iconv; -else $as_nop - enable_system_iconv=yes -fi - - -if test x$enable_libc = xyes; then - -printf "%s\n" "#define HAVE_LIBC 1" >>confdefs.h - - - - ac_fn_c_check_header_compile "$LINENO" "sys/types.h" "ac_cv_header_sys_types_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_types_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_TYPES_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "stdio.h" "ac_cv_header_stdio_h" "$ac_includes_default" -if test "x$ac_cv_header_stdio_h" = xyes -then : - printf "%s\n" "#define HAVE_STDIO_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" -if test "x$ac_cv_header_stdlib_h" = xyes -then : - printf "%s\n" "#define HAVE_STDLIB_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "stddef.h" "ac_cv_header_stddef_h" "$ac_includes_default" -if test "x$ac_cv_header_stddef_h" = xyes -then : - printf "%s\n" "#define HAVE_STDDEF_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "stdarg.h" "ac_cv_header_stdarg_h" "$ac_includes_default" -if test "x$ac_cv_header_stdarg_h" = xyes -then : - printf "%s\n" "#define HAVE_STDARG_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "malloc.h" "ac_cv_header_malloc_h" "$ac_includes_default" -if test "x$ac_cv_header_malloc_h" = xyes -then : - printf "%s\n" "#define HAVE_MALLOC_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "memory.h" "ac_cv_header_memory_h" "$ac_includes_default" -if test "x$ac_cv_header_memory_h" = xyes -then : - printf "%s\n" "#define HAVE_MEMORY_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default" -if test "x$ac_cv_header_string_h" = xyes -then : - printf "%s\n" "#define HAVE_STRING_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "strings.h" "ac_cv_header_strings_h" "$ac_includes_default" -if test "x$ac_cv_header_strings_h" = xyes -then : - printf "%s\n" "#define HAVE_STRINGS_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "wchar.h" "ac_cv_header_wchar_h" "$ac_includes_default" -if test "x$ac_cv_header_wchar_h" = xyes -then : - printf "%s\n" "#define HAVE_WCHAR_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "inttypes.h" "ac_cv_header_inttypes_h" "$ac_includes_default" -if test "x$ac_cv_header_inttypes_h" = xyes -then : - printf "%s\n" "#define HAVE_INTTYPES_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "stdint.h" "ac_cv_header_stdint_h" "$ac_includes_default" -if test "x$ac_cv_header_stdint_h" = xyes -then : - printf "%s\n" "#define HAVE_STDINT_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "limits.h" "ac_cv_header_limits_h" "$ac_includes_default" -if test "x$ac_cv_header_limits_h" = xyes -then : - printf "%s\n" "#define HAVE_LIMITS_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "ctype.h" "ac_cv_header_ctype_h" "$ac_includes_default" -if test "x$ac_cv_header_ctype_h" = xyes -then : - printf "%s\n" "#define HAVE_CTYPE_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "math.h" "ac_cv_header_math_h" "$ac_includes_default" -if test "x$ac_cv_header_math_h" = xyes -then : - printf "%s\n" "#define HAVE_MATH_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "float.h" "ac_cv_header_float_h" "$ac_includes_default" -if test "x$ac_cv_header_float_h" = xyes -then : - printf "%s\n" "#define HAVE_FLOAT_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "iconv.h" "ac_cv_header_iconv_h" "$ac_includes_default" -if test "x$ac_cv_header_iconv_h" = xyes -then : - printf "%s\n" "#define HAVE_ICONV_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "signal.h" "ac_cv_header_signal_h" "$ac_includes_default" -if test "x$ac_cv_header_signal_h" = xyes -then : - printf "%s\n" "#define HAVE_SIGNAL_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "linux/input.h" "ac_cv_header_linux_input_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_input_h" = xyes -then : - printf "%s\n" "#define HAVE_LINUX_INPUT_H 1" >>confdefs.h - -fi - - - ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = xyes -then : - -else $as_nop - -printf "%s\n" "#define size_t unsigned int" >>confdefs.h - -fi - - - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -printf %s "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if test ${ac_cv_prog_CPP+y} -then : - printf %s "(cached) " >&6 -else $as_nop - # Double quotes because $CC needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO" -then : - -else $as_nop - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO" -then : - # Broken: success on invalid input. -continue -else $as_nop - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok -then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -printf "%s\n" "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO" -then : - -else $as_nop - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO" -then : - # Broken: success on invalid input. -continue -else $as_nop - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok -then : - -else $as_nop - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for M_PI in math.h" >&5 -printf %s "checking for M_PI in math.h... " >&6; } -if test ${ac_cv_define_M_PI+y} -then : - printf %s "(cached) " >&6 -else $as_nop - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef M_PI -YES_IS_DEFINED -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "YES_IS_DEFINED" >/dev/null 2>&1 -then : - ac_cv_define_M_PI=yes -else $as_nop - ac_cv_define_M_PI=no -fi -rm -rf conftest* - - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_M_PI" >&5 -printf "%s\n" "$ac_cv_define_M_PI" >&6; } - if test "$ac_cv_define_M_PI" = "yes" ; then - -printf "%s\n" "#define HAVE_M_PI /**/" >>confdefs.h - - fi - - - # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -# for constant arguments. Useless! -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 -printf %s "checking for working alloca.h... " >&6; } -if test ${ac_cv_working_alloca_h+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ -char *p = (char *) alloca (2 * sizeof (int)); - if (p) return 0; + return !cs[0] && !zero.x; +#endif + ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_working_alloca_h=yes -else $as_nop - ac_cv_working_alloca_h=no +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_const=yes +else + ac_cv_c_const=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 -printf "%s\n" "$ac_cv_working_alloca_h" >&6; } -if test $ac_cv_working_alloca_h = yes; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 +$as_echo "$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then -printf "%s\n" "#define HAVE_ALLOCA_H 1" >>confdefs.h +$as_echo "#define const /**/" >>confdefs.h fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 -printf %s "checking for alloca... " >&6; } -if test ${ac_cv_func_alloca_works+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test $ac_cv_working_alloca_h = yes; then - ac_cv_func_alloca_works=yes +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 +$as_echo_n "checking for inline... " >&6; } +if ${ac_cv_c_inline+:} false; then : + $as_echo_n "(cached) " >&6 else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include -#include -#ifndef alloca -# ifdef __GNUC__ -# define alloca __builtin_alloca -# elif defined _MSC_VER -# include -# define alloca _alloca -# else -# ifdef __cplusplus -extern "C" -# endif -void *alloca (size_t); -# endif +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } #endif -int -main (void) -{ -char *p = (char *) alloca (1); - if (p) return 0; - ; - return 0; -} _ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_func_alloca_works=yes -else $as_nop - ac_cv_func_alloca_works=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 -printf "%s\n" "$ac_cv_func_alloca_works" >&6; } +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_inline=$ac_kw fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_inline" != no && break +done -if test $ac_cv_func_alloca_works = yes; then +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 +$as_echo "$ac_cv_c_inline" >&6; } -printf "%s\n" "#define HAVE_ALLOCA 1" >>confdefs.h +case $ac_cv_c_inline in + inline | yes) ;; + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif +_ACEOF + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working volatile" >&5 +$as_echo_n "checking for working volatile... " >&6; } +if ${ac_cv_c_volatile+:} false; then : + $as_echo_n "(cached) " >&6 else - # The SVR3 libPW and SVR4 libucb both contain incompatible functions -# that cause trouble. Some versions do not even contain alloca or -# contain a buggy version. If you still want to use their alloca, -# use ar to extract alloca.o from them instead of compiling alloca.c. - -ALLOCA=\${LIBOBJDIR}alloca.$ac_objext - -printf "%s\n" "#define C_ALLOCA 1" >>confdefs.h - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 -printf %s "checking stack direction for C alloca... " >&6; } -if test ${ac_cv_c_stack_direction+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes -then : - ac_cv_c_stack_direction=0 -else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -$ac_includes_default -int -find_stack_direction (int *addr, int depth) -{ - int dir, dummy = 0; - if (! addr) - addr = &dummy; - *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; - dir = depth ? find_stack_direction (addr, depth - 1) : 0; - return dir + dummy; -} int -main (int argc, char **argv) +main () { - return find_stack_direction (0, argc + !argv + 20) < 0; + +volatile int x; +int * volatile y = (int *) 0; +return !x && !y; + ; + return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO" -then : - ac_cv_c_stack_direction=1 -else $as_nop - ac_cv_c_stack_direction=-1 -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_volatile=yes +else + ac_cv_c_volatile=no fi - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 -printf "%s\n" "$ac_cv_c_stack_direction" >&6; } -printf "%s\n" "#define STACK_DIRECTION $ac_cv_c_stack_direction" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_volatile" >&5 +$as_echo "$ac_cv_c_volatile" >&6; } +if test $ac_cv_c_volatile = no; then +$as_echo "#define volatile /**/" >>confdefs.h fi - ac_fn_c_check_func "$LINENO" "mprotect" "ac_cv_func_mprotect" -if test "x$ac_cv_func_mprotect" = xyes -then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #include - #include - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - +# Check whether --enable-assertions was given. +if test "${enable_assertions+set}" = set; then : + enableval=$enable_assertions; +else + enable_assertions=auto +fi -printf "%s\n" "#define HAVE_MPROTECT 1" >>confdefs.h +case "$enable_assertions" in + auto) # Use optimization settings to determine assertion level + ;; + disabled) +$as_echo "#define SDL_DEFAULT_ASSERT_LEVEL 0" >>confdefs.h -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi + ;; + release) - ac_fn_c_check_func "$LINENO" "malloc" "ac_cv_func_malloc" -if test "x$ac_cv_func_malloc" = xyes -then : - printf "%s\n" "#define HAVE_MALLOC 1" >>confdefs.h +$as_echo "#define SDL_DEFAULT_ASSERT_LEVEL 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "calloc" "ac_cv_func_calloc" -if test "x$ac_cv_func_calloc" = xyes -then : - printf "%s\n" "#define HAVE_CALLOC 1" >>confdefs.h + ;; + enabled) -fi -ac_fn_c_check_func "$LINENO" "realloc" "ac_cv_func_realloc" -if test "x$ac_cv_func_realloc" = xyes -then : - printf "%s\n" "#define HAVE_REALLOC 1" >>confdefs.h +$as_echo "#define SDL_DEFAULT_ASSERT_LEVEL 2" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "free" "ac_cv_func_free" -if test "x$ac_cv_func_free" = xyes -then : - printf "%s\n" "#define HAVE_FREE 1" >>confdefs.h + ;; + paranoid) -fi -ac_fn_c_check_func "$LINENO" "getenv" "ac_cv_func_getenv" -if test "x$ac_cv_func_getenv" = xyes -then : - printf "%s\n" "#define HAVE_GETENV 1" >>confdefs.h +$as_echo "#define SDL_DEFAULT_ASSERT_LEVEL 3" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "setenv" "ac_cv_func_setenv" -if test "x$ac_cv_func_setenv" = xyes -then : - printf "%s\n" "#define HAVE_SETENV 1" >>confdefs.h + ;; + *) + as_fn_error $? "*** unknown assertion level. stop." "$LINENO" 5 + ;; +esac -fi -ac_fn_c_check_func "$LINENO" "putenv" "ac_cv_func_putenv" -if test "x$ac_cv_func_putenv" = xyes -then : - printf "%s\n" "#define HAVE_PUTENV 1" >>confdefs.h +EXTRA_CFLAGS="$EXTRA_CFLAGS -DSDL_BUILD_MAJOR_VERSION=$SDL_MAJOR_VERSION -DSDL_BUILD_MINOR_VERSION=$SDL_MINOR_VERSION -DSDL_BUILD_MICRO_VERSION=$SDL_MICRO_VERSION" +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then : + enableval=$enable_dependency_tracking; +else + enable_dependency_tracking=yes fi -ac_fn_c_check_func "$LINENO" "unsetenv" "ac_cv_func_unsetenv" -if test "x$ac_cv_func_unsetenv" = xyes -then : - printf "%s\n" "#define HAVE_UNSETENV 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "bsearch" "ac_cv_func_bsearch" -if test "x$ac_cv_func_bsearch" = xyes -then : - printf "%s\n" "#define HAVE_BSEARCH 1" >>confdefs.h +if test x$enable_dependency_tracking = xyes; then + have_gcc_mmd_mt=no + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -MMD -MT option" >&5 +$as_echo_n "checking for GCC -MMD -MT option... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -fi -ac_fn_c_check_func "$LINENO" "qsort" "ac_cv_func_qsort" -if test "x$ac_cv_func_qsort" = xyes -then : - printf "%s\n" "#define HAVE_QSORT 1" >>confdefs.h + #if !defined(__GNUC__) || __GNUC__ < 3 + #error Dependency tracking requires GCC 3.0 or newer + #endif -fi -ac_fn_c_check_func "$LINENO" "abs" "ac_cv_func_abs" -if test "x$ac_cv_func_abs" = xyes -then : - printf "%s\n" "#define HAVE_ABS 1" >>confdefs.h +int +main () +{ + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + have_gcc_mmd_mt=yes fi -ac_fn_c_check_func "$LINENO" "bcopy" "ac_cv_func_bcopy" -if test "x$ac_cv_func_bcopy" = xyes -then : - printf "%s\n" "#define HAVE_BCOPY 1" >>confdefs.h +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_mmd_mt" >&5 +$as_echo "$have_gcc_mmd_mt" >&6; } + if test x$have_gcc_mmd_mt = xyes; then + DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@" + fi fi -ac_fn_c_check_func "$LINENO" "memset" "ac_cv_func_memset" -if test "x$ac_cv_func_memset" = xyes -then : - printf "%s\n" "#define HAVE_MEMSET 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "memcmp" "ac_cv_func_memcmp" -if test "x$ac_cv_func_memcmp" = xyes -then : - printf "%s\n" "#define HAVE_MEMCMP 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker option --no-undefined" >&5 +$as_echo_n "checking for linker option --no-undefined... " >&6; } +have_no_undefined=no +case "$host" in + *-*-openbsd*) + ;; + *) + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -Wl,--no-undefined" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -fi -ac_fn_c_check_func "$LINENO" "memcpy" "ac_cv_func_memcpy" -if test "x$ac_cv_func_memcpy" = xyes -then : - printf "%s\n" "#define HAVE_MEMCPY 1" >>confdefs.h +int +main () +{ -fi -ac_fn_c_check_func "$LINENO" "memmove" "ac_cv_func_memmove" -if test "x$ac_cv_func_memmove" = xyes -then : - printf "%s\n" "#define HAVE_MEMMOVE 1" >>confdefs.h + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : -fi -ac_fn_c_check_func "$LINENO" "wcslen" "ac_cv_func_wcslen" -if test "x$ac_cv_func_wcslen" = xyes -then : - printf "%s\n" "#define HAVE_WCSLEN 1" >>confdefs.h + have_no_undefined=yes + BUILD_LDFLAGS="$BUILD_LDFLAGS -Wl,--no-undefined" fi -ac_fn_c_check_func "$LINENO" "wcslcpy" "ac_cv_func_wcslcpy" -if test "x$ac_cv_func_wcslcpy" = xyes -then : - printf "%s\n" "#define HAVE_WCSLCPY 1" >>confdefs.h +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS="$save_LDFLAGS" + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_no_undefined" >&5 +$as_echo "$have_no_undefined" >&6; } -fi -ac_fn_c_check_func "$LINENO" "wcslcat" "ac_cv_func_wcslcat" -if test "x$ac_cv_func_wcslcat" = xyes -then : - printf "%s\n" "#define HAVE_WCSLCAT 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker option --dynamicbase" >&5 +$as_echo_n "checking for linker option --dynamicbase... " >&6; } +have_dynamicbase=no +case "$host" in + *) + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -Wl,--dynamicbase" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -fi -ac_fn_c_check_func "$LINENO" "_wcsdup" "ac_cv_func__wcsdup" -if test "x$ac_cv_func__wcsdup" = xyes -then : - printf "%s\n" "#define HAVE__WCSDUP 1" >>confdefs.h +int +main () +{ -fi -ac_fn_c_check_func "$LINENO" "wcsdup" "ac_cv_func_wcsdup" -if test "x$ac_cv_func_wcsdup" = xyes -then : - printf "%s\n" "#define HAVE_WCSDUP 1" >>confdefs.h + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : -fi -ac_fn_c_check_func "$LINENO" "wcsstr" "ac_cv_func_wcsstr" -if test "x$ac_cv_func_wcsstr" = xyes -then : - printf "%s\n" "#define HAVE_WCSSTR 1" >>confdefs.h + have_dynamicbase=yes + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--dynamicbase" fi -ac_fn_c_check_func "$LINENO" "wcscmp" "ac_cv_func_wcscmp" -if test "x$ac_cv_func_wcscmp" = xyes -then : - printf "%s\n" "#define HAVE_WCSCMP 1" >>confdefs.h +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS="$save_LDFLAGS" + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_dynamicbase" >&5 +$as_echo "$have_dynamicbase" >&6; } -fi -ac_fn_c_check_func "$LINENO" "wcsncmp" "ac_cv_func_wcsncmp" -if test "x$ac_cv_func_wcsncmp" = xyes -then : - printf "%s\n" "#define HAVE_WCSNCMP 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker option --nxcompat" >&5 +$as_echo_n "checking for linker option --nxcompat... " >&6; } +have_nxcompat=no +case "$host" in + *) + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -Wl,--nxcompat" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -fi -ac_fn_c_check_func "$LINENO" "wcscasecmp" "ac_cv_func_wcscasecmp" -if test "x$ac_cv_func_wcscasecmp" = xyes -then : - printf "%s\n" "#define HAVE_WCSCASECMP 1" >>confdefs.h +int +main () +{ -fi -ac_fn_c_check_func "$LINENO" "_wcsicmp" "ac_cv_func__wcsicmp" -if test "x$ac_cv_func__wcsicmp" = xyes -then : - printf "%s\n" "#define HAVE__WCSICMP 1" >>confdefs.h + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : -fi -ac_fn_c_check_func "$LINENO" "wcsncasecmp" "ac_cv_func_wcsncasecmp" -if test "x$ac_cv_func_wcsncasecmp" = xyes -then : - printf "%s\n" "#define HAVE_WCSNCASECMP 1" >>confdefs.h + have_nxcompat=yes + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--nxcompat" fi -ac_fn_c_check_func "$LINENO" "_wcsnicmp" "ac_cv_func__wcsnicmp" -if test "x$ac_cv_func__wcsnicmp" = xyes -then : - printf "%s\n" "#define HAVE__WCSNICMP 1" >>confdefs.h +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS="$save_LDFLAGS" + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_nxcompat" >&5 +$as_echo "$have_nxcompat" >&6; } -fi -ac_fn_c_check_func "$LINENO" "strlen" "ac_cv_func_strlen" -if test "x$ac_cv_func_strlen" = xyes -then : - printf "%s\n" "#define HAVE_STRLEN 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker option --high-entropy-va" >&5 +$as_echo_n "checking for linker option --high-entropy-va... " >&6; } +have_high_entropy_va=no +case "$host" in + *) + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -Wl,--high-entropy-va" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -fi -ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" -if test "x$ac_cv_func_strlcpy" = xyes -then : - printf "%s\n" "#define HAVE_STRLCPY 1" >>confdefs.h +int +main () +{ -fi -ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat" -if test "x$ac_cv_func_strlcat" = xyes -then : - printf "%s\n" "#define HAVE_STRLCAT 1" >>confdefs.h + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : -fi -ac_fn_c_check_func "$LINENO" "_strrev" "ac_cv_func__strrev" -if test "x$ac_cv_func__strrev" = xyes -then : - printf "%s\n" "#define HAVE__STRREV 1" >>confdefs.h + have_high_entropy_va=yes + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--high-entropy-va" fi -ac_fn_c_check_func "$LINENO" "_strupr" "ac_cv_func__strupr" -if test "x$ac_cv_func__strupr" = xyes -then : - printf "%s\n" "#define HAVE__STRUPR 1" >>confdefs.h +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS="$save_LDFLAGS" + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_high_entropy_va" >&5 +$as_echo "$have_high_entropy_va" >&6; } +# Check whether --enable-libc was given. +if test "${enable_libc+set}" = set; then : + enableval=$enable_libc; +else + enable_libc=yes fi -ac_fn_c_check_func "$LINENO" "_strlwr" "ac_cv_func__strlwr" -if test "x$ac_cv_func__strlwr" = xyes -then : - printf "%s\n" "#define HAVE__STRLWR 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "index" "ac_cv_func_index" -if test "x$ac_cv_func_index" = xyes -then : - printf "%s\n" "#define HAVE_INDEX 1" >>confdefs.h +# Check whether --enable-system-iconv was given. +if test "${enable_system_iconv+set}" = set; then : + enableval=$enable_system_iconv; +else + enable_system_iconv=yes fi -ac_fn_c_check_func "$LINENO" "rindex" "ac_cv_func_rindex" -if test "x$ac_cv_func_rindex" = xyes -then : - printf "%s\n" "#define HAVE_RINDEX 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "strchr" "ac_cv_func_strchr" -if test "x$ac_cv_func_strchr" = xyes -then : - printf "%s\n" "#define HAVE_STRCHR 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "strrchr" "ac_cv_func_strrchr" -if test "x$ac_cv_func_strrchr" = xyes -then : - printf "%s\n" "#define HAVE_STRRCHR 1" >>confdefs.h +if test x$enable_libc = xyes; then -fi -ac_fn_c_check_func "$LINENO" "strstr" "ac_cv_func_strstr" -if test "x$ac_cv_func_strstr" = xyes -then : - printf "%s\n" "#define HAVE_STRSTR 1" >>confdefs.h +$as_echo "#define HAVE_LIBC 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "strtok_r" "ac_cv_func_strtok_r" -if test "x$ac_cv_func_strtok_r" = xyes -then : - printf "%s\n" "#define HAVE_STRTOK_R 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "itoa" "ac_cv_func_itoa" -if test "x$ac_cv_func_itoa" = xyes -then : - printf "%s\n" "#define HAVE_ITOA 1" >>confdefs.h + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include -fi -ac_fn_c_check_func "$LINENO" "_ltoa" "ac_cv_func__ltoa" -if test "x$ac_cv_func__ltoa" = xyes -then : - printf "%s\n" "#define HAVE__LTOA 1" >>confdefs.h +int +main () +{ + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no fi -ac_fn_c_check_func "$LINENO" "_uitoa" "ac_cv_func__uitoa" -if test "x$ac_cv_func__uitoa" = xyes -then : - printf "%s\n" "#define HAVE__UITOA 1" >>confdefs.h +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_fn_c_check_func "$LINENO" "_ultoa" "ac_cv_func__ultoa" -if test "x$ac_cv_func__ultoa" = xyes -then : - printf "%s\n" "#define HAVE__ULTOA 1" >>confdefs.h +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include -fi -ac_fn_c_check_func "$LINENO" "strtod" "ac_cv_func_strtod" -if test "x$ac_cv_func_strtod" = xyes -then : - printf "%s\n" "#define HAVE_STRTOD 1" >>confdefs.h +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : +else + ac_cv_header_stdc=no fi -ac_fn_c_check_func "$LINENO" "strtol" "ac_cv_func_strtol" -if test "x$ac_cv_func_strtol" = xyes -then : - printf "%s\n" "#define HAVE_STRTOL 1" >>confdefs.h +rm -f conftest* fi -ac_fn_c_check_func "$LINENO" "strtoul" "ac_cv_func_strtoul" -if test "x$ac_cv_func_strtoul" = xyes -then : - printf "%s\n" "#define HAVE_STRTOUL 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "_i64toa" "ac_cv_func__i64toa" -if test "x$ac_cv_func__i64toa" = xyes -then : - printf "%s\n" "#define HAVE__I64TOA 1" >>confdefs.h +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include -fi -ac_fn_c_check_func "$LINENO" "_ui64toa" "ac_cv_func__ui64toa" -if test "x$ac_cv_func__ui64toa" = xyes -then : - printf "%s\n" "#define HAVE__UI64TOA 1" >>confdefs.h +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : +else + ac_cv_header_stdc=no fi -ac_fn_c_check_func "$LINENO" "strtoll" "ac_cv_func_strtoll" -if test "x$ac_cv_func_strtoll" = xyes -then : - printf "%s\n" "#define HAVE_STRTOLL 1" >>confdefs.h +rm -f conftest* fi -ac_fn_c_check_func "$LINENO" "strtoull" "ac_cv_func_strtoull" -if test "x$ac_cv_func_strtoull" = xyes -then : - printf "%s\n" "#define HAVE_STRTOULL 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "atoi" "ac_cv_func_atoi" -if test "x$ac_cv_func_atoi" = xyes -then : - printf "%s\n" "#define HAVE_ATOI 1" >>confdefs.h +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif -fi -ac_fn_c_check_func "$LINENO" "atof" "ac_cv_func_atof" -if test "x$ac_cv_func_atof" = xyes -then : - printf "%s\n" "#define HAVE_ATOF 1" >>confdefs.h +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : +else + ac_cv_header_stdc=no fi -ac_fn_c_check_func "$LINENO" "strcmp" "ac_cv_func_strcmp" -if test "x$ac_cv_func_strcmp" = xyes -then : - printf "%s\n" "#define HAVE_STRCMP 1" >>confdefs.h - +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi -ac_fn_c_check_func "$LINENO" "strncmp" "ac_cv_func_strncmp" -if test "x$ac_cv_func_strncmp" = xyes -then : - printf "%s\n" "#define HAVE_STRNCMP 1" >>confdefs.h fi -ac_fn_c_check_func "$LINENO" "_stricmp" "ac_cv_func__stricmp" -if test "x$ac_cv_func__stricmp" = xyes -then : - printf "%s\n" "#define HAVE__STRICMP 1" >>confdefs.h - fi -ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp" -if test "x$ac_cv_func_strcasecmp" = xyes -then : - printf "%s\n" "#define HAVE_STRCASECMP 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then -fi -ac_fn_c_check_func "$LINENO" "_strnicmp" "ac_cv_func__strnicmp" -if test "x$ac_cv_func__strnicmp" = xyes -then : - printf "%s\n" "#define HAVE__STRNICMP 1" >>confdefs.h +$as_echo "#define STDC_HEADERS 1" >>confdefs.h fi -ac_fn_c_check_func "$LINENO" "strncasecmp" "ac_cv_func_strncasecmp" -if test "x$ac_cv_func_strncasecmp" = xyes -then : - printf "%s\n" "#define HAVE_STRNCASECMP 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "strcasestr" "ac_cv_func_strcasestr" -if test "x$ac_cv_func_strcasestr" = xyes -then : - printf "%s\n" "#define HAVE_STRCASESTR 1" >>confdefs.h + for ac_header in sys/types.h stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h strings.h wchar.h inttypes.h stdint.h limits.h ctype.h math.h float.h iconv.h signal.h linux/input.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF fi -ac_fn_c_check_func "$LINENO" "vsscanf" "ac_cv_func_vsscanf" -if test "x$ac_cv_func_vsscanf" = xyes -then : - printf "%s\n" "#define HAVE_VSSCANF 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "vsnprintf" "ac_cv_func_vsnprintf" -if test "x$ac_cv_func_vsnprintf" = xyes -then : - printf "%s\n" "#define HAVE_VSNPRINTF 1" >>confdefs.h +done -fi -ac_fn_c_check_func "$LINENO" "fopen64" "ac_cv_func_fopen64" -if test "x$ac_cv_func_fopen64" = xyes -then : - printf "%s\n" "#define HAVE_FOPEN64 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "fseeko" "ac_cv_func_fseeko" -if test "x$ac_cv_func_fseeko" = xyes -then : - printf "%s\n" "#define HAVE_FSEEKO 1" >>confdefs.h + ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = xyes; then : -fi -ac_fn_c_check_func "$LINENO" "fseeko64" "ac_cv_func_fseeko64" -if test "x$ac_cv_func_fseeko64" = xyes -then : - printf "%s\n" "#define HAVE_FSEEKO64 1" >>confdefs.h +else -fi -ac_fn_c_check_func "$LINENO" "sigaction" "ac_cv_func_sigaction" -if test "x$ac_cv_func_sigaction" = xyes -then : - printf "%s\n" "#define HAVE_SIGACTION 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF fi -ac_fn_c_check_func "$LINENO" "setjmp" "ac_cv_func_setjmp" -if test "x$ac_cv_func_setjmp" = xyes -then : - printf "%s\n" "#define HAVE_SETJMP 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "nanosleep" "ac_cv_func_nanosleep" -if test "x$ac_cv_func_nanosleep" = xyes -then : - printf "%s\n" "#define HAVE_NANOSLEEP 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "sysconf" "ac_cv_func_sysconf" -if test "x$ac_cv_func_sysconf" = xyes -then : - printf "%s\n" "#define HAVE_SYSCONF 1" >>confdefs.h + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for M_PI in math.h" >&5 +$as_echo_n "checking for M_PI in math.h... " >&6; } +if ${ac_cv_define_M_PI+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -fi -ac_fn_c_check_func "$LINENO" "sysctlbyname" "ac_cv_func_sysctlbyname" -if test "x$ac_cv_func_sysctlbyname" = xyes -then : - printf "%s\n" "#define HAVE_SYSCTLBYNAME 1" >>confdefs.h +#include +#ifdef M_PI +YES_IS_DEFINED +#endif +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "YES_IS_DEFINED" >/dev/null 2>&1; then : + ac_cv_define_M_PI=yes +else + ac_cv_define_M_PI=no fi -ac_fn_c_check_func "$LINENO" "getauxval" "ac_cv_func_getauxval" -if test "x$ac_cv_func_getauxval" = xyes -then : - printf "%s\n" "#define HAVE_GETAUXVAL 1" >>confdefs.h +rm -f conftest* -fi -ac_fn_c_check_func "$LINENO" "elf_aux_info" "ac_cv_func_elf_aux_info" -if test "x$ac_cv_func_elf_aux_info" = xyes -then : - printf "%s\n" "#define HAVE_ELF_AUX_INFO 1" >>confdefs.h fi -ac_fn_c_check_func "$LINENO" "poll" "ac_cv_func_poll" -if test "x$ac_cv_func_poll" = xyes -then : - printf "%s\n" "#define HAVE_POLL 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_define_M_PI" >&5 +$as_echo "$ac_cv_define_M_PI" >&6; } + if test "$ac_cv_define_M_PI" = "yes" ; then -fi -ac_fn_c_check_func "$LINENO" "_Exit" "ac_cv_func__Exit" -if test "x$ac_cv_func__Exit" = xyes -then : - printf "%s\n" "#define HAVE__EXIT 1" >>confdefs.h +$as_echo "#define HAVE_M_PI /**/" >>confdefs.h -fi + fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5 -printf %s "checking for pow in -lm... " >&6; } -if test ${ac_cv_lib_m_pow+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS -LIBS="-lm $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works +# for constant arguments. Useless! +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 +$as_echo_n "checking for working alloca.h... " >&6; } +if ${ac_cv_working_alloca_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char pow (); +#include int -main (void) +main () { -return pow (); +char *p = (char *) alloca (2 * sizeof (int)); + if (p) return 0; ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_m_pow=yes -else $as_nop - ac_cv_lib_m_pow=no +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_working_alloca_h=yes +else + ac_cv_working_alloca_h=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5 -printf "%s\n" "$ac_cv_lib_m_pow" >&6; } -if test "x$ac_cv_lib_m_pow" = xyes -then : - LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm" fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 +$as_echo "$ac_cv_working_alloca_h" >&6; } +if test $ac_cv_working_alloca_h = yes; then - ac_fn_c_check_func "$LINENO" "acos" "ac_cv_func_acos" -if test "x$ac_cv_func_acos" = xyes -then : - printf "%s\n" "#define HAVE_ACOS 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "acosf" "ac_cv_func_acosf" -if test "x$ac_cv_func_acosf" = xyes -then : - printf "%s\n" "#define HAVE_ACOSF 1" >>confdefs.h +$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h fi -ac_fn_c_check_func "$LINENO" "asin" "ac_cv_func_asin" -if test "x$ac_cv_func_asin" = xyes -then : - printf "%s\n" "#define HAVE_ASIN 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "asinf" "ac_cv_func_asinf" -if test "x$ac_cv_func_asinf" = xyes -then : - printf "%s\n" "#define HAVE_ASINF 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 +$as_echo_n "checking for alloca... " >&6; } +if ${ac_cv_func_alloca_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __GNUC__ +# define alloca __builtin_alloca +#else +# ifdef _MSC_VER +# include +# define alloca _alloca +# else +# ifdef HAVE_ALLOCA_H +# include +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +void *alloca (size_t); +# endif +# endif +# endif +# endif +#endif +int +main () +{ +char *p = (char *) alloca (1); + if (p) return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_func_alloca_works=yes +else + ac_cv_func_alloca_works=no fi -ac_fn_c_check_func "$LINENO" "atan" "ac_cv_func_atan" -if test "x$ac_cv_func_atan" = xyes -then : - printf "%s\n" "#define HAVE_ATAN 1" >>confdefs.h - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi -ac_fn_c_check_func "$LINENO" "atanf" "ac_cv_func_atanf" -if test "x$ac_cv_func_atanf" = xyes -then : - printf "%s\n" "#define HAVE_ATANF 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 +$as_echo "$ac_cv_func_alloca_works" >&6; } -fi -ac_fn_c_check_func "$LINENO" "atan2" "ac_cv_func_atan2" -if test "x$ac_cv_func_atan2" = xyes -then : - printf "%s\n" "#define HAVE_ATAN2 1" >>confdefs.h +if test $ac_cv_func_alloca_works = yes; then -fi -ac_fn_c_check_func "$LINENO" "atan2f" "ac_cv_func_atan2f" -if test "x$ac_cv_func_atan2f" = xyes -then : - printf "%s\n" "#define HAVE_ATAN2F 1" >>confdefs.h +$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "ceil" "ac_cv_func_ceil" -if test "x$ac_cv_func_ceil" = xyes -then : - printf "%s\n" "#define HAVE_CEIL 1" >>confdefs.h +else + # The SVR3 libPW and SVR4 libucb both contain incompatible functions +# that cause trouble. Some versions do not even contain alloca or +# contain a buggy version. If you still want to use their alloca, +# use ar to extract alloca.o from them instead of compiling alloca.c. -fi -ac_fn_c_check_func "$LINENO" "ceilf" "ac_cv_func_ceilf" -if test "x$ac_cv_func_ceilf" = xyes -then : - printf "%s\n" "#define HAVE_CEILF 1" >>confdefs.h +ALLOCA=\${LIBOBJDIR}alloca.$ac_objext -fi -ac_fn_c_check_func "$LINENO" "copysign" "ac_cv_func_copysign" -if test "x$ac_cv_func_copysign" = xyes -then : - printf "%s\n" "#define HAVE_COPYSIGN 1" >>confdefs.h +$as_echo "#define C_ALLOCA 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "copysignf" "ac_cv_func_copysignf" -if test "x$ac_cv_func_copysignf" = xyes -then : - printf "%s\n" "#define HAVE_COPYSIGNF 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "cos" "ac_cv_func_cos" -if test "x$ac_cv_func_cos" = xyes -then : - printf "%s\n" "#define HAVE_COS 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 +$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } +if ${ac_cv_os_cray+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined CRAY && ! defined CRAY2 +webecray +#else +wenotbecray +#endif +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "webecray" >/dev/null 2>&1; then : + ac_cv_os_cray=yes +else + ac_cv_os_cray=no fi -ac_fn_c_check_func "$LINENO" "cosf" "ac_cv_func_cosf" -if test "x$ac_cv_func_cosf" = xyes -then : - printf "%s\n" "#define HAVE_COSF 1" >>confdefs.h +rm -f conftest* fi -ac_fn_c_check_func "$LINENO" "exp" "ac_cv_func_exp" -if test "x$ac_cv_func_exp" = xyes -then : - printf "%s\n" "#define HAVE_EXP 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 +$as_echo "$ac_cv_os_cray" >&6; } +if test $ac_cv_os_cray = yes; then + for ac_func in _getb67 GETB67 getb67; do + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : -fi -ac_fn_c_check_func "$LINENO" "expf" "ac_cv_func_expf" -if test "x$ac_cv_func_expf" = xyes -then : - printf "%s\n" "#define HAVE_EXPF 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define CRAY_STACKSEG_END $ac_func +_ACEOF + break fi -ac_fn_c_check_func "$LINENO" "fabs" "ac_cv_func_fabs" -if test "x$ac_cv_func_fabs" = xyes -then : - printf "%s\n" "#define HAVE_FABS 1" >>confdefs.h + done fi -ac_fn_c_check_func "$LINENO" "fabsf" "ac_cv_func_fabsf" -if test "x$ac_cv_func_fabsf" = xyes -then : - printf "%s\n" "#define HAVE_FABSF 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "floor" "ac_cv_func_floor" -if test "x$ac_cv_func_floor" = xyes -then : - printf "%s\n" "#define HAVE_FLOOR 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 +$as_echo_n "checking stack direction for C alloca... " >&6; } +if ${ac_cv_c_stack_direction+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_c_stack_direction=0 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +find_stack_direction (int *addr, int depth) +{ + int dir, dummy = 0; + if (! addr) + addr = &dummy; + *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; + dir = depth ? find_stack_direction (addr, depth - 1) : 0; + return dir + dummy; +} +int +main (int argc, char **argv) +{ + return find_stack_direction (0, argc + !argv + 20) < 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_c_stack_direction=1 +else + ac_cv_c_stack_direction=-1 fi -ac_fn_c_check_func "$LINENO" "floorf" "ac_cv_func_floorf" -if test "x$ac_cv_func_floorf" = xyes -then : - printf "%s\n" "#define HAVE_FLOORF 1" >>confdefs.h - +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi -ac_fn_c_check_func "$LINENO" "trunc" "ac_cv_func_trunc" -if test "x$ac_cv_func_trunc" = xyes -then : - printf "%s\n" "#define HAVE_TRUNC 1" >>confdefs.h fi -ac_fn_c_check_func "$LINENO" "truncf" "ac_cv_func_truncf" -if test "x$ac_cv_func_truncf" = xyes -then : - printf "%s\n" "#define HAVE_TRUNCF 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 +$as_echo "$ac_cv_c_stack_direction" >&6; } +cat >>confdefs.h <<_ACEOF +#define STACK_DIRECTION $ac_cv_c_stack_direction +_ACEOF -fi -ac_fn_c_check_func "$LINENO" "fmod" "ac_cv_func_fmod" -if test "x$ac_cv_func_fmod" = xyes -then : - printf "%s\n" "#define HAVE_FMOD 1" >>confdefs.h fi -ac_fn_c_check_func "$LINENO" "fmodf" "ac_cv_func_fmodf" -if test "x$ac_cv_func_fmodf" = xyes -then : - printf "%s\n" "#define HAVE_FMODF 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "log" "ac_cv_func_log" -if test "x$ac_cv_func_log" = xyes -then : - printf "%s\n" "#define HAVE_LOG 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "logf" "ac_cv_func_logf" -if test "x$ac_cv_func_logf" = xyes -then : - printf "%s\n" "#define HAVE_LOGF 1" >>confdefs.h + ac_fn_c_check_func "$LINENO" "mprotect" "ac_cv_func_mprotect" +if test "x$ac_cv_func_mprotect" = xyes; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -fi -ac_fn_c_check_func "$LINENO" "log10" "ac_cv_func_log10" -if test "x$ac_cv_func_log10" = xyes -then : - printf "%s\n" "#define HAVE_LOG10 1" >>confdefs.h + #include + #include -fi -ac_fn_c_check_func "$LINENO" "log10f" "ac_cv_func_log10f" -if test "x$ac_cv_func_log10f" = xyes -then : - printf "%s\n" "#define HAVE_LOG10F 1" >>confdefs.h +int +main () +{ -fi -ac_fn_c_check_func "$LINENO" "lround" "ac_cv_func_lround" -if test "x$ac_cv_func_lround" = xyes -then : - printf "%s\n" "#define HAVE_LROUND 1" >>confdefs.h + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : -fi -ac_fn_c_check_func "$LINENO" "lroundf" "ac_cv_func_lroundf" -if test "x$ac_cv_func_lroundf" = xyes -then : - printf "%s\n" "#define HAVE_LROUNDF 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "pow" "ac_cv_func_pow" -if test "x$ac_cv_func_pow" = xyes -then : - printf "%s\n" "#define HAVE_POW 1" >>confdefs.h +$as_echo "#define HAVE_MPROTECT 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "powf" "ac_cv_func_powf" -if test "x$ac_cv_func_powf" = xyes -then : - printf "%s\n" "#define HAVE_POWF 1" >>confdefs.h fi -ac_fn_c_check_func "$LINENO" "round" "ac_cv_func_round" -if test "x$ac_cv_func_round" = xyes -then : - printf "%s\n" "#define HAVE_ROUND 1" >>confdefs.h - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -ac_fn_c_check_func "$LINENO" "roundf" "ac_cv_func_roundf" -if test "x$ac_cv_func_roundf" = xyes -then : - printf "%s\n" "#define HAVE_ROUNDF 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "scalbn" "ac_cv_func_scalbn" -if test "x$ac_cv_func_scalbn" = xyes -then : - printf "%s\n" "#define HAVE_SCALBN 1" >>confdefs.h + for ac_func in malloc calloc realloc free getenv setenv putenv unsetenv bsearch qsort abs bcopy memset memcmp memcpy memmove wcslen wcslcpy wcslcat _wcsdup wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr index rindex strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtod strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp strcasestr vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval elf_aux_info poll _Exit +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF fi -ac_fn_c_check_func "$LINENO" "scalbnf" "ac_cv_func_scalbnf" -if test "x$ac_cv_func_scalbnf" = xyes -then : - printf "%s\n" "#define HAVE_SCALBNF 1" >>confdefs.h +done -fi -ac_fn_c_check_func "$LINENO" "sin" "ac_cv_func_sin" -if test "x$ac_cv_func_sin" = xyes -then : - printf "%s\n" "#define HAVE_SIN 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "sinf" "ac_cv_func_sinf" -if test "x$ac_cv_func_sinf" = xyes -then : - printf "%s\n" "#define HAVE_SINF 1" >>confdefs.h + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5 +$as_echo_n "checking for pow in -lm... " >&6; } +if ${ac_cv_lib_m_pow+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pow (); +int +main () +{ +return pow (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_m_pow=yes +else + ac_cv_lib_m_pow=no fi -ac_fn_c_check_func "$LINENO" "sqrt" "ac_cv_func_sqrt" -if test "x$ac_cv_func_sqrt" = xyes -then : - printf "%s\n" "#define HAVE_SQRT 1" >>confdefs.h - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -ac_fn_c_check_func "$LINENO" "sqrtf" "ac_cv_func_sqrtf" -if test "x$ac_cv_func_sqrtf" = xyes -then : - printf "%s\n" "#define HAVE_SQRTF 1" >>confdefs.h - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5 +$as_echo "$ac_cv_lib_m_pow" >&6; } +if test "x$ac_cv_lib_m_pow" = xyes; then : + LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm" fi -ac_fn_c_check_func "$LINENO" "tan" "ac_cv_func_tan" -if test "x$ac_cv_func_tan" = xyes -then : - printf "%s\n" "#define HAVE_TAN 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "tanf" "ac_cv_func_tanf" -if test "x$ac_cv_func_tanf" = xyes -then : - printf "%s\n" "#define HAVE_TANF 1" >>confdefs.h + for ac_func in acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf trunc truncf fmod fmodf log logf log10 log10f lround lroundf pow powf round roundf scalbn scalbnf sin sinf sqrt sqrtf tan tanf +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF fi +done if test x$enable_system_iconv = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for iconv_open in -liconv" >&5 -printf %s "checking for iconv_open in -liconv... " >&6; } -if test ${ac_cv_lib_iconv_iconv_open+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv_open in -liconv" >&5 +$as_echo_n "checking for iconv_open in -liconv... " >&6; } +if ${ac_cv_lib_iconv_iconv_open+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-liconv $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -20063,78 +18130,86 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char iconv_open (); int -main (void) +main () { return iconv_open (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_iconv_iconv_open=yes -else $as_nop +else ac_cv_lib_iconv_iconv_open=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iconv_iconv_open" >&5 -printf "%s\n" "$ac_cv_lib_iconv_iconv_open" >&6; } -if test "x$ac_cv_lib_iconv_iconv_open" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iconv_iconv_open" >&5 +$as_echo "$ac_cv_lib_iconv_iconv_open" >&6; } +if test "x$ac_cv_lib_iconv_iconv_open" = xyes; then : LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv" fi - ac_fn_c_check_func "$LINENO" "iconv" "ac_cv_func_iconv" -if test "x$ac_cv_func_iconv" = xyes -then : - printf "%s\n" "#define HAVE_ICONV 1" >>confdefs.h + for ac_func in iconv +do : + ac_fn_c_check_func "$LINENO" "iconv" "ac_cv_func_iconv" +if test "x$ac_cv_func_iconv" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_ICONV 1 +_ACEOF fi +done fi ac_fn_c_check_member "$LINENO" "struct sigaction" "sa_sigaction" "ac_cv_member_struct_sigaction_sa_sigaction" "#include " -if test "x$ac_cv_member_struct_sigaction_sa_sigaction" = xyes -then : +if test "x$ac_cv_member_struct_sigaction_sa_sigaction" = xyes; then : -printf "%s\n" "#define HAVE_SA_SIGACTION 1" >>confdefs.h +$as_echo "#define HAVE_SA_SIGACTION 1" >>confdefs.h fi - ac_fn_c_check_header_compile "$LINENO" "libunwind.h" "ac_cv_header_libunwind_h" "$ac_includes_default" -if test "x$ac_cv_header_libunwind_h" = xyes -then : - printf "%s\n" "#define HAVE_LIBUNWIND_H 1" >>confdefs.h + for ac_header in libunwind.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "libunwind.h" "ac_cv_header_libunwind_h" "$ac_includes_default" +if test "x$ac_cv_header_libunwind_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBUNWIND_H 1 +_ACEOF fi +done + fi # Check whether --enable-gcc-atomics was given. -if test ${enable_gcc_atomics+y} -then : +if test "${enable_gcc_atomics+set}" = set; then : enableval=$enable_gcc_atomics; -else $as_nop +else enable_gcc_atomics=yes fi if test x$enable_gcc_atomics = xyes; then have_gcc_atomics=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC builtin atomic operations" >&5 -printf %s "checking for GCC builtin atomic operations... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC builtin atomic operations" >&5 +$as_echo_n "checking for GCC builtin atomic operations... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { int a; @@ -20149,18 +18224,17 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : have_gcc_atomics=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_atomics" >&5 -printf "%s\n" "$have_gcc_atomics" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_atomics" >&5 +$as_echo "$have_gcc_atomics" >&6; } if test x$have_gcc_atomics = xyes; then -printf "%s\n" "#define HAVE_GCC_ATOMICS 1" >>confdefs.h +$as_echo "#define HAVE_GCC_ATOMICS 1" >>confdefs.h else # See if we have the minimum operation needed for GCC atomics @@ -20168,7 +18242,7 @@ printf "%s\n" "#define HAVE_GCC_ATOMICS 1" >>confdefs.h /* end confdefs.h. */ int -main (void) +main () { int a; @@ -20179,15 +18253,14 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : have_gcc_sync_lock_test_and_set=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test x$have_gcc_sync_lock_test_and_set = xyes; then -printf "%s\n" "#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1" >>confdefs.h +$as_echo "#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1" >>confdefs.h fi fi @@ -20229,166 +18302,155 @@ case "$host" in esac # Check whether --enable-atomic was given. -if test ${enable_atomic+y} -then : +if test "${enable_atomic+set}" = set; then : enableval=$enable_atomic; -else $as_nop +else enable_atomic=$default_atomic fi if test x$enable_atomic != xyes; then -printf "%s\n" "#define SDL_ATOMIC_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_ATOMIC_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} atomic" fi # Check whether --enable-audio was given. -if test ${enable_audio+y} -then : +if test "${enable_audio+set}" = set; then : enableval=$enable_audio; -else $as_nop +else enable_audio=yes fi if test x$enable_audio != xyes; then -printf "%s\n" "#define SDL_AUDIO_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} audio" fi # Check whether --enable-video was given. -if test ${enable_video+y} -then : +if test "${enable_video+set}" = set; then : enableval=$enable_video; -else $as_nop +else enable_video=yes fi if test x$enable_video != xyes; then -printf "%s\n" "#define SDL_VIDEO_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} video" fi # Check whether --enable-render was given. -if test ${enable_render+y} -then : +if test "${enable_render+set}" = set; then : enableval=$enable_render; -else $as_nop +else enable_render=yes fi if test x$enable_render != xyes; then -printf "%s\n" "#define SDL_RENDER_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_RENDER_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} render" fi # Check whether --enable-events was given. -if test ${enable_events+y} -then : +if test "${enable_events+set}" = set; then : enableval=$enable_events; -else $as_nop +else enable_events=yes fi if test x$enable_events != xyes; then -printf "%s\n" "#define SDL_EVENTS_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_EVENTS_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} events" fi # Check whether --enable-joystick was given. -if test ${enable_joystick+y} -then : +if test "${enable_joystick+set}" = set; then : enableval=$enable_joystick; -else $as_nop +else enable_joystick=yes fi if test x$enable_joystick != xyes; then -printf "%s\n" "#define SDL_JOYSTICK_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} joystick" fi # Check whether --enable-haptic was given. -if test ${enable_haptic+y} -then : +if test "${enable_haptic+set}" = set; then : enableval=$enable_haptic; -else $as_nop +else enable_haptic=yes fi if test x$enable_haptic != xyes; then -printf "%s\n" "#define SDL_HAPTIC_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_HAPTIC_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} haptic" fi # Check whether --enable-hidapi was given. -if test ${enable_hidapi+y} -then : +if test "${enable_hidapi+set}" = set; then : enableval=$enable_hidapi; -else $as_nop +else enable_hidapi=yes fi if test x$enable_hidapi != xyes; then -printf "%s\n" "#define SDL_HIDAPI_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_HIDAPI_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} hidapi" fi # Check whether --enable-sensor was given. -if test ${enable_sensor+y} -then : +if test "${enable_sensor+set}" = set; then : enableval=$enable_sensor; -else $as_nop +else enable_sensor=yes fi if test x$enable_sensor != xyes; then -printf "%s\n" "#define SDL_SENSOR_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_SENSOR_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} sensor" fi # Check whether --enable-power was given. -if test ${enable_power+y} -then : +if test "${enable_power+set}" = set; then : enableval=$enable_power; -else $as_nop +else enable_power=yes fi if test x$enable_power != xyes; then -printf "%s\n" "#define SDL_POWER_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_POWER_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} power" fi # Check whether --enable-filesystem was given. -if test ${enable_filesystem+y} -then : +if test "${enable_filesystem+set}" = set; then : enableval=$enable_filesystem; -else $as_nop +else enable_filesystem=yes fi if test x$enable_filesystem != xyes; then -printf "%s\n" "#define SDL_FILESYSTEM_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_FILESYSTEM_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} filesystem" @@ -20400,106 +18462,99 @@ fi enable_threads=yes if test x$enable_threads != xyes; then -printf "%s\n" "#define SDL_THREADS_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_THREADS_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} threads" fi # Check whether --enable-timers was given. -if test ${enable_timers+y} -then : +if test "${enable_timers+set}" = set; then : enableval=$enable_timers; -else $as_nop +else enable_timers=yes fi if test x$enable_timers != xyes; then -printf "%s\n" "#define SDL_TIMERS_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_TIMERS_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} timers" fi # Check whether --enable-file was given. -if test ${enable_file+y} -then : +if test "${enable_file+set}" = set; then : enableval=$enable_file; -else $as_nop +else enable_file=yes fi if test x$enable_file != xyes; then -printf "%s\n" "#define SDL_FILE_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_FILE_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} file" fi # Check whether --enable-misc was given. -if test ${enable_misc+y} -then : +if test "${enable_misc+set}" = set; then : enableval=$enable_misc; -else $as_nop +else enable_misc=yes fi if test x$enable_misc != xyes; then -printf "%s\n" "#define SDL_MISC_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_MISC_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} misc" fi # Check whether --enable-locale was given. -if test ${enable_locale+y} -then : +if test "${enable_locale+set}" = set; then : enableval=$enable_locale; -else $as_nop +else enable_locale=yes fi if test x$enable_locale != xyes; then -printf "%s\n" "#define SDL_LOCALE_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_LOCALE_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} locale" fi # Check whether --enable-loadso was given. -if test ${enable_loadso+y} -then : +if test "${enable_loadso+set}" = set; then : enableval=$enable_loadso; -else $as_nop +else enable_loadso=yes fi if test x$enable_loadso != xyes; then -printf "%s\n" "#define SDL_LOADSO_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_LOADSO_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} loadso" fi # Check whether --enable-cpuinfo was given. -if test ${enable_cpuinfo+y} -then : +if test "${enable_cpuinfo+set}" = set; then : enableval=$enable_cpuinfo; -else $as_nop +else enable_cpuinfo=yes fi if test x$enable_cpuinfo != xyes; then -printf "%s\n" "#define SDL_CPUINFO_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_CPUINFO_DISABLED 1" >>confdefs.h else SUMMARY_modules="${SUMMARY_modules} cpuinfo" fi # Check whether --enable-assembly was given. -if test ${enable_assembly+y} -then : +if test "${enable_assembly+set}" = set; then : enableval=$enable_assembly; -else $as_nop +else enable_assembly=yes fi @@ -20522,10 +18577,9 @@ if test x$enable_assembly = xyes; then ;; esac # Check whether --enable-ssemath was given. -if test ${enable_ssemath+y} -then : +if test "${enable_ssemath+set}" = set; then : enableval=$enable_ssemath; -else $as_nop +else enable_ssemath=$default_ssemath fi @@ -20536,18 +18590,17 @@ fi fi # Check whether --enable-mmx was given. -if test ${enable_mmx+y} -then : +if test "${enable_mmx+set}" = set; then : enableval=$enable_mmx; -else $as_nop +else enable_mmx=yes fi if test x$enable_mmx = xyes; then save_CFLAGS="$CFLAGS" have_gcc_mmx=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -mmmx option" >&5 -printf %s "checking for GCC -mmmx option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -mmmx option" >&5 +$as_echo_n "checking for GCC -mmmx option... " >&6; } mmx_CFLAGS="-mmmx" CFLAGS="$save_CFLAGS $mmx_CFLAGS" @@ -20569,20 +18622,19 @@ printf %s "checking for GCC -mmmx option... " >&6; } #endif int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_mmx=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_mmx" >&5 -printf "%s\n" "$have_gcc_mmx" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_mmx" >&5 +$as_echo "$have_gcc_mmx" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_mmx = xyes; then @@ -20592,18 +18644,17 @@ printf "%s\n" "$have_gcc_mmx" >&6; } fi # Check whether --enable-3dnow was given. -if test ${enable_3dnow+y} -then : +if test "${enable_3dnow+set}" = set; then : enableval=$enable_3dnow; -else $as_nop +else enable_3dnow=yes fi if test x$enable_3dnow = xyes; then save_CFLAGS="$CFLAGS" have_gcc_3dnow=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -m3dnow option" >&5 -printf %s "checking for GCC -m3dnow option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -m3dnow option" >&5 +$as_echo_n "checking for GCC -m3dnow option... " >&6; } amd3dnow_CFLAGS="-m3dnow" CFLAGS="$save_CFLAGS $amd3dnow_CFLAGS" @@ -20616,7 +18667,7 @@ printf %s "checking for GCC -m3dnow option... " >&6; } #endif int -main (void) +main () { void *p = 0; @@ -20626,14 +18677,13 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : have_gcc_3dnow=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_3dnow" >&5 -printf "%s\n" "$have_gcc_3dnow" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_3dnow" >&5 +$as_echo "$have_gcc_3dnow" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_3dnow = xyes; then @@ -20643,18 +18693,17 @@ printf "%s\n" "$have_gcc_3dnow" >&6; } fi # Check whether --enable-sse was given. -if test ${enable_sse+y} -then : +if test "${enable_sse+set}" = set; then : enableval=$enable_sse; -else $as_nop +else enable_sse=yes fi if test x$enable_sse = xyes; then save_CFLAGS="$CFLAGS" have_gcc_sse=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -msse option" >&5 -printf %s "checking for GCC -msse option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -msse option" >&5 +$as_echo_n "checking for GCC -msse option... " >&6; } sse_CFLAGS="-msse" CFLAGS="$save_CFLAGS $sse_CFLAGS" @@ -20676,20 +18725,19 @@ printf %s "checking for GCC -msse option... " >&6; } #endif int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_sse=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_sse" >&5 -printf "%s\n" "$have_gcc_sse" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_sse" >&5 +$as_echo "$have_gcc_sse" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_sse = xyes; then @@ -20699,18 +18747,17 @@ printf "%s\n" "$have_gcc_sse" >&6; } fi # Check whether --enable-sse2 was given. -if test ${enable_sse2+y} -then : +if test "${enable_sse2+set}" = set; then : enableval=$enable_sse2; -else $as_nop +else enable_sse2=$default_ssemath fi if test x$enable_sse2 = xyes; then save_CFLAGS="$CFLAGS" have_gcc_sse2=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -msse2 option" >&5 -printf %s "checking for GCC -msse2 option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -msse2 option" >&5 +$as_echo_n "checking for GCC -msse2 option... " >&6; } sse2_CFLAGS="-msse2" CFLAGS="$save_CFLAGS $sse2_CFLAGS" @@ -20732,20 +18779,19 @@ printf %s "checking for GCC -msse2 option... " >&6; } #endif int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_sse2=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_sse2" >&5 -printf "%s\n" "$have_gcc_sse2" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_sse2" >&5 +$as_echo "$have_gcc_sse2" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_sse2 = xyes; then @@ -20755,18 +18801,17 @@ printf "%s\n" "$have_gcc_sse2" >&6; } fi # Check whether --enable-sse3 was given. -if test ${enable_sse3+y} -then : +if test "${enable_sse3+set}" = set; then : enableval=$enable_sse3; -else $as_nop +else enable_sse3=$default_ssemath fi if test x$enable_sse3 = xyes; then save_CFLAGS="$CFLAGS" have_gcc_sse3=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -msse3 option" >&5 -printf %s "checking for GCC -msse3 option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -msse3 option" >&5 +$as_echo_n "checking for GCC -msse3 option... " >&6; } sse3_CFLAGS="-msse3" CFLAGS="$save_CFLAGS $sse3_CFLAGS" @@ -20788,20 +18833,19 @@ printf %s "checking for GCC -msse3 option... " >&6; } #endif int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_sse3=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_sse3" >&5 -printf "%s\n" "$have_gcc_sse3" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_sse3" >&5 +$as_echo "$have_gcc_sse3" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_sse3 = xyes; then @@ -20810,39 +18854,37 @@ printf "%s\n" "$have_gcc_sse3" >&6; } fi fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for immintrin.h" >&5 -printf %s "checking for immintrin.h... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for immintrin.h" >&5 +$as_echo_n "checking for immintrin.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_immintrin_h_hdr=yes -else $as_nop +else have_immintrin_h_hdr=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_immintrin_h_hdr" >&5 -printf "%s\n" "$have_immintrin_h_hdr" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_immintrin_h_hdr" >&5 +$as_echo "$have_immintrin_h_hdr" >&6; } if test x$have_immintrin_h_hdr = xyes; then -printf "%s\n" "#define HAVE_IMMINTRIN_H 1" >>confdefs.h +$as_echo "#define HAVE_IMMINTRIN_H 1" >>confdefs.h fi # Check whether --enable-altivec was given. -if test ${enable_altivec+y} -then : +if test "${enable_altivec+set}" = set; then : enableval=$enable_altivec; -else $as_nop +else enable_altivec=yes fi @@ -20853,8 +18895,8 @@ fi altivec_CFLAGS="-maltivec" CFLAGS="$save_CFLAGS $altivec_CFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Altivec with GCC altivec.h and -maltivec option" >&5 -printf %s "checking for Altivec with GCC altivec.h and -maltivec option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Altivec with GCC altivec.h and -maltivec option" >&5 +$as_echo_n "checking for Altivec with GCC altivec.h and -maltivec option... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -20864,27 +18906,26 @@ printf %s "checking for Altivec with GCC altivec.h and -maltivec option... " >&6 } int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_altivec=yes have_altivec_h_hdr=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_altivec" >&5 -printf "%s\n" "$have_gcc_altivec" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_altivec" >&5 +$as_echo "$have_gcc_altivec" >&6; } if test x$have_gcc_altivec = xno; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Altivec with GCC -maltivec option" >&5 -printf %s "checking for Altivec with GCC -maltivec option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Altivec with GCC -maltivec option" >&5 +$as_echo_n "checking for Altivec with GCC -maltivec option... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -20893,25 +18934,24 @@ printf %s "checking for Altivec with GCC -maltivec option... " >&6; } } int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_altivec=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_altivec" >&5 -printf "%s\n" "$have_gcc_altivec" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_altivec" >&5 +$as_echo "$have_gcc_altivec" >&6; } fi if test x$have_gcc_altivec = xno; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Altivec with GCC altivec.h and -faltivec option" >&5 -printf %s "checking for Altivec with GCC altivec.h and -faltivec option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Altivec with GCC altivec.h and -faltivec option" >&5 +$as_echo_n "checking for Altivec with GCC altivec.h and -faltivec option... " >&6; } altivec_CFLAGS="-faltivec" CFLAGS="$save_CFLAGS $altivec_CFLAGS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -20923,28 +18963,27 @@ printf %s "checking for Altivec with GCC altivec.h and -faltivec option... " >&6 } int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_altivec=yes have_altivec_h_hdr=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_altivec" >&5 -printf "%s\n" "$have_gcc_altivec" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_altivec" >&5 +$as_echo "$have_gcc_altivec" >&6; } fi if test x$have_gcc_altivec = xno; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Altivec with GCC -faltivec option" >&5 -printf %s "checking for Altivec with GCC -faltivec option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Altivec with GCC -faltivec option" >&5 +$as_echo_n "checking for Altivec with GCC -faltivec option... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -20953,30 +18992,29 @@ printf %s "checking for Altivec with GCC -faltivec option... " >&6; } } int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_altivec=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_altivec" >&5 -printf "%s\n" "$have_gcc_altivec" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_altivec" >&5 +$as_echo "$have_gcc_altivec" >&6; } fi CFLAGS="$save_CFLAGS" if test x$have_gcc_altivec = xyes; then -printf "%s\n" "#define SDL_ALTIVEC_BLITTERS 1" >>confdefs.h +$as_echo "#define SDL_ALTIVEC_BLITTERS 1" >>confdefs.h if test x$have_altivec_h_hdr = xyes; then -printf "%s\n" "#define HAVE_ALTIVEC_H 1" >>confdefs.h +$as_echo "#define HAVE_ALTIVEC_H 1" >>confdefs.h fi EXTRA_CFLAGS="$EXTRA_CFLAGS $altivec_CFLAGS" @@ -20986,18 +19024,17 @@ printf "%s\n" "#define HAVE_ALTIVEC_H 1" >>confdefs.h fi # Check whether --enable-lsx was given. -if test ${enable_lsx+y} -then : +if test "${enable_lsx+set}" = set; then : enableval=$enable_lsx; -else $as_nop +else enable_lsx=yes fi if test x$enable_lsx = xyes; then save_CFLAGS="$CFLAGS" have_gcc_lsx=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -mlsx option" >&5 -printf %s "checking for GCC -mlsx option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -mlsx option" >&5 +$as_echo_n "checking for GCC -mlsx option... " >&6; } lsx_CFLAGS="-mlsx" CFLAGS="$save_CFLAGS $lsx_CFLAGS" @@ -21009,20 +19046,19 @@ printf %s "checking for GCC -mlsx option... " >&6; } #endif int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_lsx=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_lsx" >&5 -printf "%s\n" "$have_gcc_lsx" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_lsx" >&5 +$as_echo "$have_gcc_lsx" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_lsx = xyes; then @@ -21031,47 +19067,45 @@ printf "%s\n" "$have_gcc_lsx" >&6; } fi fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for lsxintrin.h" >&5 -printf %s "checking for lsxintrin.h... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lsxintrin.h" >&5 +$as_echo_n "checking for lsxintrin.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_lsxintrin_h_hdr=yes -else $as_nop +else have_lsxintrin_h_hdr=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_lsxintrin_h_hdr" >&5 -printf "%s\n" "$have_lsxintrin_h_hdr" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_lsxintrin_h_hdr" >&5 +$as_echo "$have_lsxintrin_h_hdr" >&6; } if test x$have_lsxintrin_h_hdr = xyes; then -printf "%s\n" "#define HAVE_LSXINTRIN_H 1" >>confdefs.h +$as_echo "#define HAVE_LSXINTRIN_H 1" >>confdefs.h fi # Check whether --enable-lasx was given. -if test ${enable_lasx+y} -then : +if test "${enable_lasx+set}" = set; then : enableval=$enable_lasx; -else $as_nop +else enable_LASX=yes fi if test x$enable_LASX = xyes; then save_CFLAGS="$CFLAGS" have_gcc_lasx=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -mlasx option" >&5 -printf %s "checking for GCC -mlasx option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -mlasx option" >&5 +$as_echo_n "checking for GCC -mlasx option... " >&6; } lasx_CFLAGS="-mlasx" CFLAGS="$save_CFLAGS $lasx_CFLAGS" @@ -21083,20 +19117,19 @@ printf %s "checking for GCC -mlasx option... " >&6; } #endif int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_lasx=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_lasx" >&5 -printf "%s\n" "$have_gcc_lasx" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_lasx" >&5 +$as_echo "$have_gcc_lasx" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_lasx = xyes; then @@ -21105,41 +19138,39 @@ printf "%s\n" "$have_gcc_lasx" >&6; } fi fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for lasxintrin.h" >&5 -printf %s "checking for lasxintrin.h... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lasxintrin.h" >&5 +$as_echo_n "checking for lasxintrin.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_lasxintrin_h_hdr=yes -else $as_nop +else have_lasxintrin_h_hdr=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_lasxintrin_h_hdr" >&5 -printf "%s\n" "$have_lasxintrin_h_hdr" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_lasxintrin_h_hdr" >&5 +$as_echo "$have_lasxintrin_h_hdr" >&6; } if test x$have_lasxintrin_h_hdr = xyes; then -printf "%s\n" "#define HAVE_LASXINTRIN_H 1" >>confdefs.h +$as_echo "#define HAVE_LASXINTRIN_H 1" >>confdefs.h fi CheckOSS() { # Check whether --enable-oss was given. -if test ${enable_oss+y} -then : +if test "${enable_oss+set}" = set; then : enableval=$enable_oss; -else $as_nop +else enable_oss=maybe fi @@ -21148,8 +19179,8 @@ fi fi if test x$enable_audio = xyes -a x$enable_oss = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for OSS audio support" >&5 -printf %s "checking for OSS audio support... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OSS audio support" >&5 +$as_echo_n "checking for OSS audio support... " >&6; } have_oss=no if test x$have_oss != xyes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -21158,7 +19189,7 @@ printf %s "checking for OSS audio support... " >&6; } #include int -main (void) +main () { int arg = SNDCTL_DSP_SETFRAGMENT; @@ -21167,18 +19198,17 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_oss=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_oss" >&5 -printf "%s\n" "$have_oss" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_oss" >&5 +$as_echo "$have_oss" >&6; } if test x$have_oss = xyes; then SUMMARY_audio="${SUMMARY_audio} oss" -printf "%s\n" "#define SDL_AUDIO_DRIVER_OSS 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_OSS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/dsp/*.c" have_audio=yes @@ -21195,10 +19225,9 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_OSS 1" >>confdefs.h CheckALSA() { # Check whether --enable-alsa was given. -if test ${enable_alsa+y} -then : +if test "${enable_alsa+set}" = set; then : enableval=$enable_alsa; -else $as_nop +else enable_alsa=yes fi @@ -21210,44 +19239,41 @@ alsa_found=yes # Check whether --with-alsa-prefix was given. -if test ${with_alsa_prefix+y} -then : +if test "${with_alsa_prefix+set}" = set; then : withval=$with_alsa_prefix; alsa_prefix="$withval" -else $as_nop +else alsa_prefix="" fi # Check whether --with-alsa-inc-prefix was given. -if test ${with_alsa_inc_prefix+y} -then : +if test "${with_alsa_inc_prefix+set}" = set; then : withval=$with_alsa_inc_prefix; alsa_inc_prefix="$withval" -else $as_nop +else alsa_inc_prefix="" fi # Check whether --enable-alsatest was given. -if test ${enable_alsatest+y} -then : +if test "${enable_alsatest+set}" = set; then : enableval=$enable_alsatest; enable_alsatest="$enableval" -else $as_nop +else enable_alsatest=yes fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ALSA CFLAGS" >&5 -printf %s "checking for ALSA CFLAGS... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ALSA CFLAGS" >&5 +$as_echo_n "checking for ALSA CFLAGS... " >&6; } if test "$alsa_inc_prefix" != "" ; then ALSA_CFLAGS="$ALSA_CFLAGS -I$alsa_inc_prefix" CFLAGS="$CFLAGS -I$alsa_inc_prefix" fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ALSA_CFLAGS" >&5 -printf "%s\n" "$ALSA_CFLAGS" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ALSA_CFLAGS" >&5 +$as_echo "$ALSA_CFLAGS" >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ALSA LDFLAGS" >&5 -printf %s "checking for ALSA LDFLAGS... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ALSA LDFLAGS" >&5 +$as_echo_n "checking for ALSA LDFLAGS... " >&6; } if test "$alsa_prefix" != "" ; then ALSA_LIBS="$ALSA_LIBS -L$alsa_prefix" LDFLAGS="$LDFLAGS $ALSA_LIBS" @@ -21259,12 +19285,12 @@ LIBS=`echo $LIBS | sed 's/-ldl//'` LIBS=`echo $LIBS | sed 's/-lpthread//'` LIBS=`echo $LIBS | sed 's/ //'` LIBS="$ALSA_LIBS $LIBS" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ALSA_LIBS" >&5 -printf "%s\n" "$ALSA_LIBS" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ALSA_LIBS" >&5 +$as_echo "$ALSA_LIBS" >&6; } min_alsa_version=1.0.11 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libasound headers version >= $min_alsa_version" >&5 -printf %s "checking for libasound headers version >= $min_alsa_version... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libasound headers version >= $min_alsa_version" >&5 +$as_echo_n "checking for libasound headers version >= $min_alsa_version... " >&6; } no_alsa="" alsa_min_major_version=`echo $min_alsa_version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` @@ -21285,7 +19311,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #include int -main (void) +main () { /* ensure backward compatibility */ @@ -21324,18 +19350,17 @@ exit(0); return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found." >&5 -printf "%s\n" "found." >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not present." >&5 -printf "%s\n" "not present." >&6; } +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found." >&5 +$as_echo "found." >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not present." >&5 +$as_echo "not present." >&6; } alsa_found=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -21344,12 +19369,11 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test "x$enable_alsatest" = "xyes"; then -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for snd_ctl_open in -lasound" >&5 -printf %s "checking for snd_ctl_open in -lasound... " >&6; } -if test ${ac_cv_lib_asound_snd_ctl_open+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for snd_ctl_open in -lasound" >&5 +$as_echo_n "checking for snd_ctl_open in -lasound... " >&6; } +if ${ac_cv_lib_asound_snd_ctl_open+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lasound $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -21358,34 +19382,37 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char snd_ctl_open (); int -main (void) +main () { return snd_ctl_open (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_asound_snd_ctl_open=yes -else $as_nop +else ac_cv_lib_asound_snd_ctl_open=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_asound_snd_ctl_open" >&5 -printf "%s\n" "$ac_cv_lib_asound_snd_ctl_open" >&6; } -if test "x$ac_cv_lib_asound_snd_ctl_open" = xyes -then : - printf "%s\n" "#define HAVE_LIBASOUND 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_asound_snd_ctl_open" >&5 +$as_echo "$ac_cv_lib_asound_snd_ctl_open" >&6; } +if test "x$ac_cv_lib_asound_snd_ctl_open" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBASOUND 1 +_ACEOF LIBS="-lasound $LIBS" -else $as_nop +else alsa_found=no @@ -21417,30 +19444,31 @@ fi LIBS="$alsa_save_LIBS" if test x$have_alsa = xyes; then # Check whether --enable-alsa-shared was given. -if test ${enable_alsa_shared+y} -then : +if test "${enable_alsa_shared+set}" = set; then : enableval=$enable_alsa_shared; -else $as_nop +else enable_alsa_shared=yes fi alsa_lib=`find_lib "libasound.so.*" "$ALSA_LIBS" | sed 's/.*\/\(.*\)/\1/; q'` -printf "%s\n" "#define SDL_AUDIO_DRIVER_ALSA 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_ALSA 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/alsa/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $ALSA_CFLAGS" if test x$have_loadso != xyes && \ test x$enable_alsa_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic ALSA loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic ALSA loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic ALSA loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic ALSA loading" >&2;} fi if test x$have_loadso = xyes && \ test x$enable_alsa_shared = xyes && test x$alsa_lib != x; then echo "-- dynamic libasound -> $alsa_lib" -printf "%s\n" "#define SDL_AUDIO_DRIVER_ALSA_DYNAMIC \"$alsa_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_AUDIO_DRIVER_ALSA_DYNAMIC "$alsa_lib" +_ACEOF SUMMARY_audio="${SUMMARY_audio} alsa(dynamic)" else @@ -21455,27 +19483,26 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_ALSA_DYNAMIC \"$alsa_lib\"" >>confdefs.h CheckJACK() { # Check whether --enable-jack was given. -if test ${enable_jack+y} -then : +if test "${enable_jack+set}" = set; then : enableval=$enable_jack; -else $as_nop +else enable_jack=yes fi if test x$enable_audio = xyes -a x$enable_jack = xyes; then pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for jack >= 0.125" >&5 -printf %s "checking for jack >= 0.125... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for jack >= 0.125" >&5 +$as_echo_n "checking for jack >= 0.125... " >&6; } if test -n "$JACK_CFLAGS"; then pkg_cv_JACK_CFLAGS="$JACK_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"jack >= 0.125\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"jack >= 0.125\""; } >&5 ($PKG_CONFIG --exists --print-errors "jack >= 0.125") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_JACK_CFLAGS=`$PKG_CONFIG --cflags "jack >= 0.125" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -21489,10 +19516,10 @@ if test -n "$JACK_LIBS"; then pkg_cv_JACK_LIBS="$JACK_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"jack >= 0.125\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"jack >= 0.125\""; } >&5 ($PKG_CONFIG --exists --print-errors "jack >= 0.125") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_JACK_LIBS=`$PKG_CONFIG --libs "jack >= 0.125" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -21506,8 +19533,8 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -21524,43 +19551,44 @@ fi audio_jack=no elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } audio_jack=no else JACK_CFLAGS=$pkg_cv_JACK_CFLAGS JACK_LIBS=$pkg_cv_JACK_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } audio_jack=yes fi if test x$audio_jack = xyes; then # Check whether --enable-jack-shared was given. -if test ${enable_jack_shared+y} -then : +if test "${enable_jack_shared+set}" = set; then : enableval=$enable_jack_shared; -else $as_nop +else enable_jack_shared=yes fi jack_lib=`find_lib "libjack.so.*" "$JACK_LIBS" | sed 's/.*\/\(.*\)/\1/; q'` -printf "%s\n" "#define SDL_AUDIO_DRIVER_JACK 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_JACK 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/jack/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $JACK_CFLAGS" if test x$have_loadso != xyes && \ test x$enable_jack_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic JACK audio loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic JACK audio loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic JACK audio loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic JACK audio loading" >&2;} fi if test x$have_loadso = xyes && \ test x$enable_jack_shared = xyes && test x$jack_lib != x; then echo "-- dynamic libjack -> $jack_lib" -printf "%s\n" "#define SDL_AUDIO_DRIVER_JACK_DYNAMIC \"$jack_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_AUDIO_DRIVER_JACK_DYNAMIC "$jack_lib" +_ACEOF SUMMARY_audio="${SUMMARY_audio} jack(dynamic)" @@ -21583,27 +19611,26 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_JACK_DYNAMIC \"$jack_lib\"" >>confdefs.h CheckESD() { # Check whether --enable-esd was given. -if test ${enable_esd+y} -then : +if test "${enable_esd+set}" = set; then : enableval=$enable_esd; -else $as_nop +else enable_esd=yes fi if test x$enable_audio = xyes -a x$enable_esd = xyes; then pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for esound >= 0.2.8" >&5 -printf %s "checking for esound >= 0.2.8... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for esound >= 0.2.8" >&5 +$as_echo_n "checking for esound >= 0.2.8... " >&6; } if test -n "$ESD_CFLAGS"; then pkg_cv_ESD_CFLAGS="$ESD_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"esound >= 0.2.8\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"esound >= 0.2.8\""; } >&5 ($PKG_CONFIG --exists --print-errors "esound >= 0.2.8") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_ESD_CFLAGS=`$PKG_CONFIG --cflags "esound >= 0.2.8" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -21617,10 +19644,10 @@ if test -n "$ESD_LIBS"; then pkg_cv_ESD_LIBS="$ESD_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"esound >= 0.2.8\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"esound >= 0.2.8\""; } >&5 ($PKG_CONFIG --exists --print-errors "esound >= 0.2.8") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_ESD_LIBS=`$PKG_CONFIG --libs "esound >= 0.2.8" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -21634,8 +19661,8 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -21652,40 +19679,37 @@ fi have_esd=no elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } have_esd=no else ESD_CFLAGS=$pkg_cv_ESD_CFLAGS ESD_LIBS=$pkg_cv_ESD_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } have_esd=yes fi if test x$have_esd = xno; then # Check whether --with-esd-prefix was given. -if test ${with_esd_prefix+y} -then : +if test "${with_esd_prefix+set}" = set; then : withval=$with_esd_prefix; esd_prefix="$withval" -else $as_nop +else esd_prefix="" fi # Check whether --with-esd-exec-prefix was given. -if test ${with_esd_exec_prefix+y} -then : +if test "${with_esd_exec_prefix+set}" = set; then : withval=$with_esd_exec_prefix; esd_exec_prefix="$withval" -else $as_nop +else esd_exec_prefix="" fi # Check whether --enable-esdtest was given. -if test ${enable_esdtest+y} -then : +if test "${enable_esdtest+set}" = set; then : enableval=$enable_esdtest; -else $as_nop +else enable_esdtest=yes fi @@ -21705,12 +19729,11 @@ fi # Extract the first word of "esd-config", so it can be a program name with args. set dummy esd-config; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_path_ESD_CONFIG+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ESD_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else case $ESD_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ESD_CONFIG="$ESD_CONFIG" # Let the user override the test with a path. @@ -21720,15 +19743,11 @@ else $as_nop for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_path_ESD_CONFIG="$as_dir$ac_word$ac_exec_ext" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ESD_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -21741,17 +19760,17 @@ esac fi ESD_CONFIG=$ac_cv_path_ESD_CONFIG if test -n "$ESD_CONFIG"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ESD_CONFIG" >&5 -printf "%s\n" "$ESD_CONFIG" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ESD_CONFIG" >&5 +$as_echo "$ESD_CONFIG" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi min_esd_version=0.2.8 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ESD - version >= $min_esd_version" >&5 -printf %s "checking for ESD - version >= $min_esd_version... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ESD - version >= $min_esd_version" >&5 +$as_echo_n "checking for ESD - version >= $min_esd_version... " >&6; } no_esd="" if test "$ESD_CONFIG" = "no" ; then no_esd=yes @@ -21777,10 +19796,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu CFLAGS="$CFLAGS $ESD_CFLAGS" LIBS="$LIBS $ESD_LIBS" rm -f conf.esdtest - if test "$cross_compiling" = yes -then : + if test "$cross_compiling" = yes; then : echo $ac_n "cross compiling; assumed OK... $ac_c" -else $as_nop +else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -21819,10 +19837,9 @@ int main (void) } _ACEOF -if ac_fn_c_try_run "$LINENO" -then : +if ac_fn_c_try_run "$LINENO"; then : -else $as_nop +else no_esd=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ @@ -21840,12 +19857,12 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu fi fi if test "x$no_esd" = x ; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } have_esd=yes else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if test "$ESD_CONFIG" = "no" ; then : else @@ -21868,15 +19885,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu #include int -main (void) +main () { return 0; ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding ESD or finding the wrong" echo "*** version of ESD. If it is not finding ESD, you'll need to set your" @@ -21886,13 +19902,13 @@ then : echo "***" echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" -else $as_nop +else echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means ESD was incorrectly installed" echo "*** or that you have moved ESD since it was installed. In the latter case, you" echo "*** may want to edit the esd-config script: $ESD_CONFIG" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" @@ -21915,30 +19931,31 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu fi if test x$have_esd = xyes; then # Check whether --enable-esd-shared was given. -if test ${enable_esd_shared+y} -then : +if test "${enable_esd_shared+set}" = set; then : enableval=$enable_esd_shared; -else $as_nop +else enable_esd_shared=yes fi esd_lib=`find_lib "libesd.so.*" "$ESD_LIBS" | sed 's/.*\/\(.*\)/\1/; q'` -printf "%s\n" "#define SDL_AUDIO_DRIVER_ESD 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_ESD 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/esd/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $ESD_CFLAGS" if test x$have_loadso != xyes && \ test x$enable_esd_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic ESD loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic ESD loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic ESD loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic ESD loading" >&2;} fi if test x$have_loadso = xyes && \ test x$enable_esd_shared = xyes && test x$esd_lib != x; then echo "-- dynamic libesd -> $esd_lib" -printf "%s\n" "#define SDL_AUDIO_DRIVER_ESD_DYNAMIC \"$esd_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_AUDIO_DRIVER_ESD_DYNAMIC "$esd_lib" +_ACEOF SUMMARY_audio="${SUMMARY_audio} esd(dynamic)" else @@ -21953,27 +19970,26 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_ESD_DYNAMIC \"$esd_lib\"" >>confdefs.h CheckPipewire() { # Check whether --enable-pipewire was given. -if test ${enable_pipewire+y} -then : +if test "${enable_pipewire+set}" = set; then : enableval=$enable_pipewire; -else $as_nop +else enable_pipewire=yes fi if test x$enable_audio = xyes -a x$enable_pipewire = xyes; then pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libpipewire-0.3 >= 0.3.20" >&5 -printf %s "checking for libpipewire-0.3 >= 0.3.20... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libpipewire-0.3 >= 0.3.20" >&5 +$as_echo_n "checking for libpipewire-0.3 >= 0.3.20... " >&6; } if test -n "$PIPEWIRE_CFLAGS"; then pkg_cv_PIPEWIRE_CFLAGS="$PIPEWIRE_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpipewire-0.3 >= 0.3.20\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpipewire-0.3 >= 0.3.20\""; } >&5 ($PKG_CONFIG --exists --print-errors "libpipewire-0.3 >= 0.3.20") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_PIPEWIRE_CFLAGS=`$PKG_CONFIG --cflags "libpipewire-0.3 >= 0.3.20" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -21987,10 +20003,10 @@ if test -n "$PIPEWIRE_LIBS"; then pkg_cv_PIPEWIRE_LIBS="$PIPEWIRE_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpipewire-0.3 >= 0.3.20\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpipewire-0.3 >= 0.3.20\""; } >&5 ($PKG_CONFIG --exists --print-errors "libpipewire-0.3 >= 0.3.20") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_PIPEWIRE_LIBS=`$PKG_CONFIG --libs "libpipewire-0.3 >= 0.3.20" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -22004,8 +20020,8 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -22022,43 +20038,44 @@ fi audio_pipewire=no elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } audio_pipewire=no else PIPEWIRE_CFLAGS=$pkg_cv_PIPEWIRE_CFLAGS PIPEWIRE_LIBS=$pkg_cv_PIPEWIRE_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } audio_pipewire=yes fi if test x$audio_pipewire = xyes; then # Check whether --enable-pipewire-shared was given. -if test ${enable_pipewire_shared+y} -then : +if test "${enable_pipewire_shared+set}" = set; then : enableval=$enable_pipewire_shared; -else $as_nop +else enable_pipewire_shared=yes fi pipewire_lib=`find_lib "libpipewire-0.3.so.*" "$PIPEWIRE_LIBS" | sed 's/.*\/\(.*\)/\1/; q'` -printf "%s\n" "#define SDL_AUDIO_DRIVER_PIPEWIRE 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_PIPEWIRE 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/pipewire/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $PIPEWIRE_CFLAGS" if test x$have_loadso != xyes && \ test x$enable_pipewire_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic Pipewire loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic Pipewire loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic Pipewire loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic Pipewire loading" >&2;} fi if test x$have_loadso = xyes && \ test x$enable_pipewire_shared = xyes && test x$pipewire_lib != x; then echo "-- dynamic libpipewire-0.3 -> $pipewire_lib" -printf "%s\n" "#define SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC \"$pipewire_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "$pipewire_lib" +_ACEOF SUMMARY_audio="${SUMMARY_audio} pipewire(dynamic)" else @@ -22073,27 +20090,26 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC \"$pipewire_lib\"" >>co CheckPulseAudio() { # Check whether --enable-pulseaudio was given. -if test ${enable_pulseaudio+y} -then : +if test "${enable_pulseaudio+set}" = set; then : enableval=$enable_pulseaudio; -else $as_nop +else enable_pulseaudio=yes fi if test x$enable_audio = xyes -a x$enable_pulseaudio = xyes; then pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libpulse-simple >= 0.9" >&5 -printf %s "checking for libpulse-simple >= 0.9... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libpulse-simple >= 0.9" >&5 +$as_echo_n "checking for libpulse-simple >= 0.9... " >&6; } if test -n "$PULSEAUDIO_CFLAGS"; then pkg_cv_PULSEAUDIO_CFLAGS="$PULSEAUDIO_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpulse-simple >= 0.9\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpulse-simple >= 0.9\""; } >&5 ($PKG_CONFIG --exists --print-errors "libpulse-simple >= 0.9") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_PULSEAUDIO_CFLAGS=`$PKG_CONFIG --cflags "libpulse-simple >= 0.9" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -22107,10 +20123,10 @@ if test -n "$PULSEAUDIO_LIBS"; then pkg_cv_PULSEAUDIO_LIBS="$PULSEAUDIO_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpulse-simple >= 0.9\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpulse-simple >= 0.9\""; } >&5 ($PKG_CONFIG --exists --print-errors "libpulse-simple >= 0.9") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_PULSEAUDIO_LIBS=`$PKG_CONFIG --libs "libpulse-simple >= 0.9" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -22124,8 +20140,8 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -22142,43 +20158,44 @@ fi audio_pulseaudio=no elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } audio_pulseaudio=no else PULSEAUDIO_CFLAGS=$pkg_cv_PULSEAUDIO_CFLAGS PULSEAUDIO_LIBS=$pkg_cv_PULSEAUDIO_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } audio_pulseaudio=yes fi if test x$audio_pulseaudio = xyes; then # Check whether --enable-pulseaudio-shared was given. -if test ${enable_pulseaudio_shared+y} -then : +if test "${enable_pulseaudio_shared+set}" = set; then : enableval=$enable_pulseaudio_shared; -else $as_nop +else enable_pulseaudio_shared=yes fi pulseaudio_lib=`find_lib "libpulse-simple.so.*" "$PULSEAUDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'` -printf "%s\n" "#define SDL_AUDIO_DRIVER_PULSEAUDIO 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_PULSEAUDIO 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/pulseaudio/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $PULSEAUDIO_CFLAGS" if test x$have_loadso != xyes && \ test x$enable_pulseaudio_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic PulseAudio loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic PulseAudio loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic PulseAudio loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic PulseAudio loading" >&2;} fi if test x$have_loadso = xyes && \ test x$enable_pulseaudio_shared = xyes && test x$pulseaudio_lib != x; then echo "-- dynamic libpulse-simple -> $pulseaudio_lib" -printf "%s\n" "#define SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC \"$pulseaudio_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "$pulseaudio_lib" +_ACEOF SUMMARY_audio="${SUMMARY_audio} pulse(dynamic)" @@ -22201,22 +20218,20 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC \"$pulseaudio_lib\"" CheckARTSC() { # Check whether --enable-arts was given. -if test ${enable_arts+y} -then : +if test "${enable_arts+set}" = set; then : enableval=$enable_arts; -else $as_nop +else enable_arts=yes fi if test x$enable_audio = xyes -a x$enable_arts = xyes; then # Extract the first word of "artsc-config", so it can be a program name with args. set dummy artsc-config; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_path_ARTSCONFIG+y} -then : - printf %s "(cached) " >&6 -else $as_nop +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ARTSCONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else case $ARTSCONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ARTSCONFIG="$ARTSCONFIG" # Let the user override the test with a path. @@ -22226,15 +20241,11 @@ else $as_nop for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac + test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_path_ARTSCONFIG="$as_dir$ac_word$ac_exec_ext" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ARTSCONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -22246,11 +20257,11 @@ esac fi ARTSCONFIG=$ac_cv_path_ARTSCONFIG if test -n "$ARTSCONFIG"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ARTSCONFIG" >&5 -printf "%s\n" "$ARTSCONFIG" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ARTSCONFIG" >&5 +$as_echo "$ARTSCONFIG" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi @@ -22259,8 +20270,8 @@ fi else ARTS_CFLAGS=`$ARTSCONFIG --cflags` ARTS_LIBS=`$ARTSCONFIG --libs` - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for aRts development environment" >&5 -printf %s "checking for aRts development environment... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for aRts development environment" >&5 +$as_echo_n "checking for aRts development environment... " >&6; } audio_arts=no save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $ARTS_CFLAGS" @@ -22270,7 +20281,7 @@ printf %s "checking for aRts development environment... " >&6; } #include int -main (void) +main () { arts_stream_t stream; @@ -22279,40 +20290,40 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : audio_arts=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $audio_arts" >&5 -printf "%s\n" "$audio_arts" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $audio_arts" >&5 +$as_echo "$audio_arts" >&6; } if test x$audio_arts = xyes; then # Check whether --enable-arts-shared was given. -if test ${enable_arts_shared+y} -then : +if test "${enable_arts_shared+set}" = set; then : enableval=$enable_arts_shared; -else $as_nop +else enable_arts_shared=yes fi arts_lib=`find_lib "libartsc.so.*" "$ARTS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'` -printf "%s\n" "#define SDL_AUDIO_DRIVER_ARTS 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_ARTS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/arts/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $ARTS_CFLAGS" if test x$have_loadso != xyes && \ test x$enable_arts_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic ARTS loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic ARTS loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic ARTS loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic ARTS loading" >&2;} fi if test x$have_loadso = xyes && \ test x$enable_arts_shared = xyes && test x$arts_lib != x; then echo "-- dynamic libartsc -> $arts_lib" -printf "%s\n" "#define SDL_AUDIO_DRIVER_ARTS_DYNAMIC \"$arts_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_AUDIO_DRIVER_ARTS_DYNAMIC "$arts_lib" +_ACEOF SUMMARY_audio="${SUMMARY_audio} arts(dynamic)" else @@ -22328,26 +20339,24 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_ARTS_DYNAMIC \"$arts_lib\"" >>confdefs.h CheckNAS() { # Check whether --enable-nas was given. -if test ${enable_nas+y} -then : +if test "${enable_nas+set}" = set; then : enableval=$enable_nas; -else $as_nop +else enable_nas=yes fi if test x$enable_audio = xyes -a x$enable_nas = xyes; then - ac_fn_c_check_header_compile "$LINENO" "audio/audiolib.h" "ac_cv_header_audio_audiolib_h" "$ac_includes_default" -if test "x$ac_cv_header_audio_audiolib_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "audio/audiolib.h" "ac_cv_header_audio_audiolib_h" "$ac_includes_default" +if test "x$ac_cv_header_audio_audiolib_h" = xyes; then : have_nas_hdr=yes fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for AuOpenServer in -laudio" >&5 -printf %s "checking for AuOpenServer in -laudio... " >&6; } -if test ${ac_cv_lib_audio_AuOpenServer+y} -then : - printf %s "(cached) " >&6 -else $as_nop + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for AuOpenServer in -laudio" >&5 +$as_echo_n "checking for AuOpenServer in -laudio... " >&6; } +if ${ac_cv_lib_audio_AuOpenServer+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-laudio $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -22356,35 +20365,36 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char AuOpenServer (); int -main (void) +main () { return AuOpenServer (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_audio_AuOpenServer=yes -else $as_nop +else ac_cv_lib_audio_AuOpenServer=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_audio_AuOpenServer" >&5 -printf "%s\n" "$ac_cv_lib_audio_AuOpenServer" >&6; } -if test "x$ac_cv_lib_audio_AuOpenServer" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_audio_AuOpenServer" >&5 +$as_echo "$ac_cv_lib_audio_AuOpenServer" >&6; } +if test "x$ac_cv_lib_audio_AuOpenServer" = xyes; then : have_nas_lib=yes fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for NAS audio support" >&5 -printf %s "checking for NAS audio support... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NAS audio support" >&5 +$as_echo_n "checking for NAS audio support... " >&6; } have_nas=no if test x$have_nas_hdr = xyes -a x$have_nas_lib = xyes; then @@ -22398,15 +20408,14 @@ printf %s "checking for NAS audio support... " >&6; } fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_nas" >&5 -printf "%s\n" "$have_nas" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_nas" >&5 +$as_echo "$have_nas" >&6; } if test x$have_nas = xyes; then # Check whether --enable-nas-shared was given. -if test ${enable_nas_shared+y} -then : +if test "${enable_nas_shared+set}" = set; then : enableval=$enable_nas_shared; -else $as_nop +else enable_nas_shared=yes fi @@ -22414,14 +20423,16 @@ fi if test x$have_loadso != xyes && \ test x$enable_nas_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic NAS loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic NAS loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic NAS loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic NAS loading" >&2;} fi if test x$have_loadso = xyes && \ test x$enable_nas_shared = xyes && test x$nas_lib != x; then echo "-- dynamic libaudio -> $nas_lib" -printf "%s\n" "#define SDL_AUDIO_DRIVER_NAS_DYNAMIC \"$nas_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_AUDIO_DRIVER_NAS_DYNAMIC "$nas_lib" +_ACEOF SUMMARY_audio="${SUMMARY_audio} nas(dynamic)" else @@ -22430,7 +20441,7 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_NAS_DYNAMIC \"$nas_lib\"" >>confdefs.h fi -printf "%s\n" "#define SDL_AUDIO_DRIVER_NAS 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_NAS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/nas/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $NAS_CFLAGS" @@ -22442,27 +20453,26 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_NAS 1" >>confdefs.h CheckSNDIO() { # Check whether --enable-sndio was given. -if test ${enable_sndio+y} -then : +if test "${enable_sndio+set}" = set; then : enableval=$enable_sndio; -else $as_nop +else enable_sndio=yes fi if test x$enable_audio = xyes -a x$enable_sndio = xyes; then pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sndio" >&5 -printf %s "checking for sndio... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sndio" >&5 +$as_echo_n "checking for sndio... " >&6; } if test -n "$SNDIO_CFLAGS"; then pkg_cv_SNDIO_CFLAGS="$SNDIO_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sndio\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sndio\""; } >&5 ($PKG_CONFIG --exists --print-errors "sndio") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_SNDIO_CFLAGS=`$PKG_CONFIG --cflags "sndio" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -22476,10 +20486,10 @@ if test -n "$SNDIO_LIBS"; then pkg_cv_SNDIO_LIBS="$SNDIO_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sndio\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sndio\""; } >&5 ($PKG_CONFIG --exists --print-errors "sndio") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_SNDIO_LIBS=`$PKG_CONFIG --libs "sndio" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -22493,8 +20503,8 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -22511,23 +20521,22 @@ fi audio_sndio=no elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } audio_sndio=no else SNDIO_CFLAGS=$pkg_cv_SNDIO_CFLAGS SNDIO_LIBS=$pkg_cv_SNDIO_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } audio_sndio=yes fi if test x$audio_sndio = xyes; then # Check whether --enable-sndio-shared was given. -if test ${enable_sndio_shared+y} -then : +if test "${enable_sndio_shared+set}" = set; then : enableval=$enable_sndio_shared; -else $as_nop +else enable_sndio_shared=yes fi @@ -22535,14 +20544,16 @@ fi if test x$have_loadso != xyes && \ test x$enable_sndio_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic sndio loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic sndio loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic sndio loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic sndio loading" >&2;} fi if test x$have_loadso = xyes && \ test x$enable_sndio_shared = xyes && test x$sndio_lib != x; then echo "-- dynamic libsndio -> $sndio_lib" -printf "%s\n" "#define SDL_AUDIO_DRIVER_SNDIO_DYNAMIC \"$sndio_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "$sndio_lib" +_ACEOF SUMMARY_audio="${SUMMARY_audio} sndio(dynamic)" else @@ -22551,7 +20562,7 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_SNDIO_DYNAMIC \"$sndio_lib\"" >>confdefs fi -printf "%s\n" "#define SDL_AUDIO_DRIVER_SNDIO 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_SNDIO 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/sndio/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $SNDIO_CFLAGS" @@ -22563,27 +20574,26 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_SNDIO 1" >>confdefs.h CheckFusionSound() { # Check whether --enable-fusionsound was given. -if test ${enable_fusionsound+y} -then : +if test "${enable_fusionsound+set}" = set; then : enableval=$enable_fusionsound; -else $as_nop +else enable_fusionsound=no fi if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fusionsound >= 1.1.1" >&5 -printf %s "checking for fusionsound >= 1.1.1... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fusionsound >= 1.1.1" >&5 +$as_echo_n "checking for fusionsound >= 1.1.1... " >&6; } if test -n "$FUSIONSOUND_CFLAGS"; then pkg_cv_FUSIONSOUND_CFLAGS="$FUSIONSOUND_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"fusionsound >= 1.1.1\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"fusionsound >= 1.1.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "fusionsound >= 1.1.1") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags "fusionsound >= 1.1.1" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -22597,10 +20607,10 @@ if test -n "$FUSIONSOUND_LIBS"; then pkg_cv_FUSIONSOUND_LIBS="$FUSIONSOUND_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"fusionsound >= 1.1.1\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"fusionsound >= 1.1.1\""; } >&5 ($PKG_CONFIG --exists --print-errors "fusionsound >= 1.1.1") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_FUSIONSOUND_LIBS=`$PKG_CONFIG --libs "fusionsound >= 1.1.1" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -22614,8 +20624,8 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -22632,44 +20642,45 @@ fi fusionsound=no elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fusionsound=no else FUSIONSOUND_CFLAGS=$pkg_cv_FUSIONSOUND_CFLAGS FUSIONSOUND_LIBS=$pkg_cv_FUSIONSOUND_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } fusionsound=yes fi if test x$fusionsound = xyes; then -printf "%s\n" "#define SDL_AUDIO_DRIVER_FUSIONSOUND 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_FUSIONSOUND 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS" # Check whether --enable-fusionsound-shared was given. -if test ${enable_fusionsound_shared+y} -then : +if test "${enable_fusionsound_shared+set}" = set; then : enableval=$enable_fusionsound_shared; -else $as_nop +else enable_fusionsound_shared=yes fi fusionsound_shared=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for FusionSound dynamic loading support" >&5 -printf %s "checking for FusionSound dynamic loading support... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FusionSound dynamic loading support" >&5 +$as_echo_n "checking for FusionSound dynamic loading support... " >&6; } if test x$have_loadso != xyes && \ test x$enable_fusionsound_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic fusionsound loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic fusionsound loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic fusionsound loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic fusionsound loading" >&2;} fi if test x$have_loadso = xyes && \ test x$enable_fusionsound_shared = xyes; then -printf "%s\n" "#define SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC \"libfusionsound.so\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "libfusionsound.so" +_ACEOF fusionsound_shared=yes SUMMARY_audio="${SUMMARY_audio} fusionsound(dynamic)" @@ -22677,8 +20688,8 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC \"libfusionsound.so\ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS" SUMMARY_audio="${SUMMARY_audio} fusionsound" fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $fusionsound_shared" >&5 -printf "%s\n" "$fusionsound_shared" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fusionsound_shared" >&5 +$as_echo "$fusionsound_shared" >&6; } have_audio=yes fi @@ -22688,16 +20699,15 @@ printf "%s\n" "$fusionsound_shared" >&6; } CheckDiskAudio() { # Check whether --enable-diskaudio was given. -if test ${enable_diskaudio+y} -then : +if test "${enable_diskaudio+set}" = set; then : enableval=$enable_diskaudio; -else $as_nop +else enable_diskaudio=yes fi if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then -printf "%s\n" "#define SDL_AUDIO_DRIVER_DISK 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_DISK 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/disk/*.c" SUMMARY_audio="${SUMMARY_audio} disk" @@ -22708,16 +20718,15 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_DISK 1" >>confdefs.h CheckDummyAudio() { # Check whether --enable-dummyaudio was given. -if test ${enable_dummyaudio+y} -then : +if test "${enable_dummyaudio+set}" = set; then : enableval=$enable_dummyaudio; -else $as_nop +else enable_dummyaudio=yes fi if test x$enable_audio = xyes -a x$enable_dummyaudio = xyes; then -printf "%s\n" "#define SDL_AUDIO_DRIVER_DUMMY 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_DUMMY 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/dummy/*.c" SUMMARY_audio="${SUMMARY_audio} dummy" @@ -22728,32 +20737,30 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_DUMMY 1" >>confdefs.h CheckLibSampleRate() { # Check whether --enable-libsamplerate was given. -if test ${enable_libsamplerate+y} -then : +if test "${enable_libsamplerate+set}" = set; then : enableval=$enable_libsamplerate; -else $as_nop +else enable_libsamplerate=yes fi if test x$enable_libsamplerate = xyes; then - ac_fn_c_check_header_compile "$LINENO" "samplerate.h" "ac_cv_header_samplerate_h" "$ac_includes_default" -if test "x$ac_cv_header_samplerate_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "samplerate.h" "ac_cv_header_samplerate_h" "$ac_includes_default" +if test "x$ac_cv_header_samplerate_h" = xyes; then : have_samplerate_h_hdr=yes -else $as_nop +else have_samplerate_h_hdr=no fi + if test x$have_samplerate_h_hdr = xyes; then -printf "%s\n" "#define HAVE_LIBSAMPLERATE_H 1" >>confdefs.h +$as_echo "#define HAVE_LIBSAMPLERATE_H 1" >>confdefs.h # Check whether --enable-libsamplerate-shared was given. -if test ${enable_libsamplerate_shared+y} -then : +if test "${enable_libsamplerate_shared+set}" = set; then : enableval=$enable_libsamplerate_shared; -else $as_nop +else enable_libsamplerate_shared=yes fi @@ -22762,14 +20769,16 @@ fi if test x$have_loadso != xyes && \ test x$enable_libsamplerate_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic libsamplerate loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic libsamplerate loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic libsamplerate loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic libsamplerate loading" >&2;} fi if test x$have_loadso = xyes && \ test x$enable_libsamplerate_shared = xyes && test x$samplerate_lib != x; then echo "-- dynamic libsamplerate -> $samplerate_lib" -printf "%s\n" "#define SDL_LIBSAMPLERATE_DYNAMIC \"$samplerate_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_LIBSAMPLERATE_DYNAMIC "$samplerate_lib" +_ACEOF else EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lsamplerate" @@ -22781,10 +20790,9 @@ printf "%s\n" "#define SDL_LIBSAMPLERATE_DYNAMIC \"$samplerate_lib\"" >>confdefs CheckARM() { # Check whether --enable-arm-simd was given. -if test ${enable_arm_simd+y} -then : +if test "${enable_arm_simd+set}" = set; then : enableval=$enable_arm_simd; enable_arm_simd=$enableval -else $as_nop +else enable_arm_simd=no fi @@ -22793,8 +20801,8 @@ fi have_arm_simd=no CFLAGS="-x assembler-with-cpp $CFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ARM SIMD" >&5 -printf %s "checking for ARM SIMD... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ARM SIMD" >&5 +$as_echo_n "checking for ARM SIMD... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -22810,19 +20818,18 @@ printf %s "checking for ARM SIMD... " >&6; } uqadd8 r0, r0, r0 _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_arm_simd=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_arm_simd" >&5 -printf "%s\n" "$have_arm_simd" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_arm_simd" >&5 +$as_echo "$have_arm_simd" >&6; } CFLAGS="$save_CFLAGS" if test x$have_arm_simd = xyes; then -printf "%s\n" "#define SDL_ARM_SIMD_BLITTERS 1" >>confdefs.h +$as_echo "#define SDL_ARM_SIMD_BLITTERS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/arm/pixman-arm-simd*.S" WARN_ABOUT_ARM_SIMD_ASM_MIT="yes" @@ -22833,10 +20840,9 @@ printf "%s\n" "#define SDL_ARM_SIMD_BLITTERS 1" >>confdefs.h CheckNEON() { # Check whether --enable-arm-neon was given. -if test ${enable_arm_neon+y} -then : +if test "${enable_arm_neon+set}" = set; then : enableval=$enable_arm_neon; enable_arm_neon=$enableval -else $as_nop +else enable_arm_neon=no fi @@ -22845,8 +20851,8 @@ fi have_arm_neon=no CFLAGS="-x assembler-with-cpp $CFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ARM NEON" >&5 -printf %s "checking for ARM NEON... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ARM NEON" >&5 +$as_echo_n "checking for ARM NEON... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -22864,18 +20870,17 @@ printf %s "checking for ARM NEON... " >&6; } vmovn.u16 d0, q0 _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_arm_neon=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_arm_neon" >&5 -printf "%s\n" "$have_arm_neon" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_arm_neon" >&5 +$as_echo "$have_arm_neon" >&6; } CFLAGS="$save_CFLAGS" if test x$have_arm_neon = xyes; then -printf "%s\n" "#define SDL_ARM_NEON_BLITTERS 1" >>confdefs.h +$as_echo "#define SDL_ARM_NEON_BLITTERS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/arm/pixman-arm-neon*.S" WARN_ABOUT_ARM_NEON_ASM_MIT="yes" @@ -22885,8 +20890,8 @@ printf "%s\n" "#define SDL_ARM_NEON_BLITTERS 1" >>confdefs.h CheckObjectiveCARC() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clang -fobjc-arc option" >&5 -printf %s "checking for clang -fobjc-arc option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clang -fobjc-arc option" >&5 +$as_echo_n "checking for clang -fobjc-arc option... " >&6; } have_clang_objc_arc=no save_CFLAGS="$CFLAGS" @@ -22897,20 +20902,19 @@ printf %s "checking for clang -fobjc-arc option... " >&6; } int x = 0; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_clang_objc_arc=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_clang_objc_arc" >&5 -printf "%s\n" "$have_clang_objc_arc" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_clang_objc_arc" >&5 +$as_echo "$have_clang_objc_arc" >&6; } CFLAGS="$save_CFLAGS" if test x$have_clang_objc_arc = xyes; then @@ -22920,8 +20924,8 @@ printf "%s\n" "$have_clang_objc_arc" >&6; } CheckGDwarf4() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -gdwarf-4 option" >&5 -printf %s "checking for GCC -gdwarf-4 option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -gdwarf-4 option" >&5 +$as_echo_n "checking for GCC -gdwarf-4 option... " >&6; } have_gcc_gdwarf4=no save_CFLAGS="$CFLAGS" @@ -22932,20 +20936,19 @@ printf %s "checking for GCC -gdwarf-4 option... " >&6; } int x = 0; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_gdwarf4=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_gdwarf4" >&5 -printf "%s\n" "$have_gcc_gdwarf4" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_gdwarf4" >&5 +$as_echo "$have_gcc_gdwarf4" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_gdwarf4 = xyes; then @@ -22955,8 +20958,8 @@ printf "%s\n" "$have_gcc_gdwarf4" >&6; } CheckVisibilityHidden() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -fvisibility=hidden option" >&5 -printf %s "checking for GCC -fvisibility=hidden option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -fvisibility=hidden option" >&5 +$as_echo_n "checking for GCC -fvisibility=hidden option... " >&6; } have_gcc_fvisibility=no visibility_CFLAGS="-fvisibility=hidden" @@ -22970,20 +20973,19 @@ printf %s "checking for GCC -fvisibility=hidden option... " >&6; } #endif int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_fvisibility=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_fvisibility" >&5 -printf "%s\n" "$have_gcc_fvisibility" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_fvisibility" >&5 +$as_echo "$have_gcc_fvisibility" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_fvisibility = xyes; then @@ -22993,8 +20995,8 @@ printf "%s\n" "$have_gcc_fvisibility" >&6; } CheckNoStrictAliasing() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -fno-strict-aliasing option" >&5 -printf %s "checking for GCC -fno-strict-aliasing option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -fno-strict-aliasing option" >&5 +$as_echo_n "checking for GCC -fno-strict-aliasing option... " >&6; } have_gcc_no_strict_aliasing=no save_CFLAGS="$CFLAGS" @@ -23005,20 +21007,19 @@ printf %s "checking for GCC -fno-strict-aliasing option... " >&6; } int x = 0; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_no_strict_aliasing=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_no_strict_aliasing" >&5 -printf "%s\n" "$have_gcc_no_strict_aliasing" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_no_strict_aliasing" >&5 +$as_echo "$have_gcc_no_strict_aliasing" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_no_strict_aliasing = xyes; then @@ -23029,16 +21030,15 @@ printf "%s\n" "$have_gcc_no_strict_aliasing" >&6; } CheckWerror() { # Check whether --enable-werror was given. -if test ${enable_werror+y} -then : +if test "${enable_werror+set}" = set; then : enableval=$enable_werror; enable_werror=$enableval -else $as_nop +else enable_werror=no fi if test x$enable_werror = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Werror option" >&5 -printf %s "checking for GCC -Werror option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -Werror option" >&5 +$as_echo_n "checking for GCC -Werror option... " >&6; } have_gcc_werror=no save_CFLAGS="$CFLAGS" @@ -23049,20 +21049,19 @@ printf %s "checking for GCC -Werror option... " >&6; } int x = 0; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_werror=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_werror" >&5 -printf "%s\n" "$have_gcc_werror" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_werror" >&5 +$as_echo "$have_gcc_werror" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_werror = xyes; then @@ -23073,8 +21072,8 @@ printf "%s\n" "$have_gcc_werror" >&6; } CheckNoErrorDeprecatedDeclarationsWerror() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Wno-error=deprecated-declarations option" >&5 -printf %s "checking for GCC -Wno-error=deprecated-declarations option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -Wno-error=deprecated-declarations option" >&5 +$as_echo_n "checking for GCC -Wno-error=deprecated-declarations option... " >&6; } have_gcc_no_werror_deprecated_declarations=no save_CFLAGS="$CFLAGS" @@ -23085,20 +21084,19 @@ printf %s "checking for GCC -Wno-error=deprecated-declarations option... " >&6; int x = 0; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_no_werror_deprecated_declarations=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_werror" >&5 -printf "%s\n" "$have_gcc_werror" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_werror" >&5 +$as_echo "$have_gcc_werror" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_no_werror_deprecated_declarations = xyes; then @@ -23108,8 +21106,8 @@ printf "%s\n" "$have_gcc_werror" >&6; } CheckDeclarationAfterStatement() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Wdeclaration-after-statement option" >&5 -printf %s "checking for GCC -Wdeclaration-after-statement option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -Wdeclaration-after-statement option" >&5 +$as_echo_n "checking for GCC -Wdeclaration-after-statement option... " >&6; } have_gcc_declaration_after_statement=no save_CFLAGS="$CFLAGS" @@ -23120,20 +21118,19 @@ printf %s "checking for GCC -Wdeclaration-after-statement option... " >&6; } int x = 0; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_declaration_after_statement=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_declaration_after_statement" >&5 -printf "%s\n" "$have_gcc_declaration_after_statement" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_declaration_after_statement" >&5 +$as_echo "$have_gcc_declaration_after_statement" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_declaration_after_statement = xyes; then @@ -23143,8 +21140,8 @@ printf "%s\n" "$have_gcc_declaration_after_statement" >&6; } CheckWarnAll() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Wall option" >&5 -printf %s "checking for GCC -Wall option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -Wall option" >&5 +$as_echo_n "checking for GCC -Wall option... " >&6; } have_gcc_Wall=no save_CFLAGS="$CFLAGS" @@ -23155,35 +21152,34 @@ printf %s "checking for GCC -Wall option... " >&6; } int x = 0; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_Wall=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_Wall" >&5 -printf "%s\n" "$have_gcc_Wall" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_Wall" >&5 +$as_echo "$have_gcc_Wall" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_Wall = xyes; then EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for necessary GCC -Wno-multichar option" >&5 -printf %s "checking for necessary GCC -Wno-multichar option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for necessary GCC -Wno-multichar option" >&5 +$as_echo_n "checking for necessary GCC -Wno-multichar option... " >&6; } need_gcc_Wno_multichar=no case "$host" in *-*-haiku*) need_gcc_Wno_multichar=yes ;; esac - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $need_gcc_Wno_multichar" >&5 -printf "%s\n" "$need_gcc_Wno_multichar" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $need_gcc_Wno_multichar" >&5 +$as_echo "$need_gcc_Wno_multichar" >&6; } if test x$need_gcc_Wno_multichar = xyes; then EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-multichar" fi @@ -23192,8 +21188,8 @@ printf "%s\n" "$need_gcc_Wno_multichar" >&6; } CheckUnusedLocalTypedefs() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Wunused-local-typedefs option" >&5 -printf %s "checking for GCC -Wunused-local-typedefs option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -Wunused-local-typedefs option" >&5 +$as_echo_n "checking for GCC -Wunused-local-typedefs option... " >&6; } have_gcc_unused_local_typedefs=no save_CFLAGS="$CFLAGS" @@ -23204,20 +21200,19 @@ printf %s "checking for GCC -Wunused-local-typedefs option... " >&6; } int x = 0; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_gcc_unused_local_typedefs=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_unused_local_typedefs" >&5 -printf "%s\n" "$have_gcc_unused_local_typedefs" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_unused_local_typedefs" >&5 +$as_echo "$have_gcc_unused_local_typedefs" >&6; } CFLAGS="$save_CFLAGS" if test x$have_gcc_unused_local_typedefs = xyes; then @@ -23228,26 +21223,24 @@ printf "%s\n" "$have_gcc_unused_local_typedefs" >&6; } CheckWayland() { # Check whether --enable-video-wayland was given. -if test ${enable_video_wayland+y} -then : +if test "${enable_video_wayland+set}" = set; then : enableval=$enable_video_wayland; -else $as_nop +else enable_video_wayland=yes fi # Check whether --enable-video-wayland-qt-touch was given. -if test ${enable_video_wayland_qt_touch+y} -then : +if test "${enable_video_wayland_qt_touch+set}" = set; then : enableval=$enable_video_wayland_qt_touch; -else $as_nop +else enable_video_wayland_qt_touch=yes fi if test x$enable_video = xyes -a x$enable_video_wayland = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Wayland support" >&5 -printf %s "checking for Wayland support... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Wayland support" >&5 +$as_echo_n "checking for Wayland support... " >&6; } video_wayland=no if test x$video_opengl_egl = xyes && \ test x$video_opengles_v2 = xyes; then @@ -23255,25 +21248,24 @@ printf %s "checking for Wayland support... " >&6; } WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon` WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon` WAYLAND_SCANNER=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner` - if $PKG_CONFIG --exists 'wayland-scanner >= 1.15' -then : + if $PKG_CONFIG --exists 'wayland-scanner >= 1.15'; then : WAYLAND_SCANNER_CODE_MODE=private-code -else $as_nop +else WAYLAND_SCANNER_CODE_MODE=code fi video_wayland=yes fi fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $video_wayland" >&5 -printf "%s\n" "$video_wayland" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_wayland" >&5 +$as_echo "$video_wayland" >&6; } if test x$video_wayland = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_WAYLAND 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_WAYLAND 1" >>confdefs.h if test x$enable_video_wayland_qt_touch = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1" >>confdefs.h fi @@ -23281,10 +21273,9 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH 1" >>confdefs.h SOURCES="$SOURCES $WAYLAND_SOURCES" EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS -I\$(gen)" # Check whether --enable-wayland-shared was given. -if test ${enable_wayland_shared+y} -then : +if test "${enable_wayland_shared+set}" = set; then : enableval=$enable_wayland_shared; -else $as_nop +else enable_wayland_shared=maybe fi @@ -23307,8 +21298,8 @@ fi fi if test x$have_loadso != xyes && \ test x$enable_wayland_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic Wayland loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic Wayland loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic Wayland loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic Wayland loading" >&2;} enable_wayland_shared=no fi if test x$have_loadso = xyes && \ @@ -23322,16 +21313,24 @@ printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynam echo "-- dynamic libwayland-cursor -> $wayland_cursor_lib" echo "-- dynamic libxkbcommon -> $xkbcommon_lib" -printf "%s\n" "#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC \"$wayland_client_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC "$wayland_client_lib" +_ACEOF -printf "%s\n" "#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL \"$wayland_egl_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL "$wayland_egl_lib" +_ACEOF -printf "%s\n" "#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR \"$wayland_cursor_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR "$wayland_cursor_lib" +_ACEOF -printf "%s\n" "#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON \"$xkbcommon_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON "$xkbcommon_lib" +_ACEOF SUMMARY_video="${SUMMARY_video} wayland(dynamic)" else @@ -23342,27 +21341,26 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON \"$xkbcommon_l have_video=yes # Check whether --enable-libdecor was given. -if test ${enable_libdecor+y} -then : +if test "${enable_libdecor+set}" = set; then : enableval=$enable_libdecor; -else $as_nop +else enable_libdecor=yes fi if test x$enable_libdecor = xyes; then pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libdecor-0" >&5 -printf %s "checking for libdecor-0... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libdecor-0" >&5 +$as_echo_n "checking for libdecor-0... " >&6; } if test -n "$DECOR_CFLAGS"; then pkg_cv_DECOR_CFLAGS="$DECOR_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdecor-0\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdecor-0\""; } >&5 ($PKG_CONFIG --exists --print-errors "libdecor-0") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_DECOR_CFLAGS=`$PKG_CONFIG --cflags "libdecor-0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -23376,10 +21374,10 @@ if test -n "$DECOR_LIBS"; then pkg_cv_DECOR_LIBS="$DECOR_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdecor-0\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdecor-0\""; } >&5 ($PKG_CONFIG --exists --print-errors "libdecor-0") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_DECOR_LIBS=`$PKG_CONFIG --libs "libdecor-0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -23393,8 +21391,8 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -23411,27 +21409,26 @@ fi video_libdecor=no elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } video_libdecor=no else DECOR_CFLAGS=$pkg_cv_DECOR_CFLAGS DECOR_LIBS=$pkg_cv_DECOR_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } video_libdecor=yes fi if test x$video_libdecor = xyes; then EXTRA_CFLAGS="$EXTRA_CFLAGS $DECOR_CFLAGS" -printf "%s\n" "#define HAVE_LIBDECOR_H 1" >>confdefs.h +$as_echo "#define HAVE_LIBDECOR_H 1" >>confdefs.h # Check whether --enable-libdecor-shared was given. -if test ${enable_libdecor_shared+y} -then : +if test "${enable_libdecor_shared+set}" = set; then : enableval=$enable_libdecor_shared; -else $as_nop +else enable_libdecor_shared=yes fi @@ -23443,14 +21440,16 @@ fi fi if test x$have_loadso != xyes && \ test x$enable_libdecor_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic libdecor loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic libdecor loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic libdecor loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic libdecor loading" >&2;} fi if test x$have_loadso = xyes && \ test x$enable_libdecor_shared = xyes && test x$decor_lib != x; then echo "-- dynamic libdecor -> $decor_lib" -printf "%s\n" "#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR \"$decor_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR "$decor_lib" +_ACEOF else EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DECOR_LIBS" @@ -23458,116 +21457,38 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR \"$decor_lib\"" saved_cflags=$CFLAGS CFLAGS="$CFLAGS $DECOR_CFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5 -printf %s "checking for $CC options needed to detect all undeclared functions... " >&6; } -if test ${ac_cv_c_undeclared_builtin_options+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_save_CFLAGS=$CFLAGS - ac_cv_c_undeclared_builtin_options='cannot detect' - for ac_arg in '' -fno-builtin; do - CFLAGS="$ac_save_CFLAGS $ac_arg" - # This test program should *not* compile successfully. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ -(void) strchr; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - -else $as_nop - # This test program should compile successfully. - # No library function is consistently available on - # freestanding implementations, so test against a dummy - # declaration. Include always-available headers on the - # off chance that they somehow elicit warnings. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include -extern void ac_decl (int, char *); - -int -main (void) -{ -(void) ac_decl (0, (char *) 0); - (void) ac_decl; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - if test x"$ac_arg" = x -then : - ac_cv_c_undeclared_builtin_options='none needed' -else $as_nop - ac_cv_c_undeclared_builtin_options=$ac_arg -fi - break -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - done - CFLAGS=$ac_save_CFLAGS - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_undeclared_builtin_options" >&5 -printf "%s\n" "$ac_cv_c_undeclared_builtin_options" >&6; } - case $ac_cv_c_undeclared_builtin_options in #( - 'cannot detect') : - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot make $CC report undeclared builtins -See \`config.log' for more details" "$LINENO" 5; } ;; #( - 'none needed') : - ac_c_undeclared_builtin_options='' ;; #( - *) : - ac_c_undeclared_builtin_options=$ac_cv_c_undeclared_builtin_options ;; -esac - -ac_fn_check_decl "$LINENO" "libdecor_frame_get_min_content_size" "ac_cv_have_decl_libdecor_frame_get_min_content_size" "#include -" "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_libdecor_frame_get_min_content_size" = xyes -then : + ac_fn_c_check_decl "$LINENO" "libdecor_frame_get_min_content_size" "ac_cv_have_decl_libdecor_frame_get_min_content_size" "#include +" +if test "x$ac_cv_have_decl_libdecor_frame_get_min_content_size" = xyes; then : ac_have_decl=1 -else $as_nop +else ac_have_decl=0 fi -printf "%s\n" "#define HAVE_DECL_LIBDECOR_FRAME_GET_MIN_CONTENT_SIZE $ac_have_decl" >>confdefs.h -if test $ac_have_decl = 1 -then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_LIBDECOR_FRAME_GET_MIN_CONTENT_SIZE $ac_have_decl +_ACEOF +if test $ac_have_decl = 1; then : libdecor_get_min_max=yes fi -ac_fn_check_decl "$LINENO" "libdecor_frame_get_max_content_size" "ac_cv_have_decl_libdecor_frame_get_max_content_size" "#include -" "$ac_c_undeclared_builtin_options" "CFLAGS" -if test "x$ac_cv_have_decl_libdecor_frame_get_max_content_size" = xyes -then : +ac_fn_c_check_decl "$LINENO" "libdecor_frame_get_max_content_size" "ac_cv_have_decl_libdecor_frame_get_max_content_size" "#include +" +if test "x$ac_cv_have_decl_libdecor_frame_get_max_content_size" = xyes; then : ac_have_decl=1 -else $as_nop +else ac_have_decl=0 fi -printf "%s\n" "#define HAVE_DECL_LIBDECOR_FRAME_GET_MAX_CONTENT_SIZE $ac_have_decl" >>confdefs.h -if test $ac_have_decl = 1 -then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_LIBDECOR_FRAME_GET_MAX_CONTENT_SIZE $ac_have_decl +_ACEOF +if test $ac_have_decl = 1; then : libdecor_get_min_max=yes fi if test x$libdecor_get_min_max = xyes; then -printf "%s\n" "#define SDL_HAVE_LIBDECOR_GET_MIN_MAX 1" >>confdefs.h +$as_echo "#define SDL_HAVE_LIBDECOR_GET_MIN_MAX 1" >>confdefs.h fi CFLAGS="$saved_cflags" @@ -23587,33 +21508,32 @@ CheckNativeClient() #endif int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : -printf "%s\n" "#define SDL_VIDEO_DRIVER_NACL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_NACL 1" >>confdefs.h -printf "%s\n" "#define SDL_AUDIO_DRIVER_NACL 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_NACL 1" >>confdefs.h -printf "%s\n" "#define HAVE_POW 1" >>confdefs.h +$as_echo "#define HAVE_POW 1" >>confdefs.h -printf "%s\n" "#define HAVE_OPENGLES2 1" >>confdefs.h +$as_echo "#define HAVE_OPENGLES2 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h SDL_LIBS="-lppapi_simple -lppapi_gles2 $SDL_LIBS" @@ -23627,33 +21547,32 @@ printf "%s\n" "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h have_video=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext } CheckRPI() { # Check whether --enable-video-rpi was given. -if test ${enable_video_rpi+y} -then : +if test "${enable_video_rpi+set}" = set; then : enableval=$enable_video_rpi; -else $as_nop +else enable_video_rpi=yes fi if test x$enable_video = xyes -a x$enable_video_rpi = xyes; then pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bcm_host brcmegl" >&5 -printf %s "checking for bcm_host brcmegl... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for bcm_host brcmegl" >&5 +$as_echo_n "checking for bcm_host brcmegl... " >&6; } if test -n "$RPI_CFLAGS"; then pkg_cv_RPI_CFLAGS="$RPI_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bcm_host brcmegl\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bcm_host brcmegl\""; } >&5 ($PKG_CONFIG --exists --print-errors "bcm_host brcmegl") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_RPI_CFLAGS=`$PKG_CONFIG --cflags "bcm_host brcmegl" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -23667,10 +21586,10 @@ if test -n "$RPI_LIBS"; then pkg_cv_RPI_LIBS="$RPI_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bcm_host brcmegl\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bcm_host brcmegl\""; } >&5 ($PKG_CONFIG --exists --print-errors "bcm_host brcmegl") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_RPI_LIBS=`$PKG_CONFIG --libs "bcm_host brcmegl" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -23684,8 +21603,8 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -23702,14 +21621,14 @@ fi video_rpi=no elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } video_rpi=no else RPI_CFLAGS=$pkg_cv_RPI_CFLAGS RPI_LIBS=$pkg_cv_RPI_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } video_rpi=yes fi @@ -23729,8 +21648,8 @@ fi # Add the Raspberry Pi compiler flags and libraries CFLAGS="$CFLAGS $RPI_CFLAGS"; LIBS="$LIBS $RPI_LIBS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Raspberry Pi 2/3" >&5 -printf %s "checking for Raspberry Pi 2/3... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Raspberry Pi 2/3" >&5 +$as_echo_n "checking for Raspberry Pi 2/3... " >&6; } have_video_rpi=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -23739,7 +21658,7 @@ printf %s "checking for Raspberry Pi 2/3... " >&6; } #include int -main (void) +main () { EGL_DISPMANX_WINDOW_T window; @@ -23749,14 +21668,13 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : have_video_rpi=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_video_rpi" >&5 -printf "%s\n" "$have_video_rpi" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_video_rpi" >&5 +$as_echo "$have_video_rpi" >&6; } # Restore the compiler flags and libraries CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs" @@ -23768,7 +21686,7 @@ printf "%s\n" "$have_video_rpi" >&6; } EXTRA_LDFLAGS="$EXTRA_LDFLAGS $RPI_LIBS" SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c" -printf "%s\n" "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} rpi" have_video=yes @@ -23779,10 +21697,9 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h CheckX11() { # Check whether --enable-video-x11 was given. -if test ${enable_video_x11+y} -then : +if test "${enable_video_x11+set}" = set; then : enableval=$enable_video_x11; -else $as_nop +else enable_video_x11=yes case "$host" in @@ -23806,13 +21723,12 @@ fi fi ;; esac - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for X" >&5 -printf %s "checking for X... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for X" >&5 +$as_echo_n "checking for X... " >&6; } # Check whether --with-x was given. -if test ${with_x+y} -then : +if test "${with_x+set}" = set; then : withval=$with_x; fi @@ -23823,41 +21739,12 @@ if test "x$with_x" = xno; then else case $x_includes,$x_libraries in #( *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #( - *,NONE | NONE,*) if test ${ac_cv_have_x+y} -then : - printf %s "(cached) " >&6 -else $as_nop + *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then : + $as_echo_n "(cached) " >&6 +else # One or both of the vars are not set, and there is no cached value. -ac_x_includes=no -ac_x_libraries=no -# Do we need to do anything special at all? -ac_save_LIBS=$LIBS -LIBS="-lX11 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ -XrmInitialize () - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - # We can compile and link X programs with no special options. - ac_x_includes= - ac_x_libraries= -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS="$ac_save_LIBS" -# If that didn't work, only try xmkmf and file system searches -# for native compilation. -if test x"$ac_x_includes" = xno && test "$cross_compiling" = no -then : - rm -f -r conftest.dir +ac_x_includes=no ac_x_libraries=no +rm -f -r conftest.dir if mkdir conftest.dir; then cd conftest.dir cat >Imakefile <<'_ACEOF' @@ -23896,7 +21783,7 @@ _ACEOF rm -f -r conftest.dir fi - # Standard set of common directories for X headers. +# Standard set of common directories for X headers. # Check X11 before X11Rn because it is often a symlink to the current release. ac_x_header_dirs=' /usr/X11/include @@ -23923,8 +21810,6 @@ ac_x_header_dirs=' /usr/local/include/X11R5 /usr/local/include/X11R4 -/opt/X11/include - /usr/X386/include /usr/x386/include /usr/XFree86/include/X11 @@ -23946,11 +21831,10 @@ if test "$ac_x_includes" = no; then /* end confdefs.h. */ #include _ACEOF -if ac_fn_c_try_cpp "$LINENO" -then : +if ac_fn_c_try_cpp "$LINENO"; then : # We can compile using X headers with no special include directory. ac_x_includes= -else $as_nop +else for ac_dir in $ac_x_header_dirs; do if test -r "$ac_dir/X11/Xlib.h"; then ac_x_includes=$ac_dir @@ -23971,21 +21855,20 @@ if test "$ac_x_libraries" = no; then /* end confdefs.h. */ #include int -main (void) +main () { XrmInitialize () ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : LIBS=$ac_save_LIBS # We can link X programs with no special library path. ac_x_libraries= -else $as_nop +else LIBS=$ac_save_LIBS -for ac_dir in `printf "%s\n" "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` +for ac_dir in `$as_echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` do # Don't even attempt the hair of trying to link an X program! for ac_extension in a so sl dylib la dll; do @@ -23996,21 +21879,19 @@ do done done fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi # $ac_x_libraries = no -fi -# Record the results. case $ac_x_includes,$ac_x_libraries in #( - no,* | *,no | *\'*) : + no,* | *,no | *\'*) # Didn't find X, or a directory has "'" in its name. - ac_cv_have_x="have_x=no" ;; #( - *) : + ac_cv_have_x="have_x=no";; #( + *) # Record where we found X for the cache. ac_cv_have_x="have_x=yes\ ac_x_includes='$ac_x_includes'\ - ac_x_libraries='$ac_x_libraries'" ;; + ac_x_libraries='$ac_x_libraries'" esac fi ;; #( @@ -24020,8 +21901,8 @@ fi fi # $with_x != no if test "$have_x" != yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_x" >&5 -printf "%s\n" "$have_x" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_x" >&5 +$as_echo "$have_x" >&6; } no_x=yes else # If each of the values was on the command line, it overrides each guess. @@ -24031,14 +21912,14 @@ else ac_cv_have_x="have_x=yes\ ac_x_includes='$x_includes'\ ac_x_libraries='$x_libraries'" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: libraries $x_libraries, headers $x_includes" >&5 -printf "%s\n" "libraries $x_libraries, headers $x_includes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: libraries $x_libraries, headers $x_includes" >&5 +$as_echo "libraries $x_libraries, headers $x_includes" >&6; } fi if test "$no_x" = yes; then # Not all programs may use this symbol, but it does not hurt to define it. -printf "%s\n" "#define X_DISPLAY_MISSING 1" >>confdefs.h +$as_echo "#define X_DISPLAY_MISSING 1" >>confdefs.h X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= else @@ -24051,8 +21932,8 @@ else X_LIBS="$X_LIBS -L$x_libraries" # For Solaris; some versions of Sun CC require a space after -R and # others require no space. Words are not sufficient . . . . - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -R must be followed by a space" >&5 -printf %s "checking whether -R must be followed by a space... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -R must be followed by a space" >&5 +$as_echo_n "checking whether -R must be followed by a space... " >&6; } ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries" ac_xsave_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes @@ -24060,44 +21941,42 @@ printf %s "checking whether -R must be followed by a space... " >&6; } /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } X_LIBS="$X_LIBS -R$x_libraries" -else $as_nop +else LIBS="$ac_xsave_LIBS -R $x_libraries" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } X_LIBS="$X_LIBS -R $x_libraries" -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: neither works" >&5 -printf "%s\n" "neither works" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: neither works" >&5 +$as_echo "neither works" >&6; } fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_c_werror_flag=$ac_xsave_c_werror_flag LIBS=$ac_xsave_LIBS @@ -24120,25 +21999,26 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char XOpenDisplay (); int -main (void) +main () { return XOpenDisplay (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet" >&5 -printf %s "checking for dnet_ntoa in -ldnet... " >&6; } -if test ${ac_cv_lib_dnet_dnet_ntoa+y} -then : - printf %s "(cached) " >&6 -else $as_nop +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet" >&5 +$as_echo_n "checking for dnet_ntoa in -ldnet... " >&6; } +if ${ac_cv_lib_dnet_dnet_ntoa+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-ldnet $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -24147,39 +22027,39 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char dnet_ntoa (); int -main (void) +main () { return dnet_ntoa (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dnet_dnet_ntoa=yes -else $as_nop +else ac_cv_lib_dnet_dnet_ntoa=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 -printf "%s\n" "$ac_cv_lib_dnet_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_dnet_ntoa" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 +$as_echo "$ac_cv_lib_dnet_dnet_ntoa" >&6; } +if test "x$ac_cv_lib_dnet_dnet_ntoa" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet_stub" >&5 -printf %s "checking for dnet_ntoa in -ldnet_stub... " >&6; } -if test ${ac_cv_lib_dnet_stub_dnet_ntoa+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet_stub" >&5 +$as_echo_n "checking for dnet_ntoa in -ldnet_stub... " >&6; } +if ${ac_cv_lib_dnet_stub_dnet_ntoa+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-ldnet_stub $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -24188,35 +22068,36 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char dnet_ntoa (); int -main (void) +main () { return dnet_ntoa (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dnet_stub_dnet_ntoa=yes -else $as_nop +else ac_cv_lib_dnet_stub_dnet_ntoa=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 -printf "%s\n" "$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 +$as_echo "$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; } +if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" fi fi fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$ac_xsave_LIBS" @@ -24229,18 +22110,16 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ # The functions gethostbyname, getservbyname, and inet_addr are # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking. ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" -if test "x$ac_cv_func_gethostbyname" = xyes -then : +if test "x$ac_cv_func_gethostbyname" = xyes; then : fi if test $ac_cv_func_gethostbyname = no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 -printf %s "checking for gethostbyname in -lnsl... " >&6; } -if test ${ac_cv_lib_nsl_gethostbyname+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 +$as_echo_n "checking for gethostbyname in -lnsl... " >&6; } +if ${ac_cv_lib_nsl_gethostbyname+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -24249,39 +22128,39 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char gethostbyname (); int -main (void) +main () { return gethostbyname (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_gethostbyname=yes -else $as_nop +else ac_cv_lib_nsl_gethostbyname=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 -printf "%s\n" "$ac_cv_lib_nsl_gethostbyname" >&6; } -if test "x$ac_cv_lib_nsl_gethostbyname" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 +$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } +if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" fi if test $ac_cv_lib_nsl_gethostbyname = no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lbsd" >&5 -printf %s "checking for gethostbyname in -lbsd... " >&6; } -if test ${ac_cv_lib_bsd_gethostbyname+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lbsd" >&5 +$as_echo_n "checking for gethostbyname in -lbsd... " >&6; } +if ${ac_cv_lib_bsd_gethostbyname+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lbsd $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -24290,29 +22169,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char gethostbyname (); int -main (void) +main () { return gethostbyname (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_bsd_gethostbyname=yes -else $as_nop +else ac_cv_lib_bsd_gethostbyname=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_gethostbyname" >&5 -printf "%s\n" "$ac_cv_lib_bsd_gethostbyname" >&6; } -if test "x$ac_cv_lib_bsd_gethostbyname" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_gethostbyname" >&5 +$as_echo "$ac_cv_lib_bsd_gethostbyname" >&6; } +if test "x$ac_cv_lib_bsd_gethostbyname" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd" fi @@ -24327,18 +22207,16 @@ fi # must be given before -lnsl if both are needed. We assume that # if connect needs -lnsl, so does gethostbyname. ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect" -if test "x$ac_cv_func_connect" = xyes -then : +if test "x$ac_cv_func_connect" = xyes; then : fi if test $ac_cv_func_connect = no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 -printf %s "checking for connect in -lsocket... " >&6; } -if test ${ac_cv_lib_socket_connect+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 +$as_echo_n "checking for connect in -lsocket... " >&6; } +if ${ac_cv_lib_socket_connect+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $X_EXTRA_LIBS $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -24347,29 +22225,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char connect (); int -main (void) +main () { return connect (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_connect=yes -else $as_nop +else ac_cv_lib_socket_connect=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 -printf "%s\n" "$ac_cv_lib_socket_connect" >&6; } -if test "x$ac_cv_lib_socket_connect" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 +$as_echo "$ac_cv_lib_socket_connect" >&6; } +if test "x$ac_cv_lib_socket_connect" = xyes; then : X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" fi @@ -24377,18 +22256,16 @@ fi # Guillermo Gomez says -lposix is necessary on A/UX. ac_fn_c_check_func "$LINENO" "remove" "ac_cv_func_remove" -if test "x$ac_cv_func_remove" = xyes -then : +if test "x$ac_cv_func_remove" = xyes; then : fi if test $ac_cv_func_remove = no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for remove in -lposix" >&5 -printf %s "checking for remove in -lposix... " >&6; } -if test ${ac_cv_lib_posix_remove+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for remove in -lposix" >&5 +$as_echo_n "checking for remove in -lposix... " >&6; } +if ${ac_cv_lib_posix_remove+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lposix $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -24397,29 +22274,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char remove (); int -main (void) +main () { return remove (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_posix_remove=yes -else $as_nop +else ac_cv_lib_posix_remove=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix_remove" >&5 -printf "%s\n" "$ac_cv_lib_posix_remove" >&6; } -if test "x$ac_cv_lib_posix_remove" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix_remove" >&5 +$as_echo "$ac_cv_lib_posix_remove" >&6; } +if test "x$ac_cv_lib_posix_remove" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" fi @@ -24427,18 +22305,16 @@ fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. ac_fn_c_check_func "$LINENO" "shmat" "ac_cv_func_shmat" -if test "x$ac_cv_func_shmat" = xyes -then : +if test "x$ac_cv_func_shmat" = xyes; then : fi if test $ac_cv_func_shmat = no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shmat in -lipc" >&5 -printf %s "checking for shmat in -lipc... " >&6; } -if test ${ac_cv_lib_ipc_shmat+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shmat in -lipc" >&5 +$as_echo_n "checking for shmat in -lipc... " >&6; } +if ${ac_cv_lib_ipc_shmat+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lipc $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -24447,29 +22323,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char shmat (); int -main (void) +main () { return shmat (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ipc_shmat=yes -else $as_nop +else ac_cv_lib_ipc_shmat=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ipc_shmat" >&5 -printf "%s\n" "$ac_cv_lib_ipc_shmat" >&6; } -if test "x$ac_cv_lib_ipc_shmat" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ipc_shmat" >&5 +$as_echo "$ac_cv_lib_ipc_shmat" >&6; } +if test "x$ac_cv_lib_ipc_shmat" = xyes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" fi @@ -24485,12 +22362,11 @@ fi # These have to be linked with before -lX11, unlike the other # libraries we check for below, so use a different variable. # John Interrante, Karl Berry - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for IceConnectionNumber in -lICE" >&5 -printf %s "checking for IceConnectionNumber in -lICE... " >&6; } -if test ${ac_cv_lib_ICE_IceConnectionNumber+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for IceConnectionNumber in -lICE" >&5 +$as_echo_n "checking for IceConnectionNumber in -lICE... " >&6; } +if ${ac_cv_lib_ICE_IceConnectionNumber+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lICE $X_EXTRA_LIBS $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -24499,29 +22375,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char IceConnectionNumber (); int -main (void) +main () { return IceConnectionNumber (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ICE_IceConnectionNumber=yes -else $as_nop +else ac_cv_lib_ICE_IceConnectionNumber=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 -printf "%s\n" "$ac_cv_lib_ICE_IceConnectionNumber" >&6; } -if test "x$ac_cv_lib_ICE_IceConnectionNumber" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 +$as_echo "$ac_cv_lib_ICE_IceConnectionNumber" >&6; } +if test "x$ac_cv_lib_ICE_IceConnectionNumber" = xyes; then : X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" fi @@ -24531,10 +22408,9 @@ fi if test x$have_x = xyes; then # Check whether --enable-x11-shared was given. -if test ${enable_x11_shared+y} -then : +if test "${enable_x11_shared+set}" = set; then : enableval=$enable_x11_shared; -else $as_nop +else enable_x11_shared=maybe fi @@ -24583,13 +22459,13 @@ fi #include " -if test "x$ac_cv_header_X11_extensions_Xext_h" = xyes -then : +if test "x$ac_cv_header_X11_extensions_Xext_h" = xyes; then : have_xext_h_hdr=yes -else $as_nop +else have_xext_h_hdr=no fi + if test x$have_xext_h_hdr != xyes; then as_fn_error $? " *** Missing Xext.h, maybe you need to install the libxext-dev package? @@ -24597,7 +22473,7 @@ fi fi -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_X11 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/x11/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS" @@ -24610,8 +22486,8 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_X11 1" >>confdefs.h fi if test x$have_loadso != xyes && \ test x$enable_x11_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic X11 loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic X11 loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic X11 loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic X11 loading" >&2;} enable_x11_shared=no fi if test x$have_loadso = xyes && \ @@ -24619,10 +22495,14 @@ printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynam echo "-- dynamic libX11 -> $x11_lib" echo "-- dynamic libX11ext -> $x11ext_lib" -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_DYNAMIC \"$x11_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_X11_DYNAMIC "$x11_lib" +_ACEOF -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT \"$x11ext_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "$x11ext_lib" +_ACEOF SUMMARY_video="${SUMMARY_video} x11(dynamic)" else @@ -24632,8 +22512,8 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT \"$x11ext_lib\"" >>conf fi have_video=yes - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for XGenericEvent" >&5 -printf %s "checking for XGenericEvent... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XGenericEvent" >&5 +$as_echo_n "checking for XGenericEvent... " >&6; } have_XGenericEvent=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -24641,7 +22521,7 @@ printf %s "checking for XGenericEvent... " >&6; } #include int -main (void) +main () { Display *display; @@ -24655,25 +22535,23 @@ XFreeEventData(display, cookie); return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_XGenericEvent=yes -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1" >>confdefs.h fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_XGenericEvent" >&5 -printf "%s\n" "$have_XGenericEvent" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_XGenericEvent" >&5 +$as_echo "$have_XGenericEvent" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for XkbKeycodeToKeysym in -lX11" >&5 -printf %s "checking for XkbKeycodeToKeysym in -lX11... " >&6; } -if test ${ac_cv_lib_X11_XkbKeycodeToKeysym+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XkbKeycodeToKeysym in -lX11" >&5 +$as_echo_n "checking for XkbKeycodeToKeysym in -lX11... " >&6; } +if ${ac_cv_lib_X11_XkbKeycodeToKeysym+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lX11 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -24682,40 +22560,40 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char XkbKeycodeToKeysym (); int -main (void) +main () { return XkbKeycodeToKeysym (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_X11_XkbKeycodeToKeysym=yes -else $as_nop +else ac_cv_lib_X11_XkbKeycodeToKeysym=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_X11_XkbKeycodeToKeysym" >&5 -printf "%s\n" "$ac_cv_lib_X11_XkbKeycodeToKeysym" >&6; } -if test "x$ac_cv_lib_X11_XkbKeycodeToKeysym" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_X11_XkbKeycodeToKeysym" >&5 +$as_echo "$ac_cv_lib_X11_XkbKeycodeToKeysym" >&6; } +if test "x$ac_cv_lib_X11_XkbKeycodeToKeysym" = xyes; then : -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1" >>confdefs.h fi # Check whether --enable-video-x11-xcursor was given. -if test ${enable_video_x11_xcursor+y} -then : +if test "${enable_video_x11_xcursor+set}" = set; then : enableval=$enable_video_x11_xcursor; -else $as_nop +else enable_video_x11_xcursor=yes fi @@ -24724,27 +22602,28 @@ fi ac_fn_c_check_header_compile "$LINENO" "X11/Xcursor/Xcursor.h" "ac_cv_header_X11_Xcursor_Xcursor_h" "#include " -if test "x$ac_cv_header_X11_Xcursor_Xcursor_h" = xyes -then : +if test "x$ac_cv_header_X11_Xcursor_Xcursor_h" = xyes; then : have_xcursor_h_hdr=yes -else $as_nop +else have_xcursor_h_hdr=no fi + if test x$have_xcursor_h_hdr = xyes; then if test x$enable_x11_shared = xyes && test x$xcursor_lib != x ; then echo "-- dynamic libXcursor -> $xcursor_lib" -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR \"$xcursor_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "$xcursor_lib" +_ACEOF definitely_enable_video_x11_xcursor=yes else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for XcursorImageCreate in -lXcursor" >&5 -printf %s "checking for XcursorImageCreate in -lXcursor... " >&6; } -if test ${ac_cv_lib_Xcursor_XcursorImageCreate+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XcursorImageCreate in -lXcursor" >&5 +$as_echo_n "checking for XcursorImageCreate in -lXcursor... " >&6; } +if ${ac_cv_lib_Xcursor_XcursorImageCreate+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lXcursor $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -24753,29 +22632,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char XcursorImageCreate (); int -main (void) +main () { return XcursorImageCreate (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_Xcursor_XcursorImageCreate=yes -else $as_nop +else ac_cv_lib_Xcursor_XcursorImageCreate=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xcursor_XcursorImageCreate" >&5 -printf "%s\n" "$ac_cv_lib_Xcursor_XcursorImageCreate" >&6; } -if test "x$ac_cv_lib_Xcursor_XcursorImageCreate" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xcursor_XcursorImageCreate" >&5 +$as_echo "$ac_cv_lib_Xcursor_XcursorImageCreate" >&6; } +if test "x$ac_cv_lib_Xcursor_XcursorImageCreate" = xyes; then : have_xcursor_lib=yes fi @@ -24788,15 +22668,14 @@ fi fi if test x$definitely_enable_video_x11_xcursor = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_XCURSOR 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_X11_XCURSOR 1" >>confdefs.h SUMMARY_video_x11="${SUMMARY_video_x11} xcursor" fi # Check whether --enable-video-x11-xdbe was given. -if test ${enable_video_x11_xdbe+y} -then : +if test "${enable_video_x11_xdbe+set}" = set; then : enableval=$enable_video_x11_xdbe; -else $as_nop +else enable_video_x11_xdbe=yes fi @@ -24804,25 +22683,24 @@ fi ac_fn_c_check_header_compile "$LINENO" "X11/extensions/Xdbe.h" "ac_cv_header_X11_extensions_Xdbe_h" "#include " -if test "x$ac_cv_header_X11_extensions_Xdbe_h" = xyes -then : +if test "x$ac_cv_header_X11_extensions_Xdbe_h" = xyes; then : have_dbe_h_hdr=yes -else $as_nop +else have_dbe_h_hdr=no fi + if test x$have_dbe_h_hdr = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_XDBE 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_X11_XDBE 1" >>confdefs.h SUMMARY_video_x11="${SUMMARY_video_x11} xdbe" fi fi # Check whether --enable-video-x11-xinput was given. -if test ${enable_video_x11_xinput+y} -then : +if test "${enable_video_x11_xinput+set}" = set; then : enableval=$enable_video_x11_xinput; -else $as_nop +else enable_video_x11_xinput=yes fi @@ -24831,27 +22709,28 @@ fi ac_fn_c_check_header_compile "$LINENO" "X11/extensions/XInput2.h" "ac_cv_header_X11_extensions_XInput2_h" "#include " -if test "x$ac_cv_header_X11_extensions_XInput2_h" = xyes -then : +if test "x$ac_cv_header_X11_extensions_XInput2_h" = xyes; then : have_xinput_h_hdr=yes -else $as_nop +else have_xinput_h_hdr=no fi + if test x$have_xinput_h_hdr = xyes; then if test x$enable_x11_shared = xyes && test x$xinput_lib != x ; then echo "-- dynamic libXi -> $xinput_lib" -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 \"$xinput_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "$xinput_lib" +_ACEOF definitely_enable_video_x11_xinput=yes else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for XOpenDevice in -lXi" >&5 -printf %s "checking for XOpenDevice in -lXi... " >&6; } -if test ${ac_cv_lib_Xi_XOpenDevice+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XOpenDevice in -lXi" >&5 +$as_echo_n "checking for XOpenDevice in -lXi... " >&6; } +if ${ac_cv_lib_Xi_XOpenDevice+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lXi $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -24860,29 +22739,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char XOpenDevice (); int -main (void) +main () { return XOpenDevice (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_Xi_XOpenDevice=yes -else $as_nop +else ac_cv_lib_Xi_XOpenDevice=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xi_XOpenDevice" >&5 -printf "%s\n" "$ac_cv_lib_Xi_XOpenDevice" >&6; } -if test "x$ac_cv_lib_Xi_XOpenDevice" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xi_XOpenDevice" >&5 +$as_echo "$ac_cv_lib_Xi_XOpenDevice" >&6; } +if test "x$ac_cv_lib_Xi_XOpenDevice" = xyes; then : have_xinput_lib=yes fi @@ -24896,10 +22776,10 @@ fi if test x$definitely_enable_video_x11_xinput = xyes; then SUMMARY_video_x11="${SUMMARY_video_x11} xinput2" -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_XINPUT2 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_X11_XINPUT2 1" >>confdefs.h - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for xinput2 multitouch" >&5 -printf %s "checking for xinput2 multitouch... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for xinput2 multitouch" >&5 +$as_echo_n "checking for xinput2 multitouch... " >&6; } have_xinput2_multitouch=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -24909,7 +22789,7 @@ printf %s "checking for xinput2 multitouch... " >&6; } #include int -main (void) +main () { int event_type = XI_TouchBegin; @@ -24919,33 +22799,31 @@ XITouchClassInfo *t; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_xinput2_multitouch=yes -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1" >>confdefs.h SUMMARY_video_x11="${SUMMARY_video_x11} xinput2_multitouch" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_xinput2_multitouch" >&5 -printf "%s\n" "$have_xinput2_multitouch" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_xinput2_multitouch" >&5 +$as_echo "$have_xinput2_multitouch" >&6; } fi # Check whether --enable-video-x11-xfixes was given. -if test ${enable_video_x11_xfixes+y} -then : +if test "${enable_video_x11_xfixes+set}" = set; then : enableval=$enable_video_x11_xfixes; -else $as_nop +else enable_video_x11_xfixes=yes fi if test x$enable_video_x11_xfixes = xyes; then definitely_enable_video_x11_xfixes=no # check along with XInput2.h because we use Xfixes with XIBarrierReleasePointer - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for X11/extensions/Xfixes.h" >&5 -printf %s "checking for X11/extensions/Xfixes.h... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for X11/extensions/Xfixes.h" >&5 +$as_echo_n "checking for X11/extensions/Xfixes.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -24954,36 +22832,36 @@ printf %s "checking for X11/extensions/Xfixes.h... " >&6; } #include #include int -main (void) +main () { BarrierEventID b; ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_xfixes_h_hdr=yes -else $as_nop +else have_xfixes_h_hdr=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_xfixes_h_hdr" >&5 -printf "%s\n" "$have_xfixes_h_hdr" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_xfixes_h_hdr" >&5 +$as_echo "$have_xfixes_h_hdr" >&6; } if test x$have_xfixes_h_hdr = xyes; then if test x$enable_x11_shared = xyes && test x$xfixes_lib != x ; then echo "-- dynamic libXfixes -> $xfixes_lib" -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES \"$xfixes_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES "$xfixes_lib" +_ACEOF definitely_enable_video_x11_xfixes=yes else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for XFixesCreatePointerBarrier in -lXfixes" >&5 -printf %s "checking for XFixesCreatePointerBarrier in -lXfixes... " >&6; } -if test ${ac_cv_lib_Xfixes_XFixesCreatePointerBarrier+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XFixesCreatePointerBarrier in -lXfixes" >&5 +$as_echo_n "checking for XFixesCreatePointerBarrier in -lXfixes... " >&6; } +if ${ac_cv_lib_Xfixes_XFixesCreatePointerBarrier+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lXfixes $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -24992,29 +22870,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char XFixesCreatePointerBarrier (); int -main (void) +main () { return XFixesCreatePointerBarrier (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_Xfixes_XFixesCreatePointerBarrier=yes -else $as_nop +else ac_cv_lib_Xfixes_XFixesCreatePointerBarrier=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xfixes_XFixesCreatePointerBarrier" >&5 -printf "%s\n" "$ac_cv_lib_Xfixes_XFixesCreatePointerBarrier" >&6; } -if test "x$ac_cv_lib_Xfixes_XFixesCreatePointerBarrier" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xfixes_XFixesCreatePointerBarrier" >&5 +$as_echo "$ac_cv_lib_Xfixes_XFixesCreatePointerBarrier" >&6; } +if test "x$ac_cv_lib_Xfixes_XFixesCreatePointerBarrier" = xyes; then : have_xfixes_lib=yes fi @@ -25027,15 +22906,14 @@ fi fi if test x$definitely_enable_video_x11_xfixes = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_XFIXES 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_X11_XFIXES 1" >>confdefs.h SUMMARY_video_x11="${SUMMARY_video_x11} xfixes" fi # Check whether --enable-video-x11-xrandr was given. -if test ${enable_video_x11_xrandr+y} -then : +if test "${enable_video_x11_xrandr+set}" = set; then : enableval=$enable_video_x11_xrandr; -else $as_nop +else enable_video_x11_xrandr=yes fi @@ -25049,7 +22927,7 @@ fi #include int -main (void) +main () { XRRScreenResources *res = NULL; @@ -25058,25 +22936,25 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_xrandr_h_hdr=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test x$have_xrandr_h_hdr = xyes; then if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then echo "-- dynamic libXrandr -> $xrandr_lib" -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR \"$xrandr_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "$xrandr_lib" +_ACEOF definitely_enable_video_x11_xrandr=yes else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for XRRQueryExtension in -lXrandr" >&5 -printf %s "checking for XRRQueryExtension in -lXrandr... " >&6; } -if test ${ac_cv_lib_Xrandr_XRRQueryExtension+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XRRQueryExtension in -lXrandr" >&5 +$as_echo_n "checking for XRRQueryExtension in -lXrandr... " >&6; } +if ${ac_cv_lib_Xrandr_XRRQueryExtension+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lXrandr $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -25085,29 +22963,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char XRRQueryExtension (); int -main (void) +main () { return XRRQueryExtension (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_Xrandr_XRRQueryExtension=yes -else $as_nop +else ac_cv_lib_Xrandr_XRRQueryExtension=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xrandr_XRRQueryExtension" >&5 -printf "%s\n" "$ac_cv_lib_Xrandr_XRRQueryExtension" >&6; } -if test "x$ac_cv_lib_Xrandr_XRRQueryExtension" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xrandr_XRRQueryExtension" >&5 +$as_echo "$ac_cv_lib_Xrandr_XRRQueryExtension" >&6; } +if test "x$ac_cv_lib_Xrandr_XRRQueryExtension" = xyes; then : have_xrandr_lib=yes fi @@ -25120,15 +22999,14 @@ fi fi if test x$definitely_enable_video_x11_xrandr = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_XRANDR 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_X11_XRANDR 1" >>confdefs.h SUMMARY_video_x11="${SUMMARY_video_x11} xrandr" fi # Check whether --enable-video-x11-scrnsaver was given. -if test ${enable_video_x11_scrnsaver+y} -then : +if test "${enable_video_x11_scrnsaver+set}" = set; then : enableval=$enable_video_x11_scrnsaver; -else $as_nop +else enable_video_x11_scrnsaver=yes fi @@ -25136,27 +23014,28 @@ fi ac_fn_c_check_header_compile "$LINENO" "X11/extensions/scrnsaver.h" "ac_cv_header_X11_extensions_scrnsaver_h" "#include " -if test "x$ac_cv_header_X11_extensions_scrnsaver_h" = xyes -then : +if test "x$ac_cv_header_X11_extensions_scrnsaver_h" = xyes; then : have_scrnsaver_h_hdr=yes -else $as_nop +else have_scrnsaver_h_hdr=no fi + if test x$have_scrnsaver_h_hdr = xyes; then if test x$enable_x11_shared = xyes && test x$xss_lib != x ; then echo "-- dynamic libXss -> $xss_lib" -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS \"$xss_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "$xss_lib" +_ACEOF definitely_enable_video_x11_scrnsaver=yes else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for XScreenSaverSuspend in -lXss" >&5 -printf %s "checking for XScreenSaverSuspend in -lXss... " >&6; } -if test ${ac_cv_lib_Xss_XScreenSaverSuspend+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XScreenSaverSuspend in -lXss" >&5 +$as_echo_n "checking for XScreenSaverSuspend in -lXss... " >&6; } +if ${ac_cv_lib_Xss_XScreenSaverSuspend+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lXss $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -25165,29 +23044,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char XScreenSaverSuspend (); int -main (void) +main () { return XScreenSaverSuspend (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_Xss_XScreenSaverSuspend=yes -else $as_nop +else ac_cv_lib_Xss_XScreenSaverSuspend=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xss_XScreenSaverSuspend" >&5 -printf "%s\n" "$ac_cv_lib_Xss_XScreenSaverSuspend" >&6; } -if test "x$ac_cv_lib_Xss_XScreenSaverSuspend" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xss_XScreenSaverSuspend" >&5 +$as_echo "$ac_cv_lib_Xss_XScreenSaverSuspend" >&6; } +if test "x$ac_cv_lib_Xss_XScreenSaverSuspend" = xyes; then : have_xss_lib=yes fi @@ -25200,15 +23080,14 @@ fi fi if test x$definitely_enable_video_x11_scrnsaver = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1" >>confdefs.h SUMMARY_video_x11="${SUMMARY_video_x11} xscrnsaver" fi # Check whether --enable-video-x11-xshape was given. -if test ${enable_video_x11_xshape+y} -then : +if test "${enable_video_x11_xshape+set}" = set; then : enableval=$enable_video_x11_xshape; -else $as_nop +else enable_video_x11_xshape=yes fi @@ -25216,16 +23095,16 @@ fi ac_fn_c_check_header_compile "$LINENO" "X11/extensions/shape.h" "ac_cv_header_X11_extensions_shape_h" "#include " -if test "x$ac_cv_header_X11_extensions_shape_h" = xyes -then : +if test "x$ac_cv_header_X11_extensions_shape_h" = xyes; then : have_shape_h_hdr=yes -else $as_nop +else have_shape_h_hdr=no fi + if test x$have_shape_h_hdr = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_XSHAPE 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_X11_XSHAPE 1" >>confdefs.h SUMMARY_video_x11="${SUMMARY_video_x11} xshape" fi @@ -25241,16 +23120,15 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_X11_XSHAPE 1" >>confdefs.h CheckVivanteVideo() { # Check whether --enable-video-vivante was given. -if test ${enable_video_vivante+y} -then : +if test "${enable_video_vivante+set}" = set; then : enableval=$enable_video_vivante; -else $as_nop +else enable_video_vivante=yes fi if test x$enable_video = xyes -a x$enable_video_vivante = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Vivante VDK API" >&5 -printf %s "checking for Vivante VDK API... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Vivante VDK API" >&5 +$as_echo_n "checking for Vivante VDK API... " >&6; } have_vivante_vdk=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -25260,23 +23138,22 @@ printf %s "checking for Vivante VDK API... " >&6; } #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_vivante_vdk=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_vivante_vdk" >&5 -printf "%s\n" "$have_vivante_vdk" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_vivante_vdk" >&5 +$as_echo "$have_vivante_vdk" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Vivante FB API" >&5 -printf %s "checking for Vivante FB API... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Vivante FB API" >&5 +$as_echo_n "checking for Vivante FB API... " >&6; } have_vivante_egl=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -25286,29 +23163,28 @@ printf %s "checking for Vivante FB API... " >&6; } #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_vivante_egl=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_vivante_egl" >&5 -printf "%s\n" "$have_vivante_egl" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_vivante_egl" >&5 +$as_echo "$have_vivante_egl" >&6; } if test x$have_vivante_vdk = xyes -o x$have_vivante_egl = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_VIVANTE 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_VIVANTE 1" >>confdefs.h EXTRA_CFLAGS="$EXTRA_CFLAGS -DLINUX -DEGL_API_FB" if test x$have_vivante_vdk = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_VIVANTE_VDK 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_VIVANTE_VDK 1" >>confdefs.h EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lVDK" fi @@ -25323,7 +23199,7 @@ CheckHaikuVideo() { if test x$enable_video = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_HAIKU 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_HAIKU 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/haiku/*.cc" have_video=yes @@ -25334,18 +23210,17 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_HAIKU 1" >>confdefs.h CheckCOCOA() { # Check whether --enable-video-cocoa was given. -if test ${enable_video_cocoa+y} -then : +if test "${enable_video_cocoa+set}" = set; then : enableval=$enable_video_cocoa; -else $as_nop +else enable_video_cocoa=yes fi if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -x objective-c" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Cocoa framework" >&5 -printf %s "checking for Cocoa framework... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Cocoa framework" >&5 +$as_echo_n "checking for Cocoa framework... " >&6; } have_cocoa=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -25353,24 +23228,23 @@ printf %s "checking for Cocoa framework... " >&6; } #import int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_cocoa=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_cocoa" >&5 -printf "%s\n" "$have_cocoa" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_cocoa" >&5 +$as_echo "$have_cocoa" >&6; } CFLAGS="$save_CFLAGS" if test x$have_cocoa = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_COCOA 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_COCOA 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/cocoa/*.m" SUMMARY_video="${SUMMARY_video} cocoa" @@ -25382,26 +23256,24 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_COCOA 1" >>confdefs.h CheckMETAL() { # Check whether --enable-video-metal was given. -if test ${enable_video_metal+y} -then : +if test "${enable_video_metal+set}" = set; then : enableval=$enable_video_metal; -else $as_nop +else enable_video_metal=yes fi # Check whether --enable-render-metal was given. -if test ${enable_render_metal+y} -then : +if test "${enable_render_metal+set}" = set; then : enableval=$enable_render_metal; -else $as_nop +else enable_render_metal=yes fi if test x$enable_video = xyes -a x$enable_video_metal = xyes; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -x objective-c" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Metal framework" >&5 -printf %s "checking for Metal framework... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Metal framework" >&5 +$as_echo_n "checking for Metal framework... " >&6; } have_metal=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -25415,28 +23287,27 @@ printf %s "checking for Metal framework... " >&6; } #endif int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_metal=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_metal" >&5 -printf "%s\n" "$have_metal" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_metal" >&5 +$as_echo "$have_metal" >&6; } if test x$have_metal = xyes; then -printf "%s\n" "#define SDL_VIDEO_METAL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_METAL 1" >>confdefs.h if test x$enable_render = xyes -a x$enable_render_metal = xyes; then -printf "%s\n" "#define SDL_VIDEO_RENDER_METAL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_METAL 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/render/metal/*.m" fi @@ -25451,27 +23322,26 @@ printf "%s\n" "#define SDL_VIDEO_RENDER_METAL 1" >>confdefs.h CheckDirectFB() { # Check whether --enable-video-directfb was given. -if test ${enable_video_directfb+y} -then : +if test "${enable_video_directfb+set}" = set; then : enableval=$enable_video_directfb; -else $as_nop +else enable_video_directfb=no fi if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for directfb >= 1.0.0" >&5 -printf %s "checking for directfb >= 1.0.0... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for directfb >= 1.0.0" >&5 +$as_echo_n "checking for directfb >= 1.0.0... " >&6; } if test -n "$DIRECTFB_CFLAGS"; then pkg_cv_DIRECTFB_CFLAGS="$DIRECTFB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"directfb >= 1.0.0\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"directfb >= 1.0.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "directfb >= 1.0.0") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags "directfb >= 1.0.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -25485,10 +23355,10 @@ if test -n "$DIRECTFB_LIBS"; then pkg_cv_DIRECTFB_LIBS="$DIRECTFB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"directfb >= 1.0.0\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"directfb >= 1.0.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "directfb >= 1.0.0") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_DIRECTFB_LIBS=`$PKG_CONFIG --libs "directfb >= 1.0.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -25502,8 +23372,8 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -25520,14 +23390,14 @@ fi video_directfb=no elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } video_directfb=no else DIRECTFB_CFLAGS=$pkg_cv_DIRECTFB_CFLAGS DIRECTFB_LIBS=$pkg_cv_DIRECTFB_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } video_directfb=yes fi @@ -25535,33 +23405,32 @@ fi # SuSE 11.1 installs directfb-config without directfb-devel save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $DIRECTFB_CFLAGS" - ac_fn_c_check_header_compile "$LINENO" "directfb.h" "ac_cv_header_directfb_h" "$ac_includes_default" -if test "x$ac_cv_header_directfb_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "directfb.h" "ac_cv_header_directfb_h" "$ac_includes_default" +if test "x$ac_cv_header_directfb_h" = xyes; then : have_directfb_hdr=yes -else $as_nop +else have_directfb_hdr=no fi + CPPFLAGS="$save_CPPFLAGS" video_directfb=$have_directfb_hdr fi if test x$video_directfb = xyes; then # Check whether --enable-directfb-shared was given. -if test ${enable_directfb_shared+y} -then : +if test "${enable_directfb_shared+set}" = set; then : enableval=$enable_directfb_shared; -else $as_nop +else enable_directfb_shared=yes fi -printf "%s\n" "#define SDL_VIDEO_DRIVER_DIRECTFB 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_DIRECTFB 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_RENDER_DIRECTFB 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_DIRECTFB 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/directfb/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS" @@ -25570,15 +23439,17 @@ printf "%s\n" "#define SDL_VIDEO_RENDER_DIRECTFB 1" >>confdefs.h directfb_lib=`find_lib "libdirectfb*.so.*" "$DIRECTFB_LIBS" | sed 's/.*\/\(.*\)/\1/; q'` if test x$have_loadso != xyes && \ test x$enable_directfb_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic directfb loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic directfb loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic directfb loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic directfb loading" >&2;} fi if test x$have_loadso = xyes && \ test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then directfb_shared=yes echo "-- dynamic libdirectfb -> $directfb_lib" -printf "%s\n" "#define SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC \"$directfb_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "$directfb_lib" +_ACEOF SUMMARY_video="${SUMMARY_video} directfb(dynamic)" else @@ -25594,10 +23465,9 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC \"$directfb_lib\"" >>co CheckKMSDRM() { # Check whether --enable-video-kmsdrm was given. -if test ${enable_video_kmsdrm+y} -then : +if test "${enable_video_kmsdrm+set}" = set; then : enableval=$enable_video_kmsdrm; -else $as_nop +else enable_video_kmsdrm=yes fi @@ -25610,17 +23480,17 @@ fi pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libdrm >= 1.4.82" >&5 -printf %s "checking for libdrm >= 1.4.82... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libdrm >= 1.4.82" >&5 +$as_echo_n "checking for libdrm >= 1.4.82... " >&6; } if test -n "$LIBDRM_CFLAGS"; then pkg_cv_LIBDRM_CFLAGS="$LIBDRM_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= 1.4.82\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= 1.4.82\""; } >&5 ($PKG_CONFIG --exists --print-errors "libdrm >= 1.4.82") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBDRM_CFLAGS=`$PKG_CONFIG --cflags "libdrm >= 1.4.82" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -25634,10 +23504,10 @@ if test -n "$LIBDRM_LIBS"; then pkg_cv_LIBDRM_LIBS="$LIBDRM_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= 1.4.82\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libdrm >= 1.4.82\""; } >&5 ($PKG_CONFIG --exists --print-errors "libdrm >= 1.4.82") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBDRM_LIBS=`$PKG_CONFIG --libs "libdrm >= 1.4.82" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -25651,8 +23521,8 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -25669,29 +23539,29 @@ fi libdrm_avail=no elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } libdrm_avail=no else LIBDRM_CFLAGS=$pkg_cv_LIBDRM_CFLAGS LIBDRM_LIBS=$pkg_cv_LIBDRM_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } libdrm_avail=yes fi pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gbm >= 11.1.0" >&5 -printf %s "checking for gbm >= 11.1.0... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gbm >= 11.1.0" >&5 +$as_echo_n "checking for gbm >= 11.1.0... " >&6; } if test -n "$LIBGBM_CFLAGS"; then pkg_cv_LIBGBM_CFLAGS="$LIBGBM_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gbm >= 11.1.0\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gbm >= 11.1.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "gbm >= 11.1.0") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBGBM_CFLAGS=`$PKG_CONFIG --cflags "gbm >= 11.1.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -25705,10 +23575,10 @@ if test -n "$LIBGBM_LIBS"; then pkg_cv_LIBGBM_LIBS="$LIBGBM_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gbm >= 11.1.0\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gbm >= 11.1.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "gbm >= 11.1.0") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBGBM_LIBS=`$PKG_CONFIG --libs "gbm >= 11.1.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -25722,8 +23592,8 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -25740,14 +23610,14 @@ fi libgbm_avail=no elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } libgbm_avail=no else LIBGBM_CFLAGS=$pkg_cv_LIBGBM_CFLAGS LIBGBM_LIBS=$pkg_cv_LIBGBM_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } libgbm_avail=yes fi @@ -25757,49 +23627,54 @@ fi if test x$video_kmsdrm = xyes; then # Check whether --enable-kmsdrm-shared was given. -if test ${enable_kmsdrm_shared+y} -then : +if test "${enable_kmsdrm_shared+set}" = set; then : enableval=$enable_kmsdrm_shared; -else $as_nop +else enable_kmsdrm_shared=yes fi -printf "%s\n" "#define SDL_VIDEO_DRIVER_KMSDRM 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_KMSDRM 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/kmsdrm/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBDRM_CFLAGS $LIBGBM_CFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for kmsdrm dynamic loading support" >&5 -printf %s "checking for kmsdrm dynamic loading support... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kmsdrm dynamic loading support" >&5 +$as_echo_n "checking for kmsdrm dynamic loading support... " >&6; } kmsdrm_shared=no drm_lib=`find_lib "libdrm.so.*" "$LIBDRM_LIBS"` gbm_lib=`find_lib "libgbm.so.*" "$LIBGBM_LIBS"` if test x$have_loadso != xyes && \ test x$enable_kmsdrm_shared = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic kmsdrm loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic kmsdrm loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic kmsdrm loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic kmsdrm loading" >&2;} fi if test x$have_loadso = xyes && \ test x$enable_kmsdrm_shared = xyes && test x$drm_lib != x && test x$gbm_lib != x; then kmsdrm_shared=yes -printf "%s\n" "#define SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC \"$drm_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC "$drm_lib" +_ACEOF -printf "%s\n" "#define SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM \"$gbm_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM "$gbm_lib" +_ACEOF -printf "%s\n" "#define HAVE_KMSDRM_SHARED \"TRUE\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_KMSDRM_SHARED "TRUE" +_ACEOF SUMMARY_video="${SUMMARY_video} kmsdrm(dynamic)" else EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBDRM_LIBS $LIBGBM_LIBS" SUMMARY_video="${SUMMARY_video} kmsdrm" fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $kmsdrm_shared" >&5 -printf "%s\n" "$kmsdrm_shared" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $kmsdrm_shared" >&5 +$as_echo "$kmsdrm_shared" >&6; } if test x$kmsdrm_shared = xyes; then echo "-- dynamic libdrm -> $drm_lib" echo "-- dynamic libgbm -> $gbm_lib" @@ -25812,16 +23687,15 @@ printf "%s\n" "$kmsdrm_shared" >&6; } CheckDummyVideo() { # Check whether --enable-video-dummy was given. -if test ${enable_video_dummy+y} -then : +if test "${enable_video_dummy+set}" = set; then : enableval=$enable_video_dummy; -else $as_nop +else enable_video_dummy=yes fi if test x$enable_video_dummy = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_DUMMY 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_DUMMY 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/dummy/*.c" have_video=yes @@ -25832,16 +23706,15 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_DUMMY 1" >>confdefs.h CheckOffscreenVideo() { # Check whether --enable-video-offscreen was given. -if test ${enable_video_offscreen+y} -then : +if test "${enable_video_offscreen+set}" = set; then : enableval=$enable_video_offscreen; -else $as_nop +else enable_video_offscreen=yes fi if test x$enable_video_offscreen = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_OFFSCREEN 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_OFFSCREEN 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/offscreen/*.c" have_video=yes @@ -25853,7 +23726,7 @@ CheckQNXVideo() { if test x$enable_video = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_QNX 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_QNX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/qnx/*.c" have_video=yes @@ -25866,7 +23739,7 @@ CheckQNXAudio() { if test x$enable_audio = xyes; then -printf "%s\n" "#define SDL_AUDIO_DRIVER_QSA 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_QSA 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/qsa/*.c" have_audio=yes @@ -25876,10 +23749,9 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_QSA 1" >>confdefs.h } # Check whether --enable-video-opengl was given. -if test ${enable_video_opengl+y} -then : +if test "${enable_video_opengl+set}" = set; then : enableval=$enable_video_opengl; -else $as_nop +else enable_video_opengl=yes fi @@ -25887,8 +23759,8 @@ fi CheckGLX() { if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GLX support" >&5 -printf %s "checking for GLX support... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLX support" >&5 +$as_echo_n "checking for GLX support... " >&6; } video_opengl_glx=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -25896,52 +23768,48 @@ printf %s "checking for GLX support... " >&6; } #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : video_opengl_glx=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $video_opengl_glx" >&5 -printf "%s\n" "$video_opengl_glx" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengl_glx" >&5 +$as_echo "$video_opengl_glx" >&6; } if test x$video_opengl_glx = xyes; then -printf "%s\n" "#define SDL_VIDEO_OPENGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_OPENGL_GLX 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_GLX 1" >>confdefs.h fi fi } # Check whether --enable-video-opengles was given. -if test ${enable_video_opengles+y} -then : +if test "${enable_video_opengles+set}" = set; then : enableval=$enable_video_opengles; -else $as_nop +else enable_video_opengles=yes fi # Check whether --enable-video-opengles1 was given. -if test ${enable_video_opengles1+y} -then : +if test "${enable_video_opengles1+set}" = set; then : enableval=$enable_video_opengles1; -else $as_nop +else enable_video_opengles1=yes fi # Check whether --enable-video-opengles2 was given. -if test ${enable_video_opengles2+y} -then : +if test "${enable_video_opengles2+set}" = set; then : enableval=$enable_video_opengles2; -else $as_nop +else enable_video_opengles2=yes fi @@ -25949,8 +23817,8 @@ fi CheckEGL() { if test x$enable_video = xyes -a x$enable_video_opengl = xyes || test x$enable_video = xyes -a x$enable_video_opengles = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for EGL support" >&5 -printf %s "checking for EGL support... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EGL support" >&5 +$as_echo_n "checking for EGL support... " >&6; } video_opengl_egl=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -25963,23 +23831,22 @@ printf %s "checking for EGL support... " >&6; } #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : video_opengl_egl=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $video_opengl_egl" >&5 -printf "%s\n" "$video_opengl_egl" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengl_egl" >&5 +$as_echo "$video_opengl_egl" >&6; } if test x$video_opengl_egl = xyes; then -printf "%s\n" "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h fi fi @@ -25988,8 +23855,8 @@ printf "%s\n" "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h CheckOpenGL() { if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for OpenGL headers" >&5 -printf %s "checking for OpenGL headers... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL headers" >&5 +$as_echo_n "checking for OpenGL headers... " >&6; } video_opengl=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -25998,26 +23865,25 @@ printf %s "checking for OpenGL headers... " >&6; } #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : video_opengl=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $video_opengl" >&5 -printf "%s\n" "$video_opengl" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengl" >&5 +$as_echo "$video_opengl" >&6; } if test x$video_opengl = xyes; then -printf "%s\n" "#define SDL_VIDEO_OPENGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_RENDER_OGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_OGL 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} opengl" fi @@ -26028,8 +23894,8 @@ CheckOpenGLES() { if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then if test x$enable_video_opengles1 = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v1 headers" >&5 -printf %s "checking for OpenGL ES v1 headers... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v1 headers" >&5 +$as_echo_n "checking for OpenGL ES v1 headers... " >&6; } video_opengles_v1=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -26038,34 +23904,33 @@ printf %s "checking for OpenGL ES v1 headers... " >&6; } #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : video_opengles_v1=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v1" >&5 -printf "%s\n" "$video_opengles_v1" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v1" >&5 +$as_echo "$video_opengles_v1" >&6; } if test x$video_opengles_v1 = xyes; then -printf "%s\n" "#define SDL_VIDEO_OPENGL_ES 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_ES 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_RENDER_OGL_ES 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_OGL_ES 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} opengl_es1" fi fi if test x$enable_video_opengles2 = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5 -printf %s "checking for OpenGL ES v2 headers... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5 +$as_echo_n "checking for OpenGL ES v2 headers... " >&6; } video_opengles_v2=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -26074,26 +23939,25 @@ printf %s "checking for OpenGL ES v2 headers... " >&6; } #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : video_opengles_v2=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5 -printf "%s\n" "$video_opengles_v2" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5 +$as_echo "$video_opengles_v2" >&6; } if test x$video_opengles_v2 = xyes; then -printf "%s\n" "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} opengl_es2" fi @@ -26105,13 +23969,13 @@ CheckWINDOWSGL() { if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then -printf "%s\n" "#define SDL_VIDEO_OPENGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_OPENGL_WGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_WGL 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_RENDER_OGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_OGL 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} opengl" fi @@ -26121,8 +23985,8 @@ CheckWINDOWSGLES() { if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for EGL support" >&5 -printf %s "checking for EGL support... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EGL support" >&5 +$as_echo_n "checking for EGL support... " >&6; } video_opengl_egl=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -26130,32 +23994,31 @@ printf %s "checking for EGL support... " >&6; } #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : video_opengl_egl=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $video_opengl_egl" >&5 -printf "%s\n" "$video_opengl_egl" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengl_egl" >&5 +$as_echo "$video_opengl_egl" >&6; } if test x$video_opengl_egl = xyes; then -printf "%s\n" "#define SDL_VIDEO_OPENGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} opengl_es1" fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5 -printf %s "checking for OpenGL ES v2 headers... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5 +$as_echo_n "checking for OpenGL ES v2 headers... " >&6; } video_opengles_v2=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -26164,29 +24027,28 @@ printf %s "checking for OpenGL ES v2 headers... " >&6; } #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : video_opengles_v2=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5 -printf "%s\n" "$video_opengles_v2" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5 +$as_echo "$video_opengles_v2" >&6; } if test x$video_opengles_v2 = xyes; then -printf "%s\n" "#define SDL_VIDEO_OPENGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} opengl_es2" fi @@ -26197,13 +24059,13 @@ CheckHaikuGL() { if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then -printf "%s\n" "#define SDL_VIDEO_OPENGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_OPENGL_HAIKU 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_HAIKU 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_RENDER_OGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_OGL 1" >>confdefs.h EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL" SUMMARY_video="${SUMMARY_video} opengl" @@ -26214,13 +24076,13 @@ CheckMacGL() { if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then -printf "%s\n" "#define SDL_VIDEO_OPENGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_OPENGL_CGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_CGL 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_RENDER_OGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_OGL 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} opengl" fi @@ -26231,14 +24093,14 @@ CheckMacGLES() if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then video_opengl_egl=yes -printf "%s\n" "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h video_opengles_v2=yes -printf "%s\n" "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} opengl_es2" fi @@ -26247,8 +24109,8 @@ printf "%s\n" "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h CheckEmscriptenGLES() { if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for EGL support" >&5 -printf %s "checking for EGL support... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EGL support" >&5 +$as_echo_n "checking for EGL support... " >&6; } video_opengl_egl=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -26256,28 +24118,27 @@ printf %s "checking for EGL support... " >&6; } #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : video_opengl_egl=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $video_opengl_egl" >&5 -printf "%s\n" "$video_opengl_egl" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengl_egl" >&5 +$as_echo "$video_opengl_egl" >&6; } if test x$video_opengl_egl = xyes; then -printf "%s\n" "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5 -printf %s "checking for OpenGL ES v2 headers... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v2 headers" >&5 +$as_echo_n "checking for OpenGL ES v2 headers... " >&6; } video_opengles_v2=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -26286,26 +24147,25 @@ printf %s "checking for OpenGL ES v2 headers... " >&6; } #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : video_opengles_v2=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5 -printf "%s\n" "$video_opengles_v2" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5 +$as_echo "$video_opengles_v2" >&6; } if test x$video_opengles_v2 = xyes; then -printf "%s\n" "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} opengl_es2" fi @@ -26313,10 +24173,9 @@ printf "%s\n" "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h } # Check whether --enable-video-vulkan was given. -if test ${enable_video_vulkan+y} -then : +if test "${enable_video_vulkan+set}" = set; then : enableval=$enable_video_vulkan; -else $as_nop +else enable_video_vulkan=yes fi @@ -26334,20 +24193,19 @@ CheckVulkan() #endif int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : -else $as_nop +else enable_video_vulkan=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; *-*-darwin*) save_CFLAGS="$CFLAGS" @@ -26364,20 +24222,19 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext #endif int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : -else $as_nop +else enable_video_vulkan=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" ;; *) @@ -26386,18 +24243,18 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext if test x$enable_video_vulkan = xno; then # For reasons I am totally unable to see, I get an undefined macro error if # I put this in the AC_TRY_COMPILE. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Vulkan does not work on this configuration." >&5 -printf "%s\n" "$as_me: WARNING: Vulkan does not work on this configuration." >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Vulkan does not work on this configuration." >&5 +$as_echo "$as_me: WARNING: Vulkan does not work on this configuration." >&2;} fi fi if test x$have_loadso != xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Vulkan support is available, but disabled because there's no loadso." >&5 -printf "%s\n" "$as_me: WARNING: Vulkan support is available, but disabled because there's no loadso." >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Vulkan support is available, but disabled because there's no loadso." >&5 +$as_echo "$as_me: WARNING: Vulkan support is available, but disabled because there's no loadso." >&2;} enable_video_vulkan=no fi if test x$enable_video_vulkan = xyes; then -printf "%s\n" "#define SDL_VIDEO_VULKAN 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_VULKAN 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} vulkan" fi @@ -26405,8 +24262,8 @@ printf "%s\n" "#define SDL_VIDEO_VULKAN 1" >>confdefs.h CheckInputEvents() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Linux 2.4 unified input interface" >&5 -printf %s "checking for Linux 2.4 unified input interface... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux 2.4 unified input interface" >&5 +$as_echo_n "checking for Linux 2.4 unified input interface... " >&6; } use_input_events=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -26414,7 +24271,7 @@ printf %s "checking for Linux 2.4 unified input interface... " >&6; } #include int -main (void) +main () { #ifndef EVIOCGNAME @@ -26425,16 +24282,15 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : use_input_events=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $use_input_events" >&5 -printf "%s\n" "$use_input_events" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_input_events" >&5 +$as_echo "$use_input_events" >&6; } if test x$use_input_events = xyes; then -printf "%s\n" "#define SDL_INPUT_LINUXEV 1" >>confdefs.h +$as_echo "#define SDL_INPUT_LINUXEV 1" >>confdefs.h SUMMARY_input="${SUMMARY_input} linuxev" fi @@ -26442,8 +24298,8 @@ printf "%s\n" "#define SDL_INPUT_LINUXEV 1" >>confdefs.h CheckInputKD() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Linux kd.h" >&5 -printf %s "checking for Linux kd.h... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux kd.h" >&5 +$as_echo_n "checking for Linux kd.h... " >&6; } use_input_kd=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -26453,7 +24309,7 @@ printf %s "checking for Linux kd.h... " >&6; } #include int -main (void) +main () { struct kbentry kbe; @@ -26464,16 +24320,15 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : use_input_kd=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $use_input_kd" >&5 -printf "%s\n" "$use_input_kd" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_input_kd" >&5 +$as_echo "$use_input_kd" >&6; } if test x$use_input_kd = xyes; then -printf "%s\n" "#define SDL_INPUT_LINUXKD 1" >>confdefs.h +$as_echo "#define SDL_INPUT_LINUXKD 1" >>confdefs.h SUMMARY_input="${SUMMARY_input} linuxkd" fi @@ -26481,8 +24336,8 @@ printf "%s\n" "#define SDL_INPUT_LINUXKD 1" >>confdefs.h CheckInputKBIO() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for FreeBSD kbio.h" >&5 -printf %s "checking for FreeBSD kbio.h... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FreeBSD kbio.h" >&5 +$as_echo_n "checking for FreeBSD kbio.h... " >&6; } use_input_kbio=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -26491,7 +24346,7 @@ printf %s "checking for FreeBSD kbio.h... " >&6; } #include int -main (void) +main () { accentmap_t accTable; @@ -26501,16 +24356,15 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : use_input_kbio=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $use_input_kbio" >&5 -printf "%s\n" "$use_input_kbio" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_input_kbio" >&5 +$as_echo "$use_input_kbio" >&6; } if test x$use_input_kbio = xyes; then -printf "%s\n" "#define SDL_INPUT_FBSDKBIO 1" >>confdefs.h +$as_echo "#define SDL_INPUT_FBSDKBIO 1" >>confdefs.h SUMMARY_input="${SUMMARY_input} fbsdkbio" fi @@ -26518,8 +24372,8 @@ printf "%s\n" "#define SDL_INPUT_FBSDKBIO 1" >>confdefs.h CheckInputWSCONS() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for OpenBSD wscons" >&5 -printf %s "checking for OpenBSD wscons... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenBSD wscons" >&5 +$as_echo_n "checking for OpenBSD wscons... " >&6; } use_input_wscons=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -26531,7 +24385,7 @@ printf %s "checking for OpenBSD wscons... " >&6; } #include int -main (void) +main () { struct wskbd_map_data data; @@ -26541,16 +24395,15 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : use_input_wscons=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $use_input_wscons" >&5 -printf "%s\n" "$use_input_wscons" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_input_wscons" >&5 +$as_echo "$use_input_wscons" >&6; } if test x$use_input_wscons = xyes; then -printf "%s\n" "#define SDL_INPUT_WSCONS 1" >>confdefs.h +$as_echo "#define SDL_INPUT_WSCONS 1" >>confdefs.h SUMMARY_input="${SUMMARY_input} wscons" fi @@ -26559,32 +24412,33 @@ printf "%s\n" "#define SDL_INPUT_WSCONS 1" >>confdefs.h CheckLibUDev() { # Check whether --enable-libudev was given. -if test ${enable_libudev+y} -then : +if test "${enable_libudev+set}" = set; then : enableval=$enable_libudev; -else $as_nop +else enable_libudev=yes fi if test x$enable_libudev = xyes; then - ac_fn_c_check_header_compile "$LINENO" "libudev.h" "ac_cv_header_libudev_h" "$ac_includes_default" -if test "x$ac_cv_header_libudev_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "libudev.h" "ac_cv_header_libudev_h" "$ac_includes_default" +if test "x$ac_cv_header_libudev_h" = xyes; then : have_libudev_h_hdr=yes -else $as_nop +else have_libudev_h_hdr=no fi + if test x$have_libudev_h_hdr = xyes; then -printf "%s\n" "#define HAVE_LIBUDEV_H 1" >>confdefs.h +$as_echo "#define HAVE_LIBUDEV_H 1" >>confdefs.h udev_lib=`find_lib "libudev.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'` if test x$udev_lib != x; then echo "-- dynamic udev -> $udev_lib" -printf "%s\n" "#define SDL_UDEV_DYNAMIC \"$udev_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_UDEV_DYNAMIC "$udev_lib" +_ACEOF fi fi @@ -26594,27 +24448,26 @@ printf "%s\n" "#define SDL_UDEV_DYNAMIC \"$udev_lib\"" >>confdefs.h CheckDBus() { # Check whether --enable-dbus was given. -if test ${enable_dbus+y} -then : +if test "${enable_dbus+set}" = set; then : enableval=$enable_dbus; -else $as_nop +else enable_dbus=yes fi if test x$enable_dbus = xyes; then pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dbus-1" >&5 -printf %s "checking for dbus-1... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dbus-1" >&5 +$as_echo_n "checking for dbus-1... " >&6; } if test -n "$DBUS_CFLAGS"; then pkg_cv_DBUS_CFLAGS="$DBUS_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1\""; } >&5 ($PKG_CONFIG --exists --print-errors "dbus-1") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_DBUS_CFLAGS=`$PKG_CONFIG --cflags "dbus-1" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -26628,10 +24481,10 @@ if test -n "$DBUS_LIBS"; then pkg_cv_DBUS_LIBS="$DBUS_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"dbus-1\""; } >&5 ($PKG_CONFIG --exists --print-errors "dbus-1") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_DBUS_LIBS=`$PKG_CONFIG --libs "dbus-1" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -26645,8 +24498,8 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -26663,30 +24516,30 @@ fi have_dbus=no elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } have_dbus=no else DBUS_CFLAGS=$pkg_cv_DBUS_CFLAGS DBUS_LIBS=$pkg_cv_DBUS_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } have_dbus=yes fi save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$save_CPPFLAGS $DBUS_CFLAGS" - ac_fn_c_check_header_compile "$LINENO" "dbus/dbus.h" "ac_cv_header_dbus_dbus_h" "$ac_includes_default" -if test "x$ac_cv_header_dbus_dbus_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "dbus/dbus.h" "ac_cv_header_dbus_dbus_h" "$ac_includes_default" +if test "x$ac_cv_header_dbus_dbus_h" = xyes; then : have_dbus_dbus_h_hdr=yes -else $as_nop +else have_dbus_dbus_h_hdr=no fi + CPPFLAGS="$save_CPPFLAGS" if test x$have_dbus_dbus_h_hdr = xyes; then -printf "%s\n" "#define HAVE_DBUS_DBUS_H 1" >>confdefs.h +$as_echo "#define HAVE_DBUS_DBUS_H 1" >>confdefs.h EXTRA_CFLAGS="$EXTRA_CFLAGS $DBUS_CFLAGS" SOURCES="$SOURCES $srcdir/src/core/linux/SDL_dbus.c" @@ -26697,16 +24550,15 @@ printf "%s\n" "#define HAVE_DBUS_DBUS_H 1" >>confdefs.h CheckIME() { # Check whether --enable-ime was given. -if test ${enable_ime+y} -then : +if test "${enable_ime+set}" = set; then : enableval=$enable_ime; -else $as_nop +else enable_ime=yes fi if test x$enable_ime = xyes; then -printf "%s\n" "#define SDL_USE_IME 1" >>confdefs.h +$as_echo "#define SDL_USE_IME 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/core/linux/SDL_ime.c" fi @@ -26719,37 +24571,43 @@ CheckInotify() *-*-freebsd*|*-*dragonfly*) LIBS="$LIBS -linotify" ;; esac - for ac_header in sys/inotify.h + for ac_header in sys/inotify.h do : - ac_fn_c_check_header_compile "$LINENO" "sys/inotify.h" "ac_cv_header_sys_inotify_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_inotify_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_INOTIFY_H 1" >>confdefs.h + ac_fn_c_check_header_mongrel "$LINENO" "sys/inotify.h" "ac_cv_header_sys_inotify_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_inotify_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_INOTIFY_H 1 +_ACEOF have_inotify_inotify_h_hdr=yes fi done - for ac_func in inotify_init + for ac_func in inotify_init do : ac_fn_c_check_func "$LINENO" "inotify_init" "ac_cv_func_inotify_init" -if test "x$ac_cv_func_inotify_init" = xyes -then : - printf "%s\n" "#define HAVE_INOTIFY_INIT 1" >>confdefs.h +if test "x$ac_cv_func_inotify_init" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_INOTIFY_INIT 1 +_ACEOF have_inotify=yes fi - done - ac_fn_c_check_func "$LINENO" "inotify_init1" "ac_cv_func_inotify_init1" -if test "x$ac_cv_func_inotify_init1" = xyes -then : - printf "%s\n" "#define HAVE_INOTIFY_INIT1 1" >>confdefs.h + + for ac_func in inotify_init1 +do : + ac_fn_c_check_func "$LINENO" "inotify_init1" "ac_cv_func_inotify_init1" +if test "x$ac_cv_func_inotify_init1" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_INOTIFY_INIT1 1 +_ACEOF fi +done if test x$have_inotify_inotify_h_hdr = xyes -a x$have_inotify = xyes; then -printf "%s\n" "#define HAVE_INOTIFY 1" >>confdefs.h +$as_echo "#define HAVE_INOTIFY 1" >>confdefs.h case "$host" in *-*-freebsd*|*-*-dragonfly*) @@ -26763,27 +24621,26 @@ printf "%s\n" "#define HAVE_INOTIFY 1" >>confdefs.h CheckIBus() { # Check whether --enable-ibus was given. -if test ${enable_ibus+y} -then : +if test "${enable_ibus+set}" = set; then : enableval=$enable_ibus; -else $as_nop +else enable_ibus=yes fi if test x$enable_ibus = xyes; then pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ibus-1.0" >&5 -printf %s "checking for ibus-1.0... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ibus-1.0" >&5 +$as_echo_n "checking for ibus-1.0... " >&6; } if test -n "$IBUS_CFLAGS"; then pkg_cv_IBUS_CFLAGS="$IBUS_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ibus-1.0\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ibus-1.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "ibus-1.0") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_IBUS_CFLAGS=`$PKG_CONFIG --cflags "ibus-1.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -26797,10 +24654,10 @@ if test -n "$IBUS_LIBS"; then pkg_cv_IBUS_LIBS="$IBUS_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ibus-1.0\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ibus-1.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "ibus-1.0") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_IBUS_LIBS=`$PKG_CONFIG --libs "ibus-1.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -26814,8 +24671,8 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -26832,43 +24689,43 @@ fi have_ibus=no elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } have_ibus=no else IBUS_CFLAGS=$pkg_cv_IBUS_CFLAGS IBUS_LIBS=$pkg_cv_IBUS_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } have_ibus=yes fi save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$save_CPPFLAGS $IBUS_CFLAGS" - ac_fn_c_check_header_compile "$LINENO" "ibus-1.0/ibus.h" "ac_cv_header_ibus_1_0_ibus_h" "$ac_includes_default" -if test "x$ac_cv_header_ibus_1_0_ibus_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "ibus-1.0/ibus.h" "ac_cv_header_ibus_1_0_ibus_h" "$ac_includes_default" +if test "x$ac_cv_header_ibus_1_0_ibus_h" = xyes; then : have_ibus_ibus_h_hdr=yes -else $as_nop +else have_ibus_ibus_h_hdr=no fi + CPPFLAGS="$save_CPPFLAGS" if test x$have_ibus_ibus_h_hdr = xyes; then if test x$enable_ime != xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: IME support is required for IBus." >&5 -printf "%s\n" "$as_me: WARNING: IME support is required for IBus." >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: IME support is required for IBus." >&5 +$as_echo "$as_me: WARNING: IME support is required for IBus." >&2;} have_ibus_ibus_h_hdr=no elif test x$enable_dbus != xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: DBus support is required for IBus." >&5 -printf "%s\n" "$as_me: WARNING: DBus support is required for IBus." >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: DBus support is required for IBus." >&5 +$as_echo "$as_me: WARNING: DBus support is required for IBus." >&2;} have_ibus_ibus_h_hdr=no elif test x$have_inotify_inotify_h_hdr != xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: INotify support is required for IBus." >&5 -printf "%s\n" "$as_me: WARNING: INotify support is required for IBus." >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: INotify support is required for IBus." >&5 +$as_echo "$as_me: WARNING: INotify support is required for IBus." >&2;} have_ibus_ibus_h_hdr=no else -printf "%s\n" "#define HAVE_IBUS_IBUS_H 1" >>confdefs.h +$as_echo "#define HAVE_IBUS_IBUS_H 1" >>confdefs.h EXTRA_CFLAGS="$EXTRA_CFLAGS $IBUS_CFLAGS" SOURCES="$SOURCES $srcdir/src/core/linux/SDL_ibus.c" @@ -26880,42 +24737,40 @@ printf "%s\n" "#define HAVE_IBUS_IBUS_H 1" >>confdefs.h CheckFcitx() { # Check whether --enable-fcitx was given. -if test ${enable_fcitx+y} -then : +if test "${enable_fcitx+set}" = set; then : enableval=$enable_fcitx; -else $as_nop +else enable_fcitx=yes fi if test x$enable_fcitx = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fcitx support" >&5 -printf %s "checking for fcitx support... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fcitx support" >&5 +$as_echo_n "checking for fcitx support... " >&6; } have_fcitx=no if test x$enable_ime != xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: IME support is required for fcitx." >&5 -printf "%s\n" "$as_me: WARNING: IME support is required for fcitx." >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: IME support is required for fcitx." >&5 +$as_echo "$as_me: WARNING: IME support is required for fcitx." >&2;} elif test x$have_dbus_dbus_h_hdr != xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: DBus support is required for fcitx." >&5 -printf "%s\n" "$as_me: WARNING: DBus support is required for fcitx." >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: DBus support is required for fcitx." >&5 +$as_echo "$as_me: WARNING: DBus support is required for fcitx." >&2;} else have_fcitx=yes -printf "%s\n" "#define HAVE_FCITX 1" >>confdefs.h +$as_echo "#define HAVE_FCITX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/core/linux/SDL_fcitx.c" fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_fcitx" >&5 -printf "%s\n" "$have_fcitx" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_fcitx" >&5 +$as_echo "$have_fcitx" >&6; } fi } CheckJoystickMFI() { # Check whether --enable-joystick-mfi was given. -if test ${enable_joystick_mfi+y} -then : +if test "${enable_joystick_mfi+set}" = set; then : enableval=$enable_joystick_mfi; -else $as_nop +else enable_joystick_mfi=yes fi @@ -26925,8 +24780,8 @@ fi save_LDFLAGS="$LDFLAGS" CFLAGS="$CFLAGS -x objective-c -fobjc-weak" LDFLAGS="$LDFLAGS -Wl,-weak_framework,CoreHaptics -Wl,-weak_framework,GameController" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GameController framework" >&5 -printf %s "checking for GameController framework... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GameController framework" >&5 +$as_echo_n "checking for GameController framework... " >&6; } enable_joystick_mfi=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -26936,7 +24791,7 @@ printf %s "checking for GameController framework... " >&6; } #import int -main (void) +main () { #if MAC_OS_X_VERSION_MIN_REQUIRED < 1080 @@ -26950,20 +24805,19 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : enable_joystick_mfi=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext CFLAGS="$save_CFLAGS" LDFLAGS="$save_LDFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_joystick_mfi" >&5 -printf "%s\n" "$enable_joystick_mfi" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_joystick_mfi" >&5 +$as_echo "$enable_joystick_mfi" >&6; } if test x$enable_joystick_mfi = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_MFI 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_MFI 1" >>confdefs.h EXTRA_CFLAGS="$EXTRA_CFLAGS -fobjc-weak -Wno-unused-command-line-argument" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-weak_framework,CoreHaptics -Wl,-weak_framework,GameController" @@ -26985,18 +24839,16 @@ CheckPTHREAD() esac # Check whether --enable-pthreads was given. -if test ${enable_pthreads+y} -then : +if test "${enable_pthreads+set}" = set; then : enableval=$enable_pthreads; -else $as_nop +else enable_pthreads=maybe fi # Check whether --enable-pthread-sem was given. -if test ${enable_pthread_sem+y} -then : +if test "${enable_pthread_sem+set}" = set; then : enableval=$enable_pthread_sem; -else $as_nop +else enable_pthread_sem=maybe fi @@ -27088,8 +24940,8 @@ fi # Add the pthread compiler flags and libraries CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib" # Check to see if we have pthread support on this system - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthreads" >&5 -printf %s "checking for pthreads... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthreads" >&5 +$as_echo_n "checking for pthreads... " >&6; } use_pthreads=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -27097,7 +24949,7 @@ printf %s "checking for pthreads... " >&6; } #include int -main (void) +main () { pthread_attr_t type; @@ -27107,21 +24959,20 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : use_pthreads=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $use_pthreads" >&5 -printf "%s\n" "$use_pthreads" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_pthreads" >&5 +$as_echo "$use_pthreads" >&6; } # Restore the compiler flags and libraries CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs" # Do futher testing if we have pthread support... if test x$use_pthreads = xyes; then -printf "%s\n" "#define SDL_THREAD_PTHREAD 1" >>confdefs.h +$as_echo "#define SDL_THREAD_PTHREAD 1" >>confdefs.h EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags" EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib" @@ -27133,8 +24984,8 @@ printf "%s\n" "#define SDL_THREAD_PTHREAD 1" >>confdefs.h CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib" # Check to see if recursive mutexes are available - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for recursive mutexes" >&5 -printf %s "checking for recursive mutexes... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for recursive mutexes" >&5 +$as_echo_n "checking for recursive mutexes... " >&6; } has_recursive_mutexes=no if test x$has_recursive_mutexes = xno; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -27144,7 +24995,7 @@ printf %s "checking for recursive mutexes... " >&6; } #include int -main (void) +main () { pthread_mutexattr_t attr; @@ -27154,16 +25005,15 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : has_recursive_mutexes=yes -printf "%s\n" "#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1" >>confdefs.h +$as_echo "#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1" >>confdefs.h fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test x$has_recursive_mutexes = xno; then @@ -27174,7 +25024,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ #include int -main (void) +main () { pthread_mutexattr_t attr; @@ -27184,25 +25034,24 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : has_recursive_mutexes=yes -printf "%s\n" "#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1" >>confdefs.h +$as_echo "#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1" >>confdefs.h fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $has_recursive_mutexes" >&5 -printf "%s\n" "$has_recursive_mutexes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_recursive_mutexes" >&5 +$as_echo "$has_recursive_mutexes" >&6; } # Check to see if pthread semaphore support is missing if test x$enable_pthread_sem = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread semaphores" >&5 -printf %s "checking for pthread semaphores... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread semaphores" >&5 +$as_echo_n "checking for pthread semaphores... " >&6; } have_pthread_sem=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -27211,24 +25060,23 @@ printf %s "checking for pthread semaphores... " >&6; } #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_pthread_sem=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_pthread_sem" >&5 -printf "%s\n" "$have_pthread_sem" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_pthread_sem" >&5 +$as_echo "$have_pthread_sem" >&6; } fi if test x$have_pthread_sem = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sem_timedwait" >&5 -printf %s "checking for sem_timedwait... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sem_timedwait" >&5 +$as_echo_n "checking for sem_timedwait... " >&6; } have_sem_timedwait=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -27237,7 +25085,7 @@ printf %s "checking for sem_timedwait... " >&6; } #include int -main (void) +main () { sem_timedwait(NULL, NULL); @@ -27246,106 +25094,109 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : have_sem_timedwait=yes -printf "%s\n" "#define HAVE_SEM_TIMEDWAIT 1" >>confdefs.h +$as_echo "#define HAVE_SEM_TIMEDWAIT 1" >>confdefs.h fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_sem_timedwait" >&5 -printf "%s\n" "$have_sem_timedwait" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sem_timedwait" >&5 +$as_echo "$have_sem_timedwait" >&6; } fi ac_fn_c_check_header_compile "$LINENO" "pthread_np.h" "ac_cv_header_pthread_np_h" " #include " -if test "x$ac_cv_header_pthread_np_h" = xyes -then : +if test "x$ac_cv_header_pthread_np_h" = xyes; then : have_pthread_np_h=yes -else $as_nop +else have_pthread_np_h=no fi + if test x$have_pthread_np_h = xyes; then -printf "%s\n" "#define HAVE_PTHREAD_NP_H 1" >>confdefs.h +$as_echo "#define HAVE_PTHREAD_NP_H 1" >>confdefs.h fi # Check to see if pthread naming is available - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_setname_np" >&5 -printf %s "checking for pthread_setname_np... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_setname_np" >&5 +$as_echo_n "checking for pthread_setname_np... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char pthread_setname_np (); int -main (void) +main () { return pthread_setname_np (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : has_pthread_setname_np=yes -printf "%s\n" "#define HAVE_PTHREAD_SETNAME_NP 1" >>confdefs.h +$as_echo "#define HAVE_PTHREAD_SETNAME_NP 1" >>confdefs.h -else $as_nop +else has_pthread_setname_np=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $has_pthread_setname_np" >&5 -printf "%s\n" "$has_pthread_setname_np" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_pthread_setname_np" >&5 +$as_echo "$has_pthread_setname_np" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_set_name_np" >&5 -printf %s "checking for pthread_set_name_np... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_set_name_np" >&5 +$as_echo_n "checking for pthread_set_name_np... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char pthread_set_name_np (); int -main (void) +main () { return pthread_set_name_np (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : has_pthread_set_name_np=yes -printf "%s\n" "#define HAVE_PTHREAD_SET_NAME_NP 1" >>confdefs.h +$as_echo "#define HAVE_PTHREAD_SET_NAME_NP 1" >>confdefs.h -else $as_nop +else has_pthread_set_name_np=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $has_pthread_set_name_np" >&5 -printf "%s\n" "$has_pthread_set_name_np" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_pthread_set_name_np" >&5 +$as_echo "$has_pthread_set_name_np" >&6; } # Restore the compiler flags and libraries CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs" @@ -27379,8 +25230,8 @@ printf "%s\n" "$has_pthread_set_name_np" >&6; } CheckWINDOWS() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking Windows compiler" >&5 -printf %s "checking Windows compiler... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Windows compiler" >&5 +$as_echo_n "checking Windows compiler... " >&6; } have_win32_gcc=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -27388,28 +25239,27 @@ printf %s "checking Windows compiler... " >&6; } #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_win32_gcc=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_win32_gcc" >&5 -printf "%s\n" "$have_win32_gcc" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_win32_gcc" >&5 +$as_echo "$have_win32_gcc" >&6; } if test x$have_win32_gcc != xyes; then as_fn_error $? " *** Your compiler ($CC) does not produce Windows executables! " "$LINENO" 5 fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking Windows CE" >&5 -printf %s "checking Windows CE... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Windows CE" >&5 +$as_echo_n "checking Windows CE... " >&6; } have_wince=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -27419,15 +25269,14 @@ printf %s "checking Windows CE... " >&6; } #endif int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_wince=yes as_fn_error $? " @@ -27435,69 +25284,68 @@ then : " "$LINENO" 5 fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_wince" >&5 -printf "%s\n" "$have_wince" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_wince" >&5 +$as_echo "$have_wince" >&6; } # headers needed elsewhere - ac_fn_c_check_header_compile "$LINENO" "tpcshrd.h" "ac_cv_header_tpcshrd_h" "$ac_includes_default" -if test "x$ac_cv_header_tpcshrd_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "tpcshrd.h" "ac_cv_header_tpcshrd_h" "$ac_includes_default" +if test "x$ac_cv_header_tpcshrd_h" = xyes; then : have_tpcshrd_h=yes fi + if test x$have_tpcshrd_h = xyes; then -printf "%s\n" "#define HAVE_TPCSHRD_H 1" >>confdefs.h +$as_echo "#define HAVE_TPCSHRD_H 1" >>confdefs.h fi - ac_fn_c_check_header_compile "$LINENO" "roapi.h" "ac_cv_header_roapi_h" "$ac_includes_default" -if test "x$ac_cv_header_roapi_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "roapi.h" "ac_cv_header_roapi_h" "$ac_includes_default" +if test "x$ac_cv_header_roapi_h" = xyes; then : have_roapi_h=yes fi + if test x$have_roapi_h = xyes; then -printf "%s\n" "#define HAVE_ROAPI_H 1" >>confdefs.h +$as_echo "#define HAVE_ROAPI_H 1" >>confdefs.h fi - ac_fn_c_check_header_compile "$LINENO" "shellscalingapi.h" "ac_cv_header_shellscalingapi_h" "$ac_includes_default" -if test "x$ac_cv_header_shellscalingapi_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "shellscalingapi.h" "ac_cv_header_shellscalingapi_h" "$ac_includes_default" +if test "x$ac_cv_header_shellscalingapi_h" = xyes; then : have_shellscalingapi_h=yes fi + if test x$shellscalingapi_h = xyes; then -printf "%s\n" "#define HAVE_SHELLSCALINGAPI_H 1" >>confdefs.h +$as_echo "#define HAVE_SHELLSCALINGAPI_H 1" >>confdefs.h fi } CheckOS2() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking OS/2 compiler" >&5 -printf %s "checking OS/2 compiler... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking OS/2 compiler" >&5 +$as_echo_n "checking OS/2 compiler... " >&6; } have_os2_gcc=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_os2_gcc=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_os2_gcc" >&5 -printf "%s\n" "$have_os2_gcc" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_os2_gcc" >&5 +$as_echo "$have_os2_gcc" >&6; } if test x$have_os2_gcc != xyes; then as_fn_error $? " *** Your compiler ($CC) does not produce OS/2 executables! @@ -27508,28 +25356,27 @@ printf "%s\n" "$have_os2_gcc" >&6; } CheckDIRECTX() { # Check whether --enable-directx was given. -if test ${enable_directx+y} -then : +if test "${enable_directx+set}" = set; then : enableval=$enable_directx; -else $as_nop +else enable_directx=yes fi if test x$enable_directx = xyes; then - ac_fn_c_check_header_compile "$LINENO" "d3d9.h" "ac_cv_header_d3d9_h" "$ac_includes_default" -if test "x$ac_cv_header_d3d9_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "d3d9.h" "ac_cv_header_d3d9_h" "$ac_includes_default" +if test "x$ac_cv_header_d3d9_h" = xyes; then : have_d3d=yes fi - ac_fn_c_check_header_compile "$LINENO" "d3d11_1.h" "ac_cv_header_d3d11_1_h" "$ac_includes_default" -if test "x$ac_cv_header_d3d11_1_h" = xyes -then : + + ac_fn_c_check_header_mongrel "$LINENO" "d3d11_1.h" "ac_cv_header_d3d11_1_h" "$ac_includes_default" +if test "x$ac_cv_header_d3d11_1_h" = xyes; then : have_d3d11=yes fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for d3d12 Windows SDK version" >&5 -printf %s "checking for d3d12 Windows SDK version... " >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for d3d12 Windows SDK version" >&5 +$as_echo_n "checking for d3d12 Windows SDK version... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -27542,65 +25389,64 @@ asdf #endif int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_d3d12=yes -else $as_nop +else have_d3d12=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_d3d12" >&5 -printf "%s\n" "$have_d3d12" >&6; } - ac_fn_c_check_header_compile "$LINENO" "ddraw.h" "ac_cv_header_ddraw_h" "$ac_includes_default" -if test "x$ac_cv_header_ddraw_h" = xyes -then : +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_d3d12" >&5 +$as_echo "$have_d3d12" >&6; } + ac_fn_c_check_header_mongrel "$LINENO" "ddraw.h" "ac_cv_header_ddraw_h" "$ac_includes_default" +if test "x$ac_cv_header_ddraw_h" = xyes; then : have_ddraw=yes fi - ac_fn_c_check_header_compile "$LINENO" "dsound.h" "ac_cv_header_dsound_h" "$ac_includes_default" -if test "x$ac_cv_header_dsound_h" = xyes -then : + + ac_fn_c_check_header_mongrel "$LINENO" "dsound.h" "ac_cv_header_dsound_h" "$ac_includes_default" +if test "x$ac_cv_header_dsound_h" = xyes; then : have_dsound=yes fi - ac_fn_c_check_header_compile "$LINENO" "dinput.h" "ac_cv_header_dinput_h" "$ac_includes_default" -if test "x$ac_cv_header_dinput_h" = xyes -then : + + ac_fn_c_check_header_mongrel "$LINENO" "dinput.h" "ac_cv_header_dinput_h" "$ac_includes_default" +if test "x$ac_cv_header_dinput_h" = xyes; then : have_dinput=yes fi - ac_fn_c_check_header_compile "$LINENO" "dxgi.h" "ac_cv_header_dxgi_h" "$ac_includes_default" -if test "x$ac_cv_header_dxgi_h" = xyes -then : + + ac_fn_c_check_header_mongrel "$LINENO" "dxgi.h" "ac_cv_header_dxgi_h" "$ac_includes_default" +if test "x$ac_cv_header_dxgi_h" = xyes; then : have_dxgi=yes fi + if test x$have_ddraw = xyes; then -printf "%s\n" "#define HAVE_DDRAW_H 1" >>confdefs.h +$as_echo "#define HAVE_DDRAW_H 1" >>confdefs.h fi if test x$have_dinput = xyes; then -printf "%s\n" "#define HAVE_DINPUT_H 1" >>confdefs.h +$as_echo "#define HAVE_DINPUT_H 1" >>confdefs.h fi if test x$have_dsound = xyes; then -printf "%s\n" "#define HAVE_DSOUND_H 1" >>confdefs.h +$as_echo "#define HAVE_DSOUND_H 1" >>confdefs.h fi if test x$have_dxgi = xyes; then -printf "%s\n" "#define HAVE_DXGI_H 1" >>confdefs.h +$as_echo "#define HAVE_DXGI_H 1" >>confdefs.h fi @@ -27614,24 +25460,23 @@ printf "%s\n" "#define HAVE_DXGI_H 1" >>confdefs.h fi # Check whether --enable-xinput was given. -if test ${enable_xinput+y} -then : +if test "${enable_xinput+set}" = set; then : enableval=$enable_xinput; -else $as_nop +else enable_xinput=yes fi if test x$enable_xinput = xyes; then have_xinput_gamepadex=no have_xinput_stateex=no - ac_fn_c_check_header_compile "$LINENO" "xinput.h" "ac_cv_header_xinput_h" "$ac_includes_default" -if test "x$ac_cv_header_xinput_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "xinput.h" "ac_cv_header_xinput_h" "$ac_includes_default" +if test "x$ac_cv_header_xinput_h" = xyes; then : have_xinput=yes fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct XINPUT_GAMEPAD_EX" >&5 -printf %s "checking for struct XINPUT_GAMEPAD_EX... " >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct XINPUT_GAMEPAD_EX" >&5 +$as_echo_n "checking for struct XINPUT_GAMEPAD_EX... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -27640,22 +25485,21 @@ printf %s "checking for struct XINPUT_GAMEPAD_EX... " >&6; } XINPUT_GAMEPAD_EX x1; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_xinput_gamepadex=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_xinput_gamepadex" >&5 -printf "%s\n" "$have_xinput_gamepadex" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct XINPUT_STATE_EX" >&5 -printf %s "checking for struct XINPUT_STATE_EX... " >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_xinput_gamepadex" >&5 +$as_echo "$have_xinput_gamepadex" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct XINPUT_STATE_EX" >&5 +$as_echo_n "checking for struct XINPUT_STATE_EX... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -27664,40 +25508,39 @@ printf %s "checking for struct XINPUT_STATE_EX... " >&6; } XINPUT_STATE_EX s1; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_xinput_stateex=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_xinput_stateex" >&5 -printf "%s\n" "$have_xinput_stateex" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_xinput_stateex" >&5 +$as_echo "$have_xinput_stateex" >&6; } if test x$have_xinput = xyes; then -printf "%s\n" "#define HAVE_XINPUT_H 1" >>confdefs.h +$as_echo "#define HAVE_XINPUT_H 1" >>confdefs.h fi if test x$have_xinput_gamepadex = xyes; then -printf "%s\n" "#define HAVE_XINPUT_GAMEPAD_EX 1" >>confdefs.h +$as_echo "#define HAVE_XINPUT_GAMEPAD_EX 1" >>confdefs.h fi if test x$have_xinput_stateex = xyes; then -printf "%s\n" "#define HAVE_XINPUT_STATE_EX 1" >>confdefs.h +$as_echo "#define HAVE_XINPUT_STATE_EX 1" >>confdefs.h fi fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for windows.gaming.input.h" >&5 -printf %s "checking for windows.gaming.input.h... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for windows.gaming.input.h" >&5 +$as_echo_n "checking for windows.gaming.input.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -27706,59 +25549,57 @@ printf %s "checking for windows.gaming.input.h... " >&6; } __x_ABI_CWindows_CGaming_CInput_CIGamepadStatics2 *s2; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_wgi=yes -else $as_nop +else have_wgi=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_wgi" >&5 -printf "%s\n" "$have_wgi" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_wgi" >&5 +$as_echo "$have_wgi" >&6; } if test x$have_wgi = xyes; then -printf "%s\n" "#define HAVE_WINDOWS_GAMING_INPUT_H 1" >>confdefs.h +$as_echo "#define HAVE_WINDOWS_GAMING_INPUT_H 1" >>confdefs.h fi - ac_fn_c_check_header_compile "$LINENO" "mmdeviceapi.h" "ac_cv_header_mmdeviceapi_h" "$ac_includes_default" -if test "x$ac_cv_header_mmdeviceapi_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "mmdeviceapi.h" "ac_cv_header_mmdeviceapi_h" "$ac_includes_default" +if test "x$ac_cv_header_mmdeviceapi_h" = xyes; then : have_wasapi=yes fi + if test x$have_wasapi = xyes; then -printf "%s\n" "#define HAVE_MMDEVICEAPI_H 1" >>confdefs.h +$as_echo "#define HAVE_MMDEVICEAPI_H 1" >>confdefs.h fi - ac_fn_c_check_header_compile "$LINENO" "audioclient.h" "ac_cv_header_audioclient_h" "$ac_includes_default" -if test "x$ac_cv_header_audioclient_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "audioclient.h" "ac_cv_header_audioclient_h" "$ac_includes_default" +if test "x$ac_cv_header_audioclient_h" = xyes; then : -else $as_nop +else have_wasapi=no fi + if test x$have_wasapi = xyes; then -printf "%s\n" "#define HAVE_AUDIOCLIENT_H 1" >>confdefs.h +$as_echo "#define HAVE_AUDIOCLIENT_H 1" >>confdefs.h fi # Check whether --enable-wasapi was given. -if test ${enable_wasapi+y} -then : +if test "${enable_wasapi+set}" = set; then : enableval=$enable_wasapi; -else $as_nop +else enable_wasapi=yes fi @@ -27767,25 +25608,24 @@ fi CheckDLOPEN() { -printf "%s\n" "#define DYNAPI_NEEDS_DLOPEN 1" >>confdefs.h +$as_echo "#define DYNAPI_NEEDS_DLOPEN 1" >>confdefs.h - ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default" -if test "x$ac_cv_header_dlfcn_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default" +if test "x$ac_cv_header_dlfcn_h" = xyes; then : have_dlfcn_h=yes -else $as_nop +else have_dlfcn_h=no fi + have_dlopen=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lc" >&5 -printf %s "checking for dlopen in -lc... " >&6; } -if test ${ac_cv_lib_c_dlopen+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lc" >&5 +$as_echo_n "checking for dlopen in -lc... " >&6; } +if ${ac_cv_lib_c_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lc $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -27794,37 +25634,37 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char dlopen (); int -main (void) +main () { return dlopen (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_c_dlopen=yes -else $as_nop +else ac_cv_lib_c_dlopen=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_dlopen" >&5 -printf "%s\n" "$ac_cv_lib_c_dlopen" >&6; } -if test "x$ac_cv_lib_c_dlopen" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_dlopen" >&5 +$as_echo "$ac_cv_lib_c_dlopen" >&6; } +if test "x$ac_cv_lib_c_dlopen" = xyes; then : have_dlopen=yes -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -printf %s "checking for dlopen in -ldl... " >&6; } -if test ${ac_cv_lib_dl_dlopen+y} -then : - printf %s "(cached) " >&6 -else $as_nop +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if ${ac_cv_lib_dl_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -27833,46 +25673,47 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char dlopen (); int -main (void) +main () { return dlopen (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes -else $as_nop +else ac_cv_lib_dl_dlopen=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : have_dlopen=yes; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl" fi fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen" >&5 -printf %s "checking for dlopen... " >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_dlopen" >&5 -printf "%s\n" "$have_dlopen" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen" >&5 +$as_echo_n "checking for dlopen... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_dlopen" >&5 +$as_echo "$have_dlopen" >&6; } if test x$have_dlfcn_h = xyes -a x$have_dlopen = xyes; then -printf "%s\n" "#define HAVE_DLOPEN 1" >>confdefs.h +$as_echo "#define HAVE_DLOPEN 1" >>confdefs.h if test x$enable_loadso = xyes; then -printf "%s\n" "#define SDL_LOADSO_DLOPEN 1" >>confdefs.h +$as_echo "#define SDL_LOADSO_DLOPEN 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c" have_loadso=yes @@ -27882,8 +25723,8 @@ printf "%s\n" "#define SDL_LOADSO_DLOPEN 1" >>confdefs.h CheckO_CLOEXEC() { - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for O_CLOEXEC" >&5 -printf %s "checking for O_CLOEXEC... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for O_CLOEXEC" >&5 +$as_echo_n "checking for O_CLOEXEC... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -27891,25 +25732,24 @@ printf %s "checking for O_CLOEXEC... " >&6; } int flag = O_CLOEXEC; int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_o_cloexec=yes -else $as_nop +else have_o_cloexec=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_o_cloexec" >&5 -printf "%s\n" "$have_o_cloexec" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_o_cloexec" >&5 +$as_echo "$have_o_cloexec" >&6; } if test $have_o_cloexec = yes; then -printf "%s\n" "#define HAVE_O_CLOEXEC 1" >>confdefs.h +$as_echo "#define HAVE_O_CLOEXEC 1" >>confdefs.h fi } @@ -27919,12 +25759,11 @@ CheckUSBHID() case "$host" in *-*-*bsd*|*-*-dragonfly*) if test x$enable_joystick = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusbhid" >&5 -printf %s "checking for hid_init in -lusbhid... " >&6; } -if test ${ac_cv_lib_usbhid_hid_init+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusbhid" >&5 +$as_echo_n "checking for hid_init in -lusbhid... " >&6; } +if ${ac_cv_lib_usbhid_hid_init+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lusbhid $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -27933,65 +25772,65 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char hid_init (); int -main (void) +main () { return hid_init (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_usbhid_hid_init=yes -else $as_nop +else ac_cv_lib_usbhid_hid_init=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usbhid_hid_init" >&5 -printf "%s\n" "$ac_cv_lib_usbhid_hid_init" >&6; } -if test "x$ac_cv_lib_usbhid_hid_init" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usbhid_hid_init" >&5 +$as_echo "$ac_cv_lib_usbhid_hid_init" >&6; } +if test "x$ac_cv_lib_usbhid_hid_init" = xyes; then : have_libusbhid=yes fi if test x$have_libusbhid = xyes; then - ac_fn_c_check_header_compile "$LINENO" "usbhid.h" "ac_cv_header_usbhid_h" "$ac_includes_default" -if test "x$ac_cv_header_usbhid_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "usbhid.h" "ac_cv_header_usbhid_h" "$ac_includes_default" +if test "x$ac_cv_header_usbhid_h" = xyes; then : USB_CFLAGS="-DHAVE_USBHID_H" fi - ac_fn_c_check_header_compile "$LINENO" "libusbhid.h" "ac_cv_header_libusbhid_h" "$ac_includes_default" -if test "x$ac_cv_header_libusbhid_h" = xyes -then : + + ac_fn_c_check_header_mongrel "$LINENO" "libusbhid.h" "ac_cv_header_libusbhid_h" "$ac_includes_default" +if test "x$ac_cv_header_libusbhid_h" = xyes; then : USB_CFLAGS="-DHAVE_LIBUSBHID_H" fi + USB_LIBS="$USB_LIBS -lusbhid" else - ac_fn_c_check_header_compile "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default" -if test "x$ac_cv_header_usb_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default" +if test "x$ac_cv_header_usb_h" = xyes; then : USB_CFLAGS="-DHAVE_USB_H" fi - ac_fn_c_check_header_compile "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default" -if test "x$ac_cv_header_libusb_h" = xyes -then : + + ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default" +if test "x$ac_cv_header_libusb_h" = xyes; then : USB_CFLAGS="-DHAVE_LIBUSB_H" fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusb" >&5 -printf %s "checking for hid_init in -lusb... " >&6; } -if test ${ac_cv_lib_usb_hid_init+y} -then : - printf %s "(cached) " >&6 -else $as_nop + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hid_init in -lusb" >&5 +$as_echo_n "checking for hid_init in -lusb... " >&6; } +if ${ac_cv_lib_usb_hid_init+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lusb $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -28000,29 +25839,30 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char hid_init (); int -main (void) +main () { return hid_init (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_usb_hid_init=yes -else $as_nop +else ac_cv_lib_usb_hid_init=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_hid_init" >&5 -printf "%s\n" "$ac_cv_lib_usb_hid_init" >&6; } -if test "x$ac_cv_lib_usb_hid_init" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_hid_init" >&5 +$as_echo "$ac_cv_lib_usb_hid_init" >&6; } +if test "x$ac_cv_lib_usb_hid_init" = xyes; then : USB_LIBS="$USB_LIBS -lusb" fi @@ -28031,8 +25871,8 @@ fi save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $USB_CFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for usbhid" >&5 -printf %s "checking for usbhid... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usbhid" >&5 +$as_echo_n "checking for usbhid... " >&6; } have_usbhid=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -28057,7 +25897,7 @@ printf %s "checking for usbhid... " >&6; } #endif int -main (void) +main () { struct report_desc *repdesc; @@ -28068,17 +25908,16 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_usbhid=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_usbhid" >&5 -printf "%s\n" "$have_usbhid" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid" >&5 +$as_echo "$have_usbhid" >&6; } if test x$have_usbhid = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ucr_data member of usb_ctl_report" >&5 -printf %s "checking for ucr_data member of usb_ctl_report... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucr_data member of usb_ctl_report" >&5 +$as_echo_n "checking for ucr_data member of usb_ctl_report... " >&6; } have_usbhid_ucr_data=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -28103,7 +25942,7 @@ printf %s "checking for ucr_data member of usb_ctl_report... " >&6; } #endif int -main (void) +main () { struct usb_ctl_report buf; @@ -28113,19 +25952,18 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_usbhid_ucr_data=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test x$have_usbhid_ucr_data = xyes; then USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA" fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_ucr_data" >&5 -printf "%s\n" "$have_usbhid_ucr_data" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_ucr_data" >&5 +$as_echo "$have_usbhid_ucr_data" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for new usbhid API" >&5 -printf %s "checking for new usbhid API... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for new usbhid API" >&5 +$as_echo_n "checking for new usbhid API... " >&6; } have_usbhid_new=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -28150,7 +25988,7 @@ printf %s "checking for new usbhid API... " >&6; } #endif int -main (void) +main () { report_desc_t d; @@ -28160,19 +25998,18 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_usbhid_new=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test x$have_usbhid_new = xyes; then USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW" fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_new" >&5 -printf "%s\n" "$have_usbhid_new" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid_new" >&5 +$as_echo "$have_usbhid_new" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct joystick in machine/joystick.h" >&5 -printf %s "checking for struct joystick in machine/joystick.h... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct joystick in machine/joystick.h" >&5 +$as_echo_n "checking for struct joystick in machine/joystick.h... " >&6; } have_machine_joystick=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -28180,7 +26017,7 @@ printf %s "checking for struct joystick in machine/joystick.h... " >&6; } #include int -main (void) +main () { struct joystick t; @@ -28189,21 +26026,20 @@ main (void) return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO" -then : +if ac_fn_c_try_compile "$LINENO"; then : have_machine_joystick=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test x$have_machine_joystick = xyes; then -printf "%s\n" "#define SDL_HAVE_MACHINE_JOYSTICK_H 1" >>confdefs.h +$as_echo "#define SDL_HAVE_MACHINE_JOYSTICK_H 1" >>confdefs.h fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_machine_joystick" >&5 -printf "%s\n" "$have_machine_joystick" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_machine_joystick" >&5 +$as_echo "$have_machine_joystick" >&6; } -printf "%s\n" "#define SDL_JOYSTICK_USBHID 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_USBHID 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS" @@ -28220,18 +26056,16 @@ printf "%s\n" "#define SDL_JOYSTICK_USBHID 1" >>confdefs.h CheckHIDAPI() { # Check whether --enable-hidapi-joystick was given. -if test ${enable_hidapi_joystick+y} -then : +if test "${enable_hidapi_joystick+set}" = set; then : enableval=$enable_hidapi_joystick; -else $as_nop +else enable_hidapi_joystick=yes fi # Check whether --enable-hidapi-libusb was given. -if test ${enable_hidapi_libusb+y} -then : +if test "${enable_hidapi_libusb+set}" = set; then : enableval=$enable_hidapi_libusb; -else $as_nop +else enable_hidapi_libusb=maybe fi @@ -28256,17 +26090,17 @@ fi if test x$enable_hidapi_libusb = xyes; then pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libusb-1.0" >&5 -printf %s "checking for libusb-1.0... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb-1.0" >&5 +$as_echo_n "checking for libusb-1.0... " >&6; } if test -n "$LIBUSB_CFLAGS"; then pkg_cv_LIBUSB_CFLAGS="$LIBUSB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb-1.0\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb-1.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "libusb-1.0") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBUSB_CFLAGS=`$PKG_CONFIG --cflags "libusb-1.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -28280,10 +26114,10 @@ if test -n "$LIBUSB_LIBS"; then pkg_cv_LIBUSB_LIBS="$LIBUSB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb-1.0\""; } >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb-1.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "libusb-1.0") 2>&5 ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBUSB_LIBS=`$PKG_CONFIG --libs "libusb-1.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes @@ -28297,8 +26131,8 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -28315,26 +26149,26 @@ fi have_libusb=no elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } have_libusb=no else LIBUSB_CFLAGS=$pkg_cv_LIBUSB_CFLAGS LIBUSB_LIBS=$pkg_cv_LIBUSB_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } have_libusb=yes fi save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$save_CPPFLAGS $LIBUSB_CFLAGS" - ac_fn_c_check_header_compile "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default" -if test "x$ac_cv_header_libusb_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default" +if test "x$ac_cv_header_libusb_h" = xyes; then : have_libusb_h=yes -else $as_nop +else have_libusb_h=no fi + CPPFLAGS="$save_CPPFLAGS" if test x$have_libusb_h = xno && test x$require_hidapi_libusb = xyes; then hidapi_support=no @@ -28343,15 +26177,15 @@ fi if test x$hidapi_support = xyes; then if test x$have_libusb_h = xyes; then - printf "%s\n" "#define HAVE_LIBUSB 1" >>confdefs.h + $as_echo "#define HAVE_LIBUSB 1" >>confdefs.h EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS" if test x$require_hidapi_libusb = xyes; then EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS" else if test x$have_loadso != xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic libusb loading" >&5 -printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic libusb loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic libusb loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic libusb loading" >&2;} fi # libusb is loaded dynamically, so don't add it to LDFLAGS libusb_lib="" @@ -28370,21 +26204,23 @@ printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynam libusb_lib=`find_lib "libusb-1.0.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'` fi -printf "%s\n" "#define SDL_LIBUSB_DYNAMIC \"$libusb_lib\"" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define SDL_LIBUSB_DYNAMIC "$libusb_lib" +_ACEOF fi fi fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for hidapi joystick support" >&5 -printf %s "checking for hidapi joystick support... " >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hidapi_support" >&5 -printf "%s\n" "$hidapi_support" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hidapi joystick support" >&5 +$as_echo_n "checking for hidapi joystick support... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hidapi_support" >&5 +$as_echo "$hidapi_support" >&6; } fi if test x$enable_joystick = xyes -a x$hidapi_support = xyes -a x$enable_hidapi_joystick = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c" fi @@ -28393,20 +26229,18 @@ printf "%s\n" "#define SDL_JOYSTICK_HIDAPI 1" >>confdefs.h CheckClockGettime() { # Check whether --enable-clock_gettime was given. -if test ${enable_clock_gettime+y} -then : +if test "${enable_clock_gettime+set}" = set; then : enableval=$enable_clock_gettime; -else $as_nop +else enable_clock_gettime=yes fi if test x$enable_clock_gettime = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lc" >&5 -printf %s "checking for clock_gettime in -lc... " >&6; } -if test ${ac_cv_lib_c_clock_gettime+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lc" >&5 +$as_echo_n "checking for clock_gettime in -lc... " >&6; } +if ${ac_cv_lib_c_clock_gettime+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lc $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -28415,43 +26249,43 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char clock_gettime (); int -main (void) +main () { return clock_gettime (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_c_clock_gettime=yes -else $as_nop +else ac_cv_lib_c_clock_gettime=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_clock_gettime" >&5 -printf "%s\n" "$ac_cv_lib_c_clock_gettime" >&6; } -if test "x$ac_cv_lib_c_clock_gettime" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_clock_gettime" >&5 +$as_echo "$ac_cv_lib_c_clock_gettime" >&6; } +if test "x$ac_cv_lib_c_clock_gettime" = xyes; then : have_clock_gettime=yes fi if test x$have_clock_gettime = xyes; then -printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h +$as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5 -printf %s "checking for clock_gettime in -lrt... " >&6; } -if test ${ac_cv_lib_rt_clock_gettime+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5 +$as_echo_n "checking for clock_gettime in -lrt... " >&6; } +if ${ac_cv_lib_rt_clock_gettime+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lrt $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -28460,36 +26294,37 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif char clock_gettime (); int -main (void) +main () { return clock_gettime (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_rt_clock_gettime=yes -else $as_nop +else ac_cv_lib_rt_clock_gettime=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5 -printf "%s\n" "$ac_cv_lib_rt_clock_gettime" >&6; } -if test "x$ac_cv_lib_rt_clock_gettime" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5 +$as_echo "$ac_cv_lib_rt_clock_gettime" >&6; } +if test "x$ac_cv_lib_rt_clock_gettime" = xyes; then : have_clock_gettime=yes fi if test x$have_clock_gettime = xyes; then EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt" -printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h +$as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h fi fi @@ -28498,12 +26333,12 @@ printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h CheckLinuxVersion() { - ac_fn_c_check_header_compile "$LINENO" "linux/version.h" "ac_cv_header_linux_version_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_version_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "linux/version.h" "ac_cv_header_linux_version_h" "$ac_includes_default" +if test "x$ac_cv_header_linux_version_h" = xyes; then : have_linux_version_h=yes fi + if test x$have_linux_version_h = xyes; then EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H" fi @@ -28512,10 +26347,9 @@ fi CheckRPATH() { # Check whether --enable-rpath was given. -if test ${enable_rpath+y} -then : +if test "${enable_rpath+set}" = set; then : enableval=$enable_rpath; -else $as_nop +else enable_rpath=yes fi @@ -28524,10 +26358,9 @@ fi CheckEventSignals() { # Check whether --enable-backgrounding-signal was given. -if test ${enable_backgrounding_signal+y} -then : +if test "${enable_backgrounding_signal+set}" = set; then : enableval=$enable_backgrounding_signal; -else $as_nop +else enable_backgrounding_signal=no fi @@ -28536,10 +26369,9 @@ fi fi # Check whether --enable-foregrounding-signal was given. -if test ${enable_foregrounding_signal+y} -then : +if test "${enable_foregrounding_signal+set}" = set; then : enableval=$enable_foregrounding_signal; -else $as_nop +else enable_foregrounding_signal=no fi @@ -28551,16 +26383,15 @@ fi CheckVirtualJoystick() { # Check whether --enable-joystick-virtual was given. -if test ${enable_joystick_virtual+y} -then : +if test "${enable_joystick_virtual+set}" = set; then : enableval=$enable_joystick_virtual; -else $as_nop +else enable_joystick_virtual=yes fi if test x$enable_joystick = xyes -a x$enable_joystick_virtual = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_VIRTUAL 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_VIRTUAL 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/joystick/virtual/*.c" have_joystick_virtual=yes @@ -28590,7 +26421,7 @@ case "$host" in if test x$enable_video = xyes; then SOURCES="$SOURCES $srcdir/src/core/android/*.c $srcdir/src/video/android/*.c" -printf "%s\n" "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} android" have_video=yes @@ -28691,7 +26522,7 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h case $ARCH in sysv5|solaris|hpux) -printf "%s\n" "#define SDL_AUDIO_DRIVER_SUNAUDIO 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_SUNAUDIO 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/sun/*.c" SUMMARY_audio="${SUMMARY_audio} sun" @@ -28699,7 +26530,7 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_SUNAUDIO 1" >>confdefs.h ;; netbsd) # Don't use this on OpenBSD, it's busted. -printf "%s\n" "#define SDL_AUDIO_DRIVER_NETBSD 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_NETBSD 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/netbsd/*.c" SUMMARY_audio="${SUMMARY_audio} netbsd" @@ -28707,7 +26538,7 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_NETBSD 1" >>confdefs.h ;; aix) -printf "%s\n" "#define SDL_AUDIO_DRIVER_PAUDIO 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_PAUDIO 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c" SUMMARY_audio="${SUMMARY_audio} paudio" @@ -28715,19 +26546,19 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_PAUDIO 1" >>confdefs.h ;; android) -printf "%s\n" "#define SDL_AUDIO_DRIVER_ANDROID 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_ANDROID 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/android/*.c" SUMMARY_audio="${SUMMARY_audio} android" -printf "%s\n" "#define SDL_AUDIO_DRIVER_OPENSLES 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_OPENSLES 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/openslES/*.c" SUMMARY_audio="${SUMMARY_audio} openslES" -printf "%s\n" "#define SDL_AUDIO_DRIVER_AAUDIO 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_AAUDIO 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/aaudio/*.c" SUMMARY_audio="${SUMMARY_audio} aaudio" @@ -28745,7 +26576,7 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_AAUDIO 1" >>confdefs.h linux) if test "x$ac_cv_header_linux_input_h" = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_LINUX 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_LINUX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c" SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c" @@ -28755,7 +26586,7 @@ printf "%s\n" "#define SDL_JOYSTICK_LINUX 1" >>confdefs.h freebsd) if test x$use_input_events = xyes -a x$ac_cv_header_linux_input_h = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_LINUX 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_LINUX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c" SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c" @@ -28764,7 +26595,7 @@ printf "%s\n" "#define SDL_JOYSTICK_LINUX 1" >>confdefs.h ;; android) -printf "%s\n" "#define SDL_JOYSTICK_ANDROID 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_ANDROID 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/joystick/android/*.c" SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c" @@ -28778,7 +26609,7 @@ printf "%s\n" "#define SDL_JOYSTICK_ANDROID 1" >>confdefs.h linux|freebsd) if test x$use_input_events = xyes; then -printf "%s\n" "#define SDL_HAPTIC_LINUX 1" >>confdefs.h +$as_echo "#define SDL_HAPTIC_LINUX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/haptic/linux/*.c" have_haptic=yes @@ -28786,7 +26617,7 @@ printf "%s\n" "#define SDL_HAPTIC_LINUX 1" >>confdefs.h ;; android) -printf "%s\n" "#define SDL_HAPTIC_ANDROID 1" >>confdefs.h +$as_echo "#define SDL_HAPTIC_ANDROID 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/haptic/android/*.c" have_haptic=yes @@ -28798,7 +26629,7 @@ printf "%s\n" "#define SDL_HAPTIC_ANDROID 1" >>confdefs.h case $ARCH in android) -printf "%s\n" "#define SDL_SENSOR_ANDROID 1" >>confdefs.h +$as_echo "#define SDL_SENSOR_ANDROID 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/sensor/android/*.c" have_sensor=yes @@ -28810,14 +26641,14 @@ printf "%s\n" "#define SDL_SENSOR_ANDROID 1" >>confdefs.h case $ARCH in linux) -printf "%s\n" "#define SDL_POWER_LINUX 1" >>confdefs.h +$as_echo "#define SDL_POWER_LINUX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/power/linux/*.c" have_power=yes ;; android) -printf "%s\n" "#define SDL_POWER_ANDROID 1" >>confdefs.h +$as_echo "#define SDL_POWER_ANDROID 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/power/android/*.c" have_power=yes @@ -28829,14 +26660,14 @@ printf "%s\n" "#define SDL_POWER_ANDROID 1" >>confdefs.h case $ARCH in android) -printf "%s\n" "#define SDL_FILESYSTEM_ANDROID 1" >>confdefs.h +$as_echo "#define SDL_FILESYSTEM_ANDROID 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/filesystem/android/*.c" have_filesystem=yes ;; *) -printf "%s\n" "#define SDL_FILESYSTEM_UNIX 1" >>confdefs.h +$as_echo "#define SDL_FILESYSTEM_UNIX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c" have_filesystem=yes @@ -28846,7 +26677,7 @@ printf "%s\n" "#define SDL_FILESYSTEM_UNIX 1" >>confdefs.h # Set up files for the timer library if test x$enable_timers = xyes; then -printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h +$as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/timer/unix/*.c" have_timers=yes @@ -28915,33 +26746,32 @@ printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h # Set up files for the video library if test x$enable_video = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_WINDOWS 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_WINDOWS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/windows/*.c" have_video=yes # Check whether --enable-render-d3d was given. -if test ${enable_render_d3d+y} -then : +if test "${enable_render_d3d+set}" = set; then : enableval=$enable_render_d3d; -else $as_nop +else enable_render_d3d=yes fi if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then -printf "%s\n" "#define SDL_VIDEO_RENDER_D3D 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_D3D 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} d3d9" fi if test x$enable_render_d3d = xyes -a x$have_d3d11 = xyes; then -printf "%s\n" "#define SDL_VIDEO_RENDER_D3D11 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_D3D11 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} d3d11" fi if test x$enable_render_d3d = xyes -a x$have_d3d12 = xyes; then -printf "%s\n" "#define SDL_VIDEO_RENDER_D3D12 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_D3D12 1" >>confdefs.h SUMMARY_video="${SUMMARY_video} d3d12" fi @@ -28949,20 +26779,20 @@ printf "%s\n" "#define SDL_VIDEO_RENDER_D3D12 1" >>confdefs.h # Set up files for the audio library if test x$enable_audio = xyes; then -printf "%s\n" "#define SDL_AUDIO_DRIVER_WINMM 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_WINMM 1" >>confdefs.h SUMMARY_audio="${SUMMARY_audio} winmm" SOURCES="$SOURCES $srcdir/src/audio/winmm/*.c" if test x$have_dsound = xyes; then -printf "%s\n" "#define SDL_AUDIO_DRIVER_DSOUND 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_DSOUND 1" >>confdefs.h SUMMARY_audio="${SUMMARY_audio} directsound" SOURCES="$SOURCES $srcdir/src/audio/directsound/*.c" fi if test x$have_wasapi = xyes -a x$enable_wasapi = xyes; then -printf "%s\n" "#define SDL_AUDIO_DRIVER_WASAPI 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_WASAPI 1" >>confdefs.h SUMMARY_audio="${SUMMARY_audio} wasapi" SOURCES="$SOURCES $srcdir/src/audio/wasapi/*.c" @@ -28972,22 +26802,22 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_WASAPI 1" >>confdefs.h # Set up files for the joystick library if test x$enable_joystick = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_RAWINPUT 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_RAWINPUT 1" >>confdefs.h if test x$have_dinput = xyes -o x$have_xinput = xyes -o x$have_wgi = xyes; then if test x$have_xinput = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_XINPUT 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_XINPUT 1" >>confdefs.h fi if test x$have_wgi = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_WGI 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_WGI 1" >>confdefs.h fi if test x$have_dinput = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_DINPUT 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_DINPUT 1" >>confdefs.h EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8" fi @@ -28999,12 +26829,12 @@ printf "%s\n" "#define SDL_JOYSTICK_DINPUT 1" >>confdefs.h if test x$have_dinput = xyes -o x$have_xinput = xyes; then if test x$have_xinput = xyes; then -printf "%s\n" "#define SDL_HAPTIC_XINPUT 1" >>confdefs.h +$as_echo "#define SDL_HAPTIC_XINPUT 1" >>confdefs.h fi if test x$have_dinput = xyes; then -printf "%s\n" "#define SDL_HAPTIC_DINPUT 1" >>confdefs.h +$as_echo "#define SDL_HAPTIC_DINPUT 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/haptic/windows/*.c" @@ -29012,22 +26842,22 @@ printf "%s\n" "#define SDL_HAPTIC_DINPUT 1" >>confdefs.h fi fi # Set up files for the sensor library - ac_fn_c_check_header_compile "$LINENO" "sensorsapi.h" "ac_cv_header_sensorsapi_h" "$ac_includes_default" -if test "x$ac_cv_header_sensorsapi_h" = xyes -then : + ac_fn_c_check_header_mongrel "$LINENO" "sensorsapi.h" "ac_cv_header_sensorsapi_h" "$ac_includes_default" +if test "x$ac_cv_header_sensorsapi_h" = xyes; then : have_winsensors=yes -else $as_nop +else have_winsensors=no fi + if test x$have_winsensors = xyes; then -printf "%s\n" "#define HAVE_SENSORSAPI_H 1" >>confdefs.h +$as_echo "#define HAVE_SENSORSAPI_H 1" >>confdefs.h fi if test x$enable_sensor = xyes -a x$have_winsensors = xyes; then -printf "%s\n" "#define SDL_SENSOR_WINDOWS 1" >>confdefs.h +$as_echo "#define SDL_SENSOR_WINDOWS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/sensor/windows/*.c" have_sensor=yes @@ -29035,7 +26865,7 @@ printf "%s\n" "#define SDL_SENSOR_WINDOWS 1" >>confdefs.h # Set up files for the power library if test x$enable_power = xyes; then -printf "%s\n" "#define SDL_POWER_WINDOWS 1" >>confdefs.h +$as_echo "#define SDL_POWER_WINDOWS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c" have_power=yes @@ -29043,7 +26873,7 @@ printf "%s\n" "#define SDL_POWER_WINDOWS 1" >>confdefs.h # Set up files for the filesystem library if test x$enable_filesystem = xyes; then -printf "%s\n" "#define SDL_FILESYSTEM_WINDOWS 1" >>confdefs.h +$as_echo "#define SDL_FILESYSTEM_WINDOWS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/filesystem/windows/SDL_sysfilesystem.c" have_filesystem=yes @@ -29051,10 +26881,10 @@ printf "%s\n" "#define SDL_FILESYSTEM_WINDOWS 1" >>confdefs.h # Set up files for the thread library if test x$enable_threads = xyes; then -printf "%s\n" "#define SDL_THREAD_GENERIC_COND_SUFFIX 1" >>confdefs.h +$as_echo "#define SDL_THREAD_GENERIC_COND_SUFFIX 1" >>confdefs.h -printf "%s\n" "#define SDL_THREAD_WINDOWS 1" >>confdefs.h +$as_echo "#define SDL_THREAD_WINDOWS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/thread/windows/*.c" SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c" @@ -29063,7 +26893,7 @@ printf "%s\n" "#define SDL_THREAD_WINDOWS 1" >>confdefs.h # Set up files for the timer library if test x$enable_timers = xyes; then -printf "%s\n" "#define SDL_TIMER_WINDOWS 1" >>confdefs.h +$as_echo "#define SDL_TIMER_WINDOWS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/timer/windows/*.c" have_timers=yes @@ -29071,7 +26901,7 @@ printf "%s\n" "#define SDL_TIMER_WINDOWS 1" >>confdefs.h # Set up files for the shared object loading library if test x$enable_loadso = xyes; then -printf "%s\n" "#define SDL_LOADSO_WINDOWS 1" >>confdefs.h +$as_echo "#define SDL_LOADSO_WINDOWS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c" fi @@ -29091,12 +26921,11 @@ printf "%s\n" "#define SDL_LOADSO_WINDOWS 1" >>confdefs.h # Check to see if this is a mingw or cygwin build have_mingw32= - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for main in -lmingw32" >&5 -printf %s "checking for main in -lmingw32... " >&6; } -if test ${ac_cv_lib_mingw32_main+y} -then : - printf %s "(cached) " >&6 -else $as_nop + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lmingw32" >&5 +$as_echo_n "checking for main in -lmingw32... " >&6; } +if ${ac_cv_lib_mingw32_main+:} false; then : + $as_echo_n "(cached) " >&6 +else ac_check_lib_save_LIBS=$LIBS LIBS="-lmingw32 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -29104,27 +26933,25 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext int -main (void) +main () { return main (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_mingw32_main=yes -else $as_nop +else ac_cv_lib_mingw32_main=no fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mingw32_main" >&5 -printf "%s\n" "$ac_cv_lib_mingw32_main" >&6; } -if test "x$ac_cv_lib_mingw32_main" = xyes -then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mingw32_main" >&5 +$as_echo "$ac_cv_lib_mingw32_main" >&6; } +if test "x$ac_cv_lib_mingw32_main" = xyes; then : have_mingw32=yes fi @@ -29155,7 +26982,7 @@ fi # Set up files for the audio library if test x$enable_audio = xyes; then -printf "%s\n" "#define SDL_AUDIO_DRIVER_HAIKU 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_HAIKU 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/haiku/*.cc" SUMMARY_audio="${SUMMARY_audio} haiku" @@ -29164,7 +26991,7 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_HAIKU 1" >>confdefs.h # Set up files for the joystick library if test x$enable_joystick = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_HAIKU 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_HAIKU 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/joystick/haiku/*.cc" have_joystick=yes @@ -29172,7 +26999,7 @@ printf "%s\n" "#define SDL_JOYSTICK_HAIKU 1" >>confdefs.h # Set up files for the timer library if test x$enable_timers = xyes; then -printf "%s\n" "#define SDL_TIMER_HAIKU 1" >>confdefs.h +$as_echo "#define SDL_TIMER_HAIKU 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/timer/haiku/*.c" have_timers=yes @@ -29180,7 +27007,7 @@ printf "%s\n" "#define SDL_TIMER_HAIKU 1" >>confdefs.h # Set up files for the system power library if test x$enable_power = xyes; then -printf "%s\n" "#define SDL_POWER_HAIKU 1" >>confdefs.h +$as_echo "#define SDL_POWER_HAIKU 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/power/haiku/*.c" have_power=yes @@ -29188,7 +27015,7 @@ printf "%s\n" "#define SDL_POWER_HAIKU 1" >>confdefs.h # Set up files for the system filesystem library if test x$enable_filesystem = xyes; then -printf "%s\n" "#define SDL_FILESYSTEM_HAIKU 1" >>confdefs.h +$as_echo "#define SDL_FILESYSTEM_HAIKU 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/filesystem/haiku/*.cc" have_filesystem=yes @@ -29237,7 +27064,7 @@ printf "%s\n" "#define SDL_FILESYSTEM_HAIKU 1" >>confdefs.h # Set up files for the audio library if test x$enable_audio = xyes; then -printf "%s\n" "#define SDL_AUDIO_DRIVER_COREAUDIO 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_COREAUDIO 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.m" SUMMARY_audio="${SUMMARY_audio} coreaudio" @@ -29246,7 +27073,7 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_COREAUDIO 1" >>confdefs.h # Set up files for the joystick library if test x$enable_joystick = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_MFI 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_MFI 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m" SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c" @@ -29264,7 +27091,7 @@ printf "%s\n" "#define SDL_JOYSTICK_MFI 1" >>confdefs.h # Set up files for the sensor library if test x$enable_sensor = xyes; then -printf "%s\n" "#define SDL_SENSOR_COREMOTION 1" >>confdefs.h +$as_echo "#define SDL_SENSOR_COREMOTION 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/sensor/coremotion/*.m" have_sensor=yes @@ -29272,7 +27099,7 @@ printf "%s\n" "#define SDL_SENSOR_COREMOTION 1" >>confdefs.h # Set up files for the power library if test x$enable_power = xyes; then -printf "%s\n" "#define SDL_POWER_UIKIT 1" >>confdefs.h +$as_echo "#define SDL_POWER_UIKIT 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/power/uikit/*.m" have_power=yes @@ -29285,14 +27112,14 @@ printf "%s\n" "#define SDL_POWER_UIKIT 1" >>confdefs.h # Set up additional files for the file library if test x$enable_file = xyes; then -printf "%s\n" "#define SDL_FILESYSTEM_COCOA 1" >>confdefs.h +$as_echo "#define SDL_FILESYSTEM_COCOA 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m" fi # Set up files for the timer library if test x$enable_timers = xyes; then -printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h +$as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/timer/unix/*.c" have_timers=yes @@ -29301,19 +27128,19 @@ printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/core/unix/*.c" # The iOS platform requires special setup. -printf "%s\n" "#define SDL_VIDEO_DRIVER_UIKIT 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_UIKIT 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_OPENGL_ES 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_OPENGL_ES 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_RENDER_OGL_ES 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_OGL_ES 1" >>confdefs.h -printf "%s\n" "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/uikit/*.m" SUMMARY_video="${SUMMARY_video} uikit" @@ -29383,7 +27210,7 @@ printf "%s\n" "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h # Set up files for the audio library if test x$enable_audio = xyes; then -printf "%s\n" "#define SDL_AUDIO_DRIVER_COREAUDIO 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_COREAUDIO 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.m" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox" @@ -29393,7 +27220,7 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_COREAUDIO 1" >>confdefs.h # Set up files for the joystick library if test x$enable_joystick = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_IOKIT 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_IOKIT 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c" SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m" @@ -29403,7 +27230,7 @@ printf "%s\n" "#define SDL_JOYSTICK_IOKIT 1" >>confdefs.h # Set up files for the haptic library if test x$enable_haptic = xyes; then -printf "%s\n" "#define SDL_HAPTIC_IOKIT 1" >>confdefs.h +$as_echo "#define SDL_HAPTIC_IOKIT 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback" @@ -29412,7 +27239,7 @@ printf "%s\n" "#define SDL_HAPTIC_IOKIT 1" >>confdefs.h # Set up files for the power library if test x$enable_power = xyes; then -printf "%s\n" "#define SDL_POWER_MACOSX 1" >>confdefs.h +$as_echo "#define SDL_POWER_MACOSX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/power/macosx/*.c" have_power=yes @@ -29420,7 +27247,7 @@ printf "%s\n" "#define SDL_POWER_MACOSX 1" >>confdefs.h # Set up files for the filesystem library if test x$enable_filesystem = xyes; then -printf "%s\n" "#define SDL_FILESYSTEM_COCOA 1" >>confdefs.h +$as_echo "#define SDL_FILESYSTEM_COCOA 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m" have_filesystem=yes @@ -29428,7 +27255,7 @@ printf "%s\n" "#define SDL_FILESYSTEM_COCOA 1" >>confdefs.h # Set up files for the timer library if test x$enable_timers = xyes; then -printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h +$as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/timer/unix/*.c" have_timers=yes @@ -29463,7 +27290,7 @@ printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h # Set up files for the timer library if test x$enable_timers = xyes; then -printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h +$as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/timer/unix/*.c" have_timers=yes @@ -29471,7 +27298,7 @@ printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h if test x$enable_filesystem = xyes; then -printf "%s\n" "#define SDL_FILESYSTEM_NACL 1" >>confdefs.h +$as_echo "#define SDL_FILESYSTEM_NACL 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/filesystem/nacl/*.c" have_filesystem=yes @@ -29480,7 +27307,7 @@ printf "%s\n" "#define SDL_FILESYSTEM_NACL 1" >>confdefs.h *-*-emscripten* ) if test x$enable_video = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_EMSCRIPTEN 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_EMSCRIPTEN 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/emscripten/*.c" have_video=yes @@ -29489,7 +27316,7 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_EMSCRIPTEN 1" >>confdefs.h if test x$enable_audio = xyes; then -printf "%s\n" "#define SDL_AUDIO_DRIVER_EMSCRIPTEN 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_EMSCRIPTEN 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/emscripten/*.c" have_audio=yes @@ -29517,7 +27344,7 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_EMSCRIPTEN 1" >>confdefs.h # Set up files for the power library if test x$enable_power = xyes; then -printf "%s\n" "#define SDL_POWER_EMSCRIPTEN 1" >>confdefs.h +$as_echo "#define SDL_POWER_EMSCRIPTEN 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/power/emscripten/*.c" have_power=yes @@ -29526,7 +27353,7 @@ printf "%s\n" "#define SDL_POWER_EMSCRIPTEN 1" >>confdefs.h # Set up files for the joystick library if test x$enable_joystick = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_EMSCRIPTEN 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_EMSCRIPTEN 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/joystick/emscripten/*.c" have_joystick=yes @@ -29535,7 +27362,7 @@ printf "%s\n" "#define SDL_JOYSTICK_EMSCRIPTEN 1" >>confdefs.h # Set up files for the filesystem library if test x$enable_filesystem = xyes; then -printf "%s\n" "#define SDL_FILESYSTEM_EMSCRIPTEN 1" >>confdefs.h +$as_echo "#define SDL_FILESYSTEM_EMSCRIPTEN 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/filesystem/emscripten/*.c" have_filesystem=yes @@ -29543,7 +27370,7 @@ printf "%s\n" "#define SDL_FILESYSTEM_EMSCRIPTEN 1" >>confdefs.h # Set up files for the timer library if test x$enable_timers = xyes; then -printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h +$as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/timer/unix/*.c" have_timers=yes @@ -29577,7 +27404,7 @@ printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h # Set up files for the video library if test x$enable_video = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_RISCOS 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_RISCOS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/riscos/*.c" have_video=yes @@ -29586,7 +27413,7 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_RISCOS 1" >>confdefs.h # Set up files for the filesystem library if test x$enable_filesystem = xyes; then -printf "%s\n" "#define SDL_FILESYSTEM_RISCOS 1" >>confdefs.h +$as_echo "#define SDL_FILESYSTEM_RISCOS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/filesystem/riscos/*.c" have_filesystem=yes @@ -29594,7 +27421,7 @@ printf "%s\n" "#define SDL_FILESYSTEM_RISCOS 1" >>confdefs.h # Set up files for the timer library if test x$enable_timers = xyes; then -printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h +$as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/timer/unix/*.c" have_timers=yes @@ -29636,7 +27463,7 @@ printf "%s\n" "#define SDL_TIMER_UNIX 1" >>confdefs.h # Set up files for the video library if test x$enable_video = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_OS2 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_OS2 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/os2/*.c" have_video=yes @@ -29645,7 +27472,7 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_OS2 1" >>confdefs.h # Set up files for the audio library if test x$enable_audio = xyes; then -printf "%s\n" "#define SDL_AUDIO_DRIVER_OS2 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_OS2 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/audio/os2/*.c" have_audio=yes @@ -29655,7 +27482,7 @@ printf "%s\n" "#define SDL_AUDIO_DRIVER_OS2 1" >>confdefs.h # Set up files for the thread library if test x$enable_threads = xyes; then -printf "%s\n" "#define SDL_THREAD_OS2 1" >>confdefs.h +$as_echo "#define SDL_THREAD_OS2 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/thread/os2/*.c" SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c" @@ -29664,7 +27491,7 @@ printf "%s\n" "#define SDL_THREAD_OS2 1" >>confdefs.h # Set up files for the timer library if test x$enable_timers = xyes; then -printf "%s\n" "#define SDL_TIMER_OS2 1" >>confdefs.h +$as_echo "#define SDL_TIMER_OS2 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/timer/os2/*.c" have_timers=yes @@ -29672,7 +27499,7 @@ printf "%s\n" "#define SDL_TIMER_OS2 1" >>confdefs.h # Set up files for the shared object loading library if test x$enable_loadso = xyes; then -printf "%s\n" "#define SDL_LOADSO_OS2 1" >>confdefs.h +$as_echo "#define SDL_LOADSO_OS2 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/loadso/os2/*.c" have_loadso=yes @@ -29680,7 +27507,7 @@ printf "%s\n" "#define SDL_LOADSO_OS2 1" >>confdefs.h # Set up files for the filesystem library if test x$enable_filesystem = xyes; then -printf "%s\n" "#define SDL_FILESYSTEM_OS2 1" >>confdefs.h +$as_echo "#define SDL_FILESYSTEM_OS2 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/filesystem/os2/*.c" have_filesystem=yes @@ -29688,12 +27515,89 @@ printf "%s\n" "#define SDL_FILESYSTEM_OS2 1" >>confdefs.h # Set up files for the joystick library if test x$enable_joystick = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_OS2 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_OS2 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/joystick/os2/*.c" have_joystick=yes fi ;; + aarch64-none-elf*) + ARCH=switch + SDL_CFLAGS="$SDL_CFLAGS -D__SWITCH__ -march=armv8-a+crc+crypto -mtune=cortex-a57 \ + -mtp=soft -ftls-model=local-exec \ + -isystem ${DEVKITPRO}/libnx/include -I${DEVKITPRO}/portlibs/switch/include" + EXTRA_CFLAGS="$EXTRA_CFLAGS -fPIC" + EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS -g -O3" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DSDL_VIDEO_STATIC_ANGLE" + EXTRA_LDFLAGS="-fPIE -L${DEVKITPRO}/libnx/lib -lEGL -lstdc++ -lglapi -ldrm_nouveau -lnx" + + CheckDeclarationAfterStatement + CheckClockGettime + CheckPTHREAD + + # Set up files for the power library + if test x$enable_power = xyes; then + +$as_echo "#define SDL_POWER_SWITCH 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/power/switch/SDL_syspower.c" + have_power=yes + fi + # Set up files for the filesystem library + if test x$enable_filesystem = xyes; then + +$as_echo "#define SDL_FILESYSTEM_SWITCH 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/filesystem/switch/SDL_sysfilesystem.c" + have_filesystem=yes + fi + # Set up files for the video library + if test x$enable_video = xyes; then + SOURCES="$SOURCES $srcdir/src/video/switch/*.c" + +$as_echo "#define SDL_VIDEO_DRIVER_SWITCH 1" >>confdefs.h + + +$as_echo "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h + + +$as_echo "#define SDL_VIDEO_OPENGL 1" >>confdefs.h + + +$as_echo "#define SDL_VIDEO_OPENGL_ES2 1" >>confdefs.h + + +$as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h + + SUMMARY_video="${SUMMARY_video} switch_opengles2" + have_video=yes + fi + # Set up files for the audio library + if test x$enable_audio = xyes; then + +$as_echo "#define SDL_AUDIO_DRIVER_SWITCH 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/audio/switch/*.c" + SUMMARY_audio="${SUMMARY_audio} switch" + have_audio=yes + fi + # Set up files for the joystick library + if test x$enable_joystick = xyes; then + +$as_echo "#define SDL_JOYSTICK_SWITCH 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/joystick/switch/*.c" + have_joystick=yes + fi + # Set up files for the timer library + if test x$enable_timers = xyes; then + +$as_echo "#define SDL_TIMER_SWITCH 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/timer/switch/*.c" + have_timers=yes + fi + ;; *) as_fn_error $? " *** Unsupported host: Please add to configure.ac @@ -29704,40 +27608,37 @@ esac CheckVirtualJoystick # Check whether to install sdl2-config -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to install sdl2-config" >&5 -printf %s "checking whether to install sdl2-config... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install sdl2-config" >&5 +$as_echo_n "checking whether to install sdl2-config... " >&6; } # Check whether --enable-sdl2-config was given. -if test ${enable_sdl2_config+y} -then : +if test "${enable_sdl2_config+set}" = set; then : enableval=$enable_sdl2_config; case "${enableval}" in yes) enable_sdl2_config="TRUE" ;; no) enable_sdl2_config="FALSE" ;; *) as_fn_error $? "bad value '${enableval}' for --enable-sdl2-config" "$LINENO" 5 ;; esac -else $as_nop +else enable_sdl2_config="TRUE" fi if test "$enable_sdl2_config" = "TRUE"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi INSTALL_SDL2_CONFIG=$enable_sdl2_config # Check whether --enable-vendor-info was given. -if test ${enable_vendor_info+y} -then : +if test "${enable_vendor_info+set}" = set; then : enableval=$enable_vendor_info; enable_vendor_info="$enableval" -else $as_nop +else enable_vendor_info= fi -if test "$enable_vendor_info" = no -then : +if test "$enable_vendor_info" = no; then : enable_vendor_info= fi SDL_VENDOR_INFO=$enable_vendor_info @@ -29748,7 +27649,7 @@ SDL_VENDOR_INFO=$enable_vendor_info if test x$have_audio != xyes; then if test x$enable_audio = xyes; then -printf "%s\n" "#define SDL_AUDIO_DRIVER_DUMMY 1" >>confdefs.h +$as_echo "#define SDL_AUDIO_DRIVER_DUMMY 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/audio/dummy/*.c" @@ -29756,7 +27657,7 @@ fi if test x$have_video != xyes; then if test x$enable_video = xyes; then -printf "%s\n" "#define SDL_VIDEO_DRIVER_DUMMY 1" >>confdefs.h +$as_echo "#define SDL_VIDEO_DRIVER_DUMMY 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/video/dummy/*.c" @@ -29764,7 +27665,7 @@ fi if test x$have_misc != xyes; then if test x$enable_misc = xyes; then -printf "%s\n" "#define SDL_MISC_DUMMY 1" >>confdefs.h +$as_echo "#define SDL_MISC_DUMMY 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/misc/dummy/*.c" @@ -29772,7 +27673,7 @@ fi if test x$have_locale != xyes; then if test x$enable_locale = xyes; then -printf "%s\n" "#define SDL_LOCALE_DUMMY 1" >>confdefs.h +$as_echo "#define SDL_LOCALE_DUMMY 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/locale/dummy/*.c" @@ -29780,7 +27681,7 @@ fi if test x$have_joystick != xyes; then if test x$enable_joystick = xyes; then -printf "%s\n" "#define SDL_JOYSTICK_DUMMY 1" >>confdefs.h +$as_echo "#define SDL_JOYSTICK_DUMMY 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c" @@ -29788,7 +27689,7 @@ fi if test x$have_haptic != xyes; then if test x$enable_haptic = xyes; then -printf "%s\n" "#define SDL_HAPTIC_DUMMY 1" >>confdefs.h +$as_echo "#define SDL_HAPTIC_DUMMY 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c" @@ -29796,7 +27697,7 @@ fi if test x$have_sensor != xyes; then if test x$enable_sensor = xyes; then -printf "%s\n" "#define SDL_SENSOR_DUMMY 1" >>confdefs.h +$as_echo "#define SDL_SENSOR_DUMMY 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/sensor/dummy/*.c" @@ -29804,7 +27705,7 @@ fi if test x$have_threads != xyes; then if test x$enable_threads = xyes; then -printf "%s\n" "#define SDL_THREADS_DISABLED 1" >>confdefs.h +$as_echo "#define SDL_THREADS_DISABLED 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/thread/generic/*.c" @@ -29812,7 +27713,7 @@ fi if test x$have_timers != xyes; then if test x$enable_timers = xyes; then -printf "%s\n" "#define SDL_TIMER_DUMMY 1" >>confdefs.h +$as_echo "#define SDL_TIMER_DUMMY 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c" @@ -29820,7 +27721,7 @@ fi if test x$have_filesystem != xyes; then if test x$enable_filesystem = xyes; then -printf "%s\n" "#define SDL_FILESYSTEM_DUMMY 1" >>confdefs.h +$as_echo "#define SDL_FILESYSTEM_DUMMY 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/filesystem/dummy/*.c" @@ -29828,7 +27729,7 @@ fi if test x$have_loadso != xyes; then if test x$enable_loadso = xyes; then -printf "%s\n" "#define SDL_LOADSO_DUMMY 1" >>confdefs.h +$as_echo "#define SDL_LOADSO_DUMMY 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c" @@ -29901,8 +27802,8 @@ if test "x$enable_rpath" = "xyes" -a "x$enable_shared" = "xyes"; then if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = linux -o $ARCH = netbsd; then SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for linker option --enable-new-dtags" >&5 -printf %s "checking for linker option --enable-new-dtags... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker option --enable-new-dtags" >&5 +$as_echo_n "checking for linker option --enable-new-dtags... " >&6; } have_enable_new_dtags=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -Wl,--enable-new-dtags" @@ -29910,25 +27811,24 @@ printf %s "checking for linker option --enable-new-dtags... " >&6; } /* end confdefs.h. */ int -main (void) +main () { ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" -then : +if ac_fn_c_try_link "$LINENO"; then : have_enable_new_dtags=yes SDL_RLD_FLAGS="$SDL_RLD_FLAGS -Wl,--enable-new-dtags" fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ +rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_enable_new_dtags" >&5 -printf "%s\n" "$have_enable_new_dtags" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_enable_new_dtags" >&5 +$as_echo "$have_enable_new_dtags" >&6; } fi if test $ARCH = solaris; then SDL_RLD_FLAGS="-R\${libdir}" @@ -30194,8 +28094,8 @@ _ACEOF case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( @@ -30225,15 +28125,15 @@ printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} /^ac_cv_env_/b end t clear :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/ + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -printf "%s\n" "$as_me: updating cache $cache_file" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else @@ -30247,8 +28147,8 @@ printf "%s\n" "$as_me: updating cache $cache_file" >&6;} fi fi else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache @@ -30265,7 +28165,7 @@ U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"` + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" @@ -30281,8 +28181,8 @@ LTLIBOBJS=$ac_ltlibobjs ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL @@ -30305,16 +28205,14 @@ cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -as_nop=: -if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 -then : +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST -else $as_nop +else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( @@ -30324,46 +28222,46 @@ esac fi - -# Reset variables that may have inherited troublesome values from -# the environment. - -# IFS needs to be set, to space, tab, and newline, in precisely that order. -# (If _AS_PATH_WALK were called with IFS unset, it would have the -# side effect of setting IFS to empty, thus disabling word splitting.) -# Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl -IFS=" "" $as_nl" - -PS1='$ ' -PS2='> ' -PS4='+ ' - -# Ensure predictable behavior from utilities with locale-dependent output. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# We cannot yet rely on "unset" to work, but we need these variables -# to be unset--not just set to an empty or harmless value--now, to -# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct -# also avoids known problems related to "unset" and subshell syntax -# in other old shells (e.g. bash 2.01 and pdksh 5.2.14). -for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH -do eval test \${$as_var+y} \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done - -# Ensure that fds 0, 1, and 2 are open. -if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi -if (exec 3>&2) ; then :; else exec 2>/dev/null; fi +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi # The user is always right. -if ${PATH_SEPARATOR+false} :; then +if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || @@ -30372,6 +28270,13 @@ if ${PATH_SEPARATOR+false} :; then fi +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( @@ -30380,12 +28285,8 @@ case $0 in #(( for as_dir in $PATH do IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - test -r "$as_dir$0" && as_myself=$as_dir$0 && break + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS @@ -30397,10 +28298,30 @@ if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then - printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] @@ -30413,14 +28334,13 @@ as_fn_error () as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - printf "%s\n" "$as_me: error: $2" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error - # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. @@ -30447,20 +28367,18 @@ as_fn_unset () { eval $1=; unset $1;} } as_unset=as_fn_unset - # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null -then : +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' -else $as_nop +else as_fn_append () { eval $1=\$$1\$2 @@ -30472,13 +28390,12 @@ fi # as_fn_append # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null -then : +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' -else $as_nop +else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` @@ -30509,7 +28426,7 @@ as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X/"$0" | +$as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q @@ -30531,10 +28448,6 @@ as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits - -# Determine whether it's possible to make 'echo' print without a newline. -# These variables are no longer used directly by Autoconf, but are AC_SUBSTed -# for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) @@ -30548,12 +28461,6 @@ case `echo -n x` in #((((( ECHO_N='-n';; esac -# For backward compatibility with old third-party macros, we provide -# the shell variables $as_echo and $as_echo_n. New code should use -# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. -as_echo='printf %s\n' -as_echo_n='printf %s' - rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file @@ -30595,7 +28502,7 @@ as_fn_mkdir_p () as_dirs= while :; do case $as_dir in #( - *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" @@ -30604,7 +28511,7 @@ $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X"$as_dir" | +$as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -30667,7 +28574,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by $as_me, which was -generated by GNU Autoconf 2.71. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -30729,16 +28636,14 @@ $config_commands Report bugs to the package provider." _ACEOF -ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"` -ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"` cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config='$ac_cs_config_escaped' +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.71, +configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2021 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -30777,15 +28682,15 @@ do -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - printf "%s\n" "$ac_cs_version"; exit ;; + $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) - printf "%s\n" "$ac_cs_config"; exit ;; + $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in - *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" @@ -30793,7 +28698,7 @@ do --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in - *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; @@ -30802,7 +28707,7 @@ do as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) - printf "%s\n" "$ac_cs_usage"; exit ;; + $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; @@ -30830,7 +28735,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift - \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6 + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" @@ -30844,7 +28749,7 @@ exec 5>>config.log sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX - printf "%s\n" "$ac_log" + $as_echo "$ac_log" } >&5 _ACEOF @@ -31352,9 +29257,9 @@ done # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then - test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files - test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers - test ${CONFIG_COMMANDS+y} || CONFIG_COMMANDS=$config_commands + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree @@ -31690,7 +29595,7 @@ do esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac - case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done @@ -31698,17 +29603,17 @@ do # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` - printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -printf "%s\n" "$as_me: creating $ac_file" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) - ac_sed_conf_input=`printf "%s\n" "$configure_input" | + ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac @@ -31725,7 +29630,7 @@ $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X"$ac_file" | +$as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -31749,9 +29654,9 @@ printf "%s\n" X"$ac_file" | case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) - ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; @@ -31808,8 +29713,8 @@ ac_sed_dataroot=' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' @@ -31852,9 +29757,9 @@ test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 -printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" @@ -31870,27 +29775,27 @@ which seems to be undefined. Please make sure it is defined" >&2;} # if test x"$ac_file" != x-; then { - printf "%s\n" "/* $configure_input */" >&1 \ + $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 -printf "%s\n" "$as_me: $ac_file is unchanged" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else - printf "%s\n" "/* $configure_input */" >&1 \ + $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; - :C) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 -printf "%s\n" "$as_me: executing $ac_file commands" >&6;} + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac @@ -32441,7 +30346,6 @@ _LT_EOF esac - ltmain=$ac_aux_dir/ltmain.sh @@ -32799,8 +30703,7 @@ if test "$no_create" != yes; then $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi - diff --git a/configure.ac b/configure.ac index 558895859..440c49aea 100644 --- a/configure.ac +++ b/configure.ac @@ -4667,6 +4667,63 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan. have_joystick=yes fi ;; + aarch64-none-elf*) + ARCH=switch + SDL_CFLAGS="$SDL_CFLAGS -D__SWITCH__ -march=armv8-a+crc+crypto -mtune=cortex-a57 \ + -mtp=soft -ftls-model=local-exec \ + -isystem ${DEVKITPRO}/libnx/include -I${DEVKITPRO}/portlibs/switch/include" + EXTRA_CFLAGS="$EXTRA_CFLAGS -fPIC" + EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS -g -O3" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DSDL_VIDEO_STATIC_ANGLE" + EXTRA_LDFLAGS="-fPIE -L${DEVKITPRO}/libnx/lib -lEGL -lstdc++ -lglapi -ldrm_nouveau -lnx" + + CheckDeclarationAfterStatement + CheckClockGettime + CheckPTHREAD + + # Set up files for the power library + if test x$enable_power = xyes; then + AC_DEFINE(SDL_POWER_SWITCH, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/power/switch/SDL_syspower.c" + have_power=yes + fi + # Set up files for the filesystem library + if test x$enable_filesystem = xyes; then + AC_DEFINE(SDL_FILESYSTEM_SWITCH, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/filesystem/switch/SDL_sysfilesystem.c" + have_filesystem=yes + fi + # Set up files for the video library + if test x$enable_video = xyes; then + SOURCES="$SOURCES $srcdir/src/video/switch/*.c" + AC_DEFINE(SDL_VIDEO_DRIVER_SWITCH, 1, [ ]) + AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ]) + AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ]) + AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ]) + AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ]) + SUMMARY_video="${SUMMARY_video} switch_opengles2" + have_video=yes + fi + # Set up files for the audio library + if test x$enable_audio = xyes; then + AC_DEFINE(SDL_AUDIO_DRIVER_SWITCH, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/audio/switch/*.c" + SUMMARY_audio="${SUMMARY_audio} switch" + have_audio=yes + fi + # Set up files for the joystick library + if test x$enable_joystick = xyes; then + AC_DEFINE(SDL_JOYSTICK_SWITCH, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/joystick/switch/*.c" + have_joystick=yes + fi + # Set up files for the timer library + if test x$enable_timers = xyes; then + AC_DEFINE(SDL_TIMER_SWITCH, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/timer/switch/*.c" + have_timers=yes + fi + ;; *) AC_MSG_ERROR([ *** Unsupported host: Please add to configure.ac diff --git a/include/SDL_config.h b/include/SDL_config.h index fd2fe8876..0ee706063 100644 --- a/include/SDL_config.h +++ b/include/SDL_config.h @@ -22,10 +22,10 @@ #ifndef SDL_config_h_ #define SDL_config_h_ -#include "SDL_platform.h" - /** - * \file SDL_config.h + * \file SDL_config.h.in + * + * This is a set of defines to configure the SDL features */ /* Add any platform that doesn't build using the configure system. */ @@ -54,6 +54,30 @@ #include "SDL_config_minimal.h" #endif /* platform config */ +/** + * \file SDL_config.h + */ + +/* Add any platform that doesn't build using the configure system. */ +#if defined(__WIN32__) +#include "SDL_config_windows.h" +#elif defined(__WINRT__) +#include "SDL_config_winrt.h" +#elif defined(__MACOSX__) +#include "SDL_config_macosx.h" +#elif defined(__IPHONEOS__) +#include "SDL_config_iphoneos.h" +#elif defined(__ANDROID__) +#include "SDL_config_android.h" +#elif defined(__PSP__) +#include "SDL_config_psp.h" +#elif defined(__OS2__) +#include "SDL_config_os2.h" +#else +/* This is a minimal configuration just to get SDL running on new platforms. */ +#include "SDL_config_minimal.h" +#endif /* platform config */ + #ifdef USING_GENERATED_CONFIG_H #error Wrong SDL_config.h, check your include path? #endif diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index 35923d020..716b19708 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -329,6 +329,7 @@ #cmakedefine SDL_AUDIO_DRIVER_PSP @SDL_AUDIO_DRIVER_PSP@ #cmakedefine SDL_AUDIO_DRIVER_PS2 @SDL_AUDIO_DRIVER_PS2@ #cmakedefine SDL_AUDIO_DRIVER_N3DS @SDL_AUDIO_DRIVER_N3DS@ +#cmakedefine SDL_AUDIO_DRIVER_SWITCH @SDL_AUDIO_DRIVER_SWITCH@ /* Enable various input drivers */ #cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@ @@ -355,6 +356,7 @@ #cmakedefine SDL_JOYSTICK_PSP @SDL_JOYSTICK_PSP@ #cmakedefine SDL_JOYSTICK_PS2 @SDL_JOYSTICK_PS2@ #cmakedefine SDL_JOYSTICK_N3DS @SDL_JOYSTICK_N3DS@ +#cmakedefine SDL_JOYSTICK_SWITCH @SDL_JOYSTICK_SWITCH@ #cmakedefine SDL_HAPTIC_DUMMY @SDL_HAPTIC_DUMMY@ #cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@ #cmakedefine SDL_HAPTIC_IOKIT @SDL_HAPTIC_IOKIT@ @@ -390,6 +392,7 @@ #cmakedefine SDL_THREAD_PSP @SDL_THREAD_PSP@ #cmakedefine SDL_THREAD_PS2 @SDL_THREAD_PS2@ #cmakedefine SDL_THREAD_N3DS @SDL_THREAD_N3DS@ +#cmakedefine SDL_THREAD_SWITCH @SDL_THREAD_SWITCH@ /* Enable various timer systems */ #cmakedefine SDL_TIMER_HAIKU @SDL_TIMER_HAIKU@ @@ -401,6 +404,7 @@ #cmakedefine SDL_TIMER_PSP @SDL_TIMER_PSP@ #cmakedefine SDL_TIMER_PS2 @SDL_TIMER_PS2@ #cmakedefine SDL_TIMER_N3DS @SDL_TIMER_N3DS@ +#cmakedefine SDL_TIMER_SWITCH @SDL_TIMER_SWITCH@ /* Enable various video drivers */ #cmakedefine SDL_VIDEO_DRIVER_ANDROID @SDL_VIDEO_DRIVER_ANDROID@ @@ -455,6 +459,7 @@ #cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM @SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM@ #cmakedefine SDL_VIDEO_DRIVER_VITA @SDL_VIDEO_DRIVER_VITA@ #cmakedefine SDL_VIDEO_DRIVER_N3DS @SDL_VIDEO_DRIVER_N3DS@ +#cmakedefine SDL_VIDEO_DRIVER_SWITCH @SDL_VIDEO_DRIVER_SWITCH@ #cmakedefine SDL_VIDEO_RENDER_D3D @SDL_VIDEO_RENDER_D3D@ #cmakedefine SDL_VIDEO_RENDER_D3D11 @SDL_VIDEO_RENDER_D3D11@ @@ -499,6 +504,7 @@ #cmakedefine SDL_POWER_VITA @SDL_POWER_VITA@ #cmakedefine SDL_POWER_PSP @SDL_POWER_PSP@ #cmakedefine SDL_POWER_N3DS @SDL_POWER_N3DS@ +#cmakedefine SDL_POWER_SWITCH @SDL_POWER_SWITCH@ /* Enable system filesystem support */ #cmakedefine SDL_FILESYSTEM_ANDROID @SDL_FILESYSTEM_ANDROID@ @@ -514,6 +520,7 @@ #cmakedefine SDL_FILESYSTEM_PSP @SDL_FILESYSTEM_PSP@ #cmakedefine SDL_FILESYSTEM_PS2 @SDL_FILESYSTEM_PS2@ #cmakedefine SDL_FILESYSTEM_N3DS @SDL_FILESYSTEM_N3DS@ +#cmakedefine SDL_FILESYSTEM_SWITCH @SDL_FILESYSTEM_SWITCH@ /* Enable misc subsystem */ #cmakedefine SDL_MISC_DUMMY @SDL_MISC_DUMMY@ diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index d6460b783..42ec968fe 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -311,6 +311,7 @@ #undef SDL_AUDIO_DRIVER_WASAPI #undef SDL_AUDIO_DRIVER_WINMM #undef SDL_AUDIO_DRIVER_OS2 +#undef SDL_AUDIO_DRIVER_SWITCH /* Enable various input drivers */ #undef SDL_INPUT_LINUXEV @@ -333,6 +334,7 @@ #undef SDL_JOYSTICK_RAWINPUT #undef SDL_JOYSTICK_EMSCRIPTEN #undef SDL_JOYSTICK_VIRTUAL +#undef SDL_JOYSTICK_SWITCH #undef SDL_HAPTIC_DUMMY #undef SDL_HAPTIC_ANDROID #undef SDL_HAPTIC_LINUX @@ -360,6 +362,7 @@ #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP #undef SDL_THREAD_WINDOWS #undef SDL_THREAD_OS2 +#undef SDL_THREAD_SWITCH /* Enable various timer systems */ #undef SDL_TIMER_HAIKU @@ -367,6 +370,7 @@ #undef SDL_TIMER_UNIX #undef SDL_TIMER_WINDOWS #undef SDL_TIMER_OS2 +#undef SDL_TIMER_SWITCH /* Enable various video drivers */ #undef SDL_VIDEO_DRIVER_HAIKU @@ -413,6 +417,7 @@ #undef SDL_VIDEO_DRIVER_OS2 #undef SDL_VIDEO_DRIVER_QNX #undef SDL_VIDEO_DRIVER_RISCOS +#undef SDL_VIDEO_DRIVER_SWITCH #undef SDL_VIDEO_RENDER_D3D #undef SDL_VIDEO_RENDER_D3D11 @@ -449,6 +454,7 @@ #undef SDL_POWER_ANDROID #undef SDL_POWER_EMSCRIPTEN #undef SDL_POWER_HARDWIRED +#undef SDL_POWER_SWITCH /* Enable system filesystem support */ #undef SDL_FILESYSTEM_ANDROID @@ -464,6 +470,7 @@ #undef SDL_FILESYSTEM_VITA #undef SDL_FILESYSTEM_PSP #undef SDL_FILESYSTEM_PS2 +#undef SDL_FILESYSTEM_SWITCH /* Enable misc subsystem */ #undef SDL_MISC_DUMMY diff --git a/sdl2-config.cmake.in b/sdl2-config.cmake.in index 842f826bb..96b000774 100644 --- a/sdl2-config.cmake.in +++ b/sdl2-config.cmake.in @@ -53,7 +53,7 @@ string(REGEX REPLACE ";-L" ";" _sdl2_libdirs "${_sdl2_libdirs}") list(APPEND _sdl2_libdirs "${SDL2_LIBDIR}") # Convert _sdl2_static_private_libs to list and keep only libraries + library directories -string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)|(-pthread)" _sdl2_static_private_libs "${_sdl2_static_private_libs_in}") +string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._+]+))|(-Wl,[^ ]*framework[^ ]*)|(-pthread)" _sdl2_static_private_libs "${_sdl2_static_private_libs_in}") string(REGEX REPLACE "^-l" "" _sdl2_static_private_libs "${_sdl2_static_private_libs}") string(REGEX REPLACE ";-l" ";" _sdl2_static_private_libs "${_sdl2_static_private_libs}") string(REGEX MATCHALL "-L([-a-zA-Z0-9._/]+)" _sdl2_static_private_libdirs "${_sdl2_static_private_libs_in}") diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 60242e60a..bf319fa57 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -111,6 +111,9 @@ static const AudioBootStrap *const bootstrap[] = { #if SDL_AUDIO_DRIVER_EMSCRIPTEN &EMSCRIPTENAUDIO_bootstrap, #endif +#if SDL_AUDIO_DRIVER_SWITCH + &SWITCHAUDIO_bootstrap, +#endif #if SDL_AUDIO_DRIVER_JACK &JACK_bootstrap, #endif diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index c755d4341..7581d70cb 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -209,6 +209,7 @@ extern AudioBootStrap VITAAUD_bootstrap; extern AudioBootStrap N3DSAUDIO_bootstrap; extern AudioBootStrap EMSCRIPTENAUDIO_bootstrap; extern AudioBootStrap OS2AUDIO_bootstrap; +extern AudioBootStrap SWITCHAUDIO_bootstrap; #endif /* SDL_sysaudio_h_ */ diff --git a/src/audio/switch/SDL_switchaudio.c b/src/audio/switch/SDL_switchaudio.c new file mode 100644 index 000000000..33710b5aa --- /dev/null +++ b/src/audio/switch/SDL_switchaudio.c @@ -0,0 +1,227 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_AUDIO_DRIVER_SWITCH + +#include +#include +#include +#include + +#include "SDL_audio.h" +#include "../SDL_audio_c.h" +#include "../SDL_audiodev_c.h" + +#include "SDL_switchaudio.h" + +static const AudioRendererConfig arConfig = + { + .output_rate = AudioRendererOutputRate_48kHz, + .num_voices = 24, + .num_effects = 0, + .num_sinks = 1, + .num_mix_objs = 1, + .num_mix_buffers = 2, + }; + +static int +SWITCHAUDIO_OpenDevice(_THIS, const char *devname) +{ + static const u8 sink_channels[] = {0, 1}; + SDL_bool supported_format = SDL_FALSE; + SDL_AudioFormat test_format; + Result res; + u32 size; + int mpid; + + this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); + if (this->hidden == NULL) { + return SDL_OutOfMemory(); + } + SDL_zerop(this->hidden); + + res = audrenInitialize(&arConfig); + if (R_FAILED(res)) { + return SDL_SetError("audrenInitialize failed (0x%x)", res); + } + this->hidden->audr_device = true; + + res = audrvCreate(&this->hidden->driver, &arConfig, 2); + if (R_FAILED(res)) { + return SDL_SetError("audrvCreate failed (0x%x)", res); + } + this->hidden->audr_driver = true; + + test_format = SDL_FirstAudioFormat(this->spec.format); + while ((!supported_format) && (test_format)) { + if (test_format == AUDIO_S16SYS) { + supported_format = SDL_TRUE; + } + else { + test_format = SDL_NextAudioFormat(); + } + } + if (!supported_format) { + return SDL_SetError("Unsupported audio format"); + } + + this->spec.format = test_format; + SDL_CalculateAudioSpec(&this->spec); + + size = (u32) ((this->spec.size * 2) + 0xfff) & ~0xfff; + this->hidden->pool = memalign(0x1000, size); + for (int i = 0; i < 2; i++) { + this->hidden->buffer[i].data_raw = this->hidden->pool; + this->hidden->buffer[i].size = this->spec.size * 2; + this->hidden->buffer[i].start_sample_offset = i * this->spec.samples; + this->hidden->buffer[i].end_sample_offset = this->hidden->buffer[i].start_sample_offset + this->spec.samples; + this->hidden->buffer_tmp = malloc(this->spec.size); + } + + mpid = audrvMemPoolAdd(&this->hidden->driver, this->hidden->pool, size); + audrvMemPoolAttach(&this->hidden->driver, mpid); + + audrvDeviceSinkAdd(&this->hidden->driver, AUDREN_DEFAULT_DEVICE_NAME, 2, sink_channels); + + res = audrenStartAudioRenderer(); + if (R_FAILED(res)) { + return SDL_SetError("audrenStartAudioRenderer failed (0x%x)", res); + } + + audrvVoiceInit(&this->hidden->driver, 0, this->spec.channels, PcmFormat_Int16, this->spec.freq); + audrvVoiceSetDestinationMix(&this->hidden->driver, 0, AUDREN_FINAL_MIX_ID); + if (this->spec.channels == 1) { + audrvVoiceSetMixFactor(&this->hidden->driver, 0, 1.0f, 0, 0); + audrvVoiceSetMixFactor(&this->hidden->driver, 0, 1.0f, 0, 1); + } + else { + audrvVoiceSetMixFactor(&this->hidden->driver, 0, 1.0f, 0, 0); + audrvVoiceSetMixFactor(&this->hidden->driver, 0, 0.0f, 0, 1); + audrvVoiceSetMixFactor(&this->hidden->driver, 0, 0.0f, 1, 0); + audrvVoiceSetMixFactor(&this->hidden->driver, 0, 1.0f, 1, 1); + } + + audrvVoiceStart(&this->hidden->driver, 0); + + return 0; +} + +static void +SWITCHAUDIO_PlayDevice(_THIS) +{ + int current = -1; + for (int i = 0; i < 2; i++) { + if (this->hidden->buffer[i].state == AudioDriverWaveBufState_Free + || this->hidden->buffer[i].state == AudioDriverWaveBufState_Done) { + current = i; + break; + } + } + + if (current >= 0) { + Uint8 *ptr = (Uint8 *) (this->hidden->pool + (current * this->spec.size)); + memcpy(ptr, this->hidden->buffer_tmp, this->spec.size); + armDCacheFlush(ptr, this->spec.size); + audrvVoiceAddWaveBuf(&this->hidden->driver, 0, &this->hidden->buffer[current]); + } + else if (!audrvVoiceIsPlaying(&this->hidden->driver, 0)) { + audrvVoiceStart(&this->hidden->driver, 0); + } + + audrvUpdate(&this->hidden->driver); + + if (current >= 0) { + while (this->hidden->buffer[current].state != AudioDriverWaveBufState_Playing) { + audrvUpdate(&this->hidden->driver); + audrenWaitFrame(); + } + } + else { + current = -1; + for (int i = 0; i < 2; i++) { + if (this->hidden->buffer[i].state == AudioDriverWaveBufState_Playing) { + current = i; + break; + } + } + while (this->hidden->buffer[current].state == AudioDriverWaveBufState_Playing) { + audrvUpdate(&this->hidden->driver); + audrenWaitFrame(); + } + } +} + +static void +SWITCHAUDIO_WaitDevice(_THIS) +{ +} + +static Uint8 +*SWITCHAUDIO_GetDeviceBuf(_THIS) +{ + return this->hidden->buffer_tmp; +} + +static void +SWITCHAUDIO_CloseDevice(_THIS) +{ + if (this->hidden->audr_driver) { + audrvClose(&this->hidden->driver); + } + + if (this->hidden->audr_device) { + audrenExit(); + } + + if (this->hidden->buffer_tmp) { + free(this->hidden->buffer_tmp); + } + + SDL_free(this->hidden); +} + +static void +SWITCHAUDIO_ThreadInit(_THIS) +{ + +} + +static SDL_bool +SWITCHAUDIO_Init(SDL_AudioDriverImpl *impl) +{ + impl->OpenDevice = SWITCHAUDIO_OpenDevice; + impl->PlayDevice = SWITCHAUDIO_PlayDevice; + impl->WaitDevice = SWITCHAUDIO_WaitDevice; + impl->GetDeviceBuf = SWITCHAUDIO_GetDeviceBuf; + impl->CloseDevice = SWITCHAUDIO_CloseDevice; + impl->ThreadInit = SWITCHAUDIO_ThreadInit; + + impl->OnlyHasDefaultOutputDevice = 1; + + return 1; +} + +AudioBootStrap SWITCHAUDIO_bootstrap = { + "switch", "Nintendo Switch audio driver", SWITCHAUDIO_Init, 0 +}; + +#endif /* SDL_AUDIO_DRIVER_SWITCH */ diff --git a/src/audio/switch/SDL_switchaudio.h b/src/audio/switch/SDL_switchaudio.h new file mode 100644 index 000000000..f5e0340fb --- /dev/null +++ b/src/audio/switch/SDL_switchaudio.h @@ -0,0 +1,41 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_switchaudio_h_ +#define SDL_switchaudio_h_ + +#include +#include "../SDL_sysaudio.h" + +/* Hidden "this" pointer for the audio functions */ +#define _THIS SDL_AudioDevice *this + +struct SDL_PrivateAudioData +{ + AudioDriver driver; + AudioDriverWaveBuf buffer[2]; + void *buffer_tmp; + void *pool; + bool audr_device; + bool audr_driver; +}; + +#endif /* SDL_switchaudio_h_ */ diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 337ae335a..39ce7484e 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -1079,7 +1079,7 @@ int SDL_GetSystemRAM(void) #endif #ifdef HAVE_SYSCTLBYNAME if (SDL_SystemRAM <= 0) { -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__SWITCH__) #ifdef HW_REALMEM int mib[2] = { CTL_HW, HW_REALMEM }; #else diff --git a/src/dynapi/SDL_dynapi.h b/src/dynapi/SDL_dynapi.h index 99ca08008..9dadb7b48 100644 --- a/src/dynapi/SDL_dynapi.h +++ b/src/dynapi/SDL_dynapi.h @@ -67,6 +67,8 @@ #define SDL_DYNAMIC_API 0 /* The N-Gage doesn't support dynamic linking either */ #elif defined(__3DS__) #define SDL_DYNAMIC_API 0 /* devkitARM doesn't support dynamic linking */ +#elif defined(__SWITCH__) && __SWITCH__ +#define SDL_DYNAMIC_API 0 /* Probably not useful on switch. */ #elif defined(DYNAPI_NEEDS_DLOPEN) && !defined(HAVE_DLOPEN) #define SDL_DYNAMIC_API 0 /* we need dlopen(), but don't have it.... */ #endif diff --git a/src/filesystem/switch/SDL_sysfilesystem.c b/src/filesystem/switch/SDL_sysfilesystem.c new file mode 100644 index 000000000..6053c6f43 --- /dev/null +++ b/src/filesystem/switch/SDL_sysfilesystem.c @@ -0,0 +1,67 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_FILESYSTEM_SWITCH + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include +#include +#include + +#include "SDL_error.h" +#include "SDL_stdinc.h" +#include "SDL_filesystem.h" + +char * +SDL_GetBasePath(void) +{ + const char *basepath = "romfs:/"; + char *retval = SDL_strdup(basepath); + return retval; +} + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + char *ret = NULL; + char buf[PATH_MAX]; + size_t len; + + if (getcwd(buf, PATH_MAX)) { + len = strlen(buf) + 2; + ret = (char *) SDL_malloc(len); + if (!ret) { + SDL_OutOfMemory(); + return NULL; + } + SDL_snprintf(ret, len, "%s/", buf); + return ret; + } + + return NULL; +} + +#endif /* SDL_FILESYSTEM_SWITCH */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/joystick/SDL_gamecontrollerdb.h b/src/joystick/SDL_gamecontrollerdb.h index f926c1612..8eda5b703 100644 --- a/src/joystick/SDL_gamecontrollerdb.h +++ b/src/joystick/SDL_gamecontrollerdb.h @@ -991,6 +991,9 @@ static const char *s_ControllerMappings[] = { #endif #if SDL_JOYSTICK_N3DS "000000004e696e74656e646f20334400,Nintendo 3DS,crc:3210,a:b0,b:b1,back:b2,dpdown:b7,dpleft:b5,dpright:b4,dpup:b6,leftshoulder:b9,lefttrigger:b14,leftx:a0,lefty:a1,rightshoulder:b8,righttrigger:b15,rightx:a2,righty:a3,start:b3,x:b10,y:b11,", +#endif +#if defined(SDL_JOYSTICK_SWITCH) + "000038f853776974636820436f6e7400,Switch Controller,a:b1,b:b0,back:b11,dpdown:b15,dpleft:b12,dpright:b14,dpup:b13,leftshoulder:b6,leftstick:b4,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b5,righttrigger:b9,rightx:a2,righty:a3,start:b10,x:b3,y:b2,", #endif "hidapi,*,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", NULL diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 834e83d99..e79cbcb80 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -105,6 +105,9 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = { #ifdef SDL_JOYSTICK_N3DS &SDL_N3DS_JoystickDriver #endif +#ifdef SDL_JOYSTICK_SWITCH + &SDL_SWITCH_JoystickDriver, +#endif #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED) &SDL_DUMMY_JoystickDriver #endif diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h index a93fa662c..c0f3e9ec1 100644 --- a/src/joystick/SDL_sysjoystick.h +++ b/src/joystick/SDL_sysjoystick.h @@ -249,6 +249,7 @@ extern SDL_JoystickDriver SDL_PS2_JoystickDriver; extern SDL_JoystickDriver SDL_PSP_JoystickDriver; extern SDL_JoystickDriver SDL_VITA_JoystickDriver; extern SDL_JoystickDriver SDL_N3DS_JoystickDriver; +extern SDL_JoystickDriver SDL_SWITCH_JoystickDriver; /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/joystick/switch/SDL_sysjoystick.c b/src/joystick/switch/SDL_sysjoystick.c new file mode 100644 index 000000000..043363b2b --- /dev/null +++ b/src/joystick/switch/SDL_sysjoystick.c @@ -0,0 +1,370 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_JOYSTICK_SWITCH + +/* This is the dummy implementation of the SDL joystick API */ + +#include "SDL_events.h" +#include "../SDL_sysjoystick.h" +#include "SDL_hints.h" + +#include + +#define JOYSTICK_COUNT 8 + +typedef struct SWITCHJoystickState { + PadState pad; + HidAnalogStickState sticks_old[2]; + HidVibrationDeviceHandle vibrationDeviceHandles; + HidVibrationValue vibrationValues; + HidNpadButton *pad_mapping; + u32 pad_type; + u32 pad_type_prev; + HidNpadStyleTag pad_style; + HidNpadStyleTag pad_style_prev; +} SWITCHJoystickState; + +static SWITCHJoystickState state[JOYSTICK_COUNT]; + +static const HidNpadButton pad_mapping_default[] = { + HidNpadButton_A, HidNpadButton_B, HidNpadButton_X, HidNpadButton_Y, + HidNpadButton_StickL, HidNpadButton_StickR, + HidNpadButton_L, HidNpadButton_R, + HidNpadButton_ZL, HidNpadButton_ZR, + HidNpadButton_Plus, HidNpadButton_Minus, + HidNpadButton_Left, HidNpadButton_Up, HidNpadButton_Right, HidNpadButton_Down, + HidNpadButton_StickLLeft, HidNpadButton_StickLUp, HidNpadButton_StickLRight, HidNpadButton_StickLDown, + HidNpadButton_StickRLeft, HidNpadButton_StickRUp, HidNpadButton_StickRRight, HidNpadButton_StickRDown, + HidNpadButton_LeftSL, HidNpadButton_LeftSR, HidNpadButton_RightSL, HidNpadButton_RightSR +}; + +// left single joycon mapping (start = left stick, select = minus) +static const HidNpadButton pad_mapping_left_joy[] = { + HidNpadButton_Down, HidNpadButton_Left, HidNpadButton_Right, HidNpadButton_Up, + BIT(31), BIT(31), + BIT(31), BIT(31), + HidNpadButton_LeftSL, HidNpadButton_LeftSR, + HidNpadButton_StickL, HidNpadButton_Minus, + HidNpadButton_StickLUp, HidNpadButton_StickLRight, HidNpadButton_StickLDown, HidNpadButton_StickLLeft, + BIT(31), BIT(31), BIT(31), BIT(31), + BIT(31), BIT(31), BIT(31), BIT(31), + BIT(31), BIT(31), BIT(31), BIT(31) +}; + +// right single joycon mapping (start = right stick, select = plus) +static const HidNpadButton pad_mapping_right_joy[] = { + HidNpadButton_X, HidNpadButton_A, HidNpadButton_Y, HidNpadButton_B, + BIT(31), BIT(31), + BIT(31), BIT(31), + HidNpadButton_RightSL, HidNpadButton_RightSR, + HidNpadButton_StickR, HidNpadButton_Plus, + HidNpadButton_StickRDown, HidNpadButton_StickRLeft, HidNpadButton_StickRUp, HidNpadButton_StickRRight, + BIT(31), BIT(31), BIT(31), BIT(31), + BIT(31), BIT(31), BIT(31), BIT(31), + BIT(31), BIT(31), BIT(31), BIT(31) +}; + +static void SWITCH_UpdateControllerSupport(bool handheld) { + if (!handheld) { + HidLaControllerSupportResultInfo info; + HidLaControllerSupportArg args; + hidLaCreateControllerSupportArg(&args); + args.hdr.player_count_max = JOYSTICK_COUNT; + hidLaShowControllerSupportForSystem(&info, &args, false); + } + + // update pads states + for (int i = 0; i < JOYSTICK_COUNT; i++) { + SDL_Joystick *joy = SDL_JoystickFromInstanceID(i); + if (joy) { + padUpdate(&state[i].pad); + state[i].pad_type = state[i].pad_type_prev = hidGetNpadDeviceType((HidNpadIdType) i); + state[i].pad_style = state[i].pad_style_prev = hidGetNpadStyleSet((HidNpadIdType) i); + // update pad mapping + if (!(state[i].pad_style & HidNpadStyleTag_NpadJoyDual) && + (state[i].pad_type & HidDeviceTypeBits_JoyLeft)) { + state[i].pad_mapping = (HidNpadButton *) &pad_mapping_left_joy; + } else if (!(state[i].pad_style & HidNpadStyleTag_NpadJoyDual) && + (state[i].pad_type & HidDeviceTypeBits_JoyRight)) { + state[i].pad_mapping = (HidNpadButton *) &pad_mapping_right_joy; + } else { + state[i].pad_mapping = (HidNpadButton *) &pad_mapping_default; + } + // update vibration stuff ? + hidInitializeVibrationDevices(&state[i].vibrationDeviceHandles, 1, + HidNpadIdType_No1 + i, state[i].pad_style); + // reset sdl joysticks states + SDL_PrivateJoystickAxis(joy, 0, 0); + SDL_PrivateJoystickAxis(joy, 1, 0); + SDL_PrivateJoystickAxis(joy, 2, 0); + SDL_PrivateJoystickAxis(joy, 3, 0); + state[i].pad.buttons_cur = 0; + state[i].pad.buttons_old = 0; + for (int j = 0; j < joy->nbuttons; j++) { + SDL_PrivateJoystickButton(joy, j, SDL_RELEASED); + } + } + } +} + +/* Function to scan the system for joysticks. + * It should return 0, or -1 on an unrecoverable fatal error. + */ +static int SWITCH_JoystickInit(void) { + padConfigureInput(JOYSTICK_COUNT, HidNpadStyleSet_NpadStandard); + + // initialize first pad to defaults + padInitializeDefault(&state[0].pad); + padUpdate(&state[0].pad); + hidSetNpadJoyHoldType(HidNpadJoyHoldType_Horizontal); + + state[0].pad_type = state[0].pad_type_prev = hidGetNpadDeviceType((HidNpadIdType) 0); + state[0].pad_style = state[0].pad_style_prev = hidGetNpadStyleSet((HidNpadIdType) 0); + if (!(state[0].pad_style & HidNpadStyleTag_NpadJoyDual) && + (state[0].pad_type & HidDeviceTypeBits_JoyLeft)) { + state[0].pad_mapping = (HidNpadButton*)&pad_mapping_left_joy; + } + else if (!(state[0].pad_style & HidNpadStyleTag_NpadJoyDual) && + (state[0].pad_type & HidDeviceTypeBits_JoyRight)) { + state[0].pad_mapping = (HidNpadButton*)&pad_mapping_right_joy; + } + else { + state[0].pad_mapping = (HidNpadButton*)&pad_mapping_default; + } + + // initialize pad and vibrations for pad 1 to 7 + for (int i = 1; i < JOYSTICK_COUNT; i++) { + padInitialize(&state[i].pad, HidNpadIdType_No1 + i); + padUpdate(&state[i].pad); + state[i].pad_type = state[i].pad_type_prev = hidGetNpadDeviceType((HidNpadIdType) i); + state[i].pad_style = state[i].pad_style_prev = hidGetNpadStyleSet((HidNpadIdType) i); + if (!(state[i].pad_style & HidNpadStyleTag_NpadJoyDual) && + (state[i].pad_type & HidDeviceTypeBits_JoyLeft)) { + state[i].pad_mapping = (HidNpadButton*)&pad_mapping_left_joy; + } + else if (!(state[i].pad_style & HidNpadStyleTag_NpadJoyDual) && + (state[i].pad_type & HidDeviceTypeBits_JoyRight)) { + state[i].pad_mapping = (HidNpadButton*)&pad_mapping_right_joy; + } + else { + state[i].pad_mapping = (HidNpadButton*)&pad_mapping_default; + } + hidInitializeVibrationDevices(&state[i].vibrationDeviceHandles, 1, + HidNpadIdType_No1 + i, state[i].pad_style); + } + + return JOYSTICK_COUNT; +} + +static int SWITCH_JoystickGetCount(void) { + return JOYSTICK_COUNT; +} + +static void SWITCH_JoystickDetect(void) { +} + +/* Function to get the device-dependent name of a joystick */ +static const char *SWITCH_JoystickGetDeviceName(int device_index) { + return "Switch Controller"; +} + +static const char *SWITCH_JoystickGetDevicePath(int index) +{ + return NULL; +} + +static int SWITCH_JoystickGetDevicePlayerIndex(int device_index) { + return -1; +} + +static void SWITCH_JoystickSetDevicePlayerIndex(int device_index, int player_index) { +} + +static SDL_JoystickGUID SWITCH_JoystickGetDeviceGUID(int device_index) { + /* the GUID is just the name for now */ + const char *name = SWITCH_JoystickGetDeviceName(device_index); + return SDL_CreateJoystickGUIDForName(name); +} + +/* Function to perform the mapping from device index to the instance id for this index */ +static SDL_JoystickID SWITCH_JoystickGetDeviceInstanceID(int device_index) { + return device_index; +} + +/* Function to open a joystick for use. + The joystick to open is specified by the device index. + This should fill the nbuttons and naxes fields of the joystick structure. + It returns 0, or -1 if there is an error. + */ +static int SWITCH_JoystickOpen(SDL_Joystick *joystick, int device_index) { + joystick->nbuttons = sizeof(pad_mapping_default) / sizeof(*pad_mapping_default); + joystick->naxes = 4; + joystick->nhats = 0; + joystick->instance_id = device_index; + + return 0; +} + +static int SWITCH_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { + int id = joystick->instance_id; + + state[id].vibrationValues.amp_low = + state[id].vibrationValues.amp_high = low_frequency_rumble == 0 ? 0.0f : 320.0f; + state[id].vibrationValues.freq_low = + low_frequency_rumble == 0 ? 160.0f : (float) low_frequency_rumble / 204; + state[id].vibrationValues.freq_high = + high_frequency_rumble == 0 ? 320.0f : (float) high_frequency_rumble / 204; + + hidSendVibrationValues(&state[id].vibrationDeviceHandles, &state[id].vibrationValues, 1); + + return 0; +} + +static int SWITCH_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left, Uint16 right) { + return SDL_Unsupported(); +} + +static Uint32 SWITCH_JoystickGetCapabilities(SDL_Joystick *joystick) { + return 0; +} + +static int SWITCH_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { + return 0; +} + +static int SWITCH_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) { + return SDL_Unsupported(); +} +static int SWITCH_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { + return SDL_Unsupported(); +} + +/* Function to update the state of a joystick - called as a device poll. + * This function shouldn't update the joystick structure directly, + * but instead should call SDL_PrivateJoystick*() to deliver events + * and update joystick device state. + */ +static void SWITCH_JoystickUpdate(SDL_Joystick *joystick) { + u64 diff; + int index = (int) SDL_JoystickInstanceID(joystick); + if (index >= JOYSTICK_COUNT || SDL_IsTextInputActive()) { + return; + } + + padUpdate(&state[index].pad); + if (!padIsConnected(&state[index].pad)) { + return; + } + + // update pad type and style, open controller support applet if needed + state[index].pad_type = hidGetNpadDeviceType((HidNpadIdType) index); + state[index].pad_style = hidGetNpadStyleSet((HidNpadIdType) index); + if (state[index].pad_type != state[index].pad_type_prev + || state[index].pad_style != state[index].pad_style_prev) { + SWITCH_UpdateControllerSupport(padIsHandheld(&state[index].pad) ? true : false); + return; + } + + // only handle axes in non-single joycon mode + if (state[index].pad_style & HidNpadStyleTag_NpadJoyDual + || (state[index].pad_type != HidDeviceTypeBits_JoyLeft + && state[index].pad_type != HidDeviceTypeBits_JoyRight)) { + // axis left + if (state[index].sticks_old[0].x != state[index].pad.sticks[0].x) { + SDL_PrivateJoystickAxis(joystick, 0, (Sint16) state[index].pad.sticks[0].x); + state[index].sticks_old[0].x = state[index].pad.sticks[0].x; + } + if (state[index].sticks_old[0].y != state[index].pad.sticks[0].y) { + SDL_PrivateJoystickAxis(joystick, 1, (Sint16) - state[index].pad.sticks[0].y); + state[index].sticks_old[0].y = -state[index].pad.sticks[0].y; + } + state[index].sticks_old[0] = padGetStickPos(&state[index].pad, 0); + // axis right + if (state[index].sticks_old[1].x != state[index].pad.sticks[1].x) { + SDL_PrivateJoystickAxis(joystick, 2, (Sint16) state[index].pad.sticks[1].x); + state[index].sticks_old[1].x = state[index].pad.sticks[1].x; + } + if (state[index].sticks_old[1].y != state[index].pad.sticks[1].y) { + SDL_PrivateJoystickAxis(joystick, 3, (Sint16) - state[index].pad.sticks[1].y); + state[index].sticks_old[1].y = -state[index].pad.sticks[1].y; + } + state[index].sticks_old[1] = padGetStickPos(&state[index].pad, 1); + } + + // handle buttons + diff = state[index].pad.buttons_old ^ state[index].pad.buttons_cur; + if (diff) { + for (int i = 0; i < joystick->nbuttons; i++) { + if (diff & state[index].pad_mapping[i]) { + SDL_PrivateJoystickButton( + joystick, i, + state[index].pad.buttons_cur & state[index].pad_mapping[i] ? + SDL_PRESSED : SDL_RELEASED); + } + } + } +} + +/* Function to close a joystick after use */ +static void SWITCH_JoystickClose(SDL_Joystick *joystick) { +} + +/* Function to perform any system-specific joystick related cleanup */ +static void SWITCH_JoystickQuit(void) { +} + +static SDL_bool SWITCH_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { + return SDL_FALSE; +} + +SDL_JoystickDriver SDL_SWITCH_JoystickDriver = { + SWITCH_JoystickInit, + SWITCH_JoystickGetCount, + SWITCH_JoystickDetect, + SWITCH_JoystickGetDeviceName, + SWITCH_JoystickGetDevicePath, + SWITCH_JoystickGetDevicePlayerIndex, + SWITCH_JoystickSetDevicePlayerIndex, + SWITCH_JoystickGetDeviceGUID, + SWITCH_JoystickGetDeviceInstanceID, + + SWITCH_JoystickOpen, + + SWITCH_JoystickRumble, + SWITCH_JoystickRumbleTriggers, + SWITCH_JoystickGetCapabilities, + + SWITCH_JoystickSetLED, + SWITCH_JoystickSendEffect, + SWITCH_JoystickSetSensorsEnabled, + + SWITCH_JoystickUpdate, + SWITCH_JoystickClose, + SWITCH_JoystickQuit, + + SWITCH_JoystickGetGamepadMapping, +}; + +#endif /* SDL_JOYSTICK_SWITCH */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/power/SDL_power.c b/src/power/SDL_power.c index 63ba38221..178ee8142 100644 --- a/src/power/SDL_power.c +++ b/src/power/SDL_power.c @@ -78,6 +78,9 @@ static SDL_GetPowerInfo_Impl implementations[] = { #ifdef SDL_POWER_EMSCRIPTEN /* handles Emscripten */ SDL_GetPowerInfo_Emscripten, #endif +#ifdef SDL_POWER_SWITCH /* handles Nintendo Switch. */ + SDL_GetPowerInfo_SWITCH, +#endif #ifdef SDL_POWER_HARDWIRED SDL_GetPowerInfo_Hardwired, diff --git a/src/power/SDL_syspower.h b/src/power/SDL_syspower.h index 5401a0ee3..a640cc5a4 100644 --- a/src/power/SDL_syspower.h +++ b/src/power/SDL_syspower.h @@ -42,6 +42,7 @@ SDL_bool SDL_GetPowerInfo_VITA(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_N3DS(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_WinRT(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *, int *, int *); +SDL_bool SDL_GetPowerInfo_SWITCH(SDL_PowerState *, int *, int *); /* this one is static in SDL_power.c */ /* SDL_bool SDL_GetPowerInfo_Hardwired(SDL_PowerState *, int *, int *);*/ diff --git a/src/power/switch/SDL_syspower.c b/src/power/switch/SDL_syspower.c new file mode 100644 index 000000000..86ae7875c --- /dev/null +++ b/src/power/switch/SDL_syspower.c @@ -0,0 +1,68 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" + +#ifndef SDL_POWER_DISABLED +#if SDL_POWER_SWITCH + +#include +#include "SDL_power.h" + +SDL_bool +SDL_GetPowerInfo_SWITCH(SDL_PowerState *state, int *seconds, + int *percent) { + PsmChargerType chargerType; + u32 charge; + //double age; + Result rc; + + rc = psmGetChargerType(&chargerType); + if (R_FAILED(rc)) { + *state = SDL_POWERSTATE_UNKNOWN; + *seconds = -1; + *percent = -1; + return SDL_FALSE; + } + + psmGetBatteryChargePercentage(&charge); + *percent = (int) charge; + + // TODO: use approximation for now, ~6h00 for a fully charged battery + *seconds = ((int) charge * 21600) / 100; + //psmGetBatteryAgePercentage(&age); + //*seconds = (int) age; + + if (chargerType == PsmChargerType_Unconnected) { + *state = SDL_POWERSTATE_ON_BATTERY; + } else if (chargerType == PsmChargerType_EnoughPower) { + *state = SDL_POWERSTATE_CHARGED; + } else { + *state = SDL_POWERSTATE_CHARGING; + } + + return SDL_TRUE; +} + +#endif /* SDL_POWER_SWITCH */ +#endif /* SDL_POWER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index 278a68026..a1e654452 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -46,6 +46,8 @@ #include "os2/SDL_systhread_c.h" #elif SDL_THREAD_NGAGE #include "ngage/SDL_systhread_c.h" +#elif SDL_THREAD_SWITCH +#include "switch/SDL_systhread_c.h" #else #error Need thread implementation for this platform #include "generic/SDL_systhread_c.h" diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index 531680705..d420475cb 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -59,8 +59,11 @@ #include #endif +#ifdef __SWITCH__ +#include +#endif -#ifndef __NACL__ +#if !defined(__NACL__) && !defined(__SWITCH__) /* List of signals to mask in the subthreads */ static const int sig_list[] = { SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH, @@ -122,10 +125,10 @@ int SDL_SYS_CreateThread(SDL_Thread *thread) void SDL_SYS_SetupThread(const char *name) { -#if !defined(__NACL__) +#if !defined(__NACL__) && !defined(__SWITCH__) int i; sigset_t mask; -#endif /* !__NACL__ */ +#endif /* !__NACL__ && !__NINTENDO_SWITCH__ */ if (name != NULL) { #if (defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)) && defined(HAVE_DLOPEN) @@ -162,14 +165,14 @@ void SDL_SYS_SetupThread(const char *name) } /* NativeClient does not yet support signals.*/ -#if !defined(__NACL__) +#if !defined(__NACL__) && !defined(__SWITCH__) /* Mask asynchronous signals for this thread */ sigemptyset(&mask); for (i = 0; sig_list[i]; ++i) { sigaddset(&mask, sig_list[i]); } pthread_sigmask(SIG_BLOCK, &mask, 0); -#endif /* !__NACL__ */ +#endif /* !__NACL__ && !__NINTENDO_SWITCH__ */ #ifdef PTHREAD_CANCEL_ASYNCHRONOUS @@ -190,6 +193,20 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { #if __NACL__ || __RISCOS__ || __OS2__ /* FIXME: Setting thread priority does not seem to be supported in NACL */ + return 0; +#elif __SWITCH__ + Result res; + if (priority == SDL_THREAD_PRIORITY_HIGH) { + res = svcSetThreadPriority(CUR_THREAD_HANDLE, 0x2B); + } else { + // 0x3B = preemptive threading + res = svcSetThreadPriority(CUR_THREAD_HANDLE, 0x3B); + } + + if(R_FAILED(res)) { + return SDL_SetError("SDL_SYS_SetThreadPriority: svcSetThreadPriority failed (%x)", res); + } + return 0; #else struct sched_param sched; diff --git a/src/timer/switch/SDL_systimer.c b/src/timer/switch/SDL_systimer.c new file mode 100644 index 000000000..64e4924cd --- /dev/null +++ b/src/timer/switch/SDL_systimer.c @@ -0,0 +1,75 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_TIMER_SWITCH + +#include "SDL_timer.h" +#include + +static bool started = false; +static Uint64 start = 0; + +void +SDL_TicksInit(void) +{ + if (started) { + return; + } + + start = SDL_GetPerformanceCounter(); + started = true; +} + +void +SDL_TicksQuit(void) +{ + started = false; +} + +Uint64 SDL_GetTicks64(void) +{ + if (!started) { + SDL_TicksInit(); + } + + return (SDL_GetPerformanceCounter() - start) * 1000 / SDL_GetPerformanceFrequency(); +} + +Uint64 +SDL_GetPerformanceCounter(void) +{ + return armGetSystemTick(); +} + +Uint64 +SDL_GetPerformanceFrequency(void) +{ + return armGetSystemTickFreq(); +} + +void +SDL_Delay(Uint32 ms) +{ + svcSleepThread((Uint64) ms * 1000000); +} + +#endif /* SDL_TIMER_SWITCH */ diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index d7a42cc64..aa51f7a11 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -482,6 +482,7 @@ extern VideoBootStrap OFFSCREEN_bootstrap; extern VideoBootStrap NGAGE_bootstrap; extern VideoBootStrap OS2DIVE_bootstrap; extern VideoBootStrap OS2VMAN_bootstrap; +extern VideoBootStrap SWITCH_bootstrap; /* Use SDL_OnVideoThread() sparingly, to avoid regressions in use cases that currently happen to work */ extern SDL_bool SDL_OnVideoThread(void); diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 8065a0b8c..1d21fd61e 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -138,6 +138,9 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_OFFSCREEN &OFFSCREEN_bootstrap, #endif +#if SDL_VIDEO_DRIVER_SWITCH + &SWITCH_bootstrap, +#endif #if SDL_VIDEO_DRIVER_DUMMY &DUMMY_bootstrap, #if SDL_INPUT_LINUXEV @@ -202,7 +205,7 @@ typedef struct static Uint32 SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this) { -#if (SDL_VIDEO_OPENGL && __MACOSX__) || (__IPHONEOS__ && !TARGET_OS_MACCATALYST) || __ANDROID__ || __NACL__ +#if (SDL_VIDEO_OPENGL && __MACOSX__) || (__IPHONEOS__ && !TARGET_OS_MACCATALYST) || __ANDROID__ || __NACL__ || __SWITCH__ if (_this->GL_CreateContext != NULL) { return SDL_WINDOW_OPENGL; } diff --git a/src/video/khronos/EGL/eglplatform.h b/src/video/khronos/EGL/eglplatform.h index 99362a23d..a20125cff 100644 --- a/src/video/khronos/EGL/eglplatform.h +++ b/src/video/khronos/EGL/eglplatform.h @@ -70,7 +70,7 @@ typedef int EGLNativeDisplayType; typedef int EGLNativePixmapType; typedef int EGLNativeWindowType; -#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ +#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ || defined(__SWITCH__) typedef int EGLNativeDisplayType; typedef void *EGLNativePixmapType; diff --git a/src/video/switch/SDL_switchkeyboard.c b/src/video/switch/SDL_switchkeyboard.c new file mode 100644 index 000000000..5037f6ff4 --- /dev/null +++ b/src/video/switch/SDL_switchkeyboard.c @@ -0,0 +1,69 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_SWITCH + +#include + +#include "SDL_events.h" +#include "SDL_log.h" +#include "SDL_switchvideo.h" +#include "SDL_switchkeyboard.h" +#include "../../events/SDL_keyboard_c.h" + +static bool keys[SDL_NUM_SCANCODES] = {0}; + +void +SWITCH_InitKeyboard(void) { + hidInitializeKeyboard(); +} + +void +SWITCH_PollKeyboard(void) { + HidKeyboardState state; + SDL_Scancode scancode; + + if (SDL_GetFocusWindow() == NULL) { + return; + } + + if (hidGetKeyboardStates(&state, 1)) { + for (scancode = SDL_SCANCODE_UNKNOWN; scancode < (SDL_Scancode) HidKeyboardKey_RightGui; scancode++) { + bool pressed = hidKeyboardStateGetKey(&state, (int) scancode); + if (pressed && !keys[scancode]) { + SDL_SendKeyboardKey(pressed, scancode); + keys[scancode] = true; + } else if (!pressed && keys[scancode]) { + SDL_SendKeyboardKey(pressed, scancode); + keys[scancode] = false; + } + } + } +} + +void +SWITCH_QuitKeyboard(void) { +} + +#endif /* SDL_VIDEO_DRIVER_SWITCH */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/switch/SDL_switchkeyboard.h b/src/video/switch/SDL_switchkeyboard.h new file mode 100644 index 000000000..a8355db78 --- /dev/null +++ b/src/video/switch/SDL_switchkeyboard.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_switchkeyboard_h +#define _SDL_switchkeyboard_h + +#include "../../SDL_internal.h" + +/* Keyboard functions */ +extern void SWITCH_InitKeyboard(void); +extern void SWITCH_PollKeyboard(void); +extern void SWITCH_QuitKeyboard(void); + +#endif /* _SDL_switchkeyboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/switch/SDL_switchmouse.c b/src/video/switch/SDL_switchmouse.c new file mode 100644 index 000000000..d6d50b87e --- /dev/null +++ b/src/video/switch/SDL_switchmouse.c @@ -0,0 +1,115 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_SWITCH + +#include + +#include "SDL_timer.h" +#include "SDL_events.h" +#include "SDL_log.h" +#include "SDL_mouse.h" +#include "SDL_switchvideo.h" +#include "SDL_switchmouse_c.h" +#include "../../events/SDL_mouse_c.h" + +static uint64_t prev_buttons = 0; +static uint64_t last_timestamp = 0; +const uint64_t mouse_read_interval = 15; // in ms + +static int +SWITCH_SetRelativeMouseMode(SDL_bool enabled) +{ + return 0; +} + +void +SWITCH_InitMouse(void) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + mouse->SetRelativeMouseMode = SWITCH_SetRelativeMouseMode; + hidInitializeMouse(); +} + +void +SWITCH_PollMouse(void) +{ + SDL_Window *window = SDL_GetFocusWindow(); + HidMouseState mouse_state; + size_t state_count; + uint64_t changed_buttons; + uint64_t timestamp; + int dx, dy; + + // We skip polling mouse if no window is created + if (window == NULL) + return; + + state_count = hidGetMouseStates(&mouse_state, 1); + changed_buttons = mouse_state.buttons ^ prev_buttons; + + if (changed_buttons & HidMouseButton_Left) { + if (prev_buttons & HidMouseButton_Left) + SDL_SendMouseButton(window, 0, SDL_RELEASED, SDL_BUTTON_LEFT); + else + SDL_SendMouseButton(window, 0, SDL_PRESSED, SDL_BUTTON_LEFT); + } + if (changed_buttons & HidMouseButton_Right) { + if (prev_buttons & HidMouseButton_Right) + SDL_SendMouseButton(window, 0, SDL_RELEASED, SDL_BUTTON_RIGHT); + else + SDL_SendMouseButton(window, 0, SDL_PRESSED, SDL_BUTTON_RIGHT); + } + if (changed_buttons & HidMouseButton_Middle) { + if (prev_buttons & HidMouseButton_Middle) + SDL_SendMouseButton(window, 0, SDL_RELEASED, SDL_BUTTON_MIDDLE); + else + SDL_SendMouseButton(window, 0, SDL_PRESSED, SDL_BUTTON_MIDDLE); + } + + prev_buttons = mouse_state.buttons; + + timestamp = SDL_GetTicks(); + + if (SDL_TICKS_PASSED(timestamp, last_timestamp + mouse_read_interval)) { + // if hidMouseRead is called once per frame, a factor two on the velocities + // results in approximately the same mouse motion as reported by mouse_pos.x and mouse_pos.y + // but without the clamping to 1280 x 720 + if(state_count > 0) { + dx = mouse_state.delta_x * 2; + dy = mouse_state.delta_y * 2; + if (dx || dy) { + SDL_SendMouseMotion(window, 0, 1, dx, dy); + } + } + last_timestamp = timestamp; + } +} + +void +SWITCH_QuitMouse(void) +{ +} + +#endif /* SDL_VIDEO_DRIVER_SWITCH */ + +/* vi: set ts=4 sw=4 expandtab: */ \ No newline at end of file diff --git a/src/video/switch/SDL_switchmouse_c.h b/src/video/switch/SDL_switchmouse_c.h new file mode 100644 index 000000000..c2bd2cfc0 --- /dev/null +++ b/src/video/switch/SDL_switchmouse_c.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_switchmouse_h +#define _SDL_switchmouse_h + +#include "../../SDL_internal.h" + +/* mouse functions */ +extern void SWITCH_InitMouse(void); +extern void SWITCH_PollMouse(void); +extern void SWITCH_QuitMouse(void); + +#endif /* _SDL_switchmouse_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/switch/SDL_switchopengles.c b/src/video/switch/SDL_switchopengles.c new file mode 100644 index 000000000..efed92328 --- /dev/null +++ b/src/video/switch/SDL_switchopengles.c @@ -0,0 +1,53 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" +#include "SDL_log.h" + +#if SDL_VIDEO_DRIVER_SWITCH + +#include "SDL_video.h" +#include "SDL_switchopengles.h" +#include "SDL_switchvideo.h" + +/* EGL implementation of SDL OpenGL support */ + +void +SWITCH_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor) +{ + *mask = SDL_GL_CONTEXT_PROFILE_ES; + *major = 2; + *minor = 0; +} + +int +SWITCH_GLES_LoadLibrary(_THIS, const char *path) +{ + return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY, 0); +} + +SDL_EGL_CreateContext_impl(SWITCH) +SDL_EGL_MakeCurrent_impl(SWITCH) +SDL_EGL_SwapWindow_impl(SWITCH) + +#endif /* SDL_VIDEO_DRIVER_SWITCH */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/switch/SDL_switchopengles.h b/src/video/switch/SDL_switchopengles.h new file mode 100644 index 000000000..3beb5eea7 --- /dev/null +++ b/src/video/switch/SDL_switchopengles.h @@ -0,0 +1,49 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifndef SDL_switchteopengles_h_ +#define SDL_switchteopengles_h_ + +#if SDL_VIDEO_DRIVER_SWITCH + +#include "../SDL_sysvideo.h" +#include "../SDL_egl_c.h" + +/* OpenGLES functions */ +#define SWITCH_GLES_GetAttribute SDL_EGL_GetAttribute +#define SWITCH_GLES_GetProcAddress SDL_EGL_GetProcAddress +#define SWITCH_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define SWITCH_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define SWITCH_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define SWITCH_GLES_DeleteContext SDL_EGL_DeleteContext + +extern int SWITCH_GLES_LoadLibrary(_THIS, const char *path); +extern SDL_GLContext SWITCH_GLES_CreateContext(_THIS, SDL_Window *window); +extern int SWITCH_GLES_SwapWindow(_THIS, SDL_Window *window); +extern int SWITCH_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); +extern void SWITCH_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor); +extern void SWITCH_GLES_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h); + +#endif /* SDL_VIDEO_DRIVER_SWITCH */ +#endif /* SDL_switchteopengles_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/switch/SDL_switchswkb.c b/src/video/switch/SDL_switchswkb.c new file mode 100644 index 000000000..1a7a4b546 --- /dev/null +++ b/src/video/switch/SDL_switchswkb.c @@ -0,0 +1,111 @@ +// +// Created by cpasjuste on 22/04/2020. +// + +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_SWITCH + +#include +#include "SDL_switchswkb.h" + +static SwkbdInline kbd; +static SwkbdAppearArg kbdAppearArg; +static bool kbdInited = SDL_FALSE; +static bool kbdShown = SDL_FALSE; + +void +SWITCH_InitSwkb() +{ +} + +void +SWITCH_PollSwkb(void) +{ + if(kbdInited) { + if(kbdShown) { + swkbdInlineUpdate(&kbd, NULL); + } else if(SDL_IsTextInputActive()) { + SDL_StopTextInput(); + } + } +} + +void +SWITCH_QuitSwkb() +{ + if(kbdInited) { + swkbdInlineClose(&kbd); + kbdInited = false; + } +} + +SDL_bool +SWITCH_HasScreenKeyboardSupport(_THIS) +{ + return SDL_TRUE; +} + +SDL_bool +SWITCH_IsScreenKeyboardShown(_THIS, SDL_Window *window) +{ + return kbdShown; +} + +static void +SWITCH_EnterCb(const char *str, SwkbdDecidedEnterArg* arg) +{ + if(arg->stringLen > 0) { + SDL_SendKeyboardText(str); + } + + kbdShown = false; +} + +static void +SWITCH_CancelCb(void) +{ + SDL_StopTextInput(); +} + +void +SWITCH_StartTextInput(_THIS) +{ + Result rc; + + if(!kbdInited) { + rc = swkbdInlineCreate(&kbd); + if (R_SUCCEEDED(rc)) { + rc = swkbdInlineLaunchForLibraryApplet(&kbd, SwkbdInlineMode_AppletDisplay, 0); + if(R_SUCCEEDED(rc)) { + swkbdInlineSetDecidedEnterCallback(&kbd, SWITCH_EnterCb); + swkbdInlineSetDecidedCancelCallback(&kbd, SWITCH_CancelCb); + swkbdInlineMakeAppearArg(&kbdAppearArg, SwkbdType_Normal); + swkbdInlineAppearArgSetOkButtonText(&kbdAppearArg, "Submit"); + kbdAppearArg.dicFlag = 1; + kbdAppearArg.returnButtonFlag = 1; + kbdInited = true; + } + } + } + + if(kbdInited) { + swkbdInlineSetInputText(&kbd, ""); + swkbdInlineSetCursorPos(&kbd, 0); + swkbdInlineUpdate(&kbd, NULL); + swkbdInlineAppear(&kbd, &kbdAppearArg); + kbdShown = true; + } +} + +void +SWITCH_StopTextInput(_THIS) +{ + if(kbdInited) { + swkbdInlineDisappear(&kbd); + } + + kbdShown = false; +} + +#endif diff --git a/src/video/switch/SDL_switchswkb.h b/src/video/switch/SDL_switchswkb.h new file mode 100644 index 000000000..988728c08 --- /dev/null +++ b/src/video/switch/SDL_switchswkb.h @@ -0,0 +1,20 @@ +// +// Created by cpasjuste on 22/04/2020. +// + +#ifndef SDL2_SDL_SWITCHSWKB_H +#define SDL2_SDL_SWITCHSWKB_H + +#include "../../events/SDL_events_c.h" + +extern void SWITCH_InitSwkb(); +extern void SWITCH_PollSwkb(); +extern void SWITCH_QuitSwkb(); + +extern SDL_bool SWITCH_HasScreenKeyboardSupport(_THIS); +extern SDL_bool SWITCH_IsScreenKeyboardShown(_THIS, SDL_Window * window); + +extern void SWITCH_StartTextInput(_THIS); +extern void SWITCH_StopTextInput(_THIS); + +#endif //SDL2_SDL_SWITCHSWKB_H diff --git a/src/video/switch/SDL_switchtouch.c b/src/video/switch/SDL_switchtouch.c new file mode 100644 index 000000000..ab1e2c77e --- /dev/null +++ b/src/video/switch/SDL_switchtouch.c @@ -0,0 +1,122 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_SWITCH + +#include + +#include "SDL_events.h" +#include "SDL_hints.h" +#include "../../events/SDL_touch_c.h" +#include "../../video/SDL_sysvideo.h" + +static HidTouchScreenState touchState; +static HidTouchScreenState touchStateOld; + +void SWITCH_InitTouch(void) +{ + hidInitializeTouchScreen(); + SDL_AddTouch((SDL_TouchID) 0, SDL_TOUCH_DEVICE_DIRECT, "Switch"); + SDL_SetHintWithPriority(SDL_HINT_TOUCH_MOUSE_EVENTS, "0", SDL_HINT_DEFAULT); + SDL_memset(&touchState, 0, sizeof(HidTouchScreenState)); + SDL_memset(&touchStateOld, 0, sizeof(HidTouchScreenState)); +} + +void SWITCH_QuitTouch(void) +{ +} + +void SWITCH_PollTouch(void) +{ + const float rel_w = 1280.0f, rel_h = 720.0f; + SDL_Window *window = SDL_GetFocusWindow(); + SDL_TouchID id = 1; + SDL_bool found; + s32 i, j; + + if (!window) { + return; + } + + if (SDL_AddTouch(id, SDL_TOUCH_DEVICE_DIRECT, "") < 0) { + SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__); + } + + SDL_memcpy(&touchStateOld, &touchState, sizeof(touchState)); + + if (hidGetTouchScreenStates(&touchState, 1)) { + /* Finger down */ + if (touchStateOld.count < touchState.count) { + for (i = 0; i < touchState.count; i++) { + found = SDL_FALSE; + + for (j = 0; j < touchStateOld.count; j++) { + if (touchStateOld.touches[j].finger_id == touchState.touches[i].finger_id) { + found = SDL_TRUE; + break; + } + } + + if (!found) { + SDL_SendTouch(id, + touchState.touches[i].finger_id, + window, SDL_TRUE, + (float)touchState.touches[i].x / rel_w, + (float)touchState.touches[i].y / rel_h, 1); + } + } + } + + /* Scan for moves or up */ + for (i = 0; i < touchStateOld.count; i++) { + found = SDL_FALSE; + + for (j = 0; j < touchState.count; j++) { + if (touchState.touches[j].finger_id == touchStateOld.touches[i].finger_id) { + found = SDL_TRUE; + /* Finger moved */ + if (touchState.touches[j].x != touchStateOld.touches[i].x || touchState.touches[j].y != touchStateOld.touches[i].y) { + SDL_SendTouchMotion(id, + (SDL_FingerID)i, window, + (float)touchState.touches[j].x / rel_w, + (float)touchState.touches[j].y / rel_h, 1); + } + break; + } + } + + if (!found) { + /* Finger Up */ + SDL_SendTouch(id, + (SDL_FingerID)touchStateOld.touches[i].finger_id, + window, + SDL_FALSE, + (float) touchStateOld.touches[i].x / rel_w, + (float) touchStateOld.touches[i].y / rel_h, 1); + } + } + } +} + +#endif /* SDL_VIDEO_DRIVER_SWITCH */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/switch/SDL_switchtouch.h b/src/video/switch/SDL_switchtouch.h new file mode 100644 index 000000000..ac5908e39 --- /dev/null +++ b/src/video/switch/SDL_switchtouch.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_switchtouch_h +#define _SDL_switchtouch_h + +#include "../../SDL_internal.h" + +/* Touch functions */ +extern void SWITCH_InitTouch(void); +extern void SWITCH_QuitTouch(void); +extern void SWITCH_PollTouch(void); + +#endif /* _SDL_switchtouch_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/switch/SDL_switchvideo.c b/src/video/switch/SDL_switchvideo.c new file mode 100644 index 000000000..262372bd1 --- /dev/null +++ b/src/video/switch/SDL_switchvideo.c @@ -0,0 +1,380 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_SWITCH + +#include "../SDL_sysvideo.h" +#include "../../render/SDL_sysrender.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_windowevents_c.h" + +#include "SDL_switchvideo.h" +#include "SDL_switchopengles.h" +#include "SDL_switchtouch.h" +#include "SDL_switchkeyboard.h" +#include "SDL_switchmouse_c.h" +#include "SDL_switchswkb.h" + +/* Currently only one window */ +static SDL_Window *switch_window = NULL; +static AppletOperationMode operationMode; + +static void +SWITCH_Destroy(SDL_VideoDevice *device) +{ + if (device != NULL) { + if(device->driverdata != NULL) { + SDL_free(device->driverdata); + } + SDL_free(device); + } +} + +static SDL_VideoDevice * +SWITCH_CreateDevice() +{ + SDL_VideoDevice *device; + + /* Initialize SDL_VideoDevice structure */ + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (device == NULL) { + SDL_OutOfMemory(); + return NULL; + } + + /* Setup amount of available displays */ + device->num_displays = 0; + + /* Set device free function */ + device->free = SWITCH_Destroy; + + /* Setup all functions which we can handle */ + device->VideoInit = SWITCH_VideoInit; + device->VideoQuit = SWITCH_VideoQuit; + device->GetDisplayModes = SWITCH_GetDisplayModes; + device->SetDisplayMode = SWITCH_SetDisplayMode; + device->CreateSDLWindow = SWITCH_CreateWindow; + device->CreateSDLWindowFrom = SWITCH_CreateWindowFrom; + device->SetWindowTitle = SWITCH_SetWindowTitle; + device->SetWindowIcon = SWITCH_SetWindowIcon; + device->SetWindowPosition = SWITCH_SetWindowPosition; + device->SetWindowSize = SWITCH_SetWindowSize; + device->ShowWindow = SWITCH_ShowWindow; + device->HideWindow = SWITCH_HideWindow; + device->RaiseWindow = SWITCH_RaiseWindow; + device->MaximizeWindow = SWITCH_MaximizeWindow; + device->MinimizeWindow = SWITCH_MinimizeWindow; + device->RestoreWindow = SWITCH_RestoreWindow; + //device->SetWindowMouseGrab = SWITCH_SetWindowGrab; // SDL 2.0.16 + //device->SetWindowKeyboardGrab = SWITCH_SetWindowGrab; // SDL 2.0.16 + device->DestroyWindow = SWITCH_DestroyWindow; + + device->GL_LoadLibrary = SWITCH_GLES_LoadLibrary; + device->GL_GetProcAddress = SWITCH_GLES_GetProcAddress; + device->GL_UnloadLibrary = SWITCH_GLES_UnloadLibrary; + device->GL_CreateContext = SWITCH_GLES_CreateContext; + device->GL_MakeCurrent = SWITCH_GLES_MakeCurrent; + device->GL_SetSwapInterval = SWITCH_GLES_SetSwapInterval; + device->GL_GetSwapInterval = SWITCH_GLES_GetSwapInterval; + device->GL_SwapWindow = SWITCH_GLES_SwapWindow; + device->GL_DeleteContext = SWITCH_GLES_DeleteContext; + device->GL_DefaultProfileConfig = SWITCH_GLES_DefaultProfileConfig; + + device->StartTextInput = SWITCH_StartTextInput; + device->StopTextInput = SWITCH_StopTextInput; + device->HasScreenKeyboardSupport = SWITCH_HasScreenKeyboardSupport; + device->IsScreenKeyboardShown = SWITCH_IsScreenKeyboardShown; + + device->PumpEvents = SWITCH_PumpEvents; + + return device; +} + +VideoBootStrap SWITCH_bootstrap = { + "Switch", + "Nintendo Switch Video Driver", + SWITCH_CreateDevice +}; + +/*****************************************************************************/ +/* SDL Video and Display initialization/handling functions */ +/*****************************************************************************/ +int +SWITCH_VideoInit(_THIS) +{ + SDL_VideoDisplay display; + SDL_DisplayMode current_mode; + + SDL_zero(current_mode); + current_mode.w = 1920; + current_mode.h = 1080; + current_mode.refresh_rate = 60; + current_mode.format = SDL_PIXELFORMAT_RGBA8888; + current_mode.driverdata = NULL; + + SDL_zero(display); + display.desktop_mode = current_mode; + display.current_mode = current_mode; + display.driverdata = NULL; + SDL_AddVideoDisplay(&display, SDL_FALSE); + + // init psm service + psmInitialize(); + // init touch + SWITCH_InitTouch(); + // init keyboard + SWITCH_InitKeyboard(); + // init mouse + SWITCH_InitMouse(); + // init software keyboard + SWITCH_InitSwkb(); + + return 0; +} + +void +SWITCH_VideoQuit(_THIS) +{ + // this should not be needed if user code is right (SDL_GL_LoadLibrary/SDL_GL_UnloadLibrary calls match) + // this (user) error doesn't have the same effect on switch thought, as the driver needs to be unloaded (crash) + if(_this->gl_config.driver_loaded > 0) { + SWITCH_GLES_UnloadLibrary(_this); + _this->gl_config.driver_loaded = 0; + } + + // exit touch + SWITCH_QuitTouch(); + // exit keyboard + SWITCH_QuitKeyboard(); + // exit mouse + SWITCH_QuitMouse(); + // exit software keyboard + SWITCH_QuitSwkb(); + // exit psm service + psmExit(); +} + +void +SWITCH_GetDisplayModes(_THIS, SDL_VideoDisplay *display) +{ + SDL_DisplayMode mode; + + // 1920x1080 RGBA8888, default mode + SDL_AddDisplayMode(display, &display->current_mode); + + // 1280x720 RGBA8888 + SDL_zero(mode); + mode.w = 1280; + mode.h = 720; + mode.refresh_rate = 60; + mode.format = SDL_PIXELFORMAT_RGBA8888; + SDL_AddDisplayMode(display, &mode); +} + +int +SWITCH_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + SDL_WindowData *data = (SDL_WindowData *) SDL_GetFocusWindow()->driverdata; + SDL_GLContext ctx = SDL_GL_GetCurrentContext(); + NWindow *nWindow = nwindowGetDefault(); + + if (data != NULL && data->egl_surface != EGL_NO_SURFACE) { + SDL_EGL_MakeCurrent(_this, NULL, NULL); + SDL_EGL_DestroySurface(_this, data->egl_surface); + nwindowSetDimensions(nWindow, mode->w, mode->h); + data->egl_surface = SDL_EGL_CreateSurface(_this, nWindow); + SDL_EGL_MakeCurrent(_this, data->egl_surface, ctx); + } + + return 0; +} + +int +SWITCH_CreateWindow(_THIS, SDL_Window *window) +{ + Result rc; + SDL_WindowData *window_data = NULL; + NWindow *nWindow = NULL; + + if (switch_window != NULL) { + return SDL_SetError("Switch only supports one window"); + } + + if (!_this->egl_data) { + return SDL_SetError("EGL not initialized"); + } + + window_data = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); + if (window_data == NULL) { + return SDL_OutOfMemory(); + } + + nWindow = nwindowGetDefault(); + + rc = nwindowSetDimensions(nWindow, window->w, window->h); + if (R_FAILED(rc)) { + return SDL_SetError("Could not set NWindow dimensions: 0x%x", rc); + } + + window_data->egl_surface = SDL_EGL_CreateSurface(_this, nWindow); + if (window_data->egl_surface == EGL_NO_SURFACE) { + return SDL_SetError("Could not create GLES window surface"); + } + + /* Setup driver data for this window */ + window->driverdata = window_data; + switch_window = window; + + /* starting operation mode */ + operationMode = appletGetOperationMode(); + + /* One window, it always has focus */ + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); + + /* Window has been successfully created */ + return 0; +} + +void +SWITCH_DestroyWindow(_THIS, SDL_Window *window) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + + if (window == switch_window) { + if (data != NULL) { + if (data->egl_surface != EGL_NO_SURFACE) { + SDL_EGL_MakeCurrent(_this, NULL, NULL); + SDL_EGL_DestroySurface(_this, data->egl_surface); + } + if(window->driverdata != NULL) { + SDL_free(window->driverdata); + window->driverdata = NULL; + } + } + switch_window = NULL; + } +} + +int +SWITCH_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) +{ + return -1; +} +void +SWITCH_SetWindowTitle(_THIS, SDL_Window *window) +{ +} +void +SWITCH_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon) +{ +} +void +SWITCH_SetWindowPosition(_THIS, SDL_Window *window) +{ +} +void +SWITCH_SetWindowSize(_THIS, SDL_Window *window) +{ + u32 w = 0, h = 0; + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_GLContext ctx = SDL_GL_GetCurrentContext(); + NWindow *nWindow = nwindowGetDefault(); + + if(window->w != w || window->h != h) { + if (data != NULL && data->egl_surface != EGL_NO_SURFACE) { + SDL_EGL_MakeCurrent(_this, NULL, NULL); + SDL_EGL_DestroySurface(_this, data->egl_surface); + nwindowSetDimensions(nWindow, window->w, window->h); + data->egl_surface = SDL_EGL_CreateSurface(_this, nWindow); + SDL_EGL_MakeCurrent(_this, data->egl_surface, ctx); + } + } +} +void +SWITCH_ShowWindow(_THIS, SDL_Window *window) +{ +} +void +SWITCH_HideWindow(_THIS, SDL_Window *window) +{ +} +void +SWITCH_RaiseWindow(_THIS, SDL_Window *window) +{ +} +void +SWITCH_MaximizeWindow(_THIS, SDL_Window *window) +{ +} +void +SWITCH_MinimizeWindow(_THIS, SDL_Window *window) +{ +} +void +SWITCH_RestoreWindow(_THIS, SDL_Window *window) +{ +} +void +SWITCH_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed) +{ +} + +void +SWITCH_PumpEvents(_THIS) +{ + AppletOperationMode om; + + if (!appletMainLoop()) { + SDL_Event ev; + ev.type = SDL_QUIT; + SDL_PushEvent(&ev); + return; + } + + // we don't want other inputs overlapping with software keyboard + if(!SDL_IsTextInputActive()) { + SWITCH_PollTouch(); + SWITCH_PollKeyboard(); + SWITCH_PollMouse(); + } + SWITCH_PollSwkb(); + + // handle docked / un-docked modes + // note that SDL_WINDOW_RESIZABLE is only possible in windowed mode, + // so we don't care about current fullscreen/windowed status + if(switch_window != NULL && switch_window->flags & SDL_WINDOW_RESIZABLE) { + om = appletGetOperationMode(); + if(om != operationMode) { + operationMode = om; + if(operationMode == AppletOperationMode_Handheld) { + SDL_SetWindowSize(switch_window, 1280, 720); + } else { + SDL_SetWindowSize(switch_window, 1920, 1080); + } + } + } +} + +#endif /* SDL_VIDEO_DRIVER_SWITCH */ \ No newline at end of file diff --git a/src/video/switch/SDL_switchvideo.h b/src/video/switch/SDL_switchvideo.h new file mode 100644 index 000000000..d34643ed4 --- /dev/null +++ b/src/video/switch/SDL_switchvideo.h @@ -0,0 +1,62 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef __SDL_SWITCHVIDEO_H__ +#define __SDL_SWITCHVIDEO_H__ + +#if SDL_VIDEO_DRIVER_SWITCH + +#include + +#include "../../SDL_internal.h" +#include "../SDL_sysvideo.h" + +#include "SDL_egl.h" + +typedef struct SDL_WindowData +{ + EGLSurface egl_surface; +} SDL_WindowData; + +int SWITCH_VideoInit(_THIS); +void SWITCH_VideoQuit(_THIS); +void SWITCH_GetDisplayModes(_THIS, SDL_VideoDisplay *display); +int SWITCH_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +int SWITCH_CreateWindow(_THIS, SDL_Window *window); +int SWITCH_CreateWindowFrom(_THIS, SDL_Window *window, const void *data); +void SWITCH_SetWindowTitle(_THIS, SDL_Window *window); +void SWITCH_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon); +void SWITCH_SetWindowPosition(_THIS, SDL_Window *window); +void SWITCH_SetWindowSize(_THIS, SDL_Window *window); +void SWITCH_ShowWindow(_THIS, SDL_Window *window); +void SWITCH_HideWindow(_THIS, SDL_Window *window); +void SWITCH_RaiseWindow(_THIS, SDL_Window *window); +void SWITCH_MaximizeWindow(_THIS, SDL_Window *window); +void SWITCH_MinimizeWindow(_THIS, SDL_Window *window); +void SWITCH_RestoreWindow(_THIS, SDL_Window *window); +void SWITCH_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed); +void SWITCH_DestroyWindow(_THIS, SDL_Window *window); +void SWITCH_PumpEvents(_THIS); + +#endif /* SDL_VIDEO_DRIVER_SWITCH */ +#endif /* __SDL_SWITCHVIDEO_H__ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/test/testswitch.c b/test/testswitch.c new file mode 100644 index 000000000..51012e481 --- /dev/null +++ b/test/testswitch.c @@ -0,0 +1,239 @@ +/* + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely. +*/ + +#include +#include + +#include +#include "SDL2/SDL.h" + +static SDL_DisplayMode modes[5]; + +static int mode_count = 0, current_mode = 0; + +void print_info(SDL_Window *window, SDL_Renderer *renderer) +{ + int w, h; + SDL_DisplayMode mode; + + SDL_GetWindowSize(window, &w, &h); + SDL_Log("window size: %i x %i\n", w, h); + SDL_GetRendererOutputSize(renderer, &w, &h); + SDL_Log("renderer size: %i x %i\n", w, h); + + SDL_GetCurrentDisplayMode(0, &mode); + SDL_Log("display mode: %i x %i @ %i bpp (%s)", + mode.w, mode.h, + SDL_BITSPERPIXEL(mode.format), + SDL_GetPixelFormatName(mode.format)); +} + +void change_mode(SDL_Window *window) +{ + current_mode++; + if (current_mode == mode_count) { + current_mode = 0; + } + + SDL_SetWindowDisplayMode(window, &modes[current_mode]); +} + +void draw_rects(SDL_Renderer *renderer, int x, int y) +{ + // R + SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); + SDL_Rect r = {x, y, 64, 64}; + SDL_RenderFillRect(renderer, &r); + + // G + SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255); + SDL_Rect g = {x + 64, y, 64, 64}; + SDL_RenderFillRect(renderer, &g); + + // B + SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255); + SDL_Rect b = {x + 128, y, 64, 64}; + SDL_RenderFillRect(renderer, &b); +} + +int main(int argc, char *argv[]) +{ + SDL_Event event; + SDL_Window *window; + SDL_Renderer *renderer; + int done = 0, x = 0, w = 0, h = 0; + + // mandatory at least on switch, else gfx is not properly closed + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { + SDL_Log("SDL_Init: %s\n", SDL_GetError()); + return -1; + } + + /// create a window (OpenGL always enabled) + /// available switch SDL2 video modes : + /// 1920 x 1080 @ 32 bpp (SDL_PIXELFORMAT_RGBA8888) + /// 1280 x 720 @ 32 bpp (SDL_PIXELFORMAT_RGBA8888) + /// + /// SDL_SetWindowSize to change window size when SDL_WINDOW_FULLSCREEN is NOT used (preferably) + /// SDL_SetDisplayMode to change display size after SDL_CreateWindow called with SDL_WINDOW_FULLSCREEN + /// (this means window size won't change, you'll need to handle that, as any SDL2 app) + window = SDL_CreateWindow("sdl2_gles2", 0, 0, 1280, 720, 0); + if (!window) { + SDL_Log("SDL_CreateWindow: %s\n", SDL_GetError()); + SDL_Quit(); + return -1; + } + + // create a renderer (OpenGL ES2) + renderer = SDL_CreateRenderer(window, 0, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); + if (!renderer) { + SDL_Log("SDL_CreateRenderer: %s\n", SDL_GetError()); + SDL_Quit(); + return -1; + } + + // pint some info about display/window/renderer + print_info(window, renderer); + + // list available display modes + mode_count = SDL_GetNumDisplayModes(0); + for (int i = 0; i < mode_count; i++) { + SDL_DisplayMode mode; + SDL_GetDisplayMode(0, i, &mode); + modes[i] = mode; + SDL_Log("found display mode: %i x %i @ %i bpp (%s)", + mode.w, mode.h, + SDL_BITSPERPIXEL(mode.format), + SDL_GetPixelFormatName(mode.format)); + } + + // open CONTROLLER_PLAYER_1 and CONTROLLER_PLAYER_2 + // when railed, both joycons are mapped to joystick #0, + // else joycons are individually mapped to joystick #0, joystick #1, ... + // https://github.com/devkitPro/SDL/blob/switch-sdl2/src/joystick/switch/SDL_sysjoystick.c#L45 + for (int i = 0; i < 2; i++) { + if (SDL_JoystickOpen(i) == NULL) { + SDL_Log("SDL_JoystickOpen: %s\n", SDL_GetError()); + SDL_Quit(); + return -1; + } + } + + while (!done) { + + while (SDL_PollEvent(&event)) { + + switch (event.type) { + + case SDL_JOYAXISMOTION: + SDL_Log("Joystick %d axis %d value: %d\n", + event.jaxis.which, + event.jaxis.axis, event.jaxis.value); + break; + + case SDL_JOYBUTTONDOWN: + SDL_Log("Joystick %d button %d down\n", + event.jbutton.which, event.jbutton.button); + // https://github.com/devkitPro/SDL/blob/switch-sdl2/src/joystick/switch/SDL_sysjoystick.c#L52 + if (event.jbutton.which == 0) { + if (event.jbutton.button == 0) { + // joystick #0 down (A) + change_mode(window); + print_info(window, renderer); + } + else if (event.jbutton.button == 2) { + // joystick #0 down (X) + if (w == 1920) { + SDL_SetWindowSize(window, 1280, 720); + } + else { + SDL_SetWindowSize(window, 1920, 1080); + } + print_info(window, renderer); + } + } + // joystick #0 down (B) + if (event.jbutton.which == 0 && event.jbutton.button == 1) { + done = 1; + } + break; + + default: + break; + } + } + + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderClear(renderer); + + // Fill renderer bounds + SDL_SetRenderDrawColor(renderer, 111, 111, 111, 255); + SDL_GetWindowSize(window, &w, &h); + SDL_Rect f = {0, 0, w, h}; + SDL_RenderFillRect(renderer, &f); + + draw_rects(renderer, x, 0); + draw_rects(renderer, x, h - 64); + + SDL_RenderPresent(renderer); + + x++; + if (x > w - 192) { + x = 0; + } + } + + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); + SDL_Quit(); + + return 0; +} + +//----------------------------------------------------------------------------- +// nxlink support +//----------------------------------------------------------------------------- + +#include + +static int s_nxlinkSock = -1; + +static void initNxLink() +{ + if (R_FAILED(socketInitializeDefault())) + return; + + s_nxlinkSock = nxlinkStdio(); + if (s_nxlinkSock >= 0) + printf("printf output now goes to nxlink server\n"); + else + socketExit(); +} + +static void deinitNxLink() +{ + if (s_nxlinkSock >= 0) { + close(s_nxlinkSock); + socketExit(); + s_nxlinkSock = -1; + } +} + +void userAppInit() +{ + initNxLink(); +} + +void userAppExit() +{ + deinitNxLink(); +} ================================================ FILE: switch/SDL2_gfx/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: TurtleP pkgname=switch-sdl2_gfx pkgver=1.0.4 pkgrel=2 pkgdesc="SDL2 graphics drawing primitives (Nintendo Switch port)." arch=('any') url="https://libsdl.org" license=("zlib") options=(!strip libtool staticlibs) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') depends=('switch-sdl2') source=("http://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-1.0.4.tar.gz" "config.sub" "config.guess") sha256sums=( '63e0e01addedc9df2f85b93a248f06e8a04affa014a835c2ea34bfe34e576262' '72e02ea93447038f8ced24f296b31e0f397bbcc6b32abdcf9b38c80f153433fd' 'fbc2337aa59a204f5d74743b82c8be7aab8b39853b4e54a888008f70430c4305' ) groups=('switch-portlibs' 'switch-sdl2') build() { cp config.sub SDL2_gfx-$pkgver cp config.guess SDL2_gfx-$pkgver cd SDL2_gfx-$pkgver ./autogen.sh source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" \ --enable-mmx=no \ --host=aarch64-none-elf \ --disable-shared --enable-static \ --with-sdl-prefix=${PORTLIBS_PREFIX} make } package() { cd SDL2_gfx-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: switch/SDL2_gfx/config.guess ================================================ #! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2015 Free Software Foundation, Inc. timestamp='2015-08-20' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ /sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || \ echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` machine=${arch}${endian}-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case "${UNAME_MACHINE_ARCH}" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; *:Sortix:*:*) echo ${UNAME_MACHINE}-unknown-sortix exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; e2k:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: ================================================ FILE: switch/SDL2_gfx/config.sub ================================================ #! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2015 Free Software Foundation, Inc. timestamp='2015-08-20' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | e2k | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; asmjs) basic_machine=asmjs-unknown ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; leon-*|leon[3-9]-*) basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: ================================================ FILE: switch/SDL2_image/Makefile.in.patch ================================================ --- Makefile.in.orig 2018-10-31 09:59:00.000000000 -0500 +++ Makefile.in 2019-06-26 01:23:45.000000000 -0500 @@ -95,7 +95,6 @@ host_triplet = @host@ @USE_VERSION_RC_FALSE@libSDL2_image_la_DEPENDENCIES = \ @USE_VERSION_RC_FALSE@ $(am__DEPENDENCIES_1) -noinst_PROGRAMS = showimage$(EXEEXT) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude/libtool.m4 \ @@ -164,9 +163,6 @@ libSDL2_image_la_LINK = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(OBJCLD) $(AM_OBJCFLAGS) \ $(OBJCFLAGS) $(libSDL2_image_la_LDFLAGS) $(LDFLAGS) -o $@ -showimage_SOURCES = showimage.c -showimage_OBJECTS = showimage.$(OBJEXT) -showimage_DEPENDENCIES = libSDL2_image.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -476,7 +472,6 @@ @USE_VERSION_RC_TRUE@libSDL2_image_la_DEPENDENCIES = version.o pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = SDL2_image.pc -showimage_LDADD = libSDL2_image.la all: all-am .SUFFIXES: @@ -566,10 +561,6 @@ libSDL2_image.la: $(libSDL2_image_la_OBJECTS) $(libSDL2_image_la_DEPENDENCIES) $(EXTRA_libSDL2_image_la_DEPENDENCIES) $(AM_V_OBJCLD)$(libSDL2_image_la_LINK) -rpath $(libdir) $(libSDL2_image_la_OBJECTS) $(libSDL2_image_la_LIBADD) $(LIBS) -showimage$(EXEEXT): $(showimage_OBJECTS) $(showimage_DEPENDENCIES) $(EXTRA_showimage_DEPENDENCIES) - @rm -f showimage$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(showimage_OBJECTS) $(showimage_LDADD) $(LIBS) - mostlyclean-compile: -rm -f *.$(OBJEXT) ================================================ FILE: switch/SDL2_image/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Cpasjuste # Contributor: carstene1ns pkgname=switch-sdl2_image pkgver=2.0.4 pkgrel=1 pkgdesc="SDL2 image loading library (Nintendo Switch port)." arch=('any') url="https://libsdl.org/projects/SDL_image/" license=("zlib") options=(!strip libtool staticlibs) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') depends=( 'switch-sdl2' 'switch-libpng' 'switch-libjpeg-turbo' 'switch-libwebp' ) source=("${url}release/SDL2_image-${pkgver}.tar.gz" "Makefile.in.patch") sha256sums=( 'e74ec49c2402eb242fbfa16f2f43a19582a74c2eabfbfb873f00d4250038ceac' 'c15da8e087e7ca4ceef3dcce8501b21cbe6569563c345cf2a1591f20316d8d86' ) groups=('switch-portlibs' 'switch-sdl2-libs') build() { cd SDL2_image-$pkgver source ${DEVKITPRO}/switchvars.sh patch -Np1 -i "$srcdir"/Makefile.in.patch Makefile.in ./configure --prefix="${PORTLIBS_PREFIX}" \ --host=aarch64-none-elf --disable-shared --enable-static \ --disable-sdltest \ --with-sdl-prefix=${PORTLIBS_PREFIX} make } package() { cd SDL2_image-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install # add our static libs echo "Requires.private: libpng libjpeg libwebp" >> "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/SDL2_image.pc" # License install -Dm644 "COPYING.txt" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/COPYING.txt" } ================================================ FILE: switch/SDL2_mixer/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Cpasjuste # Contributor: carstene1ns pkgname=switch-sdl2_mixer pkgver=2.0.4 pkgrel=2 pkgdesc="A sample multi-channel audio mixer library." arch=('any') url="https://libsdl.org/projects/SDL_mixer/" license=("zlib") options=(!strip libtool staticlibs) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') depends=( 'switch-sdl2' 'switch-flac' 'switch-libvorbisidec' 'switch-libmodplug' 'switch-mpg123' 'switch-opusfile' ) source=("${url}release/SDL2_mixer-${pkgver}.tar.gz") sha256sums=('b4cf5a382c061cd75081cf246c2aa2f9df8db04bdda8dcdc6b6cca55bede2419') groups=('switch-portlibs' 'switch-sdl2') build() { cd SDL2_mixer-$pkgver source ${DEVKITPRO}/switchvars.sh # patch out compiling playwave and playmus sed 's|\$(objects)/play.*mus\$(EXE)||' -i Makefile.in LIBS="-lm" ./configure --prefix="${PORTLIBS_PREFIX}" \ --host=aarch64-none-elf --disable-shared --enable-static \ --disable-music-cmd \ --enable-music-ogg-tremor \ --enable-music-mod-modplug make } package() { cd SDL2_mixer-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install # add our static libs echo "Requires.private: vorbisidec libmodplug libmpg123 opusfile" >> "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/SDL2_mixer.pc" # License install -Dm644 "COPYING.txt" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/COPYING.txt" } ================================================ FILE: switch/SDL2_net/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=switch-sdl2_net pkgver=2.0.1 pkgrel=3 pkgdesc="A small sample cross-platform networking library." arch=('any') url="https://libsdl.org/projects/SDL_net/" license=("MIT") options=(!strip libtool staticlibs) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') depends=( 'switch-sdl2' ) source=("${url}release/SDL2_net-${pkgver}.tar.gz") sha256sums=('15ce8a7e5a23dafe8177c8df6e6c79b6749a03fff1e8196742d3571657609d21') groups=('switch-portlibs' 'switch-sdl2-libs') build() { cd SDL2_net-$pkgver source ${DEVKITPRO}/switchvars.sh sed '/^noinst_PROGRAMS/d' -i Makefile.in ./configure --prefix="${PORTLIBS_PREFIX}" \ --host=aarch64-none-elf --disable-shared --enable-static \ --disable-sdltest \ --with-sdl-prefix=${PORTLIBS_PREFIX} make } package() { cd SDL2_net-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install # License install -Dm644 "COPYING.txt" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/COPYING.txt" } ================================================ FILE: switch/SDL2_ttf/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Cpasjuste # Contributor: carstene1ns pkgname=switch-sdl2_ttf pkgver=2.22.0 pkgrel=2 pkgdesc="SDL2 TrueType font library." arch=('any') url="https://libsdl.org/projects/SDL_ttf/" license=("zlib") options=(!strip libtool staticlibs) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') depends=( 'switch-sdl2' 'switch-freetype' 'switch-harfbuzz' ) source=("${url}release/SDL2_ttf-${pkgver}.tar.gz") groups=('switch-portlibs' 'switch-sdl2') build() { cd SDL2_ttf-$pkgver source ${DEVKITPRO}/switchvars.sh # patch out compiling showfont and glfont sed '/^noinst_PROGRAMS/d' -i Makefile.in ./configure --prefix="${PORTLIBS_PREFIX}" \ --host=aarch64-none-elf --disable-shared --enable-static \ --disable-harfbuzz-builtin \ --disable-freetype-builtin \ --disable-sdltest --without-x make } package() { cd SDL2_ttf-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install # License install -Dm644 "LICENSE.txt" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/LICENSE.txt" } sha256sums=('d48cbd1ce475b9e178206bf3b72d56b66d84d44f64ac05803328396234d67723') ================================================ FILE: switch/TinyXML2/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=switch-tinyxml2 pkgver=6.0.0 pkgrel=2 pkgdesc='A simple, small, efficient, C++ XML parser that can be easily integrated into other programs (for Nintendo Switch homebrew development)' arch=('any') url='http://leethomason.github.io/tinyxml2/' license=('apache') options=(!strip libtool staticlibs) source=( "https://github.com/leethomason/tinyxml2/archive/${pkgver}.tar.gz" ) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') sha256sums=('9444ba6322267110b4aca61cbe37d5dcab040344b5c97d0b36c119aa61319b0f') groups=('switch-portlibs') build() { cd tinyxml2-$pkgver source /opt/devkitpro/switchvars.sh cmake -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/switch.cmake \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DCMAKE_C_FLAGS="$CFLAGS $CPPFLAGS" \ -DCMAKE_CXX_FLAGS="$CFLAGS" \ -DBUILD_TESTS:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON \ -G"Unix Makefiles" \ . make } package() { cd tinyxml2-$pkgver source /opt/devkitpro/switchvars.sh make install DESTDIR="$pkgdir" } ================================================ FILE: switch/box2d/.gitignore ================================================ v*.zip ================================================ FILE: switch/box2d/PKGBUILD ================================================ # Maintainer: cpasjuste pkgbasename=box2d pkgname=switch-$pkgbasename pkgver=2.4.1 pkgrel=1 pkgdesc='Box2D is a 2D physics engine for games.' arch=('any') url='https://github.com/erincatto/box2d' license=(MIT) options=(!strip libtool staticlibs) source=("${url}/archive/refs/tags/v${pkgver}.zip") sha256sums=('0cb512dfa5be79ca227cd881b279adee61249c85c8b51caf5aa036b71e943002') makedepends=('dkp-toolchain-vars' 'switch-cmake') groups=('switch-portlibs') build() { cd ${pkgbasename}-${pkgver} source /opt/devkitpro/switchvars.sh aarch64-none-elf-cmake \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DBOX2D_BUILD_DOCS=OFF -DBOX2D_BUILD_UNIT_TESTS=OFF -DBOX2D_BUILD_TESTBED=OFF \ . make } package() { cd ${pkgbasename}-${pkgver} make install DESTDIR="$pkgdir" } ================================================ FILE: switch/bulletphysics/PKGBUILD ================================================ # Maintainer: fincs pkgname=switch-bulletphysics pkgver=2.88 pkgrel=3 pkgdesc='Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.' arch=('any') url='http://bulletphysics.org/' license=('apache') options=(!strip libtool staticlibs) source=( "https://github.com/bulletphysics/bullet3/archive/${pkgver}.tar.gz" "bulletphysics.patch") makedepends=('devkitA64' 'dkp-toolchain-vars') sha256sums=( '21c135775527754fc2929db1db5144e92ad0218ae72840a9f162acb467a7bbf9' '03735450ca1109ba95c692453049d8ae42b71731247c1623dcebf564287885d7') groups=('switch-portlibs') build() { cd bullet3-$pkgver source ${DEVKITPRO}/switchvars.sh patch -Np1 -i "$srcdir"/bulletphysics.patch aarch64-none-elf-cmake -G"Unix Makefiles" \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DCMAKE_C_FLAGS="$CFLAGS $CPPFLAGS" \ -DCMAKE_CXX_FLAGS="$CFLAGS" \ -DCMAKE_AR="$DEVKITPRO/devkitA64/bin/aarch64-none-elf-gcc-ar" \ -DBUILD_CPU_DEMOS:BOOL=OFF -DBUILD_BULLET3:BOOL=OFF -DBUILD_OPENGL3_DEMOS:BOOL=OFF -DBUILD_BULLET2_DEMOS:BOOL=OFF -DBUILD_EXTRAS:BOOL=OFF -DBUILD_UNIT_TESTS:BOOL=OFF \ . make } package() { cd bullet3-$pkgver source ${DEVKITPRO}/switchvars.sh make install DESTDIR="$pkgdir" } ================================================ FILE: switch/bulletphysics/bulletphysics.patch ================================================ diff -Naur bullet3-2.88/CMakeLists.txt bullet3-2.88-switch/CMakeLists.txt --- bullet3-2.88/CMakeLists.txt 2018-12-31 20:42:41.000000000 +0000 +++ bullet3-2.88-switch/CMakeLists.txt 2019-01-17 19:29:06.146027271 +0000 @@ -285,15 +285,17 @@ # This is the shortcut to finding GLU, GLUT and OpenGL if they are properly installed on your system # This should be the case. -FIND_PACKAGE(OpenGL) -IF (OPENGL_FOUND) +IF(NOT SWITCH_LIBNX) + FIND_PACKAGE(OpenGL) + IF (OPENGL_FOUND) MESSAGE("OPENGL FOUND") MESSAGE(${OPENGL_LIBRARIES}) -ELSE (OPENGL_FOUND) + ELSE (OPENGL_FOUND) MESSAGE("OPENGL NOT FOUND") SET(OPENGL_gl_LIBRARY opengl32) SET(OPENGL_glu_LIBRARY glu32) -ENDIF (OPENGL_FOUND) + ENDIF (OPENGL_FOUND) +ENDIF(NOT SWITCH_LIBNX) #FIND_PACKAGE(GLU) ================================================ FILE: switch/bzip2/.gitignore ================================================ switch-bzip2 ================================================ FILE: switch/bzip2/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('switch-bzip2') pkgver=1.0.8 pkgrel=1 pkgdesc="A high-quality data compression program" arch=('any') license=('custom') url="https://sourceware.org/bzip2/" options=(!strip libtool staticlibs) source=(https://sourceware.org/pub/bzip2/bzip2-${pkgver}.tar.gz) sha256sums=( 'ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269' ) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') groups=('switch-portlibs') build() { source /opt/devkitpro/switchvars.sh make -C "$srcdir/bzip2-$pkgver" \ CC=${TOOL_PREFIX}gcc \ AR=${TOOL_PREFIX}ar \ RANLIB=${TOOL_PREFIX}ranlib \ CPPFLAGS="${CPPFLAGS}" \ CFLAGS="-D_FILE_OFFSET_BITS=64 -Winline ${CFLAGS}" libbz2.a } package() { source /opt/devkitpro/switchvars.sh install -Dm 644 "$srcdir/bzip2-$pkgver"/LICENSE -t "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}" install -Dm 644 "$srcdir/bzip2-$pkgver"/bzlib.h -t "${pkgdir}/${PORTLIBS_PREFIX}/include/" install -Dm 644 "$srcdir/bzip2-$pkgver"/libbz2.a -t "${pkgdir}/${PORTLIBS_PREFIX}/lib" } ================================================ FILE: switch/curl/.gitignore ================================================ switch-curl ================================================ FILE: switch/curl/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=switch-curl pkgver=7.69.1 pkgrel=5 pkgdesc='An URL retrieval utility and library' arch=('any') url='http://www.zlib.net/' license=('zlib') options=(!strip libtool staticlibs) depends=('switch-zlib' 'libnx') makedepends=('switch-pkg-config' 'dkp-toolchain-vars') source=( "https://curl.haxx.se/download/curl-${pkgver}.tar.xz" 'switch-curl.patch' ) groups=('switch-portlibs') sha256sums=( '03c7d5e6697f7b7e40ada1b2256e565a555657398e6c1fcfa4cb251ccd819d4f' '723c7d884fc7c39ae1a3115ba245bb8c1415da47bbd60ab8f943ca98f92ebc9a' ) build() { cd curl-$pkgver patch -Np1 -i $srcdir/switch-curl.patch source /opt/devkitpro/switchvars.sh LDFLAGS="-specs=${DEVKITPRO}/libnx/switch.specs ${LDFLAGS}" ./buildconf ./configure --prefix=$PORTLIBS_PREFIX --host=aarch64-none-elf \ --disable-shared --enable-static --disable-ipv6 --disable-unix-sockets \ --disable-manual --disable-ntlm-wb --disable-threaded-resolver \ --without-ssl --without-polar-ssl --without-cyassl --without-wolfssl \ --without-mbedtls \ --with-libnx \ --with-default-ssl-backend=libnx make -C lib } package() { cd curl-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" -C lib install make DESTDIR="$pkgdir" -C include install make DESTDIR="$pkgdir" install-binSCRIPTS install-pkgconfigDATA } ================================================ FILE: switch/curl/switch-curl.patch ================================================ diff --git a/configure.ac b/configure.ac index e7ad63925..819a22c72 100755 --- a/configure.ac +++ b/configure.ac @@ -156,7 +156,7 @@ AC_SUBST(PKGADD_VENDOR) dnl dnl initialize all the info variables - curl_ssl_msg="no (--with-{ssl,gnutls,nss,mbedtls,wolfssl,schannel,secure-transport,mesalink,amissl,bearssl} )" + curl_ssl_msg="no (--with-{ssl,gnutls,nss,mbedtls,wolfssl,schannel,secure-transport,mesalink,amissl,bearssl,libnx} )" curl_ssh_msg="no (--with-{libssh,libssh2})" curl_zlib_msg="no (--with-zlib)" curl_brotli_msg="no (--with-brotli)" @@ -2632,10 +2632,89 @@ if test -z "$ssl_backends" -o "x$OPT_NSS" != xno; then test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg" fi -case "x$OPENSSL_ENABLED$GNUTLS_ENABLED$NSS_ENABLED$MBEDTLS_ENABLED$WOLFSSL_ENABLED$WINSSL_ENABLED$SECURETRANSPORT_ENABLED$MESALINK_ENABLED$BEARSSL_ENABLED$AMISSL_ENABLED" in +dnl ---------------------------------------------------- +dnl check for libnx +dnl ---------------------------------------------------- + +OPT_LIBNX=no + +_cppflags=$CPPFLAGS +_ldflags=$LDFLAGS +AC_ARG_WITH(libnx,dnl +AC_HELP_STRING([--with-libnx=PATH],[where to look for libnx, PATH points to the installation root]) +AC_HELP_STRING([--without-libnx], [disable libnx detection]), + OPT_LIBNX=$withval) + +if test -z "$ssl_backends" -o "x$OPT_LIBNX" != xno; then + ssl_msg= + + if test X"$OPT_LIBNX" != Xno; then + + if test "$OPT_LIBNX" = "yes"; then + OPT_LIBNX="" + fi + + if test -z "$OPT_LIBNX" ; then + dnl check for lib first without setting any new path + + AC_CHECK_LIB(nx, sslInitialize, + dnl libnx found, set the variable + [ + AC_DEFINE(USE_LIBNX, 1, [if libnx is enabled]) + AC_SUBST(USE_LIBNX, [1]) + LIBNX_ENABLED=1 + USE_LIBNX="yes" + ssl_msg="libnx" + test libnx != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes + ], [], -lnx) + fi + + addld="" + addlib="" + addcflags="" + libnx="" + + if test "x$USE_LIBNX" != "xyes"; then + dnl add the path and test again + addld=-L$OPT_LIBNX/lib$libsuff + addcflags=-I$OPT_LIBNX/include + libnx=$OPT_LIBNX/lib$libsuff + + LDFLAGS="$LDFLAGS $addld" + if test "$addcflags" != "-I/usr/include"; then + CPPFLAGS="$CPPFLAGS $addcflags" + fi + + AC_CHECK_LIB(nx, sslInitialize, + [ + AC_DEFINE(USE_LIBNX, 1, [if libnx is enabled]) + AC_SUBST(USE_LIBNX, [1]) + LIBNX_ENABLED=1 + USE_LIBNX="yes" + ssl_msg="libnx" + test libnx != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes + ], + [ + CPPFLAGS=$_cppflags + LDFLAGS=$_ldflags + ], -lnx) + fi + + if test "x$USE_LIBNX" = "xyes"; then + AC_MSG_NOTICE([detected libnx]) + + LIBS="-lnx $LIBS" + fi + + fi dnl libnx not disabled + + test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg" +fi + +case "x$OPENSSL_ENABLED$GNUTLS_ENABLED$NSS_ENABLED$MBEDTLS_ENABLED$WOLFSSL_ENABLED$WINSSL_ENABLED$SECURETRANSPORT_ENABLED$MESALINK_ENABLED$BEARSSL_ENABLED$AMISSL_ENABLED$LIBNX_ENABLED" in x) AC_MSG_WARN([SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.]) - AC_MSG_WARN([Use --with-ssl, --with-gnutls, --with-wolfssl, --with-mbedtls, --with-nss, --with-schannel, --with-secure-transport, --with-mesalink, --with-amissl or --with-bearssl to address this.]) + AC_MSG_WARN([Use --with-ssl, --with-gnutls, --with-wolfssl, --with-mbedtls, --with-nss, --with-schannel, --with-secure-transport, --with-mesalink, --with-amissl, --with-bearssl or --with-libnx to address this.]) ;; x1) # one SSL backend is enabled diff --git a/include/curl/curl.h b/include/curl/curl.h index b7cb30a58..8786b1be5 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -75,7 +75,8 @@ defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \ defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \ defined(__CYGWIN__) || \ - (defined(__FreeBSD_version) && (__FreeBSD_version < 800000)) + (defined(__FreeBSD_version) && (__FreeBSD_version < 800000)) || \ + defined(__SWITCH__) #include #endif @@ -155,7 +156,8 @@ typedef enum { CURLSSLBACKEND_AXTLS = 10, /* never used since 7.63.0 */ CURLSSLBACKEND_MBEDTLS = 11, CURLSSLBACKEND_MESALINK = 12, - CURLSSLBACKEND_BEARSSL = 13 + CURLSSLBACKEND_BEARSSL = 13, + CURLSSLBACKEND_LIBNX = 14 } curl_sslbackend; /* aliases for library clones and renames */ diff --git a/lib/Makefile.inc b/lib/Makefile.inc index 46ded90bb..c268dde36 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -30,12 +30,12 @@ LIB_VAUTH_HFILES = vauth/vauth.h vauth/digest.h vauth/ntlm.h LIB_VTLS_CFILES = vtls/openssl.c vtls/gtls.c vtls/vtls.c vtls/nss.c \ vtls/mbedtls_threadlock.c vtls/wolfssl.c vtls/schannel.c \ vtls/schannel_verify.c vtls/sectransp.c vtls/gskit.c vtls/mbedtls.c \ - vtls/mesalink.c vtls/bearssl.c + vtls/mesalink.c vtls/bearssl.c vtls/libnx.c LIB_VTLS_HFILES = vtls/openssl.h vtls/vtls.h vtls/gtls.h vtls/nssg.h \ vtls/mbedtls_threadlock.h vtls/wolfssl.h vtls/schannel.h \ vtls/sectransp.h vtls/gskit.h vtls/mbedtls.h vtls/mesalink.h \ - vtls/bearssl.h + vtls/bearssl.h vtls/libnx.h LIB_VQUIC_CFILES = vquic/ngtcp2.c vquic/quiche.c @@ -63,7 +63,7 @@ LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \ curl_multibyte.c hostcheck.c conncache.c dotdot.c \ x509asn1.c http2.c smb.c curl_endian.c curl_des.c system_win32.c \ mime.c sha256.c setopt.c curl_path.c curl_ctype.c curl_range.c psl.c \ - doh.c urlapi.c curl_get_line.c altsvc.c socketpair.c rename.c + doh.c urlapi.c curl_get_line.c altsvc.c socketpair.c rename.c hos.c LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \ formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \ @@ -84,7 +84,7 @@ LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \ x509asn1.h http2.h sigpipe.h smb.h curl_endian.h curl_des.h \ curl_printf.h system_win32.h rand.h mime.h curl_sha256.h setopt.h \ curl_path.h curl_ctype.h curl_range.h psl.h doh.h urlapi-int.h \ - curl_get_line.h altsvc.h quic.h socketpair.h rename.h + curl_get_line.h altsvc.h quic.h socketpair.h rename.h hos.h LIB_RCFILES = libcurl.rc diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 4ecda6a9b..85c4188ff 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -653,7 +653,7 @@ int netware_init(void); defined(USE_MBEDTLS) || \ defined(USE_WOLFSSL) || defined(USE_SCHANNEL) || \ defined(USE_SECTRANSP) || defined(USE_GSKIT) || defined(USE_MESALINK) || \ - defined(USE_BEARSSL) + defined(USE_BEARSSL) || defined(USE_LIBNX) #define USE_SSL /* SSL support has been enabled */ #endif diff --git a/lib/hos.c b/lib/hos.c new file mode 100644 index 000000000..95543e0df --- /dev/null +++ b/lib/hos.c @@ -0,0 +1,90 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2019, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "curl_setup.h" + +#ifdef USE_LIBNX + +#include + +#undef BIT + +#include "urldata.h" +#include "setopt.h" +#include "sendf.h" +#include "hos.h" + +/* The last #include files should be: */ +#include "curl_printf.h" +#include "curl_memory.h" +#include "memdebug.h" + +CURLcode Curl_os_get_system_proxy(struct connectdata *conn) +{ + struct Curl_easy *data = conn->data; + CURLcode result = CURLE_OK; + Result rc = 0; + NifmNetworkProfileData profile; + NifmProxySetting *proxy = &profile.ip_setting_data.proxy_setting; + char server[0x64]; + char user[0x20]; + char password[0x20]; + + rc = nifmInitialize(NifmServiceType_User); + if(R_SUCCEEDED(rc)) { + rc = nifmGetCurrentNetworkProfile(&profile); + nifmExit(); + + if(R_SUCCEEDED(rc) && proxy->enabled) { + data->set.proxyport = proxy->port; + + strncpy(server, proxy->server, sizeof(server) - 1); + server[sizeof(server) - 1] = 0; + + result = Curl_setstropt(&data->set.str[STRING_PROXY], server); + if(result) + return result; + + if(proxy->auto_auth_enabled) { + strncpy(user, proxy->user, sizeof(user)-1); + user[sizeof(user) - 1] = 0; + + result = Curl_setstropt(&data->set.str[STRING_PROXYUSERNAME], user); + if(result) + return result; + + strncpy(password, proxy->password, sizeof(password)-1); + password[sizeof(password) - 1] = 0; + + result = Curl_setstropt(&data->set.str[STRING_PROXYPASSWORD], password); + if(result) + return result; + + conn->bits.proxy_user_passwd = TRUE; + } + } + } + + return result; +} +#endif /* USE_LIBNX */ + diff --git a/lib/hos.h b/lib/hos.h new file mode 100644 index 000000000..ea92bac57 --- /dev/null +++ b/lib/hos.h @@ -0,0 +1,37 @@ +#ifndef HEADER_CURL_HOS_H +#define HEADER_CURL_HOS_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2019, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ +#include "curl_setup.h" + +#ifdef USE_LIBNX + +CURLcode Curl_os_get_system_proxy(struct connectdata *conn); + +#else + +#define Curl_os_get_system_proxy(x) 0 + +#endif /* USE_LIBNX */ + +#endif /* HEADER_CURL_HOS_H */ + diff --git a/lib/url.c b/lib/url.c index 47fc66aed..2bffba526 100644 --- a/lib/url.c +++ b/lib/url.c @@ -96,6 +96,7 @@ bool curl_win32_idn_to_ascii(const char *in, char **out); #include "getinfo.h" #include "urlapi-int.h" #include "system_win32.h" +#include "hos.h" /* And now for the protocols */ #include "ftp.h" @@ -2376,6 +2377,12 @@ static CURLcode create_conn_helper_init_proxy(struct connectdata *conn) CURLcode result = CURLE_OK; struct Curl_easy *data = conn->data; + if(!data->set.str[STRING_PROXY]) { + result = Curl_os_get_system_proxy(conn); + if(result) + goto out; + } + /************************************************************* * Extract the user and password from the authentication string *************************************************************/ diff --git a/lib/vtls/libnx.c b/lib/vtls/libnx.c new file mode 100644 index 000000000..372b638c5 --- /dev/null +++ b/lib/vtls/libnx.c @@ -0,0 +1,896 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2010 - 2011, Hoi-Ho Chan, + * Copyright (C) 2012 - 2020, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +/* + * Source file for all libnx-specific code for the TLS/SSL layer. No code + * but vtls.c should ever call or use these functions. + * + */ + +#include "curl_setup.h" + +#ifdef USE_LIBNX + +#include + +#undef BIT + +#include "urldata.h" +#include "sendf.h" +#include "inet_pton.h" +#include "libnx.h" +#include "vtls.h" +#include "parsedate.h" +#include "connect.h" /* for the connect timeout */ +#include "select.h" +#include "multiif.h" +#include "x509asn1.h" + +/* The last 3 #include files should be in this order */ +#include "curl_printf.h" +#include "curl_memory.h" +#include "memdebug.h" + +#include + +struct ssl_backend_data { + SslContext context; + SslConnection conn; + u8 *certbuf; + size_t certbuf_size; +}; + +#define BACKEND connssl->backend + +/* ALPN for http2? */ +#ifdef USE_NGHTTP2 +# undef HAS_ALPN +# define HAS_ALPN +#endif + + +static bool load_file(const char *path, void **buffer, size_t *size) +{ + struct stat filestat; + size_t tmp = 0; + *buffer = NULL; + *size = 0; + if(stat(path, &filestat)==-1) + return FALSE; + + FILE *f = fopen(path, "rb"); + if(!f) + return FALSE; + + *size = filestat.st_size; + *buffer = calloc(1, *size); + + if(*buffer) + tmp = fread(*buffer, 1, *size, f); + fclose(f); + + if(!*buffer) + return FALSE; + + if(tmp!=*size) { + free(*buffer); + *buffer = NULL; + return FALSE; + } + + return TRUE; +} + +static CURLcode load_capath(struct Curl_easy *data, SslContext *context, + const char *path, const bool verifypeer) +{ + Result rc = 0; + void *tmpbuf = NULL; + size_t tmpbuf_size = 0; + DIR *dir; + struct dirent* dp; + char tmp_path[PATH_MAX]; + + dir = opendir(path); + if(!dir) { + failf(data, "Error opening ca path %s", + path); + + if(verifypeer) + return CURLE_SSL_CACERT_BADFILE; + + return CURLE_OK; + } + + while((dp = readdir(dir))) { + if(dp->d_name[0]=='.') + continue; + + curl_msnprintf(tmp_path, sizeof(tmp_path), "%s/%s", path, dp->d_name); + + bool entrytype = FALSE; + + #ifdef _DIRENT_HAVE_D_TYPE + if(dp->d_type == DT_UNKNOWN) + continue; + entrytype = dp->d_type != DT_REG; + #else + struct stat tmpstat; + + if(stat(tmp_path, &tmpstat)==-1) + continue; + + entrytype = (tmpstat.st_mode & S_IFMT) != S_IFREG; + #endif + + if(entrytype) /* Ignore directories. */ + continue; + + if(!load_file(tmp_path, &tmpbuf, &tmpbuf_size)) { + failf(data, "Error reading ca path file %s", + tmp_path); + + if(verifypeer) + return CURLE_SSL_CACERT_BADFILE; + } + + rc = sslContextImportServerPki(context, tmpbuf, tmpbuf_size, + SslCertificateFormat_Pem, NULL); + free(tmpbuf); + + if(R_FAILED(rc)) { + failf(data, "Error importing ca path file %s - libnx: 0x%X", + tmp_path, rc); + + if(verifypeer) + return CURLE_SSL_CACERT_BADFILE; + } + } + + closedir(dir); + + return CURLE_OK; +} + +static CURLcode libnx_version_from_curl(u32 *outver, long version) +{ + switch(version) { + case CURL_SSLVERSION_TLSv1_0: + *outver = SslVersion_TlsV10; + return CURLE_OK; + case CURL_SSLVERSION_TLSv1_1: + *outver = SslVersion_TlsV11; + return CURLE_OK; + case CURL_SSLVERSION_TLSv1_2: + *outver = SslVersion_TlsV12; + return CURLE_OK; + case CURL_SSLVERSION_TLSv1_3: + break; + } + return CURLE_SSL_CONNECT_ERROR; +} + +static CURLcode Curl_libnx_random(struct Curl_easy *data, + unsigned char *entropy, size_t length) +{ + Result rc = csrngGetRandomBytes(entropy, length); + + return R_SUCCEEDED(rc) ? CURLE_OK : CURLE_FAILED_INIT; +} + +static CURLcode +set_ssl_version_min_max(struct connectdata *conn, int sockindex, + u32 *out_version) +{ + struct Curl_easy *data = conn->data; + struct ssl_connect_data *connssl = &conn->ssl[sockindex]; + u32 libnx_ver_min = 0; + u32 libnx_ver_max = 0; + long ssl_version = SSL_CONN_CONFIG(version); + long ssl_version_max = SSL_CONN_CONFIG(version_max); + CURLcode result = CURLE_OK; + + switch(ssl_version) { + case CURL_SSLVERSION_DEFAULT: + case CURL_SSLVERSION_TLSv1: + ssl_version = CURL_SSLVERSION_TLSv1_0; + if(ssl_version_max == CURL_SSLVERSION_MAX_NONE || + ssl_version_max == CURL_SSLVERSION_MAX_DEFAULT) { + *out_version = SslVersion_Auto; + return result; + } + break; + } + + switch(ssl_version_max) { + case CURL_SSLVERSION_MAX_NONE: + case CURL_SSLVERSION_MAX_DEFAULT: + ssl_version_max = CURL_SSLVERSION_MAX_TLSv1_2; + break; + } + + result = libnx_version_from_curl(&libnx_ver_min, ssl_version); + if(result) { + failf(data, "unsupported min version passed via CURLOPT_SSLVERSION"); + return result; + } + result = libnx_version_from_curl(&libnx_ver_max, ssl_version_max >> 16); + if(result) { + failf(data, "unsupported max version passed via CURLOPT_SSLVERSION"); + return result; + } + + *out_version = libnx_ver_min | libnx_ver_max; + + return result; +} + +static CURLcode +libnx_connect_step1(struct connectdata *conn, + int sockindex, bool nonblocking) +{ + struct Curl_easy *data = conn->data; + struct ssl_connect_data* connssl = &conn->ssl[sockindex]; + curl_socket_t sockfd = conn->sock[sockindex]; + const char * const ssl_cafile = SSL_CONN_CONFIG(CAfile); + const bool verifypeer = SSL_CONN_CONFIG(verifypeer); + const char * const ssl_capath = SSL_CONN_CONFIG(CApath); + char * const ssl_cert = SSL_SET_OPTION(cert); + char * const key_passwd = SSL_SET_OPTION(key_passwd); + const char * const ssl_crlfile = SSL_SET_OPTION(CRLfile); + const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name : + conn->host.name; + const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port; + int ret = -1; + Result rc = 0; + void *tmpbuf = NULL; + size_t tmpbuf_size = 0; + + /* ssl-service only supports TLS 1.0-1.2 */ + if(SSL_CONN_CONFIG(version) == CURL_SSLVERSION_SSLv2) { + failf(data, "ssl-service does not support SSLv2"); + return CURLE_SSL_CONNECT_ERROR; + } + + if(SSL_CONN_CONFIG(version) == CURL_SSLVERSION_SSLv3) { + failf(data, "ssl-service does not support SSLv3"); + return CURLE_SSL_CONNECT_ERROR; + } + + u32 ssl_version = 0; + switch(SSL_CONN_CONFIG(version)) { + case CURL_SSLVERSION_DEFAULT: + case CURL_SSLVERSION_TLSv1: + case CURL_SSLVERSION_TLSv1_0: + case CURL_SSLVERSION_TLSv1_1: + case CURL_SSLVERSION_TLSv1_2: + case CURL_SSLVERSION_TLSv1_3: + { + CURLcode result = set_ssl_version_min_max(conn, sockindex, &ssl_version); + if(result != CURLE_OK) + return result; + break; + } + default: + failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION"); + return CURLE_SSL_CONNECT_ERROR; + } + + rc = sslCreateContext(&BACKEND->context, ssl_version); + if(R_FAILED(rc)) + return CURLE_SSL_CONNECT_ERROR; + + /* give application a chance to interfere with context set up. */ + if(data->set.ssl.fsslctx) { + ret = (*data->set.ssl.fsslctx)(data, &BACKEND->context, + data->set.ssl.fsslctxp); + if(ret) { + failf(data, "error signaled by ssl ctx callback"); + return ret; + } + } + else { /* Only setup the context if the application didn't. */ + /* Load the trusted CA */ + if(ssl_cafile) { + if(!load_file(ssl_cafile, &tmpbuf, &tmpbuf_size)) { + failf(data, "Error reading ca cert file %s", + ssl_cafile); + + if(verifypeer) + return CURLE_SSL_CACERT_BADFILE; + } + else { + rc = sslContextImportServerPki(&BACKEND->context, tmpbuf, tmpbuf_size, + SslCertificateFormat_Pem, NULL); + free(tmpbuf); + + if(R_FAILED(rc)) { + failf(data, "Error importing ca cert file %s - libnx: 0x%X", + ssl_cafile, rc); + + if(verifypeer) + return CURLE_SSL_CACERT_BADFILE; + } + } + } + + if(ssl_capath) { + CURLcode retcode = load_capath(data, &BACKEND->context, + ssl_capath, verifypeer); + + if(retcode) return retcode; + } + + /* Load the CRL */ + /* The input for CRLFILE is PEM, but the ssl-service requires DER. + * A helper func for converting PEM to DER would be needed for this. + * sectransp.c has pem_to_der(), but having a duplicate func isn't ideal. + * Therefore, the below is disabled. */ + /* + if(ssl_crlfile) { + if(!load_file(ssl_crlfile, &tmpbuf, &tmpbuf_size)) { + failf(data, "Error reading CRL file %s", + ssl_cert); + + return CURLE_SSL_CRL_BADFILE; + } + + rc = sslContextImportCrl(&BACKEND->context, tmpbuf, tmpbuf_size, NULL); + free(tmpbuf); + + if(R_FAILED(rc)) { + failf(data, "Error importing CRL file %s - libnx: 0x%X", + ssl_crlfile, rc); + + return CURLE_SSL_CRL_BADFILE; + } + }*/ + + /* Load the client certificate */ + if(ssl_cert) { + if(!SSL_SET_OPTION(cert_type)) + infof(data, "WARNING: SSL: Certificate type not set, assuming " + "PKCS#12 format.\n"); + else if(strncmp(SSL_SET_OPTION(cert_type), "P12", + strlen(SSL_SET_OPTION(cert_type))) != 0) + infof(data, "WARNING: SSL: The ssl-service only supports " + "loading identities that are in PKCS#12 format.\n"); + + if(!load_file(ssl_cert, &tmpbuf, &tmpbuf_size)) { + failf(data, "Error reading client cert file %s", + ssl_cert); + + return CURLE_SSL_CERTPROBLEM; + } + + rc = sslContextImportClientPki(&BACKEND->context, tmpbuf, tmpbuf_size, + key_passwd, + key_passwd ? strlen(key_passwd) : 0, + NULL); + free(tmpbuf); + + if(R_FAILED(rc)) { + failf(data, "Error importing client PKCS#12 file %s - libnx: 0x%X", + ssl_cert, rc); + + return CURLE_SSL_CERTPROBLEM; + } + } + } + + rc = sslContextCreateConnection(&BACKEND->context, &BACKEND->conn); + + if(R_SUCCEEDED(rc)) + rc = sslConnectionSetOption(&BACKEND->conn, + SslOptionType_DoNotCloseSocket, TRUE); + + if(R_SUCCEEDED(rc)) { + ret = socketSslConnectionSetSocketDescriptor(&BACKEND->conn, (int)sockfd); + if(ret == -1 && errno != ENOENT) return CURLE_SSL_CONNECT_ERROR; + } + + if(R_SUCCEEDED(rc)) + rc = sslConnectionSetHostName(&BACKEND->conn, hostname, strlen(hostname)); + + /* This will fail on system-versions where this option isn't available, + * so ignore errors from this. */ + if(R_SUCCEEDED(rc)) + sslConnectionSetOption(&BACKEND->conn, + SslOptionType_SkipDefaultVerify, TRUE); + + if(R_SUCCEEDED(rc) && hosversionAtLeast(3, 0, 0)) + rc = sslConnectionSetOption(&BACKEND->conn, + SslOptionType_GetServerCertChain, TRUE); + + if(R_SUCCEEDED(rc)) { + u32 verifyopt = SslVerifyOption_DateCheck; + if(verifypeer) verifyopt |= SslVerifyOption_PeerCa; + if(SSL_CONN_CONFIG(verifyhost)) verifyopt |= SslVerifyOption_HostName; + rc = sslConnectionSetVerifyOption(&BACKEND->conn, verifyopt); + } + + if(R_SUCCEEDED(rc)) { + SslSessionCacheMode cache_mode = SslSessionCacheMode_None; + if(SSL_CONN_CONFIG(sessionid)) + cache_mode = SslSessionCacheMode_SessionId; + rc = sslConnectionSetSessionCacheMode(&BACKEND->conn, cache_mode); + } + +#ifdef HAS_ALPN + if(conn->bits.tls_enable_alpn && hosversionAtLeast(9, 0, 0)) { + rc = sslConnectionSetOption(&BACKEND->conn, + SslOptionType_EnableAlpn, TRUE); + if(R_FAILED(rc)) { + failf(data, "Failed enabling ALPN"); + return CURLE_SSL_CONNECT_ERROR; + } + + u8 protocols[0x80]={0}; + u8 *p = protocols; +#ifdef USE_NGHTTP2 + if(data->set.httpversion >= CURL_HTTP_VERSION_2) { + memcpy(p, NGHTTP2_PROTO_ALPN, NGHTTP2_PROTO_ALPN_LEN); + p += NGHTTP2_PROTO_ALPN_LEN; + infof(data, "ALPN, offering %s\n", NGHTTP2_PROTO_VERSION_ID); + } +#endif + *p++ = ALPN_HTTP_1_1_LENGTH; + memcpy(p, ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH); + infof(data, "ALPN, offering %s\n", ALPN_HTTP_1_1); + + u32 size = (uintptr_t)p + ALPN_HTTP_1_1_LENGTH - (uintptr_t)protocols; + rc = sslConnectionSetNextAlpnProto(&BACKEND->conn, protocols, + size); + if(R_FAILED(rc)) { + failf(data, "Failed setting ALPN protocols"); + return CURLE_SSL_CONNECT_ERROR; + } + } +#endif + + if(R_SUCCEEDED(rc)) { + SslIoMode iomode = SslIoMode_Blocking; + if(nonblocking) + iomode = SslIoMode_NonBlocking; + rc = sslConnectionSetIoMode(&BACKEND->conn, iomode); + } + + if(R_FAILED(rc)) + return CURLE_SSL_CONNECT_ERROR; + + infof(data, "libnx: Connecting to %s:%ld\n", hostname, port); + + connssl->connecting_state = ssl_connect_2; + + return CURLE_OK; +} + +static CURLcode +libnx_connect_step2(struct connectdata *conn, + int sockindex) +{ + Result rc = 0; + CURLcode retcode = CURLE_OK; + struct Curl_easy *data = conn->data; + struct ssl_connect_data* connssl = &conn->ssl[sockindex]; + const char * const pinnedpubkey = SSL_IS_PROXY() ? + data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] : + data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG]; + const size_t bufsize = 16384; + u8 *buffer = calloc(1, bufsize); + u8 *peercert = NULL; + u32 peercert_size = 0; + u8 zeros[4]={0}; + + if(!BACKEND->certbuf) { + BACKEND->certbuf_size = bufsize; + BACKEND->certbuf = (u8*)calloc(1, BACKEND->certbuf_size); + } + + if(!buffer || !BACKEND->certbuf) { + free(buffer); + free(BACKEND->certbuf); + return CURLE_OUT_OF_MEMORY; + } + + u32 out_size = 0, total_certs = 0; + rc = sslConnectionDoHandshake(&BACKEND->conn, &out_size, &total_certs, + buffer, bufsize); + + if(memcmp(buffer, zeros, sizeof(zeros))) + memcpy(BACKEND->certbuf, buffer, bufsize); + free(buffer); + + if(R_FAILED(rc)) { + if(R_VALUE(rc) == MAKERESULT(123, 204)) /* PR_WOULD_BLOCK_ERROR */ + return CURLE_AGAIN; + + if(R_VALUE(rc) == MAKERESULT(123, 207)) + return CURLE_PEER_FAILED_VERIFICATION; + else + return CURLE_SSL_CONNECT_ERROR; + } + + if(out_size && total_certs) { + if(data->set.ssl.certinfo) + retcode = Curl_ssl_init_certinfo(data, + (int)total_certs); + if(!retcode) { + if(hosversionBefore(3, 0, 0)) { + infof(data, "Dumping cert info:\n"); + retcode = Curl_extract_certinfo(conn, 0, BACKEND->certbuf, + &BACKEND->certbuf[out_size]); + peercert = buffer; + peercert_size = out_size; + } + else { + for(u32 certi = 0; certi < total_certs; certi++) { + void *certdata = NULL; + u32 certdata_size = 0; + + rc = sslConnectionGetServerCertDetail(BACKEND->certbuf, out_size, + certi, &certdata, + &certdata_size); + if(R_SUCCEEDED(rc)) { + if(!certi) { + infof(data, "Dumping cert info:\n"); + peercert = certdata; + peercert_size = certdata_size; + } + retcode = Curl_extract_certinfo(conn, (int)certi, certdata, + &((u8*)certdata)[certdata_size]); + } + + if(R_FAILED(rc) || retcode) break; + if(!data->set.ssl.certinfo) break; + } + } + } + } + + if(R_FAILED(rc) || retcode) + failf(data, "Unable to dump certificate information.\n"); + + if(pinnedpubkey) { + curl_X509certificate cert; + + if(!peercert || !peercert_size) { + const char *errorptr = ""; + if(!SSL_CONN_CONFIG(verifypeer)) + errorptr = ", CURLOPT_SSL_VERIFYPEER must be enabled"; + failf(data, "Failed due to missing peer certificate%s.", errorptr); + return CURLE_SSL_PINNEDPUBKEYNOTMATCH; + } + + retcode = Curl_parseX509(&cert, peercert, &peercert[peercert_size]); + if(!retcode) + return retcode; + + retcode = Curl_pin_peer_pubkey(data, + pinnedpubkey, + cert.subjectPublicKey.beg, + (uintptr_t)cert.subjectPublicKey.end - + (uintptr_t)cert.subjectPublicKey.beg); + if(retcode) + return retcode; + } + +#ifdef HAS_ALPN + if(conn->bits.tls_enable_alpn) { + u8 next_protocol[0x33]={0}; + SslAlpnProtoState state; + u32 out_size = 0; + rc = sslConnectionGetNextAlpnProto(&BACKEND->conn, &state, &out_size, + next_protocol, + sizeof(next_protocol)-1); + + if(R_SUCCEEDED(rc) && next_protocol[0] && + (state == SslAlpnProtoState_Negotiated || + state == SslAlpnProtoState_Selected)) { + infof(data, "ALPN, server accepted to use %s\n", next_protocol); +#ifdef USE_NGHTTP2 + if(out_size == NGHTTP2_PROTO_VERSION_ID_LEN && + !memcmp(next_protocol, NGHTTP2_PROTO_VERSION_ID, + NGHTTP2_PROTO_VERSION_ID_LEN)) { + conn->negnpn = CURL_HTTP_VERSION_2; + } + else +#endif + if(out_size == ALPN_HTTP_1_1_LENGTH && + !memcmp(next_protocol, ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH)) { + conn->negnpn = CURL_HTTP_VERSION_1_1; + } + } + else { + infof(data, "ALPN, server did not agree to a protocol\n"); + } + Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ? + BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE); + } +#endif + + connssl->connecting_state = ssl_connect_done; + infof(data, "SSL connected\n"); + + return CURLE_OK; +} + +static ssize_t libnx_send(struct connectdata *conn, int sockindex, + const void *mem, size_t len, + CURLcode *curlcode) +{ + struct ssl_connect_data *connssl = &conn->ssl[sockindex]; + Result rc = 0; + u32 out_size = 0; + + rc = sslConnectionWrite(&BACKEND->conn, mem, len, &out_size); + + if(R_FAILED(rc)) { + /* PR_WOULD_BLOCK_ERROR */ + *curlcode = (R_VALUE(rc) == MAKERESULT(123, 204)) ? + CURLE_AGAIN : CURLE_WRITE_ERROR; + return -1; + } + + return out_size; +} + +static void Curl_libnx_close(struct connectdata *conn, int sockindex) +{ + struct ssl_connect_data *connssl = &conn->ssl[sockindex]; + sslConnectionClose(&BACKEND->conn); + sslContextClose(&BACKEND->context); + free(BACKEND->certbuf); + BACKEND->certbuf = NULL; + BACKEND->certbuf_size = 0; +} + +static ssize_t libnx_recv(struct connectdata *conn, int num, + char *buf, size_t buffersize, + CURLcode *curlcode) +{ + struct ssl_connect_data *connssl = &conn->ssl[num]; + Result rc = 0; + u32 out_size = 0; + + memset(buf, 0, buffersize); + rc = sslConnectionRead(&BACKEND->conn, buf, buffersize, &out_size); + + if(R_FAILED(rc)) { + /* PR_WOULD_BLOCK_ERROR */ + *curlcode = (R_VALUE(rc) == MAKERESULT(123, 204)) ? + CURLE_AGAIN : CURLE_RECV_ERROR; + return -1; + } + + return out_size; +} + +static size_t Curl_libnx_version(char *buffer, size_t size) +{ + return msnprintf(buffer, size, "libnx"); +} + +/* + * This function is used to determine connection status. + * + * Return codes: + * 1 means the connection is still in place + * 0 means the connection has been closed + * -1 means the connection status is unknown + */ +static int Curl_libnx_check_cxn(struct connectdata *conn) +{ + struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET]; + u8 data = 0; + u32 out_size = 0; + Result rc = sslConnectionPeek(&BACKEND->conn, &data, + sizeof(data), &out_size); + if(R_FAILED(rc)) { + /* PR_WOULD_BLOCK_ERROR == connection is still in place, + * otherwise connection status unknown */ + return R_VALUE(rc) == MAKERESULT(123, 204) ? 1 : -1; + } + return out_size ? 1 : 0; +} + +static CURLcode +libnx_connect_common(struct connectdata *conn, + int sockindex, + bool nonblocking, + bool *done) +{ + Result rc = 0; + CURLcode retcode = CURLE_OK; + struct Curl_easy *data = conn->data; + struct ssl_connect_data *connssl = &conn->ssl[sockindex]; + timediff_t timeout_ms; + int what; + + *done = FALSE; + + /* check if the connection has already been established */ + if(ssl_connection_complete == connssl->state) { + *done = TRUE; + return CURLE_OK; + } + + if(ssl_connect_1 == connssl->connecting_state) { + /* Find out how much more time we're allowed */ + timeout_ms = Curl_timeleft(data, NULL, TRUE); + + if(timeout_ms < 0) { + /* no need to continue if time already is up */ + failf(data, "SSL connection timeout"); + return CURLE_OPERATION_TIMEDOUT; + } + retcode = libnx_connect_step1(conn, sockindex, nonblocking); + } + + if(!retcode && ssl_connect_2 == connssl->connecting_state) { + /* Find out how much more time we're allowed */ + timeout_ms = Curl_timeleft(data, NULL, TRUE); + + if(timeout_ms < 0) { + /* no need to continue if time already is up */ + failf(data, "SSL connection timeout"); + return CURLE_OPERATION_TIMEDOUT; + } + retcode = libnx_connect_step2(conn, sockindex); + } + + if(!retcode) { + /* Reset our connect state machine */ + connssl->connecting_state = ssl_connect_1; + + connssl->state = ssl_connection_complete; + conn->recv[sockindex] = libnx_recv; + conn->send[sockindex] = libnx_send; + *done = TRUE; + + return CURLE_OK; + } + + if(retcode == CURLE_AGAIN) + return CURLE_OK; + if(retcode == CURLE_PEER_FAILED_VERIFICATION) { + rc = sslConnectionGetVerifyCertError(&BACKEND->conn); + if(R_VALUE(rc) != MAKERESULT(123, 301) && + R_VALUE(rc) != MAKERESULT(123, 303) && + R_VALUE(rc) != MAKERESULT(123, 304)) { + /* 1509: SSL_ERROR_BAD_CERT_ALERT + * 1511: SSL_ERROR_REVOKED_CERT_ALERT + * 1512: SSL_ERROR_EXPIRED_CERT_ALERT */ + if(R_VALUE(rc) == MAKERESULT(123, 323) || + R_VALUE(rc) == MAKERESULT(123, 1509) || + R_VALUE(rc) == MAKERESULT(123, 1511) || + R_VALUE(rc) == MAKERESULT(123, 1512)) + retcode = CURLE_SSL_CERTPROBLEM; + } + } + + return retcode; +} + +static CURLcode Curl_libnx_connect_nonblocking(struct connectdata *conn, + int sockindex, bool *done) +{ + return libnx_connect_common(conn, sockindex, TRUE, done); +} + + +static CURLcode Curl_libnx_connect(struct connectdata *conn, int sockindex) +{ + CURLcode retcode; + bool done = FALSE; + + retcode = libnx_connect_common(conn, sockindex, FALSE, &done); + if(retcode) + return retcode; + + DEBUGASSERT(done); + + return CURLE_OK; +} + +/* + * return 0 error initializing SSL + * return 1 SSL initialized successfully + */ +static int Curl_libnx_init(void) +{ + Result rc = 0; + + rc = sslInitialize(0x3); + + if(R_SUCCEEDED(rc)) + rc = csrngInitialize(); + + return R_SUCCEEDED(rc); +} + +static void Curl_libnx_cleanup(void) +{ + csrngExit(); + sslExit(); +} + +static bool Curl_libnx_data_pending(const struct connectdata *conn, + int sockindex) +{ + const struct ssl_connect_data *connssl = &conn->ssl[sockindex]; + s32 tmp = 0; + return R_SUCCEEDED(sslConnectionPending(&BACKEND->conn, &tmp)) && tmp>0; +} + +static CURLcode Curl_libnx_sha256sum(const unsigned char *input, + size_t inputlen, + unsigned char *sha256sum, + size_t sha256len UNUSED_PARAM) +{ + (void)sha256len; + sha256CalculateHash(sha256sum, input, inputlen); + return CURLE_OK; +} + +static void *Curl_libnx_get_internals(struct ssl_connect_data *connssl, + CURLINFO info UNUSED_PARAM) +{ + (void)info; + return &BACKEND->context; +} + +const struct Curl_ssl Curl_ssl_libnx = { + { CURLSSLBACKEND_LIBNX, "libnx" }, /* info */ + + SSLSUPP_CA_PATH | + SSLSUPP_CERTINFO | + SSLSUPP_PINNEDPUBKEY | + SSLSUPP_SSL_CTX | + SSLSUPP_TLS13_CIPHERSUITES, + + sizeof(struct ssl_backend_data), + + Curl_libnx_init, /* init */ + Curl_libnx_cleanup, /* cleanup */ + Curl_libnx_version, /* version */ + Curl_libnx_check_cxn, /* check_cxn */ + Curl_none_shutdown, /* shutdown */ + Curl_libnx_data_pending, /* data_pending */ + Curl_libnx_random, /* random */ + Curl_none_cert_status_request, /* cert_status_request */ + Curl_libnx_connect, /* connect */ + Curl_libnx_connect_nonblocking, /* connect_nonblocking */ + Curl_libnx_get_internals, /* get_internals */ + Curl_libnx_close, /* close_one */ + Curl_none_close_all, /* close_all */ + Curl_none_session_free, /* session_free */ + Curl_none_set_engine, /* set_engine */ + Curl_none_set_engine_default, /* set_engine_default */ + Curl_none_engines_list, /* engines_list */ + Curl_none_false_start, /* false_start */ + Curl_none_md5sum, /* md5sum */ + Curl_libnx_sha256sum /* sha256sum */ +}; + +#endif /* USE_LIBNX */ diff --git a/lib/vtls/libnx.h b/lib/vtls/libnx.h new file mode 100644 index 000000000..67b8fae28 --- /dev/null +++ b/lib/vtls/libnx.h @@ -0,0 +1,32 @@ +#ifndef HEADER_CURL_LIBNX_H +#define HEADER_CURL_LIBNX_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2012 - 2019, Daniel Stenberg, , et al. + * Copyright (C) 2010, Hoi-Ho Chan, + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ +#include "curl_setup.h" + +#ifdef USE_LIBNX + +extern const struct Curl_ssl Curl_ssl_libnx; + +#endif /* USE_LIBNX */ +#endif /* HEADER_CURL_LIBNX_H */ diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index dfefa1bd5..e46379f72 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -1189,6 +1189,8 @@ const struct Curl_ssl *Curl_ssl = &Curl_ssl_mesalink; #elif defined(USE_BEARSSL) &Curl_ssl_bearssl; +#elif defined(USE_LIBNX) + &Curl_ssl_libnx; #else #error "Missing struct Curl_ssl for selected SSL backend" #endif @@ -1224,6 +1226,9 @@ static const struct Curl_ssl *available_backends[] = { #if defined(USE_BEARSSL) &Curl_ssl_bearssl, #endif +#if defined(USE_LIBNX) + &Curl_ssl_libnx, +#endif NULL }; diff --git a/lib/vtls/vtls.h b/lib/vtls/vtls.h index a81b2f22d..7874353e8 100644 --- a/lib/vtls/vtls.h +++ b/lib/vtls/vtls.h @@ -108,6 +108,7 @@ CURLcode Curl_none_md5sum(unsigned char *input, size_t inputlen, #include "mbedtls.h" /* mbedTLS versions */ #include "mesalink.h" /* MesaLink versions */ #include "bearssl.h" /* BearSSL versions */ +#include "libnx.h" /* libnx versions */ #ifndef MAX_PINNED_PUBKEY_SIZE #define MAX_PINNED_PUBKEY_SIZE 1048576 /* 1MB */ diff --git a/lib/x509asn1.c b/lib/x509asn1.c index ece5364d8..d6a26e1c6 100644 --- a/lib/x509asn1.c +++ b/lib/x509asn1.c @@ -23,7 +23,7 @@ #include "curl_setup.h" #if defined(USE_GSKIT) || defined(USE_NSS) || defined(USE_GNUTLS) || \ - defined(USE_WOLFSSL) || defined(USE_SCHANNEL) + defined(USE_WOLFSSL) || defined(USE_SCHANNEL) || defined(USE_LIBNX) #include #include "urldata.h" @@ -1104,7 +1104,7 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn, return CURLE_OK; } -#endif /* USE_GSKIT or USE_NSS or USE_GNUTLS or USE_WOLFSSL or USE_SCHANNEL */ +#endif /* USE_GSKIT or USE_NSS or USE_GNUTLS or USE_WOLFSSL or USE_SCHANNEL or USE_LIBNX */ #if defined(USE_GSKIT) diff --git a/lib/x509asn1.h b/lib/x509asn1.h index 205fdc0d7..03d130deb 100644 --- a/lib/x509asn1.h +++ b/lib/x509asn1.h @@ -26,7 +26,7 @@ #include "curl_setup.h" #if defined(USE_GSKIT) || defined(USE_NSS) || defined(USE_GNUTLS) || \ - defined(USE_WOLFSSL) || defined(USE_SCHANNEL) + defined(USE_WOLFSSL) || defined(USE_SCHANNEL) || defined(USE_LIBNX) #include "urldata.h" @@ -130,5 +130,5 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn, int certnum, const char *beg, const char *end); CURLcode Curl_verifyhost(struct connectdata *conn, const char *beg, const char *end); -#endif /* USE_GSKIT or USE_NSS or USE_GNUTLS or USE_WOLFSSL or USE_SCHANNEL */ +#endif /* USE_GSKIT or USE_NSS or USE_GNUTLS or USE_WOLFSSL or USE_SCHANNEL or USE_LIBNX */ #endif /* HEADER_CURL_X509ASN1_H */ ================================================ FILE: switch/dav1d/PKGBUILD ================================================ # Contributor: averne pkgbasename=dav1d pkgname=switch-$pkgbasename pkgver=1.5.0 pkgrel=1 pkgdesc="dav1d is an AV1 cross-platform decoder, open-source, and focused on speed and correctness." arch=("any") url="https://code.videolan.org/videolan/${pkgbasename}" license=("BSD") options=(!strip libtool staticlibs) source=( "${url}/-/archive/${pkgver}/${pkgbasename}-${pkgver}.tar.gz" "dav1d.patch" ) makedepends=("dkp-toolchain-vars" "dkp-meson-scripts") groups=("switch-portlibs") prepare() { cd ${pkgbasename}-${pkgver} patch -Np1 -i "$srcdir/dav1d.patch" } build() { cd ${pkgbasename}-${pkgver} /opt/devkitpro/meson-cross.sh switch ../crossfile.txt build -Dc_std=gnu11 -Db_ndebug=true -Denable_asm=true \ -Denable_tools=false -Denable_examples=false -Denable_tests=false -Denable_docs=false meson compile -C build } package() { cd ${pkgbasename}-${pkgver} DESTDIR="$pkgdir" meson install -C build } sha256sums=('78b15d9954b513ea92d27f39362535ded2243e1b0924fde39f37a31ebed5f76b' '7a59b36d2f0abd31368a11422066e2edbd5334e9504ef200b7688c3f7b81f205') ================================================ FILE: switch/dav1d/dav1d.patch ================================================ diff --git a/meson.build b/meson.build index 798abc1..cff6de6 100644 --- a/meson.build +++ b/meson.build @@ -196,6 +196,11 @@ if host_machine.system() == 'linux' endif cdata.set10('HAVE_DLSYM', have_dlsym) +libnx_dependency = [] +if host_machine.system() == 'horizon' + libnx_dependency = cc.find_library('nx', required : false) +endif + libm_dependency = cc.find_library('m', required: false) diff --git a/src/cpu.c b/src/cpu.c index 4152667..bbd3cbb 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -37,6 +37,8 @@ #ifdef __APPLE__ #include #include +#elif defined(__SWITCH__) +#include #endif #if HAVE_UNISTD_H #include @@ -91,6 +93,10 @@ COLD int dav1d_num_logical_processors(Dav1dContext *const c) { GetNativeSystemInfo(&system_info); return system_info.dwNumberOfProcessors; #endif +#elif defined(__SWITCH__) + u64 core_mask = 0; + Result rc = svcGetInfo(&core_mask, InfoType_CoreMask, CUR_PROCESS_HANDLE, 0); + return R_SUCCEEDED(rc) ? __builtin_popcountll(core_mask) : 3; #elif HAVE_PTHREAD_GETAFFINITY_NP && defined(CPU_COUNT) cpu_set_t affinity; if (!pthread_getaffinity_np(pthread_self(), sizeof(affinity), &affinity)) diff --git a/src/meson.build b/src/meson.build index 29fd5d6..bbbfc85 100644 --- a/src/meson.build +++ b/src/meson.build @@ -384,6 +384,7 @@ libdav1d = library('dav1d', thread_dependency, thread_compat_dep, libdl_dependency, + libnx_dependency, ], c_args : [libdav1d_flags, api_export_flags], version : dav1d_soname_version, ================================================ FILE: switch/enet/PKGBUILD ================================================ pkgname=switch-enet pkgver=1.3.17 pkgrel=1 pkgdesc='ENet reliable UDP networking library (adapted for Nintendo Switch homebrew development)' arch=('any') url='https://github.com/lsalzman/enet' license=('MIT') options=(!strip libtool staticlibs) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') source=(enet-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz) sha256sums=('1e0b4bc0b7127a2d779dd7928f0b31830f5b3dcb7ec9588c5de70033e8d2434a') groups=('switch-portlibs') build() { cd enet-${pkgver} source /opt/devkitpro/switchvars.sh autoreconf -vfi ./configure --prefix=$PORTLIBS_PREFIX --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { cd enet-${pkgver} source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: switch/ffmpeg/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: averne # Contributor: Ezekiel Bethel # Contributor: carstene1ns # Contributor: jakibaki pkgname=switch-ffmpeg pkgver=7.1 pkgrel=5 pkgdesc='ffmpeg port (for Nintendo Switch homebrew development)' arch=('any') url='https://ffmpeg.org/' license=('GPL') options=(!strip staticlibs) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') depends=('switch-zlib' 'switch-bzip2' 'switch-libass' 'switch-libfribidi' 'switch-freetype' 'switch-dav1d') source=("https://ffmpeg.org/releases/ffmpeg-${pkgver}.tar.xz" "ffmpeg-${pkgver}.patch" "tls.patch") sha256sums=('40973d44970dbc83ef302b0609f2e74982be2d85916dd2ee7472d30678a7abe6' '1792380b992e3554a4abcddf0d7b395bfd8c118ac7c6e38c8f2fb0d39753a390' '57ea7ec8ed26d13d3172d0fd589b7883d22f0c180d50b7434fcc73fb2b3ab7d7') groups=('switch-portlibs') prepare() { cd ffmpeg-$pkgver patch -Np1 -i "$srcdir/ffmpeg-${pkgver}.patch" patch -Np1 -i "$srcdir/tls.patch" } build() { cd ffmpeg-$pkgver source /opt/devkitpro/switchvars.sh ./configure --prefix=$PORTLIBS_PREFIX --enable-gpl --disable-shared --enable-static \ --cross-prefix=aarch64-none-elf- --enable-cross-compile \ --arch=aarch64 --cpu=cortex-a57 --target-os=horizon --enable-pic \ --extra-cflags='-D__SWITCH__ -D_GNU_SOURCE -O2 -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec' \ --extra-cxxflags='-D__SWITCH__ -D_GNU_SOURCE -O2 -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec' \ --extra-ldflags='-fPIE -L${PORTLIBS_PREFIX}/lib -L${DEVKITPRO}/libnx/lib' \ --disable-runtime-cpudetect --disable-programs --disable-debug --disable-doc --disable-autodetect \ --enable-asm --enable-neon \ --disable-avdevice --disable-encoders --disable-muxers \ --enable-swscale --enable-swresample --enable-network \ --disable-protocols --enable-protocol=file,http,ftp,tcp,udp,rtmp,tls,httpproxy \ --enable-zlib --enable-bzlib --enable-libass --enable-libfreetype --enable-libfribidi --enable-libdav1d \ --enable-libnx --enable-nvtegra make } package() { cd ffmpeg-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install # remove examples rm -r "$pkgdir"${PORTLIBS_PREFIX}/share } ================================================ FILE: switch/ffmpeg/ffmpeg-7.1.patch ================================================ diff --git a/configure b/configure index d77a55b653..566d5fbed2 100755 --- a/configure +++ b/configure @@ -363,6 +363,7 @@ External library support: --disable-vdpau disable Nvidia Video Decode and Presentation API for Unix code [autodetect] --disable-videotoolbox disable VideoToolbox code [autodetect] --disable-vulkan disable Vulkan code [autodetect] + --enable-nvtegra enable nvtegra code [no] Toolchain options: --arch=ARCH select architecture [$arch] @@ -2025,6 +2026,7 @@ HWACCEL_LIBRARY_LIST=" mmal omx opencl + nvtegra " DOCUMENT_LIST=" @@ -3151,6 +3153,7 @@ videotoolbox_hwaccel_deps="videotoolbox pthreads" videotoolbox_hwaccel_extralibs="-framework QuartzCore" vulkan_deps="threads" vulkan_deps_any="libdl LoadLibrary" +nvtegra_deps="gpl" av1_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_AV1" av1_d3d11va_hwaccel_select="av1_decoder" @@ -3190,6 +3193,8 @@ h264_videotoolbox_hwaccel_deps="videotoolbox" h264_videotoolbox_hwaccel_select="h264_decoder" h264_vulkan_hwaccel_deps="vulkan" h264_vulkan_hwaccel_select="h264_decoder" +h264_nvtegra_hwaccel_deps="nvtegra" +h264_nvtegra_hwaccel_select="h264_decoder" hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC" hevc_d3d11va_hwaccel_select="hevc_decoder" hevc_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_HEVC" @@ -3208,16 +3213,22 @@ hevc_videotoolbox_hwaccel_deps="videotoolbox" hevc_videotoolbox_hwaccel_select="hevc_decoder" hevc_vulkan_hwaccel_deps="vulkan" hevc_vulkan_hwaccel_select="hevc_decoder" +hevc_nvtegra_hwaccel_deps="nvtegra" +hevc_nvtegra_hwaccel_select="hevc_decoder" mjpeg_nvdec_hwaccel_deps="nvdec" mjpeg_nvdec_hwaccel_select="mjpeg_decoder" mjpeg_vaapi_hwaccel_deps="vaapi" mjpeg_vaapi_hwaccel_select="mjpeg_decoder" +mjpeg_nvtegra_hwaccel_deps="nvtegra" +mjpeg_nvtegra_hwaccel_select="mjpeg_decoder" mpeg1_nvdec_hwaccel_deps="nvdec" mpeg1_nvdec_hwaccel_select="mpeg1video_decoder" mpeg1_vdpau_hwaccel_deps="vdpau" mpeg1_vdpau_hwaccel_select="mpeg1video_decoder" mpeg1_videotoolbox_hwaccel_deps="videotoolbox" mpeg1_videotoolbox_hwaccel_select="mpeg1video_decoder" +mpeg1_nvtegra_hwaccel_deps="nvtegra" +mpeg1_nvtegra_hwaccel_select="mpeg1video_decoder" mpeg2_d3d11va_hwaccel_deps="d3d11va" mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder" mpeg2_d3d11va2_hwaccel_deps="d3d11va" @@ -3234,6 +3245,8 @@ mpeg2_vdpau_hwaccel_deps="vdpau" mpeg2_vdpau_hwaccel_select="mpeg2video_decoder" mpeg2_videotoolbox_hwaccel_deps="videotoolbox" mpeg2_videotoolbox_hwaccel_select="mpeg2video_decoder" +mpeg2_nvtegra_hwaccel_deps="nvtegra" +mpeg2_nvtegra_hwaccel_select="mpeg2video_decoder" mpeg4_nvdec_hwaccel_deps="nvdec" mpeg4_nvdec_hwaccel_select="mpeg4_decoder" mpeg4_vaapi_hwaccel_deps="vaapi" @@ -3244,6 +3257,8 @@ mpeg4_videotoolbox_hwaccel_deps="videotoolbox" mpeg4_videotoolbox_hwaccel_select="mpeg4_decoder" prores_videotoolbox_hwaccel_deps="videotoolbox" prores_videotoolbox_hwaccel_select="prores_decoder" +mpeg4_nvtegra_hwaccel_deps="nvtegra" +mpeg4_nvtegra_hwaccel_select="mpeg4_decoder" vc1_d3d11va_hwaccel_deps="d3d11va" vc1_d3d11va_hwaccel_select="vc1_decoder" vc1_d3d11va2_hwaccel_deps="d3d11va" @@ -3258,10 +3273,14 @@ vc1_vaapi_hwaccel_deps="vaapi" vc1_vaapi_hwaccel_select="vc1_decoder" vc1_vdpau_hwaccel_deps="vdpau" vc1_vdpau_hwaccel_select="vc1_decoder" +vc1_nvtegra_hwaccel_deps="nvtegra" +vc1_nvtegra_hwaccel_select="vc1_decoder" vp8_nvdec_hwaccel_deps="nvdec" vp8_nvdec_hwaccel_select="vp8_decoder" vp8_vaapi_hwaccel_deps="vaapi" vp8_vaapi_hwaccel_select="vp8_decoder" +vp8_nvtegra_hwaccel_deps="nvtegra" +vp8_nvtegra_hwaccel_select="vp8_decoder" vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9" vp9_d3d11va_hwaccel_select="vp9_decoder" vp9_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_VP9" @@ -3278,6 +3297,8 @@ vp9_vdpau_hwaccel_deps="vdpau VdpPictureInfoVP9" vp9_vdpau_hwaccel_select="vp9_decoder" vp9_videotoolbox_hwaccel_deps="videotoolbox" vp9_videotoolbox_hwaccel_select="vp9_decoder" +vp9_nvtegra_hwaccel_deps="nvtegra" +vp9_nvtegra_hwaccel_select="vp9_decoder" wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel" wmv3_d3d11va2_hwaccel_select="vc1_d3d11va2_hwaccel" wmv3_d3d12va_hwaccel_select="vc1_d3d12va_hwaccel" @@ -3285,6 +3306,7 @@ wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel" wmv3_nvdec_hwaccel_select="vc1_nvdec_hwaccel" wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel" wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel" +wmv3_nvtegra_hwaccel_select="vc1_nvtegra_hwaccel" # hardware-accelerated codecs d3d12va_encode_deps="d3d12va ID3D12VideoEncoder d3d12_encoder_feature" @@ -5970,6 +5992,10 @@ case $target_os in ;; minix) ;; + horizon) + enable section_data_rel_ro + add_extralibs -lnx + ;; none) ;; *) @@ -7719,6 +7745,10 @@ haiku) disable memalign fi ;; +horizon) + disable sysctl + disable sysctlbyname + ;; esac flatten_extralibs(){ diff --git a/libavcodec/Makefile b/libavcodec/Makefile index a4fcce3b42..c8fc0a1ded 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1001,6 +1001,7 @@ OBJS-$(CONFIG_VAAPI) += vaapi_decode.o OBJS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.o OBJS-$(CONFIG_VDPAU) += vdpau.o OBJS-$(CONFIG_VULKAN) += vulkan.o vulkan_video.o +OBJS-$(CONFIG_NVTEGRA) += nvtegra_decode.o OBJS-$(CONFIG_AV1_D3D11VA_HWACCEL) += dxva2_av1.o OBJS-$(CONFIG_AV1_DXVA2_HWACCEL) += dxva2_av1.o @@ -1020,6 +1021,7 @@ OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o OBJS-$(CONFIG_H264_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o OBJS-$(CONFIG_H264_VULKAN_HWACCEL) += vulkan_decode.o vulkan_h264.o +OBJS-$(CONFIG_H264_NVTEGRA_HWACCEL) += nvtegra_h264.o OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL) += dxva2_hevc.o OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o OBJS-$(CONFIG_HEVC_D3D12VA_HWACCEL) += dxva2_hevc.o d3d12va_hevc.o @@ -1028,11 +1030,14 @@ OBJS-$(CONFIG_HEVC_QSV_HWACCEL) += qsvdec.o OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o h265_profile_level.o OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o h265_profile_level.o OBJS-$(CONFIG_HEVC_VULKAN_HWACCEL) += vulkan_decode.o vulkan_hevc.o +OBJS-$(CONFIG_HEVC_NVTEGRA_HWACCEL) += nvtegra_hevc.o OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL) += nvdec_mjpeg.o OBJS-$(CONFIG_MJPEG_VAAPI_HWACCEL) += vaapi_mjpeg.o +OBJS-$(CONFIG_MJPEG_NVTEGRA_HWACCEL) += nvtegra_mjpeg.o OBJS-$(CONFIG_MPEG1_NVDEC_HWACCEL) += nvdec_mpeg12.o OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL) += vdpau_mpeg12.o OBJS-$(CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o +OBJS-$(CONFIG_MPEG1_NVTEGRA_HWACCEL) += nvtegra_mpeg12.o OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL) += dxva2_mpeg2.o OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o OBJS-$(CONFIG_MPEG2_D3D12VA_HWACCEL) += dxva2_mpeg2.o d3d12va_mpeg2.o @@ -1041,10 +1046,12 @@ OBJS-$(CONFIG_MPEG2_QSV_HWACCEL) += qsvdec.o OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL) += vdpau_mpeg12.o OBJS-$(CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o +OBJS-$(CONFIG_MPEG2_NVTEGRA_HWACCEL) += nvtegra_mpeg12.o OBJS-$(CONFIG_MPEG4_NVDEC_HWACCEL) += nvdec_mpeg4.o OBJS-$(CONFIG_MPEG4_VAAPI_HWACCEL) += vaapi_mpeg4.o OBJS-$(CONFIG_MPEG4_VDPAU_HWACCEL) += vdpau_mpeg4.o OBJS-$(CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o +OBJS-$(CONFIG_MPEG4_NVTEGRA_HWACCEL) += nvtegra_mpeg4.o OBJS-$(CONFIG_VC1_D3D11VA_HWACCEL) += dxva2_vc1.o OBJS-$(CONFIG_VC1_DXVA2_HWACCEL) += dxva2_vc1.o OBJS-$(CONFIG_VC1_D3D12VA_HWACCEL) += dxva2_vc1.o d3d12va_vc1.o @@ -1052,8 +1059,10 @@ OBJS-$(CONFIG_VC1_NVDEC_HWACCEL) += nvdec_vc1.o OBJS-$(CONFIG_VC1_QSV_HWACCEL) += qsvdec.o OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vaapi_vc1.o OBJS-$(CONFIG_VC1_VDPAU_HWACCEL) += vdpau_vc1.o +OBJS-$(CONFIG_VC1_NVTEGRA_HWACCEL) += nvtegra_vc1.o OBJS-$(CONFIG_VP8_NVDEC_HWACCEL) += nvdec_vp8.o OBJS-$(CONFIG_VP8_VAAPI_HWACCEL) += vaapi_vp8.o +OBJS-$(CONFIG_VP8_NVTEGRA_HWACCEL) += nvtegra_vp8.o OBJS-$(CONFIG_VP9_D3D11VA_HWACCEL) += dxva2_vp9.o OBJS-$(CONFIG_VP9_DXVA2_HWACCEL) += dxva2_vp9.o OBJS-$(CONFIG_VP9_D3D12VA_HWACCEL) += dxva2_vp9.o d3d12va_vp9.o @@ -1061,6 +1070,7 @@ OBJS-$(CONFIG_VP9_NVDEC_HWACCEL) += nvdec_vp9.o OBJS-$(CONFIG_VP9_VAAPI_HWACCEL) += vaapi_vp9.o OBJS-$(CONFIG_VP9_VDPAU_HWACCEL) += vdpau_vp9.o OBJS-$(CONFIG_VP9_VIDEOTOOLBOX_HWACCEL) += videotoolbox_vp9.o +OBJS-$(CONFIG_VP9_NVTEGRA_HWACCEL) += nvtegra_vp9.o OBJS-$(CONFIG_VP8_QSV_HWACCEL) += qsvdec.o # Objects duplicated from other libraries for shared builds @@ -1292,6 +1302,7 @@ SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h vulkan_encode.h vulkan_decode.h SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h v4l2_m2m.h SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h +SKIPHEADERS-$(CONFIG_NVTEGRA) += nvtegra_decode.h TESTPROGS = avcodec \ avpacket \ diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 0c23012584..5a98a33841 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -60,6 +60,9 @@ static const enum AVPixelFormat h263_hwaccel_pixfmt_list_420[] = { #endif #if CONFIG_H263_VIDEOTOOLBOX_HWACCEL || CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL AV_PIX_FMT_VIDEOTOOLBOX, +#endif +#if CONFIG_MPEG4_NVTEGRA_HWACCEL + AV_PIX_FMT_NVTEGRA, #endif AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE @@ -701,6 +704,9 @@ static const AVCodecHWConfigInternal *const h263_hw_config_list[] = { #if CONFIG_MPEG4_VDPAU_HWACCEL HWACCEL_VDPAU(mpeg4), #endif +#if CONFIG_MPEG4_NVTEGRA_HWACCEL + HWACCEL_NVTEGRA(mpeg4), +#endif #if CONFIG_H263_VIDEOTOOLBOX_HWACCEL HWACCEL_VIDEOTOOLBOX(h263), #endif diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index a66b75ca80..26d408772f 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -784,7 +784,8 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) CONFIG_H264_VAAPI_HWACCEL + \ CONFIG_H264_VIDEOTOOLBOX_HWACCEL + \ CONFIG_H264_VDPAU_HWACCEL + \ - CONFIG_H264_VULKAN_HWACCEL) + CONFIG_H264_VULKAN_HWACCEL + \ + CONFIG_H264_NVTEGRA_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; switch (h->ps.sps->bit_depth_luma) { @@ -888,6 +889,9 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) #endif #if CONFIG_H264_VAAPI_HWACCEL *fmt++ = AV_PIX_FMT_VAAPI; +#endif +#if CONFIG_H264_NVTEGRA_HWACCEL + *fmt++ = AV_PIX_FMT_NVTEGRA; #endif if (h->avctx->color_range == AVCOL_RANGE_JPEG) *fmt++ = AV_PIX_FMT_YUVJ420P; diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 0154fe17b6..f8c0a0f5ff 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -1160,6 +1160,9 @@ const FFCodec ff_h264_decoder = { #endif #if CONFIG_H264_VULKAN_HWACCEL HWACCEL_VULKAN(h264), +#endif +#if CONFIG_H264_NVTEGRA_HWACCEL + HWACCEL_NVTEGRA(h264), #endif NULL }, diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c index 0dc24f82f8..21ffcd3384 100644 --- a/libavcodec/hevc/hevcdec.c +++ b/libavcodec/hevc/hevcdec.c @@ -530,7 +530,8 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) CONFIG_HEVC_VAAPI_HWACCEL + \ CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL + \ CONFIG_HEVC_VDPAU_HWACCEL + \ - CONFIG_HEVC_VULKAN_HWACCEL) + CONFIG_HEVC_VULKAN_HWACCEL + \ + CONFIG_HEVC_NVTEGRA_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; int ret; @@ -561,6 +562,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #endif #if CONFIG_HEVC_VULKAN_HWACCEL *fmt++ = AV_PIX_FMT_VULKAN; +#endif +#if CONFIG_HEVC_NVTEGRA_HWACCEL + *fmt++ = AV_PIX_FMT_NVTEGRA; #endif break; case AV_PIX_FMT_YUV420P10: @@ -588,6 +592,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #endif #if CONFIG_HEVC_NVDEC_HWACCEL *fmt++ = AV_PIX_FMT_CUDA; +#endif +#if CONFIG_HEVC_NVTEGRA_HWACCEL + *fmt++ = AV_PIX_FMT_NVTEGRA; #endif break; case AV_PIX_FMT_YUV444P: @@ -708,6 +715,7 @@ static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, GetBitContext const HEVCVPS *vps; unsigned pps_id, layer_idx; int i, ret; + int nvidia_skip_len_start; // Coded parameters sh->first_slice_in_pic_flag = get_bits1(gb); @@ -782,6 +790,8 @@ static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, GetBitContext return AVERROR_INVALIDDATA; } + nvidia_skip_len_start = get_bits_left(gb); + // when flag is not present, picture is inferred to be output sh->pic_output_flag = 1; if (pps->output_flag_present_flag) @@ -841,6 +851,7 @@ static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, GetBitContext } sh->long_term_ref_pic_set_size = pos - get_bits_left(gb); + sh->nvidia_skip_length = nvidia_skip_len_start - get_bits_left(gb); if (sps->temporal_mvp_enabled) sh->slice_temporal_mvp_enabled_flag = get_bits1(gb); else @@ -853,6 +864,7 @@ static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, GetBitContext sh->short_term_rps = NULL; sh->long_term_ref_pic_set_size = 0; sh->slice_temporal_mvp_enabled_flag = 0; + sh->nvidia_skip_length = nvidia_skip_len_start - get_bits_left(gb); } sh->inter_layer_pred = 0; @@ -4107,6 +4119,9 @@ const FFCodec ff_hevc_decoder = { #endif #if CONFIG_HEVC_VULKAN_HWACCEL HWACCEL_VULKAN(hevc), +#endif +#if CONFIG_HEVC_NVTEGRA_HWACCEL + HWACCEL_NVTEGRA(hevc), #endif NULL }, diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h index 6ba2ca3887..c076cbbc80 100644 --- a/libavcodec/hevc/hevcdec.h +++ b/libavcodec/hevc/hevcdec.h @@ -283,6 +283,8 @@ typedef struct SliceHeader { int slice_ctb_addr_rs; unsigned data_offset; + + int nvidia_skip_length; } SliceHeader; typedef struct CodingUnit { diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h index 5171e4c7d7..f5a121d23f 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -37,6 +37,7 @@ extern const struct FFHWAccel ff_h264_nvdec_hwaccel; extern const struct FFHWAccel ff_h264_vaapi_hwaccel; extern const struct FFHWAccel ff_h264_vdpau_hwaccel; extern const struct FFHWAccel ff_h264_videotoolbox_hwaccel; +extern const struct FFHWAccel ff_h264_nvtegra_hwaccel; extern const struct FFHWAccel ff_h264_vulkan_hwaccel; extern const struct FFHWAccel ff_hevc_d3d11va_hwaccel; extern const struct FFHWAccel ff_hevc_d3d11va2_hwaccel; @@ -46,12 +47,15 @@ extern const struct FFHWAccel ff_hevc_nvdec_hwaccel; extern const struct FFHWAccel ff_hevc_vaapi_hwaccel; extern const struct FFHWAccel ff_hevc_vdpau_hwaccel; extern const struct FFHWAccel ff_hevc_videotoolbox_hwaccel; +extern const struct FFHWAccel ff_hevc_nvtegra_hwaccel; extern const struct FFHWAccel ff_hevc_vulkan_hwaccel; extern const struct FFHWAccel ff_mjpeg_nvdec_hwaccel; extern const struct FFHWAccel ff_mjpeg_vaapi_hwaccel; +extern const struct FFHWAccel ff_mjpeg_nvtegra_hwaccel; extern const struct FFHWAccel ff_mpeg1_nvdec_hwaccel; extern const struct FFHWAccel ff_mpeg1_vdpau_hwaccel; extern const struct FFHWAccel ff_mpeg1_videotoolbox_hwaccel; +extern const struct FFHWAccel ff_mpeg1_nvtegra_hwaccel; extern const struct FFHWAccel ff_mpeg2_d3d11va_hwaccel; extern const struct FFHWAccel ff_mpeg2_d3d11va2_hwaccel; extern const struct FFHWAccel ff_mpeg2_d3d12va_hwaccel; @@ -60,11 +64,13 @@ extern const struct FFHWAccel ff_mpeg2_nvdec_hwaccel; extern const struct FFHWAccel ff_mpeg2_vaapi_hwaccel; extern const struct FFHWAccel ff_mpeg2_vdpau_hwaccel; extern const struct FFHWAccel ff_mpeg2_videotoolbox_hwaccel; +extern const struct FFHWAccel ff_mpeg2_nvtegra_hwaccel; extern const struct FFHWAccel ff_mpeg4_nvdec_hwaccel; extern const struct FFHWAccel ff_mpeg4_vaapi_hwaccel; extern const struct FFHWAccel ff_mpeg4_vdpau_hwaccel; extern const struct FFHWAccel ff_mpeg4_videotoolbox_hwaccel; extern const struct FFHWAccel ff_prores_videotoolbox_hwaccel; +extern const struct FFHWAccel ff_mpeg4_nvtegra_hwaccel; extern const struct FFHWAccel ff_vc1_d3d11va_hwaccel; extern const struct FFHWAccel ff_vc1_d3d11va2_hwaccel; extern const struct FFHWAccel ff_vc1_d3d12va_hwaccel; @@ -72,8 +78,10 @@ extern const struct FFHWAccel ff_vc1_dxva2_hwaccel; extern const struct FFHWAccel ff_vc1_nvdec_hwaccel; extern const struct FFHWAccel ff_vc1_vaapi_hwaccel; extern const struct FFHWAccel ff_vc1_vdpau_hwaccel; +extern const struct FFHWAccel ff_vc1_nvtegra_hwaccel; extern const struct FFHWAccel ff_vp8_nvdec_hwaccel; extern const struct FFHWAccel ff_vp8_vaapi_hwaccel; +extern const struct FFHWAccel ff_vp8_nvtegra_hwaccel; extern const struct FFHWAccel ff_vp9_d3d11va_hwaccel; extern const struct FFHWAccel ff_vp9_d3d11va2_hwaccel; extern const struct FFHWAccel ff_vp9_d3d12va_hwaccel; @@ -82,6 +90,7 @@ extern const struct FFHWAccel ff_vp9_nvdec_hwaccel; extern const struct FFHWAccel ff_vp9_vaapi_hwaccel; extern const struct FFHWAccel ff_vp9_vdpau_hwaccel; extern const struct FFHWAccel ff_vp9_videotoolbox_hwaccel; +extern const struct FFHWAccel ff_vp9_nvtegra_hwaccel; extern const struct FFHWAccel ff_wmv3_d3d11va_hwaccel; extern const struct FFHWAccel ff_wmv3_d3d11va2_hwaccel; extern const struct FFHWAccel ff_wmv3_d3d12va_hwaccel; @@ -89,5 +98,6 @@ extern const struct FFHWAccel ff_wmv3_dxva2_hwaccel; extern const struct FFHWAccel ff_wmv3_nvdec_hwaccel; extern const struct FFHWAccel ff_wmv3_vaapi_hwaccel; extern const struct FFHWAccel ff_wmv3_vdpau_hwaccel; +extern const struct FFHWAccel ff_wmv3_nvtegra_hwaccel; #endif /* AVCODEC_HWACCELS_H */ diff --git a/libavcodec/hwconfig.h b/libavcodec/hwconfig.h index ee29ca631d..a3c3402c77 100644 --- a/libavcodec/hwconfig.h +++ b/libavcodec/hwconfig.h @@ -79,6 +79,8 @@ void ff_hwaccel_uninit(AVCodecContext *avctx); HW_CONFIG_HWACCEL(0, 0, 1, D3D11VA_VLD, NONE, ff_ ## codec ## _d3d11va_hwaccel) #define HWACCEL_D3D12VA(codec) \ HW_CONFIG_HWACCEL(1, 1, 0, D3D12, D3D12VA, ff_ ## codec ## _d3d12va_hwaccel) +#define HWACCEL_NVTEGRA(codec) \ + HW_CONFIG_HWACCEL(1, 1, 0, NVTEGRA, NVTEGRA, ff_ ## codec ## _nvtegra_hwaccel) #define HW_CONFIG_ENCODER(device, frames, ad_hoc, format, device_type_) \ &(const AVCodecHWConfigInternal) { \ diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 86ec58713c..1010e7a9cd 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -733,6 +733,9 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) #endif #if CONFIG_MJPEG_VAAPI_HWACCEL AV_PIX_FMT_VAAPI, +#endif +#if CONFIG_MJPEG_NVTEGRA_HWACCEL + AV_PIX_FMT_NVTEGRA, #endif s->avctx->pix_fmt, AV_PIX_FMT_NONE, @@ -3019,6 +3022,9 @@ const FFCodec ff_mjpeg_decoder = { #endif #if CONFIG_MJPEG_VAAPI_HWACCEL HWACCEL_VAAPI(mjpeg), +#endif +#if CONFIG_MJPEG_NVTEGRA_HWACCEL + HWACCEL_NVTEGRA(mjpeg), #endif NULL }, diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 4f784611de..e05f8e4bd4 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -812,6 +812,9 @@ static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = { #endif #if CONFIG_MPEG1_VDPAU_HWACCEL AV_PIX_FMT_VDPAU, +#endif +#if CONFIG_MPEG1_NVTEGRA_HWACCEL + AV_PIX_FMT_NVTEGRA, #endif AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE @@ -839,6 +842,9 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = { #endif #if CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL AV_PIX_FMT_VIDEOTOOLBOX, +#endif +#if CONFIG_MPEG2_NVTEGRA_HWACCEL + AV_PIX_FMT_NVTEGRA, #endif AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE @@ -2609,6 +2615,9 @@ const FFCodec ff_mpeg1video_decoder = { #endif #if CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL HWACCEL_VIDEOTOOLBOX(mpeg1), +#endif +#if CONFIG_MPEG1_NVTEGRA_HWACCEL + HWACCEL_NVTEGRA(mpeg1), #endif NULL }, @@ -2681,6 +2690,9 @@ const FFCodec ff_mpeg2video_decoder = { #endif #if CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL HWACCEL_VIDEOTOOLBOX(mpeg2), +#endif +#if CONFIG_MPEG2_NVTEGRA_HWACCEL + HWACCEL_NVTEGRA(mpeg2), #endif NULL }, diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index debcafc4c0..0575ea4236 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -3863,6 +3863,9 @@ const FFCodec ff_mpeg4_decoder = { #endif #if CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL HWACCEL_VIDEOTOOLBOX(mpeg4), +#endif +#if CONFIG_MPEG4_NVTEGRA_HWACCEL + HWACCEL_NVTEGRA(mpeg4), #endif NULL }, diff --git a/libavcodec/nvtegra_decode.c b/libavcodec/nvtegra_decode.c new file mode 100644 index 0000000000..1978fcf644 --- /dev/null +++ b/libavcodec/nvtegra_decode.c @@ -0,0 +1,517 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "libavutil/hwcontext.h" +#include "libavutil/hwcontext_nvtegra.h" +#include "libavutil/nvtegra_host1x.h" +#include "libavutil/pixdesc.h" +#include "libavutil/pixfmt.h" +#include "libavutil/intreadwrite.h" + +#include "avcodec.h" +#include "codec_desc.h" +#include "internal.h" +#include "decode.h" +#include "nvtegra_decode.h" + +static void nvtegra_input_map_free(void *opaque, uint8_t *data) { + AVNVTegraMap *map = (AVNVTegraMap *)data; + + if (!data) + return; + + av_nvtegra_map_destroy(map); + + av_freep(&map); +} + +static AVBufferRef *nvtegra_input_map_alloc(void *opaque, size_t size) { + FFNVTegraDecodeContext *ctx = opaque; + + AVBufferRef *buffer; + AVNVTegraMap *map; + int err; + + map = av_mallocz(sizeof(*map)); + if (!map) + return NULL; + + err = av_nvtegra_map_create(map, ctx->channel, ctx->input_map_size, 0x100, + NVMAP_HEAP_IOVMM, NVMAP_HANDLE_WRITE_COMBINE); + if (err < 0) + return NULL; + + buffer = av_buffer_create((uint8_t *)map, sizeof(*map), nvtegra_input_map_free, ctx, 0); + if (!buffer) + goto fail; + + ctx->new_input_buffer = true; + + return buffer; + +fail: + av_log(ctx, AV_LOG_ERROR, "Failed to create buffer\n"); + av_nvtegra_map_destroy(map); + av_freep(map); + return NULL; +} + +int ff_nvtegra_decode_init(AVCodecContext *avctx, FFNVTegraDecodeContext *ctx) { + AVHWFramesContext *frames_ctx; + AVHWDeviceContext *hw_device_ctx; + AVNVTegraDeviceContext *device_hwctx; + + int err; + + err = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_NVTEGRA); + if (err < 0) + goto fail; + + frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data; + hw_device_ctx = (AVHWDeviceContext *)frames_ctx->device_ref->data; + device_hwctx = hw_device_ctx->hwctx; + + if ((!ctx->is_nvjpg && !device_hwctx->nvdec_version) || (ctx->is_nvjpg && !device_hwctx->nvjpg_version)) + return AVERROR(EACCES); + + ctx->hw_device_ref = av_buffer_ref(frames_ctx->device_ref); + if (!ctx->hw_device_ref) { + err = AVERROR(ENOMEM); + goto fail; + } + + ctx->decoder_pool = av_buffer_pool_init2(sizeof(AVNVTegraMap), ctx, + nvtegra_input_map_alloc, NULL); + if (!ctx->decoder_pool) { + err = AVERROR(ENOMEM); + goto fail; + } + + ctx->channel = !ctx->is_nvjpg ? &device_hwctx->nvdec_channel : &device_hwctx->nvjpg_channel; + + err = av_nvtegra_cmdbuf_init(&ctx->cmdbuf); + if (err < 0) + goto fail; + + err = av_nvtegra_dfs_init(hw_device_ctx, ctx->channel, avctx->coded_width, avctx->coded_height, + av_q2d(avctx->framerate)); + if (err < 0) + goto fail; + + return 0; + +fail: + ff_nvtegra_decode_uninit(avctx, ctx); + return err; +} + +int ff_nvtegra_decode_uninit(AVCodecContext *avctx, FFNVTegraDecodeContext *ctx) { + AVHWFramesContext *frames_ctx; + AVHWDeviceContext *hw_device_ctx; + + av_buffer_pool_uninit(&ctx->decoder_pool); + + av_buffer_unref(&ctx->hw_device_ref); + + av_nvtegra_cmdbuf_deinit(&ctx->cmdbuf); + + if (avctx->hw_frames_ctx) { + frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data; + hw_device_ctx = (AVHWDeviceContext *)frames_ctx->device_ref->data; + + av_nvtegra_dfs_uninit(hw_device_ctx, ctx->channel); + } + + + return 0; +} + +static void nvtegra_fdd_priv_free(void *priv) { + FFNVTegraDecodeFrame *tf = priv; + FFNVTegraDecodeContext *ctx = tf->ctx; + + if (!tf) + return; + + if (tf->in_flight) + av_nvtegra_syncpt_wait(ctx->channel, tf->fence, -1); + + av_buffer_unref(&tf->input_map_ref); + av_freep(&tf); +} + +int ff_nvtegra_wait_decode(void *logctx, AVFrame *frame) { + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + FFNVTegraDecodeContext *ctx = tf->ctx; + AVNVTegraMap *input_map = (AVNVTegraMap *)tf->input_map_ref->data; + AVHWDeviceContext *hw_device_ctx = (AVHWDeviceContext *)ctx->hw_device_ref->data; + + nvdec_status_s *nvdec_status; + nvjpg_dec_status *nvjpg_status; + uint32_t decode_cycles; + uint8_t *mem; + int err; + + if (!tf->in_flight) + return 0; + + mem = av_nvtegra_map_get_addr(input_map); + + err = av_nvtegra_syncpt_wait(ctx->channel, tf->fence, -1); + if (err < 0) + return err; + + tf->in_flight = false; + + if (!ctx->is_nvjpg) { + nvdec_status = (nvdec_status_s *)(mem + ctx->status_off); + if (nvdec_status->error_status != 0 || nvdec_status->mbs_in_error != 0) + return AVERROR_UNKNOWN; + + decode_cycles = nvdec_status->cycle_count * 16; + } else { + nvjpg_status = (nvjpg_dec_status *)(mem + ctx->status_off); + if (nvjpg_status->error_status != 0 || nvjpg_status->bytes_offset == 0) + return AVERROR_UNKNOWN; + + decode_cycles = nvjpg_status->cycle_count; + } + + /* Decode time in µs: decode_cycles * 1000000 / ctx->channel->clock */ + err = av_nvtegra_dfs_update(hw_device_ctx, ctx->channel, tf->bitstream_len, decode_cycles); + if (err < 0) + return err; + + return 0; +} + +int ff_nvtegra_start_frame(AVCodecContext *avctx, AVFrame *frame, FFNVTegraDecodeContext *ctx) { + AVHWFramesContext *frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + + FFNVTegraDecodeFrame *tf = NULL; + int err; + + /* Abort on resolution changes that wouldn't fit into the frame */ + if ((frame->width > frames_ctx->width) || (frame->height > frames_ctx->height)) + return AVERROR(EINVAL); + + ctx->bitstream_len = ctx->num_slices = 0; + + if (fdd->hwaccel_priv) { + /* + * For interlaced video, both fields use the same fdd, + * however by proceeding we might overwrite the input buffer + * during the decoding, so wait for the previous operation to complete. + */ + err = ff_nvtegra_wait_decode(avctx, frame); + if (err < 0) + return err; + } else { + tf = av_mallocz(sizeof(*tf)); + if (!tf) + return AVERROR(ENOMEM); + + fdd->hwaccel_priv = tf; + fdd->hwaccel_priv_free = nvtegra_fdd_priv_free; + fdd->post_process = ff_nvtegra_wait_decode; + + tf->ctx = ctx; + + tf->input_map_ref = av_buffer_pool_get(ctx->decoder_pool); + if (!tf->input_map_ref) { + err = AVERROR(ENOMEM); + goto fail; + } + } + + tf = fdd->hwaccel_priv; + tf->in_flight = false; + + err = av_nvtegra_cmdbuf_add_memory(&ctx->cmdbuf, (AVNVTegraMap *)tf->input_map_ref->data, + ctx->cmdbuf_off, ctx->max_cmdbuf_size); + if (err < 0) + return err; + + err = av_nvtegra_cmdbuf_clear(&ctx->cmdbuf); + if (err < 0) + return err; + + return 0; + +fail: + nvtegra_fdd_priv_free(tf); + return err; +} + +int ff_nvtegra_decode_slice(AVCodecContext *avctx, AVFrame *frame, + const uint8_t *buf, uint32_t buf_size, bool add_startcode) +{ + FFNVTegraDecodeContext *ctx = avctx->internal->hwaccel_priv_data; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + AVNVTegraMap *input_map = (AVNVTegraMap *)tf->input_map_ref->data; + + bool need_bitstream_move = false; + uint32_t old_bitstream_off, startcode_size; + uint8_t *mem; + int err; + + mem = av_nvtegra_map_get_addr(input_map); + + startcode_size = add_startcode ? 3 : 0; + + /* Reserve 16 bytes for the termination sequence */ + if (ctx->bitstream_len + buf_size + startcode_size >= ctx->max_bitstream_size - 16) { + ctx->input_map_size += ctx->max_bitstream_size + buf_size; + ctx->input_map_size = FFALIGN(ctx->input_map_size, 0x1000); + + ctx->max_bitstream_size = ctx->input_map_size - ctx->bitstream_off; + + need_bitstream_move = false; + } + + /* Reserve 4 bytes for the bitstream size */ + if (ctx->max_num_slices && ctx->num_slices >= ctx->max_num_slices - 1) { + ctx->input_map_size += ctx->max_num_slices * sizeof(uint32_t); + ctx->input_map_size = FFALIGN(ctx->input_map_size, 0x1000); + + ctx->max_num_slices *= 2; + + old_bitstream_off = ctx->bitstream_off; + ctx->bitstream_off = ctx->slice_offsets_off + ctx->max_num_slices * sizeof(uint32_t); + + need_bitstream_move = true; + } + + if (ctx->input_map_size != av_nvtegra_map_get_size(input_map)) { + err = av_nvtegra_map_realloc(input_map, ctx->input_map_size, 0x100, + NVMAP_HEAP_IOVMM, NVMAP_HANDLE_WRITE_COMBINE); + if (err < 0) + return err; + + mem = av_nvtegra_map_get_addr(input_map); + + err = av_nvtegra_cmdbuf_add_memory(&ctx->cmdbuf, input_map, + ctx->cmdbuf_off, ctx->max_cmdbuf_size); + if (err < 0) + return err; + + /* Running out of slice offsets mem shouldn't happen so the extra memmove is fine */ + if (need_bitstream_move) + memmove(mem + ctx->bitstream_off, mem + old_bitstream_off, ctx->bitstream_len); + } + + if (ctx->max_num_slices) + ((uint32_t *)(mem + ctx->slice_offsets_off))[ctx->num_slices] = ctx->bitstream_len; + + /* NAL startcode 000001 */ + if (add_startcode) { + AV_WB24(mem + ctx->bitstream_off + ctx->bitstream_len, 1); + ctx->bitstream_len += 3; + } + + memcpy(mem + ctx->bitstream_off + ctx->bitstream_len, buf, buf_size); + ctx->bitstream_len += buf_size; + + ctx->num_slices++; + + return 0; +} + +int ff_nvtegra_end_frame(AVCodecContext *avctx, AVFrame *frame, FFNVTegraDecodeContext *ctx, + const uint8_t *end_sequence, int end_sequence_size) +{ + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + AVNVTegraMap *input_map = (AVNVTegraMap *)tf->input_map_ref->data; + + uint8_t *mem; + int err; + + mem = av_nvtegra_map_get_addr(input_map); + + /* Last slice data range */ + if (ctx->max_num_slices) + ((uint32_t *)(mem + ctx->slice_offsets_off))[ctx->num_slices] = ctx->bitstream_len; + + /* Termination sequence for the bitstream data */ + if (end_sequence_size) + memcpy(mem + ctx->bitstream_off + ctx->bitstream_len, end_sequence, end_sequence_size); + + err = av_nvtegra_cmdbuf_begin(&ctx->cmdbuf, !ctx->is_nvjpg ? HOST1X_CLASS_NVDEC : HOST1X_CLASS_NVJPG); + if (err < 0) + return err; + + err = av_nvtegra_cmdbuf_add_syncpt_incr(&ctx->cmdbuf, ctx->channel->syncpt, 0); + if (err < 0) + return err; + + err = av_nvtegra_cmdbuf_end(&ctx->cmdbuf); + if (err < 0) + return err; + + err = av_nvtegra_channel_submit(ctx->channel, &ctx->cmdbuf, &tf->fence); + if (err < 0) + return err; + + tf->bitstream_len = ctx->bitstream_len; + tf->in_flight = true; + + ctx->frame_idx++; + + ctx->new_input_buffer = false; + + return 0; +} + +static int nvtegra_get_size_constraints(enum AVCodecID codec, + int *min_width, int *min_height, + int *max_width, int *max_height, + int *align, int *max_mbs) +{ + switch (codec) { + case AV_CODEC_ID_MPEG1VIDEO: + case AV_CODEC_ID_MPEG2VIDEO: + *min_width = 48, *min_height = 1; + *max_width = 4096, *max_height = 4096; + *align = 16, *max_mbs = 0x20000; + break; + + case AV_CODEC_ID_MPEG4: + *min_width = 48, *min_height = 1; + *max_width = 2048, *max_height = 2048; + *align = 16, *max_mbs = 0x2000; + break; + + case AV_CODEC_ID_VC1: + case AV_CODEC_ID_WMV3: + *min_width = 48, *min_height = 1; + *max_width = 2048, *max_height = 2048; + *align = 1, *max_mbs = -1; + break; + + case AV_CODEC_ID_H264: + *min_width = 48, *min_height = 1; + *max_width = 4096, *max_height = 4096; + *align = 16, *max_mbs = 0x20000; + break; + + case AV_CODEC_ID_HEVC: + /* Note: on nvdec 4.0+ (tegra 194) max dimensions are 8192, and max mbs 0x80000 */ + *min_width = 144, *min_height = 144; + *max_width = 4096, *max_height = 4096; + *align = 64, *max_mbs = 0x20000; + break; + + case AV_CODEC_ID_VP8: + *min_width = 48, *min_height = 1; + *max_width = 4096, *max_height = 4096; + *align = 16, *max_mbs = 0x20000; + break; + + case AV_CODEC_ID_VP9: + /* Note: on nvdec 4.0+ (tegra 194) max dimensions are 8192, and max mbs 0x40000 */ + *min_width = 144, *min_height = 144; + *max_width = 4096, *max_height = 4096; + *align = 16, *max_mbs = 0x10000; + break; + + case AV_CODEC_ID_MJPEG: + *min_width = 1, *min_height = 1; + *max_width = 16384, *max_height = 16384; + *align = 1, *max_mbs = -1; + break; + + #if 0 + case AV_CODEC_ID_AV1: + /* Note: on nvdec 4.0+ (tegra 194) max dimensions are 8192, and max mbs 0x80000 */ + *min_width = 128, *min_height = 128; + *max_width = 4096, *max_height = 4096; + *align = 64, *max_mbs = 0x20000; + break; + #endif + + default: + return AVERROR(EINVAL); + } + + return 0; +} + +int ff_nvtegra_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx) { + AVHWFramesContext *frames_ctx = (AVHWFramesContext *)hw_frames_ctx->data; + const AVPixFmtDescriptor *sw_desc; + + int min_width, min_height, max_width, max_height, align, max_mbs, + aligned_width, aligned_height, num_mbs; + int err; + + err = nvtegra_get_size_constraints(avctx->codec_id, &min_width, &min_height, + &max_width, &max_height, &align, &max_mbs); + if (err < 0) + return err; + + aligned_width = FFALIGN(avctx->coded_width, align); + aligned_height = FFALIGN(avctx->coded_height, align); + num_mbs = (aligned_width / 16) * (aligned_height / 16); + + if ((aligned_width < min_width) || (aligned_width > max_width) || + (aligned_height < min_height) || (aligned_height > max_height)) + { + av_log(avctx, AV_LOG_ERROR, "Dimensions %dx%d (min. %dx%d, max. %dx%d) " + "are not supported by the hardware for codec %s\n", + avctx->coded_width, avctx->coded_height, + min_width, min_height, max_width, max_height, + avctx->codec_descriptor->name); + return AVERROR(EINVAL); + } + + if ((max_mbs > 0) && (num_mbs > max_mbs)) { + av_log(avctx, AV_LOG_ERROR, "Number of macroblocks %d exceeds maximum %d " + "for codec %s\n", + num_mbs, max_mbs, avctx->codec_descriptor->name); + return AVERROR(EINVAL); + } + + frames_ctx->format = AV_PIX_FMT_NVTEGRA; + frames_ctx->width = FFALIGN(avctx->coded_width, 2); /* NVDEC only supports even sizes */ + frames_ctx->height = FFALIGN(avctx->coded_height, 2); + + sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt); + if (!sw_desc) + return AVERROR_BUG; + + switch (sw_desc->comp[0].depth) { + case 8: + frames_ctx->sw_format = (sw_desc->nb_components > 1) ? + AV_PIX_FMT_NV12 : AV_PIX_FMT_GRAY8; + break; + case 10: + frames_ctx->sw_format = (sw_desc->nb_components > 1) ? + AV_PIX_FMT_P010 : AV_PIX_FMT_GRAY10; + break; + default: + return AVERROR(EINVAL); + } + + return 0; +} diff --git a/libavcodec/nvtegra_decode.h b/libavcodec/nvtegra_decode.h new file mode 100644 index 0000000000..5260c8b3c5 --- /dev/null +++ b/libavcodec/nvtegra_decode.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef AVCODEC_NVTEGRA_DECODE_H +#define AVCODEC_NVTEGRA_DECODE_H + +#include + +#include "avcodec.h" +#include "libavutil/mem.h" +#include "libavutil/hwcontext_nvtegra.h" + +#include "libavutil/nvdec_drv.h" +#include "libavutil/nvjpg_drv.h" +#include "libavutil/clc5b0.h" +#include "libavutil/cle7d0.h" + +typedef struct FFNVTegraDecodeContext { + uint64_t frame_idx; + + AVBufferRef *hw_device_ref; + AVBufferPool *decoder_pool; + + bool is_nvjpg; + AVNVTegraChannel *channel; + + AVNVTegraCmdbuf cmdbuf; + + uint32_t pic_setup_off, status_off, cmdbuf_off, + bitstream_off, slice_offsets_off; + uint32_t input_map_size; + uint32_t max_cmdbuf_size, max_bitstream_size, max_num_slices; + + uint32_t num_slices; + uint32_t bitstream_len; + + bool new_input_buffer; +} FFNVTegraDecodeContext; + +typedef struct FFNVTegraDecodeFrame { + FFNVTegraDecodeContext *ctx; + AVBufferRef *input_map_ref; + uint32_t fence; + uint32_t bitstream_len; + bool in_flight; +} FFNVTegraDecodeFrame; + +static inline size_t ff_nvtegra_decode_pick_bitstream_buffer_size(AVCodecContext *avctx) { + /* + * Official software uses a static map of a predetermined size, usually around 0x600000 (6MiB). + * Our implementation supports dynamically resizing the input map, so be less conservative. + */ + if ((avctx->coded_width >= 3840) || (avctx->coded_height >= 2160)) /* 4k */ + return 0x100000; /* 1MiB */ + if ((avctx->coded_width >= 1920) || (avctx->coded_height >= 1080)) /* 1080p */ + return 0x40000; /* 256KiB */ + else + return 0x10000; /* 64KiB */ +} + +static inline AVFrame *ff_nvtegra_safe_get_ref(AVFrame *ref, AVFrame *fallback) { + return (ref && ref->private_ref) ? ref : fallback; +} + +int ff_nvtegra_decode_init(AVCodecContext *avctx, FFNVTegraDecodeContext *ctx); +int ff_nvtegra_decode_uninit(AVCodecContext *avctx, FFNVTegraDecodeContext *ctx); +int ff_nvtegra_start_frame(AVCodecContext *avctx, AVFrame *frame, FFNVTegraDecodeContext *ctx); +int ff_nvtegra_decode_slice(AVCodecContext *avctx, AVFrame *frame, + const uint8_t *buf, uint32_t buf_size, bool add_startcode); +int ff_nvtegra_end_frame(AVCodecContext *avctx, AVFrame *frame, FFNVTegraDecodeContext *ctx, + const uint8_t *end_sequence, int end_sequence_size); + +int ff_nvtegra_wait_decode(void *logctx, AVFrame *frame); + +int ff_nvtegra_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx); + +#endif /* AVCODEC_NVTEGRA_DECODE_H */ diff --git a/libavcodec/nvtegra_h264.c b/libavcodec/nvtegra_h264.c new file mode 100644 index 0000000000..e425ec5d0f --- /dev/null +++ b/libavcodec/nvtegra_h264.c @@ -0,0 +1,501 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config_components.h" + +#include +#include + +#include "avcodec.h" +#include "hwaccel_internal.h" +#include "internal.h" +#include "hwconfig.h" +#include "h264dec.h" +#include "decode.h" +#include "nvtegra_decode.h" + +#include "libavutil/pixdesc.h" +#include "libavutil/nvtegra_host1x.h" + +typedef struct NVTegraH264FrameData { + uint8_t pic_idx; + uint8_t dpb_idx; + bool pic_initialized, dpb_initialized; +} NVTegraH264FrameData; + +typedef struct NVTegraH264DecodeContext { + FFNVTegraDecodeContext core; + + AVNVTegraMap common_map; + uint32_t coloc_off, mbhist_off, history_off; + uint32_t mbhist_size, history_size; + + H264Picture *dpb[16], *scratch_ref; + uint32_t dpb_mask, pic_idx_mask; +} NVTegraH264DecodeContext; + +/* Size (width, height) of a macroblock */ +#define MB_SIZE 16 + +static const uint8_t bitstream_end_sequence[16] = { + 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0x00, 0x00, +}; + +static int nvtegra_h264_decode_uninit(AVCodecContext *avctx) { + NVTegraH264DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + int err; + + av_log(avctx, AV_LOG_DEBUG, "Deinitializing NVTEGRA H264 decoder\n"); + + err = av_nvtegra_map_destroy(&ctx->common_map); + if (err < 0) + return err; + + err = ff_nvtegra_decode_uninit(avctx, &ctx->core); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_h264_decode_init(AVCodecContext *avctx) { + H264Context *h = avctx->priv_data; + const SPS *sps = h->ps.sps; + NVTegraH264DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + AVHWDeviceContext *hw_device_ctx; + AVNVTegraDeviceContext *device_hwctx; + uint32_t aligned_width, aligned_height, + width_in_mbs, height_in_mbs, num_slices, + coloc_size, mbhist_size, history_size, common_map_size; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Initializing NVTEGRA H264 decoder\n"); + + aligned_width = FFALIGN(avctx->coded_width, MB_SIZE); + aligned_height = FFALIGN(avctx->coded_height, MB_SIZE); + width_in_mbs = aligned_width / MB_SIZE; + height_in_mbs = aligned_height / MB_SIZE; + + num_slices = width_in_mbs * height_in_mbs; + + /* Ignored: histogram map, size 0x400 */ + ctx->core.pic_setup_off = 0; + ctx->core.status_off = FFALIGN(ctx->core.pic_setup_off + sizeof(nvdec_h264_pic_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.cmdbuf_off = FFALIGN(ctx->core.status_off + sizeof(nvdec_status_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.slice_offsets_off = FFALIGN(ctx->core.cmdbuf_off + 3*AV_NVTEGRA_MAP_ALIGN, + AV_NVTEGRA_MAP_ALIGN); + ctx->core.bitstream_off = FFALIGN(ctx->core.slice_offsets_off + num_slices * sizeof(uint32_t), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.input_map_size = FFALIGN(ctx->core.bitstream_off + ff_nvtegra_decode_pick_bitstream_buffer_size(avctx), + 0x1000); + + ctx->core.max_cmdbuf_size = ctx->core.slice_offsets_off - ctx->core.cmdbuf_off; + ctx->core.max_num_slices = (ctx->core.bitstream_off - ctx->core.slice_offsets_off) / sizeof(uint32_t); + ctx->core.max_bitstream_size = ctx->core.input_map_size - ctx->core.bitstream_off; + + err = ff_nvtegra_decode_init(avctx, &ctx->core); + if (err < 0) + goto fail; + + hw_device_ctx = (AVHWDeviceContext *)ctx->core.hw_device_ref->data; + device_hwctx = hw_device_ctx->hwctx; + + coloc_size = FFALIGN(FFALIGN(height_in_mbs, 2) * (width_in_mbs * 64) - 63, 0x100); + coloc_size *= sps->ref_frame_count + 1; /* Max number of references frames, plus current frame */ + mbhist_size = FFALIGN(width_in_mbs * 104, 0x100); + history_size = FFALIGN(width_in_mbs * 0x200 + 0x1100, 0x200); + + ctx->coloc_off = 0; + ctx->mbhist_off = FFALIGN(ctx->coloc_off + coloc_size, AV_NVTEGRA_MAP_ALIGN); + ctx->history_off = FFALIGN(ctx->mbhist_off + mbhist_size, AV_NVTEGRA_MAP_ALIGN); + common_map_size = FFALIGN(ctx->history_off + history_size, 0x1000); + + err = av_nvtegra_map_create(&ctx->common_map, &device_hwctx->nvdec_channel, common_map_size, 0x100, + NVMAP_HEAP_IOVMM, NVMAP_HANDLE_WRITE_COMBINE); + if (err < 0) + goto fail; + + ctx->mbhist_size = mbhist_size; + ctx->history_size = history_size; + + return 0; + +fail: + nvtegra_h264_decode_uninit(avctx); + return err; +} + +static inline int field_poc(int poc[2], bool top) { + return (poc[!top] != INT_MAX) ? poc[!top] : 0; +} + +static void dpb_add(H264Context *h, nvdec_dpb_entry_s *dst, H264Picture *src) { + NVTegraH264FrameData *fr_priv = src->hwaccel_picture_private; + int marking; + + marking = src->long_ref ? 2 : 1; + *dst = (nvdec_dpb_entry_s){ + .index = fr_priv->pic_idx, + .col_idx = fr_priv->pic_idx, + .state = src->reference, + .is_long_term = src->long_ref, + .not_existing = src->invalid_gap, + .is_field = src->field_picture, + .top_field_marking = (src->reference & PICT_TOP_FIELD) ? marking : 0, + .bottom_field_marking = (src->reference & PICT_BOTTOM_FIELD) ? marking : 0, + .output_memory_layout = 0, /* NV12 */ + .FieldOrderCnt = { + field_poc(src->field_poc, true), + field_poc(src->field_poc, false), + }, + .FrameIdx = src->long_ref ? src->pic_id : src->frame_num, + }; +} + +static inline void register_ref(NVTegraH264DecodeContext *ctx, H264Picture *fr) { + NVTegraH264FrameData *fr_priv = fr->hwaccel_picture_private; + + ctx->dpb[fr_priv->dpb_idx] = fr; + ctx->dpb_mask |= 1 << fr_priv->dpb_idx; + ctx->pic_idx_mask |= 1 << fr_priv->pic_idx; +} + +static inline int find_slot(uint32_t *mask) { + int slot = ff_ctz(~*mask); + *mask |= (1 << slot); + return slot; +} + +static void nvtegra_h264_prepare_frame_setup(nvdec_h264_pic_s *setup, H264Context *h, + NVTegraH264DecodeContext *ctx) +{ + const PPS *pps = h->ps.pps; + const SPS *sps = h->ps.sps; + + H264Picture *refs[16+1] = {0}; + NVTegraH264FrameData *fr_priv; + int num_refs, max, i, diff; + + *setup = (nvdec_h264_pic_s){ + .mbhist_buffer_size = ctx->mbhist_size, + + .gptimer_timeout_value = 0, /* Default value */ + + .log2_max_pic_order_cnt_lsb_minus4 = FFMAX(sps->log2_max_poc_lsb - 4, 0), + .delta_pic_order_always_zero_flag = sps->delta_pic_order_always_zero_flag, + .frame_mbs_only_flag = sps->frame_mbs_only_flag, + + .PicWidthInMbs = h->mb_width, + .FrameHeightInMbs = h->mb_height, + + .tileFormat = 0, /* TBL */ + .gob_height = 0, /* GOB_2 */ + + .entropy_coding_mode_flag = pps->cabac, + .pic_order_present_flag = pps->pic_order_present, + .num_ref_idx_l0_active_minus1 = pps->ref_count[0] - 1, + .num_ref_idx_l1_active_minus1 = pps->ref_count[1] - 1, + .deblocking_filter_control_present_flag = pps->deblocking_filter_parameters_present, + .redundant_pic_cnt_present_flag = pps->redundant_pic_cnt_present, + .transform_8x8_mode_flag = pps->transform_8x8_mode, + + .pitch_luma = h->cur_pic_ptr->f->linesize[0], + .pitch_chroma = h->cur_pic_ptr->f->linesize[1], + + .luma_top_offset = 0, + .luma_bot_offset = 0, + .luma_frame_offset = 0, + .chroma_top_offset = 0, + .chroma_bot_offset = 0, + .chroma_frame_offset = 0, + + .HistBufferSize = ctx->history_size / 256, + + .MbaffFrameFlag = sps->mb_aff && !FIELD_PICTURE(h), + .direct_8x8_inference_flag = sps->direct_8x8_inference_flag, + .weighted_pred_flag = pps->weighted_pred, + .constrained_intra_pred_flag = pps->constrained_intra_pred, + .ref_pic_flag = h->nal_ref_idc != 0, + .field_pic_flag = FIELD_PICTURE(h), + .bottom_field_flag = h->picture_structure == PICT_BOTTOM_FIELD, + .second_field = FIELD_PICTURE(h) && !h->first_field, + .log2_max_frame_num_minus4 = sps->log2_max_frame_num - 4, + .chroma_format_idc = sps->chroma_format_idc, + .pic_order_cnt_type = sps->poc_type, + .pic_init_qp_minus26 = pps->init_qp - 26, + .chroma_qp_index_offset = pps->chroma_qp_index_offset[0], + .second_chroma_qp_index_offset = pps->chroma_qp_index_offset[1], + + .weighted_bipred_idc = pps->weighted_bipred_idc, + .frame_num = h->cur_pic_ptr->frame_num, + .output_memory_layout = 0, /* NV12 */ + + .CurrFieldOrderCnt = { + field_poc(h->cur_pic_ptr->field_poc, true), + field_poc(h->cur_pic_ptr->field_poc, false), + }, + + .lossless_ipred8x8_filter_enable = true, + .qpprime_y_zero_transform_bypass_flag = sps->transform_bypass, + }; + + /* + * Decoded frames need to be allocated two indices, respectively for colocated + * and decoded data (pic_idx). For simplicity the two are kept at the same value, + * in both this code and the official driver. These indices must remain fixed + * until the frame is dropped from the DPB. + * Furthermore, a third index (dpb_idx) must be allocated when (and if) the + * decoded frame is subsequently used as a reference. + * Since decoding a frame will initialize its colocated data, but will not + * insert it (yet) in the DPB array, this last index must be decoupled from + * the previous two. The pic_idx is allocated when decoding a frame, while + * dpb_idx is allocated when it is used as a reference. + */ + + /* Build concatenated list of references */ + num_refs = 0, max = FFMIN(h->short_ref_count, FF_ARRAY_ELEMS(refs) - num_refs); + for (i = 0; i < max; ++i) + refs[num_refs++] = h->short_ref[i]; + + max = FFMIN(16, FF_ARRAY_ELEMS(refs) - num_refs); + for (i = 0; i < max; ++i) + if (h->long_ref[i]) + refs[num_refs++] = h->short_ref[i]; + + /* Add all frames with an already allocated DPB index to our ref list */ + for (i = 0; i < num_refs; ++i) { + NVTegraH264FrameData *fr_priv = refs[i]->hwaccel_picture_private; + if (!fr_priv->dpb_initialized) + continue; + + register_ref(ctx, refs[i]); + } + + /* Allocate a DPB index for new frames and add them to our ref list */ + for (i = 0; i < num_refs; ++i) { + NVTegraH264FrameData *fr_priv = refs[i]->hwaccel_picture_private; + if (fr_priv->dpb_initialized || !fr_priv->pic_initialized) + continue; + + fr_priv->dpb_idx = find_slot(&ctx->dpb_mask); + fr_priv->dpb_initialized = true; + + register_ref(ctx, refs[i]); + } + + /* Allocate a picture idx for the current frame */ + fr_priv = h->cur_pic_ptr->hwaccel_picture_private; + if (!fr_priv->pic_initialized) { + *fr_priv = (NVTegraH264FrameData){ + .pic_idx = find_slot(&ctx->pic_idx_mask), + .pic_initialized = true, + }; + } + + setup->CurrPicIdx = setup->CurrColIdx = fr_priv->pic_idx; + + /* Finally, fill the NVDEC DPB */ + for (i = 0; i < FF_ARRAY_ELEMS(setup->dpb); ++i) { + if (ctx->dpb_mask & (1 << i)) + dpb_add(h, &setup->dpb[i], ctx->dpb[i]); + } + + memcpy(setup->WeightScale, pps->scaling_matrix4, sizeof(setup->WeightScale)); + memcpy(setup->WeightScale8x8[0], pps->scaling_matrix8[0], sizeof(setup->WeightScale8x8[0])); + memcpy(setup->WeightScale8x8[1], pps->scaling_matrix8[3], sizeof(setup->WeightScale8x8[1])); + + /* Find the temporally closest frame to be used as a scratch ref, or use the current one */ + diff = INT_MAX; + ctx->scratch_ref = h->cur_pic_ptr; + for (i = 0; i < FF_ARRAY_ELEMS(ctx->dpb); ++i) { + if (!(ctx->dpb_mask & (1 << i))) + continue; + + if (FFABS(h->cur_pic_ptr->frame_num - ctx->dpb[i]->frame_num) < diff) + ctx->scratch_ref = ctx->dpb[i]; + } +} + +static int nvtegra_h264_prepare_cmdbuf(AVNVTegraCmdbuf *cmdbuf, H264Context *h, + AVFrame *cur_frame, NVTegraH264DecodeContext *ctx) +{ + FrameDecodeData *fdd = (FrameDecodeData *)cur_frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + AVNVTegraMap *input_map = (AVNVTegraMap *)tf->input_map_ref->data; + + H264Picture *refs[16+1]; + NVTegraH264FrameData *fr_priv; + int err, i; + + err = av_nvtegra_cmdbuf_begin(cmdbuf, HOST1X_CLASS_NVDEC); + if (err < 0) + return err; + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_APPLICATION_ID, + AV_NVTEGRA_ENUM(NVC5B0_SET_APPLICATION_ID, ID, H264)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_CONTROL_PARAMS, + AV_NVTEGRA_ENUM (NVC5B0_SET_CONTROL_PARAMS, CODEC_TYPE, H264) | + AV_NVTEGRA_VALUE(NVC5B0_SET_CONTROL_PARAMS, ERR_CONCEAL_ON, 1) | + AV_NVTEGRA_VALUE(NVC5B0_SET_CONTROL_PARAMS, GPTIMER_ON, 1)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_PICTURE_INDEX, + AV_NVTEGRA_VALUE(NVC5B0_SET_PICTURE_INDEX, INDEX, ctx->core.frame_idx)); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_DRV_PIC_SETUP_OFFSET, + input_map, ctx->core.pic_setup_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_IN_BUF_BASE_OFFSET, + input_map, ctx->core.bitstream_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_SLICE_OFFSETS_BUF_OFFSET, + input_map, ctx->core.slice_offsets_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_NVDEC_STATUS_OFFSET, + input_map, ctx->core.status_off, NVHOST_RELOC_TYPE_DEFAULT); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_COLOC_DATA_OFFSET, + &ctx->common_map, ctx->coloc_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_H264_SET_MBHIST_BUF_OFFSET, + &ctx->common_map, ctx->mbhist_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_HISTORY_OFFSET, + &ctx->common_map, ctx->history_off, NVHOST_RELOC_TYPE_DEFAULT); + + /* Build list of references sorted by picture idx */ + for (i = 0; i < FF_ARRAY_ELEMS(refs); ++i) + refs[i] = ctx->scratch_ref; + + fr_priv = h->cur_pic_ptr->hwaccel_picture_private; + refs[fr_priv->pic_idx] = h->cur_pic_ptr; + + for (i = 0; i < FF_ARRAY_ELEMS(ctx->dpb); ++i) { + if (!(ctx->dpb_mask & (1 << i))) + continue; + fr_priv = ctx->dpb[i]->hwaccel_picture_private; + refs[fr_priv->pic_idx] = ctx->dpb[i]; + } + +#define PUSH_FRAME(fr, offset) ({ \ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PICTURE_LUMA_OFFSET0 + offset * 4, \ + av_nvtegra_frame_get_fbuf_map(fr), 0, NVHOST_RELOC_TYPE_DEFAULT); \ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PICTURE_CHROMA_OFFSET0 + offset * 4, \ + av_nvtegra_frame_get_fbuf_map(fr), fr->data[1] - fr->data[0], \ + NVHOST_RELOC_TYPE_DEFAULT); \ +}) + + for (i = 0; i < FF_ARRAY_ELEMS(refs); ++i) + PUSH_FRAME(refs[i]->f, i); + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_EXECUTE, + AV_NVTEGRA_ENUM(NVC5B0_EXECUTE, AWAKEN, ENABLE)); + + err = av_nvtegra_cmdbuf_end(cmdbuf); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_h264_start_frame(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size) { + H264Context *h = avctx->priv_data; + AVFrame *frame = h->cur_pic_ptr->f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + NVTegraH264DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + FFNVTegraDecodeFrame *tf; + AVNVTegraMap *input_map; + uint8_t *mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Starting H264-NVTEGRA frame with pixel format %s\n", + av_get_pix_fmt_name(avctx->sw_pix_fmt)); + + err = ff_nvtegra_start_frame(avctx, frame, &ctx->core); + if (err < 0) + return err; + + tf = fdd->hwaccel_priv; + input_map = (AVNVTegraMap *)tf->input_map_ref->data; + mem = av_nvtegra_map_get_addr(input_map); + + memset(ctx->dpb, 0, sizeof(ctx->dpb)); + ctx->dpb_mask = ctx->pic_idx_mask = 0; + + nvtegra_h264_prepare_frame_setup((nvdec_h264_pic_s *)(mem + ctx->core.pic_setup_off), h, ctx); + + return 0; +} + +static int nvtegra_h264_end_frame(AVCodecContext *avctx) { + H264Context *h = avctx->priv_data; + NVTegraH264DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + AVFrame *frame = h->cur_pic_ptr->f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + + nvdec_h264_pic_s *setup; + uint8_t *mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Ending H264-NVTEGRA frame with %u slices -> %u bytes\n", + ctx->core.num_slices, ctx->core.bitstream_len); + + if (!tf || !ctx->core.num_slices) + return 0; + + mem = av_nvtegra_map_get_addr((AVNVTegraMap *)tf->input_map_ref->data); + + setup = (nvdec_h264_pic_s *)(mem + ctx->core.pic_setup_off); + setup->stream_len = ctx->core.bitstream_len + sizeof(bitstream_end_sequence); + setup->slice_count = ctx->core.num_slices; + + err = nvtegra_h264_prepare_cmdbuf(&ctx->core.cmdbuf, h, frame, ctx); + if (err < 0) + return err; + + return ff_nvtegra_end_frame(avctx, frame, &ctx->core, bitstream_end_sequence, + sizeof(bitstream_end_sequence)); +} + +static int nvtegra_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buf, + uint32_t buf_size) +{ + H264Context *h = avctx->priv_data; + AVFrame *frame = h->cur_pic_ptr->f; + + return ff_nvtegra_decode_slice(avctx, frame, buf, buf_size, true); +} + +#if CONFIG_H264_NVTEGRA_HWACCEL +const FFHWAccel ff_h264_nvtegra_hwaccel = { + .p.name = "h264_nvtegra", + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_H264, + .p.pix_fmt = AV_PIX_FMT_NVTEGRA, + .start_frame = &nvtegra_h264_start_frame, + .end_frame = &nvtegra_h264_end_frame, + .decode_slice = &nvtegra_h264_decode_slice, + .init = &nvtegra_h264_decode_init, + .uninit = &nvtegra_h264_decode_uninit, + .frame_params = &ff_nvtegra_frame_params, + .frame_priv_data_size = sizeof(NVTegraH264FrameData), + .priv_data_size = sizeof(NVTegraH264DecodeContext), + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; +#endif diff --git a/libavcodec/nvtegra_hevc.c b/libavcodec/nvtegra_hevc.c new file mode 100644 index 0000000000..0227f60220 --- /dev/null +++ b/libavcodec/nvtegra_hevc.c @@ -0,0 +1,642 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config_components.h" + +#include +#include + +#include "avcodec.h" +#include "hwaccel_internal.h" +#include "internal.h" +#include "hwconfig.h" +#include "hevc/hevcdec.h" +#include "hevc/data.h" +#include "decode.h" +#include "nvtegra_decode.h" + +#include "libavutil/pixdesc.h" +#include "libavutil/nvtegra_host1x.h" + +typedef struct NVTegraHEVCFrameData { + bool initialized; + uint8_t dpb_idx; +} NVTegraHEVCFrameData; + +typedef struct NVTegraHEVCDecodeContext { + FFNVTegraDecodeContext core; + + AVNVTegraMap common_map; + uint32_t tile_sizes_off, scaling_list_off, + coloc_off, filter_off; + + unsigned int colmv_size, sao_offset, bsd_offset; + uint8_t pattern_id; + + HEVCFrame *refs[16], *scratch_ref; + uint32_t refs_mask; +} NVTegraHEVCDecodeContext; + +/* Size (width, height) of a macroblock */ +#define MB_SIZE 16 + +/* Maximum size (width, height) of a coding tree unit */ +#define CTU_SIZE 64 + +#define FILTER_SIZE 480 +#define SAO_SIZE 3840 +#define BSD_SIZE 60 + +static int nvtegra_hevc_decode_uninit(AVCodecContext *avctx) { + NVTegraHEVCDecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + int err; + + av_log(avctx, AV_LOG_DEBUG, "Deinitializing NVTEGRA HEVC decoder\n"); + + err = av_nvtegra_map_destroy(&ctx->common_map); + if (err < 0) + return err; + + err = ff_nvtegra_decode_uninit(avctx, &ctx->core); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_hevc_decode_init(AVCodecContext *avctx) { + NVTegraHEVCDecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + AVHWDeviceContext *hw_device_ctx; + AVNVTegraDeviceContext *device_hwctx; + uint32_t aligned_width, aligned_height, + coloc_size, filter_buffer_size, common_map_size; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Initializing NVTEGRA HEVC decoder\n"); + + ctx->core.pic_setup_off = 0; + ctx->core.status_off = FFALIGN(ctx->core.pic_setup_off + sizeof(nvdec_hevc_pic_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.cmdbuf_off = FFALIGN(ctx->core.status_off + sizeof(nvdec_status_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->tile_sizes_off = FFALIGN(ctx->core.cmdbuf_off + 3*AV_NVTEGRA_MAP_ALIGN, + AV_NVTEGRA_MAP_ALIGN); + ctx->scaling_list_off = FFALIGN(ctx->tile_sizes_off + 0x900, + AV_NVTEGRA_MAP_ALIGN); + ctx->core.bitstream_off = FFALIGN(ctx->scaling_list_off + 0x400, + AV_NVTEGRA_MAP_ALIGN); + ctx->core.input_map_size = FFALIGN(ctx->core.bitstream_off + ff_nvtegra_decode_pick_bitstream_buffer_size(avctx), + 0x1000); + + ctx->core.max_cmdbuf_size = ctx->tile_sizes_off - ctx->core.cmdbuf_off; + ctx->core.max_bitstream_size = ctx->core.input_map_size - ctx->core.bitstream_off; + + err = ff_nvtegra_decode_init(avctx, &ctx->core); + if (err < 0) + goto fail; + + hw_device_ctx = (AVHWDeviceContext *)ctx->core.hw_device_ref->data; + device_hwctx = hw_device_ctx->hwctx; + + aligned_width = FFALIGN(avctx->coded_width, CTU_SIZE); + aligned_height = FFALIGN(avctx->coded_height, CTU_SIZE); + coloc_size = (aligned_width * aligned_height) + (aligned_width * aligned_height / MB_SIZE); + filter_buffer_size = (FILTER_SIZE + SAO_SIZE + BSD_SIZE) * aligned_height; + + ctx->coloc_off = 0; + ctx->filter_off = FFALIGN(ctx->coloc_off + coloc_size, AV_NVTEGRA_MAP_ALIGN); + common_map_size = FFALIGN(ctx->filter_off + filter_buffer_size, 0x1000); + + err = av_nvtegra_map_create(&ctx->common_map, &device_hwctx->nvdec_channel, common_map_size, 0x100, + NVMAP_HEAP_IOVMM, NVMAP_HANDLE_WRITE_COMBINE); + if (err < 0) + goto fail; + + ctx->colmv_size = aligned_width * aligned_height / 16; + ctx->sao_offset = FILTER_SIZE * aligned_height; + ctx->bsd_offset = (FILTER_SIZE + SAO_SIZE) * aligned_height; + + return 0; + +fail: + nvtegra_hevc_decode_uninit(avctx); + return err; +} + +static void nvtegra_hevc_set_scaling_list(nvdec_hevc_scaling_list_s *list, HEVCContext *s) { + const ScalingList *sl = s->pps->scaling_list_data_present_flag ? + &s->pps->scaling_list : &s->pps->sps->scaling_list; + + int i; + + for (i = 0; i < FF_ARRAY_ELEMS(list->ScalingListDCCoeff16x16); ++i) + list->ScalingListDCCoeff16x16[i] = sl->sl_dc[0][i]; + for (i = 0; i < FF_ARRAY_ELEMS(list->ScalingListDCCoeff32x32); ++i) + list->ScalingListDCCoeff32x32[i] = sl->sl_dc[1][i * 3]; + + for (i = 0; i < 6; ++i) + memcpy(list->ScalingList4x4[i], sl->sl[0][i], 16); + for (i = 0; i < 6; ++i) + memcpy(list->ScalingList8x8[i], sl->sl[1][i], 64); + for (i = 0; i < 6; ++i) + memcpy(list->ScalingList16x16[i], sl->sl[2][i], 64); + memcpy(list->ScalingList32x32[0], sl->sl[3][0], 64); + memcpy(list->ScalingList32x32[1], sl->sl[3][3], 64); +} + +static void nvtegra_hevc_set_tile_sizes(uint16_t *sizes, HEVCContext *s) { + const HEVCPPS *pps = s->pps; + const HEVCSPS *sps = pps->sps; + + int i, j, sum; + + uint16_t *tile_thing = sizes + 0x380; + if (pps->uniform_spacing_flag) { + for (i = 0; i < pps->num_tile_columns; ++i) + *tile_thing++ = (i + 1) * sps->ctb_width / pps->num_tile_columns << + (sps->log2_diff_max_min_coding_block_size + sps->log2_min_cb_size - 4); + for (i = 0; i < pps->num_tile_rows; ++i) + *tile_thing++ = (i + 1) * sps->ctb_height / pps->num_tile_rows << + (sps->log2_diff_max_min_coding_block_size + sps->log2_min_cb_size - 4); + } else { + sum = 0; + for (i = 0; i < pps->num_tile_columns; ++i) + *tile_thing++ = (sum += pps->column_width[i]) << + (sps->log2_diff_max_min_coding_block_size + sps->log2_min_cb_size - 4); + sum = 0; + for (i = 0; i < pps->num_tile_rows; ++i) + *tile_thing++ = (sum += pps->row_height[i]) << + (sps->log2_diff_max_min_coding_block_size + sps->log2_min_cb_size - 4); + } + + for (i = 0; i < pps->num_tile_rows; ++i) { + for (j = 0; j < pps->num_tile_columns; ++j) { + sizes[0] = pps->column_width[j]; + sizes[1] = pps->row_height [i]; + sizes += 2; + } + } +} + +static enum RPSType find_ref_rps_type(HEVCContext *s, HEVCFrame *f) { + int i; + +#define CHECK_SET(set) ({ \ + for (i = 0; i < s->rps[set].nb_refs; ++i) { \ + if (s->rps[set].ref[i] == f) \ + return set; \ + } \ +}) + + CHECK_SET(ST_CURR_BEF); + CHECK_SET(ST_CURR_AFT); + CHECK_SET(ST_FOLL); + CHECK_SET(LT_CURR); + CHECK_SET(LT_FOLL); + + return -1; +} + +static inline int find_slot(uint32_t *mask) { + int slot = ff_ctz(~*mask); + *mask |= (1 << slot); + return slot; +} + +static void nvtegra_hevc_prepare_frame_setup(nvdec_hevc_pic_s *setup, AVCodecContext *avctx, + AVFrame *frame, NVTegraHEVCDecodeContext *ctx) +{ + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + AVNVTegraMap *input_map = (AVNVTegraMap *)tf->input_map_ref->data; + AVHWFramesContext *frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data; + HEVCContext *s = avctx->priv_data; + HEVCLayerContext *l = &s->layers[s->cur_layer]; + SliceHeader *sh = &s->sh; + const HEVCPPS *pps = s->pps; + const HEVCSPS *sps = pps->sps; + + HEVCFrame *fr; + NVTegraHEVCFrameData *fr_priv; + enum RPSType st; + uint8_t *mem; + uint16_t *tile_sizes; + int output_mode, cur_frame, scratch_ref_diff_poc, i, j; + int8_t rps_stcurrbef[8], rps_stcurraft[8], rps_ltcurr[8]; + + mem = av_nvtegra_map_get_addr(input_map); + + /* Match source color depth regardless of colorspace */ + /* TODO: Dithered down 8-bit post-processing (needs DISPLAY_BUF mappings) */ + if (frames_ctx->sw_format == AV_PIX_FMT_P010 && sps->bit_depth == 10) { + output_mode = 1; /* 10-bit bt709 */ + } else { + if (sps->bit_depth == 8) { + output_mode = 0; /* 8-bit bt709 */ + } else { + switch (avctx->colorspace) { + default: + case AVCOL_SPC_BT709: + output_mode = 2; /* 10-bit bt709 truncated to 8-bit */ + break; + case AVCOL_SPC_BT2020_CL: + case AVCOL_SPC_BT2020_NCL: + output_mode = 3; /* 10-bit bt2020 truncated to 8-bit */ + break; + } + } + } + + *setup = (nvdec_hevc_pic_s){ + .gptimer_timeout_value = 0, /* Default value */ + + .tileformat = 0, /* TBL */ + .gob_height = 0, /* GOB_2 */ + + .sw_start_code_e = 1, + .disp_output_mode = output_mode, + + /* Divide by two if we are decoding to a 2bpp surface */ + .framestride = { + s->cur_frame->f->linesize[0] / ((output_mode == 1) ? 2 : 1), + s->cur_frame->f->linesize[1] / ((output_mode == 1) ? 2 : 1), + }, + + .colMvBuffersize = ctx->colmv_size / 256, + .HevcSaoBufferOffset = ctx->sao_offset / 256, + .HevcBsdCtrlOffset = ctx->bsd_offset / 256, + + .pic_width_in_luma_samples = sps->width, + .pic_height_in_luma_samples = sps->height, + + .chroma_format_idc = 1, /* 4:2:0 */ + .bit_depth_luma = sps->bit_depth, + .bit_depth_chroma = sps->bit_depth, + .log2_min_luma_coding_block_size = sps->log2_min_cb_size, + .log2_max_luma_coding_block_size = sps->log2_diff_max_min_coding_block_size + sps->log2_min_cb_size, + .log2_min_transform_block_size = sps->log2_min_tb_size, + .log2_max_transform_block_size = sps->log2_max_trafo_size, + + .max_transform_hierarchy_depth_inter = sps->max_transform_hierarchy_depth_inter, + .max_transform_hierarchy_depth_intra = sps->max_transform_hierarchy_depth_intra, + .scalingListEnable = sps->scaling_list_enabled, + .amp_enable_flag = sps->amp_enabled, + .sample_adaptive_offset_enabled_flag = sps->sao_enabled, + .pcm_enabled_flag = sps->pcm_enabled, + .pcm_sample_bit_depth_luma = sps->pcm_enabled ? sps->pcm.bit_depth : 0, + .pcm_sample_bit_depth_chroma = sps->pcm_enabled ? sps->pcm.bit_depth_chroma : 0, + .log2_min_pcm_luma_coding_block_size = sps->pcm_enabled ? sps->pcm.log2_min_pcm_cb_size : 0, + .log2_max_pcm_luma_coding_block_size = sps->pcm_enabled ? sps->pcm.log2_max_pcm_cb_size : 0, + .pcm_loop_filter_disabled_flag = sps->pcm_loop_filter_disabled, + .sps_temporal_mvp_enabled_flag = sps->temporal_mvp_enabled, + .strong_intra_smoothing_enabled_flag = sps->strong_intra_smoothing_enabled, + + .dependent_slice_segments_enabled_flag = pps->dependent_slice_segments_enabled_flag, + .output_flag_present_flag = pps->output_flag_present_flag, + .num_extra_slice_header_bits = pps->num_extra_slice_header_bits, + .sign_data_hiding_enabled_flag = pps->sign_data_hiding_flag, + .cabac_init_present_flag = pps->cabac_init_present_flag, + .num_ref_idx_l0_default_active = pps->num_ref_idx_l0_default_active, + .num_ref_idx_l1_default_active = pps->num_ref_idx_l1_default_active, + .init_qp = pps->pic_init_qp_minus26 + 26 + (sps->bit_depth - 8) * 6, + .constrained_intra_pred_flag = pps->constrained_intra_pred_flag, + .transform_skip_enabled_flag = pps->transform_skip_enabled_flag, + .cu_qp_delta_enabled_flag = pps->cu_qp_delta_enabled_flag, + .diff_cu_qp_delta_depth = pps->diff_cu_qp_delta_depth, + + .pps_cb_qp_offset = pps->cb_qp_offset, + .pps_cr_qp_offset = pps->cr_qp_offset, + .pps_beta_offset = pps->beta_offset, + .pps_tc_offset = pps->tc_offset, + .pps_slice_chroma_qp_offsets_present_flag = pps->pic_slice_level_chroma_qp_offsets_present_flag, + .weighted_pred_flag = pps->weighted_pred_flag, + .weighted_bipred_flag = pps->weighted_bipred_flag, + .transquant_bypass_enabled_flag = pps->transquant_bypass_enable_flag, + .tiles_enabled_flag = pps->tiles_enabled_flag, + .entropy_coding_sync_enabled_flag = pps->entropy_coding_sync_enabled_flag, + .num_tile_columns = pps->tiles_enabled_flag ? pps->num_tile_columns : 0, + .num_tile_rows = pps->tiles_enabled_flag ? pps->num_tile_rows : 0, + .loop_filter_across_tiles_enabled_flag = pps->tiles_enabled_flag ? pps->loop_filter_across_tiles_enabled_flag : 0, + .loop_filter_across_slices_enabled_flag = pps->seq_loop_filter_across_slices_enabled_flag, + .deblocking_filter_control_present_flag = pps->deblocking_filter_control_present_flag, + .deblocking_filter_override_enabled_flag = pps->deblocking_filter_override_enabled_flag, + .pps_deblocking_filter_disabled_flag = pps->disable_dbf, + .lists_modification_present_flag = pps->lists_modification_present_flag, + .log2_parallel_merge_level = pps->log2_parallel_merge_level, + .slice_segment_header_extension_present_flag = pps->slice_header_extension_present_flag, + + .num_ref_frames = ff_hevc_frame_nb_refs(sh, pps, s->cur_layer), + + .IDR_picture_flag = IS_IDR(s), + .RAP_picture_flag = IS_IRAP(s), + .pattern_id = ((output_mode == 0) || (output_mode == 1)) ? 2 : ctx->pattern_id, /* Disable/enable dithering */ + .sw_hdr_skip_length = sh->nvidia_skip_length, + + /* + * Ignored in official code + .separate_colour_plane_flag = sps->separate_colour_plane_flag, + .log2_max_pic_order_cnt_lsb_minus4 = sps->log2_max_poc_lsb - 4, + .num_short_term_ref_pic_sets = sps->nb_st_rps, + .num_long_term_ref_pics_sps = sps->num_long_term_ref_pics_sps, + .num_delta_pocs_of_rps_idx = s->sh.short_term_rps ? s->sh.short_term_rps->rps_idx_num_delta_pocs : 0, + .long_term_ref_pics_present_flag = sps->long_term_ref_pics_present_flag, + .num_bits_short_term_ref_pics_in_slice = sh->short_term_ref_pic_set_size; + */ + }; + + /* + * Decoded frames need to be allocated an index that represents its position + * in the data pointers array (pushed to the cmdbuf) and in the metadata + * sent to the hardware. + * This index must remain fixed until the frame is dropped from the DPB. + */ + + /* Build ordered reflist from the DPB */ + for (i = 0; i < FF_ARRAY_ELEMS(l->DPB); ++i) { + fr = &l->DPB[i]; + fr_priv = fr->hwaccel_picture_private; + + if ((fr->flags & (HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF)) && + (fr != s->cur_frame) && fr_priv->initialized) + { + ctx->refs[fr_priv->dpb_idx] = fr; + ctx->refs_mask |= 1 << fr_priv->dpb_idx; + } + } + + /* Try to find a valid reference, or use the current one */ + ctx->scratch_ref = s->cur_frame, scratch_ref_diff_poc = 0; + for (i = 0; i < FF_ARRAY_ELEMS(ctx->refs); ++i) { + fr = ctx->refs[i]; + if (!(ctx->refs_mask & (1 << i)) || (fr == s->cur_frame)) + continue; + + st = find_ref_rps_type(s, fr); + if ((st != ST_CURR_BEF) && (st != ST_CURR_AFT) && (st != LT_CURR)) + continue; + + ctx->scratch_ref = fr; + scratch_ref_diff_poc = av_clip_int8(s->cur_frame->poc - fr->poc); + break; + } + + /* Add the current frame to our ref list */ + setup->curr_pic_idx = cur_frame = find_slot(&ctx->refs_mask); + ctx->refs[cur_frame] = s->cur_frame; + + fr_priv = s->cur_frame->hwaccel_picture_private; + *fr_priv = (NVTegraHEVCFrameData){ + .dpb_idx = cur_frame, + .initialized = true, + }; + + /* Fill the POC metadata */ + for (i = 0; i < FF_ARRAY_ELEMS(setup->RefDiffPicOrderCnts); ++i) { + if (i == cur_frame) + continue; + + if (ctx->refs_mask & (1 << i)) { + fr = ctx->refs[i]; + setup->RefDiffPicOrderCnts[i] = av_clip_int8(s->cur_frame->poc - fr->poc); + setup->longtermflag |= !!(fr->flags & HEVC_FRAME_FLAG_LONG_REF) << (15 - i); + } else { + setup->RefDiffPicOrderCnts[i] = scratch_ref_diff_poc; + } + } + +#define RPS_TO_DPB_IDX(set, array) ({ \ + for (i = 0; i < s->rps[set].nb_refs; ++i) { \ + for (j = 0; j < FF_ARRAY_ELEMS(ctx->refs); ++j) { \ + if (s->rps[set].ref[i] == ctx->refs[j]) { \ + array[i] = j; \ + break; \ + } \ + } \ + } \ +}) + + RPS_TO_DPB_IDX(ST_CURR_BEF, rps_stcurrbef); + RPS_TO_DPB_IDX(ST_CURR_AFT, rps_stcurraft); + RPS_TO_DPB_IDX(LT_CURR, rps_ltcurr); + +#define FILL_REFLIST(list, set, array) ({ \ + int len = FFMIN(s->rps[set].nb_refs, 16 - i); \ + memcpy(&setup->list[i], array, len); \ + i += len; \ +}) + + /* Fill the RPS metadata */ + if (s->rps[ST_CURR_BEF].nb_refs + s->rps[ST_CURR_AFT].nb_refs + s->rps[LT_CURR].nb_refs) { + for (i = 0; i < 16;) { + FILL_REFLIST(initreflistidxl0, ST_CURR_BEF, rps_stcurrbef); + FILL_REFLIST(initreflistidxl0, ST_CURR_AFT, rps_stcurraft); + FILL_REFLIST(initreflistidxl0, LT_CURR, rps_ltcurr); + } + + for (i = 0; i < 16;) { + FILL_REFLIST(initreflistidxl1, ST_CURR_AFT, rps_stcurraft); + FILL_REFLIST(initreflistidxl1, ST_CURR_BEF, rps_stcurrbef); + FILL_REFLIST(initreflistidxl1, LT_CURR, rps_ltcurr); + } + } + + ctx->pattern_id ^= 1; + + if (sps->scaling_list_enabled) + nvtegra_hevc_set_scaling_list((nvdec_hevc_scaling_list_s *)(mem + ctx->scaling_list_off), s); + + tile_sizes = (uint16_t *)(mem + ctx->tile_sizes_off); + if (pps->tiles_enabled_flag) { + nvtegra_hevc_set_tile_sizes(tile_sizes, s); + } else { + tile_sizes[0] = pps->column_width[0]; + tile_sizes[1] = pps->row_height [0]; + } +} + +static int nvtegra_hevc_prepare_cmdbuf(AVNVTegraCmdbuf *cmdbuf, HEVCContext *s, + NVTegraHEVCDecodeContext *ctx, AVFrame *cur_frame) +{ + FrameDecodeData *fdd = (FrameDecodeData *)cur_frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + AVNVTegraMap *input_map = (AVNVTegraMap *)tf->input_map_ref->data; + + int i; + int err; + + err = av_nvtegra_cmdbuf_begin(cmdbuf, HOST1X_CLASS_NVDEC); + if (err < 0) + return err; + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_APPLICATION_ID, + AV_NVTEGRA_ENUM(NVC5B0_SET_APPLICATION_ID, ID, HEVC)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_CONTROL_PARAMS, + AV_NVTEGRA_ENUM (NVC5B0_SET_CONTROL_PARAMS, CODEC_TYPE, HEVC) | + AV_NVTEGRA_VALUE(NVC5B0_SET_CONTROL_PARAMS, ERR_CONCEAL_ON, 1) | + AV_NVTEGRA_VALUE(NVC5B0_SET_CONTROL_PARAMS, GPTIMER_ON, 1)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_PICTURE_INDEX, + AV_NVTEGRA_VALUE(NVC5B0_SET_PICTURE_INDEX, INDEX, ctx->core.frame_idx)); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_DRV_PIC_SETUP_OFFSET, + input_map, ctx->core.pic_setup_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_IN_BUF_BASE_OFFSET, + input_map, ctx->core.bitstream_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_NVDEC_STATUS_OFFSET, + input_map, ctx->core.status_off, NVHOST_RELOC_TYPE_DEFAULT); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_HEVC_SET_SCALING_LIST_OFFSET, + input_map, ctx->scaling_list_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_HEVC_SET_TILE_SIZES_OFFSET, + input_map, ctx->tile_sizes_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_HEVC_SET_FILTER_BUFFER_OFFSET, + &ctx->common_map, ctx->filter_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_COLOC_DATA_OFFSET, + &ctx->common_map, ctx->coloc_off, NVHOST_RELOC_TYPE_DEFAULT); + +#define PUSH_FRAME(fr, offset) ({ \ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PICTURE_LUMA_OFFSET0 + offset * 4, \ + av_nvtegra_frame_get_fbuf_map(fr), 0, NVHOST_RELOC_TYPE_DEFAULT); \ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PICTURE_CHROMA_OFFSET0 + offset * 4, \ + av_nvtegra_frame_get_fbuf_map(fr), fr->data[1] - fr->data[0], \ + NVHOST_RELOC_TYPE_DEFAULT); \ +}) + + for (i = 0; i < FF_ARRAY_ELEMS(ctx->refs); ++i) { + if (ctx->refs_mask & (1 << i)) + PUSH_FRAME(ctx->refs[i]->f, i); + else + PUSH_FRAME(ctx->scratch_ref->f, i); + } + + /* TODO: Dithered 8-bit post-processing, binding to DISPLAY_BUF */ + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_EXECUTE, + AV_NVTEGRA_ENUM(NVC5B0_EXECUTE, AWAKEN, ENABLE)); + + err = av_nvtegra_cmdbuf_end(cmdbuf); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_hevc_start_frame(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size) { + HEVCContext *s = avctx->priv_data; + AVFrame *frame = s->cur_frame->f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + NVTegraHEVCDecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + FFNVTegraDecodeFrame *tf; + AVNVTegraMap *input_map; + uint8_t *mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Starting HEVC-NVTEGRA frame with pixel format %s\n", + av_get_pix_fmt_name(avctx->sw_pix_fmt)); + + err = ff_nvtegra_start_frame(avctx, frame, &ctx->core); + if (err < 0) + return err; + + memset(ctx->refs, 0, sizeof(ctx->refs)); + ctx->refs_mask = 0; + + tf = fdd->hwaccel_priv; + input_map = (AVNVTegraMap *)tf->input_map_ref->data; + mem = av_nvtegra_map_get_addr(input_map); + + nvtegra_hevc_prepare_frame_setup((nvdec_hevc_pic_s *)(mem + ctx->core.pic_setup_off), + avctx, frame, ctx); + + return 0; +} + +static int nvtegra_hevc_end_frame(AVCodecContext *avctx) { + HEVCContext *s = avctx->priv_data; + NVTegraHEVCDecodeContext *ctx = avctx->internal->hwaccel_priv_data; + AVFrame *frame = s->cur_frame->f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + + nvdec_hevc_pic_s *setup; + uint8_t *mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Ending HEVC-NVTEGRA frame with %u slices -> %u bytes\n", + ctx->core.num_slices, ctx->core.bitstream_len); + + if (!tf || !ctx->core.num_slices) + return 0; + + mem = av_nvtegra_map_get_addr((AVNVTegraMap *)tf->input_map_ref->data); + + setup = (nvdec_hevc_pic_s *)(mem + ctx->core.pic_setup_off); + setup->stream_len = ctx->core.bitstream_len; + + err = nvtegra_hevc_prepare_cmdbuf(&ctx->core.cmdbuf, s, ctx, frame); + if (err < 0) + return err; + + return ff_nvtegra_end_frame(avctx, frame, &ctx->core, NULL, 0); +} + +static int nvtegra_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *buf, + uint32_t buf_size) +{ + HEVCContext *s = avctx->priv_data; + AVFrame *frame = s->cur_frame->f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + AVNVTegraMap *input_map = (AVNVTegraMap *)tf->input_map_ref->data; + NVTegraHEVCDecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + uint8_t *mem; + + mem = av_nvtegra_map_get_addr(input_map); + + /* + * Official code adds a 4-byte 00000001 startcode, + * though decoding was observed to work without it + */ + AV_WB8(mem + ctx->core.bitstream_off + ctx->core.bitstream_len, 0); + ctx->core.bitstream_len += 1; + + return ff_nvtegra_decode_slice(avctx, frame, buf, buf_size, AV_RB24(buf) != 1); +} + +#if CONFIG_HEVC_NVTEGRA_HWACCEL +const FFHWAccel ff_hevc_nvtegra_hwaccel = { + .p.name = "hevc_nvtegra", + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_HEVC, + .p.pix_fmt = AV_PIX_FMT_NVTEGRA, + .start_frame = &nvtegra_hevc_start_frame, + .end_frame = &nvtegra_hevc_end_frame, + .decode_slice = &nvtegra_hevc_decode_slice, + .init = &nvtegra_hevc_decode_init, + .uninit = &nvtegra_hevc_decode_uninit, + .frame_params = &ff_nvtegra_frame_params, + .frame_priv_data_size = sizeof(NVTegraHEVCFrameData), + .priv_data_size = sizeof(NVTegraHEVCDecodeContext), + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; +#endif diff --git a/libavcodec/nvtegra_mjpeg.c b/libavcodec/nvtegra_mjpeg.c new file mode 100644 index 0000000000..9139116159 --- /dev/null +++ b/libavcodec/nvtegra_mjpeg.c @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config_components.h" + +#include "avcodec.h" +#include "hwaccel_internal.h" +#include "internal.h" +#include "hwconfig.h" +#include "mjpegdec.h" +#include "decode.h" +#include "nvtegra_decode.h" + +#include "libavutil/pixdesc.h" +#include "libavutil/nvtegra_host1x.h" + +typedef struct NVTegraMJPEGDecodeContext { + FFNVTegraDecodeContext core; +} NVTegraMJPEGDecodeContext; + +static int nvtegra_mjpeg_decode_uninit(AVCodecContext *avctx) { + NVTegraMJPEGDecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + int err; + + av_log(avctx, AV_LOG_DEBUG, "Deinitializing NVTEGRA MJPEG decoder\n"); + + err = ff_nvtegra_decode_uninit(avctx, &ctx->core); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_mjpeg_decode_init(AVCodecContext *avctx) { + MJpegDecodeContext *s = avctx->priv_data; + NVTegraMJPEGDecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + + enum AVPixelFormat fmt; + int luma, err; + + av_log(avctx, AV_LOG_DEBUG, "Initializing NVTEGRA MJPEG decoder\n"); + + /* Reject encodes with known hardware issues */ + if (avctx->profile != AV_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT) { + av_log(avctx, AV_LOG_ERROR, "Non-baseline encoded jpegs are not supported by NVJPG\n"); + return AVERROR(EINVAL); + } + + fmt = s->avctx->pix_fmt, luma = s->comp_index[0]; + if ((fmt == AV_PIX_FMT_YUV444P || fmt == AV_PIX_FMT_YUVJ444P) + && (s->h_count[luma] != 1 || s->v_count[luma] != 1)) { + av_log(avctx, AV_LOG_ERROR, "Subsampled YUV444 is not supported by NVJPG\n"); + return AVERROR(EINVAL); + } + + ctx->core.pic_setup_off = 0; + ctx->core.status_off = FFALIGN(ctx->core.pic_setup_off + sizeof(nvjpg_dec_drv_pic_setup_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.cmdbuf_off = FFALIGN(ctx->core.status_off + sizeof(nvjpg_dec_status), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.bitstream_off = FFALIGN(ctx->core.cmdbuf_off + AV_NVTEGRA_MAP_ALIGN, + AV_NVTEGRA_MAP_ALIGN); + ctx->core.input_map_size = FFALIGN(ctx->core.bitstream_off + ff_nvtegra_decode_pick_bitstream_buffer_size(avctx), + 0x1000); + + ctx->core.max_cmdbuf_size = ctx->core.slice_offsets_off - ctx->core.cmdbuf_off; + ctx->core.max_bitstream_size = ctx->core.input_map_size - ctx->core.bitstream_off; + + ctx->core.is_nvjpg = true; + + err = ff_nvtegra_decode_init(avctx, &ctx->core); + if (err < 0) + goto fail; + + return 0; + +fail: + nvtegra_mjpeg_decode_uninit(avctx); + return err; +} + +static void nvtegra_mjpeg_prepare_frame_setup(nvjpg_dec_drv_pic_setup_s *setup, MJpegDecodeContext *s, + NVTegraMJPEGDecodeContext *ctx) +{ + int input_chroma_mode, output_chroma_mode, memory_mode; + int i, j; + + switch (s->hwaccel_sw_pix_fmt) { + case AV_PIX_FMT_GRAY8: + input_chroma_mode = 0; /* Monochrome */ + output_chroma_mode = 0; /* Monochrome */ + memory_mode = 3; /* YUV420, for some reason decoding fails with NV12 */ + break; + default: + case AV_PIX_FMT_YUV420P: + case AV_PIX_FMT_YUVJ420P: + input_chroma_mode = 1; /* YUV420 */ + output_chroma_mode = 1; /* YUV420 */ + memory_mode = 0; /* NV12 */ + break; + case AV_PIX_FMT_YUV422P: + case AV_PIX_FMT_YUVJ422P: + input_chroma_mode = 2; /* YUV422H (not sure what nvidia means by that) */ + output_chroma_mode = 1; /* YUV420 */ + memory_mode = 0; /* NV12 */ + break; + case AV_PIX_FMT_YUV440P: + case AV_PIX_FMT_YUVJ440P: + input_chroma_mode = 3; /* YUV422V (ditto) */ + output_chroma_mode = 1; /* YUV420 */ + memory_mode = 0; /* NV12 */ + break; + case AV_PIX_FMT_YUV444P: + case AV_PIX_FMT_YUVJ444P: + input_chroma_mode = 4; /* YUV444 */ + output_chroma_mode = 1; /* YUV420 */ + memory_mode = 0; /* NV12 */ + break; + } + + *setup = (nvjpg_dec_drv_pic_setup_s){ + .restart_interval = s->restart_interval, + .frame_width = s->width, + .frame_height = s->height, + .mcu_width = s->mb_width, + .mcu_height = s->mb_height, + .comp = s->nb_components, + + .stream_chroma_mode = input_chroma_mode, + .output_chroma_mode = output_chroma_mode, + .output_pixel_format = 0, /* YUV */ + .output_stride_luma = s->picture->linesize[0], + .output_stride_chroma = s->picture->linesize[1], + + .tile_mode = 0, /* Pitch linear (tiled formats are unsupported by the T210) */ + .memory_mode = memory_mode, + .power2_downscale = 0, + .motion_jpeg_type = 0, /* Type A */ + + .start_mcu_x = 0, + .start_mcu_y = 0, + }; + + for (i = 0; i < 4; ++i) { + for (j = 0; j < 16; ++j) { + setup->huffTab[0][i].codeNum[j] = s->raw_huffman_lengths[0][i][j]; + setup->huffTab[1][i].codeNum[j] = s->raw_huffman_lengths[1][i][j]; + } + + memcpy(setup->huffTab[0][i].symbol, s->raw_huffman_values[0][i], sizeof(setup->huffTab[0][i].symbol)); + memcpy(setup->huffTab[1][i].symbol, s->raw_huffman_values[1][i], sizeof(setup->huffTab[1][i].symbol)); + } + + for (i = 0; i < s->nb_components; ++i) { + j = s->comp_index[i]; + setup->blkPar[j].ac = s->ac_index [i]; + setup->blkPar[j].dc = s->dc_index [i]; + setup->blkPar[j].hblock = s->h_count [i]; + setup->blkPar[j].vblock = s->v_count [i]; + setup->blkPar[j].quant = s->quant_index[i]; + } + + for (i = 0; i < 4; ++i) { + for (j = 0; j < 64; ++j) + setup->quant[i][j] = s->quant_matrixes[i][j]; + } +} + +static int nvtegra_mjpeg_prepare_cmdbuf(AVNVTegraCmdbuf *cmdbuf, MJpegDecodeContext *s, + NVTegraMJPEGDecodeContext *ctx, AVFrame *current_frame) +{ + FrameDecodeData *fdd = (FrameDecodeData *)current_frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + AVNVTegraMap *input_map = (AVNVTegraMap *)tf->input_map_ref->data; + + int err; + + err = av_nvtegra_cmdbuf_begin(cmdbuf, HOST1X_CLASS_NVJPG); + if (err < 0) + return err; + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVE7D0_SET_APPLICATION_ID, + AV_NVTEGRA_ENUM(NVE7D0_SET_APPLICATION_ID, ID, NVJPG_DECODER)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVE7D0_SET_CONTROL_PARAMS, + AV_NVTEGRA_VALUE(NVE7D0_SET_CONTROL_PARAMS, DUMP_CYCLE_COUNT, 1) | + AV_NVTEGRA_VALUE(NVE7D0_SET_CONTROL_PARAMS, GPTIMER_ON, 1)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVE7D0_SET_PICTURE_INDEX, + AV_NVTEGRA_VALUE(NVE7D0_SET_PICTURE_INDEX, INDEX, ctx->core.frame_idx)); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVE7D0_SET_IN_DRV_PIC_SETUP, + input_map, ctx->core.pic_setup_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVE7D0_SET_BITSTREAM, + input_map, ctx->core.bitstream_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVE7D0_SET_OUT_STATUS, + input_map, ctx->core.status_off, NVHOST_RELOC_TYPE_DEFAULT); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVE7D0_SET_CUR_PIC, av_nvtegra_frame_get_fbuf_map(current_frame), + 0, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVE7D0_SET_CUR_PIC_CHROMA_U, av_nvtegra_frame_get_fbuf_map(current_frame), + current_frame->data[1] - current_frame->data[0], NVHOST_RELOC_TYPE_DEFAULT); + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVE7D0_EXECUTE, + AV_NVTEGRA_ENUM(NVE7D0_EXECUTE, AWAKEN, ENABLE)); + + err = av_nvtegra_cmdbuf_end(cmdbuf); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_mjpeg_start_frame(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size) { + MJpegDecodeContext *s = avctx->priv_data; + AVFrame *frame = s->picture; + NVTegraMJPEGDecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + int err; + + av_log(avctx, AV_LOG_DEBUG, "Starting MJPEG-NVTEGRA frame with pixel format %s\n", + av_get_pix_fmt_name(avctx->sw_pix_fmt)); + + err = ff_nvtegra_start_frame(avctx, frame, &ctx->core); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_mjpeg_end_frame(AVCodecContext *avctx) { + MJpegDecodeContext *s = avctx->priv_data; + NVTegraMJPEGDecodeContext *ctx = avctx->internal->hwaccel_priv_data; + AVFrame *frame = s->picture; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + + nvjpg_dec_drv_pic_setup_s *setup; + uint8_t *mem; + AVNVTegraMap *output_map; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Ending MJPEG-NVTEGRA frame with %u slices -> %u bytes\n", + ctx->core.num_slices, ctx->core.bitstream_len); + + if (!tf || !ctx->core.num_slices) + return 0; + + mem = av_nvtegra_map_get_addr((AVNVTegraMap *)tf->input_map_ref->data); + + setup = (nvjpg_dec_drv_pic_setup_s *)(mem + ctx->core.pic_setup_off); + setup->bitstream_offset = 0; + setup->bitstream_size = ctx->core.bitstream_len; + + err = nvtegra_mjpeg_prepare_cmdbuf(&ctx->core.cmdbuf, s, ctx, frame); + if (err < 0) + return err; + + output_map = av_nvtegra_frame_get_fbuf_map(frame); + output_map->is_linear = true; + + return ff_nvtegra_end_frame(avctx, frame, &ctx->core, NULL, 0); +} + +static int nvtegra_mjpeg_decode_slice(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size) { + MJpegDecodeContext *s = avctx->priv_data; + NVTegraMJPEGDecodeContext *ctx = avctx->internal->hwaccel_priv_data; + AVFrame *frame = s->picture; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + + FFNVTegraDecodeFrame *tf; + AVNVTegraMap *input_map; + uint8_t *mem; + + tf = fdd->hwaccel_priv; + input_map = (AVNVTegraMap *)tf->input_map_ref->data; + mem = av_nvtegra_map_get_addr(input_map); + + /* In nvtegra_mjpeg_start_frame the JFIF headers haven't been entirely parsed yet */ + nvtegra_mjpeg_prepare_frame_setup((nvjpg_dec_drv_pic_setup_s *)(mem + ctx->core.pic_setup_off), s, ctx); + + return ff_nvtegra_decode_slice(avctx, frame, buf, buf_size, false); +} + +static int nvtegra_mjpeg_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx) { + AVHWFramesContext *frames_ctx = (AVHWFramesContext *)hw_frames_ctx->data; + + int err; + + err = ff_nvtegra_frame_params(avctx, hw_frames_ctx); + if (err < 0) + return err; + + /* + * NVJPG1 can only decode to pitch linear surfaces, which have a + * 256b alignment requirement in VIC. + */ + frames_ctx->width = FFALIGN(frames_ctx->width, 256); + frames_ctx->height = FFALIGN(frames_ctx->height, 4); + + return 0; +} + +#if CONFIG_MJPEG_NVTEGRA_HWACCEL +const FFHWAccel ff_mjpeg_nvtegra_hwaccel = { + .p.name = "mjpeg_nvtegra", + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_MJPEG, + .p.pix_fmt = AV_PIX_FMT_NVTEGRA, + .start_frame = &nvtegra_mjpeg_start_frame, + .end_frame = &nvtegra_mjpeg_end_frame, + .decode_slice = &nvtegra_mjpeg_decode_slice, + .init = &nvtegra_mjpeg_decode_init, + .uninit = &nvtegra_mjpeg_decode_uninit, + .frame_params = &nvtegra_mjpeg_frame_params, + .priv_data_size = sizeof(NVTegraMJPEGDecodeContext), + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; +#endif diff --git a/libavcodec/nvtegra_mpeg12.c b/libavcodec/nvtegra_mpeg12.c new file mode 100644 index 0000000000..f5419ec0e7 --- /dev/null +++ b/libavcodec/nvtegra_mpeg12.c @@ -0,0 +1,319 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config_components.h" + +#include + +#include "avcodec.h" +#include "hwaccel_internal.h" +#include "internal.h" +#include "hwconfig.h" +#include "mpegvideo.h" +#include "mpegutils.h" +#include "decode.h" +#include "nvtegra_decode.h" + +#include "libavutil/pixdesc.h" +#include "libavutil/nvtegra_host1x.h" + +typedef struct NVTegraMPEG12DecodeContext { + FFNVTegraDecodeContext core; + + AVFrame *prev_frame, *next_frame; +} NVTegraMPEG12DecodeContext; + +/* Size (width, height) of a macroblock */ +#define MB_SIZE 16 + +static const uint8_t bitstream_end_sequence[16] = { + 0x00, 0x00, 0x01, 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb7, 0x00, 0x00, 0x00, 0x00, +}; + +static int nvtegra_mpeg12_decode_uninit(AVCodecContext *avctx) { + NVTegraMPEG12DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + int err; + + av_log(avctx, AV_LOG_DEBUG, "Deinitializing NVTEGRA MPEG12 decoder\n"); + + err = ff_nvtegra_decode_uninit(avctx, &ctx->core); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_mpeg12_decode_init(AVCodecContext *avctx) { + NVTegraMPEG12DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + uint32_t num_slices; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Initializing NVTEGRA MPEG12 decoder\n"); + + num_slices = (FFALIGN(avctx->coded_width, MB_SIZE) / MB_SIZE) * + (FFALIGN(avctx->coded_height, MB_SIZE) / MB_SIZE); + num_slices = FFMIN(num_slices, 8160); + + /* Ignored: histogram map, size 0x400 */ + ctx->core.pic_setup_off = 0; + ctx->core.status_off = FFALIGN(ctx->core.pic_setup_off + sizeof(nvdec_mpeg2_pic_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.cmdbuf_off = FFALIGN(ctx->core.status_off + sizeof(nvdec_status_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.slice_offsets_off = FFALIGN(ctx->core.cmdbuf_off + AV_NVTEGRA_MAP_ALIGN, + AV_NVTEGRA_MAP_ALIGN); + ctx->core.bitstream_off = FFALIGN(ctx->core.slice_offsets_off + num_slices * sizeof(uint32_t), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.input_map_size = FFALIGN(ctx->core.bitstream_off + ff_nvtegra_decode_pick_bitstream_buffer_size(avctx), + 0x1000); + + ctx->core.max_cmdbuf_size = ctx->core.slice_offsets_off - ctx->core.cmdbuf_off; + ctx->core.max_num_slices = (ctx->core.bitstream_off - ctx->core.slice_offsets_off) / sizeof(uint32_t); + ctx->core.max_bitstream_size = ctx->core.input_map_size - ctx->core.bitstream_off; + + err = ff_nvtegra_decode_init(avctx, &ctx->core); + if (err < 0) + goto fail; + + return 0; + +fail: + nvtegra_mpeg12_decode_uninit(avctx); + return err; +} + +static void nvtegra_mpeg12_prepare_frame_setup(nvdec_mpeg2_pic_s *setup, MpegEncContext *s, + NVTegraMPEG12DecodeContext *ctx) +{ + *setup = (nvdec_mpeg2_pic_s){ + .gptimer_timeout_value = 0, /* Default value */ + + .FrameWidth = FFALIGN(s->width, MB_SIZE), + .FrameHeight = FFALIGN(s->height, MB_SIZE), + + .picture_structure = s->picture_structure, + .picture_coding_type = s->pict_type, + .intra_dc_precision = s->intra_dc_precision, + .frame_pred_frame_dct = s->frame_pred_frame_dct, + .concealment_motion_vectors = s->concealment_motion_vectors, + .intra_vlc_format = s->intra_vlc_format, + + .tileFormat = 0, /* TBL */ + .gob_height = 0, /* GOB_2 */ + + .f_code = { + s->mpeg_f_code[0][0], s->mpeg_f_code[0][1], + s->mpeg_f_code[1][0], s->mpeg_f_code[1][1], + }, + + .PicWidthInMbs = FFALIGN(s->width, MB_SIZE) / MB_SIZE, + .FrameHeightInMbs = FFALIGN(s->height, MB_SIZE) / MB_SIZE, + .pitch_luma = s->cur_pic.ptr->f->linesize[0], + .pitch_chroma = s->cur_pic.ptr->f->linesize[1], + .luma_top_offset = 0, + .luma_bot_offset = 0, + .luma_frame_offset = 0, + .chroma_top_offset = 0, + .chroma_bot_offset = 0, + .chroma_frame_offset = 0, + .alternate_scan = s->alternate_scan, + .secondfield = s->picture_structure != PICT_FRAME && !s->first_field, + .rounding_type = 0, + .q_scale_type = s->q_scale_type, + .top_field_first = s->top_field_first, + .full_pel_fwd_vector = (s->codec_id != AV_CODEC_ID_MPEG2VIDEO) ? s->full_pel[0] : 0, + .full_pel_bwd_vector = (s->codec_id != AV_CODEC_ID_MPEG2VIDEO) ? s->full_pel[1] : 0, + .output_memory_layout = 0, /* NV12 */ + .ref_memory_layout = { 0, 0 }, /* NV12 */ + }; + + for (int i = 0; i < FF_ARRAY_ELEMS(setup->quant_mat_8x8intra); ++i) { + setup->quant_mat_8x8intra [i] = (NvU8)s->intra_matrix[i]; + setup->quant_mat_8x8nonintra[i] = (NvU8)s->inter_matrix[i]; + } +} + +static int nvtegra_mpeg12_prepare_cmdbuf(AVNVTegraCmdbuf *cmdbuf, MpegEncContext *s, NVTegraMPEG12DecodeContext *ctx, + AVFrame *current_frame, AVFrame *prev_frame, AVFrame *next_frame) +{ + FrameDecodeData *fdd = (FrameDecodeData *)current_frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + AVNVTegraMap *input_map = (AVNVTegraMap *)tf->input_map_ref->data; + + int err, codec_id; + + err = av_nvtegra_cmdbuf_begin(cmdbuf, HOST1X_CLASS_NVDEC); + if (err < 0) + return err; + + switch (s->codec_id) { + case AV_CODEC_ID_MPEG1VIDEO: + codec_id = NVC5B0_SET_CONTROL_PARAMS_CODEC_TYPE_MPEG1; + break; + case AV_CODEC_ID_MPEG2VIDEO: + codec_id = NVC5B0_SET_CONTROL_PARAMS_CODEC_TYPE_MPEG2; + break; + default: + return AVERROR(EINVAL); + } + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_APPLICATION_ID, + AV_NVTEGRA_ENUM(NVC5B0_SET_APPLICATION_ID, ID, MPEG12)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_CONTROL_PARAMS, codec_id | + AV_NVTEGRA_VALUE(NVC5B0_SET_CONTROL_PARAMS, ERR_CONCEAL_ON, 1) | + AV_NVTEGRA_VALUE(NVC5B0_SET_CONTROL_PARAMS, GPTIMER_ON, 1)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_PICTURE_INDEX, + AV_NVTEGRA_VALUE(NVC5B0_SET_PICTURE_INDEX, INDEX, ctx->core.frame_idx)); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_DRV_PIC_SETUP_OFFSET, + input_map, ctx->core.pic_setup_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_IN_BUF_BASE_OFFSET, + input_map, ctx->core.bitstream_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_SLICE_OFFSETS_BUF_OFFSET, + input_map, ctx->core.slice_offsets_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_NVDEC_STATUS_OFFSET, + input_map, ctx->core.status_off, NVHOST_RELOC_TYPE_DEFAULT); + +#define PUSH_FRAME(fr, offset) ({ \ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PICTURE_LUMA_OFFSET0 + offset * 4, \ + av_nvtegra_frame_get_fbuf_map(fr), 0, NVHOST_RELOC_TYPE_DEFAULT); \ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PICTURE_CHROMA_OFFSET0 + offset * 4, \ + av_nvtegra_frame_get_fbuf_map(fr), fr->data[1] - fr->data[0], \ + NVHOST_RELOC_TYPE_DEFAULT); \ +}) + + PUSH_FRAME(current_frame, 0); + PUSH_FRAME(prev_frame, 1); + PUSH_FRAME(next_frame, 2); + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_EXECUTE, + AV_NVTEGRA_ENUM(NVC5B0_EXECUTE, AWAKEN, ENABLE)); + + err = av_nvtegra_cmdbuf_end(cmdbuf); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_mpeg12_start_frame(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size) { + MpegEncContext *s = avctx->priv_data; + AVFrame *frame = s->cur_pic.ptr->f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + NVTegraMPEG12DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + FFNVTegraDecodeFrame *tf; + AVNVTegraMap *input_map; + uint8_t *mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Starting MPEG12-NVTEGRA frame with pixel format %s\n", + av_get_pix_fmt_name(avctx->sw_pix_fmt)); + + err = ff_nvtegra_start_frame(avctx, frame, &ctx->core); + if (err < 0) + return err; + + tf = fdd->hwaccel_priv; + input_map = (AVNVTegraMap *)tf->input_map_ref->data; + mem = av_nvtegra_map_get_addr(input_map); + + nvtegra_mpeg12_prepare_frame_setup((nvdec_mpeg2_pic_s *)(mem + ctx->core.pic_setup_off), s, ctx); + + ctx->prev_frame = (s->pict_type != AV_PICTURE_TYPE_I && s->last_pic.ptr) ? s->last_pic.ptr->f : frame; + ctx->next_frame = (s->pict_type == AV_PICTURE_TYPE_B && s->next_pic.ptr) ? s->next_pic.ptr->f : frame; + + return 0; +} + +static int nvtegra_mpeg12_end_frame(AVCodecContext *avctx) { + MpegEncContext *s = avctx->priv_data; + NVTegraMPEG12DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + AVFrame *frame = s->cur_pic.ptr->f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + + nvdec_mpeg2_pic_s *setup; + uint8_t *mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Ending MPEG12-NVTEGRA frame with %u slices -> %u bytes\n", + ctx->core.num_slices, ctx->core.bitstream_len); + + if (!tf || !ctx->core.num_slices) + return 0; + + mem = av_nvtegra_map_get_addr((AVNVTegraMap *)tf->input_map_ref->data); + + setup = (nvdec_mpeg2_pic_s *)(mem + ctx->core.pic_setup_off); + setup->stream_len = ctx->core.bitstream_len + sizeof(bitstream_end_sequence); + setup->slice_count = ctx->core.num_slices; + + err = nvtegra_mpeg12_prepare_cmdbuf(&ctx->core.cmdbuf, s, ctx, frame, + ctx->prev_frame, ctx->next_frame); + if (err < 0) + return err; + + return ff_nvtegra_end_frame(avctx, frame, &ctx->core, bitstream_end_sequence, + sizeof(bitstream_end_sequence)); +} + +static int nvtegra_mpeg12_decode_slice(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size) { + MpegEncContext *s = avctx->priv_data; + AVFrame *frame = s->cur_pic.ptr->f; + + return ff_nvtegra_decode_slice(avctx, frame, buf, buf_size, false); +} + +#if CONFIG_MPEG1_NVTEGRA_HWACCEL +const FFHWAccel ff_mpeg1_nvtegra_hwaccel = { + .p.name = "mpeg1_nvtegra", + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_MPEG1VIDEO, + .p.pix_fmt = AV_PIX_FMT_NVTEGRA, + .start_frame = &nvtegra_mpeg12_start_frame, + .end_frame = &nvtegra_mpeg12_end_frame, + .decode_slice = &nvtegra_mpeg12_decode_slice, + .init = &nvtegra_mpeg12_decode_init, + .uninit = &nvtegra_mpeg12_decode_uninit, + .frame_params = &ff_nvtegra_frame_params, + .priv_data_size = sizeof(NVTegraMPEG12DecodeContext), + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; +#endif + +#if CONFIG_MPEG2_NVTEGRA_HWACCEL +const FFHWAccel ff_mpeg2_nvtegra_hwaccel = { + .p.name = "mpeg2_nvtegra", + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_MPEG2VIDEO, + .p.pix_fmt = AV_PIX_FMT_NVTEGRA, + .start_frame = &nvtegra_mpeg12_start_frame, + .end_frame = &nvtegra_mpeg12_end_frame, + .decode_slice = &nvtegra_mpeg12_decode_slice, + .init = &nvtegra_mpeg12_decode_init, + .uninit = &nvtegra_mpeg12_decode_uninit, + .frame_params = &ff_nvtegra_frame_params, + .priv_data_size = sizeof(NVTegraMPEG12DecodeContext), + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; +#endif diff --git a/libavcodec/nvtegra_mpeg4.c b/libavcodec/nvtegra_mpeg4.c new file mode 100644 index 0000000000..bb20d02151 --- /dev/null +++ b/libavcodec/nvtegra_mpeg4.c @@ -0,0 +1,346 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config_components.h" + +#include + +#include "avcodec.h" +#include "hwaccel_internal.h" +#include "internal.h" +#include "hwconfig.h" +#include "mpeg4video.h" +#include "mpeg4videodec.h" +#include "mpeg4videodefs.h" +#include "decode.h" +#include "nvtegra_decode.h" + +#include "libavutil/pixdesc.h" +#include "libavutil/nvtegra_host1x.h" + +typedef struct NVTegraMPEG4DecodeContext { + FFNVTegraDecodeContext core; + + AVNVTegraMap common_map; + uint32_t coloc_off, history_off, scratch_off; + uint32_t history_size, scratch_size; + + AVFrame *prev_frame, *next_frame; +} NVTegraMPEG4DecodeContext; + +/* Size (width, height) of a macroblock */ +#define MB_SIZE 16 + +static const uint8_t bitstream_end_sequence[16] = { + 0x00, 0x00, 0x01, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb1, 0x00, 0x00, 0x00, 0x00, +}; + +static int nvtegra_mpeg4_decode_uninit(AVCodecContext *avctx) { + NVTegraMPEG4DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + int err; + + av_log(avctx, AV_LOG_DEBUG, "Deinitializing NVTEGRA MPEG4 decoder\n"); + + err = av_nvtegra_map_destroy(&ctx->common_map); + if (err < 0) + return err; + + err = ff_nvtegra_decode_uninit(avctx, &ctx->core); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_mpeg4_decode_init(AVCodecContext *avctx) { + NVTegraMPEG4DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + AVHWDeviceContext *hw_device_ctx; + AVNVTegraDeviceContext *device_hwctx; + uint32_t width_in_mbs, height_in_mbs, + coloc_size, history_size, scratch_size, common_map_size; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Initializing NVTEGRA MPEG4 decoder\n"); + + /* Ignored: histogram map, size 0x400 */ + ctx->core.pic_setup_off = 0; + ctx->core.status_off = FFALIGN(ctx->core.pic_setup_off + sizeof(nvdec_mpeg4_pic_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.cmdbuf_off = FFALIGN(ctx->core.status_off + sizeof(nvdec_status_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.bitstream_off = FFALIGN(ctx->core.cmdbuf_off + AV_NVTEGRA_MAP_ALIGN, + AV_NVTEGRA_MAP_ALIGN); + ctx->core.input_map_size = FFALIGN(ctx->core.bitstream_off + ff_nvtegra_decode_pick_bitstream_buffer_size(avctx), + 0x1000); + + ctx->core.max_cmdbuf_size = ctx->core.bitstream_off - ctx->core.cmdbuf_off; + ctx->core.max_bitstream_size = ctx->core.input_map_size - ctx->core.bitstream_off; + + err = ff_nvtegra_decode_init(avctx, &ctx->core); + if (err < 0) + goto fail; + + hw_device_ctx = (AVHWDeviceContext *)ctx->core.hw_device_ref->data; + device_hwctx = hw_device_ctx->hwctx; + + width_in_mbs = FFALIGN(avctx->coded_width, MB_SIZE) / MB_SIZE; + height_in_mbs = FFALIGN(avctx->coded_height, MB_SIZE) / MB_SIZE; + coloc_size = FFALIGN(FFALIGN(height_in_mbs, 2) * (width_in_mbs * 64) - 63, 0x100); + history_size = FFALIGN(width_in_mbs * 0x100 + 0x1100, 0x100); + scratch_size = 0x400; + + ctx->coloc_off = 0; + ctx->history_off = FFALIGN(ctx->coloc_off + coloc_size, AV_NVTEGRA_MAP_ALIGN); + ctx->scratch_off = FFALIGN(ctx->history_off + history_size, AV_NVTEGRA_MAP_ALIGN); + common_map_size = FFALIGN(ctx->scratch_off + scratch_size, 0x1000); + + err = av_nvtegra_map_create(&ctx->common_map, &device_hwctx->nvdec_channel, common_map_size, 0x100, + NVMAP_HEAP_IOVMM, NVMAP_HANDLE_WRITE_COMBINE); + if (err < 0) + goto fail; + + ctx->history_size = history_size; + ctx->scratch_size = scratch_size; + + return 0; + +fail: + nvtegra_mpeg4_decode_uninit(avctx); + return err; +} + +static void nvtegra_mpeg4_prepare_frame_setup(nvdec_mpeg4_pic_s *setup, AVCodecContext *avctx, + NVTegraMPEG4DecodeContext *ctx) +{ + Mpeg4DecContext *m = avctx->priv_data; + MpegEncContext *s = &m->m; + + int i; + + *setup = (nvdec_mpeg4_pic_s){ + .scratch_pic_buffer_size = ctx->scratch_size, + + .gptimer_timeout_value = 0, /* Default value */ + + .FrameWidth = FFALIGN(s->width, MB_SIZE), + .FrameHeight = FFALIGN(s->height, MB_SIZE), + + .vop_time_increment_bitcount = m->time_increment_bits, + .resync_marker_disable = !m->resync_marker, + + .tileFormat = 0, /* TBL */ + .gob_height = 0, /* GOB_2 */ + + .width = FFALIGN(s->width, MB_SIZE), + .height = FFALIGN(s->height, MB_SIZE), + + .FrameStride = { + s->cur_pic.ptr->f->linesize[0], + s->cur_pic.ptr->f->linesize[1], + }, + + .luma_top_offset = 0, + .luma_bot_offset = 0, + .luma_frame_offset = 0, + .chroma_top_offset = 0, + .chroma_bot_offset = 0, + .chroma_frame_offset = 0, + + .HistBufferSize = ctx->history_size / 256, + + .trd = { s->pp_time, s->pp_field_time >> 1 }, + .trb = { s->pb_time, s->pb_field_time >> 1 }, + + .vop_fcode_forward = s->f_code, + .vop_fcode_backward = s->b_code, + + .interlaced = s->interlaced_dct, + .quant_type = s->mpeg_quant, + .quarter_sample = s->quarter_sample, + .short_video_header = avctx->codec->id == AV_CODEC_ID_H263, + + .curr_output_memory_layout = 0, /* NV12 */ + + .ptype = s->pict_type - AV_PICTURE_TYPE_I, + .rnd = s->no_rounding, + .alternate_vertical_scan_flag = s->alternate_scan, + + .ref_memory_layout = { 0, 0 }, /* NV12 */ + }; + + for (i = 0; i < 64; ++i) { + setup->intra_quant_mat [i] = s->intra_matrix[i]; + setup->nonintra_quant_mat[i] = s->inter_matrix[i]; + } +} + +static int nvtegra_mpeg4_prepare_cmdbuf(AVNVTegraCmdbuf *cmdbuf, MpegEncContext *s, NVTegraMPEG4DecodeContext *ctx, + AVFrame *cur_frame, AVFrame *prev_frame, AVFrame *next_frame) +{ + FrameDecodeData *fdd = (FrameDecodeData *)cur_frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + AVNVTegraMap *input_map = (AVNVTegraMap *)tf->input_map_ref->data; + + int err; + + err = av_nvtegra_cmdbuf_begin(cmdbuf, HOST1X_CLASS_NVDEC); + if (err < 0) + return err; + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_APPLICATION_ID, + AV_NVTEGRA_ENUM(NVC5B0_SET_APPLICATION_ID, ID, MPEG4)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_CONTROL_PARAMS, + AV_NVTEGRA_ENUM (NVC5B0_SET_CONTROL_PARAMS, CODEC_TYPE, MPEG4) | + AV_NVTEGRA_VALUE(NVC5B0_SET_CONTROL_PARAMS, ERR_CONCEAL_ON, 1) | + AV_NVTEGRA_VALUE(NVC5B0_SET_CONTROL_PARAMS, GPTIMER_ON, 1)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_PICTURE_INDEX, + AV_NVTEGRA_VALUE(NVC5B0_SET_PICTURE_INDEX, INDEX, ctx->core.frame_idx)); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_DRV_PIC_SETUP_OFFSET, + input_map, ctx->core.pic_setup_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_IN_BUF_BASE_OFFSET, + input_map, ctx->core.bitstream_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_NVDEC_STATUS_OFFSET, + input_map, ctx->core.status_off, NVHOST_RELOC_TYPE_DEFAULT); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_COLOC_DATA_OFFSET, + &ctx->common_map, ctx->coloc_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_HISTORY_OFFSET, + &ctx->common_map, ctx->history_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PIC_SCRATCH_BUF_OFFSET, + &ctx->common_map, ctx->scratch_off, NVHOST_RELOC_TYPE_DEFAULT); + +#define PUSH_FRAME(fr, offset) ({ \ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PICTURE_LUMA_OFFSET0 + offset * 4, \ + av_nvtegra_frame_get_fbuf_map(fr), 0, NVHOST_RELOC_TYPE_DEFAULT); \ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PICTURE_CHROMA_OFFSET0 + offset * 4, \ + av_nvtegra_frame_get_fbuf_map(fr), fr->data[1] - fr->data[0], \ + NVHOST_RELOC_TYPE_DEFAULT); \ +}) + + PUSH_FRAME(cur_frame, 0); + PUSH_FRAME(prev_frame, 1); + PUSH_FRAME(next_frame, 2); + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_EXECUTE, + AV_NVTEGRA_ENUM(NVC5B0_EXECUTE, AWAKEN, ENABLE)); + + err = av_nvtegra_cmdbuf_end(cmdbuf); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_mpeg4_start_frame(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size) { + Mpeg4DecContext *m = avctx->priv_data; + MpegEncContext *s = &m->m; + AVFrame *frame = s->cur_pic.ptr->f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + NVTegraMPEG4DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + FFNVTegraDecodeFrame *tf; + AVNVTegraMap *input_map; + uint8_t *mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Starting MPEG4-NVTEGRA frame with pixel format %s\n", + av_get_pix_fmt_name(avctx->sw_pix_fmt)); + + err = ff_nvtegra_start_frame(avctx, frame, &ctx->core); + if (err < 0) + return err; + + tf = fdd->hwaccel_priv; + input_map = (AVNVTegraMap *)tf->input_map_ref->data; + mem = av_nvtegra_map_get_addr(input_map); + + nvtegra_mpeg4_prepare_frame_setup((nvdec_mpeg4_pic_s *)(mem + ctx->core.pic_setup_off), avctx, ctx); + + ctx->prev_frame = (s->pict_type != AV_PICTURE_TYPE_I && s->last_pic.ptr) ? s->last_pic.ptr->f : frame; + ctx->next_frame = (s->pict_type == AV_PICTURE_TYPE_B && s->next_pic.ptr) ? s->next_pic.ptr->f : frame; + + return 0; +} + +static int nvtegra_mpeg4_end_frame(AVCodecContext *avctx) { + Mpeg4DecContext *m = avctx->priv_data; + MpegEncContext *s = &m->m; + NVTegraMPEG4DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + AVFrame *frame = s->cur_pic.ptr->f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + + nvdec_mpeg4_pic_s *setup; + uint8_t *mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Ending MPEG4-NVTEGRA frame with %u slices -> %u bytes\n", + ctx->core.num_slices, ctx->core.bitstream_len); + + if (!tf || !ctx->core.num_slices) + return 0; + + mem = av_nvtegra_map_get_addr((AVNVTegraMap *)tf->input_map_ref->data); + + setup = (nvdec_mpeg4_pic_s *)(mem + ctx->core.pic_setup_off); + setup->stream_len = ctx->core.bitstream_len + sizeof(bitstream_end_sequence); + setup->slice_count = ctx->core.num_slices; + + err = nvtegra_mpeg4_prepare_cmdbuf(&ctx->core.cmdbuf, s, ctx, frame, + ctx->prev_frame, ctx->next_frame); + if (err < 0) + return err; + + return ff_nvtegra_end_frame(avctx, frame, &ctx->core, bitstream_end_sequence, + sizeof(bitstream_end_sequence)); +} + +static int nvtegra_mpeg4_decode_slice(AVCodecContext *avctx, const uint8_t *buf, + uint32_t buf_size) +{ + Mpeg4DecContext *m = avctx->priv_data; + AVFrame *frame = m->m.cur_pic.ptr->f; + + /* Rewind the bitstream looking for the VOP start marker */ + while (*(uint32_t *)buf != AV_BE2NE32C(VOP_STARTCODE)) + buf -= 1, buf_size += 1; + + return ff_nvtegra_decode_slice(avctx, frame, buf, buf_size, false); +} + +#if CONFIG_MPEG4_NVTEGRA_HWACCEL +const FFHWAccel ff_mpeg4_nvtegra_hwaccel = { + .p.name = "mpeg4_nvtegra", + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_MPEG4, + .p.pix_fmt = AV_PIX_FMT_NVTEGRA, + .start_frame = &nvtegra_mpeg4_start_frame, + .end_frame = &nvtegra_mpeg4_end_frame, + .decode_slice = &nvtegra_mpeg4_decode_slice, + .init = &nvtegra_mpeg4_decode_init, + .uninit = &nvtegra_mpeg4_decode_uninit, + .frame_params = &ff_nvtegra_frame_params, + .priv_data_size = sizeof(NVTegraMPEG4DecodeContext), + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; +#endif diff --git a/libavcodec/nvtegra_vc1.c b/libavcodec/nvtegra_vc1.c new file mode 100644 index 0000000000..7b79b05d60 --- /dev/null +++ b/libavcodec/nvtegra_vc1.c @@ -0,0 +1,455 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config_components.h" + +#include + +#include "avcodec.h" +#include "hwaccel_internal.h" +#include "internal.h" +#include "hwconfig.h" +#include "vc1.h" +#include "decode.h" +#include "nvtegra_decode.h" + +#include "libavutil/pixdesc.h" +#include "libavutil/nvtegra_host1x.h" + +typedef struct NVTegraVC1DecodeContext { + FFNVTegraDecodeContext core; + + AVNVTegraMap common_map; + uint32_t coloc_off, history_off, scratch_off; + uint32_t history_size, scratch_size; + + bool is_first_slice; + + AVFrame *prev_frame, *next_frame; +} NVTegraVC1DecodeContext; + +/* Size (width, height) of a macroblock */ +#define MB_SIZE 16 + +static const uint8_t bitstream_end_sequence[] = { + 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x00, +}; + +static int nvtegra_vc1_decode_uninit(AVCodecContext *avctx) { + NVTegraVC1DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + int err; + + av_log(avctx, AV_LOG_DEBUG, "Deinitializing NVTEGRA VC1 decoder\n"); + + err = av_nvtegra_map_destroy(&ctx->common_map); + if (err < 0) + return err; + + err = ff_nvtegra_decode_uninit(avctx, &ctx->core); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_vc1_decode_init(AVCodecContext *avctx) { + NVTegraVC1DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + AVHWDeviceContext *hw_device_ctx; + AVNVTegraDeviceContext *device_hwctx; + uint32_t width_in_mbs, height_in_mbs, num_slices, + coloc_size, history_size, scratch_size, common_map_size; + uint8_t *mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Initializing NVTEGRA VC1 decoder\n"); + + width_in_mbs = FFALIGN(avctx->coded_width, MB_SIZE) / MB_SIZE; + height_in_mbs = FFALIGN(avctx->coded_height, MB_SIZE) / MB_SIZE; + + num_slices = width_in_mbs * height_in_mbs; + + /* Ignored: histogram map, size 0x400 */ + ctx->core.pic_setup_off = 0; + ctx->core.status_off = FFALIGN(ctx->core.pic_setup_off + sizeof(nvdec_vc1_pic_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.cmdbuf_off = FFALIGN(ctx->core.status_off + sizeof(nvdec_status_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.slice_offsets_off = FFALIGN(ctx->core.cmdbuf_off + AV_NVTEGRA_MAP_ALIGN, + AV_NVTEGRA_MAP_ALIGN); + ctx->core.bitstream_off = FFALIGN(ctx->core.slice_offsets_off + num_slices * sizeof(uint32_t), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.input_map_size = FFALIGN(ctx->core.bitstream_off + ff_nvtegra_decode_pick_bitstream_buffer_size(avctx), + 0x1000); + + ctx->core.max_cmdbuf_size = ctx->core.slice_offsets_off - ctx->core.cmdbuf_off; + ctx->core.max_num_slices = (ctx->core.bitstream_off - ctx->core.slice_offsets_off) / sizeof(uint32_t); + ctx->core.max_bitstream_size = ctx->core.input_map_size - ctx->core.bitstream_off; + + err = ff_nvtegra_decode_init(avctx, &ctx->core); + if (err < 0) + goto fail; + + hw_device_ctx = (AVHWDeviceContext *)ctx->core.hw_device_ref->data; + device_hwctx = hw_device_ctx->hwctx; + + coloc_size = 3 * FFALIGN(width_in_mbs * FFALIGN(height_in_mbs, 2) * 64 - 63, AV_NVTEGRA_MAP_ALIGN); + history_size = FFALIGN(width_in_mbs, 2) * 0x300; + scratch_size = 0x400; + + ctx->coloc_off = 0; + ctx->history_off = FFALIGN(ctx->coloc_off + coloc_size, AV_NVTEGRA_MAP_ALIGN); + ctx->scratch_off = FFALIGN(ctx->history_off + history_size, AV_NVTEGRA_MAP_ALIGN); + common_map_size = FFALIGN(ctx->scratch_off + scratch_size, 0x1000); + + err = av_nvtegra_map_create(&ctx->common_map, &device_hwctx->nvdec_channel, common_map_size, 0x100, + NVMAP_HEAP_IOVMM, NVMAP_HANDLE_WRITE_COMBINE); + if (err < 0) + goto fail; + + mem = av_nvtegra_map_get_addr(&ctx->common_map); + + memset(mem + ctx->coloc_off, 0, coloc_size); + memset(mem + ctx->history_off, 0, history_size); + memset(mem + ctx->scratch_off, 0, scratch_size); + + ctx->history_size = history_size; + ctx->scratch_size = scratch_size; + + return 0; + +fail: + nvtegra_vc1_decode_uninit(avctx); + return err; +} + +static void nvtegra_vc1_prepare_frame_setup(nvdec_vc1_pic_s *setup, AVCodecContext *avctx, + NVTegraVC1DecodeContext *ctx) +{ + VC1Context *v = avctx->priv_data; + MpegEncContext *s = &v->s; + AVFrame *frame = s->cur_pic.ptr->f; + + /* + * Notes: + * - s->current_picture.f->linesize is unconsistently doubled for interlaced content + * between I-frames and others, so s->current_pic_ptr is used + * - a lot of fields in this structure are unused by official software, + * here we only set those + */ + *setup = (nvdec_vc1_pic_s){ + .scratch_pic_buffer_size = ctx->scratch_size, + + .gptimer_timeout_value = 0, /* Default value */ + + .bitstream_offset = 0, + + .FrameStride = { + frame->linesize[0], + frame->linesize[1], + }, + + .luma_top_offset = 0, + .luma_bot_offset = 0, + .luma_frame_offset = 0, + .chroma_top_offset = 0, + .chroma_bot_offset = 0, + .chroma_frame_offset = 0, + + .CodedWidth = FFALIGN(avctx->coded_width, + (v->profile == PROFILE_ADVANCED) ? 1 : MB_SIZE), + .CodedHeight = FFALIGN(avctx->coded_height, + (v->profile == PROFILE_ADVANCED) ? 1 : MB_SIZE), + + .HistBufferSize = ctx->history_size / 256, + + .loopfilter = s->loop_filter, + + .output_memory_layout = 0, /* NV12 */ + .ref_memory_layout = { + 0, 0, /* NV12 */ + }, + + .fastuvmc = v->fastuvmc, + + .FrameWidth = FFALIGN(frame->width, + (v->profile == PROFILE_ADVANCED) ? 1 : MB_SIZE), + .FrameHeight = FFALIGN(frame->height, + (v->profile == PROFILE_ADVANCED) ? 1 : MB_SIZE), + + .profile = (v->profile != PROFILE_ADVANCED) ? 1 : 2, + + .postprocflag = v->postprocflag, + .pulldown = v->broadcast, + .interlace = v->interlace, + + .tfcntrflag = v->tfcntrflag, + .finterpflag = v->finterpflag, + + .tileFormat = 0, /* TBL */ + + .psf = v->psf, + + .multires = v->multires, + .syncmarker = v->resync_marker, + .rangered = v->rangered, + .maxbframes = s->max_b_frames, + .panscan_flag = v->panscanflag, + .dquant = v->dquant, + .refdist_flag = v->refdist_flag, + .quantizer = v->quantizer_mode, + .overlap = v->overlap, + .vstransform = v->vstransform, + .extended_mv = v->extended_mv, + .extended_dmv = v->extended_dmv, + }; + + if (v->profile == PROFILE_ADVANCED) { + setup->displayPara.enableTFOutput = 1; + setup->displayPara.VC1MapYFlag = v->range_mapy_flag; + setup->displayPara.MapYValue = v->range_mapy; + setup->displayPara.VC1MapUVFlag = v->range_mapuv_flag; + setup->displayPara.MapUVValue = v->range_mapuv; + } else if (v->rangered && v->rangeredfrm) { + setup->displayPara.enableTFOutput = 1; + setup->displayPara.VC1MapYFlag = 1; + setup->displayPara.MapYValue = 7; + setup->displayPara.VC1MapUVFlag = 1; + setup->displayPara.MapUVValue = 7; + } + + if (v->range_mapy_flag || v->range_mapuv_flag) { + setup->displayPara.OutputBottom[0] = 0; + setup->displayPara.OutputBottom[1] = 0; + setup->displayPara.OutputStructure = v->interlace & 1; + setup->displayPara.OutStride = frame->linesize[0] & 0xff; + } +} + +static int nvtegra_vc1_prepare_cmdbuf(AVNVTegraCmdbuf *cmdbuf, VC1Context *v, NVTegraVC1DecodeContext *ctx, + AVFrame *cur_frame, AVFrame *prev_frame, AVFrame *next_frame) +{ + FrameDecodeData *fdd = (FrameDecodeData *)cur_frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + AVNVTegraMap *input_map = (AVNVTegraMap *)tf->input_map_ref->data; + + int err; + + err = av_nvtegra_cmdbuf_begin(cmdbuf, HOST1X_CLASS_NVDEC); + if (err < 0) + return err; + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_APPLICATION_ID, + AV_NVTEGRA_ENUM(NVC5B0_SET_APPLICATION_ID, ID, VC1)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_CONTROL_PARAMS, + AV_NVTEGRA_ENUM (NVC5B0_SET_CONTROL_PARAMS, CODEC_TYPE, VC1) | + AV_NVTEGRA_VALUE(NVC5B0_SET_CONTROL_PARAMS, ERR_CONCEAL_ON, 1) | + AV_NVTEGRA_VALUE(NVC5B0_SET_CONTROL_PARAMS, GPTIMER_ON, 1)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_PICTURE_INDEX, + AV_NVTEGRA_VALUE(NVC5B0_SET_PICTURE_INDEX, INDEX, ctx->core.frame_idx)); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_DRV_PIC_SETUP_OFFSET, + input_map, ctx->core.pic_setup_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_IN_BUF_BASE_OFFSET, + input_map, ctx->core.bitstream_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_SLICE_OFFSETS_BUF_OFFSET, + input_map, ctx->core.slice_offsets_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_NVDEC_STATUS_OFFSET, + input_map, ctx->core.status_off, NVHOST_RELOC_TYPE_DEFAULT); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_COLOC_DATA_OFFSET, + &ctx->common_map, ctx->coloc_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_HISTORY_OFFSET, + &ctx->common_map, ctx->history_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PIC_SCRATCH_BUF_OFFSET, + &ctx->common_map, ctx->scratch_off, NVHOST_RELOC_TYPE_DEFAULT); + +#define PUSH_FRAME(fr, offset) ({ \ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PICTURE_LUMA_OFFSET0 + offset * 4, \ + av_nvtegra_frame_get_fbuf_map(fr), 0, NVHOST_RELOC_TYPE_DEFAULT); \ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PICTURE_CHROMA_OFFSET0 + offset * 4, \ + av_nvtegra_frame_get_fbuf_map(fr), fr->data[1] - fr->data[0], \ + NVHOST_RELOC_TYPE_DEFAULT); \ +}) + + PUSH_FRAME(cur_frame, 0); + PUSH_FRAME(prev_frame, 1); + PUSH_FRAME(next_frame, 2); + + /* + * TODO: Bind a surface to the postproc output if we need range remapping + if (((v->profile != PROFILE_ADVANCED) && ((v->rangered != 0) || (v->rangeredfrm != 0))) || + ((v->range_mapy_flag != 0) || (v->range_mapuv_flag != 0))) { + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_DISPLAY_BUF_LUMA_OFFSET, + &output.luma, 0, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_DISPLAY_BUF_CHROMA_OFFSET, + &output.chroma, 0, NVHOST_RELOC_TYPE_DEFAULT); + } + */ + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_EXECUTE, + AV_NVTEGRA_ENUM(NVC5B0_EXECUTE, AWAKEN, ENABLE)); + + err = av_nvtegra_cmdbuf_end(cmdbuf); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size) { + VC1Context *v = avctx->priv_data; + MpegEncContext *s = &v->s; + AVFrame *frame = s->cur_pic.ptr->f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + NVTegraVC1DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + FFNVTegraDecodeFrame *tf; + AVNVTegraMap *input_map; + uint8_t *mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Starting VC1-NVTEGRA frame with pixel format %s\n", + av_get_pix_fmt_name(avctx->sw_pix_fmt)); + + ctx->is_first_slice = true; + + err = ff_nvtegra_start_frame(avctx, frame, &ctx->core); + if (err < 0) + return err; + + tf = fdd->hwaccel_priv; + input_map = (AVNVTegraMap *)tf->input_map_ref->data; + mem = av_nvtegra_map_get_addr(input_map); + + nvtegra_vc1_prepare_frame_setup((nvdec_vc1_pic_s *)(mem + ctx->core.pic_setup_off), avctx, ctx); + + ctx->prev_frame = ff_nvtegra_safe_get_ref(s->last_pic.ptr ? s->last_pic.ptr->f : frame, frame); + ctx->next_frame = ff_nvtegra_safe_get_ref(s->next_pic.ptr ? s->next_pic.ptr->f : frame, frame); + + return 0; +} + +static int nvtegra_vc1_end_frame(AVCodecContext *avctx) { + VC1Context *v = avctx->priv_data; + NVTegraVC1DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + AVFrame *frame = v->s.cur_pic.ptr->f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + + nvdec_vc1_pic_s *setup; + uint8_t *mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Ending VC1-NVTEGRA frame with %u slices -> %u bytes\n", + ctx->core.num_slices, ctx->core.bitstream_len); + + if (!tf || !ctx->core.num_slices) + return 0; + + mem = av_nvtegra_map_get_addr((AVNVTegraMap *)tf->input_map_ref->data); + + setup = (nvdec_vc1_pic_s *)(mem + ctx->core.pic_setup_off); + setup->stream_len = ctx->core.bitstream_len + sizeof(bitstream_end_sequence); + setup->slice_count = ctx->core.num_slices; + + err = nvtegra_vc1_prepare_cmdbuf(&ctx->core.cmdbuf, v, ctx, frame, + ctx->prev_frame, ctx->next_frame); + if (err < 0) + return err; + + return ff_nvtegra_end_frame(avctx, frame, &ctx->core, bitstream_end_sequence, + sizeof(bitstream_end_sequence)); +} + +static int nvtegra_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buf, + uint32_t buf_size) +{ + VC1Context *v = avctx->priv_data; + NVTegraVC1DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + AVFrame *frame = v->s.cur_pic.ptr->f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + AVNVTegraMap *input_map = (AVNVTegraMap *)tf->input_map_ref->data; + + nvdec_vc1_pic_s *setup; + uint8_t *mem; + enum VC1Code startcode; + + mem = av_nvtegra_map_get_addr(input_map); + + setup = (nvdec_vc1_pic_s *)(mem + ctx->core.pic_setup_off); + + if (ctx->is_first_slice) { + startcode = VC1_CODE_FRAME; + + if (v->profile == PROFILE_ADVANCED && + v->fcm == ILACE_FIELD && v->second_field) + startcode = VC1_CODE_FIELD; + + /* + * Skip a dword if the bitstream already contains the startcode + * We could probably just not insert our startcode but this is what official code does + */ + if ((buf_size >= 4) && (AV_RB32(buf) == startcode)) + setup->bitstream_offset = 1; + + AV_WB32(mem + ctx->core.bitstream_off + ctx->core.bitstream_len, startcode); + ctx->core.bitstream_len += 4; + ctx->is_first_slice = false; + } + + return ff_nvtegra_decode_slice(avctx, frame, buf, buf_size, false); +} + +#if CONFIG_VC1_NVTEGRA_HWACCEL +const FFHWAccel ff_vc1_nvtegra_hwaccel = { + .p.name = "vc1_nvtegra", + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_VC1, + .p.pix_fmt = AV_PIX_FMT_NVTEGRA, + .start_frame = &nvtegra_vc1_start_frame, + .end_frame = &nvtegra_vc1_end_frame, + .decode_slice = &nvtegra_vc1_decode_slice, + .init = &nvtegra_vc1_decode_init, + .uninit = &nvtegra_vc1_decode_uninit, + .frame_params = &ff_nvtegra_frame_params, + .priv_data_size = sizeof(NVTegraVC1DecodeContext), + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; +#endif + +#if CONFIG_WMV3_NVTEGRA_HWACCEL +const FFHWAccel ff_wmv3_nvtegra_hwaccel = { + .p.name = "wmv3_nvtegra", + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_WMV3, + .p.pix_fmt = AV_PIX_FMT_NVTEGRA, + .start_frame = &nvtegra_vc1_start_frame, + .end_frame = &nvtegra_vc1_end_frame, + .decode_slice = &nvtegra_vc1_decode_slice, + .init = &nvtegra_vc1_decode_init, + .uninit = &nvtegra_vc1_decode_uninit, + .frame_params = &ff_nvtegra_frame_params, + .priv_data_size = sizeof(NVTegraVC1DecodeContext), + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; +#endif diff --git a/libavcodec/nvtegra_vp8.c b/libavcodec/nvtegra_vp8.c new file mode 100644 index 0000000000..d6061616da --- /dev/null +++ b/libavcodec/nvtegra_vp8.c @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config_components.h" + +#include + +#include "avcodec.h" +#include "hwaccel_internal.h" +#include "internal.h" +#include "hwconfig.h" +#include "vp8.h" +#include "vp8data.h" +#include "decode.h" +#include "nvtegra_decode.h" + +#include "libavutil/pixdesc.h" +#include "libavutil/nvtegra_host1x.h" + +typedef struct NVTegraVP8DecodeContext { + FFNVTegraDecodeContext core; + + AVNVTegraMap common_map; + uint32_t prob_data_off, history_off; + uint32_t history_size; + + AVFrame *golden_frame, *altref_frame, + *previous_frame; +} NVTegraVP8DecodeContext; + +/* Size (width, height) of a macroblock */ +#define MB_SIZE 16 + +static int nvtegra_vp8_decode_uninit(AVCodecContext *avctx) { + NVTegraVP8DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + int err; + + av_log(avctx, AV_LOG_DEBUG, "Deinitializing NVTEGRA VP8 decoder\n"); + + err = av_nvtegra_map_destroy(&ctx->common_map); + if (err < 0) + return err; + + err = ff_nvtegra_decode_uninit(avctx, &ctx->core); + if (err < 0) + return err; + + return 0; +} + +static void nvtegra_vp8_init_probs(void *p) { + int i, j, k; + uint8_t *ptr = p; + + memset(p, 0, 0x4cc); + + for (i = 0; i < 4; ++i) { + for (j = 0; j < 8; ++j) { + for (k = 0; k < 3; ++k) { + memcpy(ptr, vp8_token_default_probs[i][j][k], NUM_DCT_TOKENS - 1); + ptr += NUM_DCT_TOKENS; + } + } + } + + memcpy(ptr, vp8_pred16x16_prob_inter, sizeof(vp8_pred16x16_prob_inter)); + ptr += 4; + + memcpy(ptr, vp8_pred8x8c_prob_inter, sizeof(vp8_pred8x8c_prob_inter)); + ptr += 4; + + for (i = 0; i < 2; ++i) { + memcpy(ptr, vp8_mv_default_prob[i], 19); + ptr += 20; + } +} + +static int nvtegra_vp8_decode_init(AVCodecContext *avctx) { + NVTegraVP8DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + AVHWDeviceContext *hw_device_ctx; + AVNVTegraDeviceContext *device_hwctx; + uint32_t width_in_mbs, common_map_size; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Initializing NVTEGRA VP8 decoder\n"); + + /* Ignored: histogram map, size 0x400 */ + ctx->core.pic_setup_off = 0; + ctx->core.status_off = FFALIGN(ctx->core.pic_setup_off + sizeof(nvdec_vp8_pic_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.cmdbuf_off = FFALIGN(ctx->core.status_off + sizeof(nvdec_status_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.bitstream_off = FFALIGN(ctx->core.cmdbuf_off + AV_NVTEGRA_MAP_ALIGN, + AV_NVTEGRA_MAP_ALIGN); + ctx->core.input_map_size = FFALIGN(ctx->core.bitstream_off + ff_nvtegra_decode_pick_bitstream_buffer_size(avctx), + 0x1000); + + ctx->core.max_cmdbuf_size = ctx->core.bitstream_off - ctx->core.cmdbuf_off; + ctx->core.max_bitstream_size = ctx->core.input_map_size - ctx->core.bitstream_off; + + err = ff_nvtegra_decode_init(avctx, &ctx->core); + if (err < 0) + goto fail; + + hw_device_ctx = (AVHWDeviceContext *)ctx->core.hw_device_ref->data; + device_hwctx = hw_device_ctx->hwctx; + + width_in_mbs = FFALIGN(avctx->coded_width, MB_SIZE) / MB_SIZE; + ctx->history_size = width_in_mbs * 0x200; + + ctx->prob_data_off = 0; + ctx->history_off = FFALIGN(ctx->prob_data_off + 0x4b00, AV_NVTEGRA_MAP_ALIGN); + common_map_size = FFALIGN(ctx->history_off + ctx->history_size, 0x1000); + + err = av_nvtegra_map_create(&ctx->common_map, &device_hwctx->nvdec_channel, common_map_size, 0x100, + NVMAP_HEAP_IOVMM, NVMAP_HANDLE_WRITE_COMBINE); + if (err < 0) + goto fail; + + nvtegra_vp8_init_probs((uint8_t *)av_nvtegra_map_get_addr(&ctx->common_map) + ctx->prob_data_off); + + return 0; + +fail: + nvtegra_vp8_decode_uninit(avctx); + return err; +} + +static void nvtegra_vp8_prepare_frame_setup(nvdec_vp8_pic_s *setup, VP8Context *h, + NVTegraVP8DecodeContext *ctx) +{ + *setup = (nvdec_vp8_pic_s){ + .gptimer_timeout_value = 0, /* Default value */ + + .FrameWidth = FFALIGN(h->framep[VP8_FRAME_CURRENT]->tf.f->width, MB_SIZE), + .FrameHeight = FFALIGN(h->framep[VP8_FRAME_CURRENT]->tf.f->height, MB_SIZE), + + .keyFrame = h->keyframe, + .version = h->profile, + + .tileFormat = 0, /* TBL */ + .gob_height = 0, /* GOB_2 */ + + .errorConcealOn = 1, + + .firstPartSize = h->header_partition_size, + + .HistBufferSize = ctx->history_size / 256, + + .FrameStride = { + h->framep[VP8_FRAME_CURRENT]->tf.f->linesize[0] / MB_SIZE, + h->framep[VP8_FRAME_CURRENT]->tf.f->linesize[1] / MB_SIZE, + }, + + .luma_top_offset = 0, + .luma_bot_offset = 0, + .luma_frame_offset = 0, + .chroma_top_offset = 0, + .chroma_bot_offset = 0, + .chroma_frame_offset = 0, + + .current_output_memory_layout = 0, /* NV12 */ + .output_memory_layout = { 0, 0, 0 }, /* NV12 */ + + /* ???: Official code sets this value at 0x8d (reserved1[0]), so just set both */ + .segmentation_feature_data_update = h->segmentation.enabled ? h->segmentation.update_feature_data : 0, + .reserved1[0] = h->segmentation.enabled ? h->segmentation.update_feature_data : 0, + + .resultValue = 0, + }; +} + +static int nvtegra_vp8_prepare_cmdbuf(AVNVTegraCmdbuf *cmdbuf, VP8Context *h, + NVTegraVP8DecodeContext *ctx, AVFrame *cur_frame) +{ + FrameDecodeData *fdd = (FrameDecodeData *)cur_frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + AVNVTegraMap *input_map = (AVNVTegraMap *)tf->input_map_ref->data; + + int err; + + err = av_nvtegra_cmdbuf_begin(cmdbuf, HOST1X_CLASS_NVDEC); + if (err < 0) + return err; + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_APPLICATION_ID, + AV_NVTEGRA_ENUM(NVC5B0_SET_APPLICATION_ID, ID, VP8)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_CONTROL_PARAMS, + AV_NVTEGRA_ENUM(NVC5B0_SET_CONTROL_PARAMS, CODEC_TYPE, VP8) | + AV_NVTEGRA_VALUE(NVC5B0_SET_CONTROL_PARAMS, ERR_CONCEAL_ON, 1) | + AV_NVTEGRA_VALUE(NVC5B0_SET_CONTROL_PARAMS, GPTIMER_ON, 1)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_PICTURE_INDEX, + AV_NVTEGRA_VALUE(NVC5B0_SET_PICTURE_INDEX, INDEX, ctx->core.frame_idx)); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_DRV_PIC_SETUP_OFFSET, + input_map, ctx->core.pic_setup_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_IN_BUF_BASE_OFFSET, + input_map, ctx->core.bitstream_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_NVDEC_STATUS_OFFSET, + input_map, ctx->core.status_off, NVHOST_RELOC_TYPE_DEFAULT); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_VP8_SET_PROB_DATA_OFFSET, + &ctx->common_map, ctx->prob_data_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_HISTORY_OFFSET, + &ctx->common_map, ctx->history_off, NVHOST_RELOC_TYPE_DEFAULT); + +#define PUSH_FRAME(fr, offset) ({ \ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PICTURE_LUMA_OFFSET0 + offset * 4, \ + av_nvtegra_frame_get_fbuf_map(fr), 0, NVHOST_RELOC_TYPE_DEFAULT); \ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PICTURE_CHROMA_OFFSET0 + offset * 4, \ + av_nvtegra_frame_get_fbuf_map(fr), fr->data[1] - fr->data[0], \ + NVHOST_RELOC_TYPE_DEFAULT); \ +}) + + PUSH_FRAME(ctx->golden_frame, 0); + PUSH_FRAME(ctx->altref_frame, 1); + PUSH_FRAME(ctx->previous_frame, 2); + PUSH_FRAME(cur_frame, 3); + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_EXECUTE, + AV_NVTEGRA_ENUM(NVC5B0_EXECUTE, AWAKEN, ENABLE)); + + err = av_nvtegra_cmdbuf_end(cmdbuf); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_vp8_start_frame(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size) { + VP8Context *h = avctx->priv_data; + AVFrame *frame = h->framep[VP8_FRAME_CURRENT]->tf.f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + NVTegraVP8DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + FFNVTegraDecodeFrame *tf; + AVNVTegraMap *input_map; + uint8_t *mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Starting VP8-NVTEGRA frame with pixel format %s\n", + av_get_pix_fmt_name(avctx->sw_pix_fmt)); + + err = ff_nvtegra_start_frame(avctx, frame, &ctx->core); + if (err < 0) + return err; + + tf = fdd->hwaccel_priv; + input_map = (AVNVTegraMap *)tf->input_map_ref->data; + mem = av_nvtegra_map_get_addr(input_map); + + nvtegra_vp8_prepare_frame_setup((nvdec_vp8_pic_s *)(mem + ctx->core.pic_setup_off), h, ctx); + +#define SAFE_REF(type) (h->framep[(type)] ?: h->framep[VP8_FRAME_CURRENT]) + ctx->golden_frame = ff_nvtegra_safe_get_ref(SAFE_REF(VP8_FRAME_GOLDEN) ->tf.f, frame); + ctx->altref_frame = ff_nvtegra_safe_get_ref(SAFE_REF(VP8_FRAME_ALTREF) ->tf.f, frame); + ctx->previous_frame = ff_nvtegra_safe_get_ref(SAFE_REF(VP8_FRAME_PREVIOUS)->tf.f, frame); + + return 0; +} + +static int nvtegra_vp8_end_frame(AVCodecContext *avctx) { + VP8Context *h = avctx->priv_data; + NVTegraVP8DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + AVFrame *frame = h->framep[VP8_FRAME_CURRENT]->tf.f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + + nvdec_vp8_pic_s *setup; + uint8_t *mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Ending VP8-NVTEGRA frame with %u slices -> %u bytes\n", + ctx->core.num_slices, ctx->core.bitstream_len); + + if (!tf || !ctx->core.num_slices) + return 0; + + mem = av_nvtegra_map_get_addr((AVNVTegraMap *)tf->input_map_ref->data); + + setup = (nvdec_vp8_pic_s *)(mem + ctx->core.pic_setup_off); + setup->VLDBufferSize = ctx->core.bitstream_len; + + err = nvtegra_vp8_prepare_cmdbuf(&ctx->core.cmdbuf, h, ctx, frame); + if (err < 0) + return err; + + return ff_nvtegra_end_frame(avctx, frame, &ctx->core, NULL, 0); +} + +static int nvtegra_vp8_decode_slice(AVCodecContext *avctx, const uint8_t *buf, + uint32_t buf_size) +{ + VP8Context *h = avctx->priv_data; + AVFrame *frame = h->framep[VP8_FRAME_CURRENT]->tf.f; + + int offset = h->keyframe ? 10 : 3; + + return ff_nvtegra_decode_slice(avctx, frame, buf + offset, buf_size - offset, false); +} + +#if CONFIG_VP8_NVTEGRA_HWACCEL +const FFHWAccel ff_vp8_nvtegra_hwaccel = { + .p.name = "vp8_nvtegra", + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_VP8, + .p.pix_fmt = AV_PIX_FMT_NVTEGRA, + .start_frame = &nvtegra_vp8_start_frame, + .end_frame = &nvtegra_vp8_end_frame, + .decode_slice = &nvtegra_vp8_decode_slice, + .init = &nvtegra_vp8_decode_init, + .uninit = &nvtegra_vp8_decode_uninit, + .frame_params = &ff_nvtegra_frame_params, + .priv_data_size = sizeof(NVTegraVP8DecodeContext), + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; +#endif diff --git a/libavcodec/nvtegra_vp9.c b/libavcodec/nvtegra_vp9.c new file mode 100644 index 0000000000..f9544de09f --- /dev/null +++ b/libavcodec/nvtegra_vp9.c @@ -0,0 +1,665 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config_components.h" + +#include + +#include "avcodec.h" +#include "hwaccel_internal.h" +#include "internal.h" +#include "hwconfig.h" +#include "vp9data.h" +#include "vp9dec.h" +#include "decode.h" +#include "nvtegra_decode.h" + +#include "libavutil/pixdesc.h" +#include "libavutil/nvtegra_host1x.h" + +typedef struct NVTegraVP9DecodeContext { + FFNVTegraDecodeContext core; + + uint32_t prob_tab_off; + + AVNVTegraMap common_map; + uint32_t segment_rw1_off, segment_rw2_off, tile_sizes_off, filter_off, + col_mvrw1_off, col_mvrw2_off, ctx_counter_off; + + bool prev_show_frame; + + AVFrame *refs[3]; +} NVTegraVP9DecodeContext; + +/* Size (width, height) of a macroblock */ +#define MB_SIZE 16 + +/* Maximum size (width, height) of a superblock */ +#define SB_SIZE 64 + +#define CEILDIV(a, b) (((a) + (b) - 1) / (b)) + +/* Prediction modes aren't layed out in the same order in ffmpeg's defaults than in hardware */ +static const uint8_t pmconv[] = { 2, 0, 1, 3, 4, 5, 6, 8, 7, 9 }; + +static int nvtegra_vp9_decode_uninit(AVCodecContext *avctx) { + NVTegraVP9DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + int err; + + av_log(avctx, AV_LOG_DEBUG, "Deinitializing NVTEGRA VP9 decoder\n"); + + err = av_nvtegra_map_destroy(&ctx->common_map); + if (err < 0) + return err; + + err = ff_nvtegra_decode_uninit(avctx, &ctx->core); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_vp9_decode_init(AVCodecContext *avctx) { + NVTegraVP9DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + AVHWDeviceContext *hw_device_ctx; + AVNVTegraDeviceContext *device_hwctx; + uint32_t aligned_width, aligned_height, max_sb_size, + segment_rw_size, filter_size, col_mvrw_size, ctx_counter_size, + common_map_size; + uint8_t *mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Initializing NVTEGRA VP9 decoder\n"); + + ctx->core.pic_setup_off = 0; + ctx->core.status_off = FFALIGN(ctx->core.pic_setup_off + sizeof(nvdec_vp9_pic_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.cmdbuf_off = FFALIGN(ctx->core.status_off + sizeof(nvdec_status_s), + AV_NVTEGRA_MAP_ALIGN); + ctx->prob_tab_off = FFALIGN(ctx->core.cmdbuf_off + 2*AV_NVTEGRA_MAP_ALIGN, + AV_NVTEGRA_MAP_ALIGN); + ctx->core.bitstream_off = FFALIGN(ctx->prob_tab_off + sizeof(nvdec_vp9EntropyProbs_t), + AV_NVTEGRA_MAP_ALIGN); + ctx->core.input_map_size = FFALIGN(ctx->core.bitstream_off + ff_nvtegra_decode_pick_bitstream_buffer_size(avctx), + 0x1000); + + ctx->core.max_cmdbuf_size = ctx->prob_tab_off - ctx->core.cmdbuf_off; + ctx->core.max_bitstream_size = ctx->core.input_map_size - ctx->core.bitstream_off; + + err = ff_nvtegra_decode_init(avctx, &ctx->core); + if (err < 0) + goto fail; + + hw_device_ctx = (AVHWDeviceContext *)ctx->core.hw_device_ref->data; + device_hwctx = hw_device_ctx->hwctx; + + aligned_width = FFALIGN(avctx->coded_width, MB_SIZE); + aligned_height = FFALIGN(avctx->coded_height, MB_SIZE); + max_sb_size = CEILDIV(aligned_width, 64) * CEILDIV(aligned_height, 64); + segment_rw_size = FFALIGN(max_sb_size * 32, 0x100); + filter_size = FFALIGN(avctx->height, 64) * 988; + col_mvrw_size = max_sb_size * 1024; + ctx_counter_size = FFALIGN(sizeof(nvdec_vp9EntropyCounts_t), 0x100); + + ctx->segment_rw1_off = 0; + ctx->segment_rw2_off = FFALIGN(ctx->segment_rw1_off + segment_rw_size, AV_NVTEGRA_MAP_ALIGN); + ctx->tile_sizes_off = FFALIGN(ctx->segment_rw2_off + segment_rw_size, AV_NVTEGRA_MAP_ALIGN); + ctx->filter_off = FFALIGN(ctx->tile_sizes_off + 0x700, AV_NVTEGRA_MAP_ALIGN); + ctx->col_mvrw1_off = FFALIGN(ctx->filter_off + filter_size, AV_NVTEGRA_MAP_ALIGN); + ctx->col_mvrw2_off = FFALIGN(ctx->col_mvrw1_off + col_mvrw_size, AV_NVTEGRA_MAP_ALIGN); + ctx->ctx_counter_off = FFALIGN(ctx->col_mvrw2_off + col_mvrw_size, AV_NVTEGRA_MAP_ALIGN); + common_map_size = FFALIGN(ctx->ctx_counter_off + ctx_counter_size, 0x1000); + + err = av_nvtegra_map_create(&ctx->common_map, &device_hwctx->nvdec_channel, common_map_size, 0x100, + NVMAP_HEAP_IOVMM, NVMAP_HANDLE_WRITE_COMBINE); + if (err < 0) + goto fail; + + mem = av_nvtegra_map_get_addr(&ctx->common_map); + + memset(mem + ctx->segment_rw1_off, 0, segment_rw_size); + memset(mem + ctx->segment_rw2_off, 0, segment_rw_size); + + memset(mem + ctx->tile_sizes_off, 0, 0x700); + ((uint16_t *)(mem + ctx->tile_sizes_off))[0x37a] = 9; + ((uint16_t *)(mem + ctx->tile_sizes_off))[0x37b] = 1; + + memset(mem + ctx->col_mvrw1_off, 0, col_mvrw_size); + memset(mem + ctx->col_mvrw2_off, 0, col_mvrw_size); + + memset(mem + ctx->ctx_counter_off, 0, sizeof(nvdec_vp9EntropyCounts_t)); + + return 0; + +fail: + nvtegra_vp9_decode_uninit(avctx); + return err; +} + +static void nvtegra_vp9_init_probs(nvdec_vp9EntropyProbs_t *probs) { + int i, j; + + for (i = 0; i < FF_ARRAY_ELEMS(probs->kf_bmode_prob); ++i) { + for (j = 0; j < FF_ARRAY_ELEMS(probs->kf_bmode_prob[0]); ++j) { + memcpy(probs->kf_bmode_prob[i][j], ff_vp9_default_kf_ymode_probs[pmconv[i]][pmconv[j]], 8); + probs->kf_bmode_probB[i][j][0] = ff_vp9_default_kf_ymode_probs[pmconv[i]][pmconv[j]][8]; + } + memcpy(probs->kf_uv_mode_prob[i], ff_vp9_default_kf_uvmode_probs[pmconv[i]], 8); + probs->kf_uv_mode_probB[i][0] = ff_vp9_default_kf_uvmode_probs[pmconv[i]][8]; + } +} + +static void nvtegra_vp9_update_probs(nvdec_vp9EntropyProbs_t *probs, + VP9Context *s, bool init) +{ + ProbContext *p = &s->prob.p; + + int i, j, k, l; + + if (init) { + memset(probs, 0, sizeof(nvdec_vp9EntropyProbs_t)); + nvtegra_vp9_init_probs(probs); + } + + for (i = 0; i < FF_ARRAY_ELEMS(probs->ref_pred_probs); ++i) + probs->ref_pred_probs[i] = *s->intra_pred_data[i]; + + memcpy(probs->mb_segment_tree_probs, s->s.h.segmentation.prob, sizeof(probs->mb_segment_tree_probs)); + if (s->s.h.segmentation.temporal) + memcpy(probs->segment_pred_probs, s->s.h.segmentation.pred_prob, sizeof(probs->segment_pred_probs)); + else + memset(probs->segment_pred_probs, 0xff, sizeof(probs->segment_pred_probs)); + + /* Ignored by official software: ref_scores, prob_comppred */ + + for (i = 0; i < FF_ARRAY_ELEMS(probs->a.inter_mode_prob); ++i) + memcpy(probs->a.inter_mode_prob[i], p->mv_mode[i], 3); + + memcpy(probs->a.intra_inter_prob, p->intra, sizeof(probs->a.intra_inter_prob)); + + for (i = 0; i < FF_ARRAY_ELEMS(probs->a.uv_mode_prob); ++i) { + memcpy(probs->a.uv_mode_prob[i], p->uv_mode[pmconv[i]], 8); + probs->a.uv_mode_probB[i][0] = p->uv_mode[pmconv[i]][8]; + } + + for (i = 0; i < FF_ARRAY_ELEMS(probs->a.tx8x8_prob); ++i) { + memcpy(probs->a.tx8x8_prob [i], &p->tx8p [i], 1); + memcpy(probs->a.tx16x16_prob[i], p->tx16p[i], 2); + memcpy(probs->a.tx32x32_prob[i], p->tx32p[i], 3); + } + + for (i = 0; i < FF_ARRAY_ELEMS(probs->a.sb_ymode_prob); ++i) { + memcpy(probs->a.sb_ymode_prob[i], p->y_mode[i], 8); + probs->a.sb_ymode_probB[i][0] = p->y_mode[i][8]; + } + + for (i = 0; i < 4; ++i) { + for (j = 0; j < 4; ++j) { + memcpy(probs->a.partition_prob[0][4*(3-i)+j], + &ff_vp9_default_kf_partition_probs[i][j], 3); + memcpy(probs->a.partition_prob[1][4*(3-i)+j], &p->partition[i][j], 3); + } + } + + memcpy(probs->a.switchable_interp_prob, p->filter, sizeof(probs->a.switchable_interp_prob)); + memcpy(probs->a.comp_inter_prob, p->comp, sizeof(probs->a.comp_inter_prob)); + memcpy(probs->a.mbskip_probs, p->skip, sizeof(probs->a.mbskip_probs)); + + memcpy(probs->a.nmvc.joints, p->mv_joint, 3); + for (i = 0; i < FF_ARRAY_ELEMS(p->mv_comp); ++i) { + probs->a.nmvc.sign [i] = p->mv_comp[i].sign; + probs->a.nmvc.class0 [i][0] = p->mv_comp[i].class0; + probs->a.nmvc.class0_hp[i] = p->mv_comp[i].class0_hp; + probs->a.nmvc.hp [i] = p->mv_comp[i].hp; + memcpy(probs->a.nmvc.fp [i], p->mv_comp[i].fp, 3); + memcpy(probs->a.nmvc.classes [i], p->mv_comp[i].classes, 10); + memcpy(probs->a.nmvc.class0_fp[i], p->mv_comp[i].class0_fp, 2 * 3); + memcpy(probs->a.nmvc.bits [i], p->mv_comp[i].bits, 10); + } + + memcpy(probs->a.single_ref_prob, p->single_ref, sizeof(probs->a.single_ref_prob)); + memcpy(probs->a.comp_ref_prob, p->comp_ref, sizeof(probs->a.comp_ref_prob)); + + for (i = 0; i < FF_ARRAY_ELEMS(probs->a.probCoeffs); ++i) { + for (j = 0; j < FF_ARRAY_ELEMS(probs->a.probCoeffs[0]); ++j) { + for (k = 0; k < FF_ARRAY_ELEMS(probs->a.probCoeffs[0][0]); ++k) { + for (l = 0; l < FF_ARRAY_ELEMS(probs->a.probCoeffs[0][0][0]); ++l) { + memcpy(probs->a.probCoeffs [i][j][k][l], s->prob.coef[0][i][j][k][l], 3); + memcpy(probs->a.probCoeffs8x8 [i][j][k][l], s->prob.coef[1][i][j][k][l], 3); + memcpy(probs->a.probCoeffs16x16[i][j][k][l], s->prob.coef[2][i][j][k][l], 3); + memcpy(probs->a.probCoeffs32x32[i][j][k][l], s->prob.coef[3][i][j][k][l], 3); + } + } + } + } +} + +static void nvtegra_vp9_set_tile_sizes(uint16_t *sizes, VP9Context *s) { + int i, j; + + for (i = 0; i < s->s.h.tiling.tile_rows; ++i) { + for (j = 0; j < s->s.h.tiling.tile_cols; ++j) { + sizes[0] = (s->sb_cols * (j + 1) >> s->s.h.tiling.log2_tile_cols) - + (s->sb_cols * j >> s->s.h.tiling.log2_tile_cols); + sizes[1] = (s->sb_rows * (i + 1) >> s->s.h.tiling.log2_tile_rows) - + (s->sb_rows * i >> s->s.h.tiling.log2_tile_rows); + sizes += 2; + } + } +} + +static void nvtegra_vp9_update_counts(nvdec_vp9EntropyCounts_t *cts, + VP9TileData *td) +{ + int i, j, k, l; + + for (i = 0; i < FF_ARRAY_ELEMS(td->counts.y_mode); ++i) { + for (j = 0; j < FF_ARRAY_ELEMS(td->counts.y_mode[0]); ++j) { + td->counts.y_mode[i][pmconv[j]] = cts->sb_ymode_counts[i][j]; + } + } + + for (i = 0; i < FF_ARRAY_ELEMS(td->counts.uv_mode); ++i) { + for (j = 0; j < FF_ARRAY_ELEMS(td->counts.uv_mode[0]); ++j) { + td->counts.uv_mode[pmconv[i]][pmconv[j]] = cts->uv_mode_counts[i][j]; + } + } + + memcpy(td->counts.filter, cts->switchable_interp_counts, sizeof(td->counts.filter)); + memcpy(td->counts.intra, cts->intra_inter_count, sizeof(td->counts.intra)); + memcpy(td->counts.comp, cts->comp_inter_count, sizeof(td->counts.comp)); + memcpy(td->counts.single_ref, cts->single_ref_count, sizeof(td->counts.single_ref)); + memcpy(td->counts.tx32p, cts->tx32x32_count, sizeof(td->counts.tx32p)); + memcpy(td->counts.tx16p, cts->tx16x16_count, sizeof(td->counts.tx16p)); + memcpy(td->counts.tx8p, cts->tx8x8_count, sizeof(td->counts.tx8p)); + memcpy(td->counts.skip, cts->mbskip_count, sizeof(td->counts.skip)); + + for (i = 0; i < FF_ARRAY_ELEMS(td->counts.mv_mode); ++i) { + td->counts.mv_mode[i][0] = cts->inter_mode_counts[i][1][0]; + td->counts.mv_mode[i][1] = cts->inter_mode_counts[i][2][0]; + td->counts.mv_mode[i][2] = cts->inter_mode_counts[i][0][0]; + td->counts.mv_mode[i][3] = cts->inter_mode_counts[i][2][1]; + } + + memcpy(td->counts.mv_joint, cts->nmvcount.joints, sizeof(td->counts.mv_joint)); + for (i = 0; i < FF_ARRAY_ELEMS(td->counts.mv_comp); ++i) { + memcpy(td->counts.mv_comp[i].sign, cts->nmvcount.sign [i], sizeof(td->counts.mv_comp[i].sign)); + memcpy(td->counts.mv_comp[i].classes, cts->nmvcount.classes [i], sizeof(td->counts.mv_comp[i].classes)); + memcpy(td->counts.mv_comp[i].class0, cts->nmvcount.class0 [i], sizeof(td->counts.mv_comp[i].class0)); + memcpy(td->counts.mv_comp[i].bits, cts->nmvcount.bits [i], sizeof(td->counts.mv_comp[i].bits)); + memcpy(td->counts.mv_comp[i].class0_fp, cts->nmvcount.class0_fp[i], sizeof(td->counts.mv_comp[i].class0_fp)); + memcpy(td->counts.mv_comp[i].fp, cts->nmvcount.fp [i], sizeof(td->counts.mv_comp[i].fp)); + memcpy(td->counts.mv_comp[i].class0_hp, cts->nmvcount.class0_hp[i], sizeof(td->counts.mv_comp[i].class0_hp)); + memcpy(td->counts.mv_comp[i].hp, cts->nmvcount.hp [i], sizeof(td->counts.mv_comp[i].hp)); + } + + memcpy(td->counts.partition[0], cts->partition_counts[12], sizeof(td->counts.partition[0])); + memcpy(td->counts.partition[1], cts->partition_counts[ 8], sizeof(td->counts.partition[1])); + memcpy(td->counts.partition[2], cts->partition_counts[ 4], sizeof(td->counts.partition[2])); + memcpy(td->counts.partition[3], cts->partition_counts[ 0], sizeof(td->counts.partition[3])); + + for (i = 0; i < FF_ARRAY_ELEMS(td->counts.coef[0]); ++i) { + for (j = 0; j < FF_ARRAY_ELEMS(td->counts.coef[0][0]); ++j) { + for (k = 0; k < FF_ARRAY_ELEMS(td->counts.coef[0][0][0]); ++k) { + for (l = 0; l < FF_ARRAY_ELEMS(td->counts.coef[0][0][0][0]); ++l) { + memcpy(td->counts.coef[0][i][j][k][l], cts->countCoeffs [i][j][k][l], + sizeof(td->counts.coef[0][i][j][k][l])); + memcpy(td->counts.coef[1][i][j][k][l], cts->countCoeffs8x8 [i][j][k][l], + sizeof(td->counts.coef[1][i][j][k][l])); + memcpy(td->counts.coef[2][i][j][k][l], cts->countCoeffs16x16[i][j][k][l], + sizeof(td->counts.coef[2][i][j][k][l])); + memcpy(td->counts.coef[3][i][j][k][l], cts->countCoeffs32x32[i][j][k][l], + sizeof(td->counts.coef[3][i][j][k][l])); + td->counts.eob[0][i][j][k][l][0] = cts->countCoeffs [i][j][k][l][3]; + td->counts.eob[0][i][j][k][l][1] = cts->countEobs[0][i][j][k][l] - td->counts.eob[0][i][j][k][l][0]; + td->counts.eob[1][i][j][k][l][0] = cts->countCoeffs8x8 [i][j][k][l][3]; + td->counts.eob[1][i][j][k][l][1] = cts->countEobs[1][i][j][k][l] - td->counts.eob[1][i][j][k][l][0]; + td->counts.eob[2][i][j][k][l][0] = cts->countCoeffs16x16[i][j][k][l][3]; + td->counts.eob[2][i][j][k][l][1] = cts->countEobs[2][i][j][k][l] - td->counts.eob[2][i][j][k][l][0]; + td->counts.eob[3][i][j][k][l][0] = cts->countCoeffs32x32[i][j][k][l][3]; + td->counts.eob[3][i][j][k][l][1] = cts->countEobs[3][i][j][k][l] - td->counts.eob[3][i][j][k][l][0]; + } + } + } + } +} + +static void nvtegra_vp9_prepare_frame_setup(nvdec_vp9_pic_s *setup, AVCodecContext *avctx, + NVTegraVP9DecodeContext *ctx) +{ + VP9Context *s = avctx->priv_data; + VP9SharedContext *h = &s->s; + + int i; + + /* Note: the stride is divided by 2 when the depth is > 8 (not supported on T210) */ +#define FWIDTH(f) ((f && f->private_ref) ? f->width : 0) +#define FHEIGHT(f) ((f && f->private_ref) ? f->height : 0) +#define FSTRIDE(f, c) ((f && f->private_ref) ? f->linesize[c] : 0) + + /* Note: the v1 substructure isn't filled out on T210 */ + *setup = (nvdec_vp9_pic_s){ + .gptimer_timeout_value = 0, /* Default value */ + + .tileformat = 0, /* TBL */ + .gob_height = 0, /* GOB_2 */ + + .Vp9BsdCtrlOffset = FFALIGN(avctx->height, 64) * 912 / 256, + + .ref0_width = FWIDTH (h->refs[h->h.refidx[0]].f), + .ref0_height = FHEIGHT(h->refs[h->h.refidx[0]].f), + .ref0_stride = { + FSTRIDE(h->refs[h->h.refidx[0]].f, 0), + FSTRIDE(h->refs[h->h.refidx[0]].f, 1), + }, + + .ref1_width = FWIDTH (h->refs[h->h.refidx[1]].f), + .ref1_height = FHEIGHT(h->refs[h->h.refidx[1]].f), + .ref1_stride = { + FSTRIDE(h->refs[h->h.refidx[1]].f, 0), + FSTRIDE(h->refs[h->h.refidx[1]].f, 1), + }, + + .ref2_width = FWIDTH (h->refs[h->h.refidx[2]].f), + .ref2_height = FHEIGHT(h->refs[h->h.refidx[2]].f), + .ref2_stride = { + FSTRIDE(h->refs[h->h.refidx[2]].f, 0), + FSTRIDE(h->refs[h->h.refidx[2]].f, 1), + }, + + .width = FWIDTH (h->frames[CUR_FRAME].tf.f), + .height = FHEIGHT(h->frames[CUR_FRAME].tf.f), + .framestride = { + FSTRIDE(h->frames[CUR_FRAME].tf.f, 0), + FSTRIDE(h->frames[CUR_FRAME].tf.f, 1), + }, + + .keyFrame = h->h.keyframe, + .prevIsKeyFrame = s->last_keyframe, + .errorResilient = h->h.errorres, + .prevShowFrame = ctx->prev_show_frame, + .intraOnly = h->h.intraonly, + + .refFrameSignBias = { + 0, + h->h.signbias[0], h->h.signbias[1], h->h.signbias[2], + }, + + .loopFilterLevel = h->h.filter.level, + .loopFilterSharpness = h->h.filter.sharpness, + + .qpYAc = h->h.yac_qi, + .qpYDc = h->h.ydc_qdelta, + .qpChAc = h->h.uvdc_qdelta, + .qpChDc = h->h.uvac_qdelta, + + .lossless = h->h.lossless, + .transform_mode = h->h.txfmmode, + .allow_high_precision_mv = h->h.keyframe ? 0 : h->h.highprecisionmvs, + .mcomp_filter_type = h->h.filtermode, + .comp_pred_mode = h->h.comppredmode, + .comp_fixed_ref = h->h.allowcompinter ? h->h.fixcompref + 1 : 0, + .comp_var_ref = { + h->h.allowcompinter ? h->h.varcompref[0] + 1 : 0, + h->h.allowcompinter ? h->h.varcompref[1] + 1 : 0, + }, + + .log2_tile_columns = h->h.tiling.log2_tile_cols, + .log2_tile_rows = h->h.tiling.log2_tile_rows, + + .segmentEnabled = h->h.segmentation.enabled, + .segmentMapUpdate = h->h.segmentation.update_map, + .segmentMapTemporalUpdate = h->h.segmentation.temporal, + .segmentFeatureMode = h->h.segmentation.absolute_vals, + .modeRefLfEnabled = h->h.lf_delta.enabled, + .mbRefLfDelta = { + h->h.lf_delta.ref[0], h->h.lf_delta.ref[1], + h->h.lf_delta.ref[2], h->h.lf_delta.ref[3], + }, + .mbModeLfDelta = { + h->h.lf_delta.mode[0], h->h.lf_delta.mode[1], + }, + }; + + for (i = 0; i < 8; ++i) { + setup->segmentFeatureEnable[i][0] = h->h.segmentation.feat[i].q_enabled; + setup->segmentFeatureEnable[i][1] = h->h.segmentation.feat[i].lf_enabled; + setup->segmentFeatureEnable[i][2] = h->h.segmentation.feat[i].ref_enabled; + setup->segmentFeatureEnable[i][3] = h->h.segmentation.feat[i].skip_enabled; + + setup->segmentFeatureData[i][0] = h->h.segmentation.feat[i].q_val; + setup->segmentFeatureData[i][1] = h->h.segmentation.feat[i].lf_val; + setup->segmentFeatureData[i][2] = h->h.segmentation.feat[i].ref_val; + setup->segmentFeatureData[i][3] = 0; + } + + ctx->prev_show_frame = !h->h.invisible; +} + +static int nvtegra_vp9_prepare_cmdbuf(AVNVTegraCmdbuf *cmdbuf, VP9SharedContext *h, + NVTegraVP9DecodeContext *ctx, AVFrame *cur_frame) +{ + FrameDecodeData *fdd = (FrameDecodeData *)cur_frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + AVNVTegraMap *input_map = (AVNVTegraMap *)tf->input_map_ref->data; + + uint32_t col_mvwrite_off, col_mvread_off; + int err; + + if (ctx->core.frame_idx % 2 == 0) + col_mvwrite_off = ctx->col_mvrw1_off, col_mvread_off = ctx->col_mvrw2_off; + else + col_mvwrite_off = ctx->col_mvrw2_off, col_mvread_off = ctx->col_mvrw1_off; + + err = av_nvtegra_cmdbuf_begin(cmdbuf, HOST1X_CLASS_NVDEC); + if (err < 0) + return err; + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_APPLICATION_ID, + AV_NVTEGRA_ENUM(NVC5B0_SET_APPLICATION_ID, ID, VP9)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_CONTROL_PARAMS, + AV_NVTEGRA_ENUM (NVC5B0_SET_CONTROL_PARAMS, CODEC_TYPE, VP9) | + AV_NVTEGRA_VALUE(NVC5B0_SET_CONTROL_PARAMS, ERR_CONCEAL_ON, 1) | + AV_NVTEGRA_VALUE(NVC5B0_SET_CONTROL_PARAMS, GPTIMER_ON, 1)); + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_SET_PICTURE_INDEX, + AV_NVTEGRA_VALUE(NVC5B0_SET_PICTURE_INDEX, INDEX, ctx->core.frame_idx)); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_DRV_PIC_SETUP_OFFSET, + input_map, ctx->core.pic_setup_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_IN_BUF_BASE_OFFSET, + input_map, ctx->core.bitstream_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_NVDEC_STATUS_OFFSET, + input_map, ctx->core.status_off, NVHOST_RELOC_TYPE_DEFAULT); + + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_VP9_SET_PROB_TAB_BUF_OFFSET, + input_map, ctx->prob_tab_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_VP9_SET_CTX_COUNTER_BUF_OFFSET, + &ctx->common_map, ctx->ctx_counter_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_VP9_SET_TILE_SIZE_BUF_OFFSET, + &ctx->common_map, ctx->tile_sizes_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_VP9_SET_COL_MVWRITE_BUF_OFFSET, + &ctx->common_map, col_mvwrite_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_VP9_SET_COL_MVREAD_BUF_OFFSET, + &ctx->common_map, col_mvread_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_VP9_SET_SEGMENT_READ_BUF_OFFSET, + &ctx->common_map, ctx->segment_rw1_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_VP9_SET_SEGMENT_WRITE_BUF_OFFSET, + &ctx->common_map, ctx->segment_rw2_off, NVHOST_RELOC_TYPE_DEFAULT); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_VP9_SET_FILTER_BUFFER_OFFSET, + &ctx->common_map, ctx->filter_off, NVHOST_RELOC_TYPE_DEFAULT); + +#define PUSH_FRAME(fr, offset) ({ \ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PICTURE_LUMA_OFFSET0 + offset * 4, \ + av_nvtegra_frame_get_fbuf_map(fr), 0, NVHOST_RELOC_TYPE_DEFAULT); \ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVC5B0_SET_PICTURE_CHROMA_OFFSET0 + offset * 4, \ + av_nvtegra_frame_get_fbuf_map(fr), fr->data[1] - fr->data[0], \ + NVHOST_RELOC_TYPE_DEFAULT); \ +}) + + PUSH_FRAME(ctx->refs[0], 0); + PUSH_FRAME(ctx->refs[1], 1); + PUSH_FRAME(ctx->refs[2], 2); + PUSH_FRAME(cur_frame, 3); + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVC5B0_EXECUTE, + AV_NVTEGRA_ENUM(NVC5B0_EXECUTE, AWAKEN, ENABLE)); + + err = av_nvtegra_cmdbuf_end(cmdbuf); + if (err < 0) + return err; + + if (h->h.segmentation.update_map) + FFSWAP(uint32_t, ctx->segment_rw1_off, ctx->segment_rw2_off); + + return 0; +} + +static int nvtegra_vp9_start_frame(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size) { + VP9Context *s = avctx->priv_data; + VP9SharedContext *h = &s->s; + AVFrame *frame = h->frames[CUR_FRAME].tf.f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + NVTegraVP9DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + + FFNVTegraDecodeFrame *tf; + AVNVTegraMap *input_map; + uint8_t *mem, *common_mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Starting VP9-NVTEGRA frame with pixel format %s\n", + av_get_pix_fmt_name(avctx->sw_pix_fmt)); + + if (s->s.h.refreshctx && s->s.h.parallelmode) { + int i, j, k, l, m; + + for (i = 0; i < FF_ARRAY_ELEMS(s->prob_ctx[s->s.h.framectxid].coef); i++) { + for (j = 0; j < FF_ARRAY_ELEMS(s->prob_ctx[s->s.h.framectxid].coef[0]); j++) + for (k = 0; k < FF_ARRAY_ELEMS(s->prob_ctx[s->s.h.framectxid].coef[0][0]); k++) + for (l = 0; l < FF_ARRAY_ELEMS(s->prob_ctx[s->s.h.framectxid].coef[0][0][0]); l++) + for (m = 0; m < FF_ARRAY_ELEMS(s->prob_ctx[s->s.h.framectxid].coef[0][0][0][0]); m++) + memcpy(s->prob_ctx[s->s.h.framectxid].coef[i][j][k][l][m], + s->prob.coef[i][j][k][l][m], + FF_ARRAY_ELEMS(s->prob_ctx[s->s.h.framectxid].coef[0][0][0][0][0])); + if (s->s.h.txfmmode == i) + break; + } + + s->prob_ctx[s->s.h.framectxid].p = s->prob.p; + } + + err = ff_nvtegra_start_frame(avctx, frame, &ctx->core); + if (err < 0) + return err; + + tf = fdd->hwaccel_priv; + input_map = (AVNVTegraMap *)tf->input_map_ref->data; + mem = av_nvtegra_map_get_addr(input_map), common_mem = av_nvtegra_map_get_addr(&ctx->common_map); + + nvtegra_vp9_prepare_frame_setup((nvdec_vp9_pic_s *)(mem + ctx->core.pic_setup_off), avctx, ctx); + nvtegra_vp9_set_tile_sizes((uint16_t *)(common_mem + ctx->tile_sizes_off), s); + nvtegra_vp9_update_probs((nvdec_vp9EntropyProbs_t *)(mem + ctx->prob_tab_off), s, ctx->core.new_input_buffer); + + ctx->refs[0] = ff_nvtegra_safe_get_ref(h->refs[h->h.refidx[0]].f, h->frames[CUR_FRAME].tf.f); + ctx->refs[1] = ff_nvtegra_safe_get_ref(h->refs[h->h.refidx[1]].f, h->frames[CUR_FRAME].tf.f); + ctx->refs[2] = ff_nvtegra_safe_get_ref(h->refs[h->h.refidx[2]].f, h->frames[CUR_FRAME].tf.f); + + return 0; +} + +static int nvtegra_vp9_end_frame(AVCodecContext *avctx) { + VP9Context *s = avctx->priv_data; + VP9SharedContext *h = avctx->priv_data; + NVTegraVP9DecodeContext *ctx = avctx->internal->hwaccel_priv_data; + AVFrame *frame = h->frames[CUR_FRAME].tf.f; + FrameDecodeData *fdd = (FrameDecodeData *)frame->private_ref->data; + FFNVTegraDecodeFrame *tf = fdd->hwaccel_priv; + + nvdec_vp9_pic_s *setup; + uint8_t *mem, *common_mem; + int err; + + av_log(avctx, AV_LOG_DEBUG, "Ending VP9-NVTEGRA frame with %u slices -> %u bytes\n", + ctx->core.num_slices, ctx->core.bitstream_len); + + if (!tf || !ctx->core.num_slices) + return 0; + + mem = av_nvtegra_map_get_addr((AVNVTegraMap *)tf->input_map_ref->data); + + setup = (nvdec_vp9_pic_s *)(mem + ctx->core.pic_setup_off); + setup->stream_len = ctx->core.bitstream_len; + + err = nvtegra_vp9_prepare_cmdbuf(&ctx->core.cmdbuf, h, ctx, frame); + if (err < 0) + return err; + + err = ff_nvtegra_end_frame(avctx, frame, &ctx->core, NULL, 0); + if (err < 0) + return err; + + /* + * Perform backward probability updates if necessary. + * Since it depends on entropy counts calculated by the hardware, + * we need to wait for the decode operation to complete. + */ + if (!s->s.h.errorres && !s->s.h.parallelmode) { + err = ff_nvtegra_wait_decode(avctx, frame); + if (err < 0) + return err; + + common_mem = av_nvtegra_map_get_addr(&ctx->common_map); + + nvtegra_vp9_update_counts((nvdec_vp9EntropyCounts_t *)(common_mem + ctx->ctx_counter_off), + s->td); + ff_vp9_adapt_probs(s); + } + + return 0; +} + +static int nvtegra_vp9_decode_slice(AVCodecContext *avctx, const uint8_t *buf, + uint32_t buf_size) +{ + VP9SharedContext *h = avctx->priv_data; + AVFrame *frame = h->frames[CUR_FRAME].tf.f; + + int offset = h->h.uncompressed_header_size + h->h.compressed_header_size; + + return ff_nvtegra_decode_slice(avctx, frame, buf + offset, buf_size - offset, false); +} + +#if CONFIG_VP9_NVTEGRA_HWACCEL +const FFHWAccel ff_vp9_nvtegra_hwaccel = { + .p.name = "vp9_nvtegra", + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_VP9, + .p.pix_fmt = AV_PIX_FMT_NVTEGRA, + .start_frame = &nvtegra_vp9_start_frame, + .end_frame = &nvtegra_vp9_end_frame, + .decode_slice = &nvtegra_vp9_decode_slice, + .init = &nvtegra_vp9_decode_init, + .uninit = &nvtegra_vp9_decode_uninit, + .frame_params = &ff_nvtegra_frame_params, + .priv_data_size = sizeof(NVTegraVP9DecodeContext), + .caps_internal = HWACCEL_CAP_ASYNC_SAFE, +}; +#endif diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 5f1a5bd437..62ef919ca9 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -71,6 +71,9 @@ static const enum AVPixelFormat vc1_hwaccel_pixfmt_list_420[] = { #endif #if CONFIG_VC1_VDPAU_HWACCEL AV_PIX_FMT_VDPAU, +#endif +#if CONFIG_VC1_NVTEGRA_HWACCEL + AV_PIX_FMT_NVTEGRA, #endif AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE @@ -1425,6 +1428,9 @@ const FFCodec ff_vc1_decoder = { #endif #if CONFIG_VC1_VDPAU_HWACCEL HWACCEL_VDPAU(vc1), +#endif +#if CONFIG_VC1_NVTEGRA_HWACCEL + HWACCEL_NVTEGRA(vc1), #endif NULL }, @@ -1464,6 +1470,9 @@ const FFCodec ff_wmv3_decoder = { #endif #if CONFIG_WMV3_VDPAU_HWACCEL HWACCEL_VDPAU(wmv3), +#endif +#if CONFIG_WMV3_NVTEGRA_HWACCEL + HWACCEL_NVTEGRA(wmv3), #endif NULL }, diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index d6df018655..6ae6980abd 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -184,6 +184,9 @@ static enum AVPixelFormat get_pixel_format(VP8Context *s) #endif #if CONFIG_VP8_NVDEC_HWACCEL AV_PIX_FMT_CUDA, +#endif +#if CONFIG_VP8_NVTEGRA_HWACCEL + AV_PIX_FMT_NVTEGRA, #endif AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE, @@ -2980,6 +2983,9 @@ const FFCodec ff_vp8_decoder = { #endif #if CONFIG_VP8_NVDEC_HWACCEL HWACCEL_NVDEC(vp8), +#endif +#if CONFIG_VP8_NVTEGRA_HWACCEL + HWACCEL_NVTEGRA(vp8), #endif NULL }, diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 8ede2e2eb3..6f2b6f5241 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -165,7 +165,8 @@ static int update_size(AVCodecContext *avctx, int w, int h) CONFIG_VP9_NVDEC_HWACCEL + \ CONFIG_VP9_VAAPI_HWACCEL + \ CONFIG_VP9_VDPAU_HWACCEL + \ - CONFIG_VP9_VIDEOTOOLBOX_HWACCEL) + CONFIG_VP9_VIDEOTOOLBOX_HWACCEL + \ + CONFIG_VP9_NVTEGRA_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts; VP9Context *s = avctx->priv_data; uint8_t *p; @@ -180,6 +181,10 @@ static int update_size(AVCodecContext *avctx, int w, int h) switch (s->pix_fmt) { case AV_PIX_FMT_YUV420P: +#if CONFIG_VP9_NVTEGRA_HWACCEL + *fmtp++ = AV_PIX_FMT_NVTEGRA; +#endif + /* fallthrough */ case AV_PIX_FMT_YUV420P10: #if CONFIG_VP9_DXVA2_HWACCEL *fmtp++ = AV_PIX_FMT_DXVA2_VLD; @@ -1870,6 +1875,9 @@ const FFCodec ff_vp9_decoder = { #endif #if CONFIG_VP9_VIDEOTOOLBOX_HWACCEL HWACCEL_VIDEOTOOLBOX(vp9), +#endif +#if CONFIG_VP9_NVTEGRA_HWACCEL + HWACCEL_NVTEGRA(vp9), #endif NULL }, diff --git a/libavutil/Makefile b/libavutil/Makefile index 6e6fa8d800..8e1f9ebc2f 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -52,6 +52,10 @@ HEADERS = adler32.h \ hwcontext_videotoolbox.h \ hwcontext_vdpau.h \ hwcontext_vulkan.h \ + hwcontext_nvtegra.h \ + nvtegra.h \ + nvhost_ioctl.h \ + nvmap_ioctl.h \ iamf.h \ imgutils.h \ intfloat.h \ @@ -207,6 +211,7 @@ OBJS-$(CONFIG_VDPAU) += hwcontext_vdpau.o OBJS-$(CONFIG_VULKAN) += hwcontext_vulkan.o vulkan.o OBJS-$(!CONFIG_VULKAN) += hwcontext_stub.o +OBJS-$(CONFIG_NVTEGRA) += nvtegra.o hwcontext_nvtegra.o OBJS += $(COMPAT_OBJS:%=../compat/%) @@ -228,6 +233,9 @@ SKIPHEADERS-$(CONFIG_VDPAU) += hwcontext_vdpau.h SKIPHEADERS-$(CONFIG_VULKAN) += hwcontext_vulkan.h vulkan.h \ vulkan_functions.h \ vulkan_loader.h +SKIPHEADERS-$(CONFIG_NVTEGRA) += nvtegra.h \ + nvtegra_host1x.h \ + hwcontext_nvtegra.h TESTPROGS = adler32 \ aes \ diff --git a/libavutil/aarch64/intmath.h b/libavutil/aarch64/intmath.h new file mode 100644 index 0000000000..da8dbd6574 --- /dev/null +++ b/libavutil/aarch64/intmath.h @@ -0,0 +1,32 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_RISCV_INTMATH_H +#define AVUTIL_RISCV_INTMATH_H + +#include + +#include "config.h" +#include "libavutil/attributes.h" + +#if defined (__GNUC__) || defined (__clang__) +#define av_popcount __builtin_popcount +#define av_popcount64 __builtin_popcountll +#endif + +#endif /* AVUTIL_RISCV_INTMATH_H */ diff --git a/libavutil/buffer.c b/libavutil/buffer.c index a8101d83f0..40e6605ada 100644 --- a/libavutil/buffer.c +++ b/libavutil/buffer.c @@ -16,9 +16,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" + #include #include #include +#if HAVE_MALLOC_H +#include +#endif #include "avassert.h" #include "buffer_internal.h" @@ -90,6 +95,32 @@ AVBufferRef *av_buffer_alloc(size_t size) return ret; } +AVBufferRef *av_buffer_aligned_alloc(size_t size, size_t align) +{ + AVBufferRef *ret = NULL; + uint8_t *data = NULL; + +#if HAVE_POSIX_MEMALIGN + if (posix_memalign((void **)&data, align, size)) + return NULL; +#elif HAVE_ALIGNED_MALLOC + data = aligned_alloc(align, size); +#elif HAVE_MEMALIGN + data = memalign(align, size); +#else + return NULL; +#endif + + if (!data) + return NULL; + + ret = av_buffer_create(data, size, av_buffer_default_free, NULL, 0); + if (!ret) + av_freep(&data); + + return ret; +} + AVBufferRef *av_buffer_allocz(size_t size) { AVBufferRef *ret = av_buffer_alloc(size); diff --git a/libavutil/buffer.h b/libavutil/buffer.h index e1ef5b7f07..085d92eaa3 100644 --- a/libavutil/buffer.h +++ b/libavutil/buffer.h @@ -101,6 +101,8 @@ typedef struct AVBufferRef { */ AVBufferRef *av_buffer_alloc(size_t size); +AVBufferRef *av_buffer_aligned_alloc(size_t size, size_t align); + /** * Same as av_buffer_alloc(), except the returned buffer will be initialized * to zero. diff --git a/libavutil/clb0b6.h b/libavutil/clb0b6.h new file mode 100644 index 0000000000..dc2f202083 --- /dev/null +++ b/libavutil/clb0b6.h @@ -0,0 +1,303 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _clb0b6_h_ +#define _clb0b6_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define NVB0B6_VIDEO_COMPOSITOR (0x0000B0B6) + +#define NVB0B6_VIDEO_COMPOSITOR_NOP (0x00000100) +#define NVB0B6_VIDEO_COMPOSITOR_NOP_PARAMETER 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_PM_TRIGGER (0x00000140) +#define NVB0B6_VIDEO_COMPOSITOR_PM_TRIGGER_V 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_APPLICATION_ID (0x00000200) +#define NVB0B6_VIDEO_COMPOSITOR_SET_APPLICATION_ID_ID 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_APPLICATION_ID_ID_COMPOSITOR (0x00000000) +#define NVB0B6_VIDEO_COMPOSITOR_SET_WATCHDOG_TIMER (0x00000204) +#define NVB0B6_VIDEO_COMPOSITOR_SET_WATCHDOG_TIMER_TIMER 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_A (0x00000240) +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_A_UPPER 7:0 +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_B (0x00000244) +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_B_LOWER 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_C (0x00000248) +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_C_PAYLOAD 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_CTX_SAVE_AREA (0x0000024C) +#define NVB0B6_VIDEO_COMPOSITOR_CTX_SAVE_AREA_OFFSET 27:0 +#define NVB0B6_VIDEO_COMPOSITOR_CTX_SAVE_AREA_CTX_VALID 31:28 +#define NVB0B6_VIDEO_COMPOSITOR_CTX_SWITCH (0x00000250) +#define NVB0B6_VIDEO_COMPOSITOR_CTX_SWITCH_RESTORE 0:0 +#define NVB0B6_VIDEO_COMPOSITOR_CTX_SWITCH_RESTORE_FALSE (0x00000000) +#define NVB0B6_VIDEO_COMPOSITOR_CTX_SWITCH_RESTORE_TRUE (0x00000001) +#define NVB0B6_VIDEO_COMPOSITOR_CTX_SWITCH_RST_NOTIFY 1:1 +#define NVB0B6_VIDEO_COMPOSITOR_CTX_SWITCH_RST_NOTIFY_FALSE (0x00000000) +#define NVB0B6_VIDEO_COMPOSITOR_CTX_SWITCH_RST_NOTIFY_TRUE (0x00000001) +#define NVB0B6_VIDEO_COMPOSITOR_CTX_SWITCH_RESERVED 7:2 +#define NVB0B6_VIDEO_COMPOSITOR_CTX_SWITCH_ASID 23:8 +#define NVB0B6_VIDEO_COMPOSITOR_EXECUTE (0x00000300) +#define NVB0B6_VIDEO_COMPOSITOR_EXECUTE_NOTIFY 0:0 +#define NVB0B6_VIDEO_COMPOSITOR_EXECUTE_NOTIFY_DISABLE (0x00000000) +#define NVB0B6_VIDEO_COMPOSITOR_EXECUTE_NOTIFY_ENABLE (0x00000001) +#define NVB0B6_VIDEO_COMPOSITOR_EXECUTE_NOTIFY_ON 1:1 +#define NVB0B6_VIDEO_COMPOSITOR_EXECUTE_NOTIFY_ON_END (0x00000000) +#define NVB0B6_VIDEO_COMPOSITOR_EXECUTE_NOTIFY_ON_BEGIN (0x00000001) +#define NVB0B6_VIDEO_COMPOSITOR_EXECUTE_AWAKEN 8:8 +#define NVB0B6_VIDEO_COMPOSITOR_EXECUTE_AWAKEN_DISABLE (0x00000000) +#define NVB0B6_VIDEO_COMPOSITOR_EXECUTE_AWAKEN_ENABLE (0x00000001) +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D (0x00000304) +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D_STRUCTURE_SIZE 0:0 +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D_STRUCTURE_SIZE_ONE (0x00000000) +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D_STRUCTURE_SIZE_FOUR (0x00000001) +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D_AWAKEN_ENABLE 8:8 +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D_AWAKEN_ENABLE_FALSE (0x00000000) +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D_AWAKEN_ENABLE_TRUE (0x00000001) +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D_OPERATION 17:16 +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D_OPERATION_RELEASE (0x00000000) +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D_OPERATION_RESERVED0 (0x00000001) +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D_OPERATION_RESERVED1 (0x00000002) +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D_OPERATION_TRAP (0x00000003) +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D_FLUSH_DISABLE 21:21 +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D_FLUSH_DISABLE_FALSE (0x00000000) +#define NVB0B6_VIDEO_COMPOSITOR_SEMAPHORE_D_FLUSH_DISABLE_TRUE (0x00000001) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE0_LUMA_OFFSET(b) (0x00000400 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE0_LUMA_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE0_CHROMA_U_OFFSET(b) (0x00000404 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE0_CHROMA_U_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE0_CHROMA_V_OFFSET(b) (0x00000408 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE0_CHROMA_V_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE1_LUMA_OFFSET(b) (0x0000040C + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE1_LUMA_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE1_CHROMA_U_OFFSET(b) (0x00000410 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE1_CHROMA_U_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE1_CHROMA_V_OFFSET(b) (0x00000414 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE1_CHROMA_V_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE2_LUMA_OFFSET(b) (0x00000418 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE2_LUMA_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE2_CHROMA_U_OFFSET(b) (0x0000041C + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE2_CHROMA_U_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE2_CHROMA_V_OFFSET(b) (0x00000420 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE2_CHROMA_V_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE3_LUMA_OFFSET(b) (0x00000424 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE3_LUMA_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE3_CHROMA_U_OFFSET(b) (0x00000428 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE3_CHROMA_U_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE3_CHROMA_V_OFFSET(b) (0x0000042C + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE3_CHROMA_V_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE4_LUMA_OFFSET(b) (0x00000430 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE4_LUMA_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE4_CHROMA_U_OFFSET(b) (0x00000434 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE4_CHROMA_U_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE4_CHROMA_V_OFFSET(b) (0x00000438 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE4_CHROMA_V_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE5_LUMA_OFFSET(b) (0x0000043C + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE5_LUMA_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE5_CHROMA_U_OFFSET(b) (0x00000440 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE5_CHROMA_U_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE5_CHROMA_V_OFFSET(b) (0x00000444 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE5_CHROMA_V_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE6_LUMA_OFFSET(b) (0x00000448 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE6_LUMA_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE6_CHROMA_U_OFFSET(b) (0x0000044C + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE6_CHROMA_U_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE6_CHROMA_V_OFFSET(b) (0x00000450 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE6_CHROMA_V_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE7_LUMA_OFFSET(b) (0x00000454 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE7_LUMA_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE7_CHROMA_U_OFFSET(b) (0x00000458 + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE7_CHROMA_U_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE7_CHROMA_V_OFFSET(b) (0x0000045C + (b)*0x00000060) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE7_CHROMA_V_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_PICTURE_INDEX (0x00000700) +#define NVB0B6_VIDEO_COMPOSITOR_SET_PICTURE_INDEX_INDEX 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONTROL_PARAMS (0x00000704) +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONTROL_PARAMS_GPTIMER_ON 0:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONTROL_PARAMS_DEBUG_MODE 4:4 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONTROL_PARAMS_FALCON_CONTROL 8:8 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONTROL_PARAMS_CONFIG_STRUCT_SIZE 31:16 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONFIG_STRUCT_OFFSET (0x00000708) +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONFIG_STRUCT_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_FILTER_STRUCT_OFFSET (0x0000070C) +#define NVB0B6_VIDEO_COMPOSITOR_SET_FILTER_STRUCT_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_PALETTE_OFFSET (0x00000710) +#define NVB0B6_VIDEO_COMPOSITOR_SET_PALETTE_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_HIST_OFFSET (0x00000714) +#define NVB0B6_VIDEO_COMPOSITOR_SET_HIST_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONTEXT_ID (0x00000718) +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONTEXT_ID_FCE_UCODE 3:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONTEXT_ID_CONFIG 7:4 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONTEXT_ID_PALETTE 11:8 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONTEXT_ID_OUTPUT 15:12 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CONTEXT_ID_HIST 19:16 +#define NVB0B6_VIDEO_COMPOSITOR_SET_FCE_UCODE_SIZE (0x0000071C) +#define NVB0B6_VIDEO_COMPOSITOR_SET_FCE_UCODE_SIZE_FCE_SZ 15:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_OUTPUT_SURFACE_LUMA_OFFSET (0x00000720) +#define NVB0B6_VIDEO_COMPOSITOR_SET_OUTPUT_SURFACE_LUMA_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_OUTPUT_SURFACE_CHROMA_U_OFFSET (0x00000724) +#define NVB0B6_VIDEO_COMPOSITOR_SET_OUTPUT_SURFACE_CHROMA_U_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_OUTPUT_SURFACE_CHROMA_V_OFFSET (0x00000728) +#define NVB0B6_VIDEO_COMPOSITOR_SET_OUTPUT_SURFACE_CHROMA_V_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_FCE_UCODE_OFFSET (0x0000072C) +#define NVB0B6_VIDEO_COMPOSITOR_SET_FCE_UCODE_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CRC_STRUCT_OFFSET (0x00000730) +#define NVB0B6_VIDEO_COMPOSITOR_SET_CRC_STRUCT_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CRC_MODE (0x00000734) +#define NVB0B6_VIDEO_COMPOSITOR_SET_CRC_MODE_INTF_PART_ASEL 3:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CRC_MODE_INTF_PART_BSEL 7:4 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CRC_MODE_INTF_PART_CSEL 11:8 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CRC_MODE_INTF_PART_DSEL 15:12 +#define NVB0B6_VIDEO_COMPOSITOR_SET_CRC_MODE_CRC_MODE 16:16 +#define NVB0B6_VIDEO_COMPOSITOR_SET_STATUS_OFFSET (0x00000738) +#define NVB0B6_VIDEO_COMPOSITOR_SET_STATUS_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SLOT_CONTEXT_ID(b) (0x00000740 + (b)*0x00000004) +#define NVB0B6_VIDEO_COMPOSITOR_SET_SLOT_CONTEXT_ID_CTX_ID_SFC0 3:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SLOT_CONTEXT_ID_CTX_ID_SFC1 7:4 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SLOT_CONTEXT_ID_CTX_ID_SFC2 11:8 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SLOT_CONTEXT_ID_CTX_ID_SFC3 15:12 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SLOT_CONTEXT_ID_CTX_ID_SFC4 19:16 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SLOT_CONTEXT_ID_CTX_ID_SFC5 23:20 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SLOT_CONTEXT_ID_CTX_ID_SFC6 27:24 +#define NVB0B6_VIDEO_COMPOSITOR_SET_SLOT_CONTEXT_ID_CTX_ID_SFC7 31:28 +#define NVB0B6_VIDEO_COMPOSITOR_SET_HISTORY_BUFFER_OFFSET(b) (0x00000780 + (b)*0x00000004) +#define NVB0B6_VIDEO_COMPOSITOR_SET_HISTORY_BUFFER_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_SET_COMP_TAG_BUFFER_OFFSET(b) (0x000007C0 + (b)*0x00000004) +#define NVB0B6_VIDEO_COMPOSITOR_SET_COMP_TAG_BUFFER_OFFSET_OFFSET 31:0 +#define NVB0B6_VIDEO_COMPOSITOR_PM_TRIGGER_END (0x00001114) +#define NVB0B6_VIDEO_COMPOSITOR_PM_TRIGGER_END_V 31:0 + +#define NVB0B6_DXVAHD_FRAME_FORMAT_PROGRESSIVE 0 +#define NVB0B6_DXVAHD_FRAME_FORMAT_INTERLACED_TOP_FIELD_FIRST 1 +#define NVB0B6_DXVAHD_FRAME_FORMAT_INTERLACED_BOTTOM_FIELD_FIRST 2 +#define NVB0B6_DXVAHD_FRAME_FORMAT_TOP_FIELD 3 +#define NVB0B6_DXVAHD_FRAME_FORMAT_BOTTOM_FIELD 4 +#define NVB0B6_DXVAHD_FRAME_FORMAT_SUBPIC_PROGRESSIVE 5 +#define NVB0B6_DXVAHD_FRAME_FORMAT_SUBPIC_INTERLACED_TOP_FIELD_FIRST 6 +#define NVB0B6_DXVAHD_FRAME_FORMAT_SUBPIC_INTERLACED_BOTTOM_FIELD_FIRST 7 +#define NVB0B6_DXVAHD_FRAME_FORMAT_SUBPIC_TOP_FIELD 8 +#define NVB0B6_DXVAHD_FRAME_FORMAT_SUBPIC_BOTTOM_FIELD 9 +#define NVB0B6_DXVAHD_FRAME_FORMAT_TOP_FIELD_CHROMA_BOTTOM 10 +#define NVB0B6_DXVAHD_FRAME_FORMAT_BOTTOM_FIELD_CHROMA_TOP 11 +#define NVB0B6_DXVAHD_FRAME_FORMAT_SUBPIC_TOP_FIELD_CHROMA_BOTTOM 12 +#define NVB0B6_DXVAHD_FRAME_FORMAT_SUBPIC_BOTTOM_FIELD_CHROMA_TOP 13 + +#define NVB0B6_T_A8 0 +#define NVB0B6_T_L8 1 +#define NVB0B6_T_A4L4 2 +#define NVB0B6_T_L4A4 3 +#define NVB0B6_T_R8 4 +#define NVB0B6_T_A8L8 5 +#define NVB0B6_T_L8A8 6 +#define NVB0B6_T_R8G8 7 +#define NVB0B6_T_G8R8 8 +#define NVB0B6_T_B5G6R5 9 +#define NVB0B6_T_R5G6B5 10 +#define NVB0B6_T_B6G5R5 11 +#define NVB0B6_T_R5G5B6 12 +#define NVB0B6_T_A1B5G5R5 13 +#define NVB0B6_T_A1R5G5B5 14 +#define NVB0B6_T_B5G5R5A1 15 +#define NVB0B6_T_R5G5B5A1 16 +#define NVB0B6_T_A5B5G5R1 17 +#define NVB0B6_T_A5R1G5B5 18 +#define NVB0B6_T_B5G5R1A5 19 +#define NVB0B6_T_R1G5B5A5 20 +#define NVB0B6_T_X1B5G5R5 21 +#define NVB0B6_T_X1R5G5B5 22 +#define NVB0B6_T_B5G5R5X1 23 +#define NVB0B6_T_R5G5B5X1 24 +#define NVB0B6_T_A4B4G4R4 25 +#define NVB0B6_T_A4R4G4B4 26 +#define NVB0B6_T_B4G4R4A4 27 +#define NVB0B6_T_R4G4B4A4 28 +#define NVB0B6_T_B8_G8_R8 29 +#define NVB0B6_T_R8_G8_B8 30 +#define NVB0B6_T_A8B8G8R8 31 +#define NVB0B6_T_A8R8G8B8 32 +#define NVB0B6_T_B8G8R8A8 33 +#define NVB0B6_T_R8G8B8A8 34 +#define NVB0B6_T_X8B8G8R8 35 +#define NVB0B6_T_X8R8G8B8 36 +#define NVB0B6_T_B8G8R8X8 37 +#define NVB0B6_T_R8G8B8X8 38 +#define NVB0B6_T_A2B10G10R10 39 +#define NVB0B6_T_A2R10G10B10 40 +#define NVB0B6_T_B10G10R10A2 41 +#define NVB0B6_T_R10G10B10A2 42 +#define NVB0B6_T_A4P4 43 +#define NVB0B6_T_P4A4 44 +#define NVB0B6_T_P8A8 45 +#define NVB0B6_T_A8P8 46 +#define NVB0B6_T_P8 47 +#define NVB0B6_T_P1 48 +#define NVB0B6_T_U8V8 49 +#define NVB0B6_T_V8U8 50 +#define NVB0B6_T_A8Y8U8V8 51 +#define NVB0B6_T_V8U8Y8A8 52 +#define NVB0B6_T_Y8_U8_V8 53 +#define NVB0B6_T_Y8_V8_U8 54 +#define NVB0B6_T_U8_V8_Y8 55 +#define NVB0B6_T_V8_U8_Y8 56 +#define NVB0B6_T_Y8_U8__Y8_V8 57 +#define NVB0B6_T_Y8_V8__Y8_U8 58 +#define NVB0B6_T_U8_Y8__V8_Y8 59 +#define NVB0B6_T_V8_Y8__U8_Y8 60 +#define NVB0B6_T_Y8___U8V8_N444 61 +#define NVB0B6_T_Y8___V8U8_N444 62 +#define NVB0B6_T_Y8___U8V8_N422 63 +#define NVB0B6_T_Y8___V8U8_N422 64 +#define NVB0B6_T_Y8___U8V8_N422R 65 +#define NVB0B6_T_Y8___V8U8_N422R 66 +#define NVB0B6_T_Y8___U8V8_N420 67 +#define NVB0B6_T_Y8___V8U8_N420 68 +#define NVB0B6_T_Y8___U8___V8_N444 69 +#define NVB0B6_T_Y8___U8___V8_N422 70 +#define NVB0B6_T_Y8___U8___V8_N422R 71 +#define NVB0B6_T_Y8___U8___V8_N420 72 +#define NVB0B6_T_U8 73 +#define NVB0B6_T_V8 74 + +#define NVB0B6_DXVAHD_ALPHA_FILL_MODE_OPAQUE 0 +#define NVB0B6_DXVAHD_ALPHA_FILL_MODE_BACKGROUND 1 +#define NVB0B6_DXVAHD_ALPHA_FILL_MODE_DESTINATION 2 +#define NVB0B6_DXVAHD_ALPHA_FILL_MODE_SOURCE_STREAM 3 +#define NVB0B6_DXVAHD_ALPHA_FILL_MODE_COMPOSITED 4 +#define NVB0B6_DXVAHD_ALPHA_FILL_MODE_SOURCE_ALPHA 5 + +#define NVB0B6_BLK_KIND_PITCH 0 +#define NVB0B6_BLK_KIND_GENERIC_16Bx2 1 +#define NVB0B6_BLK_KIND_BL_NAIVE 2 +#define NVB0B6_BLK_KIND_BL_KEPLER_XBAR_RAW 3 +#define NVB0B6_BLK_KIND_VP2_TILED 15 + +#define NVB0B6_FILTER_LENGTH_1TAP 0 +#define NVB0B6_FILTER_LENGTH_2TAP 1 +#define NVB0B6_FILTER_LENGTH_5TAP 2 +#define NVB0B6_FILTER_LENGTH_10TAP 3 + +#define NVB0B6_FILTER_TYPE_NORMAL 0 +#define NVB0B6_FILTER_TYPE_NOISE 1 +#define NVB0B6_FILTER_TYPE_DETAIL 2 + +#ifdef __cplusplus +}; /* extern "C" */ +#endif +#endif // _clb0b6_h diff --git a/libavutil/clc5b0.h b/libavutil/clc5b0.h new file mode 100644 index 0000000000..4f17e82fb3 --- /dev/null +++ b/libavutil/clc5b0.h @@ -0,0 +1,436 @@ +/******************************************************************************* + Copyright (c) 1993-2020, NVIDIA CORPORATION. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + +*******************************************************************************/ + +#ifndef _clc5b0_h_ +#define _clc5b0_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define NVC5B0_VIDEO_DECODER (0x0000C5B0) + +#define NVC5B0_NOP (0x00000100) +#define NVC5B0_NOP_PARAMETER 31:0 +#define NVC5B0_SET_APPLICATION_ID (0x00000200) +#define NVC5B0_SET_APPLICATION_ID_ID 31:0 +#define NVC5B0_SET_APPLICATION_ID_ID_MPEG12 (0x00000001) +#define NVC5B0_SET_APPLICATION_ID_ID_VC1 (0x00000002) +#define NVC5B0_SET_APPLICATION_ID_ID_H264 (0x00000003) +#define NVC5B0_SET_APPLICATION_ID_ID_MPEG4 (0x00000004) +#define NVC5B0_SET_APPLICATION_ID_ID_VP8 (0x00000005) +#define NVC5B0_SET_APPLICATION_ID_ID_HEVC (0x00000007) +#define NVC5B0_SET_APPLICATION_ID_ID_VP9 (0x00000009) +#define NVC5B0_SET_APPLICATION_ID_ID_HEVC_PARSER (0x0000000C) +#define NVC5B0_SET_WATCHDOG_TIMER (0x00000204) +#define NVC5B0_SET_WATCHDOG_TIMER_TIMER 31:0 +#define NVC5B0_SEMAPHORE_A (0x00000240) +#define NVC5B0_SEMAPHORE_A_UPPER 7:0 +#define NVC5B0_SEMAPHORE_B (0x00000244) +#define NVC5B0_SEMAPHORE_B_LOWER 31:0 +#define NVC5B0_SEMAPHORE_C (0x00000248) +#define NVC5B0_SEMAPHORE_C_PAYLOAD 31:0 +#define NVC5B0_CTX_SAVE_AREA (0x0000024C) +#define NVC5B0_CTX_SAVE_AREA_OFFSET 31:0 +#define NVC5B0_CTX_SWITCH (0x00000250) +#define NVC5B0_CTX_SWITCH_OP 1:0 +#define NVC5B0_CTX_SWITCH_OP_CTX_UPDATE (0x00000000) +#define NVC5B0_CTX_SWITCH_OP_CTX_SAVE (0x00000001) +#define NVC5B0_CTX_SWITCH_OP_CTX_RESTORE (0x00000002) +#define NVC5B0_CTX_SWITCH_OP_CTX_FORCERESTORE (0x00000003) +#define NVC5B0_CTX_SWITCH_CTXID_VALID 2:2 +#define NVC5B0_CTX_SWITCH_CTXID_VALID_FALSE (0x00000000) +#define NVC5B0_CTX_SWITCH_CTXID_VALID_TRUE (0x00000001) +#define NVC5B0_CTX_SWITCH_RESERVED0 7:3 +#define NVC5B0_CTX_SWITCH_CTX_ID 23:8 +#define NVC5B0_CTX_SWITCH_RESERVED1 31:24 +#define NVC5B0_EXECUTE (0x00000300) +#define NVC5B0_EXECUTE_NOTIFY 0:0 +#define NVC5B0_EXECUTE_NOTIFY_DISABLE (0x00000000) +#define NVC5B0_EXECUTE_NOTIFY_ENABLE (0x00000001) +#define NVC5B0_EXECUTE_NOTIFY_ON 1:1 +#define NVC5B0_EXECUTE_NOTIFY_ON_END (0x00000000) +#define NVC5B0_EXECUTE_NOTIFY_ON_BEGIN (0x00000001) +#define NVC5B0_EXECUTE_AWAKEN 8:8 +#define NVC5B0_EXECUTE_AWAKEN_DISABLE (0x00000000) +#define NVC5B0_EXECUTE_AWAKEN_ENABLE (0x00000001) +#define NVC5B0_SEMAPHORE_D (0x00000304) +#define NVC5B0_SEMAPHORE_D_STRUCTURE_SIZE 0:0 +#define NVC5B0_SEMAPHORE_D_STRUCTURE_SIZE_ONE (0x00000000) +#define NVC5B0_SEMAPHORE_D_STRUCTURE_SIZE_FOUR (0x00000001) +#define NVC5B0_SEMAPHORE_D_AWAKEN_ENABLE 8:8 +#define NVC5B0_SEMAPHORE_D_AWAKEN_ENABLE_FALSE (0x00000000) +#define NVC5B0_SEMAPHORE_D_AWAKEN_ENABLE_TRUE (0x00000001) +#define NVC5B0_SEMAPHORE_D_OPERATION 17:16 +#define NVC5B0_SEMAPHORE_D_OPERATION_RELEASE (0x00000000) +#define NVC5B0_SEMAPHORE_D_OPERATION_RESERVED0 (0x00000001) +#define NVC5B0_SEMAPHORE_D_OPERATION_RESERVED1 (0x00000002) +#define NVC5B0_SEMAPHORE_D_OPERATION_TRAP (0x00000003) +#define NVC5B0_SEMAPHORE_D_FLUSH_DISABLE 21:21 +#define NVC5B0_SEMAPHORE_D_FLUSH_DISABLE_FALSE (0x00000000) +#define NVC5B0_SEMAPHORE_D_FLUSH_DISABLE_TRUE (0x00000001) +#define NVC5B0_SET_CONTROL_PARAMS (0x00000400) +#define NVC5B0_SET_CONTROL_PARAMS_CODEC_TYPE 3:0 +#define NVC5B0_SET_CONTROL_PARAMS_CODEC_TYPE_MPEG1 (0x00000000) +#define NVC5B0_SET_CONTROL_PARAMS_CODEC_TYPE_MPEG2 (0x00000001) +#define NVC5B0_SET_CONTROL_PARAMS_CODEC_TYPE_VC1 (0x00000002) +#define NVC5B0_SET_CONTROL_PARAMS_CODEC_TYPE_H264 (0x00000003) +#define NVC5B0_SET_CONTROL_PARAMS_CODEC_TYPE_MPEG4 (0x00000004) +#define NVC5B0_SET_CONTROL_PARAMS_CODEC_TYPE_DIVX3 (0x00000004) +#define NVC5B0_SET_CONTROL_PARAMS_CODEC_TYPE_VP8 (0x00000005) +#define NVC5B0_SET_CONTROL_PARAMS_CODEC_TYPE_HEVC (0x00000007) +#define NVC5B0_SET_CONTROL_PARAMS_CODEC_TYPE_VP9 (0x00000009) +#define NVC5B0_SET_CONTROL_PARAMS_GPTIMER_ON 4:4 +#define NVC5B0_SET_CONTROL_PARAMS_RET_ERROR 5:5 +#define NVC5B0_SET_CONTROL_PARAMS_ERR_CONCEAL_ON 6:6 +#define NVC5B0_SET_CONTROL_PARAMS_ERROR_FRM_IDX 12:7 +#define NVC5B0_SET_CONTROL_PARAMS_MBTIMER_ON 13:13 +#define NVC5B0_SET_CONTROL_PARAMS_EC_INTRA_FRAME_USING_PSLC 14:14 +#define NVC5B0_SET_CONTROL_PARAMS_ALL_INTRA_FRAME 17:17 +#define NVC5B0_SET_CONTROL_PARAMS_RESERVED 31:18 +#define NVC5B0_SET_DRV_PIC_SETUP_OFFSET (0x00000404) +#define NVC5B0_SET_DRV_PIC_SETUP_OFFSET_OFFSET 31:0 +#define NVC5B0_SET_IN_BUF_BASE_OFFSET (0x00000408) +#define NVC5B0_SET_IN_BUF_BASE_OFFSET_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_INDEX (0x0000040C) +#define NVC5B0_SET_PICTURE_INDEX_INDEX 31:0 +#define NVC5B0_SET_SLICE_OFFSETS_BUF_OFFSET (0x00000410) +#define NVC5B0_SET_SLICE_OFFSETS_BUF_OFFSET_OFFSET 31:0 +#define NVC5B0_SET_COLOC_DATA_OFFSET (0x00000414) +#define NVC5B0_SET_COLOC_DATA_OFFSET_OFFSET 31:0 +#define NVC5B0_SET_HISTORY_OFFSET (0x00000418) +#define NVC5B0_SET_HISTORY_OFFSET_OFFSET 31:0 +#define NVC5B0_SET_DISPLAY_BUF_SIZE (0x0000041C) +#define NVC5B0_SET_DISPLAY_BUF_SIZE_SIZE 31:0 +#define NVC5B0_SET_HISTOGRAM_OFFSET (0x00000420) +#define NVC5B0_SET_HISTOGRAM_OFFSET_OFFSET 31:0 +#define NVC5B0_SET_NVDEC_STATUS_OFFSET (0x00000424) +#define NVC5B0_SET_NVDEC_STATUS_OFFSET_OFFSET 31:0 +#define NVC5B0_SET_DISPLAY_BUF_LUMA_OFFSET (0x00000428) +#define NVC5B0_SET_DISPLAY_BUF_LUMA_OFFSET_OFFSET 31:0 +#define NVC5B0_SET_DISPLAY_BUF_CHROMA_OFFSET (0x0000042C) +#define NVC5B0_SET_DISPLAY_BUF_CHROMA_OFFSET_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET0 (0x00000430) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET0_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET1 (0x00000434) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET1_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET2 (0x00000438) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET2_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET3 (0x0000043C) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET3_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET4 (0x00000440) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET4_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET5 (0x00000444) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET5_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET6 (0x00000448) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET6_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET7 (0x0000044C) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET7_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET8 (0x00000450) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET8_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET9 (0x00000454) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET9_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET10 (0x00000458) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET10_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET11 (0x0000045C) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET11_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET12 (0x00000460) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET12_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET13 (0x00000464) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET13_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET14 (0x00000468) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET14_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET15 (0x0000046C) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET15_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_LUMA_OFFSET16 (0x00000470) +#define NVC5B0_SET_PICTURE_LUMA_OFFSET16_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET0 (0x00000474) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET0_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET1 (0x00000478) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET1_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET2 (0x0000047C) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET2_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET3 (0x00000480) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET3_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET4 (0x00000484) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET4_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET5 (0x00000488) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET5_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET6 (0x0000048C) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET6_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET7 (0x00000490) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET7_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET8 (0x00000494) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET8_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET9 (0x00000498) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET9_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET10 (0x0000049C) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET10_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET11 (0x000004A0) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET11_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET12 (0x000004A4) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET12_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET13 (0x000004A8) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET13_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET14 (0x000004AC) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET14_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET15 (0x000004B0) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET15_OFFSET 31:0 +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET16 (0x000004B4) +#define NVC5B0_SET_PICTURE_CHROMA_OFFSET16_OFFSET 31:0 +#define NVC5B0_SET_PIC_SCRATCH_BUF_OFFSET (0x000004B8) +#define NVC5B0_SET_PIC_SCRATCH_BUF_OFFSET_OFFSET 31:0 +#define NVC5B0_SET_EXTERNAL_MVBUFFER_OFFSET (0x000004BC) +#define NVC5B0_SET_EXTERNAL_MVBUFFER_OFFSET_OFFSET 31:0 +#define NVC5B0_H264_SET_MBHIST_BUF_OFFSET (0x00000500) +#define NVC5B0_H264_SET_MBHIST_BUF_OFFSET_OFFSET 31:0 +#define NVC5B0_VP8_SET_PROB_DATA_OFFSET (0x00000540) +#define NVC5B0_VP8_SET_PROB_DATA_OFFSET_OFFSET 31:0 +#define NVC5B0_VP8_SET_HEADER_PARTITION_BUF_BASE_OFFSET (0x00000544) +#define NVC5B0_VP8_SET_HEADER_PARTITION_BUF_BASE_OFFSET_OFFSET 31:0 +#define NVC5B0_HEVC_SET_SCALING_LIST_OFFSET (0x00000580) +#define NVC5B0_HEVC_SET_SCALING_LIST_OFFSET_OFFSET 31:0 +#define NVC5B0_HEVC_SET_TILE_SIZES_OFFSET (0x00000584) +#define NVC5B0_HEVC_SET_TILE_SIZES_OFFSET_OFFSET 31:0 +#define NVC5B0_HEVC_SET_FILTER_BUFFER_OFFSET (0x00000588) +#define NVC5B0_HEVC_SET_FILTER_BUFFER_OFFSET_OFFSET 31:0 +#define NVC5B0_HEVC_SET_SAO_BUFFER_OFFSET (0x0000058C) +#define NVC5B0_HEVC_SET_SAO_BUFFER_OFFSET_OFFSET 31:0 +#define NVC5B0_HEVC_SET_SLICE_INFO_BUFFER_OFFSET (0x00000590) +#define NVC5B0_HEVC_SET_SLICE_INFO_BUFFER_OFFSET_OFFSET 31:0 +#define NVC5B0_HEVC_SET_SLICE_GROUP_INDEX (0x00000594) +#define NVC5B0_HEVC_SET_SLICE_GROUP_INDEX_OFFSET 31:0 +#define NVC5B0_VP9_SET_PROB_TAB_BUF_OFFSET (0x000005C0) +#define NVC5B0_VP9_SET_PROB_TAB_BUF_OFFSET_OFFSET 31:0 +#define NVC5B0_VP9_SET_CTX_COUNTER_BUF_OFFSET (0x000005C4) +#define NVC5B0_VP9_SET_CTX_COUNTER_BUF_OFFSET_OFFSET 31:0 +#define NVC5B0_VP9_SET_SEGMENT_READ_BUF_OFFSET (0x000005C8) +#define NVC5B0_VP9_SET_SEGMENT_READ_BUF_OFFSET_OFFSET 31:0 +#define NVC5B0_VP9_SET_SEGMENT_WRITE_BUF_OFFSET (0x000005CC) +#define NVC5B0_VP9_SET_SEGMENT_WRITE_BUF_OFFSET_OFFSET 31:0 +#define NVC5B0_VP9_SET_TILE_SIZE_BUF_OFFSET (0x000005D0) +#define NVC5B0_VP9_SET_TILE_SIZE_BUF_OFFSET_OFFSET 31:0 +#define NVC5B0_VP9_SET_COL_MVWRITE_BUF_OFFSET (0x000005D4) +#define NVC5B0_VP9_SET_COL_MVWRITE_BUF_OFFSET_OFFSET 31:0 +#define NVC5B0_VP9_SET_COL_MVREAD_BUF_OFFSET (0x000005D8) +#define NVC5B0_VP9_SET_COL_MVREAD_BUF_OFFSET_OFFSET 31:0 +#define NVC5B0_VP9_SET_FILTER_BUFFER_OFFSET (0x000005DC) +#define NVC5B0_VP9_SET_FILTER_BUFFER_OFFSET_OFFSET 31:0 + +#define NVC5B0_ERROR_NONE (0x00000000) +#define NVC5B0_OS_ERROR_EXECUTE_INSUFFICIENT_DATA (0x00000001) +#define NVC5B0_OS_ERROR_SEMAPHORE_INSUFFICIENT_DATA (0x00000002) +#define NVC5B0_OS_ERROR_INVALID_METHOD (0x00000003) +#define NVC5B0_OS_ERROR_INVALID_DMA_PAGE (0x00000004) +#define NVC5B0_OS_ERROR_UNHANDLED_INTERRUPT (0x00000005) +#define NVC5B0_OS_ERROR_EXCEPTION (0x00000006) +#define NVC5B0_OS_ERROR_INVALID_CTXSW_REQUEST (0x00000007) +#define NVC5B0_OS_ERROR_APPLICATION (0x00000008) +#define NVC5B0_OS_ERROR_SW_BREAKPT (0x00000009) +#define NVC5B0_OS_INTERRUPT_EXECUTE_AWAKEN (0x00000100) +#define NVC5B0_OS_INTERRUPT_BACKEND_SEMAPHORE_AWAKEN (0x00000200) +#define NVC5B0_OS_INTERRUPT_CTX_ERROR_FBIF (0x00000300) +#define NVC5B0_OS_INTERRUPT_LIMIT_VIOLATION (0x00000400) +#define NVC5B0_OS_INTERRUPT_LIMIT_AND_FBIF_CTX_ERROR (0x00000500) +#define NVC5B0_OS_INTERRUPT_HALT_ENGINE (0x00000600) +#define NVC5B0_OS_INTERRUPT_TRAP_NONSTALL (0x00000700) +#define NVC5B0_H264_VLD_ERR_SEQ_DATA_INCONSISTENT (0x00004001) +#define NVC5B0_H264_VLD_ERR_PIC_DATA_INCONSISTENT (0x00004002) +#define NVC5B0_H264_VLD_ERR_SLC_DATA_BUF_ADDR_OUT_OF_BOUNDS (0x00004100) +#define NVC5B0_H264_VLD_ERR_BITSTREAM_ERROR (0x00004101) +#define NVC5B0_H264_VLD_ERR_CTX_DMA_ID_CTRL_IN_INVALID (0x000041F8) +#define NVC5B0_H264_VLD_ERR_SLC_HDR_OUT_SIZE_NOT_MULT256 (0x00004200) +#define NVC5B0_H264_VLD_ERR_SLC_DATA_OUT_SIZE_NOT_MULT256 (0x00004201) +#define NVC5B0_H264_VLD_ERR_CTX_DMA_ID_FLOW_CTRL_INVALID (0x00004203) +#define NVC5B0_H264_VLD_ERR_CTX_DMA_ID_SLC_HDR_OUT_INVALID (0x00004204) +#define NVC5B0_H264_VLD_ERR_SLC_HDR_OUT_BUF_TOO_SMALL (0x00004205) +#define NVC5B0_H264_VLD_ERR_SLC_HDR_OUT_BUF_ALREADY_VALID (0x00004206) +#define NVC5B0_H264_VLD_ERR_SLC_DATA_OUT_BUF_TOO_SMALL (0x00004207) +#define NVC5B0_H264_VLD_ERR_DATA_BUF_CNT_TOO_SMALL (0x00004208) +#define NVC5B0_H264_VLD_ERR_BITSTREAM_EMPTY (0x00004209) +#define NVC5B0_H264_VLD_ERR_FRAME_WIDTH_TOO_LARGE (0x0000420A) +#define NVC5B0_H264_VLD_ERR_FRAME_HEIGHT_TOO_LARGE (0x0000420B) +#define NVC5B0_H264_VLD_ERR_HIST_BUF_TOO_SMALL (0x00004300) +#define NVC5B0_VC1_VLD_ERR_PIC_DATA_BUF_ADDR_OUT_OF_BOUND (0x00005100) +#define NVC5B0_VC1_VLD_ERR_BITSTREAM_ERROR (0x00005101) +#define NVC5B0_VC1_VLD_ERR_PIC_HDR_OUT_SIZE_NOT_MULT256 (0x00005200) +#define NVC5B0_VC1_VLD_ERR_PIC_DATA_OUT_SIZE_NOT_MULT256 (0x00005201) +#define NVC5B0_VC1_VLD_ERR_CTX_DMA_ID_CTRL_IN_INVALID (0x00005202) +#define NVC5B0_VC1_VLD_ERR_CTX_DMA_ID_FLOW_CTRL_INVALID (0x00005203) +#define NVC5B0_VC1_VLD_ERR_CTX_DMA_ID_PIC_HDR_OUT_INVALID (0x00005204) +#define NVC5B0_VC1_VLD_ERR_SLC_HDR_OUT_BUF_TOO_SMALL (0x00005205) +#define NVC5B0_VC1_VLD_ERR_PIC_HDR_OUT_BUF_ALREADY_VALID (0x00005206) +#define NVC5B0_VC1_VLD_ERR_PIC_DATA_OUT_BUF_TOO_SMALL (0x00005207) +#define NVC5B0_VC1_VLD_ERR_DATA_INFO_IN_BUF_TOO_SMALL (0x00005208) +#define NVC5B0_VC1_VLD_ERR_BITSTREAM_EMPTY (0x00005209) +#define NVC5B0_VC1_VLD_ERR_FRAME_WIDTH_TOO_LARGE (0x0000520A) +#define NVC5B0_VC1_VLD_ERR_FRAME_HEIGHT_TOO_LARGE (0x0000520B) +#define NVC5B0_VC1_VLD_ERR_PIC_DATA_OUT_BUF_FULL_TIME_OUT (0x00005300) +#define NVC5B0_MPEG12_VLD_ERR_SLC_DATA_BUF_ADDR_OUT_OF_BOUNDS (0x00006100) +#define NVC5B0_MPEG12_VLD_ERR_BITSTREAM_ERROR (0x00006101) +#define NVC5B0_MPEG12_VLD_ERR_SLC_DATA_OUT_SIZE_NOT_MULT256 (0x00006200) +#define NVC5B0_MPEG12_VLD_ERR_CTX_DMA_ID_CTRL_IN_INVALID (0x00006201) +#define NVC5B0_MPEG12_VLD_ERR_CTX_DMA_ID_FLOW_CTRL_INVALID (0x00006202) +#define NVC5B0_MPEG12_VLD_ERR_SLC_DATA_OUT_BUF_TOO_SMALL (0x00006203) +#define NVC5B0_MPEG12_VLD_ERR_DATA_INFO_IN_BUF_TOO_SMALL (0x00006204) +#define NVC5B0_MPEG12_VLD_ERR_BITSTREAM_EMPTY (0x00006205) +#define NVC5B0_MPEG12_VLD_ERR_INVALID_PIC_STRUCTURE (0x00006206) +#define NVC5B0_MPEG12_VLD_ERR_INVALID_PIC_CODING_TYPE (0x00006207) +#define NVC5B0_MPEG12_VLD_ERR_FRAME_WIDTH_TOO_LARGE (0x00006208) +#define NVC5B0_MPEG12_VLD_ERR_FRAME_HEIGHT_TOO_LARGE (0x00006209) +#define NVC5B0_MPEG12_VLD_ERR_SLC_DATA_OUT_BUF_FULL_TIME_OUT (0x00006300) +#define NVC5B0_CMN_VLD_ERR_PDEC_RETURNED_ERROR (0x00007101) +#define NVC5B0_CMN_VLD_ERR_EDOB_FLUSH_TIME_OUT (0x00007102) +#define NVC5B0_CMN_VLD_ERR_EDOB_REWIND_TIME_OUT (0x00007103) +#define NVC5B0_CMN_VLD_ERR_VLD_WD_TIME_OUT (0x00007104) +#define NVC5B0_CMN_VLD_ERR_NUM_SLICES_ZERO (0x00007105) +#define NVC5B0_MPEG4_VLD_ERR_PIC_DATA_BUF_ADDR_OUT_OF_BOUND (0x00008100) +#define NVC5B0_MPEG4_VLD_ERR_BITSTREAM_ERROR (0x00008101) +#define NVC5B0_MPEG4_VLD_ERR_PIC_HDR_OUT_SIZE_NOT_MULT256 (0x00008200) +#define NVC5B0_MPEG4_VLD_ERR_PIC_DATA_OUT_SIZE_NOT_MULT256 (0x00008201) +#define NVC5B0_MPEG4_VLD_ERR_CTX_DMA_ID_CTRL_IN_INVALID (0x00008202) +#define NVC5B0_MPEG4_VLD_ERR_CTX_DMA_ID_FLOW_CTRL_INVALID (0x00008203) +#define NVC5B0_MPEG4_VLD_ERR_CTX_DMA_ID_PIC_HDR_OUT_INVALID (0x00008204) +#define NVC5B0_MPEG4_VLD_ERR_SLC_HDR_OUT_BUF_TOO_SMALL (0x00008205) +#define NVC5B0_MPEG4_VLD_ERR_PIC_HDR_OUT_BUF_ALREADY_VALID (0x00008206) +#define NVC5B0_MPEG4_VLD_ERR_PIC_DATA_OUT_BUF_TOO_SMALL (0x00008207) +#define NVC5B0_MPEG4_VLD_ERR_DATA_INFO_IN_BUF_TOO_SMALL (0x00008208) +#define NVC5B0_MPEG4_VLD_ERR_BITSTREAM_EMPTY (0x00008209) +#define NVC5B0_MPEG4_VLD_ERR_FRAME_WIDTH_TOO_LARGE (0x0000820A) +#define NVC5B0_MPEG4_VLD_ERR_FRAME_HEIGHT_TOO_LARGE (0x0000820B) +#define NVC5B0_MPEG4_VLD_ERR_PIC_DATA_OUT_BUF_FULL_TIME_OUT (0x00051E01) +#define NVC5B0_DEC_ERROR_MPEG12_APPTIMER_EXPIRED (0xDEC10001) +#define NVC5B0_DEC_ERROR_MPEG12_MVTIMER_EXPIRED (0xDEC10002) +#define NVC5B0_DEC_ERROR_MPEG12_INVALID_TOKEN (0xDEC10003) +#define NVC5B0_DEC_ERROR_MPEG12_SLICEDATA_MISSING (0xDEC10004) +#define NVC5B0_DEC_ERROR_MPEG12_HWERR_INTERRUPT (0xDEC10005) +#define NVC5B0_DEC_ERROR_MPEG12_DETECTED_VLD_FAILURE (0xDEC10006) +#define NVC5B0_DEC_ERROR_MPEG12_PICTURE_INIT (0xDEC10100) +#define NVC5B0_DEC_ERROR_MPEG12_STATEMACHINE_FAILURE (0xDEC10101) +#define NVC5B0_DEC_ERROR_MPEG12_INVALID_CTXID_PIC (0xDEC10901) +#define NVC5B0_DEC_ERROR_MPEG12_INVALID_CTXID_UCODE (0xDEC10902) +#define NVC5B0_DEC_ERROR_MPEG12_INVALID_CTXID_FC (0xDEC10903) +#define NVC5B0_DEC_ERROR_MPEG12_INVALID_CTXID_SLH (0xDEC10904) +#define NVC5B0_DEC_ERROR_MPEG12_INVALID_UCODE_SIZE (0xDEC10905) +#define NVC5B0_DEC_ERROR_MPEG12_INVALID_SLICE_COUNT (0xDEC10906) +#define NVC5B0_DEC_ERROR_VC1_APPTIMER_EXPIRED (0xDEC20001) +#define NVC5B0_DEC_ERROR_VC1_MVTIMER_EXPIRED (0xDEC20002) +#define NVC5B0_DEC_ERROR_VC1_INVALID_TOKEN (0xDEC20003) +#define NVC5B0_DEC_ERROR_VC1_SLICEDATA_MISSING (0xDEC20004) +#define NVC5B0_DEC_ERROR_VC1_HWERR_INTERRUPT (0xDEC20005) +#define NVC5B0_DEC_ERROR_VC1_DETECTED_VLD_FAILURE (0xDEC20006) +#define NVC5B0_DEC_ERROR_VC1_TIMEOUT_POLLING_FOR_DATA (0xDEC20007) +#define NVC5B0_DEC_ERROR_VC1_PDEC_PIC_END_UNALIGNED (0xDEC20008) +#define NVC5B0_DEC_ERROR_VC1_WDTIMER_EXPIRED (0xDEC20009) +#define NVC5B0_DEC_ERROR_VC1_ERRINTSTART (0xDEC20010) +#define NVC5B0_DEC_ERROR_VC1_IQT_ERRINT (0xDEC20011) +#define NVC5B0_DEC_ERROR_VC1_MC_ERRINT (0xDEC20012) +#define NVC5B0_DEC_ERROR_VC1_MC_IQT_ERRINT (0xDEC20013) +#define NVC5B0_DEC_ERROR_VC1_REC_ERRINT (0xDEC20014) +#define NVC5B0_DEC_ERROR_VC1_REC_IQT_ERRINT (0xDEC20015) +#define NVC5B0_DEC_ERROR_VC1_REC_MC_ERRINT (0xDEC20016) +#define NVC5B0_DEC_ERROR_VC1_REC_MC_IQT_ERRINT (0xDEC20017) +#define NVC5B0_DEC_ERROR_VC1_DBF_ERRINT (0xDEC20018) +#define NVC5B0_DEC_ERROR_VC1_DBF_IQT_ERRINT (0xDEC20019) +#define NVC5B0_DEC_ERROR_VC1_DBF_MC_ERRINT (0xDEC2001A) +#define NVC5B0_DEC_ERROR_VC1_DBF_MC_IQT_ERRINT (0xDEC2001B) +#define NVC5B0_DEC_ERROR_VC1_DBF_REC_ERRINT (0xDEC2001C) +#define NVC5B0_DEC_ERROR_VC1_DBF_REC_IQT_ERRINT (0xDEC2001D) +#define NVC5B0_DEC_ERROR_VC1_DBF_REC_MC_ERRINT (0xDEC2001E) +#define NVC5B0_DEC_ERROR_VC1_DBF_REC_MC_IQT_ERRINT (0xDEC2001F) +#define NVC5B0_DEC_ERROR_VC1_PICTURE_INIT (0xDEC20100) +#define NVC5B0_DEC_ERROR_VC1_STATEMACHINE_FAILURE (0xDEC20101) +#define NVC5B0_DEC_ERROR_VC1_INVALID_CTXID_PIC (0xDEC20901) +#define NVC5B0_DEC_ERROR_VC1_INVALID_CTXID_UCODE (0xDEC20902) +#define NVC5B0_DEC_ERROR_VC1_INVALID_CTXID_FC (0xDEC20903) +#define NVC5B0_DEC_ERROR_VC1_INVAILD_CTXID_SLH (0xDEC20904) +#define NVC5B0_DEC_ERROR_VC1_INVALID_UCODE_SIZE (0xDEC20905) +#define NVC5B0_DEC_ERROR_VC1_INVALID_SLICE_COUNT (0xDEC20906) +#define NVC5B0_DEC_ERROR_H264_APPTIMER_EXPIRED (0xDEC30001) +#define NVC5B0_DEC_ERROR_H264_MVTIMER_EXPIRED (0xDEC30002) +#define NVC5B0_DEC_ERROR_H264_INVALID_TOKEN (0xDEC30003) +#define NVC5B0_DEC_ERROR_H264_SLICEDATA_MISSING (0xDEC30004) +#define NVC5B0_DEC_ERROR_H264_HWERR_INTERRUPT (0xDEC30005) +#define NVC5B0_DEC_ERROR_H264_DETECTED_VLD_FAILURE (0xDEC30006) +#define NVC5B0_DEC_ERROR_H264_ERRINTSTART (0xDEC30010) +#define NVC5B0_DEC_ERROR_H264_IQT_ERRINT (0xDEC30011) +#define NVC5B0_DEC_ERROR_H264_MC_ERRINT (0xDEC30012) +#define NVC5B0_DEC_ERROR_H264_MC_IQT_ERRINT (0xDEC30013) +#define NVC5B0_DEC_ERROR_H264_REC_ERRINT (0xDEC30014) +#define NVC5B0_DEC_ERROR_H264_REC_IQT_ERRINT (0xDEC30015) +#define NVC5B0_DEC_ERROR_H264_REC_MC_ERRINT (0xDEC30016) +#define NVC5B0_DEC_ERROR_H264_REC_MC_IQT_ERRINT (0xDEC30017) +#define NVC5B0_DEC_ERROR_H264_DBF_ERRINT (0xDEC30018) +#define NVC5B0_DEC_ERROR_H264_DBF_IQT_ERRINT (0xDEC30019) +#define NVC5B0_DEC_ERROR_H264_DBF_MC_ERRINT (0xDEC3001A) +#define NVC5B0_DEC_ERROR_H264_DBF_MC_IQT_ERRINT (0xDEC3001B) +#define NVC5B0_DEC_ERROR_H264_DBF_REC_ERRINT (0xDEC3001C) +#define NVC5B0_DEC_ERROR_H264_DBF_REC_IQT_ERRINT (0xDEC3001D) +#define NVC5B0_DEC_ERROR_H264_DBF_REC_MC_ERRINT (0xDEC3001E) +#define NVC5B0_DEC_ERROR_H264_DBF_REC_MC_IQT_ERRINT (0xDEC3001F) +#define NVC5B0_DEC_ERROR_H264_PICTURE_INIT (0xDEC30100) +#define NVC5B0_DEC_ERROR_H264_STATEMACHINE_FAILURE (0xDEC30101) +#define NVC5B0_DEC_ERROR_H264_INVALID_CTXID_PIC (0xDEC30901) +#define NVC5B0_DEC_ERROR_H264_INVALID_CTXID_UCODE (0xDEC30902) +#define NVC5B0_DEC_ERROR_H264_INVALID_CTXID_FC (0xDEC30903) +#define NVC5B0_DEC_ERROR_H264_INVALID_CTXID_SLH (0xDEC30904) +#define NVC5B0_DEC_ERROR_H264_INVALID_UCODE_SIZE (0xDEC30905) +#define NVC5B0_DEC_ERROR_H264_INVALID_SLICE_COUNT (0xDEC30906) +#define NVC5B0_DEC_ERROR_MPEG4_APPTIMER_EXPIRED (0xDEC40001) +#define NVC5B0_DEC_ERROR_MPEG4_MVTIMER_EXPIRED (0xDEC40002) +#define NVC5B0_DEC_ERROR_MPEG4_INVALID_TOKEN (0xDEC40003) +#define NVC5B0_DEC_ERROR_MPEG4_SLICEDATA_MISSING (0xDEC40004) +#define NVC5B0_DEC_ERROR_MPEG4_HWERR_INTERRUPT (0xDEC40005) +#define NVC5B0_DEC_ERROR_MPEG4_DETECTED_VLD_FAILURE (0xDEC40006) +#define NVC5B0_DEC_ERROR_MPEG4_TIMEOUT_POLLING_FOR_DATA (0xDEC40007) +#define NVC5B0_DEC_ERROR_MPEG4_PDEC_PIC_END_UNALIGNED (0xDEC40008) +#define NVC5B0_DEC_ERROR_MPEG4_WDTIMER_EXPIRED (0xDEC40009) +#define NVC5B0_DEC_ERROR_MPEG4_ERRINTSTART (0xDEC40010) +#define NVC5B0_DEC_ERROR_MPEG4_IQT_ERRINT (0xDEC40011) +#define NVC5B0_DEC_ERROR_MPEG4_MC_ERRINT (0xDEC40012) +#define NVC5B0_DEC_ERROR_MPEG4_MC_IQT_ERRINT (0xDEC40013) +#define NVC5B0_DEC_ERROR_MPEG4_REC_ERRINT (0xDEC40014) +#define NVC5B0_DEC_ERROR_MPEG4_REC_IQT_ERRINT (0xDEC40015) +#define NVC5B0_DEC_ERROR_MPEG4_REC_MC_ERRINT (0xDEC40016) +#define NVC5B0_DEC_ERROR_MPEG4_REC_MC_IQT_ERRINT (0xDEC40017) +#define NVC5B0_DEC_ERROR_MPEG4_DBF_ERRINT (0xDEC40018) +#define NVC5B0_DEC_ERROR_MPEG4_DBF_IQT_ERRINT (0xDEC40019) +#define NVC5B0_DEC_ERROR_MPEG4_DBF_MC_ERRINT (0xDEC4001A) +#define NVC5B0_DEC_ERROR_MPEG4_DBF_MC_IQT_ERRINT (0xDEC4001B) +#define NVC5B0_DEC_ERROR_MPEG4_DBF_REC_ERRINT (0xDEC4001C) +#define NVC5B0_DEC_ERROR_MPEG4_DBF_REC_IQT_ERRINT (0xDEC4001D) +#define NVC5B0_DEC_ERROR_MPEG4_DBF_REC_MC_ERRINT (0xDEC4001E) +#define NVC5B0_DEC_ERROR_MPEG4_DBF_REC_MC_IQT_ERRINT (0xDEC4001F) +#define NVC5B0_DEC_ERROR_MPEG4_PICTURE_INIT (0xDEC40100) +#define NVC5B0_DEC_ERROR_MPEG4_STATEMACHINE_FAILURE (0xDEC40101) +#define NVC5B0_DEC_ERROR_MPEG4_INVALID_CTXID_PIC (0xDEC40901) +#define NVC5B0_DEC_ERROR_MPEG4_INVALID_CTXID_UCODE (0xDEC40902) +#define NVC5B0_DEC_ERROR_MPEG4_INVALID_CTXID_FC (0xDEC40903) +#define NVC5B0_DEC_ERROR_MPEG4_INVALID_CTXID_SLH (0xDEC40904) +#define NVC5B0_DEC_ERROR_MPEG4_INVALID_UCODE_SIZE (0xDEC40905) +#define NVC5B0_DEC_ERROR_MPEG4_INVALID_SLICE_COUNT (0xDEC40906) + +#ifdef __cplusplus +}; /* extern "C" */ +#endif +#endif // _clc5b0_h diff --git a/libavutil/cle7d0.h b/libavutil/cle7d0.h new file mode 100644 index 0000000000..cefa634164 --- /dev/null +++ b/libavutil/cle7d0.h @@ -0,0 +1,129 @@ +/******************************************************************************* + Copyright (c) 1993-2020, NVIDIA CORPORATION. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + +*******************************************************************************/ + +#ifndef _cle7d0_h_ +#define _cle7d0_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define NVE7D0_VIDEO_NVJPG (0x0000E7D0) + +#define NVE7D0_NOP (0x00000100) +#define NVE7D0_NOP_PARAMETER 31:0 +#define NVE7D0_SET_APPLICATION_ID (0x00000200) +#define NVE7D0_SET_APPLICATION_ID_ID 31:0 +#define NVE7D0_SET_APPLICATION_ID_ID_NVJPG_DECODER (0x00000001) +#define NVE7D0_SET_APPLICATION_ID_ID_NVJPG_ENCODER (0x00000002) +#define NVE7D0_SET_WATCHDOG_TIMER (0x00000204) +#define NVE7D0_SET_WATCHDOG_TIMER_TIMER 31:0 +#define NVE7D0_SEMAPHORE_A (0x00000240) +#define NVE7D0_SEMAPHORE_A_UPPER 7:0 +#define NVE7D0_SEMAPHORE_B (0x00000244) +#define NVE7D0_SEMAPHORE_B_LOWER 31:0 +#define NVE7D0_SEMAPHORE_C (0x00000248) +#define NVE7D0_SEMAPHORE_C_PAYLOAD 31:0 +#define NVE7D0_CTX_SAVE_AREA (0x0000024C) +#define NVE7D0_CTX_SAVE_AREA_OFFSET 27:0 +#define NVE7D0_CTX_SAVE_AREA_CTX_VALID 31:28 +#define NVE7D0_CTX_SWITCH (0x00000250) +#define NVE7D0_CTX_SWITCH_RESTORE 0:0 +#define NVE7D0_CTX_SWITCH_RESTORE_FALSE (0x00000000) +#define NVE7D0_CTX_SWITCH_RESTORE_TRUE (0x00000001) +#define NVE7D0_CTX_SWITCH_RST_NOTIFY 1:1 +#define NVE7D0_CTX_SWITCH_RST_NOTIFY_FALSE (0x00000000) +#define NVE7D0_CTX_SWITCH_RST_NOTIFY_TRUE (0x00000001) +#define NVE7D0_CTX_SWITCH_RESERVED 7:2 +#define NVE7D0_CTX_SWITCH_ASID 23:8 +#define NVE7D0_EXECUTE (0x00000300) +#define NVE7D0_EXECUTE_NOTIFY 0:0 +#define NVE7D0_EXECUTE_NOTIFY_DISABLE (0x00000000) +#define NVE7D0_EXECUTE_NOTIFY_ENABLE (0x00000001) +#define NVE7D0_EXECUTE_NOTIFY_ON 1:1 +#define NVE7D0_EXECUTE_NOTIFY_ON_END (0x00000000) +#define NVE7D0_EXECUTE_NOTIFY_ON_BEGIN (0x00000001) +#define NVE7D0_EXECUTE_AWAKEN 8:8 +#define NVE7D0_EXECUTE_AWAKEN_DISABLE (0x00000000) +#define NVE7D0_EXECUTE_AWAKEN_ENABLE (0x00000001) +#define NVE7D0_SEMAPHORE_D (0x00000304) +#define NVE7D0_SEMAPHORE_D_STRUCTURE_SIZE 0:0 +#define NVE7D0_SEMAPHORE_D_STRUCTURE_SIZE_ONE (0x00000000) +#define NVE7D0_SEMAPHORE_D_STRUCTURE_SIZE_FOUR (0x00000001) +#define NVE7D0_SEMAPHORE_D_AWAKEN_ENABLE 8:8 +#define NVE7D0_SEMAPHORE_D_AWAKEN_ENABLE_FALSE (0x00000000) +#define NVE7D0_SEMAPHORE_D_AWAKEN_ENABLE_TRUE (0x00000001) +#define NVE7D0_SEMAPHORE_D_OPERATION 17:16 +#define NVE7D0_SEMAPHORE_D_OPERATION_RELEASE (0x00000000) +#define NVE7D0_SEMAPHORE_D_OPERATION_RESERVED0 (0x00000001) +#define NVE7D0_SEMAPHORE_D_OPERATION_RESERVED1 (0x00000002) +#define NVE7D0_SEMAPHORE_D_OPERATION_TRAP (0x00000003) +#define NVE7D0_SEMAPHORE_D_FLUSH_DISABLE 21:21 +#define NVE7D0_SEMAPHORE_D_FLUSH_DISABLE_FALSE (0x00000000) +#define NVE7D0_SEMAPHORE_D_FLUSH_DISABLE_TRUE (0x00000001) +#define NVE7D0_SET_CONTROL_PARAMS (0x00000700) +#define NVE7D0_SET_CONTROL_PARAMS_GPTIMER_ON 0:0 +#define NVE7D0_SET_CONTROL_PARAMS_DUMP_CYCLE_COUNT 1:1 +#define NVE7D0_SET_CONTROL_PARAMS_DEBUG_MODE 2:2 +#define NVE7D0_SET_PICTURE_INDEX (0x00000704) +#define NVE7D0_SET_PICTURE_INDEX_INDEX 31:0 +#define NVE7D0_SET_IN_DRV_PIC_SETUP (0x00000708) +#define NVE7D0_SET_IN_DRV_PIC_SETUP_OFFSET 31:0 +#define NVE7D0_SET_OUT_STATUS (0x0000070C) +#define NVE7D0_SET_OUT_STATUS_OFFSET 31:0 +#define NVE7D0_SET_BITSTREAM (0x00000710) +#define NVE7D0_SET_BITSTREAM_OFFSET 31:0 +#define NVE7D0_SET_CUR_PIC (0x00000714) +#define NVE7D0_SET_CUR_PIC_OFFSET 31:0 +#define NVE7D0_SET_CUR_PIC_CHROMA_U (0x00000718) +#define NVE7D0_SET_CUR_PIC_CHROMA_U_OFFSET 31:0 +#define NVE7D0_SET_CUR_PIC_CHROMA_V (0x0000071C) +#define NVE7D0_SET_CUR_PIC_CHROMA_V_OFFSET 31:0 + +#define NVE7D0_ERROR_NONE (0x00000000) +#define NVE7D0_OS_ERROR_EXECUTE_INSUFFICIENT_DATA (0x00000001) +#define NVE7D0_OS_ERROR_SEMAPHORE_INSUFFICIENT_DATA (0x00000002) +#define NVE7D0_OS_ERROR_INVALID_METHOD (0x00000003) +#define NVE7D0_OS_ERROR_INVALID_DMA_PAGE (0x00000004) +#define NVE7D0_OS_ERROR_UNHANDLED_INTERRUPT (0x00000005) +#define NVE7D0_OS_ERROR_EXCEPTION (0x00000006) +#define NVE7D0_OS_ERROR_INVALID_CTXSW_REQUEST (0x00000007) +#define NVE7D0_OS_ERROR_APPLICATION (0x00000008) +#define NVE7D0_OS_INTERRUPT_EXECUTE_AWAKEN (0x00000100) +#define NVE7D0_OS_INTERRUPT_BACKEND_SEMAPHORE_AWAKEN (0x00000200) +#define NVE7D0_OS_INTERRUPT_CTX_ERROR_FBIF (0x00000300) +#define NVE7D0_OS_INTERRUPT_LIMIT_VIOLATION (0x00000400) +#define NVE7D0_OS_INTERRUPT_LIMIT_AND_FBIF_CTX_ERROR (0x00000500) +#define NVE7D0_OS_INTERRUPT_HALT_ENGINE (0x00000600) +#define NVE7D0_OS_INTERRUPT_TRAP_NONSTALL (0x00000700) +#define NVE7D0_OS_INTERRUPT_CTX_SAVE_DONE (0x00000800) +#define NVE7D0_OS_INTERRUPT_CTX_RESTORE_DONE (0x00000900) +#define NVE7D0_ERROR_JPGAPPTIMER_EXPIRED (0x30000001) +#define NVE7D0_ERROR_JPGINVALID_INPUT (0x30000002) +#define NVE7D0_ERROR_JPGHWERR_INTERRUPT (0x30000003) +#define NVE7D0_ERROR_JPGBAD_MAGIC (0x30000004) + +#ifdef __cplusplus +}; /* extern "C" */ +#endif +#endif // _cle7d0_h diff --git a/libavutil/cpu.c b/libavutil/cpu.c index df00bd541f..9d0563b144 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -48,6 +48,9 @@ #if HAVE_UNISTD_H #include #endif +#ifdef __SWITCH__ +#include +#endif #if HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO #include @@ -249,6 +252,10 @@ int av_cpu_count(void) #elif HAVE_WINRT GetNativeSystemInfo(&sysinfo); nb_cpus = sysinfo.dwNumberOfProcessors; +#elif defined(__SWITCH__) + u64 core_mask = 0; + Result rc = svcGetInfo(&core_mask, InfoType_CoreMask, CUR_PROCESS_HANDLE, 0); + nb_cpus = R_SUCCEEDED(rc) ? av_popcount64(core_mask) : 3; #endif if (!atomic_exchange_explicit(&printed, 1, memory_order_relaxed)) diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index fa99a0d8a4..8dd05147a4 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -65,6 +65,9 @@ static const HWContextType * const hw_table[] = { #endif #if CONFIG_VULKAN &ff_hwcontext_type_vulkan, +#endif +#if CONFIG_NVTEGRA + &ff_hwcontext_type_nvtegra, #endif NULL, }; @@ -82,6 +85,7 @@ static const char *const hw_type_names[] = { [AV_HWDEVICE_TYPE_VIDEOTOOLBOX] = "videotoolbox", [AV_HWDEVICE_TYPE_MEDIACODEC] = "mediacodec", [AV_HWDEVICE_TYPE_VULKAN] = "vulkan", + [AV_HWDEVICE_TYPE_NVTEGRA] = "nvtegra", }; typedef struct FFHWDeviceContext { diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index bac30debae..d506281784 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -38,6 +38,7 @@ enum AVHWDeviceType { AV_HWDEVICE_TYPE_MEDIACODEC, AV_HWDEVICE_TYPE_VULKAN, AV_HWDEVICE_TYPE_D3D12VA, + AV_HWDEVICE_TYPE_NVTEGRA, }; /** diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_internal.h index e32b786238..478583abdd 100644 --- a/libavutil/hwcontext_internal.h +++ b/libavutil/hwcontext_internal.h @@ -163,5 +163,6 @@ extern const HWContextType ff_hwcontext_type_vdpau; extern const HWContextType ff_hwcontext_type_videotoolbox; extern const HWContextType ff_hwcontext_type_mediacodec; extern const HWContextType ff_hwcontext_type_vulkan; +extern const HWContextType ff_hwcontext_type_nvtegra; #endif /* AVUTIL_HWCONTEXT_INTERNAL_H */ diff --git a/libavutil/hwcontext_nvtegra.c b/libavutil/hwcontext_nvtegra.c new file mode 100644 index 0000000000..6b72348082 --- /dev/null +++ b/libavutil/hwcontext_nvtegra.c @@ -0,0 +1,1045 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include "config.h" +#include "pixdesc.h" +#include "imgutils.h" +#include "internal.h" +#include "mem.h" +#include "time.h" + +#include "hwcontext.h" +#include "hwcontext_internal.h" + +#include "nvhost_ioctl.h" +#include "nvmap_ioctl.h" +#include "nvtegra_host1x.h" +#include "clb0b6.h" +#include "vic_drv.h" + +#include "hwcontext_nvtegra.h" + +typedef struct NVTegraDevicePriv { + /* The public AVNVTegraDeviceContext */ + AVNVTegraDeviceContext p; + + AVBufferRef *driver_state_ref; + + AVNVTegraJobPool job_pool; + uint32_t vic_setup_off, vic_cmdbuf_off; + + double framerate; + uint32_t dfs_lowcorner; + double dfs_decode_cycles_ema; + double dfs_ema_damping; + int dfs_bitrate_sum; + int dfs_cur_sample, dfs_num_samples; + int64_t dfs_sampling_start_ts, dfs_last_ts_delta; +} NVTegraDevicePriv; + +static const enum AVPixelFormat supported_sw_formats[] = { + AV_PIX_FMT_GRAY8, + AV_PIX_FMT_NV12, + AV_PIX_FMT_P010, + AV_PIX_FMT_YUV420P, +}; + +int av_nvtegra_pixfmt_to_vic(enum AVPixelFormat fmt) { + switch (fmt) { + case AV_PIX_FMT_GRAY8: + return NVB0B6_T_L8; + case AV_PIX_FMT_NV12: + return NVB0B6_T_Y8___U8V8_N420; + case AV_PIX_FMT_YUV420P: + return NVB0B6_T_Y8___U8___V8_N420; + case AV_PIX_FMT_RGB565: + return NVB0B6_T_R5G6B5; + case AV_PIX_FMT_RGB32: + return NVB0B6_T_A8R8G8B8; + case AV_PIX_FMT_BGR32: + return NVB0B6_T_A8B8G8R8; + case AV_PIX_FMT_RGB32_1: + return NVB0B6_T_R8G8B8A8; + case AV_PIX_FMT_BGR32_1: + return NVB0B6_T_B8G8R8A8; + case AV_PIX_FMT_0RGB32: + return NVB0B6_T_X8R8G8B8; + case AV_PIX_FMT_0BGR32: + return NVB0B6_T_X8B8G8R8; + default: + return -1; + } +} + +static inline uint32_t nvtegra_surface_get_width_align(enum AVPixelFormat fmt, const AVComponentDescriptor *comp) { + int step = comp->step; + + if (fmt != AV_PIX_FMT_NVTEGRA) + return 256 / step; /* Pitch linear surfaces must be aligned to 256B for VIC */ + + /* + * GOBs are 64B wide. + * In addition, we use a 32Bx8 cache width in VIC for block linear surfaces. + */ + return 64 / step; +} + +static inline uint32_t nvtegra_surface_get_height_align(enum AVPixelFormat fmt, const AVComponentDescriptor *comp) { + /* Height alignment is in terms of lines, not bytes, therefore we don't divide by the sample step */ + if (fmt != AV_PIX_FMT_NVTEGRA) + return 4; /* We use 64Bx4 cache width in VIC for pitch linear surfaces */ + + /* + * GOBs are 8B high, and we use a GOB height of 2. + * In addition, we use a 32Bx8 cache width in VIC for block linear surfaces. + * We double this requirement to make sure it is respected for the subsampled chroma plane. + */ + return 32; +} + +static int nvtegra_channel_set_freq(AVNVTegraChannel *channel, uint32_t freq) { + int err; +#ifndef __SWITCH__ + err = av_nvtegra_channel_set_clock_rate(channel, channel->module_id, freq); + if (err < 0) + return err; + + err = av_nvtegra_channel_get_clock_rate(channel, channel->module_id, &channel->clock); + if (err < 0) + return err; +#else + err = AVERROR(mmuRequestSetAndWait(&channel->mmu_request, freq, -1)); + if (err < 0) + return err; + + err = AVERROR(mmuRequestGet(&channel->mmu_request, &channel->clock)); + if (err < 0) + return err; +#endif + return 0; +} + +static void nvtegra_device_uninit(AVHWDeviceContext *ctx) { + NVTegraDevicePriv *priv = ctx->hwctx; + AVNVTegraDeviceContext *hwctx = &priv->p; + + av_log(ctx, AV_LOG_DEBUG, "Deinitializing NVTEGRA device\n"); + + av_nvtegra_job_pool_uninit(&priv->job_pool); + + if (hwctx->nvdec_version) { + av_nvtegra_channel_close(&hwctx->nvdec_channel); +#ifdef __SWITCH__ + mmuRequestFinalize(&hwctx->nvdec_channel.mmu_request); +#endif + } + + if (hwctx->nvjpg_version) { + av_nvtegra_channel_close(&hwctx->nvjpg_channel); +#ifdef __SWITCH__ + mmuRequestFinalize(&hwctx->nvjpg_channel.mmu_request); +#endif + } + + av_nvtegra_channel_close(&hwctx->vic_channel); + + av_buffer_unref(&priv->driver_state_ref); +} + +/* + * Hardware modules on the Tegra X1 (see t210.c in l4t kernel sources) + * - nvdec v2.0 + * - nvenc v5.0 + * - nvjpg v1.0 + * - vic v4.0 + */ + +static int nvtegra_device_init(AVHWDeviceContext *ctx) { + NVTegraDevicePriv *priv = ctx->hwctx; + AVNVTegraDeviceContext *hwctx = &priv->p; + + uint32_t vic_map_size; + int err; + + av_log(ctx, AV_LOG_DEBUG, "Initializing NVTEGRA device\n"); + + err = av_nvtegra_channel_open(&hwctx->nvdec_channel, "/dev/nvhost-nvdec"); + if (!err) + hwctx->nvdec_version = AV_NVTEGRA_ENCODE_REV(2,0); + + err = av_nvtegra_channel_open(&hwctx->nvjpg_channel, "/dev/nvhost-nvjpg"); + if (!err) + hwctx->nvjpg_version = AV_NVTEGRA_ENCODE_REV(1,0); + + err = av_nvtegra_channel_open(&hwctx->vic_channel, "/dev/nvhost-vic"); + if (err < 0) + goto fail; + + hwctx->vic_version = AV_NVTEGRA_ENCODE_REV(4,0); + + /* Note: Official code only sets this for the nvdec channel */ + if (hwctx->nvdec_version) { + err = av_nvtegra_channel_set_submit_timeout(&hwctx->nvdec_channel, 1000); + if (err < 0) + goto fail; + } + + if (hwctx->nvjpg_version) { + err = av_nvtegra_channel_set_submit_timeout(&hwctx->nvjpg_channel, 1000); + if (err < 0) + goto fail; + } + + priv->vic_setup_off = 0; + priv->vic_cmdbuf_off = FFALIGN(priv->vic_setup_off + sizeof(VicConfigStruct), + AV_NVTEGRA_MAP_ALIGN); + vic_map_size = FFALIGN(priv->vic_cmdbuf_off + AV_NVTEGRA_MAP_ALIGN, + 0x1000); + + err = av_nvtegra_job_pool_init(&priv->job_pool, &hwctx->vic_channel, vic_map_size, + priv->vic_cmdbuf_off, vic_map_size - priv->vic_cmdbuf_off); + if (err < 0) + goto fail; + +#ifndef __SWITCH__ + hwctx->nvdec_channel.module_id = 0x75; + hwctx->nvjpg_channel.module_id = 0x76; +#else + /* + * The NVHOST_IOCTL_CHANNEL_SET_CLK_RATE ioctl also exists on HOS but the clock rate + * will be reset when the console goes to sleep. + */ + if (hwctx->nvdec_version) { + err = AVERROR(mmuRequestInitialize(&hwctx->nvdec_channel.mmu_request, (MmuModuleId)5, 8, false)); + if (err < 0) + goto fail; + } + + if (hwctx->nvjpg_version) { + err = AVERROR(mmuRequestInitialize(&hwctx->nvjpg_channel.mmu_request, MmuModuleId_Nvjpg, 8, false)); + if (err < 0) + goto fail; + } +#endif + + return 0; + +fail: + nvtegra_device_uninit(ctx); + return err; +} + +static int nvtegra_device_create(AVHWDeviceContext *ctx, const char *device, + AVDictionary *opts, int flags) +{ + NVTegraDevicePriv *priv = ctx->hwctx; + + av_log(ctx, AV_LOG_DEBUG, "Creating NVTEGRA device\n"); + + priv->driver_state_ref = av_nvtegra_driver_init(); + if (!priv->driver_state_ref) { + av_log(ctx, AV_LOG_ERROR, "Failed to create driver context, " + "make sure you are using a Tegra device\n"); + return AVERROR(ENOSYS); + } + + return 0; +} + +static int nvtegra_frames_get_constraints(AVHWDeviceContext *ctx, const void *hwconfig, + AVHWFramesConstraints *constraints) +{ + av_log(ctx, AV_LOG_DEBUG, "Getting frame constraints for NVTEGRA device\n"); + + constraints->valid_sw_formats = av_malloc_array(FF_ARRAY_ELEMS(supported_sw_formats) + 1, + sizeof(*constraints->valid_sw_formats)); + if (!constraints->valid_sw_formats) + return AVERROR(ENOMEM); + + for (int i = 0; i < FF_ARRAY_ELEMS(supported_sw_formats); ++i) + constraints->valid_sw_formats[i] = supported_sw_formats[i]; + constraints->valid_sw_formats[FF_ARRAY_ELEMS(supported_sw_formats)] = AV_PIX_FMT_NONE; + + constraints->valid_hw_formats = av_malloc_array(2, sizeof(*constraints->valid_hw_formats)); + if (!constraints->valid_hw_formats) + return AVERROR(ENOMEM); + + constraints->valid_hw_formats[0] = AV_PIX_FMT_NVTEGRA; + constraints->valid_hw_formats[1] = AV_PIX_FMT_NONE; + + return 0; +} + +static void nvtegra_map_free(void *opaque, uint8_t *data) { + AVNVTegraMap *map = (AVNVTegraMap *)data; + + if (!map) + return; + + av_nvtegra_map_destroy(map); + + av_freep(&map); +} + +static void nvtegra_frame_free(void *opaque, uint8_t *data) { + AVNVTegraFrame *frame = (AVNVTegraFrame *)data; + + if (!frame) + return; + + av_buffer_unref(&frame->map_ref); + + av_freep(&frame); +} + +static AVBufferRef *nvtegra_pool_alloc(void *opaque, size_t size) { + AVHWFramesContext *ctx = opaque; + AVNVTegraDeviceContext *hwctx = &((NVTegraDevicePriv *)ctx->device_ctx->hwctx)->p; + + AVBufferRef *buffer = NULL; + AVNVTegraFrame *frame = NULL; + AVNVTegraMap *map = NULL; + int err; + + av_log(ctx, AV_LOG_DEBUG, "Creating surface from NVTEGRA device\n"); + + map = av_mallocz(sizeof(*map)); + if (!map) + goto fail; + + frame = av_mallocz(sizeof(*frame)); + if (!map) + goto fail; + + /* + * Framebuffers are allocated as CPU-cacheable, since they might get copied from + * during transfer operations. Cache management is done manually. + */ + err = av_nvtegra_map_create(map, &hwctx->nvdec_channel, size, 0x100, + NVMAP_HEAP_CARVEOUT_GENERIC, NVMAP_HANDLE_CACHEABLE); + if (err < 0) + goto fail; + + /* Flush the CPU cache */ + av_nvtegra_map_cache_op(map, NVMAP_CACHE_OP_WB, av_nvtegra_map_get_addr(map), + av_nvtegra_map_get_size(map)); + + frame->map_ref = av_buffer_create((uint8_t *)map, sizeof(*map), nvtegra_map_free, ctx, 0); + if (!frame->map_ref) + goto fail; + + buffer = av_buffer_create((uint8_t *)frame, sizeof(*frame), nvtegra_frame_free, ctx, 0); + if (!buffer) + goto fail; + + return buffer; + +fail: + av_log(ctx, AV_LOG_ERROR, "Failed to create buffer\n"); + nvtegra_frame_free(opaque, (uint8_t *)frame); + return NULL; +} + +static int nvtegra_frames_init(AVHWFramesContext *ctx) { + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(ctx->sw_format); + + uint32_t width_aligned, height_aligned, size; + + av_log(ctx, AV_LOG_DEBUG, "Initializing frame pool for the NVTEGRA device\n"); + + if (!ctx->pool) { + width_aligned = FFALIGN(ctx->width, nvtegra_surface_get_width_align (ctx->format, &desc->comp[0])); + height_aligned = FFALIGN(ctx->height, nvtegra_surface_get_height_align(ctx->format, &desc->comp[0])); + + size = av_image_get_buffer_size(ctx->sw_format, width_aligned, height_aligned, + nvtegra_surface_get_width_align(ctx->format, &desc->comp[0])); + + ffhwframesctx(ctx)->pool_internal = av_buffer_pool_init2(size, ctx, nvtegra_pool_alloc, NULL); + if (!ffhwframesctx(ctx)->pool_internal) + return AVERROR(ENOMEM); + } + + return 0; +} + +static void nvtegra_frames_uninit(AVHWFramesContext *ctx) { + av_log(ctx, AV_LOG_DEBUG, "Deinitializing frame pool for the NVTEGRA device\n"); +} + +static int nvtegra_get_buffer(AVHWFramesContext *ctx, AVFrame *frame) { + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(ctx->sw_format); + + AVNVTegraMap *map; + uint32_t width_aligned, height_aligned; + int err; + + av_log(ctx, AV_LOG_DEBUG, "Getting frame buffer for NVTEGRA device\n"); + + frame->buf[0] = av_buffer_pool_get(ctx->pool); + if (!frame->buf[0]) + return AVERROR(ENOMEM); + + map = av_nvtegra_frame_get_fbuf_map(frame); + + width_aligned = FFALIGN(ctx->width, nvtegra_surface_get_width_align (ctx->format, &desc->comp[0])); + height_aligned = FFALIGN(ctx->height, nvtegra_surface_get_height_align(ctx->format, &desc->comp[0])); + + err = av_image_fill_arrays(frame->data, frame->linesize, av_nvtegra_map_get_addr(map), + ctx->sw_format, width_aligned, height_aligned, + nvtegra_surface_get_width_align(ctx->format, &desc->comp[0])); + if (err < 0) + return err; + + frame->format = AV_PIX_FMT_NVTEGRA; + frame->width = ctx->width; + frame->height = ctx->height; + + return 0; +} + +/* + * Possible frequencies on Icosa and Mariko+, in MHz + * (see tegra210-core-dvfs.c and tegra210b01-core-dvfs.c in l4t kernel sources, respectively): + * for NVDEC: + * 268.8, 384.0, 448.0, 486.4, 550.4, 576.0, 614.4, 652.8, 678.4, 691.2, 716.8 + * 460.8, 499.2, 556.8, 633.6, 652.8, 710.4, 748.8, 787.2, 825.6, 844.8, 883.2, 902.4, 921.6, 940.8, 960.0, 979.2 + * for NVJPG: + * 192.0, 307.2, 345.6, 409.6, 486.4, 524.8, 550.4, 576.0, 588.8, 614.4, 627.2 + * 422.4, 441.6, 499.2, 518.4, 537.6, 556.8, 576.0, 595.2, 614.4, 633.6, 652.8 + */ + +int av_nvtegra_dfs_init(AVHWDeviceContext *ctx, AVNVTegraChannel *channel, int width, int height, + double framerate_hz) +{ + NVTegraDevicePriv *priv = ctx->hwctx; + + uint32_t max_freq, lowcorner; + int num_mbs, err; + + priv->dfs_num_samples = 20; + priv->dfs_ema_damping = 0.1; + + /* + * Initialize low-corner frequency (reproduces official code) + * Framerate might be unavailable (or variable), but this is official logic + */ + num_mbs = width / 16 * height / 16; + if (num_mbs <= 3600) + lowcorner = 100000000; /* 480p */ + else if (num_mbs <= 8160) + lowcorner = 180000000; /* 720p */ + else if (num_mbs <= 32400) + lowcorner = 345000000; /* 1080p */ + else + lowcorner = 576000000; /* 4k */ + + if (framerate_hz >= 0.1 && isfinite(framerate_hz)) + lowcorner = FFMIN(lowcorner, lowcorner * framerate_hz / 30.0); + + priv->framerate = framerate_hz; + priv->dfs_lowcorner = lowcorner; + + av_log(ctx, AV_LOG_DEBUG, "DFS: Initializing lowcorner to %d Hz, using %u samples\n", + priv->dfs_lowcorner, priv->dfs_num_samples); + + /* + * Initialize channel to the max possible frequency (the kernel driver will clamp to an allowed value) + * Note: Official code passes INT_MAX kHz then multiplies by 1000 (to Hz) and converts to u32, + * resulting in this value. + */ + max_freq = (UINT64_C(1)<<32) - 1000 & UINT32_MAX; + + err = nvtegra_channel_set_freq(channel, max_freq); + if (err < 0) + return err; + + priv->dfs_decode_cycles_ema = 0.0; + priv->dfs_bitrate_sum = 0; + priv->dfs_cur_sample = 0; + priv->dfs_sampling_start_ts = av_gettime_relative(); + priv->dfs_last_ts_delta = 0; + + return 0; +} + +int av_nvtegra_dfs_update(AVHWDeviceContext *ctx, AVNVTegraChannel *channel, int bitstream_len, int decode_cycles) { + NVTegraDevicePriv *priv = ctx->hwctx; + + double frame_time, avg; + int64_t now, wl_dt; + uint32_t clock; + int err; + + /* + * Official software implements DFS using a flat average of the decoder pool occupancy. + * We instead use the decode cycles as reported by NVDEC microcode, and the "bitrate" + * (bitstream bits fed to the hardware in a given clock time interval, NOT video time), + * to calculate a suitable frequency, and multiply it by 1.2 for good measure: + * Freq = decode_cycles_per_bit * bits_per_second * 1.2 + */ + + /* Convert to bits */ + bitstream_len *= 8; + + /* Exponential moving average of decode cycles per frame */ + priv->dfs_decode_cycles_ema = priv->dfs_ema_damping * (double)decode_cycles/bitstream_len + + (1.0 - priv->dfs_ema_damping) * priv->dfs_decode_cycles_ema; + + priv->dfs_bitrate_sum += bitstream_len; + priv->dfs_cur_sample = (priv->dfs_cur_sample + 1) % priv->dfs_num_samples; + + err = 0; + + /* Reclock if we collected enough samples */ + if (priv->dfs_cur_sample == 0) { + now = av_gettime_relative(); + wl_dt = now - priv->dfs_sampling_start_ts; + + /* + * Try to filter bad sample sets caused by eg. pausing the video playback. + * We reject if one of these conditions is met: + * - the wall time is over 1.5x the framerate (10Hz is used as fallback if no framerate information is available) + * - the wall time is over 1.5x the ema-damped previous values + */ + + if (priv->framerate >= 0.1 && isfinite(priv->framerate)) + frame_time = 1.0e6 / priv->framerate; + else + frame_time = 0.1e6; + + if ((wl_dt < 1.5 * priv->dfs_num_samples * frame_time) || + ((priv->dfs_last_ts_delta) && (wl_dt < 1.5 * priv->dfs_last_ts_delta))) { + avg = priv->dfs_bitrate_sum * 1e6 / wl_dt; + clock = priv->dfs_decode_cycles_ema * avg * 1.2; + clock = FFMAX(clock, priv->dfs_lowcorner); + + av_log(ctx, AV_LOG_DEBUG, "DFS: %.0f cycles/b (ema), %.0f b/s -> clock %u Hz (lowcorner %u Hz)\n", + priv->dfs_decode_cycles_ema, avg, clock, priv->dfs_lowcorner); + + err = nvtegra_channel_set_freq(channel, clock); + + priv->dfs_last_ts_delta = wl_dt; + } + + priv->dfs_bitrate_sum = 0; + priv->dfs_sampling_start_ts = now; + } + + return err; +} + +int av_nvtegra_dfs_uninit(AVHWDeviceContext *ctx, AVNVTegraChannel *channel) { + return nvtegra_channel_set_freq(channel, 0); +} + +static int nvtegra_transfer_get_formats(AVHWFramesContext *ctx, + enum AVHWFrameTransferDirection dir, + enum AVPixelFormat **formats) +{ + enum AVPixelFormat *fmts; + + av_log(ctx, AV_LOG_DEBUG, "Getting transfer formats for NVTEGRA device\n"); + + fmts = av_malloc_array(2, sizeof(**formats)); + if (!fmts) + return AVERROR(ENOMEM); + + fmts[0] = ctx->sw_format; + fmts[1] = AV_PIX_FMT_NONE; + + *formats = fmts; + return 0; +} + +static inline void nvtegra_cpu_copy_plane(void *dst, int dst_stride, + void *src, int src_stride, int h, bool from) +{ + /* + * Adapted from https://fgiesen.wordpress.com/2011/01/17/texture-tiling-and-swizzling/. + * We process 16x2 bytes at a time. Horizontally, this is the size of a linear atom + * in a 16Bx2 sector, conveniently also the size of a cache line and of a macroblock. + * + * NVDEC always uses a GOB height of 2 (block height of 16, in line with macroblock dimensions). + * The corresponding swizzling pattern is the following: + * y3 y2 y1 y0 x5 x4 x3 x2 x1 x0 + * x: ___x5_______x4____x3 x3 x1 x0 + * y: y3____y2 y1____y0____________ + * + * Addresses for the 4 lower bits can then be copied as-is (16 bytes). + * As a further optimization, the y0 bit is also handled within the same inner loop, + * which halves the total number of iterations. + * + * This function is declared inline with the expectation that the compiler will optimize + * the branches depending on the copy direction. + */ + + __uint128_t *src_ = src, *dst_ = dst, *src_line, *dst_line; + uint32_t ws = src_stride / sizeof(__uint128_t), wd = dst_stride / sizeof(__uint128_t), + w = FFMIN(ws, wd), offs_x = 0, offs_y = 0, offs_line; + uint32_t x_mask = -0x2e, y_mask = 0x2c; + int x, y; + + for (y = 0; y < h; y += 2) { + dst_line = dst_ + (from ? y * wd : offs_y); + src_line = src_ + (from ? offs_y : y * ws); + + offs_line = offs_x; + for (x = 0; x < w; ++x) { + dst_line[from ? x+0 : offs_line+0] = src_line[from ? offs_line+0 : x+0 ]; + dst_line[from ? x+wd : offs_line+1] = src_line[from ? offs_line+1 : x+ws]; + offs_line = (offs_line - x_mask) & x_mask; + } + + offs_y = (offs_y - y_mask) & y_mask; + + /* Wrap into next tile row */ + if (!offs_y) + offs_x += from ? src_stride : dst_stride; + } +} + +static int nvtegra_cpu_transfer_data(AVHWFramesContext *ctx, const AVFrame *dst, const AVFrame *src, + int num_planes, bool from) +{ + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(ctx->sw_format); + const AVFrame *hwframe, *swframe; + AVNVTegraMap *map; + int h, i; + + hwframe = from ? src : dst, swframe = from ? dst : src; + map = av_nvtegra_frame_get_fbuf_map(hwframe); + + if (swframe->format != ctx->sw_format) { + av_log(ctx, AV_LOG_ERROR, "Source and destination must have the same format for cpu transfers\n"); + return AVERROR(EINVAL); + } + + /* If we are transferring from a hardware frame, invalidate the CPU cache which might be stale */ + if (from) { + av_nvtegra_map_cache_op(map, NVMAP_CACHE_OP_INV, + av_nvtegra_map_get_addr(map), av_nvtegra_map_get_size(map)); + } + + /* Align the height to an even size */ + h = FFALIGN(dst->height, 2); + + for (i = 0; i < num_planes; ++i) { + if (map->is_linear) { + av_image_copy_plane(dst->data[i], dst->linesize[i], src->data[i], src->linesize[i], + FFMIN(dst->linesize[i], src->linesize[i]), + h >> (i ? desc->log2_chroma_h : 0)); + } else { + /* + * Instanciate the same inlined function for both destinations, + * giving the compiler the opportunity to remove branching within the copy loops. + * (verified by decompilation at -O1 and higher for both gcc and clang) + */ + if (from) + nvtegra_cpu_copy_plane(dst->data[i], dst->linesize[i], src->data[i], src->linesize[i], + h >> (i ? desc->log2_chroma_h : 0), true); + else + nvtegra_cpu_copy_plane(dst->data[i], dst->linesize[i], src->data[i], src->linesize[i], + h >> (i ? desc->log2_chroma_h : 0), false); + } + } + + /* If we transferred to a hardware frame, flush the CPU cache to make the data visible to hardware engines */ + if (!from) { + av_nvtegra_map_cache_op(map, NVMAP_CACHE_OP_WB, + av_nvtegra_map_get_addr(map), av_nvtegra_map_get_size(map)); + } + + return 0; +} + +static void nvtegra_vic_preprare_config(VicConfigStruct *config, const AVFrame *src, const AVFrame *dst, + enum AVPixelFormat fmt, bool is_16b_chroma) +{ + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt); + bool input_linear = (src->format != AV_PIX_FMT_NVTEGRA) || av_nvtegra_frame_get_fbuf_map(src)->is_linear, + output_linear = (dst->format != AV_PIX_FMT_NVTEGRA) || av_nvtegra_frame_get_fbuf_map(dst)->is_linear; + + /* + * The VIC engine has an undocumented limitation regarding height alignment, + * which should be padded to an even size. + */ + + /* Subsampled dimensions when emulating 16-bit chroma transfers, as input is always NV12 */ + int divider = !is_16b_chroma ? 1 : 2; + int src_width = src->width / divider, src_height = FFALIGN(src->height, 2) / divider, + dst_width = dst->width / divider, dst_height = FFALIGN(dst->height, 2) / divider; + + *config = (VicConfigStruct){ + .pipeConfig = { + .DownsampleHoriz = 1 << 2, /* U9.2 */ + .DownsampleVert = 1 << 2, /* U9.2 */ + }, + .outputConfig = { + .AlphaFillMode = !is_16b_chroma ? NVB0B6_DXVAHD_ALPHA_FILL_MODE_OPAQUE : + NVB0B6_DXVAHD_ALPHA_FILL_MODE_SOURCE_STREAM, + .BackgroundAlpha = 0, + .BackgroundR = 0, + .BackgroundG = 0, + .BackgroundB = 0, + .TargetRectLeft = 0, + .TargetRectRight = dst_width - 1, + .TargetRectTop = 0, + .TargetRectBottom = dst_height - 1, + }, + .outputSurfaceConfig = { + .OutPixelFormat = av_nvtegra_pixfmt_to_vic(fmt), + .OutSurfaceWidth = dst_width - 1, + .OutSurfaceHeight = dst_height - 1, + .OutBlkKind = !output_linear ? NVB0B6_BLK_KIND_GENERIC_16Bx2 : NVB0B6_BLK_KIND_PITCH, + .OutBlkHeight = !output_linear ? 1 : 0, /* GOB height 2 */ + .OutLumaWidth = (dst->linesize[0] / desc->comp[0].step) - 1, + .OutLumaHeight = FFALIGN(dst_height, !output_linear ? 32 : 2) - 1, + .OutChromaWidth = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? + -1 : (dst->linesize[1] / desc->comp[1].step) - 1, + .OutChromaHeight = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? -1 : + (FFALIGN(dst_height, !output_linear ? 32 : 2) >> desc->log2_chroma_h) - 1, + }, + .slotStruct = { + { + .slotConfig = { + .SlotEnable = 1, + .CurrentFieldEnable = 1, + .SoftClampLow = 0, + .SoftClampHigh = 1023, + .PlanarAlpha = 1023, + .ConstantAlpha = 1, + .SourceRectLeft = 0, + .SourceRectRight = (src_width - 1) << 16, /* U14.16 (for subpixel positioning) */ + .SourceRectTop = 0, + .SourceRectBottom = (src_height - 1) << 16, + .DestRectLeft = 0, + .DestRectRight = src_width - 1, + .DestRectTop = 0, + .DestRectBottom = src_height - 1, + }, + .slotSurfaceConfig = { + .SlotPixelFormat = av_nvtegra_pixfmt_to_vic(fmt), + .SlotChromaLocHoriz = ((desc->flags & AV_PIX_FMT_FLAG_RGB) || + src->chroma_location == AVCHROMA_LOC_TOPLEFT || + src->chroma_location == AVCHROMA_LOC_LEFT || + src->chroma_location == AVCHROMA_LOC_BOTTOMLEFT) ? 0 : 1, + .SlotChromaLocVert = ((desc->flags & AV_PIX_FMT_FLAG_RGB) || + src->chroma_location == AVCHROMA_LOC_TOPLEFT || + src->chroma_location == AVCHROMA_LOC_TOP) ? 0 : + (src->chroma_location == AVCHROMA_LOC_LEFT || + src->chroma_location == AVCHROMA_LOC_CENTER) ? 1 : 2, + .SlotBlkKind = !input_linear ? NVB0B6_BLK_KIND_GENERIC_16Bx2 : NVB0B6_BLK_KIND_PITCH, + .SlotBlkHeight = !input_linear ? 1 : 0, /* GOB height 2 */ + .SlotCacheWidth = !input_linear ? 1 : 3, /* 32Bx8 for block, 128Bx2 for pitch */ + .SlotSurfaceWidth = src_width - 1, + .SlotSurfaceHeight = src_height - 1, + .SlotLumaWidth = (src->linesize[0] / desc->comp[0].step) - 1, + .SlotLumaHeight = FFALIGN(src_height, !input_linear ? 32 : 2) - 1, + .SlotChromaWidth = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? + -1 : (src->linesize[1] / desc->comp[1].step) - 1, + .SlotChromaHeight = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? -1 : + (FFALIGN(src_height, !input_linear ? 32 : 2) >> desc->log2_chroma_h) - 1, + }, + }, + }, + }; +} + +static int nvtegra_vic_prepare_cmdbuf(AVHWFramesContext *ctx, AVNVTegraJobPool *pool, AVNVTegraJob *job, + const AVFrame *src, const AVFrame *dst, enum AVPixelFormat fmt, + AVNVTegraMap **plane_maps, uint32_t *plane_offsets, int num_planes) +{ + NVTegraDevicePriv *priv = ctx->device_ctx->hwctx; + AVNVTegraCmdbuf *cmdbuf = &job->cmdbuf; + + AVNVTegraMap *src_maps[4], *dst_maps[4]; + uint32_t src_map_offsets[4], dst_map_offsets[4]; + int src_reloc_type, dst_reloc_type, i, err; + +#define RELOC_VARS(frame) ({ \ + if (frame->format == AV_PIX_FMT_NVTEGRA) { \ + for (i = 0; i < FF_ARRAY_ELEMS(AV_JOIN(frame, _map_offsets)); ++i) { \ + AV_JOIN(frame, _maps )[i] = av_nvtegra_frame_get_fbuf_map(frame); \ + AV_JOIN(frame, _map_offsets)[i] = frame->data[i] - frame->data[0]; \ + } \ + AV_JOIN(frame, _reloc_type) = !av_nvtegra_frame_get_fbuf_map(frame)->is_linear ? \ + NVHOST_RELOC_TYPE_BLOCK_LINEAR : NVHOST_RELOC_TYPE_PITCH_LINEAR; \ + } else { \ + for (i = 0; i < FF_ARRAY_ELEMS(AV_JOIN(frame, _map_offsets)); ++i) { \ + AV_JOIN(frame, _maps )[i] = plane_maps [i]; \ + AV_JOIN(frame, _map_offsets)[i] = plane_offsets[i]; \ + } \ + AV_JOIN(frame, _reloc_type) = NVHOST_RELOC_TYPE_PITCH_LINEAR; \ + } \ +}) + + RELOC_VARS(src); + RELOC_VARS(dst); + + err = av_nvtegra_cmdbuf_begin(cmdbuf, HOST1X_CLASS_VIC); + if (err < 0) + return err; + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVB0B6_VIDEO_COMPOSITOR_SET_CONTROL_PARAMS, + AV_NVTEGRA_VALUE(NVB0B6_VIDEO_COMPOSITOR_SET_CONTROL_PARAMS, CONFIG_STRUCT_SIZE, sizeof(VicConfigStruct) >> 4) | + AV_NVTEGRA_VALUE(NVB0B6_VIDEO_COMPOSITOR_SET_CONTROL_PARAMS, GPTIMER_ON, 1) | + AV_NVTEGRA_VALUE(NVB0B6_VIDEO_COMPOSITOR_SET_CONTROL_PARAMS, FALCON_CONTROL, 1)); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVB0B6_VIDEO_COMPOSITOR_SET_CONFIG_STRUCT_OFFSET, + &job->input_map, priv->vic_setup_off, NVHOST_RELOC_TYPE_DEFAULT); + + switch (fmt) { + /* 16-bit transfer emulation */ + case AV_PIX_FMT_RGB565: + /* Luma transfer */ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE0_LUMA_OFFSET(0), + src_maps[0], src_map_offsets[0], src_reloc_type); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVB0B6_VIDEO_COMPOSITOR_SET_OUTPUT_SURFACE_LUMA_OFFSET, + dst_maps[0], dst_map_offsets[0], dst_reloc_type); + break; + case AV_PIX_FMT_RGB32: + /* Chroma transfer */ + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE0_LUMA_OFFSET(0), + src_maps[1], src_map_offsets[1], src_reloc_type); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVB0B6_VIDEO_COMPOSITOR_SET_OUTPUT_SURFACE_LUMA_OFFSET, + dst_maps[1], dst_map_offsets[1], dst_reloc_type); + break; + + /* Normal transfers */ + case AV_PIX_FMT_GRAY8: + case AV_PIX_FMT_NV12: + case AV_PIX_FMT_YUV420P: + for (i = 0; i < num_planes; ++i) { + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVB0B6_VIDEO_COMPOSITOR_SET_SURFACE0_LUMA_OFFSET(0) + i * sizeof(uint32_t), + src_maps[i], src_map_offsets[i], src_reloc_type); + AV_NVTEGRA_PUSH_RELOC(cmdbuf, NVB0B6_VIDEO_COMPOSITOR_SET_OUTPUT_SURFACE_LUMA_OFFSET + i * sizeof(uint32_t), + dst_maps[i], dst_map_offsets[i], dst_reloc_type); + } + break; + default: + return AVERROR(EINVAL); + } + + AV_NVTEGRA_PUSH_VALUE(cmdbuf, NVB0B6_VIDEO_COMPOSITOR_EXECUTE, + AV_NVTEGRA_ENUM(NVB0B6_VIDEO_COMPOSITOR_EXECUTE, AWAKEN, ENABLE)); + + err = av_nvtegra_cmdbuf_add_syncpt_incr(cmdbuf, pool->channel->syncpt, 0); + if (err < 0) + return err; + + err = av_nvtegra_cmdbuf_end(cmdbuf); + if (err < 0) + return err; + + return 0; +} + +static int nvtegra_vic_copy_plane(AVHWFramesContext *ctx, AVNVTegraJob *job, + const AVFrame *src, const AVFrame *dst, + enum AVPixelFormat fmt, AVNVTegraMap **plane_maps, uint32_t *plane_offsets, + int num_planes, bool is_chroma) +{ + NVTegraDevicePriv *priv = ctx->device_ctx->hwctx; + + uint8_t *mem; + int err; + + mem = av_nvtegra_map_get_addr(&job->input_map); + + nvtegra_vic_preprare_config((VicConfigStruct *)(mem + priv->vic_setup_off), + src, dst, fmt, is_chroma); + + err = av_nvtegra_cmdbuf_clear(&job->cmdbuf); + if (err < 0) + return err; + + err = nvtegra_vic_prepare_cmdbuf(ctx, &priv->job_pool, job, src, dst, fmt, + plane_maps, plane_offsets, num_planes); + if (err < 0) + goto fail; + + err = av_nvtegra_job_submit(&priv->job_pool, job); + if (err < 0) + goto fail; + + err = av_nvtegra_job_wait(&priv->job_pool, job, -1); + if (err < 0) + goto fail; + +fail: + return err; +} + +static int nvtegra_vic_transfer_data(AVHWFramesContext *ctx, const AVFrame *dst, const AVFrame *src, + int num_planes, bool from) +{ + NVTegraDevicePriv *priv = ctx->device_ctx->hwctx; + AVNVTegraDeviceContext *hwctx = &priv->p; + + AVBufferRef *job_ref; + AVNVTegraJob *job; + const AVFrame *swframe; + uint8_t *map_bases[4]; + AVNVTegraMap maps[4] = {0}; + AVNVTegraMap *plane_maps[4]; + uint32_t plane_offsets[4]; + int num_maps, i, j, err; + + swframe = from ? dst : src; + + job_ref = av_nvtegra_job_pool_get(&priv->job_pool); + if (!job_ref) { + err = AVERROR(ENOMEM); + goto fail; + } + + job = (AVNVTegraJob *)job_ref->data; + + /* Create a map for each frame backing buffer */ + for (i = 0; i < FF_ARRAY_ELEMS(maps); num_maps = ++i) { + if (!swframe->buf[i]) + break; + + /* + * In order to avoid a full-frame copy on the CPU, the provided memory + * is mapped into VIC and used directly during the transfer. + * The address and size are aligned to page boundaries. + * Cache management is performed manually to not affect data outside the buffer. + */ + map_bases[i] = (uint8_t *)((uintptr_t)swframe->buf[i]->data & ~0xfff); + err = av_nvtegra_map_from_va(&maps[i], &hwctx->vic_channel, map_bases[i], + swframe->buf[i]->size + ((uintptr_t)swframe->buf[i]->data & 0xfff), + 0x100, NVMAP_HANDLE_CACHEABLE); + if (err < 0) + goto fail; + + err = av_nvtegra_map_map(&maps[i]); + if (err < 0) + goto fail; + + /* Flush-invalidate the CPU cache prior to the transfer */ + av_nvtegra_map_cache_op(&maps[i], NVMAP_CACHE_OP_WB_INV, + ((uint8_t *)av_nvtegra_map_get_addr(&maps[i])) + + ((uintptr_t)swframe->buf[i]->data & 0xfff), + swframe->buf[i]->size); + } + + /* Find the corresponding map object and its offset for each plane */ + for (i = 0; i < num_planes; ++i) { + for (j = 0; j < FF_ARRAY_ELEMS(swframe->buf); ++j) { + if ((swframe->buf[j]->data <= swframe->data[i]) && + (swframe->data[i] < swframe->buf[j]->data + swframe->buf[j]->size)) + break; + } + + plane_maps [i] = &maps[j]; + plane_offsets[i] = swframe->data[i] - map_bases[j]; + } + + /* VIC expects planes in the reversed order */ + if (swframe->format == AV_PIX_FMT_YUV420P) { + FFSWAP(AVNVTegraMap *, plane_maps [1], plane_maps [2]); + FFSWAP(uint32_t, plane_offsets[1], plane_offsets[2]); + } + + /* + * VIC2 does not support 16-bit YUV surfaces (eg. P010, P012, ...). + * Here we emulate them using two separates transfers for the luma and chroma planes + * (16-bit and 32-bit widths respectively). + */ + if (swframe->format == AV_PIX_FMT_P010) { + err = nvtegra_vic_copy_plane(ctx, job, src, dst, AV_PIX_FMT_RGB565, + plane_maps, plane_offsets, 1, false); + if (err < 0) + goto fail; + + err = nvtegra_vic_copy_plane(ctx, job, src, dst, AV_PIX_FMT_RGB32, + plane_maps, plane_offsets, 1, true); + if (err < 0) + goto fail; + } else { + err = nvtegra_vic_copy_plane(ctx, job, src, dst, swframe->format, + plane_maps, plane_offsets, num_planes, false); + if (err < 0) + goto fail; + } + +fail: + for (i = 0; i < num_maps; ++i) { + av_nvtegra_map_unmap(&maps[i]); + av_nvtegra_map_close(&maps[i]); + } + + av_buffer_unref(&job_ref); + + return err; +} + +static int nvtegra_transfer_data(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src) { + const AVFrame *swframe; + bool from; + int num_planes, i; + + from = !dst->hw_frames_ctx; + swframe = from ? dst : src; + + if (swframe->hw_frames_ctx) + return AVERROR(ENOSYS); + + num_planes = av_pix_fmt_count_planes(swframe->format); + + for (i = 0; i < num_planes; ++i) { + if (((uintptr_t)swframe->data[i] & 0xff) || (swframe->linesize[i] & 0xff)) { + av_log(ctx, AV_LOG_WARNING, "Frame address/pitch not aligned to 256, " + "falling back to cpu transfer\n"); + return nvtegra_cpu_transfer_data(ctx, dst, src, num_planes, from); + } + } + + return nvtegra_vic_transfer_data(ctx, dst, src, num_planes, from); +} + +const HWContextType ff_hwcontext_type_nvtegra = { + .type = AV_HWDEVICE_TYPE_NVTEGRA, + .name = "nvtegra", + + .device_hwctx_size = sizeof(NVTegraDevicePriv), + .device_hwconfig_size = 0, + .frames_hwctx_size = 0, + + .device_create = &nvtegra_device_create, + .device_init = &nvtegra_device_init, + .device_uninit = &nvtegra_device_uninit, + + .frames_get_constraints = &nvtegra_frames_get_constraints, + .frames_init = &nvtegra_frames_init, + .frames_uninit = &nvtegra_frames_uninit, + .frames_get_buffer = &nvtegra_get_buffer, + + .transfer_get_formats = &nvtegra_transfer_get_formats, + .transfer_data_to = &nvtegra_transfer_data, + .transfer_data_from = &nvtegra_transfer_data, + + .pix_fmts = (const enum AVPixelFormat[]) { + AV_PIX_FMT_NVTEGRA, + AV_PIX_FMT_NONE, + }, +}; diff --git a/libavutil/hwcontext_nvtegra.h b/libavutil/hwcontext_nvtegra.h new file mode 100644 index 0000000000..7c845951d9 --- /dev/null +++ b/libavutil/hwcontext_nvtegra.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef AVUTIL_HWCONTEXT_NVTEGRA_H +#define AVUTIL_HWCONTEXT_NVTEGRA_H + +#include + +#include "hwcontext.h" +#include "buffer.h" +#include "frame.h" +#include "pixfmt.h" + +#include "nvtegra.h" + +/* + * Encode a hardware revision into a version number + */ +#define AV_NVTEGRA_ENCODE_REV(maj, min) (((maj & 0xff) << 8) | (min & 0xff)) + +/* + * Decode a version number + */ +static inline void av_nvtegra_decode_rev(int rev, int *maj, int *min) { + *maj = (rev >> 8) & 0xff; + *min = (rev >> 0) & 0xff; +} + +/** + * @file + * API-specific header for AV_HWDEVICE_TYPE_NVTEGRA. + * + * For user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs + * with the data pointer set to an AVNVTegraMap. + */ + +typedef struct AVNVTegraDeviceContext { + /* + * Hardware multimedia engines + */ + AVNVTegraChannel nvdec_channel, nvenc_channel, nvjpg_channel, vic_channel; + + /* + * Hardware revisions for associated engines, or 0 if invalid + */ + int nvdec_version, nvenc_version, nvjpg_version, vic_version; +} AVNVTegraDeviceContext; + +typedef struct AVNVTegraFrame { + /* + * Reference to an AVNVTegraMap object + */ + AVBufferRef *map_ref; +} AVNVTegraFrame; + +/* + * Helper to retrieve a map object from the corresponding frame + */ +static inline AVNVTegraMap *av_nvtegra_frame_get_fbuf_map(const AVFrame *frame) { + return (AVNVTegraMap *)((AVNVTegraFrame *)frame->buf[0]->data)->map_ref->data; +} + +/* + * Converts a pixel format to the equivalent code for the VIC engine + */ +int av_nvtegra_pixfmt_to_vic(enum AVPixelFormat fmt); + +/* + * Dynamic frequency scaling routines + */ +int av_nvtegra_dfs_init(AVHWDeviceContext *ctx, AVNVTegraChannel *channel, int width, int height, double framerate_hz); +int av_nvtegra_dfs_update(AVHWDeviceContext *ctx, AVNVTegraChannel *channel, int bitstream_len, int decode_cycles); +int av_nvtegra_dfs_uninit(AVHWDeviceContext *ctx, AVNVTegraChannel *channel); + +#endif /* AVUTIL_HWCONTEXT_NVTEGRA_H */ diff --git a/libavutil/intmath.h b/libavutil/intmath.h index 52e11a8d5f..4c91e14d86 100644 --- a/libavutil/intmath.h +++ b/libavutil/intmath.h @@ -26,7 +26,9 @@ #include "config.h" #include "attributes.h" -#if ARCH_ARM +#if ARCH_AARCH64 +# include "aarch64/intmath.h" +#elif ARCH_ARM # include "arm/intmath.h" #elif ARCH_RISCV # include "riscv/intmath.h" diff --git a/libavutil/nvdec_drv.h b/libavutil/nvdec_drv.h new file mode 100644 index 0000000000..7805588d02 --- /dev/null +++ b/libavutil/nvdec_drv.h @@ -0,0 +1,1858 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 1993-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef __NVDEC_DRV_H_ +#define __NVDEC_DRV_H_ + +// TODO: Many fields can be converted to bitfields to save memory BW +// TODO: Revisit reserved fields for proper alignment and memory savings + +/////////////////////////////////////////////////////////////////////////////// +// NVDEC(MSDEC 5) is a single engine solution, and seperates into VLD, MV, IQT, +// MCFETCH, MC, MCC, REC, DBF, DFBFDMA, HIST etc unit. +// The class(driver to HW) can mainly seperate into VLD parser +// and Decoder part to be consistent with original design. And +// the sequence level info usally set in VLD part. Later codec like +// VP8 won't name in this way. +// MSVLD: Multi-Standard VLD parser. +// +#define ALIGN_UP(v, n) (((v) + ((n)-1)) &~ ((n)-1)) +#define NVDEC_ALIGN(value) ALIGN_UP(value,256) // Align to 256 bytes +#define NVDEC_MAX_MPEG2_SLICE 65536 // at 4096*4096, macroblock count = 65536, 1 macroblock per slice + +#define NVDEC_CODEC_MPEG1 0 +#define NVDEC_CODEC_MPEG2 1 +#define NVDEC_CODEC_VC1 2 +#define NVDEC_CODEC_H264 3 +#define NVDEC_CODEC_MPEG4 4 +#define NVDEC_CODEC_DIVX NVDEC_CODEC_MPEG4 +#define NVDEC_CODEC_VP8 5 +#define NVDEC_CODEC_HEVC 7 +#define NVDEC_CODEC_VP9 9 +#define NVDEC_CODEC_HEVC_PARSER 12 +#define NVDEC_CODEC_AV1 10 + +// AES encryption +enum +{ + AES128_NONE = 0x0, + AES128_CTR = 0x1, + AES128_CBC, + AES128_ECB, + AES128_OFB, + AES128_CTR_LSB16B, + AES128_CLR_AS_ENCRYPT, + AES128_RESERVED = 0x7 +}; + +enum +{ + AES128_CTS_DISABLE = 0x0, + AES128_CTS_ENABLE = 0x1 +}; + +enum +{ + AES128_PADDING_NONE = 0x0, + AES128_PADDING_CARRY_OVER, + AES128_PADDING_RFC2630, + AES128_PADDING_RESERVED = 0x7 +}; + +typedef enum +{ + ENCR_MODE_CTR64 = 0, + ENCR_MODE_CBC = 1, + ENCR_MODE_ECB = 2, + ENCR_MODE_ECB_PARTIAL = 3, + ENCR_MODE_CBC_PARTIAL = 4, + ENCR_MODE_CLEAR_INTO_VPR = 5, // used for clear stream decoding into VPR. + ENCR_MODE_FORCE_INTO_VPR = 6, // used to force decode output into VPR. +} ENCR_MODE; + +// drm_mode configuration +// +// Bit 0:2 AES encryption mode +// Bit 3 CTS (CipherTextStealing) enable/disable +// Bit 4:6 Padding type +// Bit 7:7 Unwrap key enable/disable + +#define AES_MODE_MASK 0x7 +#define AES_CTS_MASK 0x1 +#define AES_PADDING_TYPE_MASK 0x7 +#define AES_UNWRAP_KEY_MASK 0x1 + +#define AES_MODE_SHIFT 0 +#define AES_CTS_SHIFT 3 +#define AES_PADDING_TYPE_SHIFT 4 +#define AES_UNWRAP_KEY_SHIFT 7 + +#define AES_SET_FLAG(M, C, P) ((M & AES_MODE_MASK) << AES_MODE_SHIFT) | \ + ((C & AES_CTS_MASK) << AES_CTS_SHIFT) | \ + ((P & AES_PADDING_TYPE_MASK) << AES_PADDING_TYPE_SHIFT) + +#define AES_GET_FLAG(V, F) ((V & ((AES_##F##_MASK) <<(AES_##F##_SHIFT))) >> (AES_##F##_SHIFT)) + +#define DRM_MODE_MASK 0x7f // Bits 0:6 (0:2 -> AES_MODE, 3 -> AES_CTS, 4:6 -> AES_PADDING_TYPE) +#define AES_GET_DRM_MODE(V) (V & DRM_MODE_MASK) + +enum { DRM_MS_PIFF_CTR = AES_SET_FLAG(AES128_CTR, AES128_CTS_DISABLE, AES128_PADDING_CARRY_OVER) }; +enum { DRM_MS_PIFF_CBC = AES_SET_FLAG(AES128_CBC, AES128_CTS_DISABLE, AES128_PADDING_NONE) }; +enum { DRM_MARLIN_CTR = AES_SET_FLAG(AES128_CTR, AES128_CTS_DISABLE, AES128_PADDING_NONE) }; +enum { DRM_MARLIN_CBC = AES_SET_FLAG(AES128_CBC, AES128_CTS_DISABLE, AES128_PADDING_RFC2630) }; +enum { DRM_WIDEVINE = AES_SET_FLAG(AES128_CBC, AES128_CTS_ENABLE, AES128_PADDING_NONE) }; +enum { DRM_WIDEVINE_CTR = AES_SET_FLAG(AES128_CTR, AES128_CTS_DISABLE, AES128_PADDING_CARRY_OVER) }; +enum { DRM_ULTRA_VIOLET = AES_SET_FLAG(AES128_CTR_LSB16B, AES128_CTS_DISABLE, AES128_PADDING_NONE) }; +enum { DRM_NONE = AES_SET_FLAG(AES128_NONE, AES128_CTS_DISABLE, AES128_PADDING_NONE) }; +enum { DRM_CLR_AS_ENCRYPT = AES_SET_FLAG(AES128_CLR_AS_ENCRYPT, AES128_CTS_DISABLE, AES128_PADDING_NONE)}; + +// SSM entry structure +typedef struct _nvdec_ssm_s { + unsigned int bytes_of_protected_data;//bytes of protected data, follows bytes_of_clear_data. Note: When padding is enabled, it does not include the padding_bytes (1~15), which can be derived by "(16-(bytes_of_protected_data&0xF))&0xF" + unsigned int bytes_of_clear_data:16; //bytes of clear data, located before bytes_of_protected_data + unsigned int skip_byte_blk : 4; //valid when (entry_type==0 && mode = 1) + unsigned int crypt_byte_blk : 4; //valid when (entry_type==0 && mode = 1) + unsigned int skip : 1; //whether this SSM entry should be skipped or not + unsigned int last : 1; //whether this SSM entry is the last one for the whole decoding frame + unsigned int pad : 1; //valid when (entry_type==0 && mode==0 && AES_PADDING_TYPE==AES128_PADDING_RFC2630), 0 for pad_end, 1 for pad_begin + unsigned int mode : 1; //0 for normal mode, 1 for pattern mode + unsigned int entry_type : 1; //0 for DATA, 1 for IV + unsigned int reserved : 3; +} nvdec_ssm_s; /* SubSampleMap, 8bytes */ + +// PASS2 OTF extension structure for SSM support, not exist in nvdec_mpeg4_pic_s (as MPEG4 OTF SW-DRM is not supported yet) +typedef struct _nvdec_pass2_otf_ext_s { + unsigned int ssm_entry_num :16; //specifies how many SSM entries (each in unit of 8 bytes) existed in SET_SUB_SAMPLE_MAP_OFFSET surface + unsigned int ssm_iv_num :16; //specifies how many SSM IV (each in unit of 16 bytes) existed in SET_SUB_SAMPLE_MAP_IV_OFFSET surface + unsigned int real_stream_length; //the real stream length, which is the bitstream length EMD/VLD will get after whole frame SSM processing, sum up of "clear+protected" bytes in SSM entries and removing "non_slice_data/skip". + unsigned int non_slice_data :16; //specifies the first many bytes needed to skip, includes only those of "clear+protected" bytes ("padding" bytes excluded) + unsigned int drm_mode : 7; + unsigned int reserved : 9; +} nvdec_pass2_otf_ext_s; /* 12bytes */ + + +//NVDEC5.0 low latency decoding (partial stream kickoff without context switch), method will reuse HevcSetSliceInfoBufferOffset. +typedef struct _nvdec_substream_entry_s { + unsigned int substream_start_offset; //substream byte start offset to bitstream base address + unsigned int substream_length; //subsream length in byte + unsigned int substream_first_tile_idx : 8; //the first tile index(raster scan in frame) of this substream,max is 255 + unsigned int substream_last_tile_idx : 8; //the last tile index(raster scan in frame) of this substream, max is 255 + unsigned int last_substream_entry_in_frame : 1; //this entry is the last substream entry of this frame + unsigned int reserved : 15; +} nvdec_substream_entry_s;/*low latency without context switch substream entry map,12bytes*/ + + +// GIP + +/* tile border coefficients of filter */ +#define GIP_ASIC_VERT_FILTER_RAM_SIZE 16 /* bytes per pixel */ + +/* BSD control data of current picture at tile border + * 11 * 128 bits per 4x4 tile = 128/(8*4) bytes per row */ +#define GIP_ASIC_BSD_CTRL_RAM_SIZE 4 /* bytes per row */ + +/* 8 dc + 8 to boundary + 6*16 + 2*6*64 + 2*64 -> 63 * 16 bytes */ +#define GIP_ASIC_SCALING_LIST_SIZE (16*64) + +/* tile border coefficients of filter */ +#define GIP_ASIC_VERT_SAO_RAM_SIZE 16 /* bytes per pixel */ + +/* max number of tiles times width and height (2 bytes each), + * rounding up to next 16 bytes boundary + one extra 16 byte + * chunk (HW guys wanted to have this) */ +#define GIP_ASIC_TILE_SIZE ((20*22*2*2+16+15) & ~0xF) + +/* Segment map uses 32 bytes / CTB */ +#define GIP_ASIC_VP9_CTB_SEG_SIZE 32 + +// HEVC Filter FG buffer +#define HEVC_DBLK_TOP_SIZE_IN_SB16 ALIGN_UP(632, 128) // ctb16 + 444 +#define HEVC_DBLK_TOP_BUF_SIZE(w) NVDEC_ALIGN( (ALIGN_UP(w,16)/16 + 2) * HEVC_DBLK_TOP_SIZE_IN_SB16) // 8K: 1285*256 + +#define HEVC_DBLK_LEFT_SIZE_IN_SB16 ALIGN_UP(506, 128) // ctb16 + 444 +#define HEVC_DBLK_LEFT_BUF_SIZE(h) NVDEC_ALIGN( (ALIGN_UP(h,16)/16 + 2) * HEVC_DBLK_LEFT_SIZE_IN_SB16) // 8K: 1028*256 + +#define HEVC_SAO_LEFT_SIZE_IN_SB16 ALIGN_UP(713, 128) // ctb16 + 444 +#define HEVC_SAO_LEFT_BUF_SIZE(h) NVDEC_ALIGN( (ALIGN_UP(h,16)/16 + 2) * HEVC_SAO_LEFT_SIZE_IN_SB16) // 8K: 1542*256 + +// VP9 Filter FG buffer +#define VP9_DBLK_TOP_SIZE_IN_SB64 ALIGN_UP(2000, 128) // 420 +#define VP9_DBLK_TOP_BUF_SIZE(w) NVDEC_ALIGN( (ALIGN_UP(w,64)/64 + 2) * VP9_DBLK_TOP_SIZE_IN_SB64) // 8K: 1040*256 + +#define VP9_DBLK_LEFT_SIZE_IN_SB64 ALIGN_UP(1600, 128) // 420 +#define VP9_DBLK_LEFT_BUF_SIZE(h) NVDEC_ALIGN( (ALIGN_UP(h,64)/64 + 2) * VP9_DBLK_LEFT_SIZE_IN_SB64) // 8K: 845*256 + +// VP9 Hint Dump Buffer +#define VP9_HINT_DUMP_SIZE_IN_SB64 ((64*64)/(4*4)*8) // 8 bytes per CU, 256 CUs(2048 bytes) per SB64 +#define VP9_HINT_DUMP_SIZE(w, h) NVDEC_ALIGN(VP9_HINT_DUMP_SIZE_IN_SB64*((w+63)/64)*((h+63)/64)) + +// used for ecdma debug +typedef struct _nvdec_ecdma_config_s +{ + unsigned int ecdma_enable; // enable/disable ecdma + unsigned short ecdma_blk_x_src; // src start position x , it's 64x aligned + unsigned short ecdma_blk_y_src; // src start position y , it's 8x aligned + unsigned short ecdma_blk_x_dst; // dst start position x , it's 64x aligned + unsigned short ecdma_blk_y_dst; // dst start position y , it's 8x aligned + unsigned short ref_pic_idx; // ref(src) picture index , used to derived source picture base address + unsigned short boundary0_top; // src insided tile/partition region top boundary + unsigned short boundary0_bottom; // src insided tile/partition region bottom boundary + unsigned short boundary1_left; // src insided tile/partition region left boundary + unsigned short boundary1_right; // src insided tile/partition region right boundary + unsigned char blk_copy_flag; // blk_copy enable flag. + // if it's 1 ,ctb_size ==3,ecdma_blk_x_src == boundary1_left and ecdma_blk_y_src == boundary0_top ; + // if it's 0 ,ecdma_blk_x_src == ecdma_blk_x_dst and ecdma_blk_y_src == ecdma_blk_y_dst; + unsigned char ctb_size; // ctb_size .0:64x64,1:32x32,2:16x16,3:8x8 +} nvdec_ecdma_config_s; + +typedef struct _nvdec_status_hevc_s +{ + unsigned int frame_status_intra_cnt; //Intra block counter, in unit of 8x8 block, IPCM block included + unsigned int frame_status_inter_cnt; //Inter block counter, in unit of 8x8 block, SKIP block included + unsigned int frame_status_skip_cnt; //Skip block counter, in unit of 4x4 block, blocks having NO/ZERO texture/coeff data + unsigned int frame_status_fwd_mvx_cnt; //ABS sum of forward MVx, one 14bit MVx(integer) per 4x4 block + unsigned int frame_status_fwd_mvy_cnt; //ABS sum of forward MVy, one 14bit MVy(integer) per 4x4 block + unsigned int frame_status_bwd_mvx_cnt; //ABS sum of backward MVx, one 14bit MVx(integer) per 4x4 block + unsigned int frame_status_bwd_mvy_cnt; //ABS sum of backward MVy, one 14bit MVy(integer) per 4x4 block + unsigned int error_ctb_pos; //[15:0] error ctb position in Y direction, [31:16] error ctb position in X direction + unsigned int error_slice_pos; //[15:0] error slice position in Y direction, [31:16] error slice position in X direction +} nvdec_status_hevc_s; + +typedef struct _nvdec_status_vp9_s +{ + unsigned int frame_status_intra_cnt; //Intra block counter, in unit of 8x8 block, IPCM block included + unsigned int frame_status_inter_cnt; //Inter block counter, in unit of 8x8 block, SKIP block included + unsigned int frame_status_skip_cnt; //Skip block counter, in unit of 4x4 block, blocks having NO/ZERO texture/coeff data + unsigned int frame_status_fwd_mvx_cnt; //ABS sum of forward MVx, one 14bit MVx(integer) per 4x4 block + unsigned int frame_status_fwd_mvy_cnt; //ABS sum of forward MVy, one 14bit MVy(integer) per 4x4 block + unsigned int frame_status_bwd_mvx_cnt; //ABS sum of backward MVx, one 14bit MVx(integer) per 4x4 block + unsigned int frame_status_bwd_mvy_cnt; //ABS sum of backward MVy, one 14bit MVy(integer) per 4x4 block + unsigned int error_ctb_pos; //[15:0] error ctb position in Y direction, [31:16] error ctb position in X direction + unsigned int error_slice_pos; //[15:0] error slice position in Y direction, [31:16] error slice position in X direction +} nvdec_status_vp9_s; + +typedef struct _nvdec_status_s +{ + unsigned int mbs_correctly_decoded; // total numers of correctly decoded macroblocks + unsigned int mbs_in_error; // number of error macroblocks. + unsigned int cycle_count; // total cycles taken for execute. read from PERF_DECODE_FRAME_V register + unsigned int error_status; // report error if any + union + { + nvdec_status_hevc_s hevc; + nvdec_status_vp9_s vp9; + }; + unsigned int slice_header_error_code; // report error in slice header + +} nvdec_status_s; + +// per 16x16 block, used in hevc/vp9 surface of SetExternalMVBufferOffset when error_external_mv_en = 1 +typedef struct _external_mv_s +{ + int mvx : 14; //integrate pixel precision + int mvy : 14; //integrate pixel precision + unsigned int refidx : 4; +} external_mv_s; + +// HEVC +typedef struct _nvdec_hevc_main10_444_ext_s +{ + unsigned int transformSkipRotationEnableFlag : 1; //sps extension for transform_skip_rotation_enabled_flag + unsigned int transformSkipContextEnableFlag : 1; //sps extension for transform_skip_context_enabled_flag + unsigned int intraBlockCopyEnableFlag :1; //sps intraBlockCopyEnableFlag, always 0 before spec define it + unsigned int implicitRdpcmEnableFlag : 1; //sps implicit_rdpcm_enabled_flag + unsigned int explicitRdpcmEnableFlag : 1; //sps explicit_rdpcm_enabled_flag + unsigned int extendedPrecisionProcessingFlag : 1; //sps extended_precision_processing_flag,always 0 in current profile + unsigned int intraSmoothingDisabledFlag : 1; //sps intra_smoothing_disabled_flag + unsigned int highPrecisionOffsetsEnableFlag :1; //sps high_precision_offsets_enabled_flag + unsigned int fastRiceAdaptationEnableFlag: 1; //sps fast_rice_adaptation_enabled_flag + unsigned int cabacBypassAlignmentEnableFlag : 1; //sps cabac_bypass_alignment_enabled_flag, always 0 in current profile + unsigned int sps_444_extension_reserved : 22; //sps reserve for future extension + + unsigned int log2MaxTransformSkipSize : 4 ; //pps extension log2_max_transform_skip_block_size_minus2, 0...5 + unsigned int crossComponentPredictionEnableFlag: 1; //pps cross_component_prediction_enabled_flag + unsigned int chromaQpAdjustmentEnableFlag:1; //pps chroma_qp_adjustment_enabled_flag + unsigned int diffCuChromaQpAdjustmentDepth:2; //pps diff_cu_chroma_qp_adjustment_depth, 0...3 + unsigned int chromaQpAdjustmentTableSize:3; //pps chroma_qp_adjustment_table_size_minus1+1, 1...6 + unsigned int log2SaoOffsetScaleLuma:3; //pps log2_sao_offset_scale_luma, max(0,bitdepth-10),maxBitdepth 16 for future. + unsigned int log2SaoOffsetScaleChroma: 3; //pps log2_sao_offset_scale_chroma + unsigned int pps_444_extension_reserved : 15; //pps reserved + char cb_qp_adjustment[6]; //-[12,+12] + char cr_qp_adjustment[6]; //-[12,+12] + unsigned int HevcFltAboveOffset; // filter above offset respect to filter buffer, 256 bytes unit + unsigned int HevcSaoAboveOffset; // sao above offset respect to filter buffer, 256 bytes unit +} nvdec_hevc_main10_444_ext_s; + +typedef struct _nvdec_hevc_pic_v1_s +{ + // New fields + //hevc main10 444 extensions + nvdec_hevc_main10_444_ext_s hevc_main10_444_ext; + + //HEVC skip bytes from beginning setting for secure + //it is different to the sw_hdr_skip_length who skips the middle of stream of + //the slice header which is parsed by driver + unsigned int sw_skip_start_length : 14; + unsigned int external_ref_mem_dis : 1; + unsigned int error_recovery_start_pos : 2; //0: from start of frame, 1: from start of slice segment, 2: from error detected ctb, 3: reserved + unsigned int error_external_mv_en : 1; + unsigned int reserved0 : 14; + // Reserved bits padding +} nvdec_hevc_pic_v1_s; + +//No versioning in structure: NVDEC2 (T210 and GM206) +//version v1 : NVDEC3 (T186 and GP100) +//version v2 : NVDEC3.1 (GP10x) + +typedef struct _nvdec_hevc_pic_v2_s +{ + // mv-hevc field + unsigned int mv_hevc_enable :1; + unsigned int nuh_layer_id :6; + unsigned int default_ref_layers_active_flag :1; + unsigned int NumDirectRefLayers :6; + unsigned int max_one_active_ref_layer_flag :1; + unsigned int NumActiveRefLayerPics :6; + unsigned int poc_lsb_not_present_flag :1; + unsigned int reserved0 :10; +} nvdec_hevc_pic_v2_s; + +typedef struct _nvdec_hevc_pic_v3_s +{ + // slice level decoding + unsigned int slice_decoding_enable:1;//1: enable slice level decoding + unsigned int slice_ec_enable:1; //1: enable slice error concealment. When slice_ec_enable=1,slice_decoding_enable must be 1; + unsigned int slice_ec_mv_type:2; //0: zero mv; 1: co-located mv; 2: external mv; + unsigned int err_detected_sw:1; //1: indicate sw/driver has detected error already in frame kick mode + unsigned int slice_ec_slice_type:2; //0: B slice; 1: P slice ; others: reserved + unsigned int slice_strm_recfg_en:1; //enable slice bitstream re-configure or not ; + unsigned int reserved:24; + unsigned int HevcSliceEdgeOffset;// slice edge buffer offset which repsect to filter buffer ,256 bytes as one unit +}nvdec_hevc_pic_v3_s; + +typedef struct _nvdec_hevc_pic_s +{ + //The key/IV addr must be 128bit alignment + unsigned int wrapped_session_key[4]; //session keys + unsigned int wrapped_content_key[4]; //content keys + unsigned int initialization_vector[4]; //Ctrl64 initial vector + // hevc_bitstream_data_info + unsigned int stream_len; // stream length in one frame + unsigned int enable_encryption; // flag to enable/disable encryption + unsigned int key_increment : 6; // added to content key after unwrapping + unsigned int encryption_mode : 4; + unsigned int key_slot_index : 4; + unsigned int ssm_en : 1; + unsigned int enable_histogram : 1; // histogram stats output enable + unsigned int enable_substream_decoding: 1; //frame substream kickoff without context switch + unsigned int reserved0 :15; + + // Driver may or may not use based upon need. + // If 0 then default value of 1<<27 = 298ms @ 450MHz will be used in ucode. + // Driver can send this value based upon resolution using the formula: + // gptimer_timeout_value = 3 * (cycles required for one frame) + unsigned int gptimer_timeout_value; + + // general + unsigned char tileformat : 2 ; // 0: TBL; 1: KBL; 2: Tile16x16 + unsigned char gob_height : 3 ; // Set GOB height, 0: GOB_2, 1: GOB_4, 2: GOB_8, 3: GOB_16, 4: GOB_32 (NVDEC3 onwards) + unsigned char reserverd_surface_format : 3 ; + unsigned char sw_start_code_e; // 0: stream doesn't contain start codes,1: stream contains start codes + unsigned char disp_output_mode; // 0: Rec.709 8 bit, 1: Rec.709 10 bit, 2: Rec.709 10 bits -> 8 bit, 3: Rec.2020 10 bit -> 8 bit + unsigned char reserved1; + unsigned int framestride[2]; // frame buffer stride for luma and chroma + unsigned int colMvBuffersize; // collocated MV buffer size of one picture ,256 bytes unit + unsigned int HevcSaoBufferOffset; // sao buffer offset respect to filter buffer ,256 bytes unit . + unsigned int HevcBsdCtrlOffset; // bsd buffer offset respect to filter buffer ,256 bytes unit . + // sps + unsigned short pic_width_in_luma_samples; // :15, 48(?)..16384, multiple of 8 (48 is smallest width supported by NVDEC for CTU size 16x16) + unsigned short pic_height_in_luma_samples; // :15, 8..16384, multiple of 8 + unsigned int chroma_format_idc : 4; // always 1 (=4:2:0) + unsigned int bit_depth_luma : 4; // 8..12 + unsigned int bit_depth_chroma : 4; + unsigned int log2_min_luma_coding_block_size : 4; // 3..6 + unsigned int log2_max_luma_coding_block_size : 4; // 3..6 + unsigned int log2_min_transform_block_size : 4; // 2..5 + unsigned int log2_max_transform_block_size : 4; // 2..5 + unsigned int reserved2 : 4; + + unsigned int max_transform_hierarchy_depth_inter : 3; // 0..4 + unsigned int max_transform_hierarchy_depth_intra : 3; // 0..4 + unsigned int scalingListEnable : 1; // + unsigned int amp_enable_flag : 1; // + unsigned int sample_adaptive_offset_enabled_flag : 1; // + unsigned int pcm_enabled_flag : 1; // + unsigned int pcm_sample_bit_depth_luma : 4; // + unsigned int pcm_sample_bit_depth_chroma : 4; + unsigned int log2_min_pcm_luma_coding_block_size : 4; // + unsigned int log2_max_pcm_luma_coding_block_size : 4; // + unsigned int pcm_loop_filter_disabled_flag : 1; // + unsigned int sps_temporal_mvp_enabled_flag : 1; // + unsigned int strong_intra_smoothing_enabled_flag : 1; // + unsigned int reserved3 : 3; + // pps + unsigned int dependent_slice_segments_enabled_flag : 1; // + unsigned int output_flag_present_flag : 1; // + unsigned int num_extra_slice_header_bits : 3; // 0..7 (normally 0) + unsigned int sign_data_hiding_enabled_flag : 1; // + unsigned int cabac_init_present_flag : 1; // + unsigned int num_ref_idx_l0_default_active : 4; // 1..15 + unsigned int num_ref_idx_l1_default_active : 4; // 1..15 + unsigned int init_qp : 7; // 0..127, support higher bitdepth + unsigned int constrained_intra_pred_flag : 1; // + unsigned int transform_skip_enabled_flag : 1; // + unsigned int cu_qp_delta_enabled_flag : 1; // + unsigned int diff_cu_qp_delta_depth : 2; // 0..3 + unsigned int reserved4 : 5; // + + char pps_cb_qp_offset ; // -12..12 + char pps_cr_qp_offset ; // -12..12 + char pps_beta_offset ; // -12..12 + char pps_tc_offset ; // -12..12 + unsigned int pps_slice_chroma_qp_offsets_present_flag : 1; // + unsigned int weighted_pred_flag : 1; // + unsigned int weighted_bipred_flag : 1; // + unsigned int transquant_bypass_enabled_flag : 1; // + unsigned int tiles_enabled_flag : 1; // (redundant: = num_tile_columns_minus1!=0 || num_tile_rows_minus1!=0) + unsigned int entropy_coding_sync_enabled_flag : 1; // + unsigned int num_tile_columns : 5; // 0..20 + unsigned int num_tile_rows : 5; // 0..22 + unsigned int loop_filter_across_tiles_enabled_flag : 1; // + unsigned int loop_filter_across_slices_enabled_flag : 1; // + unsigned int deblocking_filter_control_present_flag : 1; // + unsigned int deblocking_filter_override_enabled_flag : 1; // + unsigned int pps_deblocking_filter_disabled_flag : 1; // + unsigned int lists_modification_present_flag : 1; // + unsigned int log2_parallel_merge_level : 3; // 2..4 + unsigned int slice_segment_header_extension_present_flag : 1; // (normally 0) + unsigned int reserved5 : 6; + + // reference picture related + unsigned char num_ref_frames; + unsigned char reserved6; + unsigned short longtermflag; // long term flag for refpiclist.bit 15 for picidx 0, bit 14 for picidx 1,... + unsigned char initreflistidxl0[16]; // :5, [refPicidx] 0..15 + unsigned char initreflistidxl1[16]; // :5, [refPicidx] 0..15 + short RefDiffPicOrderCnts[16]; // poc diff between current and reference pictures .[-128,127] + // misc + unsigned char IDR_picture_flag; // idr flag for current picture + unsigned char RAP_picture_flag; // rap flag for current picture + unsigned char curr_pic_idx; // current picture store buffer index,used to derive the store addess of frame buffer and MV + unsigned char pattern_id; // used for dithering to select between 2 tables + unsigned short sw_hdr_skip_length; // reference picture inititial related syntax elements(SE) bits in slice header. + // those SE only decoding once in driver,related bits will flush in HW + unsigned short reserved7; + + // used for ecdma debug + nvdec_ecdma_config_s ecdma_cfg; + + //DXVA on windows + unsigned int separate_colour_plane_flag : 1; + unsigned int log2_max_pic_order_cnt_lsb_minus4 : 4; //0~12 + unsigned int num_short_term_ref_pic_sets : 7 ; //0~64 + unsigned int num_long_term_ref_pics_sps : 6; //0~32 + unsigned int bBitParsingDisable : 1 ; //disable parsing + unsigned int num_delta_pocs_of_rps_idx : 8; + unsigned int long_term_ref_pics_present_flag : 1; + unsigned int reserved_dxva : 4; + //the number of bits for short_term_ref_pic_set()in slice header,dxva API + unsigned int num_bits_short_term_ref_pics_in_slice; + + // New additions + nvdec_hevc_pic_v1_s v1; + nvdec_hevc_pic_v2_s v2; + nvdec_hevc_pic_v3_s v3; + nvdec_pass2_otf_ext_s ssm; + +} nvdec_hevc_pic_s; + +//hevc slice info class +typedef struct _hevc_slice_info_s { + unsigned int first_flag :1;//first slice(s) of frame,must valid for slice EC + unsigned int err_flag :1;//error slice(s) .optional info for EC + unsigned int last_flag :1;//last slice segment(s) of frame,this bit is must be valid when slice_strm_recfg_en==1 or slice_ec==1 + unsigned int conceal_partial_slice :1; // indicate do partial slice error conealment for packet loss case + unsigned int available :1; // indicate the slice bitstream is available. + unsigned int reserved0 :7; + unsigned int ctb_count :20;// ctbs counter inside slice(s) .must valid for slice EC + unsigned int bs_offset; //slice(s) bitstream offset in bitstream buffer (in byte unit) + unsigned int bs_length; //slice(s) bitstream length. It is sum of aligned size and skip size and valid slice bitstream size. + unsigned short start_ctbx; //slice start ctbx ,it's optional,HW can output it in previous slice decoding. + //but this is one check points for error + unsigned short start_ctby; //slice start ctby + } hevc_slice_info_s; + + +//hevc slice ctx class +//slice pos and next slice address +typedef struct _slice_edge_ctb_pos_ctx_s { + unsigned int next_slice_pos_ctbxy; //2d address in raster scan + unsigned int next_slice_segment_addr; //1d address in tile scan +}slice_edge_ctb_pos_ctx_s; + +// next slice's first ctb located tile related information +typedef struct _slice_edge_tile_ctx_s { + unsigned int tileInfo1;// Misc tile info includes tile width and tile height and tile col and tile row + unsigned int tileInfo2;// Misc tile info includes tile start ctbx and start ctby and tile index + unsigned int tileInfo3;// Misc tile info includes ctb pos inside tile +} slice_edge_tile_ctx_s; + +//frame level stats +typedef struct _slice_edge_stats_ctx_s { + unsigned int frame_status_intra_cnt;// frame stats for intra block count + unsigned int frame_status_inter_cnt;// frame stats for inter block count + unsigned int frame_status_skip_cnt;// frame stats for skip block count + unsigned int frame_status_fwd_mvx_cnt;// frame stats for sum of abs fwd mvx + unsigned int frame_status_fwd_mvy_cnt;// frame stats for sum of abs fwd mvy + unsigned int frame_status_bwd_mvx_cnt;// frame stats for sum of abs bwd mvx + unsigned int frame_status_bwd_mvy_cnt;// frame stats for sum of abs bwd mvy + unsigned int frame_status_mv_cnt_ext;// extension bits of sum of abs mv to keep full precision. +}slice_edge_stats_ctx_s; + +//ctx of vpc_edge unit for tile left +typedef struct _slice_vpc_edge_ctx_s { + unsigned int reserved; +}slice_vpc_edge_ctx_s; + +//ctx of vpc_main unit +typedef struct _slice_vpc_main_ctx_s { + unsigned int reserved; +} slice_vpc_main_ctx_s; + +//hevc slice edge ctx class +typedef struct _slice_edge_ctx_s { + //ctb pos + slice_edge_ctb_pos_ctx_s slice_ctb_pos_ctx; + // stats + slice_edge_stats_ctx_s slice_stats_ctx; + // tile info + slice_edge_tile_ctx_s slice_tile_ctx; + //vpc_edge + slice_vpc_edge_ctx_s slice_vpc_edge_ctx; + //vpc_main + slice_vpc_main_ctx_s slice_vpc_main_ctx; +} slice_edge_ctx_s; + +typedef struct _nvdec_hevc_scaling_list_s { + unsigned char ScalingListDCCoeff16x16[6]; + unsigned char ScalingListDCCoeff32x32[2]; + unsigned char reserved0[8]; + + unsigned char ScalingList4x4[6][16]; + unsigned char ScalingList8x8[6][64]; + unsigned char ScalingList16x16[6][64]; + unsigned char ScalingList32x32[2][64]; +} nvdec_hevc_scaling_list_s; + + +//vp9 + +typedef struct _nvdec_vp9_pic_v1_s +{ + // New fields + // new_var : xx; // for variables with expanded bitlength, comment on why the new bit legth is required + // Reserved bits for padding and/or non-HW specific functionality + unsigned int Vp9FltAboveOffset; // filter above offset respect to filter buffer, 256 bytes unit + unsigned int external_ref_mem_dis : 1; + unsigned int bit_depth : 4; + unsigned int error_recovery_start_pos : 2; //0: from start of frame, 1: from start of slice segment, 2: from error detected ctb, 3: reserved + unsigned int error_external_mv_en : 1; + unsigned int Reserved0 : 24; +} nvdec_vp9_pic_v1_s; + +enum VP9_FRAME_SFC_ID +{ + VP9_LAST_FRAME_SFC = 0, + VP9_GOLDEN_FRAME_SFC, + VP9_ALTREF_FRAME_SFC, + VP9_CURR_FRAME_SFC +}; + +typedef struct _nvdec_vp9_pic_s +{ + // vp9_bitstream_data_info + //Key and IV address must 128bit alignment + unsigned int wrapped_session_key[4]; //session keys + unsigned int wrapped_content_key[4]; //content keys + unsigned int initialization_vector[4]; //Ctrl64 initial vector + unsigned int stream_len; // stream length in one frame + unsigned int enable_encryption; // flag to enable/disable encryption + unsigned int key_increment : 6; // added to content key after unwrapping + unsigned int encryption_mode : 4; + unsigned int sw_hdr_skip_length :14; //vp9 skip bytes setting for secure + unsigned int key_slot_index : 4; + unsigned int ssm_en : 1; + unsigned int enable_histogram : 1; // histogram stats output enable + unsigned int reserved0 : 2; + + // Driver may or may not use based upon need. + // If 0 then default value of 1<<27 = 298ms @ 450MHz will be used in ucode. + // Driver can send this value based upon resolution using the formula: + // gptimer_timeout_value = 3 * (cycles required for one frame) + unsigned int gptimer_timeout_value; + + //general + unsigned char tileformat : 2 ; // 0: TBL; 1: KBL; 2: Tile16x16 + unsigned char gob_height : 3 ; // Set GOB height, 0: GOB_2, 1: GOB_4, 2: GOB_8, 3: GOB_16, 4: GOB_32 (NVDEC3 onwards) + unsigned char reserverd_surface_format : 3 ; + unsigned char reserved1[3]; + unsigned int Vp9BsdCtrlOffset; // bsd buffer offset respect to filter buffer ,256 bytes unit . + + + //ref_last dimensions + unsigned short ref0_width; //ref_last coded width + unsigned short ref0_height; //ref_last coded height + unsigned short ref0_stride[2]; //ref_last stride + + //ref_golden dimensions + unsigned short ref1_width; //ref_golden coded width + unsigned short ref1_height; //ref_golden coded height + unsigned short ref1_stride[2]; //ref_golden stride + + //ref_alt dimensions + unsigned short ref2_width; //ref_alt coded width + unsigned short ref2_height; //ref_alt coded height + unsigned short ref2_stride[2]; //ref_alt stride + + + /* Current frame dimensions */ + unsigned short width; //pic width + unsigned short height; //pic height + unsigned short framestride[2]; // frame buffer stride for luma and chroma + + unsigned char keyFrame :1; + unsigned char prevIsKeyFrame:1; + unsigned char resolutionChange:1; + unsigned char errorResilient:1; + unsigned char prevShowFrame:1; + unsigned char intraOnly:1; + unsigned char reserved2 : 2; + + /* DCT coefficient partitions */ + //unsigned int offsetToDctParts; + + unsigned char reserved3[3]; + //unsigned char activeRefIdx[3];//3 bits + //unsigned char refreshFrameFlags; + //unsigned char refreshEntropyProbs; + //unsigned char frameParallelDecoding; + //unsigned char resetFrameContext; + + unsigned char refFrameSignBias[4]; + char loopFilterLevel;//6 bits + char loopFilterSharpness;//3 bits + + /* Quantization parameters */ + unsigned char qpYAc; + char qpYDc; + char qpChAc; + char qpChDc; + + /* From here down, frame-to-frame persisting stuff */ + + char lossless; + char transform_mode; + char allow_high_precision_mv; + char mcomp_filter_type; + char comp_pred_mode; + char comp_fixed_ref; + char comp_var_ref[2]; + char log2_tile_columns; + char log2_tile_rows; + + /* Segment and macroblock specific values */ + unsigned char segmentEnabled; + unsigned char segmentMapUpdate; + unsigned char segmentMapTemporalUpdate; + unsigned char segmentFeatureMode; /* ABS data or delta data */ + unsigned char segmentFeatureEnable[8][4]; + short segmentFeatureData[8][4]; + char modeRefLfEnabled; + char mbRefLfDelta[4]; + char mbModeLfDelta[2]; + char reserved5; // for alignment + + // New additions + nvdec_vp9_pic_v1_s v1; + nvdec_pass2_otf_ext_s ssm; + +} nvdec_vp9_pic_s; + +#define NVDEC_VP9HWPAD(x, y) unsigned char x[y] + +typedef struct { + /* last bytes of address 41 */ + unsigned char joints[3]; + unsigned char sign[2]; + /* address 42 */ + unsigned char class0[2][1]; + unsigned char fp[2][3]; + unsigned char class0_hp[2]; + unsigned char hp[2]; + unsigned char classes[2][10]; + /* address 43 */ + unsigned char class0_fp[2][2][3]; + unsigned char bits[2][10]; + +} nvdec_nmv_context; + +typedef struct { + unsigned int joints[4]; + unsigned int sign[2][2]; + unsigned int classes[2][11]; + unsigned int class0[2][2]; + unsigned int bits[2][10][2]; + unsigned int class0_fp[2][2][4]; + unsigned int fp[2][4]; + unsigned int class0_hp[2][2]; + unsigned int hp[2][2]; + +} nvdec_nmv_context_counts; + +/* Adaptive entropy contexts, padding elements are added to have + * 256 bit aligned tables for HW access. + * Compile with TRACE_PROB_TABLES to print bases for each table. */ +typedef struct nvdec_vp9AdaptiveEntropyProbs_s +{ + /* address 32 */ + unsigned char inter_mode_prob[7][4]; + unsigned char intra_inter_prob[4]; + + /* address 33 */ + unsigned char uv_mode_prob[10][8]; + unsigned char tx8x8_prob[2][1]; + unsigned char tx16x16_prob[2][2]; + unsigned char tx32x32_prob[2][3]; + unsigned char sb_ymode_probB[4][1]; + unsigned char sb_ymode_prob[4][8]; + + /* address 37 */ + unsigned char partition_prob[2][16][4]; + + /* address 41 */ + unsigned char uv_mode_probB[10][1]; + unsigned char switchable_interp_prob[4][2]; + unsigned char comp_inter_prob[5]; + unsigned char mbskip_probs[3]; + NVDEC_VP9HWPAD(pad1, 1); + + nvdec_nmv_context nmvc; + + /* address 44 */ + unsigned char single_ref_prob[5][2]; + unsigned char comp_ref_prob[5]; + NVDEC_VP9HWPAD(pad2, 17); + + /* address 45 */ + unsigned char probCoeffs[2][2][6][6][4]; + unsigned char probCoeffs8x8[2][2][6][6][4]; + unsigned char probCoeffs16x16[2][2][6][6][4]; + unsigned char probCoeffs32x32[2][2][6][6][4]; + +} nvdec_vp9AdaptiveEntropyProbs_t; + +/* Entropy contexts */ +typedef struct nvdec_vp9EntropyProbs_s +{ + /* Default keyframe probs */ + /* Table formatted for 256b memory, probs 0to7 for all tables followed by + * probs 8toN for all tables. + * Compile with TRACE_PROB_TABLES to print bases for each table. */ + + unsigned char kf_bmode_prob[10][10][8]; + + /* Address 25 */ + unsigned char kf_bmode_probB[10][10][1]; + unsigned char ref_pred_probs[3]; + unsigned char mb_segment_tree_probs[7]; + unsigned char segment_pred_probs[3]; + unsigned char ref_scores[4]; + unsigned char prob_comppred[2]; + NVDEC_VP9HWPAD(pad1, 9); + + /* Address 29 */ + unsigned char kf_uv_mode_prob[10][8]; + unsigned char kf_uv_mode_probB[10][1]; + NVDEC_VP9HWPAD(pad2, 6); + + nvdec_vp9AdaptiveEntropyProbs_t a; /* Probs with backward adaptation */ + +} nvdec_vp9EntropyProbs_t; + +/* Counters for adaptive entropy contexts */ +typedef struct nvdec_vp9EntropyCounts_s +{ + unsigned int inter_mode_counts[7][3][2]; + unsigned int sb_ymode_counts[4][10]; + unsigned int uv_mode_counts[10][10]; + unsigned int partition_counts[16][4]; + unsigned int switchable_interp_counts[4][3]; + unsigned int intra_inter_count[4][2]; + unsigned int comp_inter_count[5][2]; + unsigned int single_ref_count[5][2][2]; + unsigned int comp_ref_count[5][2]; + unsigned int tx32x32_count[2][4]; + unsigned int tx16x16_count[2][3]; + unsigned int tx8x8_count[2][2]; + unsigned int mbskip_count[3][2]; + + nvdec_nmv_context_counts nmvcount; + + unsigned int countCoeffs[2][2][6][6][4]; + unsigned int countCoeffs8x8[2][2][6][6][4]; + unsigned int countCoeffs16x16[2][2][6][6][4]; + unsigned int countCoeffs32x32[2][2][6][6][4]; + + unsigned int countEobs[4][2][2][6][6]; + +} nvdec_vp9EntropyCounts_t; + +// Legacy codecs encryption parameters +typedef struct _nvdec_pass2_otf_s { + unsigned int wrapped_session_key[4]; // session keys + unsigned int wrapped_content_key[4]; // content keys + unsigned int initialization_vector[4];// Ctrl64 initial vector + unsigned int enable_encryption : 1; // flag to enable/disable encryption + unsigned int key_increment : 6; // added to content key after unwrapping + unsigned int encryption_mode : 4; + unsigned int key_slot_index : 4; + unsigned int ssm_en : 1; + unsigned int reserved1 :16; // reserved +} nvdec_pass2_otf_s; // 0x10 bytes + +typedef struct _nvdec_display_param_s +{ + unsigned int enableTFOutput : 1; //=1, enable dbfdma to output the display surface; if disable, then the following configure on tf is useless. + //remap for VC1 + unsigned int VC1MapYFlag : 1; + unsigned int MapYValue : 3; + unsigned int VC1MapUVFlag : 1; + unsigned int MapUVValue : 3; + //tf + unsigned int OutStride : 8; + unsigned int TilingFormat : 3; + unsigned int OutputStructure : 1; //(0=frame, 1=field) + unsigned int reserved0 :11; + int OutputTop[2]; // in units of 256 + int OutputBottom[2]; // in units of 256 + //histogram + unsigned int enableHistogram : 1; // enable histogram info collection. + unsigned int HistogramStartX :12; // start X of Histogram window + unsigned int HistogramStartY :12; // start Y of Histogram window + unsigned int reserved1 : 7; + unsigned int HistogramEndX :12; // end X of Histogram window + unsigned int HistogramEndY :12; // end y of Histogram window + unsigned int reserved2 : 8; +} nvdec_display_param_s; // size 0x1c bytes + +// H.264 +typedef struct _nvdec_dpb_entry_s // 16 bytes +{ + unsigned int index : 7; // uncompressed frame buffer index + unsigned int col_idx : 5; // index of associated co-located motion data buffer + unsigned int state : 2; // bit1(state)=1: top field used for reference, bit1(state)=1: bottom field used for reference + unsigned int is_long_term : 1; // 0=short-term, 1=long-term + unsigned int not_existing : 1; // 1=marked as non-existing + unsigned int is_field : 1; // set if unpaired field or complementary field pair + unsigned int top_field_marking : 4; + unsigned int bottom_field_marking : 4; + unsigned int output_memory_layout : 1; // Set according to picture level output NV12/NV24 setting. + unsigned int reserved : 6; + unsigned int FieldOrderCnt[2]; // : 2*32 [top/bottom] + int FrameIdx; // : 16 short-term: FrameNum (16 bits), long-term: LongTermFrameIdx (4 bits) +} nvdec_dpb_entry_s; + +typedef struct _nvdec_h264_pic_s +{ + nvdec_pass2_otf_s encryption_params; + unsigned char eos[16]; + unsigned char explicitEOSPresentFlag; + unsigned char hint_dump_en; //enable COLOMV surface dump for all frames, which includes hints of "MV/REFIDX/QP/CBP/MBPART/MBTYPE", nvbug: 200212874 + unsigned char reserved0[2]; + unsigned int stream_len; + unsigned int slice_count; + unsigned int mbhist_buffer_size; // to pass buffer size of MBHIST_BUFFER + + // Driver may or may not use based upon need. + // If 0 then default value of 1<<27 = 298ms @ 450MHz will be used in ucode. + // Driver can send this value based upon resolution using the formula: + // gptimer_timeout_value = 3 * (cycles required for one frame) + unsigned int gptimer_timeout_value; + + // Fields from msvld_h264_seq_s + int log2_max_pic_order_cnt_lsb_minus4; + int delta_pic_order_always_zero_flag; + int frame_mbs_only_flag; + int PicWidthInMbs; + int FrameHeightInMbs; + + unsigned int tileFormat : 2 ; // 0: TBL; 1: KBL; 2: Tile16x16 + unsigned int gob_height : 3 ; // Set GOB height, 0: GOB_2, 1: GOB_4, 2: GOB_8, 3: GOB_16, 4: GOB_32 (NVDEC3 onwards) + unsigned int reserverd_surface_format : 27; + + // Fields from msvld_h264_pic_s + int entropy_coding_mode_flag; + int pic_order_present_flag; + int num_ref_idx_l0_active_minus1; + int num_ref_idx_l1_active_minus1; + int deblocking_filter_control_present_flag; + int redundant_pic_cnt_present_flag; + int transform_8x8_mode_flag; + + // Fields from mspdec_h264_picture_setup_s + unsigned int pitch_luma; // Luma pitch + unsigned int pitch_chroma; // chroma pitch + + unsigned int luma_top_offset; // offset of luma top field in units of 256 + unsigned int luma_bot_offset; // offset of luma bottom field in units of 256 + unsigned int luma_frame_offset; // offset of luma frame in units of 256 + unsigned int chroma_top_offset; // offset of chroma top field in units of 256 + unsigned int chroma_bot_offset; // offset of chroma bottom field in units of 256 + unsigned int chroma_frame_offset; // offset of chroma frame in units of 256 + unsigned int HistBufferSize; // in units of 256 + + unsigned int MbaffFrameFlag : 1; // + unsigned int direct_8x8_inference_flag: 1; // + unsigned int weighted_pred_flag : 1; // + unsigned int constrained_intra_pred_flag:1; // + unsigned int ref_pic_flag : 1; // reference picture (nal_ref_idc != 0) + unsigned int field_pic_flag : 1; // + unsigned int bottom_field_flag : 1; // + unsigned int second_field : 1; // second field of complementary reference field + unsigned int log2_max_frame_num_minus4: 4; // (0..12) + unsigned int chroma_format_idc : 2; // + unsigned int pic_order_cnt_type : 2; // (0..2) + int pic_init_qp_minus26 : 6; // : 6 (-26..+25) + int chroma_qp_index_offset : 5; // : 5 (-12..+12) + int second_chroma_qp_index_offset : 5; // : 5 (-12..+12) + + unsigned int weighted_bipred_idc : 2; // : 2 (0..2) + unsigned int CurrPicIdx : 7; // : 7 uncompressed frame buffer index + unsigned int CurrColIdx : 5; // : 5 index of associated co-located motion data buffer + unsigned int frame_num : 16; // + unsigned int frame_surfaces : 1; // frame surfaces flag + unsigned int output_memory_layout : 1; // 0: NV12; 1:NV24. Field pair must use the same setting. + + int CurrFieldOrderCnt[2]; // : 32 [Top_Bottom], [0]=TopFieldOrderCnt, [1]=BottomFieldOrderCnt + nvdec_dpb_entry_s dpb[16]; + unsigned char WeightScale[6][4][4]; // : 6*4*4*8 in raster scan order (not zig-zag order) + unsigned char WeightScale8x8[2][8][8]; // : 2*8*8*8 in raster scan order (not zig-zag order) + + // mvc setup info, must be zero if not mvc + unsigned char num_inter_view_refs_lX[2]; // number of inter-view references + char reserved1[14]; // reserved for alignment + signed char inter_view_refidx_lX[2][16]; // DPB indices (must also be marked as long-term) + + // lossless decode (At the time of writing this manual, x264 and JM encoders, differ in Intra_8x8 reference sample filtering) + unsigned int lossless_ipred8x8_filter_enable : 1; // = 0, skips Intra_8x8 reference sample filtering, for vertical and horizontal predictions (x264 encoded streams); = 1, filter Intra_8x8 reference samples (JM encoded streams) + unsigned int qpprime_y_zero_transform_bypass_flag : 1; // determines the transform bypass mode + unsigned int reserved2 : 30; // kept for alignment; may be used for other parameters + + nvdec_display_param_s displayPara; + nvdec_pass2_otf_ext_s ssm; + +} nvdec_h264_pic_s; + +// VC-1 Scratch buffer +typedef enum _vc1_fcm_e +{ + FCM_PROGRESSIVE = 0, + FCM_FRAME_INTERLACE = 2, + FCM_FIELD_INTERLACE = 3 +} vc1_fcm_e; + +typedef enum _syntax_vc1_ptype_e +{ + PTYPE_I = 0, + PTYPE_P = 1, + PTYPE_B = 2, + PTYPE_BI = 3, //PTYPE_BI is not used to config register NV_CNVDEC_VLD_PIC_INFO_COMMON. field NV_CNVDEC_VLD_PIC_INFO_COMMON_PIC_CODING_VC1 is only 2 bits. I and BI pictures are configured with same value. Please refer to manual. + PTYPE_SKIPPED = 4 +} syntax_vc1_ptype_e; + +// 7.1.1.32, Table 46 etc. +enum vc1_mvmode_e +{ + MVMODE_MIXEDMV = 0, + MVMODE_1MV = 1, + MVMODE_1MV_HALFPEL = 2, + MVMODE_1MV_HALFPEL_BILINEAR = 3, + MVMODE_INTENSITY_COMPENSATION = 4 +}; + +// 9.1.1.42, Table 105 +typedef enum _vc1_fptype_e +{ + FPTYPE_I_I = 0, + FPTYPE_I_P, + FPTYPE_P_I, + FPTYPE_P_P, + FPTYPE_B_B, + FPTYPE_B_BI, + FPTYPE_BI_B, + FPTYPE_BI_BI +} vc1_fptype_e; + +// Table 43 (7.1.1.31.2) +typedef enum _vc1_dqprofile_e +{ + DQPROFILE_ALL_FOUR_EDGES_ = 0, + DQPROFILE_DOUBLE_EDGE_ = 1, + DQPROFILE_SINGLE_EDGE_ = 2, + DQPROFILE_ALL_MACROBLOCKS_ = 3 +} vc1_dqprofile_e; + +typedef struct _nvdec_vc1_pic_s +{ + nvdec_pass2_otf_s encryption_params; + unsigned char eos[16]; // to pass end of stream data separately if not present in bitstream surface + unsigned char prefixStartCode[4]; // used for dxva to pass prefix start code. + unsigned int bitstream_offset; // offset in words from start of bitstream surface if there is gap. + unsigned char explicitEOSPresentFlag; // to indicate that eos[] is used for passing end of stream data. + unsigned char reserved0[3]; + unsigned int stream_len; + unsigned int slice_count; + unsigned int scratch_pic_buffer_size; + + // Driver may or may not use based upon need. + // If 0 then default value of 1<<27 = 298ms @ 450MHz will be used in ucode. + // Driver can send this value based upon resolution using the formula: + // gptimer_timeout_value = 3 * (cycles required for one frame) + unsigned int gptimer_timeout_value; + + // Fields from vc1_seq_s + unsigned short FrameWidth; // actual frame width + unsigned short FrameHeight; // actual frame height + + unsigned char profile; // 1 = SIMPLE or MAIN, 2 = ADVANCED + unsigned char postprocflag; + unsigned char pulldown; + unsigned char interlace; + + unsigned char tfcntrflag; + unsigned char finterpflag; + unsigned char psf; + unsigned char tileFormat : 2 ; // 0: TBL; 1: KBL; 2: Tile16x16 + unsigned char gob_height : 3 ; // Set GOB height, 0: GOB_2, 1: GOB_4, 2: GOB_8, 3: GOB_16, 4: GOB_32 (NVDEC3 onwards) + unsigned char reserverd_surface_format : 3 ; + + // simple,main + unsigned char multires; + unsigned char syncmarker; + unsigned char rangered; + unsigned char maxbframes; + + // Fields from vc1_entrypoint_s + unsigned char dquant; + unsigned char panscan_flag; + unsigned char refdist_flag; + unsigned char quantizer; + + unsigned char extended_mv; + unsigned char extended_dmv; + unsigned char overlap; + unsigned char vstransform; + + // Fields from vc1_scratch_s + char refdist; + char reserved1[3]; // for alignment + + // Fields from vld_vc1_pic_s + vc1_fcm_e fcm; + syntax_vc1_ptype_e ptype; + int tfcntr; + int rptfrm; + int tff; + int rndctrl; + int pqindex; + int halfqp; + int pquantizer; + int postproc; + int condover; + int transacfrm; + int transacfrm2; + int transdctab; + int pqdiff; + int abspq; + int dquantfrm; + vc1_dqprofile_e dqprofile; + int dqsbedge; + int dqdbedge; + int dqbilevel; + int mvrange; + enum vc1_mvmode_e mvmode; + enum vc1_mvmode_e mvmode2; + int lumscale; + int lumshift; + int mvtab; + int cbptab; + int ttmbf; + int ttfrm; + int bfraction; + vc1_fptype_e fptype; + int numref; + int reffield; + int dmvrange; + int intcompfield; + int lumscale1; // type was char in ucode + int lumshift1; // type was char in ucode + int lumscale2; // type was char in ucode + int lumshift2; // type was char in ucode + int mbmodetab; + int imvtab; + int icbptab; + int fourmvbptab; + int fourmvswitch; + int intcomp; + int twomvbptab; + // simple,main + int rangeredfrm; + + // Fields from pdec_vc1_pic_s + unsigned int HistBufferSize; // in units of 256 + // frame buffers + unsigned int FrameStride[2]; // [y_c] + unsigned int luma_top_offset; // offset of luma top field in units of 256 + unsigned int luma_bot_offset; // offset of luma bottom field in units of 256 + unsigned int luma_frame_offset; // offset of luma frame in units of 256 + unsigned int chroma_top_offset; // offset of chroma top field in units of 256 + unsigned int chroma_bot_offset; // offset of chroma bottom field in units of 256 + unsigned int chroma_frame_offset; // offset of chroma frame in units of 256 + + unsigned short CodedWidth; // entrypoint specific + unsigned short CodedHeight; // entrypoint specific + + unsigned char loopfilter; // entrypoint specific + unsigned char fastuvmc; // entrypoint specific + unsigned char output_memory_layout; // picture specific + unsigned char ref_memory_layout[2]; // picture specific 0: fwd, 1: bwd + unsigned char reserved3[3]; // for alignment + + nvdec_display_param_s displayPara; + nvdec_pass2_otf_ext_s ssm; + +} nvdec_vc1_pic_s; + +// MPEG-2 +typedef struct _nvdec_mpeg2_pic_s +{ + nvdec_pass2_otf_s encryption_params; + unsigned char eos[16]; + unsigned char explicitEOSPresentFlag; + unsigned char reserved0[3]; + unsigned int stream_len; + unsigned int slice_count; + + // Driver may or may not use based upon need. + // If 0 then default value of 1<<27 = 298ms @ 450MHz will be used in ucode. + // Driver can send this value based upon resolution using the formula: + // gptimer_timeout_value = 3 * (cycles required for one frame) + unsigned int gptimer_timeout_value; + + // Fields from vld_mpeg2_seq_pic_info_s + short FrameWidth; // actual frame width + short FrameHeight; // actual frame height + unsigned char picture_structure; // 0 => Reserved, 1 => Top field, 2 => Bottom field, 3 => Frame picture. Table 6-14. + unsigned char picture_coding_type; // 0 => Forbidden, 1 => I, 2 => P, 3 => B, 4 => D (for MPEG-2). Table 6-12. + unsigned char intra_dc_precision; // 0 => 8 bits, 1=> 9 bits, 2 => 10 bits, 3 => 11 bits. Table 6-13. + char frame_pred_frame_dct; // as in section 6.3.10 + char concealment_motion_vectors; // as in section 6.3.10 + char intra_vlc_format; // as in section 6.3.10 + unsigned char tileFormat : 2 ; // 0: TBL; 1: KBL; 2: Tile16x16 + unsigned char gob_height : 3 ; // Set GOB height, 0: GOB_2, 1: GOB_4, 2: GOB_8, 3: GOB_16, 4: GOB_32 (NVDEC3 onwards) + unsigned char reserverd_surface_format : 3 ; + + char reserved1; // always 0 + char f_code[4]; // as in section 6.3.10 + + // Fields from pdec_mpeg2_picture_setup_s + unsigned short PicWidthInMbs; + unsigned short FrameHeightInMbs; + unsigned int pitch_luma; + unsigned int pitch_chroma; + unsigned int luma_top_offset; + unsigned int luma_bot_offset; + unsigned int luma_frame_offset; + unsigned int chroma_top_offset; + unsigned int chroma_bot_offset; + unsigned int chroma_frame_offset; + unsigned int HistBufferSize; + unsigned short output_memory_layout; + unsigned short alternate_scan; + unsigned short secondfield; + /******************************/ + // Got rid of the union kept for compatibility with NVDEC1. + // Removed field mpeg2, and kept rounding type. + // NVDEC1 ucode is not using the mpeg2 field, instead using codec type from the methods. + // Rounding type should only be set for Divx3.11. + unsigned short rounding_type; + /******************************/ + unsigned int MbInfoSizeInBytes; + unsigned int q_scale_type; + unsigned int top_field_first; + unsigned int full_pel_fwd_vector; + unsigned int full_pel_bwd_vector; + unsigned char quant_mat_8x8intra[64]; + unsigned char quant_mat_8x8nonintra[64]; + unsigned int ref_memory_layout[2]; //0:for fwd; 1:for bwd + + nvdec_display_param_s displayPara; + nvdec_pass2_otf_ext_s ssm; + +} nvdec_mpeg2_pic_s; + +// MPEG-4 +typedef struct _nvdec_mpeg4_pic_s +{ + nvdec_pass2_otf_s encryption_params; + unsigned char eos[16]; + unsigned char explicitEOSPresentFlag; + unsigned char reserved2[3]; // for alignment + unsigned int stream_len; + unsigned int slice_count; + unsigned int scratch_pic_buffer_size; + + // Driver may or may not use based upon need. + // If 0 then default value of 1<<27 = 298ms @ 450MHz will be used in ucode. + // Driver can send this value based upon resolution using the formula: + // gptimer_timeout_value = 3 * (cycles required for one frame) + unsigned int gptimer_timeout_value; + + // Fields from vld_mpeg4_seq_s + short FrameWidth; // :13 video_object_layer_width + short FrameHeight; // :13 video_object_layer_height + char vop_time_increment_bitcount; // : 5 1..16 + char resync_marker_disable; // : 1 + unsigned char tileFormat : 2 ; // 0: TBL; 1: KBL; 2: Tile16x16 + unsigned char gob_height : 3 ; // Set GOB height, 0: GOB_2, 1: GOB_4, 2: GOB_8, 3: GOB_16, 4: GOB_32 (NVDEC3 onwards) + unsigned char reserverd_surface_format : 3 ; + char reserved3; // for alignment + + // Fields from pdec_mpeg4_picture_setup_s + int width; // : 13 + int height; // : 13 + + unsigned int FrameStride[2]; // [y_c] + unsigned int luma_top_offset; // offset of luma top field in units of 256 + unsigned int luma_bot_offset; // offset of luma bottom field in units of 256 + unsigned int luma_frame_offset; // offset of luma frame in units of 256 + unsigned int chroma_top_offset; // offset of chroma top field in units of 256 + unsigned int chroma_bot_offset; // offset of chroma bottom field in units of 256 + unsigned int chroma_frame_offset; // offset of chroma frame in units of 256 + + unsigned int HistBufferSize; // in units of 256, History buffer size + + int trd[2]; // : 16, temporal reference frame distance (only needed for B-VOPs) + int trb[2]; // : 16, temporal reference B-VOP distance from fwd reference frame (only needed for B-VOPs) + + int divx_flags; // : 16 (bit 0: DivX interlaced chroma rounding, bit 1: Divx 4 boundary padding, bit 2: Divx IDCT) + + short vop_fcode_forward; // : 1...7 + short vop_fcode_backward; // : 1...7 + + unsigned char interlaced; // : 1 + unsigned char quant_type; // : 1 + unsigned char quarter_sample; // : 1 + unsigned char short_video_header; // : 1 + + unsigned char curr_output_memory_layout; // : 1 0:NV12; 1:NV24 + unsigned char ptype; // picture type: 0 for PTYPE_I, 1 for PTYPE_P, 2 for PTYPE_B, 3 for PTYPE_BI, 4 for PTYPE_SKIPPED + unsigned char rnd; // : 1, rounding mode + unsigned char alternate_vertical_scan_flag; // : 1 + + unsigned char top_field_flag; // : 1 + unsigned char reserved0[3]; // alignment purpose + + unsigned char intra_quant_mat[64]; // : 64*8 + unsigned char nonintra_quant_mat[64]; // : 64*8 + unsigned char ref_memory_layout[2]; //0:for fwd; 1:for bwd + unsigned char reserved1[34]; // 256 byte alignemnt till now + + nvdec_display_param_s displayPara; + +} nvdec_mpeg4_pic_s; + +// VP8 +enum VP8_FRAME_TYPE +{ + VP8_KEYFRAME = 0, + VP8_INTERFRAME = 1 +}; + +enum VP8_FRAME_SFC_ID +{ + VP8_GOLDEN_FRAME_SFC = 0, + VP8_ALTREF_FRAME_SFC, + VP8_LAST_FRAME_SFC, + VP8_CURR_FRAME_SFC +}; + +typedef struct _nvdec_vp8_pic_s +{ + nvdec_pass2_otf_s encryption_params; + + // Driver may or may not use based upon need. + // If 0 then default value of 1<<27 = 298ms @ 450MHz will be used in ucode. + // Driver can send this value based upon resolution using the formula: + // gptimer_timeout_value = 3 * (cycles required for one frame) + unsigned int gptimer_timeout_value; + + unsigned short FrameWidth; // actual frame width + unsigned short FrameHeight; // actual frame height + + unsigned char keyFrame; // 1: key frame; 0: not + unsigned char version; + unsigned char tileFormat : 2 ; // 0: TBL; 1: KBL; 2: Tile16x16 + unsigned char gob_height : 3 ; // Set GOB height, 0: GOB_2, 1: GOB_4, 2: GOB_8, 3: GOB_16, 4: GOB_32 (NVDEC3 onwards) + unsigned char reserverd_surface_format : 3 ; + unsigned char errorConcealOn; // 1: error conceal on; 0: off + + unsigned int firstPartSize; // the size of first partition(frame header and mb header partition) + + // ctx + unsigned int HistBufferSize; // in units of 256 + unsigned int VLDBufferSize; // in units of 1 + // current frame buffers + unsigned int FrameStride[2]; // [y_c] + unsigned int luma_top_offset; // offset of luma top field in units of 256 + unsigned int luma_bot_offset; // offset of luma bottom field in units of 256 + unsigned int luma_frame_offset; // offset of luma frame in units of 256 + unsigned int chroma_top_offset; // offset of chroma top field in units of 256 + unsigned int chroma_bot_offset; // offset of chroma bottom field in units of 256 + unsigned int chroma_frame_offset; // offset of chroma frame in units of 256 + + nvdec_display_param_s displayPara; + + // decode picture buffere related + char current_output_memory_layout; + char output_memory_layout[3]; // output NV12/NV24 setting. item 0:golden; 1: altref; 2: last + + unsigned char segmentation_feature_data_update; + unsigned char reserved1[3]; + + // ucode return result + unsigned int resultValue; // ucode return the picture header info; includes copy_buffer_to_golden etc. + unsigned int partition_offset[8]; // byte offset to each token partition (used for encrypted streams only) + + nvdec_pass2_otf_ext_s ssm; + +} nvdec_vp8_pic_s; // size is 0xc0 + +// PASS1 + +//Sample means the entire frame is encrypted with a single IV, and subsample means a given frame may be encrypted in multiple chunks with different IVs. +#define NUM_SUBSAMPLES 32 + +typedef struct _bytes_of_data_s +{ + unsigned int clear_bytes; // clear bytes per subsample + unsigned int encypted_bytes; // encrypted bytes per subsample + +} bytes_of_data_s; + +typedef struct _nvdec_pass1_input_data_s +{ + bytes_of_data_s sample_size[NUM_SUBSAMPLES]; // clear/encrypted bytes per subsample + unsigned int initialization_vector[NUM_SUBSAMPLES][4]; // Ctrl64 initial vector per subsample + unsigned char IvValid[NUM_SUBSAMPLES]; // each element will tell whether IV is valid for that subsample or not. + unsigned int stream_len; // encrypted bitstream size. + unsigned int clearBufferSize; // allocated size of clear buffer size + unsigned int reencryptBufferSize; // allocated size of reencrypted buffer size + unsigned int vp8coeffPartitonBufferSize; // allocated buffer for vp8 coeff partition buffer + unsigned int PrevWidth; // required for VP9 + unsigned int num_nals :16; // number of subsamples in a frame + unsigned int drm_mode : 8; // DRM mode + unsigned int key_sel : 4; // key select from keyslot + unsigned int codec : 4; // codecs selection + unsigned int TotalSizeOfClearData; // Used with Pattern based encryption + unsigned int SliceHdrOffset; // This is used with pattern mode encryption where data before slice hdr comes in clear. + unsigned int EncryptBlkCnt :16; + unsigned int SkipBlkCnt :16; +} nvdec_pass1_input_data_s; + +#define VP8_MAX_TOKEN_PARTITIONS 8 +#define VP9_MAX_FRAMES_IN_SUPERFRAME 8 + +typedef struct _nvdec_pass1_output_data_s +{ + unsigned int clear_header_size; // h264/vc1/mpeg2/vp8, decrypted pps/sps/part of slice header info, 128 bits aligned + unsigned int reencrypt_data_size; // h264/vc1/mpeg2, slice level data, vp8 mb header info, 128 bits aligned + unsigned int clear_token_data_size; // vp8, clear token data saved in VPR, 128 bits aligned + unsigned int key_increment : 6; // added to content key after unwrapping + unsigned int encryption_mode : 4; // encryption mode + unsigned int bReEncrypted : 1; // set to 0 if no re-encryption is done. + unsigned int bvp9SuperFrame : 1; // set to 1 for vp9 superframe + unsigned int vp9NumFramesMinus1 : 3; // set equal to numFrames-1 for vp9superframe. Max 8 frames are possible in vp9 superframe. + unsigned int reserved1 :17; // reserved, 32 bit alignment + unsigned int wrapped_session_key[4]; // session keys + unsigned int wrapped_content_key[4]; // content keys + unsigned int initialization_vector[4]; // Ctrl64 initial vector + union { + unsigned int partition_size[VP8_MAX_TOKEN_PARTITIONS]; // size of each token partition (used for encrypted streams of VP8) + unsigned int vp9_frame_sizes[VP9_MAX_FRAMES_IN_SUPERFRAME]; // frame size information for all frames in vp9 superframe. + }; + unsigned int vp9_clear_hdr_size[VP9_MAX_FRAMES_IN_SUPERFRAME]; // clear header size for each frame in vp9 superframe. +} nvdec_pass1_output_data_s; + + +/***************************************************** + AV1 +*****************************************************/ +typedef struct _scale_factors_reference_s{ + short x_scale_fp; // horizontal fixed point scale factor + short y_scale_fp; // vertical fixed point scale factor +}scale_factors_reference_s; + +typedef struct _frame_info_t{ + unsigned short width; // in pixel, av1 support arbitray resolution + unsigned short height; + unsigned short stride[2]; // luma and chroma stride in 16Bytes + unsigned int frame_buffer_idx; // TBD :clean associate the reference frame and frame buffer id to lookup base_addr +} frame_info_t; + +typedef struct _ref_frame_struct_s{ + frame_info_t info; + scale_factors_reference_s sf; // scalefactor for reference frame and current frame size, driver can calculate it + unsigned char sign_bias : 1; // calcuate based on frame_offset and current frame offset + unsigned char wmtype : 2; // global motion parameters : identity,translation,rotzoom,affine + unsigned char reserved_rf : 5; + short frame_off; // relative offset to current frame + short roffset; // relative offset from current frame +} ref_frame_struct_s; + +typedef struct _av1_fgs_cfg_t{ + //from AV1 spec 5.9.30 Film Grain Params syntax + unsigned short apply_grain : 1; + unsigned short overlap_flag : 1; + unsigned short clip_to_restricted_range : 1; + unsigned short chroma_scaling_from_luma : 1; + unsigned short num_y_points_b : 1; // flag indicates num_y_points>0 + unsigned short num_cb_points_b : 1; // flag indicates num_cb_points>0 + unsigned short num_cr_points_b : 1; // flag indicates num_cr_points>0 + unsigned short scaling_shift : 4; + unsigned short reserved_fgs : 5; + unsigned short sw_random_seed; + short cb_offset; + short cr_offset; + char cb_mult; + char cb_luma_mult; + char cr_mult; + char cr_luma_mult; +} av1_fgs_cfg_t; + + +typedef struct _nvdec_av1_pic_s +{ + nvdec_pass2_otf_s encryption_params; + + nvdec_pass2_otf_ext_s ssm; + + av1_fgs_cfg_t fgs_cfg; + + // Driver may or may not use based upon need. + // If 0 then default value of 1<<27 = 298ms @ 450MHz will be used in ucode. + // Driver can send this value based upon resolution using the formula: + // gptimer_timeout_value = 3 * (cycles required for one frame) + unsigned int gptimer_timeout_value; + + unsigned int stream_len; // stream length. + unsigned int reserved12; // skip bytes length to real frame data . + + //sequence header + unsigned int use_128x128_superblock : 1; // superblock 128x128 or 64x64, 0:64x64, 1: 128x128 + unsigned int chroma_format : 2; // 1:420, others:reserved for future + unsigned int bit_depth : 4; // bitdepth + unsigned int enable_filter_intra : 1; // tool enable in seq level, 0 : disable 1: frame header control + unsigned int enable_intra_edge_filter : 1; + unsigned int enable_interintra_compound : 1; + unsigned int enable_masked_compound : 1; + unsigned int enable_dual_filter : 1; // enable or disable vertical and horiz filter selection + unsigned int reserved10 : 1; // 0 - disable order hint, and related tools + unsigned int reserved0 : 3; + unsigned int enable_jnt_comp : 1; // 0 - disable joint compound modes + unsigned int reserved1 : 1; + unsigned int enable_cdef : 1; + unsigned int reserved11 : 1; + unsigned int enable_fgs : 1; + unsigned int enable_substream_decoding : 1; //enable frame substream kickoff mode without context switch + unsigned int reserved2 : 10; // reserved bits + + //frame header + unsigned int frame_type : 2; // 0:Key frame, 1:Inter frame, 2:intra only, 3:s-frame + unsigned int show_frame : 1; // show frame flag + unsigned int reserved13 : 1; + unsigned int disable_cdf_update : 1; // disable CDF update during symbol decoding + unsigned int allow_screen_content_tools : 1; // screen content tool enable + unsigned int cur_frame_force_integer_mv : 1; // AMVR enable + unsigned int scale_denom_minus9 : 3; // The denominator minus9 of the superres scale + unsigned int allow_intrabc : 1; // IBC enable + unsigned int allow_high_precision_mv : 1; // 1/8 precision mv enable + unsigned int interp_filter : 3; // interpolation filter : EIGHTTAP_REGULAR,.... + unsigned int switchable_motion_mode : 1; // 0: simple motion mode, 1: SIMPLE, OBMC, LOCAL WARP + unsigned int use_ref_frame_mvs : 1; // 1: current frame can use the previous frame mv information, MFMV + unsigned int refresh_frame_context : 1; // backward update flag + unsigned int delta_q_present_flag : 1; // quantizer index delta values are present in the block level + unsigned int delta_q_res : 2; // left shift will apply to decoded quantizer index delta values + unsigned int delta_lf_present_flag : 1; // specified whether loop filter delta values are present in the block level + unsigned int delta_lf_res : 2; // specifies the left shift will apply to decoded loop filter values + unsigned int delta_lf_multi : 1; // seperate loop filter deltas for Hy,Vy,U,V edges + unsigned int reserved3 : 1; + unsigned int coded_lossless : 1; // 1 means all segments use lossless coding. Frame is fully lossless, CDEF/DBF will disable + unsigned int tile_enabled : 1; // tile enable + unsigned int reserved4 : 2; + unsigned int superres_is_scaled : 1; // frame level frame for using_superres + unsigned int reserved_fh : 1; + + unsigned int tile_cols : 8; // horizontal tile numbers in frame, max is 64 + unsigned int tile_rows : 8; // vertical tile numbers in frame, max is 64 + unsigned int context_update_tile_id : 16; // which tile cdf will be seleted as the backward update CDF, MAXTILEROW=64, MAXTILECOL=64, 12bits + + unsigned int cdef_damping_minus_3 : 2; // controls the amount of damping in the deringing filter + unsigned int cdef_bits : 2; // the number of bits needed to specify which CDEF filter to apply + unsigned int frame_tx_mode : 3; // 0:ONLY4x4,3:LARGEST,4:SELECT + unsigned int frame_reference_mode : 2; // single,compound,select + unsigned int skip_mode_flag : 1; // skip mode + unsigned int skip_ref0 : 4; + unsigned int skip_ref1 : 4; + unsigned int allow_warp : 1; // sequence level & frame level warp enable + unsigned int reduced_tx_set_used : 1; // whether the frame is restricted to oa reduced subset of the full set of transform types + unsigned int ref_scaling_enable : 1; + unsigned int reserved5 : 1; + unsigned int reserved6 : 10; // reserved bits + unsigned short superres_upscaled_width; // upscale width, frame_size_with_refs() syntax,restoration will use it + unsigned short superres_luma_step; + unsigned short superres_chroma_step; + unsigned short superres_init_luma_subpel_x; + unsigned short superres_init_chroma_subpel_x; + + /*frame header qp information*/ + unsigned char base_qindex; // the maximum qp is 255 + char y_dc_delta_q; + char u_dc_delta_q; + char v_dc_delta_q; + char u_ac_delta_q; + char v_ac_delta_q; + unsigned char qm_y; // 4bit: 0-15 + unsigned char qm_u; + unsigned char qm_v; + + /*cdef, need to update in the new spec*/ + unsigned int cdef_y_pri_strength; // 4bit for one, max is 8 + unsigned int cdef_uv_pri_strength; // 4bit for one, max is 8 + unsigned int cdef_y_sec_strength : 16; // 2bit for one, max is 8 + unsigned int cdef_uv_sec_strength : 16; // 2bit for one, max is 8 + + /*segmentation*/ + unsigned char segment_enabled; + unsigned char segment_update_map; + unsigned char reserved7; + unsigned char segment_temporal_update; + short segment_feature_data[8][8]; + unsigned char last_active_segid; // The highest numbered segment id that has some enabled feature. + unsigned char segid_preskip; // Whether the segment id will be read before the skip syntax element. + // 1: the segment id will be read first. + // 0: the skip syntax element will be read first. + unsigned char prevsegid_flag; // 1 : previous segment id is available + unsigned char segment_quant_sign : 8; // sign bit for segment alternative QP + + /*loopfilter*/ + unsigned char filter_level[2]; + unsigned char filter_level_u; + unsigned char filter_level_v; + unsigned char lf_sharpness_level; + char lf_ref_deltas[8]; // 0 = Intra, Last, Last2+Last3, GF, BRF, ARF2, ARF + char lf_mode_deltas[2]; // 0 = ZERO_MV, MV + + /*restoration*/ + unsigned char lr_type ; // restoration type. Y:bit[1:0];U:bit[3:2],V:bit[5:4] + unsigned char lr_unit_size; // restoration unit size 0:32x32, 1:64x64, 2:128x128,3:256x256; Y:bit[1:0];U:bit[3:2],V:bit[5:4] + + //general + frame_info_t current_frame; + ref_frame_struct_s ref_frame[7]; // Last, Last2, Last3, Golden, BWDREF, ALTREF2, ALTREF + + unsigned int use_temporal0_mvs : 1; + unsigned int use_temporal1_mvs : 1; + unsigned int use_temporal2_mvs : 1; + unsigned int mf1_type : 3; + unsigned int mf2_type : 3; + unsigned int mf3_type : 3; + unsigned int reserved_mfmv : 20; + + short mfmv_offset[3][7]; // 3: mf0~2, 7: Last, Last2, Last3, Golden, BWDREF, ALTREF2, ALTREF + char mfmv_side[3][7]; // flag for reverse offset great than 0 + // MFMV relative offset from the ref frame(reference to reference relative offset) + + unsigned char tileformat : 2; // 0: TBL; 1: KBL; + unsigned char gob_height : 3; // Set GOB height, 0: GOB_2, 1: GOB_4, 2: GOB_8, 3: GOB_16, 4: GOB_32 (NVDEC3 onwards) + unsigned char errorConcealOn : 1; // this field is not used, use ctrl_param.error_conceal_on to enable error concealment in ucode, + // always set NV_CNVDEC_GIP_ERR_CONCEAL_CTRL_ON = 1 to enable error detect in hw + unsigned char reserver8 : 2; // reserve + + unsigned char stream_error_detection : 1; + unsigned char mv_error_detection : 1; + unsigned char coeff_error_detection : 1; + unsigned char reserved_eh : 5; + + // Filt neighbor buffer offset + unsigned int Av1FltTopOffset; // filter top buffer offset respect to filter buffer, 256 bytes unit + unsigned int Av1FltVertOffset; // filter vertical buffer offset respect to filter buffer, 256 bytes unit + unsigned int Av1CdefVertOffset; // cdef vertical buffer offset respect to filter buffer, 256 bytes unit + unsigned int Av1LrVertOffset; // lr vertical buffer offset respect to filter buffer, 256 bytes unit + unsigned int Av1HusVertOffset; // hus vertical buffer offset respect to filter buffer, 256 bytes unit + unsigned int Av1FgsVertOffset; // fgs vertical buffer offset respect to filter buffer, 256 bytes unit + + unsigned int enable_histogram : 1; + unsigned int sw_skip_start_length : 14; //skip start length + unsigned int reserved_stat : 17; + +} nvdec_av1_pic_s; + +////////////////////////////////////////////////////////////////////// +// AV1 Buffer structure +////////////////////////////////////////////////////////////////////// +typedef struct _AV1FilmGrainMemory + { + unsigned char scaling_lut_y[256]; + unsigned char scaling_lut_cb[256]; + unsigned char scaling_lut_cr[256]; + short cropped_luma_grain_block[4096]; + short cropped_cb_grain_block[1024]; + short cropped_cr_grain_block[1024]; +} AV1FilmGrainMemory; + +typedef struct _AV1TileInfo_OLD +{ + unsigned char width_in_sb; + unsigned char height_in_sb; + unsigned char tile_start_b0; + unsigned char tile_start_b1; + unsigned char tile_start_b2; + unsigned char tile_start_b3; + unsigned char tile_end_b0; + unsigned char tile_end_b1; + unsigned char tile_end_b2; + unsigned char tile_end_b3; + unsigned char padding[6]; +} AV1TileInfo_OLD; + +typedef struct _AV1TileInfo +{ + unsigned char width_in_sb; + unsigned char padding_w; + unsigned char height_in_sb; + unsigned char padding_h; +} AV1TileInfo; + +typedef struct _AV1TileStreamInfo +{ + unsigned int tile_start; + unsigned int tile_end; + unsigned char padding[8]; +} AV1TileStreamInfo; + + +// AV1 TileSize buffer +#define AV1_MAX_TILES 256 +#define AV1_TILEINFO_BUF_SIZE_OLD NVDEC_ALIGN(AV1_MAX_TILES * sizeof(AV1TileInfo_OLD)) +#define AV1_TILEINFO_BUF_SIZE NVDEC_ALIGN(AV1_MAX_TILES * sizeof(AV1TileInfo)) + +// AV1 TileStreamInfo buffer +#define AV1_TILESTREAMINFO_BUF_SIZE NVDEC_ALIGN(AV1_MAX_TILES * sizeof(AV1TileStreamInfo)) + +// AV1 SubStreamEntry buffer +#define MAX_SUBSTREAM_ENTRY_SIZE 32 +#define AV1_SUBSTREAM_ENTRY_BUF_SIZE NVDEC_ALIGN(MAX_SUBSTREAM_ENTRY_SIZE * sizeof(nvdec_substream_entry_s)) + +// AV1 FilmGrain Parameter buffer +#define AV1_FGS_BUF_SIZE NVDEC_ALIGN(sizeof(AV1FilmGrainMemory)) + +// AV1 Temporal MV buffer +#define AV1_TEMPORAL_MV_SIZE_IN_64x64 256 // 4Bytes for 8x8 +#define AV1_TEMPORAL_MV_BUF_SIZE(w, h) ALIGN_UP( ALIGN_UP(w,128) * ALIGN_UP(h,128) / (64*64) * AV1_TEMPORAL_MV_SIZE_IN_64x64, 4096) + +// AV1 SegmentID buffer +#define AV1_SEGMENT_ID_SIZE_IN_64x64 128 // (3bits + 1 pad_bits) for 4x4 +#define AV1_SEGMENT_ID_BUF_SIZE(w, h) ALIGN_UP( ALIGN_UP(w,128) * ALIGN_UP(h,128) / (64*64) * AV1_SEGMENT_ID_SIZE_IN_64x64, 4096) + +// AV1 Global Motion buffer +#define AV1_GLOBAL_MOTION_BUF_SIZE NVDEC_ALIGN(7*32) + +// AV1 Intra Top buffer +#define AV1_INTRA_TOP_BUF_SIZE NVDEC_ALIGN(8*8192) + +// AV1 Histogram buffer +#define AV1_HISTOGRAM_BUF_SIZE NVDEC_ALIGN(1024) + +// AV1 Filter FG buffer +#define AV1_DBLK_TOP_SIZE_IN_SB64 ALIGN_UP(1920, 128) +#define AV1_DBLK_TOP_BUF_SIZE(w) NVDEC_ALIGN( (ALIGN_UP(w,64)/64 + 2) * AV1_DBLK_TOP_SIZE_IN_SB64) + +#define AV1_DBLK_LEFT_SIZE_IN_SB64 ALIGN_UP(1536, 128) +#define AV1_DBLK_LEFT_BUF_SIZE(h) NVDEC_ALIGN( (ALIGN_UP(h,64)/64 + 2) * AV1_DBLK_LEFT_SIZE_IN_SB64) + +#define AV1_CDEF_LEFT_SIZE_IN_SB64 ALIGN_UP(1792, 128) +#define AV1_CDEF_LEFT_BUF_SIZE(h) NVDEC_ALIGN( (ALIGN_UP(h,64)/64 + 2) * AV1_CDEF_LEFT_SIZE_IN_SB64) + +#define AV1_HUS_LEFT_SIZE_IN_SB64 ALIGN_UP(12544, 128) +#define AV1_ASIC_HUS_LEFT_BUFFER_SIZE(h) NVDEC_ALIGN( (ALIGN_UP(h,64)/64 + 2) * AV1_HUS_LEFT_SIZE_IN_SB64) +#define AV1_HUS_LEFT_BUF_SIZE(h) 2*AV1_ASIC_HUS_LEFT_BUFFER_SIZE(h) // Ping-Pong buffers + +#define AV1_LR_LEFT_SIZE_IN_SB64 ALIGN_UP(1920, 128) +#define AV1_LR_LEFT_BUF_SIZE(h) NVDEC_ALIGN( (ALIGN_UP(h,64)/64 + 2) * AV1_LR_LEFT_SIZE_IN_SB64) + +#define AV1_FGS_LEFT_SIZE_IN_SB64 ALIGN_UP(320, 128) +#define AV1_FGS_LEFT_BUF_SIZE(h) NVDEC_ALIGN( (ALIGN_UP(h,64)/64 + 2) * AV1_FGS_LEFT_SIZE_IN_SB64) + +// AV1 Hint Dump Buffer +#define AV1_HINT_DUMP_SIZE_IN_SB64 ((64*64)/(4*4)*8) // 8 bytes per CU, 256 CUs(2048 bytes) per SB64 +#define AV1_HINT_DUMP_SIZE_IN_SB128 ((128*128)/(4*4)*8) // 8 bytes per CU,1024 CUs(8192 bytes) per SB128 +#define AV1_HINT_DUMP_SIZE(w, h) NVDEC_ALIGN(AV1_HINT_DUMP_SIZE_IN_SB128*((w+127)/128)*((h+127)/128)) // always use SB128 for allocation + + +/******************************************************************* + New H264 +********************************************************************/ +typedef struct _nvdec_new_h264_pic_s +{ + nvdec_pass2_otf_s encryption_params; + unsigned char eos[16]; + unsigned char explicitEOSPresentFlag; + unsigned char hint_dump_en; //enable COLOMV surface dump for all frames, which includes hints of "MV/REFIDX/QP/CBP/MBPART/MBTYPE", nvbug: 200212874 + unsigned char reserved0[2]; + unsigned int stream_len; + unsigned int slice_count; + unsigned int mbhist_buffer_size; // to pass buffer size of MBHIST_BUFFER + + // Driver may or may not use based upon need. + // If 0 then default value of 1<<27 = 298ms @ 450MHz will be used in ucode. + // Driver can send this value based upon resolution using the formula: + // gptimer_timeout_value = 3 * (cycles required for one frame) + unsigned int gptimer_timeout_value; + + // Fields from msvld_h264_seq_s + int log2_max_pic_order_cnt_lsb_minus4; + int delta_pic_order_always_zero_flag; + int frame_mbs_only_flag; + int PicWidthInMbs; + int FrameHeightInMbs; + + unsigned int tileFormat : 2 ; // 0: TBL; 1: KBL; 2: Tile16x16 + unsigned int gob_height : 3 ; // Set GOB height, 0: GOB_2, 1: GOB_4, 2: GOB_8, 3: GOB_16, 4: GOB_32 (NVDEC3 onwards) + unsigned int reserverd_surface_format : 27; + + // Fields from msvld_h264_pic_s + int entropy_coding_mode_flag; + int pic_order_present_flag; + int num_ref_idx_l0_active_minus1; + int num_ref_idx_l1_active_minus1; + int deblocking_filter_control_present_flag; + int redundant_pic_cnt_present_flag; + int transform_8x8_mode_flag; + + // Fields from mspdec_h264_picture_setup_s + unsigned int pitch_luma; // Luma pitch + unsigned int pitch_chroma; // chroma pitch + + unsigned int luma_top_offset; // offset of luma top field in units of 256 + unsigned int luma_bot_offset; // offset of luma bottom field in units of 256 + unsigned int luma_frame_offset; // offset of luma frame in units of 256 + unsigned int chroma_top_offset; // offset of chroma top field in units of 256 + unsigned int chroma_bot_offset; // offset of chroma bottom field in units of 256 + unsigned int chroma_frame_offset; // offset of chroma frame in units of 256 + unsigned int HistBufferSize; // in units of 256 + + unsigned int MbaffFrameFlag : 1; // + unsigned int direct_8x8_inference_flag: 1; // + unsigned int weighted_pred_flag : 1; // + unsigned int constrained_intra_pred_flag:1; // + unsigned int ref_pic_flag : 1; // reference picture (nal_ref_idc != 0) + unsigned int field_pic_flag : 1; // + unsigned int bottom_field_flag : 1; // + unsigned int second_field : 1; // second field of complementary reference field + unsigned int log2_max_frame_num_minus4: 4; // (0..12) + unsigned int chroma_format_idc : 2; // + unsigned int pic_order_cnt_type : 2; // (0..2) + int pic_init_qp_minus26 : 6; // : 6 (-26..+25) + int chroma_qp_index_offset : 5; // : 5 (-12..+12) + int second_chroma_qp_index_offset : 5; // : 5 (-12..+12) + + unsigned int weighted_bipred_idc : 2; // : 2 (0..2) + unsigned int CurrPicIdx : 7; // : 7 uncompressed frame buffer index + unsigned int CurrColIdx : 5; // : 5 index of associated co-located motion data buffer + unsigned int frame_num : 16; // + unsigned int frame_surfaces : 1; // frame surfaces flag + unsigned int output_memory_layout : 1; // 0: NV12; 1:NV24. Field pair must use the same setting. + + int CurrFieldOrderCnt[2]; // : 32 [Top_Bottom], [0]=TopFieldOrderCnt, [1]=BottomFieldOrderCnt + nvdec_dpb_entry_s dpb[16]; + unsigned char WeightScale[6][4][4]; // : 6*4*4*8 in raster scan order (not zig-zag order) + unsigned char WeightScale8x8[2][8][8]; // : 2*8*8*8 in raster scan order (not zig-zag order) + + // mvc setup info, must be zero if not mvc + unsigned char num_inter_view_refs_lX[2]; // number of inter-view references + char reserved1[14]; // reserved for alignment + signed char inter_view_refidx_lX[2][16]; // DPB indices (must also be marked as long-term) + + // lossless decode (At the time of writing this manual, x264 and JM encoders, differ in Intra_8x8 reference sample filtering) + unsigned int lossless_ipred8x8_filter_enable : 1; // = 0, skips Intra_8x8 reference sample filtering, for vertical and horizontal predictions (x264 encoded streams); = 1, filter Intra_8x8 reference samples (JM encoded streams) + unsigned int qpprime_y_zero_transform_bypass_flag : 1; // determines the transform bypass mode + unsigned int reserved2 : 30; // kept for alignment; may be used for other parameters + + nvdec_display_param_s displayPara; + nvdec_pass2_otf_ext_s ssm; + +} nvdec_new_h264_pic_s; + +// golden crc struct dumped into surface +// for each part, if golden crc compare is enabled, one interface is selected to do crc calculation in vmod. +// vmod's crc is compared with cmod's golden crc (4*32 bits), and compare reuslt is written into surface. +typedef struct +{ + // input + unsigned int dbg_crc_enable_partb : 1; // Eable flag for enable/disable interface crc calculation in NVDEC HW's part b + unsigned int dbg_crc_enable_partc : 1; // Eable flag for enable/disable interface crc calculation in NVDEC HW's part c + unsigned int dbg_crc_enable_partd : 1; // Eable flag for enable/disable interface crc calculation in NVDEC HW's part d + unsigned int dbg_crc_enable_parte : 1; // Eable flag for enable/disable interface crc calculation in NVDEC HW's part e + unsigned int dbg_crc_intf_partb : 6; // For partb to select which interface to compare crc. see DBG_CRC_PARTE_INTF_SEL for detailed control value for each interface + unsigned int dbg_crc_intf_partc : 6; // For partc to select which interface to compare crc. see DBG_CRC_PARTE_INTF_SEL for detailed control value for each interface + unsigned int dbg_crc_intf_partd : 6; // For partd to select which interface to compare crc. see DBG_CRC_PARTE_INTF_SEL for detailed control value for each interface + unsigned int dbg_crc_intf_parte : 6; // For parte to select which interface to compare crc. see DBG_CRC_PARTE_INTF_SEL for detailed control value for each interface + unsigned int reserved0 : 4; + + unsigned int dbg_crc_partb_golden[4]; // Golden crc values for part b + unsigned int dbg_crc_partc_golden[4]; // Golden crc values for part c + unsigned int dbg_crc_partd_golden[4]; // Golden crc values for part d + unsigned int dbg_crc_parte_golden[4]; // Golden crc values for part e + + // output + unsigned int dbg_crc_comp_partb : 4; // Compare result for part b + unsigned int dbg_crc_comp_partc : 4; // Compare result for part c + unsigned int dbg_crc_comp_partd : 4; // Compare result for part d + unsigned int dbg_crc_comp_parte : 4; // Compare result for part e + unsigned int reserved1 : 16; + + unsigned char reserved2[56]; +}nvdec_crc_s; // 128 Bytes + +#endif // __DRV_NVDEC_H_ diff --git a/libavutil/nvhost_ioctl.h b/libavutil/nvhost_ioctl.h new file mode 100644 index 0000000000..dd49369391 --- /dev/null +++ b/libavutil/nvhost_ioctl.h @@ -0,0 +1,511 @@ +/* + * include/uapi/linux/nvhost_ioctl.h + * + * Tegra graphics host driver + * + * Copyright (c) 2016-2020, NVIDIA CORPORATION. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __UAPI_LINUX_NVHOST_IOCTL_H +#define __UAPI_LINUX_NVHOST_IOCTL_H + +#ifndef __SWITCH__ +# include +# include +#else +# include + +# define _IO _NV_IO +# define _IOR _NV_IOR +# define _IOW _NV_IOW +# define _IOWR _NV_IOWR + +# define _IOC_DIR _NV_IOC_DIR +# define _IOC_TYPE _NV_IOC_TYPE +# define _IOC_NR _NV_IOC_NR +# define _IOC_SIZE _NV_IOC_SIZE +#endif + +#define __user + +#define NVHOST_INVALID_SYNCPOINT 0xFFFFFFFF +#define NVHOST_NO_TIMEOUT (-1) +#define NVHOST_NO_CONTEXT 0x0 +#define NVHOST_IOCTL_MAGIC 'H' +#define NVHOST_PRIORITY_LOW 50 +#define NVHOST_PRIORITY_MEDIUM 100 +#define NVHOST_PRIORITY_HIGH 150 + +#define NVHOST_TIMEOUT_FLAG_DISABLE_DUMP 0 + +#define NVHOST_SUBMIT_VERSION_V0 0x0 +#define NVHOST_SUBMIT_VERSION_V1 0x1 +#define NVHOST_SUBMIT_VERSION_V2 0x2 +#define NVHOST_SUBMIT_VERSION_MAX_SUPPORTED NVHOST_SUBMIT_VERSION_V2 + +struct nvhost_cmdbuf { + uint32_t mem; + uint32_t offset; + uint32_t words; +} __attribute__((packed)); + +struct nvhost_cmdbuf_ext { + int32_t pre_fence; + uint32_t reserved; +}; + +struct nvhost_reloc { + uint32_t cmdbuf_mem; + uint32_t cmdbuf_offset; + uint32_t target; + uint32_t target_offset; +}; + +struct nvhost_reloc_shift { + uint32_t shift; +} __attribute__((packed)); + +#define NVHOST_RELOC_TYPE_DEFAULT 0 +#define NVHOST_RELOC_TYPE_PITCH_LINEAR 1 +#define NVHOST_RELOC_TYPE_BLOCK_LINEAR 2 +#define NVHOST_RELOC_TYPE_NVLINK 3 +struct nvhost_reloc_type { + uint32_t reloc_type; + uint32_t padding; +}; + +struct nvhost_waitchk { + uint32_t mem; + uint32_t offset; + uint32_t syncpt_id; + uint32_t thresh; +}; + +struct nvhost_syncpt_incr { + uint32_t syncpt_id; + uint32_t syncpt_incrs; +}; + +struct nvhost_get_param_args { + uint32_t value; +} __attribute__((packed)); + +struct nvhost_get_param_arg { + uint32_t param; + uint32_t value; +}; + +struct nvhost_get_client_managed_syncpt_arg { + uint64_t name; + uint32_t param; + uint32_t value; +}; + +struct nvhost_free_client_managed_syncpt_arg { + uint32_t param; + uint32_t value; +}; + +struct nvhost_channel_open_args { + int32_t channel_fd; +}; + +struct nvhost_set_syncpt_name_args { + uint64_t name; + uint32_t syncpt_id; + uint32_t padding; +}; + +struct nvhost_set_nvmap_fd_args { + uint32_t fd; +} __attribute__((packed)); + +enum nvhost_clk_attr { + NVHOST_CLOCK = 0, + NVHOST_BW, + NVHOST_PIXELRATE, + NVHOST_BW_KHZ, +}; + +/* + * moduleid[15:0] => module id + * moduleid[24:31] => nvhost_clk_attr + */ +#define NVHOST_MODULE_ID_BIT_POS 0 +#define NVHOST_MODULE_ID_BIT_WIDTH 16 +#define NVHOST_CLOCK_ATTR_BIT_POS 24 +#define NVHOST_CLOCK_ATTR_BIT_WIDTH 8 +struct nvhost_clk_rate_args { + uint32_t rate; + uint32_t moduleid; +}; + +struct nvhost_set_timeout_args { + uint32_t timeout; +} __attribute__((packed)); + +struct nvhost_set_timeout_ex_args { + uint32_t timeout; + uint32_t flags; +}; + +struct nvhost_set_priority_args { + uint32_t priority; +} __attribute__((packed)); + +struct nvhost_set_error_notifier { + uint64_t offset; + uint64_t size; + uint32_t mem; + uint32_t padding; +}; + +struct nvhost32_ctrl_module_regrdwr_args { + uint32_t id; + uint32_t num_offsets; + uint32_t block_size; + uint32_t offsets; + uint32_t values; + uint32_t write; +}; + +struct nvhost_ctrl_module_regrdwr_args { + uint32_t id; + uint32_t num_offsets; + uint32_t block_size; + uint32_t write; + uint64_t offsets; + uint64_t values; +}; + +struct nvhost32_submit_args { + uint32_t submit_version; + uint32_t num_syncpt_incrs; + uint32_t num_cmdbufs; + uint32_t num_relocs; + uint32_t num_waitchks; + uint32_t timeout; + uint32_t syncpt_incrs; + uint32_t cmdbufs; + uint32_t relocs; + uint32_t reloc_shifts; + uint32_t waitchks; + uint32_t waitbases; + uint32_t class_ids; + + uint32_t pad[2]; /* future expansion */ + + uint32_t fences; + uint32_t fence; /* Return value */ +} __attribute__((packed)); + +#define NVHOST_SUBMIT_FLAG_SYNC_FENCE_FD 0 +#define NVHOST_SUBMIT_MAX_NUM_SYNCPT_INCRS 10 + +struct nvhost_submit_args { + uint32_t submit_version; + uint32_t num_syncpt_incrs; + uint32_t num_cmdbufs; + uint32_t num_relocs; + uint32_t num_waitchks; + uint32_t timeout; + uint32_t flags; + uint32_t fence; /* Return value */ + uint64_t syncpt_incrs; + uint64_t cmdbuf_exts; + + uint32_t checksum_methods; + uint32_t checksum_falcon_methods; + + uint64_t pad[1]; /* future expansion */ + + uint64_t reloc_types; + uint64_t cmdbufs; + uint64_t relocs; + uint64_t reloc_shifts; + uint64_t waitchks; + uint64_t waitbases; + uint64_t class_ids; + uint64_t fences; +}; + +struct nvhost_set_ctxswitch_args { + uint32_t num_cmdbufs_save; + uint32_t num_save_incrs; + uint32_t save_incrs; + uint32_t save_waitbases; + uint32_t cmdbuf_save; + uint32_t num_cmdbufs_restore; + uint32_t num_restore_incrs; + uint32_t restore_incrs; + uint32_t restore_waitbases; + uint32_t cmdbuf_restore; + uint32_t num_relocs; + uint32_t relocs; + uint32_t reloc_shifts; + + uint32_t pad; +}; + +struct nvhost_channel_buffer { + uint32_t dmabuf_fd; /* in */ + uint32_t reserved0; /* reserved, must be 0 */ + uint64_t reserved1[2]; /* reserved, must be 0 */ + uint64_t address; /* out, device view to the buffer */ +}; + +struct nvhost_channel_unmap_buffer_args { + uint32_t num_buffers; /* in, number of buffers to unmap */ + uint32_t reserved; /* reserved, must be 0 */ + uint64_t table_address; /* pointer to beginning of buffer */ +}; + +struct nvhost_channel_map_buffer_args { + uint32_t num_buffers; /* in, number of buffers to map */ + uint32_t reserved; /* reserved, must be 0 */ + uint64_t table_address; /* pointer to beginning of buffer */ +}; + +#define NVHOST_IOCTL_CHANNEL_GET_SYNCPOINTS \ + _IOR(NVHOST_IOCTL_MAGIC, 2, struct nvhost_get_param_args) +#define NVHOST_IOCTL_CHANNEL_GET_WAITBASES \ + _IOR(NVHOST_IOCTL_MAGIC, 3, struct nvhost_get_param_args) +#define NVHOST_IOCTL_CHANNEL_GET_MODMUTEXES \ + _IOR(NVHOST_IOCTL_MAGIC, 4, struct nvhost_get_param_args) +#define NVHOST_IOCTL_CHANNEL_SET_NVMAP_FD \ + _IOW(NVHOST_IOCTL_MAGIC, 5, struct nvhost_set_nvmap_fd_args) +#define NVHOST_IOCTL_CHANNEL_NULL_KICKOFF \ + _IOR(NVHOST_IOCTL_MAGIC, 6, struct nvhost_get_param_args) +#define NVHOST_IOCTL_CHANNEL_GET_CLK_RATE \ + _IOWR(NVHOST_IOCTL_MAGIC, 9, struct nvhost_clk_rate_args) +#define NVHOST_IOCTL_CHANNEL_SET_CLK_RATE \ + _IOW(NVHOST_IOCTL_MAGIC, 10, struct nvhost_clk_rate_args) +#define NVHOST_IOCTL_CHANNEL_SET_TIMEOUT \ + _IOW(NVHOST_IOCTL_MAGIC, 11, struct nvhost_set_timeout_args) +#define NVHOST_IOCTL_CHANNEL_GET_TIMEDOUT \ + _IOR(NVHOST_IOCTL_MAGIC, 12, struct nvhost_get_param_args) +#define NVHOST_IOCTL_CHANNEL_SET_PRIORITY \ + _IOW(NVHOST_IOCTL_MAGIC, 13, struct nvhost_set_priority_args) +#define NVHOST32_IOCTL_CHANNEL_MODULE_REGRDWR \ + _IOWR(NVHOST_IOCTL_MAGIC, 14, struct nvhost32_ctrl_module_regrdwr_args) +#define NVHOST32_IOCTL_CHANNEL_SUBMIT \ + _IOWR(NVHOST_IOCTL_MAGIC, 15, struct nvhost32_submit_args) +#define NVHOST_IOCTL_CHANNEL_GET_SYNCPOINT \ + _IOWR(NVHOST_IOCTL_MAGIC, 16, struct nvhost_get_param_arg) +#define NVHOST_IOCTL_CHANNEL_GET_WAITBASE \ + _IOWR(NVHOST_IOCTL_MAGIC, 17, struct nvhost_get_param_arg) +#define NVHOST_IOCTL_CHANNEL_SET_TIMEOUT_EX \ + _IOWR(NVHOST_IOCTL_MAGIC, 18, struct nvhost_set_timeout_ex_args) +#define NVHOST_IOCTL_CHANNEL_GET_CLIENT_MANAGED_SYNCPOINT \ + _IOWR(NVHOST_IOCTL_MAGIC, 19, struct nvhost_get_client_managed_syncpt_arg) +#define NVHOST_IOCTL_CHANNEL_FREE_CLIENT_MANAGED_SYNCPOINT \ + _IOWR(NVHOST_IOCTL_MAGIC, 20, struct nvhost_free_client_managed_syncpt_arg) +#define NVHOST_IOCTL_CHANNEL_GET_MODMUTEX \ + _IOWR(NVHOST_IOCTL_MAGIC, 23, struct nvhost_get_param_arg) +#define NVHOST_IOCTL_CHANNEL_SET_CTXSWITCH \ + _IOWR(NVHOST_IOCTL_MAGIC, 25, struct nvhost_set_ctxswitch_args) + +/* ioctls added for 64bit compatibility */ +#define NVHOST_IOCTL_CHANNEL_SUBMIT \ + _IOWR(NVHOST_IOCTL_MAGIC, 26, struct nvhost_submit_args) +#define NVHOST_IOCTL_CHANNEL_MODULE_REGRDWR \ + _IOWR(NVHOST_IOCTL_MAGIC, 27, struct nvhost_ctrl_module_regrdwr_args) + +#define NVHOST_IOCTL_CHANNEL_MAP_BUFFER \ + _IOWR(NVHOST_IOCTL_MAGIC, 28, struct nvhost_channel_map_buffer_args) +#define NVHOST_IOCTL_CHANNEL_UNMAP_BUFFER \ + _IOWR(NVHOST_IOCTL_MAGIC, 29, struct nvhost_channel_unmap_buffer_args) + +#define NVHOST_IOCTL_CHANNEL_SET_SYNCPOINT_NAME \ + _IOW(NVHOST_IOCTL_MAGIC, 30, struct nvhost_set_syncpt_name_args) + +#define NVHOST_IOCTL_CHANNEL_SET_ERROR_NOTIFIER \ + _IOWR(NVHOST_IOCTL_MAGIC, 111, struct nvhost_set_error_notifier) +#define NVHOST_IOCTL_CHANNEL_OPEN \ + _IOR(NVHOST_IOCTL_MAGIC, 112, struct nvhost_channel_open_args) + +#define NVHOST_IOCTL_CHANNEL_LAST \ + _IOC_NR(NVHOST_IOCTL_CHANNEL_OPEN) +#define NVHOST_IOCTL_CHANNEL_MAX_ARG_SIZE sizeof(struct nvhost_submit_args) + +struct nvhost_ctrl_syncpt_read_args { + uint32_t id; + uint32_t value; +}; + +struct nvhost_ctrl_syncpt_incr_args { + uint32_t id; +} __attribute__((packed)); + +struct nvhost_ctrl_syncpt_wait_args { + uint32_t id; + uint32_t thresh; + int32_t timeout; +} __attribute__((packed)); + +struct nvhost_ctrl_syncpt_waitex_args { + uint32_t id; + uint32_t thresh; + int32_t timeout; + uint32_t value; +}; + +struct nvhost_ctrl_syncpt_waitmex_args { + uint32_t id; + uint32_t thresh; + int32_t timeout; + uint32_t value; + uint32_t tv_sec; + uint32_t tv_nsec; + uint32_t clock_id; + uint32_t reserved; +}; + +struct nvhost_ctrl_sync_fence_info { + uint32_t id; + uint32_t thresh; +}; + +struct nvhost32_ctrl_sync_fence_create_args { + uint32_t num_pts; + uint64_t pts; /* struct nvhost_ctrl_sync_fence_info* */ + uint64_t name; /* const char* */ + int32_t fence_fd; /* fd of new fence */ +}; + +struct nvhost_ctrl_sync_fence_create_args { + uint32_t num_pts; + int32_t fence_fd; /* fd of new fence */ + uint64_t pts; /* struct nvhost_ctrl_sync_fence_info* */ + uint64_t name; /* const char* */ +}; + +struct nvhost_ctrl_sync_fence_name_args { + uint64_t name; /* const char* for name */ + int32_t fence_fd; /* fd of fence */ +}; + +struct nvhost_ctrl_module_mutex_args { + uint32_t id; + uint32_t lock; +}; + +enum nvhost_module_id { + NVHOST_MODULE_NONE = -1, + NVHOST_MODULE_DISPLAY_A = 0, + NVHOST_MODULE_DISPLAY_B, + NVHOST_MODULE_VI, + NVHOST_MODULE_ISP, + NVHOST_MODULE_MPE, + NVHOST_MODULE_MSENC, + NVHOST_MODULE_TSEC, + NVHOST_MODULE_GPU, + NVHOST_MODULE_VIC, + NVHOST_MODULE_NVDEC, + NVHOST_MODULE_NVJPG, + NVHOST_MODULE_VII2C, + NVHOST_MODULE_NVENC1, + NVHOST_MODULE_NVDEC1, + NVHOST_MODULE_NVCSI, + NVHOST_MODULE_TSECB = (1<<16) | NVHOST_MODULE_TSEC, +}; + +struct nvhost_characteristics { +#define NVHOST_CHARACTERISTICS_GFILTER (1 << 0) +#define NVHOST_CHARACTERISTICS_RESOURCE_PER_CHANNEL_INSTANCE (1 << 1) +#define NVHOST_CHARACTERISTICS_SUPPORT_PREFENCES (1 << 2) + uint64_t flags; + + uint32_t num_mlocks; + uint32_t num_syncpts; + + uint32_t syncpts_base; + uint32_t syncpts_limit; + + uint32_t num_hw_pts; + uint32_t padding; +}; + +struct nvhost_ctrl_get_characteristics { + uint64_t nvhost_characteristics_buf_size; + uint64_t nvhost_characteristics_buf_addr; +}; + +struct nvhost_ctrl_check_module_support_args { + uint32_t module_id; + uint32_t value; +}; + +struct nvhost_ctrl_poll_fd_create_args { + int32_t fd; + uint32_t padding; +}; + +struct nvhost_ctrl_poll_fd_trigger_event_args { + int32_t fd; + uint32_t id; + uint32_t thresh; + uint32_t padding; +}; + +#define NVHOST_IOCTL_CTRL_SYNCPT_READ \ + _IOWR(NVHOST_IOCTL_MAGIC, 1, struct nvhost_ctrl_syncpt_read_args) +#define NVHOST_IOCTL_CTRL_SYNCPT_INCR \ + _IOW(NVHOST_IOCTL_MAGIC, 2, struct nvhost_ctrl_syncpt_incr_args) +#define NVHOST_IOCTL_CTRL_SYNCPT_WAIT \ + _IOW(NVHOST_IOCTL_MAGIC, 3, struct nvhost_ctrl_syncpt_wait_args) + +#define NVHOST_IOCTL_CTRL_MODULE_MUTEX \ + _IOWR(NVHOST_IOCTL_MAGIC, 4, struct nvhost_ctrl_module_mutex_args) +#define NVHOST32_IOCTL_CTRL_MODULE_REGRDWR \ + _IOWR(NVHOST_IOCTL_MAGIC, 5, struct nvhost32_ctrl_module_regrdwr_args) + +#define NVHOST_IOCTL_CTRL_SYNCPT_WAITEX \ + _IOWR(NVHOST_IOCTL_MAGIC, 6, struct nvhost_ctrl_syncpt_waitex_args) + +#define NVHOST_IOCTL_CTRL_GET_VERSION \ + _IOR(NVHOST_IOCTL_MAGIC, 7, struct nvhost_get_param_args) + +#define NVHOST_IOCTL_CTRL_SYNCPT_READ_MAX \ + _IOWR(NVHOST_IOCTL_MAGIC, 8, struct nvhost_ctrl_syncpt_read_args) + +#define NVHOST_IOCTL_CTRL_SYNCPT_WAITMEX \ + _IOWR(NVHOST_IOCTL_MAGIC, 9, struct nvhost_ctrl_syncpt_waitmex_args) + +#define NVHOST32_IOCTL_CTRL_SYNC_FENCE_CREATE \ + _IOWR(NVHOST_IOCTL_MAGIC, 10, struct nvhost32_ctrl_sync_fence_create_args) +#define NVHOST_IOCTL_CTRL_SYNC_FENCE_CREATE \ + _IOWR(NVHOST_IOCTL_MAGIC, 11, struct nvhost_ctrl_sync_fence_create_args) +#define NVHOST_IOCTL_CTRL_MODULE_REGRDWR \ + _IOWR(NVHOST_IOCTL_MAGIC, 12, struct nvhost_ctrl_module_regrdwr_args) +#define NVHOST_IOCTL_CTRL_SYNC_FENCE_SET_NAME \ + _IOWR(NVHOST_IOCTL_MAGIC, 13, struct nvhost_ctrl_sync_fence_name_args) +#define NVHOST_IOCTL_CTRL_GET_CHARACTERISTICS \ + _IOWR(NVHOST_IOCTL_MAGIC, 14, struct nvhost_ctrl_get_characteristics) +#define NVHOST_IOCTL_CTRL_CHECK_MODULE_SUPPORT \ + _IOWR(NVHOST_IOCTL_MAGIC, 15, struct nvhost_ctrl_check_module_support_args) +#define NVHOST_IOCTL_CTRL_POLL_FD_CREATE \ + _IOR(NVHOST_IOCTL_MAGIC, 16, struct nvhost_ctrl_poll_fd_create_args) +#define NVHOST_IOCTL_CTRL_POLL_FD_TRIGGER_EVENT \ + _IOW(NVHOST_IOCTL_MAGIC, 17, struct nvhost_ctrl_poll_fd_trigger_event_args) + +#define NVHOST_IOCTL_CTRL_LAST \ + _IOC_NR(NVHOST_IOCTL_CTRL_POLL_FD_TRIGGER_EVENT) +#define NVHOST_IOCTL_CTRL_MAX_ARG_SIZE \ + sizeof(struct nvhost_ctrl_syncpt_waitmex_args) + +#endif diff --git a/libavutil/nvjpg_drv.h b/libavutil/nvjpg_drv.h new file mode 100644 index 0000000000..35b6c5d337 --- /dev/null +++ b/libavutil/nvjpg_drv.h @@ -0,0 +1,189 @@ +/******************************************************************************* + Copyright (c) 2016-2020, NVIDIA CORPORATION. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + +*******************************************************************************/ + +#ifndef NVJPG_DRV_H +#define NVJPG_DRV_H + +#include + +typedef uint8_t NvU8; +typedef uint16_t NvU16; +typedef uint32_t NvU32; +typedef uint64_t NvU64; +typedef int8_t NvS8; +typedef int16_t NvS16; +typedef int32_t NvS32; +typedef int64_t NvS64; +typedef _Bool NvBool; + +// +// CLASS NV_E7D0_NVJPG +// +// NVJPG is the combination of JPEG decoder and encoder, it will support baseline sequential profile. +// In the encoder side, it support: a. 420 pitch linear format, b. programable huffman/qunat table, ... etc. +// In the decoder side, it support: a. 400/420/422/444 decoding, b. YUV2RGB, c. Power2Scale: 1/2, 1/4, 1/8, d.ChromaSumbSample ... etc. +// =================== + + +// huffuman table: +// huffuman table is organized in symbol value order, each table item include 2 field, codeWord length, and codeWord value +#define DCVALUEITEM 12 +#define ACVALUEITEM 256 // in fact, only 162 items are used in baseline sequential profile. +typedef struct +{ + unsigned short length; // 4 bit, code word length + unsigned short value; // 16 bit, code word value +}huffman_symbol_s; + + +typedef struct +{ + // surface related + unsigned int bitstream_start_off;// start offset position in bitstream buffer where data should be written (byte offset) + unsigned int bitstream_buf_size; // size in bytes of the buffer allocated for bitstream slice/mb data + unsigned int luma_stride; // 64 bytes align; + unsigned int chroma_stride; // 64 bytes align; + unsigned int inputType : 4; // 0: YUV; 1: RGB, 2: BGR, 3:RGBA, 4: BGRA, 5: ABGR, 6: ARGB + unsigned int chromaFormat : 2; // chroma format: 0: 444; 1: 422H; 2:422V; 3:420 + unsigned int tilingMode : 2; // 0: linear; 1: GPU_blkLinear; 2: Tegra_blkLinear + unsigned int gobHeight : 3; // used for blkLinear, 0: 2; 1: 4; ... 4: 32 + unsigned int yuvMemoryMode: 3; // 0-semi planar nv12; 1-semi planar nv21; 2-plane(yuy2); 3-planar + unsigned int reserved_0 : 18; + // control para + unsigned short imageWidth; // real image width, up to 16K + unsigned short imageHeight; // real image height, up to 16K + unsigned short jpegWidth; // image width align to 8 or 16 pixel + unsigned short jpegHeight; // image height align to 8 or 16 pixel + unsigned int totalMcu; + unsigned int widthMcu; + unsigned int heightMcu; + unsigned int restartInterval; // restart interval, 0 means disable the restart feature + + // rate control related + unsigned int rateControl : 2; // RC: 0:disable; 1:block-base; others: reserve + unsigned int rcTargetYBits : 11; // target luma bits per block, [0 ~ (1<<11)-1] + unsigned int rcTargetCBits : 11; // target chroma bits per block, [0 ~ (1<<11)-1] + unsigned int reserved_1 : 8; + unsigned int preQuant : 1; // pre quant trunction enabled flag + unsigned int rcThreshIdx : 8; // pre_quant threshold index [1 ~ 63] + unsigned int rcThreshMag : 21; // threshold magnitude + // mjpeg-typeB + unsigned int isMjpgTypeB : 1; // a flag indicate mjpg type B format, which control HW no stuff byte. + unsigned int reserved_2 : 1; + // huffman tables + huffman_symbol_s hfDcLuma[DCVALUEITEM]; //dc luma huffman table, arranged in symbol increase order, encoder can directly index and use + huffman_symbol_s hfAcLuma[ACVALUEITEM]; //ac luma huffman table, arranged in symbol increase order, encoder can directly index and use + huffman_symbol_s hfDcChroma[DCVALUEITEM]; //dc chroma huffman table, arranged in symbol increase order, encoder can directly index and use + huffman_symbol_s hfAcChroma[ACVALUEITEM]; //ac chroma huffman table, arranged in symbol increase order, encoder can directly index and use + // quantization tables + unsigned short quantLumaFactor[64]; //luma quantize factor table, arranged in horizontal scan order, (1<<15)/quantLuma + unsigned short quantChromaFactor[64]; //chroma quantize factor table, arranged in horizontal scan order, (1<<15)/quantLuma + + unsigned char reserve[0x6c]; +}nvjpg_enc_drv_pic_setup_s; + +typedef struct +{ + unsigned int bitstream_size; //exact residual part bitstram size of current image + unsigned int mcu_x; //encoded mcu_x + unsigned int mcu_y; //encoded mcu_y + unsigned int cycle_count; + unsigned int error_status; //report error if any + unsigned char reserved1[12]; +}nvjpg_enc_status; + +struct ctrl_param_s +{ + union + { + struct + { + unsigned int gptimer_on :1; + unsigned int dump_cycle :1; + unsigned int debug_mode :1; + unsigned int reserved :29; + }bits; + unsigned int data; + }; +}; + + +//NVJPG Decoder class interface +typedef struct +{ + int codeNum[16]; //the number of huffman code with length i + unsigned char minCodeIdx[16]; //the index of the min huffman code with length i + int minCode[16]; //the min huffman code with length i + unsigned char symbol[162]; // symbol need to be coded. + unsigned char reserved[2]; // alignment +}huffman_tab_s; + +typedef struct +{ + unsigned char hblock; + unsigned char vblock; + unsigned char quant; + unsigned char ac; + unsigned char dc; + unsigned char reserved[3]; //alignment +} block_parameter_s; + +typedef struct +{ + huffman_tab_s huffTab[2][4]; + block_parameter_s blkPar[4]; + unsigned char quant[4][64]; //quant table + int restart_interval; + int frame_width; + int frame_height; + int mcu_width; + int mcu_height; + int comp; + int bitstream_offset; + int bitstream_size; + int stream_chroma_mode; //0-mono chrome; 1-yuv420; 2-yuv422H; 3-yuv422V; 4-yuv444; + int output_chroma_mode; //0-mono chrome; 1-yuv420; 2-yuv422H; 3-yuv422V; 4-yuv444; + int output_pixel_format; //0-yuv; 1-RGB; 2-BGR; 3-RGBA; 4-BGRA; 5-ABGR; 6-ARGB + int output_stride_luma; //64 bytes align + int output_stride_chroma; //64 bytes align + int alpha_value; + int yuv2rgb_param[6]; //K0, K1, K2, K3, K4, C + int tile_mode; //0-pitch linear; 1-gpu block linear; 2-tegra block linear + int block_linear_height; + int memory_mode; //0-semi planar nv12; 1-semi planar nv21; 2-plane(yuy2); 3-planar + int power2_downscale; //0-no scale; 1- 1/2; 2- 1/4; 3- 1/8 + int motion_jpeg_type; //0-type A; 1-type B + int start_mcu_x; //set start mcu x for error robust + int start_mcu_y; //set start mcu y for error robust +}nvjpg_dec_drv_pic_setup_s; + +typedef struct +{ + unsigned int bytes_offset; //bytes consumed by HW + unsigned int mcu_x; //decoded mcu_x + unsigned int mcu_y; //decoded mcu_y + unsigned int cycle_count; + unsigned int error_status; //report error if any + unsigned char reserved1[12]; +}nvjpg_dec_status; +#endif diff --git a/libavutil/nvmap_ioctl.h b/libavutil/nvmap_ioctl.h new file mode 100644 index 0000000000..bc9b67dfcf --- /dev/null +++ b/libavutil/nvmap_ioctl.h @@ -0,0 +1,451 @@ +/* + * include/uapi/linux/nvmap.h + * + * structure declarations for nvmem and nvmap user-space ioctls + * + * Copyright (c) 2009-2020, NVIDIA CORPORATION. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#ifndef __SWITCH__ +#include +#include +#else +# include + +# define _IO _NV_IO +# define _IOR _NV_IOR +# define _IOW _NV_IOW +# define _IOWR _NV_IOWR + +# define _IOC_DIR _NV_IOC_DIR +# define _IOC_TYPE _NV_IOC_TYPE +# define _IOC_NR _NV_IOC_NR +# define _IOC_SIZE _NV_IOC_SIZE +#endif + +#ifndef __UAPI_LINUX_NVMAP_H +#define __UAPI_LINUX_NVMAP_H + +/* + * From linux-headers nvidia/include/linux/nvmap.h + */ +#define NVMAP_HEAP_IOVMM (1ul<<30) + +/* common carveout heaps */ +#define NVMAP_HEAP_CARVEOUT_IRAM (1ul<<29) +#define NVMAP_HEAP_CARVEOUT_VPR (1ul<<28) +#define NVMAP_HEAP_CARVEOUT_TSEC (1ul<<27) +#define NVMAP_HEAP_CARVEOUT_VIDMEM (1ul<<26) +#define NVMAP_HEAP_CARVEOUT_IVM (1ul<<1) +#define NVMAP_HEAP_CARVEOUT_GENERIC (1ul<<0) + +#define NVMAP_HEAP_CARVEOUT_MASK (NVMAP_HEAP_IOVMM - 1) + +/* allocation flags */ +#define NVMAP_HANDLE_UNCACHEABLE (0x0ul << 0) +#define NVMAP_HANDLE_WRITE_COMBINE (0x1ul << 0) +#define NVMAP_HANDLE_INNER_CACHEABLE (0x2ul << 0) +#define NVMAP_HANDLE_CACHEABLE (0x3ul << 0) +#define NVMAP_HANDLE_CACHE_FLAG (0x3ul << 0) + +#define NVMAP_HANDLE_SECURE (0x1ul << 2) +#define NVMAP_HANDLE_KIND_SPECIFIED (0x1ul << 3) +#define NVMAP_HANDLE_COMPR_SPECIFIED (0x1ul << 4) +#define NVMAP_HANDLE_ZEROED_PAGES (0x1ul << 5) +#define NVMAP_HANDLE_PHYS_CONTIG (0x1ul << 6) +#define NVMAP_HANDLE_CACHE_SYNC (0x1ul << 7) +#define NVMAP_HANDLE_CACHE_SYNC_AT_RESERVE (0x1ul << 8) +#define NVMAP_HANDLE_RO (0x1ul << 9) + +/* + * DOC: NvMap Userspace API + * + * create a client by opening /dev/nvmap + * most operations handled via following ioctls + * + */ +enum { + NVMAP_HANDLE_PARAM_SIZE = 1, + NVMAP_HANDLE_PARAM_ALIGNMENT, + NVMAP_HANDLE_PARAM_BASE, + NVMAP_HANDLE_PARAM_HEAP, + NVMAP_HANDLE_PARAM_KIND, + NVMAP_HANDLE_PARAM_COMPR, /* ignored, to be removed */ +}; + +enum { + NVMAP_CACHE_OP_WB = 0, + NVMAP_CACHE_OP_INV, + NVMAP_CACHE_OP_WB_INV, +}; + +enum { + NVMAP_PAGES_UNRESERVE = 0, + NVMAP_PAGES_RESERVE, + NVMAP_INSERT_PAGES_ON_UNRESERVE, + NVMAP_PAGES_PROT_AND_CLEAN, +}; + +#define NVMAP_ELEM_SIZE_U64 (1 << 31) + +struct nvmap_create_handle { + union { + struct { + union { + /* size will be overwritten */ + uint32_t size; /* CreateHandle */ + int32_t fd; /* DmaBufFd or FromFd */ + }; + uint32_t handle; /* returns nvmap handle */ + }; + struct { + /* one is input parameter, and other is output parameter + * since its a union please note that input parameter + * will be overwritten once ioctl returns + */ + union { + uint64_t ivm_id; /* CreateHandle from ivm*/ + int32_t ivm_handle; /* Get ivm_id from handle */ + }; + }; + struct { + union { + /* size64 will be overwritten */ + uint64_t size64; /* CreateHandle */ + uint32_t handle64; /* returns nvmap handle */ + }; + }; + }; +}; + +struct nvmap_create_handle_from_va { + uint64_t va; /* FromVA*/ + uint32_t size; /* non-zero for partial memory VMA. zero for end of VMA */ + uint32_t flags; /* wb/wc/uc/iwb, tag etc. */ + union { + uint32_t handle; /* returns nvmap handle */ + uint64_t size64; /* used when size is 0 */ + }; +}; + +struct nvmap_gup_test { + uint64_t va; /* FromVA*/ + uint32_t handle; /* returns nvmap handle */ + uint32_t result; /* result=1 for pass, result=-err for failure */ +}; + +struct nvmap_alloc_handle { + uint32_t handle; /* nvmap handle */ + uint32_t heap_mask; /* heaps to allocate from */ + uint32_t flags; /* wb/wc/uc/iwb etc. */ + uint32_t align; /* min alignment necessary */ +}; + +struct nvmap_alloc_ivm_handle { + uint32_t handle; /* nvmap handle */ + uint32_t heap_mask; /* heaps to allocate from */ + uint32_t flags; /* wb/wc/uc/iwb etc. */ + uint32_t align; /* min alignment necessary */ + uint32_t peer; /* peer with whom handle must be shared. Used + * only for NVMAP_HEAP_CARVEOUT_IVM + */ +}; + +struct nvmap_alloc_kind_handle { + uint32_t handle; /* nvmap handle */ + uint32_t heap_mask; + uint32_t flags; + uint32_t align; + uint8_t kind; + uint8_t comp_tags; +}; + +struct nvmap_map_caller { + uint32_t handle; /* nvmap handle */ + uint32_t offset; /* offset into hmem; should be page-aligned */ + uint32_t length; /* number of bytes to map */ + uint32_t flags; /* maps as wb/iwb etc. */ + unsigned long addr; /* user pointer */ +}; + +#ifdef CONFIG_COMPAT +struct nvmap_map_caller_32 { + uint32_t handle; /* nvmap handle */ + uint32_t offset; /* offset into hmem; should be page-aligned */ + uint32_t length; /* number of bytes to map */ + uint32_t flags; /* maps as wb/iwb etc. */ + uint32_t addr; /* user pointer*/ +}; +#endif + +struct nvmap_rw_handle { + unsigned long addr; /* user pointer*/ + uint32_t handle; /* nvmap handle */ + uint32_t offset; /* offset into hmem */ + uint32_t elem_size; /* individual atom size */ + uint32_t hmem_stride; /* delta in bytes between atoms in hmem */ + uint32_t user_stride; /* delta in bytes between atoms in user */ + uint32_t count; /* number of atoms to copy */ +}; + +struct nvmap_rw_handle_64 { + unsigned long addr; /* user pointer*/ + uint32_t handle; /* nvmap handle */ + uint64_t offset; /* offset into hmem */ + uint64_t elem_size; /* individual atom size */ + uint64_t hmem_stride; /* delta in bytes between atoms in hmem */ + uint64_t user_stride; /* delta in bytes between atoms in user */ + uint64_t count; /* number of atoms to copy */ +}; + +#ifdef CONFIG_COMPAT +struct nvmap_rw_handle_32 { + uint32_t addr; /* user pointer */ + uint32_t handle; /* nvmap handle */ + uint32_t offset; /* offset into hmem */ + uint32_t elem_size; /* individual atom size */ + uint32_t hmem_stride; /* delta in bytes between atoms in hmem */ + uint32_t user_stride; /* delta in bytes between atoms in user */ + uint32_t count; /* number of atoms to copy */ +}; +#endif + +struct nvmap_pin_handle { + uint32_t *handles; /* array of handles to pin/unpin */ + unsigned long *addr; /* array of addresses to return */ + uint32_t count; /* number of entries in handles */ +}; + +#ifdef CONFIG_COMPAT +struct nvmap_pin_handle_32 { + uint32_t handles; /* array of handles to pin/unpin */ + uint32_t addr; /* array of addresses to return */ + uint32_t count; /* number of entries in handles */ +}; +#endif + +struct nvmap_handle_param { + uint32_t handle; /* nvmap handle */ + uint32_t param; /* size/align/base/heap etc. */ + unsigned long result; /* returns requested info*/ +}; + +#ifdef CONFIG_COMPAT +struct nvmap_handle_param_32 { + uint32_t handle; /* nvmap handle */ + uint32_t param; /* size/align/base/heap etc. */ + uint32_t result; /* returns requested info*/ +}; +#endif + +struct nvmap_cache_op { + unsigned long addr; /* user pointer*/ + uint32_t handle; /* nvmap handle */ + uint32_t len; /* bytes to flush */ + int32_t op; /* wb/wb_inv/inv */ +}; + +struct nvmap_cache_op_64 { + unsigned long addr; /* user pointer*/ + uint32_t handle; /* nvmap handle */ + uint64_t len; /* bytes to flush */ + int32_t op; /* wb/wb_inv/inv */ +}; + +#ifdef CONFIG_COMPAT +struct nvmap_cache_op_32 { + uint32_t addr; /* user pointer*/ + uint32_t handle; /* nvmap handle */ + uint32_t len; /* bytes to flush */ + int32_t op; /* wb/wb_inv/inv */ +}; +#endif + +struct nvmap_cache_op_list { + uint64_t handles; /* Ptr to u32 type array, holding handles */ + uint64_t offsets; /* Ptr to u32 type array, holding offsets + * into handle mem */ + uint64_t sizes; /* Ptr to u32 type array, holindg sizes of memory + * regions within each handle */ + uint32_t nr; /* Number of handles */ + int32_t op; /* wb/wb_inv/inv */ +}; + +struct nvmap_debugfs_handles_header { + uint8_t version; +}; + +struct nvmap_debugfs_handles_entry { + uint64_t base; + uint64_t size; + uint32_t flags; + uint32_t share_count; + uint64_t mapped_size; +}; + +struct nvmap_set_tag_label { + uint32_t tag; + uint32_t len; /* in: label length + out: number of characters copied */ + uint64_t addr; /* in: pointer to label or NULL to remove */ +}; + +struct nvmap_available_heaps { + uint64_t heaps; /* heaps bitmask */ +}; + +struct nvmap_heap_size { + uint32_t heap; + uint64_t size; +}; + +/** + * Struct used while querying heap parameters + */ +struct nvmap_query_heap_params { + uint32_t heap_mask; + uint32_t flags; + uint8_t contig; + uint64_t total; + uint64_t free; + uint64_t largest_free_block; +}; + +struct nvmap_handle_parameters { + uint8_t contig; + uint32_t import_id; + uint32_t handle; + uint32_t heap_number; + uint32_t access_flags; + uint64_t heap; + uint64_t align; + uint64_t coherency; + uint64_t size; +}; + +#define NVMAP_IOC_MAGIC 'N' + +/* Creates a new memory handle. On input, the argument is the size of the new + * handle; on return, the argument is the name of the new handle + */ +#define NVMAP_IOC_CREATE _IOWR(NVMAP_IOC_MAGIC, 0, struct nvmap_create_handle) +#define NVMAP_IOC_CREATE_64 \ + _IOWR(NVMAP_IOC_MAGIC, 1, struct nvmap_create_handle) +#define NVMAP_IOC_FROM_ID _IOWR(NVMAP_IOC_MAGIC, 2, struct nvmap_create_handle) + +/* Actually allocates memory for the specified handle */ +#define NVMAP_IOC_ALLOC _IOW(NVMAP_IOC_MAGIC, 3, struct nvmap_alloc_handle) + +/* Frees a memory handle, unpinning any pinned pages and unmapping any mappings + */ +#define NVMAP_IOC_FREE _IO(NVMAP_IOC_MAGIC, 4) + +/* Maps the region of the specified handle into a user-provided virtual address + * that was previously created via an mmap syscall on this fd */ +#define NVMAP_IOC_MMAP _IOWR(NVMAP_IOC_MAGIC, 5, struct nvmap_map_caller) +#ifdef CONFIG_COMPAT +#define NVMAP_IOC_MMAP_32 _IOWR(NVMAP_IOC_MAGIC, 5, struct nvmap_map_caller_32) +#endif + +/* Reads/writes data (possibly strided) from a user-provided buffer into the + * hmem at the specified offset */ +#define NVMAP_IOC_WRITE _IOW(NVMAP_IOC_MAGIC, 6, struct nvmap_rw_handle) +#define NVMAP_IOC_READ _IOW(NVMAP_IOC_MAGIC, 7, struct nvmap_rw_handle) +#ifdef CONFIG_COMPAT +#define NVMAP_IOC_WRITE_32 _IOW(NVMAP_IOC_MAGIC, 6, struct nvmap_rw_handle_32) +#define NVMAP_IOC_READ_32 _IOW(NVMAP_IOC_MAGIC, 7, struct nvmap_rw_handle_32) +#endif +#define NVMAP_IOC_WRITE_64 \ + _IOW(NVMAP_IOC_MAGIC, 6, struct nvmap_rw_handle_64) +#define NVMAP_IOC_READ_64 \ + _IOW(NVMAP_IOC_MAGIC, 7, struct nvmap_rw_handle_64) + +#define NVMAP_IOC_PARAM _IOWR(NVMAP_IOC_MAGIC, 8, struct nvmap_handle_param) +#ifdef CONFIG_COMPAT +#define NVMAP_IOC_PARAM_32 _IOWR(NVMAP_IOC_MAGIC, 8, struct nvmap_handle_param_32) +#endif + +/* Pins a list of memory handles into IO-addressable memory (either IOVMM + * space or physical memory, depending on the allocation), and returns the + * address. Handles may be pinned recursively. */ +#define NVMAP_IOC_PIN_MULT _IOWR(NVMAP_IOC_MAGIC, 10, struct nvmap_pin_handle) +#define NVMAP_IOC_UNPIN_MULT _IOW(NVMAP_IOC_MAGIC, 11, struct nvmap_pin_handle) +#ifdef CONFIG_COMPAT +#define NVMAP_IOC_PIN_MULT_32 _IOWR(NVMAP_IOC_MAGIC, 10, struct nvmap_pin_handle_32) +#define NVMAP_IOC_UNPIN_MULT_32 _IOW(NVMAP_IOC_MAGIC, 11, struct nvmap_pin_handle_32) +#endif + +#define NVMAP_IOC_CACHE _IOW(NVMAP_IOC_MAGIC, 12, struct nvmap_cache_op) +#define NVMAP_IOC_CACHE_64 _IOW(NVMAP_IOC_MAGIC, 12, struct nvmap_cache_op_64) +#ifdef CONFIG_COMPAT +#define NVMAP_IOC_CACHE_32 _IOW(NVMAP_IOC_MAGIC, 12, struct nvmap_cache_op_32) +#endif + +/* Returns a global ID usable to allow a remote process to create a handle + * reference to the same handle */ +#define NVMAP_IOC_GET_ID _IOWR(NVMAP_IOC_MAGIC, 13, struct nvmap_create_handle) + +/* Returns a dma-buf fd usable to allow a remote process to create a handle + * reference to the same handle */ +#define NVMAP_IOC_SHARE _IOWR(NVMAP_IOC_MAGIC, 14, struct nvmap_create_handle) + +/* Returns a file id that allows a remote process to create a handle + * reference to the same handle */ +#define NVMAP_IOC_GET_FD _IOWR(NVMAP_IOC_MAGIC, 15, struct nvmap_create_handle) + +/* Create a new memory handle from file id passed */ +#define NVMAP_IOC_FROM_FD _IOWR(NVMAP_IOC_MAGIC, 16, struct nvmap_create_handle) + +/* Perform cache maintenance on a list of handles. */ +#define NVMAP_IOC_CACHE_LIST _IOW(NVMAP_IOC_MAGIC, 17, \ + struct nvmap_cache_op_list) +/* Perform reserve operation on a list of handles. */ +#define NVMAP_IOC_RESERVE _IOW(NVMAP_IOC_MAGIC, 18, \ + struct nvmap_cache_op_list) + +#define NVMAP_IOC_FROM_IVC_ID _IOWR(NVMAP_IOC_MAGIC, 19, struct nvmap_create_handle) +#define NVMAP_IOC_GET_IVC_ID _IOWR(NVMAP_IOC_MAGIC, 20, struct nvmap_create_handle) +#define NVMAP_IOC_GET_IVM_HEAPS _IOR(NVMAP_IOC_MAGIC, 21, unsigned int) + +/* Create a new memory handle from VA passed */ +#define NVMAP_IOC_FROM_VA _IOWR(NVMAP_IOC_MAGIC, 22, struct nvmap_create_handle_from_va) + +#define NVMAP_IOC_GUP_TEST _IOWR(NVMAP_IOC_MAGIC, 23, struct nvmap_gup_test) + +/* Define a label for allocation tag */ +#define NVMAP_IOC_SET_TAG_LABEL _IOW(NVMAP_IOC_MAGIC, 24, struct nvmap_set_tag_label) + +#define NVMAP_IOC_GET_AVAILABLE_HEAPS \ + _IOR(NVMAP_IOC_MAGIC, 25, struct nvmap_available_heaps) + +#define NVMAP_IOC_GET_HEAP_SIZE \ + _IOR(NVMAP_IOC_MAGIC, 26, struct nvmap_heap_size) + +#define NVMAP_IOC_PARAMETERS \ + _IOR(NVMAP_IOC_MAGIC, 27, struct nvmap_handle_parameters) +/* START of T124 IOCTLS */ +/* Actually allocates memory for the specified handle, with kind */ +#define NVMAP_IOC_ALLOC_KIND _IOW(NVMAP_IOC_MAGIC, 100, struct nvmap_alloc_kind_handle) + +/* Actually allocates memory from IVM heaps */ +#define NVMAP_IOC_ALLOC_IVM _IOW(NVMAP_IOC_MAGIC, 101, struct nvmap_alloc_ivm_handle) + +/* Allocate seperate memory for VPR */ +#define NVMAP_IOC_VPR_FLOOR_SIZE _IOW(NVMAP_IOC_MAGIC, 102, uint32_t) + +/* Get heap parameters such as total and frre size */ +#define NVMAP_IOC_QUERY_HEAP_PARAMS _IOR(NVMAP_IOC_MAGIC, 105, \ + struct nvmap_query_heap_params) + +#define NVMAP_IOC_MAXNR (_IOC_NR(NVMAP_IOC_QUERY_HEAP_PARAMS)) + +#endif /* __UAPI_LINUX_NVMAP_H */ diff --git a/libavutil/nvtegra.c b/libavutil/nvtegra.c new file mode 100644 index 0000000000..ad0bbbdfaa --- /dev/null +++ b/libavutil/nvtegra.c @@ -0,0 +1,1035 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __SWITCH__ +# include +# include +# include +# include +#else +# include +# include +#endif + +#include + +#include "buffer.h" +#include "log.h" +#include "error.h" +#include "mem.h" +#include "thread.h" + +#include "nvhost_ioctl.h" +#include "nvmap_ioctl.h" +#include "nvtegra_host1x.h" + +#include "nvtegra.h" + +/* + * Tag used by the kernel to identify allocations. + * Official software has been seen using 0x900, 0xf00, 0x1100, 0x1400, 0x4000. + */ +#define MEM_TAG (0xfeed) + +struct DriverState { + int nvmap_fd, nvhost_fd; +}; + +static AVMutex g_driver_init_mtx = AV_MUTEX_INITIALIZER; +static struct DriverState *g_driver_state = NULL; +static AVBufferRef *g_driver_state_ref = NULL; + +static void free_driver_fds(void *opaque, uint8_t *data) { + if (!g_driver_state) + return; + +#ifndef __SWITCH__ + if (g_driver_state->nvmap_fd > 0) + close(g_driver_state->nvmap_fd); + + if (g_driver_state->nvhost_fd > 0) + close(g_driver_state->nvhost_fd); +#else + nvFenceExit(); + nvMapExit(); + nvExit(); + mmuExit(); +#endif + + g_driver_init_mtx = (AVMutex)AV_MUTEX_INITIALIZER; + g_driver_state_ref = NULL; + av_freep(&g_driver_state); +} + +static int init_driver_fds(void) { + AVBufferRef *ref; + struct DriverState *state; + int err; + + state = av_mallocz(sizeof(*state)); + if (!state) + return AVERROR(ENOMEM); + + ref = av_buffer_create((uint8_t *)state, sizeof(*state), free_driver_fds, NULL, 0); + if (!state) + return AVERROR(ENOMEM); + + g_driver_state = state; + g_driver_state_ref = ref; + +#ifndef __SWITCH__ + err = open("/dev/nvmap", O_RDWR | O_SYNC); + if (err < 0) + return AVERROR(errno); + state->nvmap_fd = err; + + err = open("/dev/nvhost-ctrl", O_RDWR | O_SYNC); + if (err < 0) + return AVERROR(errno); + state->nvhost_fd = err; +#else + err = nvInitialize(); + if (R_FAILED(err)) + return AVERROR(err); + + err = nvMapInit(); + if (R_FAILED(err)) + return AVERROR(err); + state->nvmap_fd = nvMapGetFd(); + + err = nvFenceInit(); + if (R_FAILED(err)) + return AVERROR(err); + /* libnx doesn't export the nvhost-ctrl file descriptor */ + + err = mmuInitialize(); + if (R_FAILED(err)) + return AVERROR(err); +#endif + + return 0; +} + +static inline int get_nvmap_fd(void) { + if (!g_driver_state) + return AVERROR_UNKNOWN; + + if (!g_driver_state->nvmap_fd) + return AVERROR_UNKNOWN; + + return g_driver_state->nvmap_fd; +} + +static inline int get_nvhost_fd(void) { + if (!g_driver_state) + return AVERROR_UNKNOWN; + + if (!g_driver_state->nvhost_fd) + return AVERROR_UNKNOWN; + + return g_driver_state->nvhost_fd; +} + +AVBufferRef *av_nvtegra_driver_init(void) { + AVBufferRef *out = NULL; + int err; + + /* + * We have to do this overly complex dance of putting driver fds in a refcounted struct, + * otherwise initializing multiple hwcontexts would leak fds + */ + + err = ff_mutex_lock(&g_driver_init_mtx); + if (err != 0) + goto exit; + + if (g_driver_state_ref) { + out = av_buffer_ref(g_driver_state_ref); + goto exit; + } + + err = init_driver_fds(); + if (err < 0) { + /* In case memory allocations failed, call the destructor ourselves */ + av_buffer_unref(&g_driver_state_ref); + free_driver_fds(NULL, NULL); + goto exit; + } + + out = g_driver_state_ref; + +exit: + ff_mutex_unlock(&g_driver_init_mtx); + return out; +} + +int av_nvtegra_channel_open(AVNVTegraChannel *channel, const char *dev) { + int err; +#ifndef __SWITCH__ + struct nvhost_get_param_arg args; + + err = open(dev, O_RDWR); + if (err < 0) + return AVERROR(errno); + + channel->fd = err; + + args = (struct nvhost_get_param_arg){0}; + + err = ioctl(channel->fd, NVHOST_IOCTL_CHANNEL_GET_SYNCPOINT, &args); + if (err < 0) + goto fail; + + channel->syncpt = args.value; + + return 0; + +fail: + close(channel->fd); + return AVERROR(errno); +#else + err = nvChannelCreate(&channel->channel, dev); + if (R_FAILED(err)) + return AVERROR(err); + + err = nvioctlChannel_GetSyncpt(channel->channel.fd, 0, &channel->syncpt); + if (R_FAILED(err)) + goto fail; + + return 0; + +fail: + nvChannelClose(&channel->channel); + return AVERROR(err); +#endif +} + +int av_nvtegra_channel_close(AVNVTegraChannel *channel) { +#ifndef __SWITCH__ + if (!channel->fd) + return 0; + + return close(channel->fd); +#else + nvChannelClose(&channel->channel); + return 0; +#endif +} + +int av_nvtegra_channel_get_clock_rate(AVNVTegraChannel *channel, uint32_t moduleid, uint32_t *clock_rate) { + int err; +#ifndef __SWITCH__ + struct nvhost_clk_rate_args args; + + args = (struct nvhost_clk_rate_args){ + .moduleid = moduleid, + }; + + err = ioctl(channel->fd, NVHOST_IOCTL_CHANNEL_GET_CLK_RATE, &args); + if (err < 0) + return AVERROR(errno); + + if (clock_rate) + *clock_rate = args.rate; + + return 0; +#else + uint32_t tmp; + + err = AVERROR(nvioctlChannel_GetModuleClockRate(channel->channel.fd, moduleid, &tmp)); + if (err < 0) + return err; + + if (clock_rate) + *clock_rate = tmp * 1000; + + return 0; +#endif +} + +int av_nvtegra_channel_set_clock_rate(AVNVTegraChannel *channel, uint32_t moduleid, uint32_t clock_rate) { +#ifndef __SWITCH__ + struct nvhost_clk_rate_args args; + + args = (struct nvhost_clk_rate_args){ + .rate = clock_rate, + .moduleid = moduleid, + }; + + return (ioctl(channel->fd, NVHOST_IOCTL_CHANNEL_SET_CLK_RATE, &args) < 0) ? AVERROR(errno) : 0; +#else + return AVERROR(nvioctlChannel_SetModuleClockRate(channel->channel.fd, moduleid, clock_rate / 1000)); +#endif +} + +int av_nvtegra_channel_submit(AVNVTegraChannel *channel, AVNVTegraCmdbuf *cmdbuf, uint32_t *fence) { + int err; +#ifndef __SWITCH__ + struct nvhost_submit_args args; + + args = (struct nvhost_submit_args){ + .submit_version = NVHOST_SUBMIT_VERSION_V2, + .num_syncpt_incrs = cmdbuf->num_syncpt_incrs, + .num_cmdbufs = cmdbuf->num_cmdbufs, + .num_relocs = cmdbuf->num_relocs, + .num_waitchks = cmdbuf->num_waitchks, + .timeout = 0, + .flags = 0, + .fence = 0, + .syncpt_incrs = (uintptr_t)cmdbuf->syncpt_incrs, + .cmdbuf_exts = (uintptr_t)cmdbuf->cmdbuf_exts, + .checksum_methods = 0, + .checksum_falcon_methods = 0, + .pad = { 0 }, + .reloc_types = (uintptr_t)cmdbuf->reloc_types, + .cmdbufs = (uintptr_t)cmdbuf->cmdbufs, + .relocs = (uintptr_t)cmdbuf->relocs, + .reloc_shifts = (uintptr_t)cmdbuf->reloc_shifts, + .waitchks = (uintptr_t)cmdbuf->waitchks, + .waitbases = 0, + .class_ids = (uintptr_t)cmdbuf->class_ids, + .fences = (uintptr_t)cmdbuf->fences, + }; + + err = ioctl(channel->fd, NVHOST_IOCTL_CHANNEL_SUBMIT, &args); + if (err < 0) + return AVERROR(errno); + + if (fence) + *fence = args.fence; + + return 0; +#else + nvioctl_fence tmp; + + err = nvioctlChannel_Submit(channel->channel.fd, (nvioctl_cmdbuf *)cmdbuf->cmdbufs, cmdbuf->num_cmdbufs, + NULL, NULL, 0, (nvioctl_syncpt_incr *)cmdbuf->syncpt_incrs, cmdbuf->num_syncpt_incrs, + &tmp, 1); + if (R_FAILED(err)) + return AVERROR(err); + + if (fence) + *fence = tmp.value; + + return 0; +#endif +} + +int av_nvtegra_channel_set_submit_timeout(AVNVTegraChannel *channel, uint32_t timeout_ms) { +#ifndef __SWITCH__ + struct nvhost_set_timeout_args args; + + args = (struct nvhost_set_timeout_args){ + .timeout = timeout_ms, + }; + + return (ioctl(channel->fd, NVHOST_IOCTL_CHANNEL_SET_TIMEOUT, &args) < 0) ? AVERROR(errno) : 0; +#else + return AVERROR(nvioctlChannel_SetSubmitTimeout(channel->channel.fd, timeout_ms)); +#endif +} + +int av_nvtegra_syncpt_wait(AVNVTegraChannel *channel, uint32_t threshold, int32_t timeout) { +#ifndef __SWITCH__ + struct nvhost_ctrl_syncpt_waitex_args args = { + .id = channel->syncpt, + .thresh = threshold, + .timeout = timeout, + }; + + return (ioctl(get_nvhost_fd(), NVHOST_IOCTL_CTRL_SYNCPT_WAITEX, &args) < 0) ? AVERROR(errno) : 0; +#else + NvFence fence; + + fence = (NvFence){ + .id = channel->syncpt, + .value = threshold, + }; + + return AVERROR(nvFenceWait(&fence, timeout)); +#endif +} + +#ifdef __SWITCH__ +static inline bool convert_cache_flags(uint32_t flags) { + /* Return whether the map should be CPU-cacheable */ + switch (flags & NVMAP_HANDLE_CACHE_FLAG) { + case NVMAP_HANDLE_INNER_CACHEABLE: + case NVMAP_HANDLE_CACHEABLE: + return true; + default: + return false; + } +} +#endif + +int av_nvtegra_map_allocate(AVNVTegraMap *map, AVNVTegraChannel *channel, uint32_t size, + uint32_t align, int heap_mask, int flags) +{ +#ifndef __SWITCH__ + struct nvmap_create_handle create_args; + struct nvmap_alloc_handle alloc_args; + int err; + + create_args = (struct nvmap_create_handle){ + .size = size, + }; + + err = ioctl(get_nvmap_fd(), NVMAP_IOC_CREATE, &create_args); + if (err < 0) + return AVERROR(errno); + + map->size = size; + map->handle = create_args.handle; + + alloc_args = (struct nvmap_alloc_handle){ + .handle = create_args.handle, + .heap_mask = heap_mask, + .flags = flags | (MEM_TAG << 16), + .align = align, + }; + + err = ioctl(get_nvmap_fd(), NVMAP_IOC_ALLOC, &alloc_args); + if (err < 0) + goto fail; + + return 0; + +fail: + av_nvtegra_map_free(map); + return AVERROR(errno); +#else + void *mem; + + map->owner = channel->channel.fd; + + size = FFALIGN(size, 0x1000); + + mem = aligned_alloc(FFALIGN(align, 0x1000), size); + if (!mem) + return AVERROR(ENOMEM); + + return AVERROR(nvMapCreate(&map->map, mem, size, 0x10000, NvKind_Pitch, + convert_cache_flags(flags))); +#endif +} + +int av_nvtegra_map_free(AVNVTegraMap *map) { +#ifndef __SWITCH__ + int err; + + if (!map->handle) + return 0; + + err = ioctl(get_nvmap_fd(), NVMAP_IOC_FREE, map->handle); + if (err < 0) + return AVERROR(errno); + + map->handle = 0; + + return 0; +#else + void *addr = map->map.cpu_addr; + + if (!map->map.cpu_addr) + return 0; + + nvMapClose(&map->map); + free(addr); + return 0; +#endif +} + +int av_nvtegra_map_from_va(AVNVTegraMap *map, AVNVTegraChannel *owner, void *mem, + uint32_t size, uint32_t align, uint32_t flags) +{ +#ifndef __SWITCH__ + struct nvmap_create_handle_from_va args; + int err; + + args = (struct nvmap_create_handle_from_va){ + .va = (uintptr_t)mem, + .size = size, + .flags = flags | (MEM_TAG << 16), + }; + + err = ioctl(get_nvmap_fd(), NVMAP_IOC_FROM_VA, &args); + if (err < 0) + return AVERROR(errno); + + map->cpu_addr = mem; + map->size = size; + map->handle = args.handle; + + return 0; +#else + + map->owner = owner->channel.fd; + + return AVERROR(nvMapCreate(&map->map, mem, FFALIGN(size, 0x1000), 0x10000, NvKind_Pitch, + convert_cache_flags(flags)));; +#endif +} + +int av_nvtegra_map_close(AVNVTegraMap *map) { +#ifndef __SWITCH__ + return av_nvtegra_map_free(map); +#else + nvMapClose(&map->map); + return 0; +#endif +} + +int av_nvtegra_map_map(AVNVTegraMap *map) { +#ifndef __SWITCH__ + void *addr; + + addr = mmap(NULL, map->size, PROT_READ | PROT_WRITE, MAP_SHARED, map->handle, 0); + if (addr == MAP_FAILED) + return AVERROR(errno); + + map->cpu_addr = addr; + + return 0; +#else + nvioctl_command_buffer_map params; + int err; + + params = (nvioctl_command_buffer_map){ + .handle = map->map.handle, + }; + + err = nvioctlChannel_MapCommandBuffer(map->owner, ¶ms, 1, false); + if (R_FAILED(err)) + return AVERROR(err); + + map->iova = params.iova; + + return 0; +#endif +} + +int av_nvtegra_map_unmap(AVNVTegraMap *map) { + int err; +#ifndef __SWITCH__ + if (!map->cpu_addr) + return 0; + + err = munmap(map->cpu_addr, map->size); + if (err < 0) + return AVERROR(errno); + + map->cpu_addr = NULL; + + return 0; +#else + nvioctl_command_buffer_map params; + + if (!map->iova) + return 0; + + params = (nvioctl_command_buffer_map){ + .handle = map->map.handle, + .iova = map->iova, + }; + + err = nvioctlChannel_UnmapCommandBuffer(map->owner, ¶ms, 1, false); + if (R_FAILED(err)) + return AVERROR(err); + + map->iova = 0; + + return 0; +#endif +} + +int av_nvtegra_map_cache_op(AVNVTegraMap *map, int op, void *addr, size_t len) { +#ifndef __SWITCH__ + struct nvmap_cache_op args; + + args = (struct nvmap_cache_op){ + .addr = (uintptr_t)addr, + .len = len, + .handle = av_nvtegra_map_get_handle(map), + .op = op, + }; + + return AVERROR(ioctl(get_nvmap_fd(), NVMAP_IOC_CACHE, &args)); +#else + if (!map->map.is_cpu_cacheable) + return 0; + + switch (op) { + case NVMAP_CACHE_OP_WB: + armDCacheClean(addr, len); + break; + default: + case NVMAP_CACHE_OP_INV: + case NVMAP_CACHE_OP_WB_INV: + /* libnx internally performs a clean-invalidate, since invalidate is a privileged instruction */ + armDCacheFlush(addr, len); + break; + } + + return 0; +#endif +} + +int av_nvtegra_map_realloc(AVNVTegraMap *map, uint32_t size, uint32_t align, + int heap_mask, int flags) +{ + AVNVTegraChannel channel; + AVNVTegraMap tmp = {0}; + int err; + + if (av_nvtegra_map_get_size(map) >= size) + return 0; + + /* Dummy channel object to hold the owner fd */ + channel = (AVNVTegraChannel){ +#ifdef __SWITCH__ + .channel.fd = map->owner, +#endif + }; + + err = av_nvtegra_map_create(&tmp, &channel, size, align, heap_mask, flags); + if (err < 0) + goto fail; + + memcpy(av_nvtegra_map_get_addr(&tmp), av_nvtegra_map_get_addr(map), av_nvtegra_map_get_size(map)); + + err = av_nvtegra_map_destroy(map); + if (err < 0) + goto fail; + + *map = tmp; + + return 0; + +fail: + av_nvtegra_map_destroy(&tmp); + return err; +} + +int av_nvtegra_cmdbuf_init(AVNVTegraCmdbuf *cmdbuf) { + cmdbuf->num_cmdbufs = 0; +#ifndef __SWITCH__ + cmdbuf->num_relocs = 0; + cmdbuf->num_waitchks = 0; +#endif + cmdbuf->num_syncpt_incrs = 0; + +#define NUM_INITIAL_CMDBUFS 3 +#define NUM_INITIAL_RELOCS 15 +#define NUM_INITIAL_SYNCPT_INCRS 3 + + cmdbuf->cmdbufs = av_malloc_array(NUM_INITIAL_CMDBUFS, sizeof(*cmdbuf->cmdbufs)); +#ifndef __SWITCH__ + cmdbuf->cmdbuf_exts = av_malloc_array(NUM_INITIAL_CMDBUFS, sizeof(*cmdbuf->cmdbuf_exts)); + cmdbuf->class_ids = av_malloc_array(NUM_INITIAL_CMDBUFS, sizeof(*cmdbuf->class_ids)); +#endif + +#ifndef __SWITCH__ + if (!cmdbuf->cmdbufs || !cmdbuf->cmdbuf_exts || !cmdbuf->class_ids) +#else + if (!cmdbuf->cmdbufs) +#endif + return AVERROR(ENOMEM); + +#ifndef __SWITCH__ + cmdbuf->relocs = av_malloc_array(NUM_INITIAL_RELOCS, sizeof(*cmdbuf->relocs)); + cmdbuf->reloc_types = av_malloc_array(NUM_INITIAL_RELOCS, sizeof(*cmdbuf->reloc_types)); + cmdbuf->reloc_shifts = av_malloc_array(NUM_INITIAL_RELOCS, sizeof(*cmdbuf->reloc_shifts)); + if (!cmdbuf->relocs || !cmdbuf->reloc_types || !cmdbuf->reloc_shifts) + return AVERROR(ENOMEM); +#endif + + cmdbuf->syncpt_incrs = av_malloc_array(NUM_INITIAL_SYNCPT_INCRS, sizeof(*cmdbuf->syncpt_incrs)); +#ifndef __SWITCH__ + cmdbuf->fences = av_malloc_array(NUM_INITIAL_SYNCPT_INCRS, sizeof(*cmdbuf->fences)); +#endif + +#ifndef __SWITCH__ + if (!cmdbuf->syncpt_incrs || !cmdbuf->fences) +#else + if (!cmdbuf->syncpt_incrs) +#endif + return AVERROR(ENOMEM); + + return 0; +} + +int av_nvtegra_cmdbuf_deinit(AVNVTegraCmdbuf *cmdbuf) { + av_freep(&cmdbuf->cmdbufs); + av_freep(&cmdbuf->syncpt_incrs); + +#ifndef __SWITCH__ + av_freep(&cmdbuf->cmdbuf_exts), av_freep(&cmdbuf->class_ids); + av_freep(&cmdbuf->relocs), av_freep(&cmdbuf->reloc_types), av_freep(&cmdbuf->reloc_shifts); + av_freep(&cmdbuf->fences); +#endif + + return 0; +} + +int av_nvtegra_cmdbuf_add_memory(AVNVTegraCmdbuf *cmdbuf, AVNVTegraMap *map, uint32_t offset, uint32_t size) { + uint8_t *mem; + + mem = av_nvtegra_map_get_addr(map); + + cmdbuf->map = map; + cmdbuf->mem_offset = offset; + cmdbuf->mem_size = size; + + cmdbuf->cur_word = (uint32_t *)(mem + cmdbuf->mem_offset); + + return 0; +} + +int av_nvtegra_cmdbuf_clear(AVNVTegraCmdbuf *cmdbuf) { + uint8_t *mem; + + mem = av_nvtegra_map_get_addr(cmdbuf->map); + + cmdbuf->num_cmdbufs = 0, cmdbuf->num_syncpt_incrs = 0; +#ifndef __SWITCH__ + cmdbuf->num_relocs = 0, cmdbuf->num_waitchks = 0; +#endif + + cmdbuf->cur_word = (uint32_t *)(mem + cmdbuf->mem_offset); + return 0; +} + +int av_nvtegra_cmdbuf_begin(AVNVTegraCmdbuf *cmdbuf, uint32_t class_id) { + uint8_t *mem; + void *tmp1; +#ifndef __SWITCH__ + void *tmp2, *tmp3; +#endif + + mem = av_nvtegra_map_get_addr(cmdbuf->map); + + tmp1 = av_realloc_array(cmdbuf->cmdbufs, cmdbuf->num_cmdbufs + 1, sizeof(*cmdbuf->cmdbufs)); +#ifndef __SWITCH__ + tmp2 = av_realloc_array(cmdbuf->cmdbuf_exts, cmdbuf->num_cmdbufs + 1, sizeof(*cmdbuf->cmdbuf_exts)); + tmp3 = av_realloc_array(cmdbuf->class_ids, cmdbuf->num_cmdbufs + 1, sizeof(*cmdbuf->class_ids)); +#endif + +#ifndef __SWITCH__ + if (!tmp1 || !tmp2 || !tmp3) +#else + if (!tmp1) +#endif + return AVERROR(ENOMEM); + + cmdbuf->cmdbufs = tmp1; + +#ifndef __SWITCH__ + cmdbuf->cmdbuf_exts = tmp2, cmdbuf->class_ids = tmp3; +#endif + + cmdbuf->cmdbufs[cmdbuf->num_cmdbufs] = (struct nvhost_cmdbuf){ + .mem = av_nvtegra_map_get_handle(cmdbuf->map), + .offset = (uint8_t *)cmdbuf->cur_word - mem, + }; + +#ifndef __SWITCH__ + cmdbuf->cmdbuf_exts[cmdbuf->num_cmdbufs] = (struct nvhost_cmdbuf_ext){ + .pre_fence = -1, + }; + + cmdbuf->class_ids[cmdbuf->num_cmdbufs] = class_id; +#endif + +#ifdef __SWITCH__ + if (cmdbuf->num_cmdbufs == 0) + av_nvtegra_cmdbuf_push_word(cmdbuf, host1x_opcode_setclass(class_id, 0, 0)); +#endif + + return 0; +} + +int av_nvtegra_cmdbuf_end(AVNVTegraCmdbuf *cmdbuf) { + cmdbuf->num_cmdbufs++; + return 0; +} + +int av_nvtegra_cmdbuf_push_word(AVNVTegraCmdbuf *cmdbuf, uint32_t word) { + uintptr_t mem_start = (uintptr_t)av_nvtegra_map_get_addr(cmdbuf->map) + cmdbuf->mem_offset; + + if ((uintptr_t)cmdbuf->cur_word - mem_start >= cmdbuf->mem_size) + return AVERROR(ENOMEM); + + *cmdbuf->cur_word++ = word; + cmdbuf->cmdbufs[cmdbuf->num_cmdbufs].words += 1; + return 0; +} + +int av_nvtegra_cmdbuf_push_value(AVNVTegraCmdbuf *cmdbuf, uint32_t offset, uint32_t word) { + int err; + + err = av_nvtegra_cmdbuf_push_word(cmdbuf, host1x_opcode_incr(NV_THI_METHOD0>>2, 2)); + if (err < 0) + return err; + + err = av_nvtegra_cmdbuf_push_word(cmdbuf, offset); + if (err < 0) + return err; + + err = av_nvtegra_cmdbuf_push_word(cmdbuf, word); + if (err < 0) + return err; + + return 0; +} + +int av_nvtegra_cmdbuf_push_reloc(AVNVTegraCmdbuf *cmdbuf, uint32_t offset, AVNVTegraMap *target, uint32_t target_offset, + int reloc_type, int shift) +{ + int err; +#ifndef __SWITCH__ + uint8_t *mem; + void *tmp1, *tmp2, *tmp3; + + mem = av_nvtegra_map_get_addr(cmdbuf->map); + + tmp1 = av_realloc_array(cmdbuf->relocs, cmdbuf->num_relocs + 1, sizeof(*cmdbuf->relocs)); + tmp2 = av_realloc_array(cmdbuf->reloc_types, cmdbuf->num_relocs + 1, sizeof(*cmdbuf->reloc_types)); + tmp3 = av_realloc_array(cmdbuf->reloc_shifts, cmdbuf->num_relocs + 1, sizeof(*cmdbuf->reloc_shifts)); + if (!tmp1 || !tmp2 || !tmp3) + return AVERROR(ENOMEM); + + cmdbuf->relocs = tmp1, cmdbuf->reloc_types = tmp2, cmdbuf->reloc_shifts = tmp3; + + err = av_nvtegra_cmdbuf_push_value(cmdbuf, offset, 0xdeadbeef); + if (err < 0) + return err; + + cmdbuf->relocs[cmdbuf->num_relocs] = (struct nvhost_reloc){ + .cmdbuf_mem = av_nvtegra_map_get_handle(cmdbuf->map), + .cmdbuf_offset = (uint8_t *)cmdbuf->cur_word - mem - sizeof(uint32_t), + .target = av_nvtegra_map_get_handle(target), + .target_offset = target_offset, + }; + + cmdbuf->reloc_types[cmdbuf->num_relocs] = (struct nvhost_reloc_type){ + .reloc_type = reloc_type, + }; + + cmdbuf->reloc_shifts[cmdbuf->num_relocs] = (struct nvhost_reloc_shift){ + .shift = shift, + }; + + cmdbuf->num_relocs++; + + return 0; +#else + err = av_nvtegra_cmdbuf_push_value(cmdbuf, offset, (target->iova + target_offset) >> shift); + if (err < 0) + return err; + + return 0; +#endif +} + +int av_nvtegra_cmdbuf_push_syncpt_incr(AVNVTegraCmdbuf *cmdbuf, uint32_t syncpt) { + int err; + + err = av_nvtegra_cmdbuf_push_word(cmdbuf, host1x_opcode_nonincr(NV_THI_INCR_SYNCPT>>2, 1)); + if (err < 0) + return err; + + err = av_nvtegra_cmdbuf_push_word(cmdbuf, + AV_NVTEGRA_VALUE(NV_THI_INCR_SYNCPT, INDX, syncpt) | + AV_NVTEGRA_ENUM (NV_THI_INCR_SYNCPT, COND, OP_DONE)); + if (err < 0) + return err; + + return 0; +} + +int av_nvtegra_cmdbuf_push_wait(AVNVTegraCmdbuf *cmdbuf, uint32_t syncpt, uint32_t fence) { + int err; + + err = av_nvtegra_cmdbuf_push_word(cmdbuf, host1x_opcode_setclass(HOST1X_CLASS_HOST1X, 0, 0)); + if (err < 0) + return err; + + err = av_nvtegra_cmdbuf_push_word(cmdbuf, host1x_opcode_mask(NV_CLASS_HOST_LOAD_SYNCPT_PAYLOAD>>2, + (1<<(NV_CLASS_HOST_LOAD_SYNCPT_PAYLOAD - NV_CLASS_HOST_LOAD_SYNCPT_PAYLOAD)) | + (1<<(NV_CLASS_HOST_WAIT_SYNCPT - NV_CLASS_HOST_LOAD_SYNCPT_PAYLOAD)))); + if (err < 0) + return err; + + err = av_nvtegra_cmdbuf_push_word(cmdbuf, fence); + if (err < 0) + return err; + + err = av_nvtegra_cmdbuf_push_word(cmdbuf, syncpt); + if (err < 0) + return err; + + return 0; +} + +int av_nvtegra_cmdbuf_add_syncpt_incr(AVNVTegraCmdbuf *cmdbuf, uint32_t syncpt, uint32_t fence) +{ + void *tmp1; +#ifndef __SWITCH__ + void *tmp2; +#endif + + tmp1 = av_realloc_array(cmdbuf->syncpt_incrs, cmdbuf->num_syncpt_incrs + 1, sizeof(*cmdbuf->syncpt_incrs)); +#ifndef __SWITCH__ + tmp2 = av_realloc_array(cmdbuf->fences, cmdbuf->num_syncpt_incrs + 1, sizeof(*cmdbuf->fences)); +#endif + +#ifndef __SWITCH__ + if (!tmp1 || !tmp2) +#else + if (!tmp1) +#endif + return AVERROR(ENOMEM); + + cmdbuf->syncpt_incrs = tmp1; +#ifndef __SWITCH__ + cmdbuf->fences = tmp2; +#endif + + cmdbuf->syncpt_incrs[cmdbuf->num_syncpt_incrs] = (struct nvhost_syncpt_incr){ + .syncpt_id = syncpt, + .syncpt_incrs = 1, + }; + +#ifndef __SWITCH__ + cmdbuf->fences[cmdbuf->num_syncpt_incrs] = fence; +#endif + + cmdbuf->num_syncpt_incrs++; + + return av_nvtegra_cmdbuf_push_syncpt_incr(cmdbuf, syncpt); +} + +int av_nvtegra_cmdbuf_add_waitchk(AVNVTegraCmdbuf *cmdbuf, uint32_t syncpt, uint32_t fence) { +#ifndef __SWITCH__ + uint8_t *mem; + void *tmp; + + mem = av_nvtegra_map_get_addr(cmdbuf->map); + + tmp = av_realloc_array(cmdbuf->waitchks, cmdbuf->num_waitchks + 1, sizeof(*cmdbuf->waitchks)); + if (!tmp) + return AVERROR(ENOMEM); + + cmdbuf->waitchks = tmp; + + cmdbuf->waitchks[cmdbuf->num_waitchks] = (struct nvhost_waitchk){ + .mem = av_nvtegra_map_get_handle(cmdbuf->map), + .offset = (uint8_t *)cmdbuf->cur_word - mem - sizeof(uint32_t), + .syncpt_id = syncpt, + .thresh = fence, + }; + + cmdbuf->num_waitchks++; +#endif + + return av_nvtegra_cmdbuf_push_wait(cmdbuf, syncpt, fence); +} + +static void nvtegra_job_free(void *opaque, uint8_t *data) { + AVNVTegraJob *job = (AVNVTegraJob *)data; + + if (!job) + return; + + av_nvtegra_cmdbuf_deinit(&job->cmdbuf); + av_nvtegra_map_destroy(&job->input_map); + + av_freep(&job); +} + +static AVBufferRef *nvtegra_job_alloc(void *opaque, size_t size) { + AVNVTegraJobPool *pool = opaque; + + AVBufferRef *buffer; + AVNVTegraJob *job; + int err; + + job = av_mallocz(sizeof(*job)); + if (!job) + return NULL; + + err = av_nvtegra_map_create(&job->input_map, pool->channel, pool->input_map_size, 0x100, + NVMAP_HEAP_IOVMM, NVMAP_HANDLE_WRITE_COMBINE); + if (err < 0) + goto fail; + + err = av_nvtegra_cmdbuf_init(&job->cmdbuf); + if (err < 0) + goto fail; + + err = av_nvtegra_cmdbuf_add_memory(&job->cmdbuf, &job->input_map, pool->cmdbuf_off, pool->max_cmdbuf_size); + if (err < 0) + goto fail; + + buffer = av_buffer_create((uint8_t *)job, sizeof(*job), nvtegra_job_free, pool, 0); + if (!buffer) + goto fail; + + return buffer; + +fail: + av_nvtegra_cmdbuf_deinit(&job->cmdbuf); + av_nvtegra_map_destroy(&job->input_map); + av_freep(job); + return NULL; +} + +int av_nvtegra_job_pool_init(AVNVTegraJobPool *pool, AVNVTegraChannel *channel, + size_t input_map_size, off_t cmdbuf_off, size_t max_cmdbuf_size) +{ + pool->channel = channel; + pool->input_map_size = input_map_size; + pool->cmdbuf_off = cmdbuf_off; + pool->max_cmdbuf_size = max_cmdbuf_size; + pool->pool = av_buffer_pool_init2(sizeof(AVNVTegraJob), pool, + nvtegra_job_alloc, NULL); + if (!pool->pool) + return AVERROR(ENOMEM); + + return 0; +} + +int av_nvtegra_job_pool_uninit(AVNVTegraJobPool *pool) { + av_buffer_pool_uninit(&pool->pool); + return 0; +} + +AVBufferRef *av_nvtegra_job_pool_get(AVNVTegraJobPool *pool) { + return av_buffer_pool_get(pool->pool); +} + +int av_nvtegra_job_submit(AVNVTegraJobPool *pool, AVNVTegraJob *job) { + return av_nvtegra_channel_submit(pool->channel, &job->cmdbuf, &job->fence); +} + +int av_nvtegra_job_wait(AVNVTegraJobPool *pool, AVNVTegraJob *job, int timeout) { + return av_nvtegra_syncpt_wait(pool->channel, job->fence, timeout); +} diff --git a/libavutil/nvtegra.h b/libavutil/nvtegra.h new file mode 100644 index 0000000000..3b63335d6c --- /dev/null +++ b/libavutil/nvtegra.h @@ -0,0 +1,258 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef AVUTIL_NVTEGRA_H +#define AVUTIL_NVTEGRA_H + +#include +#include + +#include "buffer.h" + +#include "nvhost_ioctl.h" +#include "nvmap_ioctl.h" + +typedef struct AVNVTegraChannel { +#ifndef __SWITCH__ + int fd; + int module_id; +#else + NvChannel channel; +#endif + + uint32_t syncpt; + +#ifdef __SWITCH__ + MmuRequest mmu_request; +#endif + uint32_t clock; +} AVNVTegraChannel; + +typedef struct AVNVTegraMap { +#ifndef __SWITCH__ + uint32_t handle; + uint32_t size; + void *cpu_addr; +#else + NvMap map; + uint32_t iova; + uint32_t owner; +#endif + bool is_linear; +} AVNVTegraMap; + +typedef struct AVNVTegraCmdbuf { + AVNVTegraMap *map; + + uint32_t mem_offset, mem_size; + + uint32_t *cur_word; + + struct nvhost_cmdbuf *cmdbufs; +#ifndef __SWITCH__ + struct nvhost_cmdbuf_ext *cmdbuf_exts; + uint32_t *class_ids; +#endif + uint32_t num_cmdbufs; + +#ifndef __SWITCH__ + struct nvhost_reloc *relocs; + struct nvhost_reloc_type *reloc_types; + struct nvhost_reloc_shift *reloc_shifts; + uint32_t num_relocs; +#endif + + struct nvhost_syncpt_incr *syncpt_incrs; +#ifndef __SWITCH__ + uint32_t *fences; +#endif + uint32_t num_syncpt_incrs; + +#ifndef __SWITCH__ + struct nvhost_waitchk *waitchks; + uint32_t num_waitchks; +#endif +} AVNVTegraCmdbuf; + +typedef struct AVNVTegraJobPool { + /* + * Pool object for job allocation + */ + AVBufferPool *pool; + + /* + * Hardware channel the jobs will be submitted to + */ + AVNVTegraChannel *channel; + + /* + * Total size of the input memory-mapped buffer + */ + size_t input_map_size; + + /* + * Offset of the command data within the input map + */ + off_t cmdbuf_off; + + /* + * Maximum memory usable by the command buffer + */ + size_t max_cmdbuf_size; +} AVNVTegraJobPool; + +typedef struct AVNVTegraJob { + /* + * Memory-mapped buffer for command buffers, metadata structures, ... + */ + AVNVTegraMap input_map; + + /* + * Object for command recording + */ + AVNVTegraCmdbuf cmdbuf; + + /* + * Fence indicating completion of the job + */ + uint32_t fence; +} AVNVTegraJob; + +AVBufferRef *av_nvtegra_driver_init(void); + +int av_nvtegra_channel_open(AVNVTegraChannel *channel, const char *dev); +int av_nvtegra_channel_close(AVNVTegraChannel *channel); +int av_nvtegra_channel_get_clock_rate(AVNVTegraChannel *channel, uint32_t moduleid, uint32_t *clock_rate); +int av_nvtegra_channel_set_clock_rate(AVNVTegraChannel *channel, uint32_t moduleid, uint32_t clock_rate); +int av_nvtegra_channel_submit(AVNVTegraChannel *channel, AVNVTegraCmdbuf *cmdbuf, uint32_t *fence); +int av_nvtegra_channel_set_submit_timeout(AVNVTegraChannel *channel, uint32_t timeout_ms); + +int av_nvtegra_syncpt_wait(AVNVTegraChannel *channel, uint32_t threshold, int32_t timeout); + +int av_nvtegra_map_allocate(AVNVTegraMap *map, AVNVTegraChannel *owner, uint32_t size, + uint32_t align, int heap_mask, int flags); +int av_nvtegra_map_free(AVNVTegraMap *map); +int av_nvtegra_map_from_va(AVNVTegraMap *map, AVNVTegraChannel *owner, void *mem, + uint32_t size, uint32_t align, uint32_t flags); +int av_nvtegra_map_close(AVNVTegraMap *map); +int av_nvtegra_map_map(AVNVTegraMap *map); +int av_nvtegra_map_unmap(AVNVTegraMap *map); +int av_nvtegra_map_cache_op(AVNVTegraMap *map, int op, void *addr, size_t len); +int av_nvtegra_map_realloc(AVNVTegraMap *map, uint32_t size, uint32_t align, int heap_mask, int flags); + +static inline int av_nvtegra_map_create(AVNVTegraMap *map, AVNVTegraChannel *owner, uint32_t size, uint32_t align, + int heap_mask, int flags) +{ + int err; + + err = av_nvtegra_map_allocate(map, owner, size, align, heap_mask, flags); + if (err < 0) + return err; + + return av_nvtegra_map_map(map); +} + +static inline int av_nvtegra_map_destroy(AVNVTegraMap *map) { + int err; + + err = av_nvtegra_map_unmap(map); + if (err < 0) + return err; + + return av_nvtegra_map_free(map); +} + +int av_nvtegra_cmdbuf_init(AVNVTegraCmdbuf *cmdbuf); +int av_nvtegra_cmdbuf_deinit(AVNVTegraCmdbuf *cmdbuf); +int av_nvtegra_cmdbuf_add_memory(AVNVTegraCmdbuf *cmdbuf, AVNVTegraMap *map, uint32_t offset, uint32_t size); +int av_nvtegra_cmdbuf_clear(AVNVTegraCmdbuf *cmdbuf); +int av_nvtegra_cmdbuf_begin(AVNVTegraCmdbuf *cmdbuf, uint32_t class_id); +int av_nvtegra_cmdbuf_end(AVNVTegraCmdbuf *cmdbuf); +int av_nvtegra_cmdbuf_push_word(AVNVTegraCmdbuf *cmdbuf, uint32_t word); +int av_nvtegra_cmdbuf_push_value(AVNVTegraCmdbuf *cmdbuf, uint32_t offset, uint32_t word); +int av_nvtegra_cmdbuf_push_reloc(AVNVTegraCmdbuf *cmdbuf, uint32_t offset, AVNVTegraMap *target, uint32_t target_offset, + int reloc_type, int shift); +int av_nvtegra_cmdbuf_push_syncpt_incr(AVNVTegraCmdbuf *cmdbuf, uint32_t syncpt); +int av_nvtegra_cmdbuf_push_wait(AVNVTegraCmdbuf *cmdbuf, uint32_t syncpt, uint32_t fence); +int av_nvtegra_cmdbuf_add_syncpt_incr(AVNVTegraCmdbuf *cmdbuf, uint32_t syncpt, uint32_t fence); +int av_nvtegra_cmdbuf_add_waitchk(AVNVTegraCmdbuf *cmdbuf, uint32_t syncpt, uint32_t fence); + +/* + * Job allocation and submission routines + */ +int av_nvtegra_job_pool_init(AVNVTegraJobPool *pool, AVNVTegraChannel *channel, + size_t input_map_size, off_t cmdbuf_off, size_t max_cmdbuf_size); +int av_nvtegra_job_pool_uninit(AVNVTegraJobPool *pool); +AVBufferRef *av_nvtegra_job_pool_get(AVNVTegraJobPool *pool); + +int av_nvtegra_job_submit(AVNVTegraJobPool *pool, AVNVTegraJob *job); +int av_nvtegra_job_wait(AVNVTegraJobPool *pool, AVNVTegraJob *job, int timeout); + +static inline uint32_t av_nvtegra_map_get_handle(AVNVTegraMap *map) { +#ifndef __SWITCH__ + return map->handle; +#else + return map->map.handle; +#endif +} + +static inline void *av_nvtegra_map_get_addr(AVNVTegraMap *map) { +#ifndef __SWITCH__ + return map->cpu_addr; +#else + return map->map.cpu_addr; +#endif +} + +static inline uint32_t av_nvtegra_map_get_size(AVNVTegraMap *map) { +#ifndef __SWITCH__ + return map->size; +#else + return map->map.size; +#endif +} + +/* Addresses are shifted by 8 bits in the command buffer, requiring an alignment to 256 */ +#define AV_NVTEGRA_MAP_ALIGN (1 << 8) + +#define AV_NVTEGRA_VALUE(offset, field, value) \ + ((value & \ + ((uint32_t)((UINT64_C(1) << ((1?offset ## _ ## field) - (0?offset ## _ ## field) + 1)) - 1))) \ + << (0?offset ## _ ## field)) + +#define AV_NVTEGRA_ENUM(offset, field, value) \ + ((offset ## _ ## field ## _ ## value & \ + ((uint32_t)((UINT64_C(1) << ((1?offset ## _ ## field) - (0?offset ## _ ## field) + 1)) - 1))) \ + << (0?offset ## _ ## field)) + +#define AV_NVTEGRA_PUSH_VALUE(cmdbuf, offset, value) ({ \ + int _err = av_nvtegra_cmdbuf_push_value(cmdbuf, (offset) / sizeof(uint32_t), value); \ + if (_err < 0) \ + return _err; \ +}) + +#define AV_NVTEGRA_PUSH_RELOC(cmdbuf, offset, target, target_offset, type) ({ \ + int _err = av_nvtegra_cmdbuf_push_reloc(cmdbuf, (offset) / sizeof(uint32_t), \ + target, target_offset, type, 8); \ + if (_err < 0) \ + return _err; \ +}) + +#endif /* AVUTIL_NVTEGRA_H */ diff --git a/libavutil/nvtegra_host1x.h b/libavutil/nvtegra_host1x.h new file mode 100644 index 0000000000..25e37eae61 --- /dev/null +++ b/libavutil/nvtegra_host1x.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef AVUTIL_NVTEGRA_HOST1X_H +#define AVUTIL_NVTEGRA_HOST1X_H + +#include + +#include "macros.h" + +/* From L4T include/linux/host1x.h */ +enum host1x_class { + HOST1X_CLASS_HOST1X = 0x01, + HOST1X_CLASS_NVENC = 0x21, + HOST1X_CLASS_VI = 0x30, + HOST1X_CLASS_ISPA = 0x32, + HOST1X_CLASS_ISPB = 0x34, + HOST1X_CLASS_GR2D = 0x51, + HOST1X_CLASS_GR2D_SB = 0x52, + HOST1X_CLASS_VIC = 0x5d, + HOST1X_CLASS_GR3D = 0x60, + HOST1X_CLASS_NVJPG = 0xc0, + HOST1X_CLASS_NVDEC = 0xf0, +}; + +static inline uint32_t host1x_opcode_setclass(unsigned class_id, unsigned offset, unsigned mask) { + return (0 << 28) | (offset << 16) | (class_id << 6) | mask; +} + +static inline uint32_t host1x_opcode_incr(unsigned offset, unsigned count) { + return (1 << 28) | (offset << 16) | count; +} + +static inline uint32_t host1x_opcode_nonincr(unsigned offset, unsigned count) { + return (2 << 28) | (offset << 16) | count; +} + +static inline uint32_t host1x_opcode_mask(unsigned offset, unsigned mask) { + return (3 << 28) | (offset << 16) | mask; +} + +static inline uint32_t host1x_opcode_imm(unsigned offset, unsigned value) { + return (4 << 28) | (offset << 16) | value; +} + +#define NV_CLASS_HOST_LOAD_SYNCPT_PAYLOAD (0x00000138) +#define NV_CLASS_HOST_WAIT_SYNCPT (0x00000140) + +#define NV_THI_INCR_SYNCPT (0x00000000) +#define NV_THI_INCR_SYNCPT_INDX 7:0 +#define NV_THI_INCR_SYNCPT_COND 15:8 +#define NV_THI_INCR_SYNCPT_COND_IMMEDIATE (0x00000000) +#define NV_THI_INCR_SYNCPT_COND_OP_DONE (0x00000001) +#define NV_THI_INCR_SYNCPT_ERR (0x00000008) +#define NV_THI_INCR_SYNCPT_ERR_COND_STS_IMM 0:0 +#define NV_THI_INCR_SYNCPT_ERR_COND_STS_OPDONE 1:1 +#define NV_THI_CTXSW_INCR_SYNCPT (0x0000000c) +#define NV_THI_CTXSW_INCR_SYNCPT_INDX 7:0 +#define NV_THI_CTXSW (0x00000020) +#define NV_THI_CTXSW_CURR_CLASS 9:0 +#define NV_THI_CTXSW_AUTO_ACK 11:11 +#define NV_THI_CTXSW_CURR_CHANNEL 15:12 +#define NV_THI_CTXSW_NEXT_CLASS 25:16 +#define NV_THI_CTXSW_NEXT_CHANNEL 31:28 +#define NV_THI_CONT_SYNCPT_EOF (0x00000028) +#define NV_THI_CONT_SYNCPT_EOF_INDEX 7:0 +#define NV_THI_CONT_SYNCPT_EOF_COND 8:8 +#define NV_THI_METHOD0 (0x00000040) +#define NV_THI_METHOD0_OFFSET 11:0 +#define NV_THI_METHOD1 (0x00000044) +#define NV_THI_METHOD1_DATA 31:0 +#define NV_THI_INT_STATUS (0x00000078) +#define NV_THI_INT_STATUS_FALCON_INT 0:0 +#define NV_THI_INT_MASK (0x0000007c) +#define NV_THI_INT_MASK_FALCON_INT 0:0 + +#endif /* AVUTIL_NVTEGRA_HOST1X_H */ diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 1c0bcf2232..bb14b1b306 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2791,6 +2791,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, + [AV_PIX_FMT_NVTEGRA] = { + .name = "nvtegra", + .flags = AV_PIX_FMT_FLAG_HWACCEL, + }, }; static const char * const color_range_names[] = { diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index a7f50e1690..1b98a7ecc4 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -439,6 +439,14 @@ enum AVPixelFormat { */ AV_PIX_FMT_D3D12, + /** + * Hardware surfaces for Tegra devices. + * + * data[0..2] points to memory-mapped buffers containing frame data + * buf[0] contains an AVBufferRef to an AVNTegraMap + */ + AV_PIX_FMT_NVTEGRA, + AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; diff --git a/libavutil/vic_drv.h b/libavutil/vic_drv.h new file mode 100644 index 0000000000..c2a89ed44e --- /dev/null +++ b/libavutil/vic_drv.h @@ -0,0 +1,279 @@ +/* + * Copyright (c) 2024 averne + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __VIC_DRV_H +#define __VIC_DRV_H + +#include + +typedef uint8_t NvU8; +typedef uint16_t NvU16; +typedef uint32_t NvU32; +typedef uint64_t NvU64; +typedef int8_t NvS8; +typedef int16_t NvS16; +typedef int32_t NvS32; +typedef int64_t NvS64; +typedef _Bool NvBool; + +typedef struct VicPipeConfig { + NvU32 DownsampleHoriz : 11; + NvU32 reserved0 : 5; + NvU32 DownsampleVert : 11; + NvU32 reserved1 : 5; + NvU32 reserved2 : 32; + NvU32 reserved3 : 32; + NvU32 reserved4 : 32; +} VicPipeConfig; + +typedef struct VicOutputConfig { + NvU64 AlphaFillMode : 3; + NvU64 AlphaFillSlot : 3; + NvU64 BackgroundAlpha : 10; + NvU64 BackgroundR : 10; + NvU64 BackgroundG : 10; + NvU64 BackgroundB : 10; + NvU64 RegammaMode : 2; + NvU64 OutputFlipX : 1; + NvU64 OutputFlipY : 1; + NvU64 OutputTranspose : 1; + NvU64 reserved1 : 1; + NvU64 reserved2 : 12; + NvU32 TargetRectLeft : 14; + NvU32 reserved3 : 2; + NvU32 TargetRectRight : 14; + NvU32 reserved4 : 2; + NvU32 TargetRectTop : 14; + NvU32 reserved5 : 2; + NvU32 TargetRectBottom : 14; + NvU32 reserved6 : 2; +} VicOutputConfig; + +typedef struct VicOutputSurfaceConfig { + NvU32 OutPixelFormat : 7; + NvU32 OutChromaLocHoriz : 2; + NvU32 OutChromaLocVert : 2; + NvU32 OutBlkKind : 4; + NvU32 OutBlkHeight : 4; + NvU32 reserved0 : 3; + NvU32 reserved1 : 10; + NvU32 OutSurfaceWidth : 14; + NvU32 OutSurfaceHeight : 14; + NvU32 reserved2 : 4; + NvU32 OutLumaWidth : 14; + NvU32 OutLumaHeight : 14; + NvU32 reserved3 : 4; + NvU32 OutChromaWidth : 14; + NvU32 OutChromaHeight : 14; + NvU32 reserved4 : 4; +} VicOutputSurfaceConfig; + +typedef struct VicMatrixStruct { + NvU64 matrix_coeff00 : 20; + NvU64 matrix_coeff10 : 20; + NvU64 matrix_coeff20 : 20; + NvU64 matrix_r_shift : 4; + NvU64 matrix_coeff01 : 20; + NvU64 matrix_coeff11 : 20; + NvU64 matrix_coeff21 : 20; + NvU64 reserved0 : 3; + NvU64 matrix_enable : 1; + NvU64 matrix_coeff02 : 20; + NvU64 matrix_coeff12 : 20; + NvU64 matrix_coeff22 : 20; + NvU64 reserved1 : 4; + NvU64 matrix_coeff03 : 20; + NvU64 matrix_coeff13 : 20; + NvU64 matrix_coeff23 : 20; + NvU64 reserved2 : 4; +} VicMatrixStruct; + +typedef struct VicClearRectStruct { + NvU32 ClearRect0Left : 14; + NvU32 reserved0 : 2; + NvU32 ClearRect0Right : 14; + NvU32 reserved1 : 2; + NvU32 ClearRect0Top : 14; + NvU32 reserved2 : 2; + NvU32 ClearRect0Bottom : 14; + NvU32 reserved3 : 2; + NvU32 ClearRect1Left : 14; + NvU32 reserved4 : 2; + NvU32 ClearRect1Right : 14; + NvU32 reserved5 : 2; + NvU32 ClearRect1Top : 14; + NvU32 reserved6 : 2; + NvU32 ClearRect1Bottom : 14; + NvU32 reserved7 : 2; +} VicClearRectStruct; + +typedef struct VicSlotStructSlotConfig { + NvU64 SlotEnable : 1; + NvU64 DeNoise : 1; + NvU64 AdvancedDenoise : 1; + NvU64 CadenceDetect : 1; + NvU64 MotionMap : 1; + NvU64 MMapCombine : 1; + NvU64 IsEven : 1; + NvU64 ChromaEven : 1; + NvU64 CurrentFieldEnable : 1; + NvU64 PrevFieldEnable : 1; + NvU64 NextFieldEnable : 1; + NvU64 NextNrFieldEnable : 1; + NvU64 CurMotionFieldEnable : 1; + NvU64 PrevMotionFieldEnable : 1; + NvU64 PpMotionFieldEnable : 1; + NvU64 CombMotionFieldEnable : 1; + NvU64 FrameFormat : 4; + NvU64 FilterLengthY : 2; + NvU64 FilterLengthX : 2; + NvU64 Panoramic : 12; + NvU64 reserved1 : 22; + NvU64 DetailFltClamp : 6; + NvU64 FilterNoise : 10; + NvU64 FilterDetail : 10; + NvU64 ChromaNoise : 10; + NvU64 ChromaDetail : 10; + NvU64 DeinterlaceMode : 4; + NvU64 MotionAccumWeight : 3; + NvU64 NoiseIir : 11; + NvU64 LightLevel : 4; + NvU64 reserved4 : 2; + NvU32 SoftClampLow : 10; + NvU32 SoftClampHigh : 10; + NvU32 reserved5 : 3; + NvU32 reserved6 : 9; + NvU32 PlanarAlpha : 10; + NvU32 ConstantAlpha : 1; + NvU32 StereoInterleave : 3; + NvU32 ClipEnabled : 1; + NvU32 ClearRectMask : 8; + NvU32 DegammaMode : 2; + NvU32 reserved7 : 1; + NvU32 DecompressEnable : 1; + NvU32 reserved9 : 5; + NvU64 DecompressCtbCount : 8; + NvU64 DecompressZbcColor : 32; + NvU64 reserved12 : 24; + NvU32 SourceRectLeft : 30; + NvU32 reserved14 : 2; + NvU32 SourceRectRight : 30; + NvU32 reserved15 : 2; + NvU32 SourceRectTop : 30; + NvU32 reserved16 : 2; + NvU32 SourceRectBottom : 30; + NvU32 reserved17 : 2; + NvU32 DestRectLeft : 14; + NvU32 reserved18 : 2; + NvU32 DestRectRight : 14; + NvU32 reserved19 : 2; + NvU32 DestRectTop : 14; + NvU32 reserved20 : 2; + NvU32 DestRectBottom : 14; + NvU32 reserved21 : 2; + NvU32 reserved22 : 32; + NvU32 reserved23 : 32; +} VicSlotStructSlotConfig; + +typedef struct VicSlotStructSlotSurfaceConfig { + NvU32 SlotPixelFormat : 7; + NvU32 SlotChromaLocHoriz : 2; + NvU32 SlotChromaLocVert : 2; + NvU32 SlotBlkKind : 4; + NvU32 SlotBlkHeight : 4; + NvU32 SlotCacheWidth : 3; + NvU32 reserved0 : 10; + NvU32 SlotSurfaceWidth : 14; + NvU32 SlotSurfaceHeight : 14; + NvU32 reserved1 : 4; + NvU32 SlotLumaWidth : 14; + NvU32 SlotLumaHeight : 14; + NvU32 reserved2 : 4; + NvU32 SlotChromaWidth : 14; + NvU32 SlotChromaHeight : 14; + NvU32 reserved3 : 4; +} VicSlotStructSlotSurfaceConfig; + +typedef struct VicSlotStructLumaKeyStruct { + NvU64 luma_coeff0 : 20; + NvU64 luma_coeff1 : 20; + NvU64 luma_coeff2 : 20; + NvU64 luma_r_shift : 4; + NvU64 luma_coeff3 : 20; + NvU64 LumaKeyLower : 10; + NvU64 LumaKeyUpper : 10; + NvU64 LumaKeyEnabled : 1; + NvU64 reserved0 : 2; + NvU64 reserved1 : 21; +} VicSlotStructLumaKeyStruct; + +typedef struct VicSlotStructBlendingSlotStruct { + NvU32 AlphaK1 : 10; + NvU32 reserved0 : 6; + NvU32 AlphaK2 : 10; + NvU32 reserved1 : 6; + NvU32 SrcFactCMatchSelect : 3; + NvU32 reserved2 : 1; + NvU32 DstFactCMatchSelect : 3; + NvU32 reserved3 : 1; + NvU32 SrcFactAMatchSelect : 3; + NvU32 reserved4 : 1; + NvU32 DstFactAMatchSelect : 3; + NvU32 reserved5 : 1; + NvU32 reserved6 : 4; + NvU32 reserved7 : 4; + NvU32 reserved8 : 4; + NvU32 reserved9 : 4; + NvU32 reserved10 : 2; + NvU32 OverrideR : 10; + NvU32 OverrideG : 10; + NvU32 OverrideB : 10; + NvU32 OverrideA : 10; + NvU32 reserved11 : 2; + NvU32 UseOverrideR : 1; + NvU32 UseOverrideG : 1; + NvU32 UseOverrideB : 1; + NvU32 UseOverrideA : 1; + NvU32 MaskR : 1; + NvU32 MaskG : 1; + NvU32 MaskB : 1; + NvU32 MaskA : 1; + NvU32 reserved12 : 12; +} VicSlotStructBlendingSlotStruct; + +typedef struct VicSlotStruct { + VicSlotStructSlotConfig slotConfig; + VicSlotStructSlotSurfaceConfig slotSurfaceConfig; + VicSlotStructLumaKeyStruct lumaKeyStruct; + VicMatrixStruct colorMatrixStruct; + VicMatrixStruct gamutMatrixStruct; + VicSlotStructBlendingSlotStruct blendingSlotStruct; +} VicSlotStruct; + +typedef struct VicConfigStruct { + VicPipeConfig pipeConfig; + VicOutputConfig outputConfig; + VicOutputSurfaceConfig outputSurfaceConfig; + VicMatrixStruct outColorMatrixStruct; + VicClearRectStruct clearRectStruct[4]; + VicSlotStruct slotStruct[8]; +} VicConfigStruct; + +#endif // __VIC_DRV_H ================================================ FILE: switch/ffmpeg/tls.patch ================================================ diff --git a/configure b/configure index 566d5fb..1429aef 100755 --- a/configure +++ b/configure @@ -318,6 +318,7 @@ External library support: --enable-decklink enable Blackmagic DeckLink I/O support [no] --enable-mbedtls enable mbedTLS, needed for https support if openssl, gnutls or libtls is not used [no] + --enable-libnx enable libnx, needed for https support --enable-mediacodec enable Android MediaCodec support [no] --enable-mediafoundation enable encoding via MediaFoundation [auto] --disable-metal disable Apple Metal framework [autodetect] @@ -1852,6 +1853,7 @@ EXTERNAL_AUTODETECT_LIBRARY_LIST=" mediafoundation metal schannel + libnx sdl2 securetransport sndio @@ -3818,7 +3820,7 @@ sctp_protocol_select="network" securetransport_conflict="openssl gnutls libtls mbedtls" srtp_protocol_select="rtp_protocol srtp" tcp_protocol_select="network" -tls_protocol_deps_any="gnutls openssl schannel securetransport libtls mbedtls" +tls_protocol_deps_any="gnutls openssl schannel securetransport libtls mbedtls libnx" tls_protocol_select="tcp_protocol" udp_protocol_select="network" udplite_protocol_select="network" diff --git a/libavformat/Makefile b/libavformat/Makefile index 7ca68a7..c1447c0 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -704,6 +704,7 @@ OBJS-$(CONFIG_IPNS_GATEWAY_PROTOCOL) += ipfsgateway.o TLS-OBJS-$(CONFIG_GNUTLS) += tls_gnutls.o TLS-OBJS-$(CONFIG_LIBTLS) += tls_libtls.o TLS-OBJS-$(CONFIG_MBEDTLS) += tls_mbedtls.o +TLS-OBJS-$(CONFIG_LIBNX) += tls_libnx.o TLS-OBJS-$(CONFIG_OPENSSL) += tls_openssl.o TLS-OBJS-$(CONFIG_SECURETRANSPORT) += tls_securetransport.o TLS-OBJS-$(CONFIG_SCHANNEL) += tls_schannel.o diff --git a/libavformat/network.h b/libavformat/network.h index ca21408..f255760 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -219,6 +219,14 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen, #define getnameinfo ff_getnameinfo #endif /* !HAVE_GETADDRINFO */ +#if HAVE_GETADDRINFO && __SWITCH__ +#undef getnameinfo +int ff_getnameinfo(const struct sockaddr *sa, int salen, + char *host, int hostlen, + char *serv, int servlen, int flags); +#define getnameinfo ff_getnameinfo +#endif + #if !HAVE_GETADDRINFO || HAVE_WINSOCK2_H const char *ff_gai_strerror(int ecode); #undef gai_strerror diff --git a/libavformat/os_support.c b/libavformat/os_support.c index 4d6eb8a..3a54dec 100644 --- a/libavformat/os_support.c +++ b/libavformat/os_support.c @@ -137,6 +137,10 @@ void ff_freeaddrinfo(struct addrinfo *res) av_freep(&res); } +#endif + +#if HAVE_GETADDRINFO && __SWITCH__ + int ff_getnameinfo(const struct sockaddr *sa, int salen, char *host, int hostlen, char *serv, int servlen, int flags) diff --git a/libavformat/tls_libnx.c b/libavformat/tls_libnx.c new file mode 100644 index 0000000..e09b8ed --- /dev/null +++ b/libavformat/tls_libnx.c @@ -0,0 +1,194 @@ +/* + * TLS/SSL Protocol + * Copyright (c) 2018 Thomas Volkert + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "avformat.h" +#include "internal.h" +#include "url.h" +#include "tls.h" +#include "libavutil/parseutils.h" +#include "libavutil/time.h" + +typedef struct TLSContext { + const AVClass *class; + TLSShared tls_shared; + SslContext context; + SslConnection conn; +} TLSContext; + +static int tls_close(URLContext *h) +{ + TLSContext *tls_ctx = h->priv_data; + + sslConnectionClose(&tls_ctx->conn); + sslContextClose(&tls_ctx->context); + + ffurl_closep(&tls_ctx->tls_shared.tcp); + return 0; +} + +static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **options) +{ + TLSContext *tls_ctx = h->priv_data; + TLSShared *shr = &tls_ctx->tls_shared; + int ret; + Result rc; + + if (shr->listen) { + av_log(h, AV_LOG_ERROR, "TLS Listen Sockets with libnx is not implemented.\n"); + return AVERROR(EINVAL); + } + + if ((ret = ff_tls_open_underlying(shr, h, uri, options)) < 0) + goto fail; + + rc = sslCreateContext(&tls_ctx->context, SslVersion_Auto); + if (R_FAILED(rc)) { + ret = AVERROR(EINVAL); + goto fail; + } + + rc = sslContextCreateConnection(&tls_ctx->context, &tls_ctx->conn); + + if (R_SUCCEEDED(rc)) { + rc = sslConnectionSetOption(&tls_ctx->conn, SslOptionType_DoNotCloseSocket, true); + } + + if (R_SUCCEEDED(rc)) { + int sockfd = ffurl_get_file_handle(shr->tcp); + ret = socketSslConnectionSetSocketDescriptor(&tls_ctx->conn, sockfd); + if (ret == -1 && errno != ENOENT) { + ret = AVERROR(EIO); + goto fail; + } + } + + if (R_SUCCEEDED(rc)) { + rc = sslConnectionSetHostName(&tls_ctx->conn, shr->host, strlen(shr->host)); + } + + /* This will fail on system-versions where this option isn't available, + * so ignore errors from this. */ + if (R_SUCCEEDED(rc)) { + sslConnectionSetOption(&tls_ctx->conn, SslOptionType_SkipDefaultVerify, true); + } + + if (R_SUCCEEDED(rc)) { + u32 verifyopt = SslVerifyOption_DateCheck; + if (shr->verify) verifyopt |= SslVerifyOption_PeerCa; + rc = sslConnectionSetVerifyOption(&tls_ctx->conn, verifyopt); + } + + if (R_SUCCEEDED(rc)) { + SslIoMode iomode = SslIoMode_Blocking; + if (h->flags & AVIO_FLAG_NONBLOCK) iomode = SslIoMode_NonBlocking; + rc = sslConnectionSetIoMode(&tls_ctx->conn, iomode); + } + + while (rc = sslConnectionDoHandshake(&tls_ctx->conn, NULL, NULL, NULL, 0)) { + if (R_VALUE(rc) == MAKERESULT(123, 204)) { // PR_WOULD_BLOCK_ERROR + av_usleep(10000); + continue; + } + if (R_VALUE(rc) == MAKERESULT(123, 207)) { + av_log(h, AV_LOG_ERROR, "The certificate is not correctly signed by the trusted CA.\n"); + } else { + av_log(h, AV_LOG_ERROR, "sslConnectionDoHandshake returned: 0x%X\n", R_VALUE(rc)); + } + ret = AVERROR(EIO); + goto fail; + } + return 0; + +fail: + tls_close(h); + return ret; +} + +static int tls_read(URLContext *h, uint8_t *buf, int size) +{ + TLSContext *tls_ctx = h->priv_data; + Result rc = 0; + u32 out_size = 0; + rc = sslConnectionRead(&tls_ctx->conn, buf, size, &out_size); + if (R_SUCCEEDED(rc)) { + return out_size; // return read length + } + if (R_VALUE(rc) == MAKERESULT(123, 204)) { // PR_WOULD_BLOCK_ERROR + return AVERROR(EAGAIN); + } + av_log(h, AV_LOG_WARNING, "sslConnectionRead returned 0x%X\n", R_VALUE(rc)); + return AVERROR(EIO); +} + +static int tls_write(URLContext *h, const uint8_t *buf, int size) +{ + TLSContext *tls_ctx = h->priv_data; + Result rc = 0; + u32 out_size = 0; + rc = sslConnectionWrite(&tls_ctx->conn, buf, size, &out_size); + if (R_SUCCEEDED(rc)) { + return out_size; // return written length + } + if (R_VALUE(rc) == MAKERESULT(123, 204)) { // PR_WOULD_BLOCK_ERROR + return AVERROR(EAGAIN); + } + av_log(h, AV_LOG_WARNING, "sslConnectionWrite returned 0x%X\n", R_VALUE(rc)); + return AVERROR(EIO); +} + +static int tls_get_file_handle(URLContext *h) +{ + TLSContext *c = h->priv_data; + return ffurl_get_file_handle(c->tls_shared.tcp); +} + +static int tls_get_short_seek(URLContext *h) +{ + TLSContext *s = h->priv_data; + return ffurl_get_short_seek(s->tls_shared.tcp); +} + +static const AVOption options[] = { + TLS_COMMON_OPTIONS(TLSContext, tls_shared), + { NULL } +}; + +static const AVClass tls_class = { + .class_name = "tls", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +const URLProtocol ff_tls_protocol = { + .name = "tls", + .url_open2 = tls_open, + .url_read = tls_read, + .url_write = tls_write, + .url_close = tls_close, + .url_get_file_handle = tls_get_file_handle, + .url_get_short_seek = tls_get_short_seek, + .priv_data_size = sizeof(TLSContext), + .flags = URL_PROTOCOL_FLAG_NETWORK, + .priv_data_class = &tls_class, +}; ================================================ FILE: switch/flac/.gitignore ================================================ switch-flac ================================================ FILE: switch/flac/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: cpasjuste pkgname=switch-flac pkgver=1.3.2 pkgrel=4 pkgdesc='FLAC stands for Free Lossless Audio Codec, an audio format similar to MP3, but lossless...' arch=('any') url='https://xiph.org/flac/' license=(Xiph.org) options=(!strip libtool staticlibs) depends=("switch-libogg") makedepends=('dkp-toolchain-vars') source=( "https://ftp.osuosl.org/pub/xiph/releases/flac/flac-$pkgver.tar.xz" "flac-${pkgver}.patch" ) groups=('switch-portlibs') sha256sums=( '91cfc3ed61dc40f47f050a109b08610667d73477af6ef36dcad31c31a4a8d53f' '4cf8a618c78a1726a2517700d5d7816ce925b510b0a7117ebcab2faec202a785' ) build() { cd flac-$pkgver source /opt/devkitpro/switchvars.sh patch -Np1 -i "$srcdir/flac-${pkgver}.patch" CFLAGS="${CFLAGS} -D__SWITCH__ " \ ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static \ --disable-xmms-plugin --enable-cpplibs \ --disable-sse make -C src/libFLAC } package() { cd flac-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: switch/flac/flac-1.3.2.patch ================================================ diff -NBaur flac-1.3.2.orig/include/share/compat.h flac-1.3.2/include/share/compat.h --- flac-1.3.2.orig/include/share/compat.h 2016-12-07 20:10:26.218454157 +0000 +++ flac-1.3.2/include/share/compat.h 2019-05-24 01:17:05.257064900 +0100 @@ -167,8 +167,14 @@ #define flac_vfprintf vfprintf #define flac_fopen fopen +#ifdef __SWITCH__ +#define flac_chmod(a, b) printf("flac_chmod: not implemented\n") +#define flac_utime(a, b) printf("flac_utime: not implemented\n") +#define chown(a, b, c) printf("flac_chown: not implemented\n") +#else #define flac_chmod chmod #define flac_utime utime +#endif #define flac_unlink unlink #define flac_rename rename #define flac_stat stat diff -NBaur flac-1.3.2.orig/Makefile.in flac-1.3.2/Makefile.in --- flac-1.3.2.orig/Makefile.in 2017-01-01 03:46:48.833726273 +0000 +++ flac-1.3.2/Makefile.in 2019-05-24 01:17:05.264899302 +0100 @@ -397,7 +397,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = doc include m4 man src examples test build objs microbench +SUBDIRS = include m4 src build objs EXTRA_DIST = \ COPYING.FDL \ COPYING.GPL \ diff -NBaur flac-1.3.2.orig/src/Makefile.in flac-1.3.2/src/Makefile.in --- flac-1.3.2.orig/src/Makefile.in 2017-01-01 03:46:49.385728167 +0000 +++ flac-1.3.2/src/Makefile.in 2019-05-24 01:18:39.497280352 +0100 @@ -363,19 +363,11 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @FLaC__HAS_XMMS_TRUE@XMMS_DIRS = plugin_common plugin_xmms -@FLaC__WITH_CPPLIBS_TRUE@CPPLIBS_DIRS = libFLAC++ test_libFLAC++ +@FLaC__WITH_CPPLIBS_TRUE@CPPLIBS_DIRS = libFLAC++ SUBDIRS = \ libFLAC \ share \ - flac \ - metaflac \ $(XMMS_DIRS) \ - test_grabbag \ - test_libs_common \ - test_libFLAC \ - test_seeking \ - test_streams \ - utils \ $(CPPLIBS_DIRS) EXTRA_DIST = \ ================================================ FILE: switch/freetype/.gitignore ================================================ switch-freetype ================================================ FILE: switch/freetype/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: cpasjuste # Contributor: carstene1ns # Contributor: Pablo Curiel pkgname=switch-freetype pkgver=2.13.3 pkgrel=1 pkgdesc='FreeType is a freely available software library to render fonts.' arch=('any') url='https://www.freetype.org/' license=(GPL2+ custom:FreeType) options=(!strip libtool staticlibs) depends=("switch-bzip2" "switch-libpng" "switch-zlib" ) groups=('switch-portlibs') makedepends=('switch-pkg-config' 'dkp-toolchain-vars') source=("http://download.savannah.gnu.org/releases/freetype/freetype-$pkgver.tar.xz") prepare() { cd freetype-$pkgver source /opt/devkitpro/switchvars.sh aarch64-none-elf-cmake -B _build -GNinja } build() { cd freetype-$pkgver source /opt/devkitpro/switchvars.sh aarch64-none-elf-cmake --build _build } package() { cd freetype-$pkgver source /opt/devkitpro/switchvars.sh DESTDIR="$pkgdir" aarch64-none-elf-cmake --install _build # Licenses install -Dm644 "LICENSE.TXT" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/LICENSE.TXT" install -Dm644 "docs/GPLv2.TXT" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/GPLv2.TXT" install -Dm644 "docs/FTL.TXT" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/FTL.TXT" } sha256sums=('0550350666d427c74daeb85d5ac7bb353acba5f76956395995311a9c6f063289') ================================================ FILE: switch/giflib/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Colin969 pkgname=switch-giflib pkgver=5.1.4 pkgrel=2 pkgdesc='A library for reading and writing gif images' arch=('any') url='http://sourceforge.net/projects/giflib' license=('MIT') options=(!strip libtool staticlibs) source=("http://downloads.sourceforge.net/sourceforge/giflib/giflib-${pkgver}.tar.bz2") sha256sums=('df27ec3ff24671f80b29e6ab1c4971059c14ac3db95406884fc26574631ba8d5') makedepends=('dkp-toolchain-vars') groups=('switch-portlibs') build() { source /opt/devkitpro/switchvars.sh cd giflib-$pkgver ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf make } package() { cd giflib-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="${pkgdir}" install # MIT License install -Dm644 COPYING "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/COPYING" } ================================================ FILE: switch/glad/PKGBUILD ================================================ # Maintainer: fincs pkgname=switch-glad pkgver=0.1.27 pkgrel=1 pkgdesc="OpenGL Loader (modified for Switch)" arch=('any') license=('MIT') url="http://github.com/devkitPro" options=(!strip libtool staticlibs) source=(${url}/${pkgname}/releases/download/v${pkgver}/${pkgname}-src-${pkgver}.tar.bz2) sha256sums=('b59cf95c542b19947e0595daef7da9b5b541f4e8ce3cb6995ea3470298b7ccb9') makedepends=('devkitA64') depends=('switch-mesa') groups=('switch-portlibs') build() { make -C $srcdir } package() { make -C $srcdir DESTDIR=$pkgdir install } ================================================ FILE: switch/glfw/PKGBUILD ================================================ # Maintainer: fincs pkgbasename=glfw pkgname=switch-$pkgbasename pkgver=3.3.4 pkgrel=2 pkgdesc='Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan development on the desktop' arch=('any') url='https://github.com/glfw/glfw' license=(MIT) options=(!strip libtool staticlibs) source=( "${url}/releases/download/${pkgver}/${pkgbasename}-${pkgver}.zip" "${pkgname}-${pkgver}.patch" ) sha256sums=( 'bbd2c42c660b725e9755eb417e40b373f0d4c03138c9b2e210d02cd308bd99cd' # glfw-3.3.4.zip '3af95bc53a11472f024ad8518a2013b52ce3b93c73d66691da992279306663f9' # switch-glfw-3.3.4.patch ) depends=('switch-mesa') makedepends=('dkp-toolchain-vars' 'switch-cmake') groups=('switch-portlibs') build() { cd ${pkgbasename}-${pkgver} patch -p1 -i ${srcdir}/${pkgname}-${pkgver}.patch source ${DEVKITPRO}/switchvars.sh aarch64-none-elf-cmake -G"Unix Makefiles" \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DCMAKE_C_FLAGS="$CFLAGS $CPPFLAGS" \ -DGLFW_BUILD_EXAMPLES:BOOL=OFF -DGLFW_BUILD_TESTS:BOOL=OFF -DGLFW_BUILD_DOCS:BOOL=OFF \ -DGLFW_VULKAN_STATIC:BOOL=ON -DGLFW_EGL_STATIC:BOOL=ON \ . make } package() { cd ${pkgbasename}-${pkgver} make install DESTDIR="$pkgdir" } ================================================ FILE: switch/glfw/switch-glfw-3.3.4.patch ================================================ diff --git a/CMakeLists.txt b/CMakeLists.txt index e2962df9..f6a3abe7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,7 @@ option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON) option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON) option(GLFW_INSTALL "Generate installation target" ON) option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" OFF) +option(GLFW_EGL_STATIC "Statically link to EGL" OFF) include(GNUInstallDirs) include(CMakeDependentOption) @@ -57,6 +58,13 @@ if (GLFW_VULKAN_STATIC) set(_GLFW_VULKAN_STATIC 1) endif() +if (GLFW_EGL_STATIC) + if (BUILD_SHARED_LIBS) + message(FATAL_ERROR "You are trying to link the EGL static library into the GLFW shared library") + endif() + set(_GLFW_EGL_STATIC 1) +endif() + list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules") find_package(Threads REQUIRED) @@ -155,6 +163,9 @@ elseif (APPLE) elseif (UNIX) set(_GLFW_X11 1) message(STATUS "Using X11 for window creation") +elseif (NINTENDO_SWITCH) + set(_GLFW_SWITCH 1) + message(STATUS "Using Switch for window creation") else() message(FATAL_ERROR "No supported platform was detected") endif() @@ -183,6 +194,15 @@ if (UNIX AND NOT APPLE) endif() endif() +if (NINTENDO_SWITCH) + find_library(MATH_LIBRARY m) + mark_as_advanced(MATH_LIBRARY) + if (MATH_LIBRARY) + list(APPEND glfw_LIBRARIES "${MATH_LIBRARY}") + list(APPEND glfw_PKG_LIBS "-lm") + endif() +endif() + #-------------------------------------------------------------------- # Use Win32 for window creation #-------------------------------------------------------------------- @@ -295,13 +315,29 @@ if (_GLFW_COCOA) set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation") endif() +#-------------------------------------------------------------------- +# Use Switch for window creation +#-------------------------------------------------------------------- +if (_GLFW_SWITCH) + + list(APPEND glfw_PKG_LIBS "-lnx") + +endif() + #-------------------------------------------------------------------- # Add the Vulkan loader as a dependency if necessary #-------------------------------------------------------------------- -if (GLFW_VULKAN_STATIC) +if (GLFW_VULKAN_STATIC AND NOT SWITCH_LIBNX) list(APPEND glfw_PKG_DEPS "vulkan") endif() +#-------------------------------------------------------------------- +# Add EGL as a dependency if necessary +#-------------------------------------------------------------------- +if (GLFW_EGL_STATIC) + list(APPEND glfw_PKG_DEPS "egl") +endif() + #-------------------------------------------------------------------- # Export GLFW library dependencies #-------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a409459b..1cec7407 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -60,6 +60,11 @@ elseif (_GLFW_OSMESA) posix_time.h posix_thread.h osmesa_context.h) set(glfw_SOURCES ${common_SOURCES} null_init.c null_monitor.c null_window.c null_joystick.c posix_time.c posix_thread.c osmesa_context.c) +elseif (_GLFW_SWITCH) + set(glfw_HEADERS ${common_HEADERS} switch_platform.h switch_joystick.h + posix_time.h posix_thread.h egl_context.h) + set(glfw_SOURCES ${common_SOURCES} switch_init.c switch_monitor.c switch_window.c + switch_joystick.c switch_context.c switch_time.c posix_thread.c egl_context.c) endif() if (_GLFW_X11 OR _GLFW_WAYLAND) diff --git a/src/egl_context.c b/src/egl_context.c index 6288fb7c..3965da29 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -252,6 +252,7 @@ static int extensionSupportedEGL(const char* extension) static GLFWglproc getProcAddressEGL(const char* procname) { +#if !defined(_GLFW_EGL_STATIC) _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); if (window->context.egl.client) @@ -261,12 +262,14 @@ static GLFWglproc getProcAddressEGL(const char* procname) if (proc) return proc; } +#endif return eglGetProcAddress(procname); } static void destroyContextEGL(_GLFWwindow* window) { +#if !defined(_GLFW_EGL_STATIC) #if defined(_GLFW_X11) // NOTE: Do not unload libGL.so.1 while the X11 display is still open, // as it will make XCloseDisplay segfault @@ -279,6 +282,7 @@ static void destroyContextEGL(_GLFWwindow* window) window->context.egl.client = NULL; } } +#endif if (window->context.egl.surface) { @@ -302,6 +306,7 @@ static void destroyContextEGL(_GLFWwindow* window) // GLFWbool _glfwInitEGL(void) { +#if !defined(_GLFW_EGL_STATIC) int i; const char* sonames[] = { @@ -394,6 +399,10 @@ GLFWbool _glfwInitEGL(void) _glfwTerminateEGL(); return GLFW_FALSE; } +#else + if (_glfw.egl.display) + return GLFW_TRUE; +#endif _glfw.egl.display = eglGetDisplay(_GLFW_EGL_NATIVE_DISPLAY); if (_glfw.egl.display == EGL_NO_DISPLAY) @@ -440,11 +449,13 @@ void _glfwTerminateEGL(void) _glfw.egl.display = EGL_NO_DISPLAY; } +#if !defined(_GLFW_EGL_STATIC) if (_glfw.egl.handle) { _glfw_dlclose(_glfw.egl.handle); _glfw.egl.handle = NULL; } +#endif } #define setAttrib(a, v) \ @@ -613,6 +624,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, window->context.egl.config = config; +#if !defined(_GLFW_EGL_STATIC) // Load the appropriate client library if (!_glfw.egl.KHR_get_all_proc_addresses) { @@ -690,6 +702,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, return GLFW_FALSE; } } +#endif window->context.makeCurrent = makeContextCurrentEGL; window->context.swapBuffers = swapBuffersEGL; diff --git a/src/egl_context.h b/src/egl_context.h index 6d42e11c..04f92f27 100644 --- a/src/egl_context.h +++ b/src/egl_context.h @@ -43,6 +43,10 @@ typedef Window EGLNativeWindowType; #define EGLAPIENTRY typedef struct wl_display* EGLNativeDisplayType; typedef struct wl_egl_window* EGLNativeWindowType; +#elif defined(_GLFW_SWITCH) + #define EGLAPIENTRY +typedef void* EGLNativeDisplayType; +typedef void* EGLNativeWindowType; #else #error "No supported EGL platform selected" #endif @@ -115,6 +119,24 @@ typedef void* EGLContext; typedef void* EGLDisplay; typedef void* EGLSurface; +#if defined(_GLFW_EGL_STATIC) +EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay,EGLConfig,EGLint,EGLint*); +EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay,EGLConfig*,EGLint,EGLint*); +EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType); +EGLint EGLAPIENTRY eglGetError(void); +EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay,EGLint*,EGLint*); +EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay); +EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum); +EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay,EGLConfig,EGLContext,const EGLint*); +EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay,EGLSurface); +EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay,EGLContext); +EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*); +EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay,EGLSurface,EGLSurface,EGLContext); +EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay,EGLSurface); +EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay,EGLint); +const char* EGLAPIENTRY eglQueryString(EGLDisplay,EGLint); +GLFWglproc EGLAPIENTRY eglGetProcAddress(const char*); +#else // EGL function pointer typedefs typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*); typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*); @@ -148,6 +170,7 @@ typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*); #define eglSwapInterval _glfw.egl.SwapInterval #define eglQueryString _glfw.egl.QueryString #define eglGetProcAddress _glfw.egl.GetProcAddress +#endif #define _GLFW_EGL_CONTEXT_STATE _GLFWcontextEGL egl #define _GLFW_EGL_LIBRARY_CONTEXT_STATE _GLFWlibraryEGL egl @@ -161,7 +184,9 @@ typedef struct _GLFWcontextEGL EGLContext handle; EGLSurface surface; +#if !defined(_GLFW_EGL_STATIC) void* client; +#endif } _GLFWcontextEGL; @@ -179,6 +204,7 @@ typedef struct _GLFWlibraryEGL GLFWbool KHR_get_all_proc_addresses; GLFWbool KHR_context_flush_control; +#if !defined(_GLFW_EGL_STATIC) void* handle; PFN_eglGetConfigAttrib GetConfigAttrib; @@ -197,6 +223,7 @@ typedef struct _GLFWlibraryEGL PFN_eglSwapInterval SwapInterval; PFN_eglQueryString QueryString; PFN_eglGetProcAddress GetProcAddress; +#endif } _GLFWlibraryEGL; diff --git a/src/glfw_config.h.in b/src/glfw_config.h.in index f418c995..08673eab 100644 --- a/src/glfw_config.h.in +++ b/src/glfw_config.h.in @@ -44,11 +44,15 @@ #cmakedefine _GLFW_WAYLAND // Define this to 1 if building GLFW for OSMesa #cmakedefine _GLFW_OSMESA +// Define this to 1 if building GLFW for Switch +#cmakedefine _GLFW_SWITCH // Define this to 1 if building as a shared library / dynamic library / DLL #cmakedefine _GLFW_BUILD_DLL // Define this to 1 to use Vulkan loader linked statically into application #cmakedefine _GLFW_VULKAN_STATIC +// Define this to 1 to use EGL linked statically into application +#cmakedefine _GLFW_EGL_STATIC // Define this to 1 to force use of high-performance GPU on hybrid systems #cmakedefine _GLFW_USE_HYBRID_HPG diff --git a/src/init.c b/src/init.c index e44d0ca2..8706b22d 100644 --- a/src/init.c +++ b/src/init.c @@ -28,7 +28,9 @@ //======================================================================== #include "internal.h" +#if !defined(_GLFW_SWITCH) #include "mappings.h" +#endif #include #include @@ -250,6 +252,7 @@ GLFWAPI int glfwInit(void) glfwDefaultWindowHints(); +#if !defined(_GLFW_SWITCH) { int i; @@ -262,6 +265,7 @@ GLFWAPI int glfwInit(void) } } } +#endif return GLFW_TRUE; } diff --git a/src/input.c b/src/input.c index 337d5cf0..44674352 100644 --- a/src/input.c +++ b/src/input.c @@ -43,6 +43,8 @@ #define _GLFW_JOYSTICK_BUTTON 2 #define _GLFW_JOYSTICK_HATBIT 3 +#if !defined(_GLFW_SWITCH) + // Finds a mapping based on joystick GUID // static _GLFWmapping* findMapping(const char* guid) @@ -251,6 +253,8 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string) return GLFW_TRUE; } +#endif + ////////////////////////////////////////////////////////////////////////// ////// GLFW event API ////// @@ -439,7 +443,9 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name, js->hatCount = hatCount; strncpy(js->guid, guid, sizeof(js->guid) - 1); +#if !defined(_GLFW_SWITCH) js->mapping = findValidMapping(js); +#endif return js; } @@ -1114,6 +1120,7 @@ GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun) GLFWAPI int glfwUpdateGamepadMappings(const char* string) { +#if !defined(_GLFW_SWITCH) int jid; const char* c = string; @@ -1168,6 +1175,7 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string) if (js->present) js->mapping = findValidMapping(js); } +#endif return GLFW_TRUE; } diff --git a/src/internal.h b/src/internal.h index 91631c06..b607cbbe 100644 --- a/src/internal.h +++ b/src/internal.h @@ -190,6 +190,8 @@ typedef void (APIENTRY * PFN_vkVoidFunction)(void); #include "wl_platform.h" #elif defined(_GLFW_OSMESA) #include "null_platform.h" +#elif defined(_GLFW_SWITCH) + #include "switch_platform.h" #else #error "No supported window creation API selected" #endif @@ -563,6 +565,8 @@ struct _GLFWlibrary GLFWbool KHR_xcb_surface; #elif defined(_GLFW_WAYLAND) GLFWbool KHR_wayland_surface; +#elif defined(_GLFW_SWITCH) + GLFWbool NN_vi_surface; #endif } vk; diff --git a/src/switch_context.c b/src/switch_context.c new file mode 100644 index 00000000..b2fef527 --- /dev/null +++ b/src/switch_context.c @@ -0,0 +1,77 @@ +//======================================================================== +// GLFW 3.3 - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2016 Google Inc. +// Copyright (c) 2016-2019 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#define _GLFW_SWITCH_NO_CONTEXT_WRAPPER +#include "internal.h" + + +int _glfwPlatformCreateContext(_GLFWwindow* window, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig) +{ + if (!_glfwInitEGL()) + return GLFW_FALSE; + if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) + return GLFW_FALSE; + return GLFW_TRUE; +} + +void _glfwPlatformTerminateContextApi(void) +{ + _glfwTerminateEGL(); +} + +GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle) +{ + _glfwMakeContextCurrentImpl(handle); +} + +GLFWAPI GLFWwindow* glfwGetCurrentContext(void) +{ + return _glfwGetCurrentContextImpl(); +} + +GLFWAPI void glfwSwapBuffers(GLFWwindow* handle) +{ + _glfwSwapBuffersImpl(handle); +} + +GLFWAPI void glfwSwapInterval(int interval) +{ + _glfwSwapIntervalImpl(interval); +} + +GLFWAPI int glfwExtensionSupported(const char* extension) +{ + return _glfwExtensionSupportedImpl(extension); +} + +GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname) +{ + return _glfwGetProcAddressImpl(procname); +} + diff --git a/src/switch_init.c b/src/switch_init.c new file mode 100644 index 00000000..4145a4a7 --- /dev/null +++ b/src/switch_init.c @@ -0,0 +1,110 @@ +//======================================================================== +// GLFW 3.3 - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2016 Google Inc. +// Copyright (c) 2016-2017 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#include "internal.h" + + +static AppletHookCookie s_glfwAppletHookCookie; + +static void _glfwSwitchRefreshFocusState(void) +{ + int is_focused = appletGetFocusState() == AppletFocusState_InFocus ? GLFW_TRUE : GLFW_FALSE; + if (is_focused != _glfw.nx.is_focused) + { + _glfw.nx.event_mask |= _GLFW_SWITCH_EVENT_FOCUS_CHANGED; + _glfw.nx.is_focused = is_focused; + } +} + +static void _glfwSwitchRefreshScreenSize(void) +{ + _glfw.nx.event_mask |= _GLFW_SWITCH_EVENT_SCREEN_SIZE_CHANGED; + switch (appletGetOperationMode()) + { + default: + case AppletOperationMode_Handheld: + _glfw.nx.scr_width = 1280; + _glfw.nx.scr_height = 720; + break; + case AppletOperationMode_Console: + _glfw.nx.scr_width = 1920; + _glfw.nx.scr_height = 1080; + break; + } +} + +static void _glfwSwitchAppletHook(AppletHookType hook, void* param) +{ + switch (hook) + { + default: + break; + case AppletHookType_OnFocusState: + _glfwSwitchRefreshFocusState(); + break; + case AppletHookType_OnOperationMode: + _glfwSwitchRefreshScreenSize(); + break; + } +} + +__attribute__ ((weak)) +void _glfwPlatformTerminateContextApi(void) +{ +} + + +////////////////////////////////////////////////////////////////////////// +////// GLFW platform API ////// +////////////////////////////////////////////////////////////////////////// + +int _glfwPlatformInit(void) +{ + appletLockExit(); + appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend); + appletHook(&s_glfwAppletHookCookie, _glfwSwitchAppletHook, NULL); + _glfwSwitchRefreshFocusState(); + _glfwSwitchRefreshScreenSize(); + + _GLFWmonitor* monitor = _glfwAllocMonitor("Default", 1920, 1080); + _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST); + _glfwInitSwitchJoysticks(); + return GLFW_TRUE; +} + +void _glfwPlatformTerminate(void) +{ + _glfwPlatformTerminateContextApi(); + appletUnhook(&s_glfwAppletHookCookie); + appletUnlockExit(); +} + +const char* _glfwPlatformGetVersionString(void) +{ + return _GLFW_VERSION_NUMBER " Switch EGL"; +} + diff --git a/src/switch_joystick.c b/src/switch_joystick.c new file mode 100644 index 00000000..e0054235 --- /dev/null +++ b/src/switch_joystick.c @@ -0,0 +1,230 @@ +//======================================================================== +// GLFW 3.3 - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2016-2017 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#include "internal.h" + +// Built-in soft-reset combo that triggers a GLFW window close event +#define SOFT_RESET_COMBO (HidNpadButton_Plus|HidNpadButton_Minus|HidNpadButton_L|HidNpadButton_R) + +// Internal constants for gamepad mapping source types +#define _GLFW_JOYSTICK_AXIS 1 +#define _GLFW_JOYSTICK_BUTTON 2 +#define _GLFW_JOYSTICK_HATBIT 3 + +#define TOUCH_WIDTH 1280 +#define TOUCH_HEIGHT 720 + +enum +{ + _SWITCH_AXIS_LEFT_X, + _SWITCH_AXIS_LEFT_Y, + _SWITCH_AXIS_RIGHT_X, + _SWITCH_AXIS_RIGHT_Y, + + _SWITCH_AXIS_COUNT +}; + +enum +{ + _SWITCH_BUTTON_A, + _SWITCH_BUTTON_B, + _SWITCH_BUTTON_X, + _SWITCH_BUTTON_Y, + _SWITCH_BUTTON_LSTICK, + _SWITCH_BUTTON_RSTICK, + _SWITCH_BUTTON_L, + _SWITCH_BUTTON_R, + _SWITCH_BUTTON_ZL, + _SWITCH_BUTTON_ZR, + _SWITCH_BUTTON_PLUS, + _SWITCH_BUTTON_MINUS, + + _SWITCH_BUTTON_COUNT +}; + +enum +{ + _SWITCH_HAT_DPAD, + _SWITCH_HAT_LEFT_STICK, + _SWITCH_HAT_RIGHT_STICK, + + _SWITCH_HAT_COUNT +}; + +static _GLFWmapping s_switchMapping = +{ + .name = "Nintendo Switch Controller", + .guid = "", + .buttons = + { + [GLFW_GAMEPAD_BUTTON_A] = { .type = _GLFW_JOYSTICK_BUTTON, .index = _SWITCH_BUTTON_A }, + [GLFW_GAMEPAD_BUTTON_B] = { .type = _GLFW_JOYSTICK_BUTTON, .index = _SWITCH_BUTTON_B }, + [GLFW_GAMEPAD_BUTTON_X] = { .type = _GLFW_JOYSTICK_BUTTON, .index = _SWITCH_BUTTON_X }, + [GLFW_GAMEPAD_BUTTON_Y] = { .type = _GLFW_JOYSTICK_BUTTON, .index = _SWITCH_BUTTON_Y }, + [GLFW_GAMEPAD_BUTTON_BACK] = { .type = _GLFW_JOYSTICK_BUTTON, .index = _SWITCH_BUTTON_MINUS }, + [GLFW_GAMEPAD_BUTTON_START] = { .type = _GLFW_JOYSTICK_BUTTON, .index = _SWITCH_BUTTON_PLUS }, + //[GLFW_GAMEPAD_BUTTON_GUIDE] = { .type = _GLFW_JOYSTICK_BUTTON, .index = 0 }, + [GLFW_GAMEPAD_BUTTON_LEFT_BUMPER] = { .type = _GLFW_JOYSTICK_BUTTON, .index = _SWITCH_BUTTON_L }, + [GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER] = { .type = _GLFW_JOYSTICK_BUTTON, .index = _SWITCH_BUTTON_R }, + [GLFW_GAMEPAD_BUTTON_LEFT_THUMB] = { .type = _GLFW_JOYSTICK_BUTTON, .index = _SWITCH_BUTTON_LSTICK }, + [GLFW_GAMEPAD_BUTTON_RIGHT_THUMB] = { .type = _GLFW_JOYSTICK_BUTTON, .index = _SWITCH_BUTTON_RSTICK }, + [GLFW_GAMEPAD_BUTTON_DPAD_UP] = { .type = _GLFW_JOYSTICK_HATBIT, .index = (_SWITCH_HAT_DPAD<<4) | 0x1 }, + [GLFW_GAMEPAD_BUTTON_DPAD_RIGHT] = { .type = _GLFW_JOYSTICK_HATBIT, .index = (_SWITCH_HAT_DPAD<<4) | 0x2 }, + [GLFW_GAMEPAD_BUTTON_DPAD_DOWN] = { .type = _GLFW_JOYSTICK_HATBIT, .index = (_SWITCH_HAT_DPAD<<4) | 0x4 }, + [GLFW_GAMEPAD_BUTTON_DPAD_LEFT] = { .type = _GLFW_JOYSTICK_HATBIT, .index = (_SWITCH_HAT_DPAD<<4) | 0x8 }, + }, + .axes = + { + [GLFW_GAMEPAD_AXIS_LEFT_TRIGGER] = { .type = _GLFW_JOYSTICK_BUTTON, .index = _SWITCH_BUTTON_ZL }, + [GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER] = { .type = _GLFW_JOYSTICK_BUTTON, .index = _SWITCH_BUTTON_ZR }, + [GLFW_GAMEPAD_AXIS_LEFT_X] = { .type = _GLFW_JOYSTICK_AXIS, .index = _SWITCH_AXIS_LEFT_X, .axisScale = 1, .axisOffset = 0 }, + [GLFW_GAMEPAD_AXIS_LEFT_Y] = { .type = _GLFW_JOYSTICK_AXIS, .index = _SWITCH_AXIS_LEFT_Y, .axisScale = 1, .axisOffset = 0 }, + [GLFW_GAMEPAD_AXIS_RIGHT_X] = { .type = _GLFW_JOYSTICK_AXIS, .index = _SWITCH_AXIS_RIGHT_X, .axisScale = 1, .axisOffset = 0 }, + [GLFW_GAMEPAD_AXIS_RIGHT_Y] = { .type = _GLFW_JOYSTICK_AXIS, .index = _SWITCH_AXIS_RIGHT_Y, .axisScale = 1, .axisOffset = 0 }, + }, +}; + +PadState pad; + +void _glfwInitSwitchJoysticks(void) +{ + _GLFWjoystick* js = _glfwAllocJoystick(s_switchMapping.name, s_switchMapping.guid, + _SWITCH_AXIS_COUNT, _SWITCH_BUTTON_COUNT, _SWITCH_HAT_COUNT); + + padConfigureInput(1, HidNpadStyleSet_NpadStandard); + padInitializeDefault(&pad); + hidInitializeTouchScreen(); + + js->mapping = &s_switchMapping; + + padUpdate(&pad); + _glfwInputJoystick(js, GLFW_CONNECTED); +} + +void _glfwUpdateSwitchJoysticks(void) +{ + u64 down, held, up; + + // Read input state + padUpdate(&pad); + down = padGetButtonsDown(&pad); + held = padGetButtons(&pad); + up = padGetButtonsUp(&pad); + + // Check for soft-reset combo + if ((held & SOFT_RESET_COMBO) == SOFT_RESET_COMBO) + { + _glfwInputWindowCloseRequest(_glfw.nx.cur_window); + return; + } + +#define MAP_KEY(_libnx_key, _glfw_key, _scancode) \ + do { \ + if (down & (_libnx_key)) _glfwInputKey(_glfw.nx.cur_window, (_glfw_key), (_scancode), GLFW_PRESS, 0); \ + else if (up & (_libnx_key)) _glfwInputKey(_glfw.nx.cur_window, (_glfw_key), (_scancode), GLFW_RELEASE, 0); \ + } while (0) + + // Map common keyboard keys to the controller + // TODO: Only do this mapping if a keyboard isn't connected + MAP_KEY(HidNpadButton_Up, GLFW_KEY_UP, HidKeyboardKey_UpArrow); + MAP_KEY(HidNpadButton_Down, GLFW_KEY_DOWN, HidKeyboardKey_DownArrow); + MAP_KEY(HidNpadButton_Left, GLFW_KEY_LEFT, HidKeyboardKey_LeftArrow); + MAP_KEY(HidNpadButton_Right, GLFW_KEY_RIGHT, HidKeyboardKey_RightArrow); + MAP_KEY(HidNpadButton_A, GLFW_KEY_X, HidKeyboardKey_X); + MAP_KEY(HidNpadButton_B, GLFW_KEY_Z, HidKeyboardKey_Z); + MAP_KEY(HidNpadButton_X, GLFW_KEY_S, HidKeyboardKey_S); + MAP_KEY(HidNpadButton_Y, GLFW_KEY_A, HidKeyboardKey_A); + MAP_KEY(HidNpadButton_Plus, GLFW_KEY_ENTER, HidKeyboardKey_Return); + MAP_KEY(HidNpadButton_Minus, GLFW_KEY_ESCAPE, HidKeyboardKey_Escape); + + // Report touch inputs as mouse clicks + HidTouchScreenState state={0}; + if (hidGetTouchScreenStates(&state, 1)) { + if (state.count > 0) + { + + double scaledXPos = (double)state.touches[0].x / TOUCH_WIDTH * _glfw.nx.scr_width; + double scaledYPos = (double)state.touches[0].y / TOUCH_HEIGHT * _glfw.nx.scr_height; + + _glfwInputCursorPos(_glfw.nx.cur_window, scaledXPos, scaledYPos); + + if (_glfw.nx.cur_window->mouseButtons[GLFW_MOUSE_BUTTON_LEFT] == GLFW_RELEASE) + _glfwInputMouseClick(_glfw.nx.cur_window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, 0); + + } + else if (_glfw.nx.cur_window->mouseButtons[GLFW_MOUSE_BUTTON_LEFT] == GLFW_PRESS) + _glfwInputMouseClick(_glfw.nx.cur_window, GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE, 0); + } +} + +////////////////////////////////////////////////////////////////////////// +////// GLFW platform API ////// +////////////////////////////////////////////////////////////////////////// + +int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) +{ + // Detect presence + if (!padIsConnected(&pad)) + return GLFW_FALSE; + + if (mode & _GLFW_POLL_AXES) + { + HidAnalogStickState left, right; + left = padGetStickPos(&pad, 0); + right = padGetStickPos(&pad, 1); + _glfwInputJoystickAxis(js, _SWITCH_AXIS_LEFT_X, left.x / 32768.0f); + _glfwInputJoystickAxis(js, _SWITCH_AXIS_LEFT_Y, -left.y / 32768.0f); + _glfwInputJoystickAxis(js, _SWITCH_AXIS_RIGHT_X, right.x / 32768.0f); + _glfwInputJoystickAxis(js, _SWITCH_AXIS_RIGHT_Y, -right.y / 32768.0f); + } + + if (mode & _GLFW_POLL_BUTTONS) + { + int i; + u64 keys = padGetButtons(&pad); + keys |= ((keys >> 24) & 0x3) << _SWITCH_BUTTON_L; // Map KEY_SL/SR_LEFT into HidNpadButton_L/R + keys |= ((keys >> 26) & 0x3) << _SWITCH_BUTTON_L; // Map KEY_SL/SR_RIGHT into HidNpadButton_L/R + for (i = 0; i < _SWITCH_BUTTON_COUNT; i ++) + _glfwInputJoystickButton(js, i, (keys & BIT(i)) ? GLFW_PRESS : GLFW_RELEASE); + for (i = 0; i < _SWITCH_HAT_COUNT; i ++) + { + // Extract hat values. A small ROR operation is necessary + // in order to convert Switch DRUL into glfw LDRU + char hatbits = (keys >> (12 + 4*i)) & 0xF; + hatbits = (hatbits >> 1) | ((hatbits & 1) << 3); + _glfwInputJoystickHat(js, i, hatbits); + } + } + + return GLFW_TRUE; +} + +/* Not used on Switch +void _glfwPlatformUpdateGamepadGUID(char* guid) +{ +} +*/ + diff --git a/src/switch_joystick.h b/src/switch_joystick.h new file mode 100644 index 00000000..9314b376 --- /dev/null +++ b/src/switch_joystick.h @@ -0,0 +1,40 @@ +//======================================================================== +// GLFW 3.3 - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2006-2017 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNX nx +#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE + +#define _GLFW_PLATFORM_MAPPING_NAME "Switch" + +// Switch-specific per-joystick data +// +typedef struct _GLFWjoystickNX +{ +} _GLFWjoystickNX; + +void _glfwInitSwitchJoysticks(void); +void _glfwUpdateSwitchJoysticks(void); + diff --git a/src/switch_monitor.c b/src/switch_monitor.c new file mode 100644 index 00000000..4a7df359 --- /dev/null +++ b/src/switch_monitor.c @@ -0,0 +1,91 @@ +//======================================================================== +// GLFW 3.3 - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2016 Google Inc. +// Copyright (c) 2016-2019 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#include "internal.h" +#include + + +////////////////////////////////////////////////////////////////////////// +////// GLFW platform API ////// +////////////////////////////////////////////////////////////////////////// + +void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) +{ +} + +void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) +{ +} + +void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, + float* xscale, float* yscale) +{ + if (xscale) + *xscale = 1.f; + if (yscale) + *yscale = 1.f; +} + +void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, + int* xpos, int* ypos, + int* width, int* height) +{ + GLFWvidmode mode; + _glfwPlatformGetVideoMode(monitor, &mode); + if (width) + *width = mode.width; + if (height) + *height = mode.height; +} + +GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) +{ + GLFWvidmode* modes = calloc(1, sizeof(GLFWvidmode)); + _glfwPlatformGetVideoMode(monitor, modes); + *found = 1; + return modes; +} + +void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) +{ + mode->width = _glfw.nx.scr_width; + mode->height = _glfw.nx.scr_height; + mode->redBits = 8; + mode->greenBits = 8; + mode->blueBits = 8; + mode->refreshRate = 60; +} + +GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) +{ + return GLFW_FALSE; +} + +void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) +{ +} + diff --git a/src/switch_platform.h b/src/switch_platform.h new file mode 100644 index 00000000..1158b6cf --- /dev/null +++ b/src/switch_platform.h @@ -0,0 +1,99 @@ +//======================================================================== +// GLFW 3.3 - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2016 Google Inc. +// Copyright (c) 2016-2017 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#include + +// Internally rename GLFW OpenGL context management functions +// This is necessary in order to avoid a linker dependency to EGL/mesa when +// GLFW's OpenGL context management functions aren't called by user code +// +#if !defined(_GLFW_SWITCH_NO_CONTEXT_WRAPPER) +#define glfwMakeContextCurrent _glfwMakeContextCurrentImpl +#define glfwGetCurrentContext _glfwGetCurrentContextImpl +#define glfwSwapBuffers _glfwSwapBuffersImpl +#define glfwSwapInterval _glfwSwapIntervalImpl +#define glfwExtensionSupported _glfwExtensionSupportedImpl +#define glfwGetProcAddress _glfwGetProcAddressImpl +#endif + +#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->nx.nwin) +#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY + +#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNX nx +#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNX nx + +#define _GLFW_PLATFORM_CONTEXT_STATE +#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE + +#define _GLFW_OSMESA_CONTEXT_STATE +#define _GLFW_OSMESA_LIBRARY_CONTEXT_STATE + +#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE +#define _GLFW_PLATFORM_MONITOR_STATE +#define _GLFW_PLATFORM_CURSOR_STATE + +#include "egl_context.h" +#include "posix_thread.h" +#include "switch_joystick.h" + +#define _GLFW_SWITCH_EVENT_FOCUS_CHANGED 0x01 +#define _GLFW_SWITCH_EVENT_SCREEN_SIZE_CHANGED 0x02 + +// Switch-specific per-window data +// +typedef struct _GLFWwindowNX +{ + NWindow* nwin; + int width, height; +} _GLFWwindowNX; + +// Switch-specific global data +// +typedef struct _GLFWlibraryNX +{ + _GLFWwindow* cur_window; + int event_mask; + int is_focused; + int scr_width, scr_height; +} _GLFWlibraryNX; + +// Switch-specific context management functions +// +int _glfwPlatformCreateContext(_GLFWwindow* window, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig); +void _glfwPlatformTerminateContextApi(void); + +// Wrapped names of GLFW context management functions +// +GLFWAPI void _glfwMakeContextCurrentImpl(GLFWwindow* handle); +GLFWAPI GLFWwindow* _glfwGetCurrentContextImpl(void); +GLFWAPI void _glfwSwapBuffersImpl(GLFWwindow* handle); +GLFWAPI void _glfwSwapIntervalImpl(int interval); +GLFWAPI int _glfwExtensionSupportedImpl(const char* extension); +GLFWAPI GLFWglproc _glfwGetProcAddressImpl(const char* procname); + diff --git a/src/switch_time.c b/src/switch_time.c new file mode 100644 index 00000000..bd38d67d --- /dev/null +++ b/src/switch_time.c @@ -0,0 +1,44 @@ +//======================================================================== +// GLFW 3.3 POSIX - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2002-2006 Marcus Geelnard +// Copyright (c) 2006-2017 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#include "internal.h" + + +////////////////////////////////////////////////////////////////////////// +////// GLFW platform API ////// +////////////////////////////////////////////////////////////////////////// + +uint64_t _glfwPlatformGetTimerValue(void) +{ + return armGetSystemTick(); +} + +uint64_t _glfwPlatformGetTimerFrequency(void) +{ + return 19200000; // 19.2 MHz +} + diff --git a/src/switch_window.c b/src/switch_window.c new file mode 100644 index 00000000..594a1397 --- /dev/null +++ b/src/switch_window.c @@ -0,0 +1,411 @@ +//======================================================================== +// GLFW 3.3 - www.glfw.org +//------------------------------------------------------------------------ +// Copyright (c) 2016 Google Inc. +// Copyright (c) 2016-2019 Camilla Löwy +// +// This software is provided 'as-is', without any express or implied +// warranty. In no event will the authors be held liable for any damages +// arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software +// in a product, an acknowledgment in the product documentation would +// be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not +// be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source +// distribution. +// +//======================================================================== + +#include "internal.h" + + +#define FB_WIDTH 1920 +#define FB_HEIGHT 1080 + + +static int resizeNativeWindow(_GLFWwindow* window, int width, int height) +{ + if (width > FB_WIDTH) + { + _glfwInputError(GLFW_INVALID_VALUE, "Invalid width (%d > %d)", width, FB_WIDTH); + return GLFW_FALSE; + } + if (height > FB_HEIGHT) + { + _glfwInputError(GLFW_INVALID_VALUE, "Invalid height (%d > %d)", height, FB_HEIGHT); + return GLFW_FALSE; + } + + nwindowSetCrop(window->nx.nwin, 0, FB_HEIGHT-height, width, FB_HEIGHT); + window->nx.width = width; + window->nx.height = height; + + _glfwInputFramebufferSize(window, width, height); + _glfwInputWindowSize(window, width, height); + _glfwInputWindowDamage(window); + + return GLFW_TRUE; +} + +static int createNativeWindow(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig) +{ + window->nx.nwin = nwindowGetDefault(); + nwindowSetDimensions(window->nx.nwin, FB_WIDTH, FB_HEIGHT); + return resizeNativeWindow(window, wndconfig->width, wndconfig->height); +} + +__attribute__ ((weak)) +int _glfwPlatformCreateContext(_GLFWwindow* window, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig) +{ + _glfwInputError(GLFW_API_UNAVAILABLE, "Switch: EGL library not loaded"); + return GLFW_FALSE; +} + + +////////////////////////////////////////////////////////////////////////// +////// GLFW platform API ////// +////////////////////////////////////////////////////////////////////////// + +int _glfwPlatformCreateWindow(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig, + const _GLFWctxconfig* ctxconfig, + const _GLFWfbconfig* fbconfig) +{ + if (_glfw.nx.cur_window) + { + _glfwInputError(GLFW_PLATFORM_ERROR, "Switch: Cannot create more than one window"); + return GLFW_FALSE; + } + + if (!createNativeWindow(window, wndconfig)) + return GLFW_FALSE; + + if (ctxconfig->client != GLFW_NO_API) + { + if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API || + ctxconfig->source == GLFW_EGL_CONTEXT_API) + { + if (!_glfwPlatformCreateContext(window, ctxconfig, fbconfig)) + return GLFW_FALSE; + } + else + { + _glfwInputError(GLFW_API_UNAVAILABLE, "Switch: OSMesa not available"); + return GLFW_FALSE; + } + } + + _glfw.nx.cur_window = window; + return GLFW_TRUE; +} + +void _glfwPlatformDestroyWindow(_GLFWwindow* window) +{ + if (window->context.destroy) + window->context.destroy(window); + _glfw.nx.cur_window = NULL; +} + +void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) +{ +} + +void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count, + const GLFWimage* images) +{ +} + +void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, + _GLFWmonitor* monitor, + int xpos, int ypos, + int width, int height, + int refreshRate) +{ +} + +void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) +{ +} + +void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) +{ +} + +void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) +{ + if (width) + *width = window->nx.width; + if (height) + *height = window->nx.height; +} + +void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) +{ + if (window->resizable) + resizeNativeWindow(window, width, height); +} + +void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, + int minwidth, int minheight, + int maxwidth, int maxheight) +{ +} + +void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d) +{ +} + +void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height) +{ + // Applications rely on framebuffer size == window size; so let's do it that way. + _glfwPlatformGetWindowSize(window, width, height); +} + +void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, + int* left, int* top, + int* right, int* bottom) +{ + _glfwPlatformGetWindowSize(window, right, bottom); +} + +void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, + float* xscale, float* yscale) +{ + if (xscale) + *xscale = 1.f; + if (yscale) + *yscale = 1.f; +} + +void _glfwPlatformIconifyWindow(_GLFWwindow* window) +{ +} + +void _glfwPlatformRestoreWindow(_GLFWwindow* window) +{ +} + +void _glfwPlatformMaximizeWindow(_GLFWwindow* window) +{ +} + +int _glfwPlatformWindowMaximized(_GLFWwindow* window) +{ + return GLFW_FALSE; // "Full screen windows cannot be maximized" +} + +int _glfwPlatformWindowHovered(_GLFWwindow* window) +{ + return _glfw.nx.is_focused; +} + +int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) +{ + return GLFW_FALSE; +} + +void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) +{ +} + +void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) +{ +} + +void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) +{ +} + +float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) +{ + return 1.f; +} + +void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) +{ +} + +void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) +{ +} + +GLFWbool _glfwPlatformRawMouseMotionSupported(void) +{ + return GLFW_FALSE; +} + +void _glfwPlatformShowWindow(_GLFWwindow* window) +{ +} + +void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) +{ +} + +void _glfwPlatformUnhideWindow(_GLFWwindow* window) +{ +} + +void _glfwPlatformHideWindow(_GLFWwindow* window) +{ +} + +void _glfwPlatformFocusWindow(_GLFWwindow* window) +{ +} + +int _glfwPlatformWindowFocused(_GLFWwindow* window) +{ + return GLFW_TRUE; // We always have input focus +} + +int _glfwPlatformWindowIconified(_GLFWwindow* window) +{ + return !_glfw.nx.is_focused; +} + +int _glfwPlatformWindowVisible(_GLFWwindow* window) +{ + return _glfw.nx.is_focused; +} + +void _glfwPlatformPollEvents(void) +{ + u32 msg; + Result res; + + if (!_glfw.nx.cur_window) + return; + + int events; + do + { + res = appletGetMessage(&msg); + if (R_SUCCEEDED(res)) + { + bool should_close = !appletProcessMessage(msg); + if (should_close) + { + _glfwInputWindowCloseRequest(_glfw.nx.cur_window); + return; + } + } + + events = _glfw.nx.event_mask; + _glfw.nx.event_mask = 0; + if (events & _GLFW_SWITCH_EVENT_FOCUS_CHANGED) + { + _glfwInputWindowIconify(_glfw.nx.cur_window, !_glfw.nx.is_focused); + if (_glfw.nx.is_focused) + appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend); + else + appletSetFocusHandlingMode(AppletFocusHandlingMode_SuspendHomeSleepNotify); + } + if (events & _GLFW_SWITCH_EVENT_SCREEN_SIZE_CHANGED) + _glfwPlatformSetWindowSize(_glfw.nx.cur_window, _glfw.nx.scr_width, _glfw.nx.scr_height); + } while (events); + + // Update joysticks + _glfwUpdateSwitchJoysticks(); +} + +void _glfwPlatformWaitEvents(void) +{ + _glfwPlatformPollEvents(); +} + +void _glfwPlatformWaitEventsTimeout(double timeout) +{ + _glfwPlatformPollEvents(); +} + +void _glfwPlatformPostEmptyEvent(void) +{ +} + +void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) +{ +} + +void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) +{ +} + +void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) +{ +} + +int _glfwPlatformCreateCursor(_GLFWcursor* cursor, + const GLFWimage* image, + int xhot, int yhot) +{ + return GLFW_TRUE; +} + +int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) +{ + return GLFW_TRUE; +} + +void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) +{ +} + +void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) +{ +} + +void _glfwPlatformSetClipboardString(const char* string) +{ +} + +const char* _glfwPlatformGetClipboardString(void) +{ + return NULL; +} + +const char* _glfwPlatformGetScancodeName(int scancode) +{ + return ""; +} + +int _glfwPlatformGetKeyScancode(int key) +{ + return -1; +} + +void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) +{ + extensions[0] = "VK_KHR_surface"; + extensions[1] = "VK_NN_vi_surface"; +} + +int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, + VkPhysicalDevice device, + uint32_t queuefamily) +{ + return GLFW_FALSE; +} + +VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, + _GLFWwindow* window, + const VkAllocationCallbacks* allocator, + VkSurfaceKHR* surface) +{ + // TODO: Actually use VK_NN_vi_surface to create a VkSurfaceKHR from a NWindow + // (wishful thinking though - I have no idea when will Vulkan be supported) + return VK_ERROR_INITIALIZATION_FAILED; +} + diff --git a/src/vulkan.c b/src/vulkan.c index 22c54e4a..e186dd03 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -142,6 +142,9 @@ GLFWbool _glfwInitVulkan(int mode) #elif defined(_GLFW_WAYLAND) else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0) _glfw.vk.KHR_wayland_surface = GLFW_TRUE; +#elif defined(_GLFW_SWITCH) + else if (strcmp(ep[i].extensionName, "VK_NN_vi_surface") == 0) + _glfw.vk.NN_vi_surface = GLFW_TRUE; #endif } ================================================ FILE: switch/glm/PKGBUILD ================================================ # Maintainer: fincs pkgname=switch-glm pkgver=0.9.9.7 pkgrel=2 pkgdesc='OpenGL Mathematics (GLM) header only C++ library' arch=('any') url='https://github.com/g-truc/glm' license=(MIT) options=(!strip libtool staticlibs) source=("${url}/releases/download/${pkgver}/glm-${pkgver}.zip") sha256sums=('6b79c3d06d9745d1cce3f38c0c15666596f9aefff25ddb74df3af0a02f011ee1') makedepends=('dkp-toolchain-vars') groups=('switch-portlibs') package() { source $DEVKITPRO/switchvars.sh mkdir -p ${pkgdir}${PORTLIBS_PREFIX}/include cp -r ${srcdir}/glm/glm ${pkgdir}${PORTLIBS_PREFIX}/include/ } ================================================ FILE: switch/glu/LICENSE ================================================ SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice including the dates of first publication and either this permission notice or a reference to http://oss.sgi.com/projects/FreeB/ shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of Silicon Graphics, Inc. shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Silicon Graphics, Inc. ================================================ FILE: switch/glu/PKGBUILD ================================================ # Maintainer: Rhys Koedijk pkgbasename=glu pkgname=switch-$pkgbasename pkgver=9.0.3 pkgrel=1 pkgdesc='SGI implementation of the OpenGL Utility library' arch=('any') url='https://mesa.freedesktop.org/archive/glu/' license=('custom') options=(!strip libtool staticlibs) source=( "${url}/${pkgbasename}-${pkgver}.tar.xz" "glu-9.0.3-meson-enable-egl-arg.patch" "LICENSE" ) depends=('switch-mesa') makedepends=("switch-pkg-config" "dkp-toolchain-vars" "dkp-meson-scripts") groups=('switch-portlibs') prepare() { cd ${pkgbasename}-${pkgver} patch -Np2 -i "${srcdir}/glu-9.0.3-meson-enable-egl-arg.patch" } build() { cd ${pkgbasename}-${pkgver} source /opt/devkitpro/switchvars.sh /opt/devkitpro/meson-cross.sh switch ../crossfile.txt \ -Dgl_provider=egl \ build } package() { cd ${pkgbasename}-${pkgver} DESTDIR="$pkgdir" meson install -C build install -dm755 "$pkgdir"/opt/devkitpro/portlibs/switch/licenses/$pkgname install -m644 "${srcdir}"/LICENSE "$pkgdir"/opt/devkitpro/portlibs/switch/licenses/$pkgname/ } sha256sums=('bd43fe12f374b1192eb15fe20e45ff456b9bc26ab57f0eee919f96ca0f8a330f' '5dccad835d8229d8a10daa87b70fd2fddd193702df23fd47b1934d6721acc52c' '0d27597d42ef0c1ad0e52887de19d3c985608daa60581e9c075c1a978aa5bf40') ================================================ FILE: switch/glu/glu-9.0.3-meson-enable-egl-arg.patch ================================================ --- src/glu-9.0.3/meson_options.txt~ 2024-04-29 09:41:20 +++ src/glu-9.0.3/meson_options.txt 2024-04-29 09:41:27 @@ -4,7 +4,7 @@ option( 'gl_provider', type : 'combo', - choices : ['glvnd', 'gl', 'osmesa'], + choices : ['glvnd', 'gl', 'osmesa', 'egl'], value : 'glvnd', description : 'Which OpenGL to link with' ) ================================================ FILE: switch/harfbuzz/PKGBUILD ================================================ # Maintainer: Mary Strodl pkgname=switch-harfbuzz pkgver=10.0.1 pkgrel=1 pkgdesc='HarfBuzz is a text shaping library. Using the HarfBuzz library allows programs to convert a sequence of Unicode input into properly formatted and positioned glyph output—for any writing system and language.' arch=('any') url='https://harfbuzz.github.io/' license=(LGPL) options=(!strip libtool staticlibs) source=("https://github.com/harfbuzz/harfbuzz/releases/download/$pkgver/harfbuzz-$pkgver.tar.xz") sha256sums=( 'b2cb13bd351904cb9038f907dc0dee0ae07127061242fe3556b2795c4e9748fc' ) makedepends=('dkp-toolchain-vars' 'dkp-meson-scripts') depends=('switch-freetype') groups=('switch-portlibs') build() { cd harfbuzz-${pkgver} /opt/devkitpro/meson-cross.sh switch ../crossfile.txt build \ -Dicu=disabled -Dglib=disabled -Dcairo=disabled -Dgobject=disabled \ -Dtests=disabled -Ddocs=disabled -Dbenchmark=disabled meson compile -C build } package() { cd harfbuzz-${pkgver} DESTDIR="${pkgdir}" meson install -C build rm -fr ${pkgdir}/${PORTLIBS_PREFIX}/share } ================================================ FILE: switch/jansson/.gitignore ================================================ switch-jansson ================================================ FILE: switch/jansson/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Kevoot pkgname=switch-jansson pkgver=2.11 pkgrel=3 pkgdesc='A C library for encoding, decoding and manipulating JSON data.' arch=('any') url='http://www.digip.org/jansson/' license=('custom') options=(!strip libtool staticlibs) makedepends=('dkp-toolchain-vars') source=("http://www.digip.org/jansson/releases/jansson-$pkgver.tar.gz") sha256sums=('6e85f42dabe49a7831dbdd6d30dca8a966956b51a9a50ed534b82afc3fa5b2f4') groups=('switch-portlibs') build() { cd jansson-$pkgver source ${DEVKITPRO}/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { cd jansson-$pkgver source ${DEVKITPRO}/switchvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 LICENSE "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/LICENSE } ================================================ FILE: switch/libarchive/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=switch-libarchive pkgver=3.7.2 pkgrel=7 pkgdesc='library that can create and read several streaming archive formats' arch=('any') url="https://www.libarchive.org" license=('Simplified BSD') options=(!strip libtool staticlibs) source=( "http://www.libarchive.org/downloads/libarchive-${pkgver}.tar.gz" "libarchive-3.7.2.patch" ) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') depends=('switch-bzip2' 'switch-zlib' 'switch-liblzma' 'switch-lz4' 'switch-libexpat' 'switch-libzstd') groups=('switch-portlibs') build() { cd libarchive-$pkgver source /opt/devkitpro/switchvars.sh patch -Np1 -i "$srcdir"/libarchive-${pkgver}.patch aarch64-none-elf-cmake -B _build -S . -GNinja \ -DENABLE_CAT=OFF \ -DENABLE_CPIO=OFF \ -DENABLE_TAR=OFF \ -DENABLE_UNZIP=OFF \ -DENABLE_ZSTD=ON \ -DENABLE_OPENSSL=OFF \ -DENABLE_LIBXML2=OFF \ -DENABLE_ACL=OFF \ -DENABLE_TEST=OFF \ -DBUILD_TESTING=OFF cmake --build _build } package() { cd libarchive-$pkgver source /opt/devkitpro/switchvars.sh DESTDIR="$pkgdir" cmake --install _build # license install -Dm644 "$srcdir"/libarchive-${pkgver}/COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/LICENSE # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share } sha256sums=('df404eb7222cf30b4f8f93828677890a2986b66ff8bf39dac32a804e96ddf104' '975c46e9ce765407fb369ec369a2e7f746801f801238a830a38ec61676929fa3') ================================================ FILE: switch/libarchive/libarchive-3.7.2.patch ================================================ diff --git a/libarchive/archive_read_disk_posix.c b/libarchive/archive_read_disk_posix.c index 8d5c32f0..0b57969d 100644 --- a/libarchive/archive_read_disk_posix.c +++ b/libarchive/archive_read_disk_posix.c @@ -99,8 +99,10 @@ __FBSDID("$FreeBSD$"); #include "archive_read_disk_private.h" #ifndef HAVE_FCHDIR +#ifndef __SWITCH__ #error fchdir function required. #endif +#endif #ifndef O_BINARY #define O_BINARY 0 #endif diff --git a/libarchive/archive_read_support_filter_program.c b/libarchive/archive_read_support_filter_program.c index 885b2c20..83ad505a 100644 --- a/libarchive/archive_read_support_filter_program.c +++ b/libarchive/archive_read_support_filter_program.c @@ -58,6 +58,13 @@ __FBSDID("$FreeBSD$"); #include "archive_read_private.h" #include "filter_fork.h" +#ifdef __SWITCH__ +int +__archive_read_program(struct archive_read_filter *self, const char *cmd) { + return (ARCHIVE_OK); +} +#else + #if ARCHIVE_VERSION_NUMBER < 4000000 /* Deprecated; remove in libarchive 4.0 */ @@ -494,3 +501,6 @@ program_filter_close(struct archive_read_filter *self) return (e); } + +#endif + diff --git a/libarchive/archive_write_set_format_iso9660.c b/libarchive/archive_write_set_format_iso9660.c index 2a3ae07f..b93dadda 100644 --- a/libarchive/archive_write_set_format_iso9660.c +++ b/libarchive/archive_write_set_format_iso9660.c @@ -2178,9 +2178,11 @@ get_system_identitier(char *system_id, size_t size) strncpy(system_id, "Windows", size-1); system_id[size-1] = '\0'; #else +#ifndef __SWITCH__ strncpy(system_id, "Unknown", size-1); system_id[size-1] = '\0'; #endif +#endif } static void @@ -2506,7 +2508,7 @@ get_gmoffset(struct tm *tm) #if defined(HAVE__GET_TIMEZONE) _get_timezone(&offset); -#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) +#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) || defined(__SWITCH__) offset = _timezone; #else offset = timezone; diff --git a/libarchive_fe/passphrase.c b/libarchive_fe/passphrase.c index 1cae6a7b..97014d9e 100644 --- a/libarchive_fe/passphrase.c +++ b/libarchive_fe/passphrase.c @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #ifdef HAVE_UNISTD_H #include #endif + #ifdef HAVE_READPASSPHRASE_H #include #endif @@ -131,9 +132,12 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags) #endif #include #include +#ifndef __SWITCH__ #include +#endif #include +#ifndef __SWITCH__ #ifndef _PATH_TTY #define _PATH_TTY "/dev/tty" #endif @@ -316,9 +320,14 @@ restart: errno = save_errno; return(nr == -1 ? NULL : buf); } +#else +static char* readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags) +{ + return NULL; +} +#endif /* __SWITCH__ */ #endif /* _WIN32 && !__CYGWIN__ */ #endif /* HAVE_READPASSPHRASE */ - char * lafe_readpassphrase(const char *prompt, char *buf, size_t bufsiz) { ================================================ FILE: switch/libass/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: carstene1ns pkgbasename=libass pkgname=switch-$pkgbasename pkgver=0.17.3 pkgrel=1 pkgdesc='A portable subtitle renderer (Nintendo Switch port)' arch=('any') url="https://github.com/libass/libass" license=('custom: ISC') options=(!strip libtool staticlibs) depends=('switch-freetype' 'switch-libfribidi' 'switch-harfbuzz') makedepends=('dkp-toolchain-vars' 'switch-pkg-config') source=("$url/releases/download/$pkgver/$pkgbasename-$pkgver.tar.gz") groups=('switch-portlibs') build() { cd $pkgbasename-$pkgver source /opt/devkitpro/switchvars.sh ./configure --prefix="$PORTLIBS_PREFIX" --host=aarch64-none-elf \ --disable-shared --enable-static \ --enable-asm --enable-large-tiles \ --disable-require-system-font-provider make } package() { cd $pkgbasename-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 "COPYING" "$pkgdir/$PORTLIBS_PREFIX/licenses/$pkgname/COPYING" } sha256sums=('da7c348deb6fa6c24507afab2dee7545ba5dd5bbf90a137bfe9e738f7df68537') ================================================ FILE: switch/libavif/CMakeLists.txt.patch ================================================ --- CMakeLists.txt.orig 2022-04-11 22:55:49.000000000 +0000 +++ CMakeLists.txt 2023-09-11 23:40:47.113419200 +0000 @@ -30,7 +30,7 @@ option(AVIF_ENABLE_WERROR "Treat all compiler warnings as errors" ON) option(AVIF_CODEC_AOM "Use the AOM codec for encoding/decoding (see AVIF_CODEC_AOM_DECODE/AVIF_CODEC_AOM_ENCODE)" OFF) -option(AVIF_CODEC_DAV1D "Use the dav1d codec for decoding" OFF) +option(AVIF_CODEC_DAV1D "Use the dav1d codec for decoding" ON) option(AVIF_CODEC_LIBGAV1 "Use the libgav1 codec for decoding" OFF) option(AVIF_CODEC_RAV1E "Use the rav1e codec for encoding" OFF) option(AVIF_CODEC_SVT "Use the SVT-AV1 codec for encoding" OFF) ================================================ FILE: switch/libavif/PKGBUILD ================================================ # Contributor: Otorhin pkgname=switch-libavif pkgver=1.0.1 pkgrel=2 pkgdesc="Library for encoding and decoding .avif files" arch=('any') url="https://github.com/AOMediaCodec/libavif" license=("zlib") options=(!strip libtool staticlibs) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') depends=( 'switch-dav1d' ) source=("${url}/archive/refs/tags/v${pkgver}.tar.gz" "CMakeLists.txt.patch") sha256sums=('398fe7039ce35db80fe7da8d116035924f2c02ea4a4aa9f4903df6699287599c' 'a08d3a263c49aea9c8ad8a22b5c462f708c1247e1ab67d55466669ea4ecc370e') groups=('switch-portlibs') DEVKITPRO=/opt/devkitpro build() { cd libavif-$pkgver source $DEVKITPRO/switchvars.sh patch -Np1 -i "$srcdir"/CMakeLists.txt.patch CMakeLists.txt aarch64-none-elf-cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX -DCMAKE_C_FLAGS="$CFLAGS $CPPFLAGS" -DCMAKE_AR="$DEVKITPRO/devkitA64/bin/aarch64-none-elf-gcc-ar" . make } package() { cd libavif-$pkgver source $DEVKITPRO/switchvars.sh make DESTDIR="$pkgdir" install # add our static libs echo "Requires.private: dav1d" >> "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/libavif.pc" # License install -Dm644 "LICENSE" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/LICENSE" } ================================================ FILE: switch/libconfig/.gitignore ================================================ switch-libconfig ================================================ FILE: switch/libconfig/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=switch-libconfig pkgver=1.7.2 pkgrel=3 pkgdesc='C/C++ Configuration File Library (for Nintendo Switch homebrew development)' arch=('any') url="https://www.hyperrealm.com/libconfig/libconfig.html" license=('LGPL') options=(!strip libtool staticlibs) source=("https://hyperrealm.github.io/libconfig/dist/libconfig-${pkgver}.tar.gz" "libconfig.patch") makedepends=('switch-pkg-config' 'dkp-toolchain-vars') sha256sums=( '7c3c7a9c73ff3302084386e96f903eb62ce06953bb1666235fac74363a16fad9' '474c17940200d4aa286e486568a0ecaba2130a758f108e2a0b86c6fed5915d1f' ) groups=('switch-portlibs') build() { cd libconfig-$pkgver source /opt/devkitpro/switchvars.sh patch -Np1 -i "$srcdir"/libconfig.patch ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static \ --disable-examples make } package() { cd libconfig-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 COPYING.LIB "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING.LIB # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share } ================================================ FILE: switch/libconfig/libconfig.patch ================================================ diff -Naur libconfig-1.7.2-ori/lib/libconfig.c libconfig-1.7.2-new/lib/libconfig.c --- libconfig-1.7.2-ori/lib/libconfig.c 2017-12-02 19:12:14.000000000 +0100 +++ libconfig-1.7.2-new/lib/libconfig.c 2020-05-24 15:17:00.850073719 +0200 @@ -78,48 +78,12 @@ static void __config_locale_override(void) { -#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ - && ! defined(__MINGW32__) - - _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); - setlocale(LC_NUMERIC, "C"); - -#elif defined(__APPLE__) - - locale_t loc = newlocale(LC_NUMERIC_MASK, "C", NULL); - uselocale(loc); - -#elif ((defined HAVE_NEWLOCALE) && (defined HAVE_USELOCALE)) - - locale_t loc = newlocale(LC_NUMERIC, "C", NULL); - uselocale(loc); - -#else - -#warning "No way to modify calling thread's locale!" - -#endif } /* ------------------------------------------------------------------------- */ static void __config_locale_restore(void) { -#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ - && ! defined(__MINGW32__) - - _configthreadlocale(_DISABLE_PER_THREAD_LOCALE); - -#elif ((defined HAVE_USELOCALE) && (defined HAVE_FREELOCALE)) - - locale_t loc = uselocale(LC_GLOBAL_LOCALE); - freelocale(loc); - -#else - -#warning "No way to modify calling thread's locale!" - -#endif } /* ------------------------------------------------------------------------- */ ================================================ FILE: switch/libdrm_nouveau/PKGBUILD ================================================ # Maintainer: fincs pkgbasename=libdrm_nouveau pkgname=switch-$pkgbasename pkgver=1.0.1 pkgrel=2 pkgdesc="Interface between mesa/nouveau and Nintendo Switch Nvidia GPU driver" arch=('any') license=('MIT') url="http://github.com/devkitPro" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/${pkgbasename}/archive/v${pkgver}/${pkgbasename}-src-${pkgver}.tar.gz) sha256sums=('b069bf8029abb120294bd2dd988dc4d6ce2be3f1016c88c26c73c87b6f312136') makedepends=('devkitA64') groups=('switch-portlibs') build() { make -C $srcdir/$pkgbasename-$pkgver } package() { make -C $srcdir/$pkgbasename-$pkgver DESTDIR=$pkgdir install } ================================================ FILE: switch/libexpat/.gitignore ================================================ switch-libexpat ================================================ FILE: switch/libexpat/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: cpasjuste pkgname=switch-libexpat pkgver=2.2.5 pkgrel=3 pkgdesc='Expat, a stream-oriented XML parser library written in C.' arch=('any') url='https://libexpat.github.io/' license=(MIT/X) options=(!strip libtool staticlibs) source=("https://github.com/libexpat/libexpat/releases/download/R_2_2_5/expat-$pkgver.tar.bz2") sha256sums=('d9dc32efba7e74f788fcc4f212a43216fc37cf5f23f4c2339664d473353aedf6') makedepends=('switch-pkg-config' 'dkp-toolchain-vars') groups=('switch-portlibs') build() { cd expat-$pkgver source /opt/devkitpro/devkita64.sh source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { cd expat-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: switch/libfribidi/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: carstene1ns pkgname=switch-libfribidi pkgver=1.0.12 pkgrel=1 pkgdesc='Free Implementation of the Unicode Bidirectional Algorithm (Nintendo Switch port)' arch=('any') url="https://github.com/fribidi/fribidi" license=('LGPL2.1') options=(!strip staticlibs) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') source=("https://github.com/fribidi/fribidi/releases/download/v$pkgver/fribidi-$pkgver.tar.xz") sha256sums=('0cd233f97fc8c67bb3ac27ce8440def5d3ffacf516765b91c2cc654498293495') groups=('switch-portlibs') prepare() { cd fribidi-$pkgver # patch out binaries, as they conflict with getopt and do not work anyway sed '/^SUBDIRS/ s/bin //' -i Makefile.am ./autogen.sh } build() { cd fribidi-$pkgver source /opt/devkitpro/switchvars.sh ./configure --prefix="$PORTLIBS_PREFIX" --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { cd fribidi-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install # remove documentation rm -fr "$pkgdir"${PORTLIBS_PREFIX}/share } ================================================ FILE: switch/libgd/PKGBUILD ================================================ # Contributor: Nichole Mattera pkgname=switch-libgd pkgver=2.2.5 pkgrel=2 pkgdesc="Library for the dynamic creation of images" url="https://libgd.github.io" license=("custom") arch=("any") depends=("switch-freetype" "switch-bzip2" "switch-libpng" "switch-zlib" "switch-libjpeg-turbo" "switch-libwebp") makedepends=("switch-pkg-config" "dkp-toolchain-vars") options=("!buildflags" "staticlibs" "libtool" "!strip") source=("https://github.com/libgd/libgd/releases/download/gd-$pkgver/libgd-$pkgver.tar.xz" "libgd-2.2.5-nosyslog.patch") sha256sums=("8c302ccbf467faec732f0741a859eef4ecae22fea2d2ab87467be940842bde51" "549027858ef0d2d6dec42232bcc2d66a5966d9f66bfc30518dfd026090a3d2d5") groups=('switch-portlibs') prepare() { patch libgd-$pkgver/src/gd_errors.h < libgd-2.2.5-nosyslog.patch } build() { cd libgd-$pkgver source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf --disable-shared --enable-static make } package() { cd libgd-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install install -Dm644 COPYING "$pkgdir/$PORTLIBS_PREFIX/licenses/$pkgname/COPYING" # These binaries all end up for aarch64, so we shouldn't keep them rm -rf "$pkgdir/$PORTLIBS_PREFIX/bin" } ================================================ FILE: switch/libgd/libgd-2.2.5-nosyslog.patch ================================================ 4,6d3 < #ifndef _WIN32 < # include < #else 24d20 < #endif ================================================ FILE: switch/libjpeg-turbo/.gitignore ================================================ switch-libjpeg-turbo ================================================ FILE: switch/libjpeg-turbo/PKGBUILD ================================================ # Maintainer: WinterMute _libname=libjpeg-turbo pkgname=switch-${_libname} pkgver=2.1.2 pkgrel=2 pkgdesc='libjpeg derivative with accelerated baseline JPEG compression and decompression' arch=('any') url='https://github.com/libjpeg-turbo/libjpeg-turbo' license=('IJG') options=(!strip libtool staticlibs) source=( "${_libname}-${pkgver}.tar.gz::${url}/archive/refs/tags/${pkgver}.tar.gz" "libjpeg-turbo.patch" ) sha256sums=( 'e7fdc8a255c45bc8fbd9aa11c1a49c23092fcd7379296aeaeb14d3343a3d1bed' '79fb3d6acdc9b405a1695a7c6248c420b40e63c115e4a5cab913eb7c2b0c38e4' ) makedepends=('switch-cmake' 'switch-pkg-config' 'dkp-toolchain-vars') groups=('switch-portlibs') build() { cd libjpeg-turbo-$pkgver patch -Np1 -i ${srcdir}/libjpeg-turbo.patch source /opt/devkitpro/switchvars.sh aarch64-none-elf-cmake -DENABLE_SHARED:BOOLEAN=false -DWITH_TURBOJPEG_TESTS:BOOLEAN=false -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX . make } package() { cd libjpeg-turbo-$pkgver make DESTDIR="$pkgdir" install # license install -d "$pkgdir"/opt/devkitpro/portlibs/switch/licenses/$pkgname cp -v LICENSE.md "$pkgdir"/opt/devkitpro/portlibs/switch/licenses/$pkgname/ # remove useless stuff rm -r "$pkgdir"/opt/devkitpro/portlibs/switch/share rm -r "$pkgdir"/opt/devkitpro/portlibs/switch/bin } ================================================ FILE: switch/libjpeg-turbo/libjpeg-turbo.patch ================================================ diff --git a/CMakeLists.txt b/CMakeLists.txt index 639ea570..6032aaed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -207,8 +207,10 @@ option(WITH_MEM_SRCDST "Include in-memory source/destination manager functions w boolean_number(WITH_MEM_SRCDST) option(WITH_SIMD "Include SIMD extensions, if available for this platform" TRUE) boolean_number(WITH_SIMD) -option(WITH_TURBOJPEG "Include the TurboJPEG API library and associated test programs" TRUE) +option(WITH_TURBOJPEG "Include the TurboJPEG API library" TRUE) boolean_number(WITH_TURBOJPEG) +option(WITH_TURBOJPEG_TESTS "Include the TurboJPEG API library test programs" TRUE) +boolean_number(WITH_TURBOJPEG_TESTS) option(WITH_FUZZ "Build fuzz targets" FALSE) macro(report_option var desc) @@ -634,17 +636,19 @@ if(WITH_TURBOJPEG) LINK_FLAGS "${TJMAPFLAG}${TJMAPFILE}") endif() - add_executable(tjunittest tjunittest.c tjutil.c md5/md5.c md5/md5hl.c) - target_link_libraries(tjunittest turbojpeg) + if(WITH_TURBOJPEG_TESTS) + add_executable(tjunittest tjunittest.c tjutil.c md5/md5.c md5/md5hl.c) + target_link_libraries(tjunittest turbojpeg) - add_executable(tjbench tjbench.c tjutil.c) - target_link_libraries(tjbench turbojpeg) - if(UNIX) - target_link_libraries(tjbench m) - endif() + add_executable(tjbench tjbench.c tjutil.c) + target_link_libraries(tjbench turbojpeg) + if(UNIX) + target_link_libraries(tjbench m) + endif() - add_executable(tjexample tjexample.c) - target_link_libraries(tjexample turbojpeg) + add_executable(tjexample tjexample.c) + target_link_libraries(tjexample turbojpeg) + endif() endif() if(ENABLE_STATIC) @@ -657,14 +661,16 @@ if(WITH_TURBOJPEG) set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg) endif() - add_executable(tjunittest-static tjunittest.c tjutil.c md5/md5.c - md5/md5hl.c) - target_link_libraries(tjunittest-static turbojpeg-static) + if(WITH_TURBOJPEG_TESTS) + add_executable(tjunittest-static tjunittest.c tjutil.c md5/md5.c + md5/md5hl.c) + target_link_libraries(tjunittest-static turbojpeg-static) - add_executable(tjbench-static tjbench.c tjutil.c) - target_link_libraries(tjbench-static turbojpeg-static) - if(UNIX) - target_link_libraries(tjbench-static m) + add_executable(tjbench-static tjbench.c tjutil.c) + target_link_libraries(tjbench-static turbojpeg-static) + if(UNIX) + target_link_libraries(tjbench-static m) + endif() endif() endif() endif() @@ -1452,8 +1458,10 @@ if(WITH_TURBOJPEG) else() set(DIR ${CMAKE_CURRENT_BINARY_DIR}) endif() - install(PROGRAMS ${DIR}/tjbench-static${EXE} - DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE}) + if(WITH_TURBOJPEG_TESTS) + install(PROGRAMS ${DIR}/tjbench-static${EXE} + DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE}) + endif() endif() endif() install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg.h ================================================ FILE: switch/libjson-c/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Pablo Curiel pkgname=switch-libjson-c pkgver=0.16 pkgrel=2 pkgdesc='A JSON implementation in C.' arch=('any') url='https://github.com/json-c/json-c/' license=('MIT') options=(!strip libtool staticlibs) source=( "https://s3.amazonaws.com/json-c_releases/releases/json-c-${pkgver}.tar.gz" "json-c-${pkgver}.patch" ) sha256sums=( '8e45ac8f96ec7791eaf3bb7ee50e9c2100bbbc87b8d0f1d030c5ba8a0288d96b' 'fadfd93ee3998fa95726f3f2a1f348711abfe43f2394a505da06dbb9ca721f55' ) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') groups=('switch-portlibs') build() { cd json-c-$pkgver patch -p0 -i ${srcdir}/json-c-${pkgver}.patch source /opt/devkitpro/switchvars.sh aarch64-none-elf-cmake \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DENABLE_THREADING=ON \ -DBUILD_SHARED_LIBS=OFF \ -DBUILD_STATIC_LIBS=ON \ -DCMAKE_BUILD_TYPE=Release \ . make } package() { cd json-c-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: switch/libjson-c/json-c-0.16.patch ================================================ --- CMakeLists.txt.orig 2023-03-06 22:27:27.653258333 +0000 +++ CMakeLists.txt 2023-03-06 22:29:07.183682590 +0000 @@ -105,7 +105,7 @@ option(DISABLE_JSON_POINTER "Disable JSON pointer (RFC6901) support." OFF) -if (UNIX OR MINGW OR CYGWIN) +if (UNIX OR MINGW OR CYGWIN OR NINTENDO_SWITCH) list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) endif() @@ -164,7 +164,7 @@ check_symbol_exists(_isnan "float.h" HAVE_DECL__ISNAN) check_symbol_exists(_finite "float.h" HAVE_DECL__FINITE) -if ((MSVC AND NOT (MSVC_VERSION LESS 1800)) OR MINGW OR CYGWIN OR UNIX) +if ((MSVC AND NOT (MSVC_VERSION LESS 1800)) OR MINGW OR CYGWIN OR UNIX OR NINTENDO_SWITCH) check_symbol_exists(INFINITY "math.h" HAVE_DECL_INFINITY) check_symbol_exists(isinf "math.h" HAVE_DECL_ISINF) check_symbol_exists(isnan "math.h" HAVE_DECL_ISNAN) @@ -172,7 +172,7 @@ endif() check_symbol_exists(_doprnt "stdio.h" HAVE_DOPRNT) -if (UNIX OR MINGW OR CYGWIN) +if (UNIX OR MINGW OR CYGWIN OR NINTENDO_SWITCH) check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF) endif() check_symbol_exists(vasprintf "stdio.h" HAVE_VASPRINTF) ================================================ FILE: switch/liblzma/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: rsn8887 pkgname=switch-liblzma pkgver=5.8.2 pkgrel=1 pkgdesc='A compression library with an API similar to that of zlib' arch=('any') url='https://tukaani.org/xz/' license=('public domain') options=(!strip libtool staticlibs) makedepends=('dkp-toolchain-vars') groups=('switch-portlibs') source=("https://tukaani.org/xz/xz-${pkgver}.tar.gz") build() { cd xz-${pkgver} source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static cd src/liblzma make } package() { cd xz-${pkgver} source /opt/devkitpro/switchvars.sh cd src/liblzma make DESTDIR="${pkgdir}" install } ================================================ FILE: switch/liblzo2/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: rsn8887 pkgname=switch-liblzo2 pkgver=2.10 pkgrel=2 pkgdesc='A real-time data compression library' arch=('any' ) url='https://www.oberhumer.com/opensource/lzo/' license=('GPL v2+') options=(!strip libtool staticlibs) makedepends=('dkp-toolchain-vars') source=("https://www.oberhumer.com/opensource/lzo/download/lzo-${pkgver}.tar.gz") sha256sums=('c0f892943208266f9b6543b3ae308fab6284c5c90e627931446fb49b4221a072') groups=('switch-portlibs') build() { cd lzo-${pkgver} source ${DEVKITPRO}/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { cd lzo-${pkgver} source ${DEVKITPRO}/switchvars.sh make DESTDIR="${pkgdir}" install } ================================================ FILE: switch/libmad/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=switch-libmad pkgver=0.15.1b pkgrel=3 pkgdesc='A high-quality MPEG audio decoder. (for Nintendo 3DS homebrew development)' arch=('any') url='https://www.underbit.com' license=('GPL') options=(!strip libtool staticlibs) source=("https://sourceforge.net/projects/mad/files/libmad/${pkgver}/libmad-${pkgver}.tar.gz") sha256sums=( 'bbfac3ed6bfbc2823d3775ebb931087371e142bb0e9bb1bee51a76a6e0078690' ) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') groups=('switch-portlibs') prepare() { cd ${srcdir}/libmad-${pkgver} sed -i 's,optimize="$optimize -fforce-mem",#optimize="$optimize -fforce-mem",' configure.ac # configury is too old for aarch64-none-elf touch NEWS AUTHORS ChangeLog autoreconf -fi automake --foreign --add-missing --copy --force-missing } build() { cd libmad-$pkgver source ${DEVKITPRO}/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf --disable-shared --enable-static --with-pic=yes make } package() { cd libmad-$pkgver source ${DEVKITPRO}/switchvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: switch/libmikmod/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: carstene1ns pkgname=switch-libmikmod pkgver=3.3.11.1 pkgrel=2 pkgdesc='A portable sound library supporting many tracker formats (Nintendo Switch port)' arch=('any') url="http://mikmod.sourceforge.net/" license=('LGPL') options=(!strip libtool staticlibs) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') source=("https://sourceforge.net/projects/mikmod/files/libmikmod/$pkgver/libmikmod-$pkgver.tar.gz" "libmikmod-switch-support.patch") sha256sums=('ad9d64dfc8f83684876419ea7cd4ff4a41d8bcd8c23ef37ecb3a200a16b46d19' '2d2059ac16713812b4b1f75d6a2106cd6800747d1008497de5711aa424c693ed') groups=('switch-portlibs') prepare() { cd libmikmod-$pkgver patch -Np1 < ../libmikmod-switch-support.patch autoreconf -i } build() { cd libmikmod-$pkgver source /opt/devkitpro/devkita64.sh source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { cd libmikmod-$pkgver source /opt/devkitpro/devkita64.sh source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install rm -fr "$pkgdir"${PORTLIBS_PREFIX}/share } ================================================ FILE: switch/libmikmod/libmikmod-switch-support.patch ================================================ From a996ed8f575be672cbaa2d377ca696a0010b445f Mon Sep 17 00:00:00 2001 From: libjared Date: Sat, 29 Sep 2018 01:24:04 -0500 Subject: [PATCH] Add Nintendo Switch Port --- Makefile.am | 1 + configure.ac | 54 ++++++++- drivers/Makefile.am | 1 + drivers/drv_switch.c | 218 +++++++++++++++++++++++++++++++++++++ include/mikmod.h | 1 + include/mikmod_internals.h | 11 ++ playercode/mdriver.c | 6 + 7 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 drivers/drv_switch.c diff --git a/Makefile.am b/Makefile.am index 44bc0b0..90e76a1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -63,6 +63,7 @@ libmikmod_la_SOURCES = \ drivers/drv_sndio.c \ drivers/drv_stdout.c \ drivers/drv_sun.c \ + drivers/drv_switch.c \ drivers/drv_ultra.c \ drivers/drv_wav.c \ drivers/drv_win.c \ diff --git a/configure.ac b/configure.ac index b5cdbb5..dd77cb4 100644 --- a/configure.ac +++ b/configure.ac @@ -49,6 +49,7 @@ libmikmod_irix=no libmikmod_sun=no libmikmod_aix=no libmikmod_hpux=no +libmikmod_switch=no case $host_os in mingw*) libmikmod_mingw=yes ;; @@ -76,6 +77,11 @@ case $host_os in libmikmod_sun=yes ;; esac +if test $host = aarch64-none-elf +then + libmikmod_switch=yes +fi + # ============================================================== # libmikmod specific control variables and their default values. # ============================================================== @@ -115,6 +121,7 @@ libmikmod_driver_xaudio2=no libmikmod_driver_ultra=no libmikmod_driver_os2=$libmikmod_os2 libmikmod_driver_dart=$libmikmod_os2 +libmikmod_driver_switch=$libmikmod_switch libmikmod_driver_aiff=yes libmikmod_driver_wav=yes libmikmod_driver_raw=yes @@ -173,6 +180,7 @@ then libmikmod_driver_ultra=no libmikmod_driver_os2=no libmikmod_driver_dart=no + libmikmod_driver_switch=no libmikmod_driver_aiff=no libmikmod_driver_wav=no libmikmod_driver_raw=no @@ -309,6 +317,12 @@ case $host_os in *) ;; esac +if test $host = aarch64-none-elf +then + libmikmod_driver_pipe=no + libmikmod_driver_stdout=no +fi + AC_ARG_ENABLE([aiff], [AS_HELP_STRING([--enable-aiff],[include support for output to an aiff file [default=yes]])], [if test "$enableval" = "yes" then @@ -455,6 +469,14 @@ else libmikmod_driver_ultra=no fi]) +AC_ARG_ENABLE([switch], [AS_HELP_STRING([--enable-switch],[include Nintendo Switch driver [default=no]])], +[if test "$enableval" = "yes" +then + libmikmod_driver_switch=$libmikmod_switch +else + libmikmod_driver_switch=no +fi]) + AC_ARG_ENABLE([dl], [AS_HELP_STRING([--enable-dl],[load alsa, esound and ultra drivers at runtime [default=yes]])], [if test "$enableval" = "yes" then @@ -627,7 +649,7 @@ fi # POSIX.4 threads # --------------- -if test $libmikmod_mingw = yes || test $libmikmod_amiga = yes +if test $libmikmod_mingw = yes || test $libmikmod_amiga = yes || test $libmikmod_switch = yes then dnl libmikmod_threads variable is for pthreads only libmikmod_threads=no @@ -928,6 +950,29 @@ then fi fi +# nintendo switch audio +# --------------------- +if test $libmikmod_driver_switch = yes +then + libmikmod_driver_switch=no + ac_save_CPPFLAGS=$CPPFLAGS + ac_save_LDFLAGS=$LDFLAGS + ac_save_LIBS=$LIBS + CPPFLAGS="$CPPFLAGS -isystem${DEVKITPRO}/libnx/include -D__SWITCH__" + LDFLAGS="$LDFLAGS -L${DEVKITPRO}/libnx/lib" + LIBS="$LIBS -lnx" + AC_CHECK_HEADERS([switch.h],[AC_CHECK_LIB([nx],[svcGetSystemTick],[libmikmod_driver_switch=yes])]) + CPPFLAGS=$ac_save_CPPFLAGS + LDFLAGS=$ac_save_LDFLAGS + LIBS=$ac_save_LIBS + if test $libmikmod_driver_switch = yes + then + CPPFLAGS="$CPPFLAGS -isystem${DEVKITPRO}/libnx/include -D__SWITCH__" + LDFLAGS="$LDFLAGS -L${DEVKITPRO}/libnx/lib" + LIBS="$LIBS -lnx" + fi +fi + # ================ # Choose settings. # ================ @@ -1186,6 +1231,13 @@ then fi fi +if test $libmikmod_driver_switch = yes +then + libmikmod_driverlist="switch $libmikmod_driverlist" + AC_DEFINE([DRV_SWITCH], 1, [Define if the Nintendo Switch driver is compiled]) + LIBRARY_LIB="-lnx $LIBRARY_LIB" +fi + if test $libmikmod_debug = yes then AC_DEFINE([MIKMOD_DEBUG], 1, [Define if you want a debug version of the library]) diff --git a/drivers/Makefile.am b/drivers/Makefile.am index fee4fb4..2fe22c3 100644 --- a/drivers/Makefile.am +++ b/drivers/Makefile.am @@ -30,6 +30,7 @@ EXTRA_DIST = CMakeLists.txt \ drv_sndio.c \ drv_stdout.c \ drv_sun.c \ + drv_switch.c \ drv_ultra.c \ drv_wav.c \ drv_win.c \ diff --git a/drivers/drv_switch.c b/drivers/drv_switch.c new file mode 100644 index 0000000..bf4d755 --- /dev/null +++ b/drivers/drv_switch.c @@ -0,0 +1,218 @@ +/* MikMod sound library + (c) 1998-2014 Miodrag Vallat and others - see file AUTHORS for + complete list. + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +/*============================================================================== +==============================================================================*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "mikmod_internals.h" + +#ifdef DRV_SWITCH + +#include +#include +#include + +#define SAMPLERATE 48000 +#define CHANNELCOUNT 2 +#define FRAMERATE (1000 / 30) +#define SAMPLECOUNT (SAMPLERATE / FRAMERATE) * 2 +#define BYTESPERSAMPLE 4 +#define BUFFERSCOUNT 2 + +AudioOutBuffer out_buf[BUFFERSCOUNT]; +u32 data_size = (SAMPLECOUNT * CHANNELCOUNT * BYTESPERSAMPLE); +u32 buffer_size; + +static volatile int audio_ready = 0; +static volatile int audio_terminate = 0; +static volatile int playing = 0; +static volatile u32 current_buffer = 0; +static volatile u32 initial_buffers = 0; + +static void SWITCH_Update(void) { + if (!audio_terminate) { + if (audio_ready) { + // play + if (!initial_buffers) { + AudioOutBuffer *audout_released_buf = NULL; + u32 released_count = 0; + audoutGetReleasedAudioOutBuffer(&audout_released_buf, &released_count); + if (!audout_released_buf) { + return; + } + } else { + initial_buffers--; + } + + // select the next buffer to fill with samples + current_buffer = (current_buffer + 1) % BUFFERSCOUNT; + } + + void *bufptr = out_buf[current_buffer].buffer; + + MUTEX_LOCK(vars); + if (playing) { + // fill + VC_WriteBytes(bufptr, data_size); + } else { + // silence + memset(bufptr, 0, data_size); + } + MUTEX_UNLOCK(vars); + + if (audio_ready) { + audoutAppendAudioOutBuffer(&out_buf[current_buffer]); + } + } +} + +static BOOL SWITCH_IsPresent(void) { + return 1; +} + +static int SWITCH_Init(void) { + Result rc = 0; + + if (VC_Init()) + return 1; + + md_mixfreq = SAMPLERATE; + + audio_terminate = 0; + audio_ready = 0; + + // alignment + buffer_size = (data_size + 0xfff) & ~0xfff; + + for (u32 i = 0; i < BUFFERSCOUNT; i++) { + out_buf[i].buffer = memalign(0x1000, buffer_size); + if (out_buf[i].buffer == NULL) { + printf("Failed to allocate sample data buffers\n"); + return 1; + } + out_buf[i].buffer_size = buffer_size; + out_buf[i].data_size = data_size; + out_buf[i].next = NULL; + out_buf[i].data_offset = 0; + + // clear + memset(out_buf[i].buffer, 0, buffer_size); + } + + // init hardware + rc = audoutInitialize(); + if (R_SUCCEEDED(rc)) + rc = audoutStartAudioOut(); + + if (R_FAILED(rc)) { + _mm_errno = MMERR_OPENING_AUDIO; + printf("Failed to initialize Switch audio hardware\n"); + return 1; + } + + // when starting playback, fill each buffer without waiting + initial_buffers = BUFFERSCOUNT; + current_buffer = 0; + + audio_ready = 1; + return 0; +} + +static void SWITCH_Exit(void) { + audio_ready = 0; + audio_terminate = 1; + + VC_Exit(); + + // deinit hardware + audoutStopAudioOut(); + audoutExit(); + + // cleanup + for (int i = 0; i < BUFFERSCOUNT; i++) { + if (out_buf[i].buffer) { + free(out_buf[i].buffer); + out_buf[i].buffer = NULL; + } + } +} + +static int SWITCH_Reset(void) { + VC_Exit(); + return VC_Init(); +} + +static int SWITCH_PlayStart(void) { + VC_PlayStart(); + playing = 1; + return 0; +} + +static void SWITCH_PlayStop(void) { + playing = 0; + VC_PlayStop(); +} + +MIKMODAPI MDRIVER drv_switch = { + NULL, + "Switch Audio", + "Switch Output Driver v1.1 - by carstene1ns and libjared", + 0, 255, + "switch", + NULL, + NULL, + + SWITCH_IsPresent, + VC_SampleLoad, + VC_SampleUnload, + VC_SampleSpace, + VC_SampleLength, + SWITCH_Init, + SWITCH_Exit, + SWITCH_Reset, + + VC_SetNumVoices, + SWITCH_PlayStart, + SWITCH_PlayStop, + SWITCH_Update, + NULL, + + VC_VoiceSetVolume, + VC_VoiceGetVolume, + VC_VoiceSetFrequency, + VC_VoiceGetFrequency, + VC_VoiceSetPanning, + VC_VoiceGetPanning, + VC_VoicePlay, + VC_VoiceStop, + VC_VoiceStopped, + VC_VoiceGetPosition, + VC_VoiceRealVolume +}; + +#else + +MISSING(drv_switch); + +#endif diff --git a/include/mikmod.h b/include/mikmod.h index 9218529..46b98b6 100644 --- a/include/mikmod.h +++ b/include/mikmod.h @@ -833,6 +833,7 @@ MIKMODAPI extern struct MDRIVER drv_osx; /* MacOS X CoreAudio Driver */ MIKMODAPI extern struct MDRIVER drv_dc; /* Dreamcast driver */ MIKMODAPI extern struct MDRIVER drv_gp32; /* GP32 Sound driver */ MIKMODAPI extern struct MDRIVER drv_psp; /* PlayStation Portable driver */ +MIKMODAPI extern struct MDRIVER drv_switch; /* Nintendo Switch driver */ MIKMODAPI extern struct MDRIVER drv_wss; /* DOS WSS driver */ MIKMODAPI extern struct MDRIVER drv_sb; /* DOS S/B driver */ diff --git a/include/mikmod_internals.h b/include/mikmod_internals.h index 1622a2d..f5e21e9 100644 --- a/include/mikmod_internals.h +++ b/include/mikmod_internals.h @@ -117,6 +117,17 @@ extern MikMod_handler_t _mm_errorhandler; if(_mm_mutex_##name)\ ReleaseMutex(_mm_mutex_##name) +#elif defined(__SWITCH__) +#include +#define DECLARE_MUTEX(name) \ + extern Mutex _mm_mutex_##name +#define MUTEX_LOCK(name) \ + if(_mm_mutex_##name)\ + mutexLock(&_mm_mutex_##name) +#define MUTEX_UNLOCK(name) \ + if(_mm_mutex_##name)\ + mutexUnlock(&_mm_mutex_##name) + #else #define DECLARE_MUTEX(name) \ extern void *_mm_mutex_##name diff --git a/playercode/mdriver.c b/playercode/mdriver.c index b3d3d4a..880e621 100644 --- a/playercode/mdriver.c +++ b/playercode/mdriver.c @@ -835,6 +835,10 @@ MIKMODAPI long MikMod_GetVersion(void) #define INIT_MUTEX(name) \ HANDLE _mm_mutex_##name +#elif defined(__SWITCH__) +#define INIT_MUTEX(name) \ + Mutex _mm_mutex_##name = 0; + #else #define INIT_MUTEX(name) \ void *_mm_mutex_##name = NULL @@ -865,6 +869,8 @@ MIKMODAPI BOOL MikMod_InitThreads(void) result=0; else result=1; +#elif defined(__SWITCH__) + result=1; #endif } return result; -- 2.18.0 ================================================ FILE: switch/libmodplug/.gitignore ================================================ switch-libmodplug ================================================ FILE: switch/libmodplug/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: cpasjuste pkgname=switch-libmodplug pkgver=0.8.9.0 pkgrel=2 pkgdesc='Play various .mod formats' arch=('any') url='http://modplug-xmms.sourceforge.net/' license=(public domain) options=(!strip libtool staticlibs) depends=("switch-zlib") groups=('switch-portlibs') source=( "https://sourceforge.net/projects/modplug-xmms/files/libmodplug/$pkgver/libmodplug-$pkgver.tar.gz" "libmodplug-${pkgver}.patch" ) sha256sums=( '457ca5a6c179656d66c01505c0d95fafaead4329b9dbaa0f997d00a3508ad9de' '0be5de1981997ac11cd4711a3715662d75d7fabb15ff096ea302ebc8378ce9ef' ) build() { cd libmodplug-$pkgver source /opt/devkitpro/devkita64.sh source /opt/devkitpro/switchvars.sh patch -Np1 -i "$srcdir/libmodplug-${pkgver}.patch" ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { cd libmodplug-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: switch/libmodplug/libmodplug-0.8.9.0.patch ================================================ diff -Naur libmodplug-0.8.9.0.old/src/load_abc.cpp libmodplug-0.8.9.0/src/load_abc.cpp --- libmodplug-0.8.9.0.old/src/load_abc.cpp 2020-10-08 22:58:42.530000706 +0200 +++ libmodplug-0.8.9.0/src/load_abc.cpp 2020-10-08 22:59:20.744998238 +0200 @@ -3597,8 +3597,10 @@ mm.mm = (char *)lpStream; mm.sz = dwMemLength; mm.pos = 0; +#ifndef __SWITCH__ while( avoid_reentry ) sleep(1); avoid_reentry = 1; +#endif pat_resetsmp(); pat_init_patnames(); m_nDefaultTempo = 0; diff -Naur libmodplug-0.8.9.0.old/src/load_mid.cpp libmodplug-0.8.9.0/src/load_mid.cpp --- libmodplug-0.8.9.0.old/src/load_mid.cpp 2020-10-08 22:58:42.530000706 +0200 +++ libmodplug-0.8.9.0/src/load_mid.cpp 2020-10-08 22:59:30.568997604 +0200 @@ -1170,8 +1170,10 @@ BYTE midibyte[2]; long metalen, delta; BYTE *p; +#ifndef __SWITCH__ while( avoid_reentry ) sleep(1); avoid_reentry = 1; +#endif if( !TestMID(lpStream, dwMemLength) ) { avoid_reentry = 0; return FALSE; diff -Naur libmodplug-0.8.9.0.old/src/load_pat.cpp libmodplug-0.8.9.0/src/load_pat.cpp --- libmodplug-0.8.9.0.old/src/load_pat.cpp 2020-10-08 22:58:42.531000706 +0200 +++ libmodplug-0.8.9.0/src/load_pat.cpp 2020-10-08 22:59:26.472997869 +0200 @@ -1149,8 +1149,10 @@ mm.sz = dwMemLength; mm.pos = 0; mm.error = 0; +#ifndef __SWITCH__ while( avoid_reentry ) sleep(1); avoid_reentry = 1; +#endif pat_read_patname(h, mmfile); h->samples = pat_read_numsmp(mmfile); if( strlen(h->patname) ) ================================================ FILE: switch/libmpeg2/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Matthieu Milan pkgname=switch-libmpeg2 pkgver=0.5.1 pkgrel=1 pkgdesc='A free MPEG-2 video stream decoder' arch=('any') url='http://libmpeg2.sourceforge.net/' license=('GPL') options=(!strip libtool staticlibs) source=("http://libmpeg2.sourceforge.net/files/libmpeg2-${pkgver}.tar.gz") sha256sums=('dee22e893cb5fc2b2b6ebd60b88478ab8556cb3b93f9a0d7ce8f3b61851871d4') makedepends=('switch-pkg-config' 'dkp-toolchain-vars') groups=('switch-portlibs') prepare() { cd libmpeg2-$pkgver sed '/AC_PATH_XTRA/d' -i configure.ac autoreconf --force --install } build() { cd libmpeg2-$pkgver source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static --disable-sdl make } package() { cd libmpeg2-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: switch/libmpv/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Cpasjuste # Contributor: averne pkgbasename=libmpv pkgname=switch-${pkgbasename} pkgver=0.39.0 pkgrel=4 pkgdesc='Command line video player (library only)' arch=('any') url='https://mpv.io/' license=('GPL') options=(!strip libtool staticlibs) source=("${pkgbasename}-${pkgver}.tar.gz::https://github.com/mpv-player/mpv/archive/v${pkgver}.tar.gz" "mpv.patch") sha256sums=( '2ca92437affb62c2b559b4419ea4785c70d023590500e8a52e95ea3ab4554683' '092795383fee49a97053444c46a527a7ba79df8a5533c25bcdbde93fee2656e1' ) makedepends=("dkp-toolchain-vars" "dkp-meson-scripts") depends=('switch-sdl2' 'switch-ffmpeg' 'switch-mesa' 'switch-libarchive' 'switch-libplacebo') groups=('switch-portlibs') prepare() { cd mpv-$pkgver patch -Np1 -i "$srcdir/mpv.patch" } build() { cd mpv-$pkgver /opt/devkitpro/meson-cross.sh switch ../crossfile.txt build \ -Dlibmpv=true -Dcplayer=false -Dtests=false -Dplain-gl=enabled -Dlua=disabled \ -Dsdl2=enabled -Dsdl2-gamepad=enabled -Dsdl2-audio=enabled -Dsdl2-video=enabled \ -Diconv=disabled meson compile -C build } package() { cd mpv-$pkgver DESTDIR="$pkgdir" meson install -C build } ================================================ FILE: switch/libmpv/mpv.patch ================================================ diff --git a/audio/out/ao.c b/audio/out/ao.c index ee20b736a3..11fa28929f 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -54,6 +54,7 @@ extern const struct ao_driver audio_out_wasapi; extern const struct ao_driver audio_out_pcm; extern const struct ao_driver audio_out_lavc; extern const struct ao_driver audio_out_sdl; +extern const struct ao_driver audio_out_hos; static const struct ao_driver * const audio_out_drivers[] = { // native: @@ -99,6 +100,9 @@ static const struct ao_driver * const audio_out_drivers[] = { #endif #if HAVE_SNDIO &audio_out_sndio, +#endif +#if HAVE_HOS_AUDIO + &audio_out_hos, #endif &audio_out_null, #if HAVE_COREAUDIO diff --git a/audio/out/ao_hos.c b/audio/out/ao_hos.c new file mode 100644 index 0000000000..83bd03de7d --- /dev/null +++ b/audio/out/ao_hos.c @@ -0,0 +1,298 @@ +/* + * audio output driver for Horizon OS using audren + * Copyright (c) 2024 averne + * + * This file is part of mpv. + * + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * mpv is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see . + */ + +#include + +#include "config.h" +#include "common/common.h" +#include "common/msg.h" +#include "options/m_option.h" +#include "audio/format.h" +#include "ao.h" +#include "internal.h" + +#define MAX_CHANS 6 // 5.1 +#define MAX_BUF 16 +#define MAX_SAMPLES 32768 + +struct priv { + AudioDriver driver; + int num_buffers; + int num_samples; + + void *pool; + AudioDriverWaveBuf *buffers; + + int cur_buf_idx; + uint32_t cur_queued_samples, total_queued_samples; +}; + +static const AudioRendererConfig ar_config = { + .output_rate = AudioRendererOutputRate_48kHz, + .num_voices = MAX_CHANS, + .num_effects = 0, + .num_sinks = 1, + .num_mix_objs = 1, + .num_mix_buffers = MAX_CHANS, +}; + +static const uint8_t sink_channel_ids[] = { 0, 1, 2, 3, 4, 5 }; + +static const struct mp_chmap possible_channel_layouts[] = { + {0}, + MP_CHMAP_INIT_MONO, // mono + MP_CHMAP_INIT_STEREO, // stereo + MP_CHMAP3(FL, FR, LFE), // 2.1 + MP_CHMAP4(FL, FR, BL, BR), // 4.0 + MP_CHMAP5(FL, FR, FC, BL, BR), // 5.0 + MP_CHMAP6(FL, FR, FC, LFE, BL, BR), // 5.1 +}; + +static int init(struct ao *ao) { + struct priv *priv = ao->priv; + + Result rc; + + MP_VERBOSE(ao, "Initializing hos audio\n"); + + ao->format = AF_FORMAT_S16; // Only format supported by audrv with Adpcm which mpv can't output + ao->channels = possible_channel_layouts[MPMIN(ao->channels.num, MAX_CHANS)]; + + rc = audrenInitialize(&ar_config); + if (R_FAILED(rc)) + return -rc; + + rc = audrvCreate(&priv->driver, &ar_config, MAX_CHANS); + if (R_FAILED(rc)) + return -rc; + + size_t mempool_size = MP_ALIGN_UP(priv->num_samples * ao->channels.num * + priv->num_buffers * sizeof(int16_t), AUDREN_MEMPOOL_ALIGNMENT); + + priv->pool = aligned_alloc(AUDREN_MEMPOOL_ALIGNMENT, mempool_size); + if (!priv->pool) + return -1; + + priv->buffers = talloc_array(priv, AudioDriverWaveBuf, priv->num_buffers); + for (int i = 0; i < priv->num_buffers; ++i) { + priv->buffers[i] = (AudioDriverWaveBuf){ + .data_raw = priv->pool, + .size = mempool_size, + .start_sample_offset = priv->num_samples * i, + .end_sample_offset = priv->num_samples * (i + 1), + }; + } + + int mpid = audrvMemPoolAdd(&priv->driver, priv->pool, mempool_size); + audrvMemPoolAttach(&priv->driver, mpid); + + ao->device_buffer = priv->num_buffers * priv->num_samples; + + audrvDeviceSinkAdd(&priv->driver, AUDREN_DEFAULT_DEVICE_NAME, MAX_CHANS, sink_channel_ids); + + rc = audrenStartAudioRenderer(); + if (R_FAILED(rc)) + return -rc; + + audrvVoiceInit(&priv->driver, 0, ao->channels.num, PcmFormat_Int16, ao->samplerate); + audrvVoiceSetDestinationMix(&priv->driver, 0, AUDREN_FINAL_MIX_ID); + + for (int i = 0; i < ao->channels.num; ++i) + audrvVoiceSetMixFactor(&priv->driver, 0, 1.0f, ao->channels.speaker[i], ao->channels.speaker[i]); + + return 0; +} + +static void uninit(struct ao *ao) { + struct priv *priv = ao->priv; + + MP_VERBOSE(ao, "Deinitializing hos audio\n"); + + audrvVoiceStop(&priv->driver, 0); + audrvUpdate(&priv->driver); + + audrvClose(&priv->driver); + audrenExit(); + + free(priv->pool); +} + +static void reset(struct ao *ao) { + struct priv *priv = ao->priv; + + priv->cur_buf_idx = -1; + priv->cur_queued_samples = priv->total_queued_samples = 0; + audrvVoiceStop(&priv->driver, 0); + audrvUpdate(&priv->driver); +} + +static bool set_pause(struct ao *ao, bool paused) { + struct priv *priv = ao->priv; + + audrvVoiceSetPaused(&priv->driver, 0, paused); + return R_SUCCEEDED(audrvUpdate(&priv->driver)); +} + +static void start(struct ao *ao) { + struct priv *priv = ao->priv; + + audrvVoiceStart(&priv->driver, 0); + audrvUpdate(&priv->driver); +} + +static int find_free_wavebuf(struct priv *priv) { + for (int i = 0; i < priv->num_buffers; ++i) { + AudioDriverWaveBuf *buf = &priv->buffers[i]; + if (buf->state == AudioDriverWaveBufState_Done || + buf->state == AudioDriverWaveBufState_Free) + return i; + } + return -1; +} + +static bool audio_write(struct ao *ao, void **data, int samples) { + struct priv *priv = ao->priv; + + // We requested a linear format so there is only one buffer + uint8_t *dat = data[0]; + + while (samples) { + int idx = (priv->cur_buf_idx != -1) ? priv->cur_buf_idx : find_free_wavebuf(priv); + if (idx == -1) + return false; + priv->cur_buf_idx = idx; + + AudioDriverWaveBuf *buf = &priv->buffers[idx]; + uint8_t *buf_offset = (uint8_t *)buf->data_raw + (idx * priv->num_samples * ao->sstride); + + size_t num_samples = MPMIN(samples, priv->num_samples - priv->cur_queued_samples); + + memcpy(buf_offset + priv->cur_queued_samples * ao->sstride, dat, num_samples * ao->sstride); + priv->cur_queued_samples += num_samples; + priv->total_queued_samples += num_samples; + + dat += num_samples * ao->sstride; + samples -= num_samples; + + // Append buffer once it's full + if (priv->cur_queued_samples >= priv->num_samples) { + armDCacheFlush(buf_offset, priv->num_samples * ao->sstride); + audrvVoiceAddWaveBuf(&priv->driver, 0, buf); + audrvUpdate(&priv->driver); + + priv->cur_buf_idx = -1, priv->cur_queued_samples = 0; + } + } + + return true; +} + +static void get_state(struct ao *ao, struct mp_pcm_state *state) { + struct priv *priv = ao->priv; + + Result rc = audrvUpdate(&priv->driver); + if (R_FAILED(rc)) + return; + + state->free_samples = state->queued_samples = 0; + for (int i = 0; i < priv->num_buffers; ++i) { + AudioDriverWaveBuf *buf = &priv->buffers[i]; + if (buf->state == AudioDriverWaveBufState_Free + || buf->state == AudioDriverWaveBufState_Done) + state->free_samples += priv->num_samples; + } + + if (priv->cur_buf_idx != -1) + state->free_samples -= priv->num_samples - priv->cur_queued_samples; + + state->queued_samples = priv->total_queued_samples - + audrvVoiceGetPlayedSampleCount(&priv->driver, 0); + + state->delay = (double)state->queued_samples / ao->samplerate; + + state->playing = audrvVoiceIsPlaying(&priv->driver, 0); +} + +static int control(struct ao *ao, enum aocontrol cmd, void *arg) { + struct priv *priv = ao->priv; + + int rc; + + switch (cmd) { + case AOCONTROL_SET_MUTE: + case AOCONTROL_SET_VOLUME: { + float vol; + if (cmd == AOCONTROL_SET_MUTE) { + bool in = *(bool *)arg; + vol = !in; + } else { + float *in = arg; + vol = *in / 100.0f; + } + + audrvMixSetVolume(&priv->driver, 0, vol); + rc = audrvUpdate(&priv->driver); + } + break; + case AOCONTROL_GET_MUTE: + case AOCONTROL_GET_VOLUME: { + rc = audrvUpdate(&priv->driver); + float vol = priv->driver.in_mixes[0].volume; + if (cmd == AOCONTROL_GET_MUTE) { + bool *out = (bool *)arg; + *out = !vol; + } else { + float *out = arg; + *out = vol * 100.0f; + } + } + break; + default: + return CONTROL_UNKNOWN; + } + + return R_SUCCEEDED(rc) ? CONTROL_OK : CONTROL_ERROR; +} + +#define OPT_BASE_STRUCT struct priv + +const struct ao_driver audio_out_hos = { + .description = "HOS Audio", + .name = "hos", + .init = init, + .uninit = uninit, + .reset = reset, + .control = control, + .set_pause = set_pause, + .start = start, + .write = audio_write, + .get_state = get_state, + .priv_size = sizeof(struct priv), + .priv_defaults = &(const struct priv){ + .num_buffers = 4, + .num_samples = 8192, + }, + .options = (const struct m_option[]){ + {"num-buffers", OPT_INT(num_buffers), M_RANGE(2, MAX_BUF)}, + {"num-samples", OPT_INT(num_samples), M_RANGE(256, MAX_SAMPLES)}, + {0} + }, + .options_prefix = "ao-hos", +}; diff --git a/common/common.h b/common/common.h index 7466ea2d61..a14d2084c6 100644 --- a/common/common.h +++ b/common/common.h @@ -26,7 +26,7 @@ #include "config.h" -#if HAVE_POSIX || defined(__MINGW32__) +#if HAVE_POSIX || defined(__MINGW32__) || defined(__SWITCH__) #include #include #endif diff --git a/meson.build b/meson.build index b7bcb1b0ba..266fbbb75d 100644 --- a/meson.build +++ b/meson.build @@ -301,7 +301,8 @@ endif darwin = host_machine.system() == 'darwin' win32 = host_machine.system() == 'cygwin' or host_machine.system() == 'windows' -posix = not win32 +hos = host_machine.system() == 'horizon' +posix = not (win32 or hos) features += {'darwin': darwin} features += {'posix': posix} @@ -322,7 +323,7 @@ if host_machine.system() == 'cygwin' flags += [mswin_flags, '-mwin32'] endif -if posix +if posix or hos flags += ['-D_GNU_SOURCE'] endif @@ -347,6 +348,8 @@ if features['libdl'] dependencies += libdl endif +libnx = cc.find_library('nx', required: false) + # C11 atomics are mandatory but linking to the library is not always required. dependencies += cc.find_library('atomic', required: false) @@ -407,6 +410,17 @@ if features['cocoa'] main_fn_source = files('osdep/main-fn-mac.c') endif +if hos + path_source = files('osdep/path-unix.c') + timer_source = files('osdep/timer-linux.c') + sources += files('osdep/subprocess-dummy.c', + 'osdep/terminal-dummy.c', + 'osdep/main-fn-unix.c', + 'osdep/language-posix.c', + 'input/ipc-dummy.c', + 'sub/filter_regex.c') +endif + if posix path_source = files('osdep/path-unix.c') if cc.has_function('fork', prefix : '#include ') @@ -895,6 +909,12 @@ if features['sdl2-audio'] sources += files('audio/out/ao_sdl.c') endif +features += {'hos-audio': hos and libnx.found()} +if features['hos-audio'] + sources += files('audio/out/ao_hos.c') + dependencies += libnx +endif + sndio = dependency('sndio', required: get_option('sndio')) features += {'sndio': sndio.found()} features += {'sndio-1-9': sndio.version().version_compare('>= 1.9.0')} diff --git a/osdep/io.c b/osdep/io.c index 6c3c8b7c36..75ebae4128 100644 --- a/osdep/io.c +++ b/osdep/io.c @@ -62,7 +62,7 @@ bool mp_set_cloexec(int fd) return true; } -#ifdef _WIN32 +#if defined(__MINGW32__) || defined(__SWITCH__) int mp_make_cloexec_pipe(int pipes[2]) { pipes[0] = pipes[1] = -1; diff --git a/osdep/io.h b/osdep/io.h index 722413456d..9356ee4724 100644 --- a/osdep/io.h +++ b/osdep/io.h @@ -242,7 +242,7 @@ void freelocale(locale_t); #else /* __MINGW32__ */ -#include +#include "switch/sys/mman.h" extern char **environ; diff --git a/osdep/switch/sys/mman.h b/osdep/switch/sys/mman.h new file mode 100644 index 0000000000..398ff01729 --- /dev/null +++ b/osdep/switch/sys/mman.h @@ -0,0 +1,15 @@ +#ifndef _MEMMAP_H_ +#define _MEMMAP_H_ + +#include +#include + +#define PROT_READ 0x1 +#define PROT_WRITE 0x2 +#define MAP_SHARED 0x01 +#define MAP_FAILED ((void *) -1) + +#define mmap(a, b, c, d, e, f) malloc(b) +#define munmap(a, b) free(a) + +#endif diff --git a/osdep/terminal-dummy.c b/osdep/terminal-dummy.c index a2cfe741a8..5a01e5b7d1 100644 --- a/osdep/terminal-dummy.c +++ b/osdep/terminal-dummy.c @@ -42,3 +42,7 @@ bool terminal_try_attach(void) { return false; } + +void terminal_set_mouse_input(bool enable) +{ +} diff --git a/player/lua/stats.lua b/player/lua/stats.lua index 8b8913fc45..7e904f2cc0 100644 --- a/player/lua/stats.lua +++ b/player/lua/stats.lua @@ -52,7 +52,7 @@ local o = { plot_bg_border_width = 0.5, -- Text style - font = "", + font = "nintendo_udsg-r_std_003", font_mono = "monospace", -- monospaced digits are sufficient font_size = 8, font_color = "", diff --git a/sub/filter_regex.c b/sub/filter_regex.c index 1d29ea1ac1..3218e12be5 100644 --- a/sub/filter_regex.c +++ b/sub/filter_regex.c @@ -1,5 +1,5 @@ -#include #include +#include #include "common/common.h" #include "common/msg.h" diff --git a/sub/osd.c b/sub/osd.c index 6a57574a52..83294f3139 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -80,7 +80,7 @@ const struct m_sub_options osd_style_conf = { .opts = style_opts, .size = sizeof(struct osd_style_opts), .defaults = &(const struct osd_style_opts){ - .font = "sans-serif", + .font = "nintendo_udsg-r_std_003", .font_size = 55, .color = {255, 255, 255, 255}, .outline_color = {0, 0, 0, 255}, @@ -100,7 +100,7 @@ const struct m_sub_options sub_style_conf = { .opts = style_opts, .size = sizeof(struct osd_style_opts), .defaults = &(const struct osd_style_opts){ - .font = "sans-serif", + .font = "nintendo_udsg-r_std_003", .font_size = 55, .color = {255, 255, 255, 255}, .outline_color = {0, 0, 0, 255}, diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 47b3109ec7..f133298aea 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -21,6 +21,10 @@ #include #include +#ifdef __SWITCH__ +#include +#endif + #include #include @@ -206,6 +210,18 @@ static void enable_output(struct sd *sd, bool enable) } else { ctx->ass_renderer = ass_renderer_init(ctx->ass_library); +#ifdef __SWITCH__ + if (R_SUCCEEDED(plInitialize(PlServiceType_User))) { + PlFontData font; + Result rc = plGetSharedFontByType(&font, PlSharedFontType_Standard); + if (R_SUCCEEDED(rc)) + ass_add_font(ctx->ass_library, "nintendo_udsg-r_std_003", font.address, font.size); + else + MP_ERR(sd, "Failed to add font from pl: %#x\n", rc); + plExit(); + } +#endif + mp_ass_configure_fonts(ctx->ass_renderer, sd->opts->sub_style, sd->global, sd->log); } diff --git a/video/mp_image.c b/video/mp_image.c index b809dae765..0a9cace6db 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -175,7 +175,7 @@ static bool mp_image_alloc_planes(struct mp_image *mpi) return false; // Note: mp_image_pool assumes this creates only 1 AVBufferRef. - mpi->bufs[0] = av_buffer_alloc(size + align); + mpi->bufs[0] = av_buffer_aligned_alloc(size + align, 0x100); // Alignment required for plane offsets if (!mpi->bufs[0]) return false; diff --git a/video/mp_image.h b/video/mp_image.h index 2208deb26d..751fccfaf7 100644 --- a/video/mp_image.h +++ b/video/mp_image.h @@ -32,7 +32,7 @@ // libraries except libavcodec don't really know what alignment they want. // Things will randomly crash or get slower if the alignment is not satisfied. // Whatever. This value should be pretty safe with current CPU architectures. -#define MP_IMAGE_BYTE_ALIGN 64 +#define MP_IMAGE_BYTE_ALIGN 256 // VIC alignement #define MP_IMGFIELD_TOP_FIRST 0x02 #define MP_IMGFIELD_REPEAT_FIRST 0x04 ================================================ FILE: switch/libogg/.gitignore ================================================ switch-ogg ================================================ FILE: switch/libogg/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: cpasjuste pkgname=switch-libogg pkgver=1.3.4 pkgrel=2 pkgdesc='The Ogg transport bitstream is designed to provide framing, error protection and seeking structure for higher-level codec streams that consist of raw, unencapsulated data packets, such as the Opus, Vorbis and FLAC audio codecs or the Theora and Dirac video codecs.' arch=('any') url='https://wiki.xiph.org/Ogg' license=(Xiph.org) options=(!strip libtool staticlibs) source=("https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-$pkgver.tar.gz") sha256sums=('fe5670640bd49e828d64d2879c31cb4dde9758681bb664f9bdbf159a01b0c76e') makedepends=('switch-pkg-config' 'dkp-toolchain-vars') groups=('switch-portlibs') build() { cd libogg-$pkgver source /opt/devkitpro/devkita64.sh source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { cd libogg-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: switch/libopus/PKGBUILD ================================================ pkgname=switch-libopus pkgver=1.3 pkgrel=2 pkgdesc='Reference implementation of the lossy audio codec' arch=('any') url='https://opus-codec.org/' license=(BSD) options=(!strip libtool staticlibs) source=("https://archive.mozilla.org/pub/opus/opus-$pkgver.tar.gz") sha256sums=('4f3d69aefdf2dbaf9825408e452a8a414ffc60494c70633560700398820dc550') makedepends=('switch-pkg-config' 'dkp-toolchain-vars') groups=('switch-portlibs') build() { cd opus-$pkgver source /opt/devkitpro/switchvars.sh ./configure \ --prefix="${PORTLIBS_PREFIX}" \ --host="aarch64-none-elf" \ --disable-shared --enable-static make } package() { cd opus-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: switch/libpcre2/PKGBUILD ================================================ # Maintainer: Ezekiel Bethel pkgname=switch-libpcre2 pkgver=10.33 pkgrel=1 pkgdesc='libpcre2 port (for Nintendo Switch homebrew development)' arch=('any') url='https://www.pcre.org/' license=('BSD') options=(!strip libtool staticlibs) depends=() source=("https://ftp.pcre.org/pub/pcre/pcre2-${pkgver}.tar.gz" ) groups=('switch-portlibs') sha256sums=('e2e2899a97489fc6ad1b0cc3da7952c7cca991b4a0f7db6649b75d9721025d31') build() { cd pcre2-$pkgver source ${DEVKITPRO}/switchvars.sh # Disable building programs & tests. sed -i 's/^bin_PROGRAMS = .*//' Makefile.in sed -i 's/^TESTS = .*//' Makefile.in sed -i 's/^noinst_PROGRAMS = .*//' Makefile.in ./configure --prefix=$PORTLIBS_PREFIX --host=aarch64-none-elf \ --disable-shared --enable-static --enable-pcre2-16 --enable-pcre2-32 make } package() { cd pcre2-$pkgver source ${DEVKITPRO}/switchvars.sh make DESTDIR="$pkgdir" install # Delete the docs rm -r $pkgdir/$PORTLIBS_PREFIX/share/ } ================================================ FILE: switch/libplacebo/PKGBUILD ================================================ pkgbasename=libplacebo pkgname=switch-${pkgbasename} pkgver=6.338.2 vulkanver=1.3.283 pkgrel=1 pkgdesc="Reusable library for GPU-accelerated video/image rendering primitives" arch=('any') url="https://code.videolan.org/videolan/libplacebo" license=('LGPL2.1') options=(!strip libtool staticlibs) source=( "${url}/-/archive/v${pkgver}/${pkgbasename}-v${pkgver}.tar.gz" "vulkan-headers-${vulkanver}.tar.gz::https://github.com/KhronosGroup/Vulkan-Headers/archive/v${vulkanver}.tar.gz" ) groups=('switch-portlibs') makedepends=("dkp-toolchain-vars" "dkp-meson-scripts") build() { cd ${srcdir}/${pkgbasename}-v${pkgver} cp -r ${srcdir}/Vulkan-Headers-${vulkanver}/include/* src/include /opt/devkitpro/meson-cross.sh switch ../crossfile.txt \ -Dopengl=disabled -Dgl-proc-addr=disabled \ -Dd3d11=disabled -Dglslang=disabled -Dshaderc=disabled \ -Ddovi=disabled -Dlibdovi=disabled \ -Dlcms=disabled -Dvulkan=disabled \ -Ddemos=false -Dtests=false build meson compile -C build } package() { cd ${srcdir}/${pkgbasename}-v${pkgver} DESTDIR="$pkgdir" meson install -C build } sha256sums=('d029adbe55bba8aed7aed2c48b0b66081dddfb9d42683a709342e33aa666c544' 'a76ff77815012c76abc9811215c2167128a73a697bcc23948e858d1f7dd54a85') ================================================ FILE: switch/libpng/.gitignore ================================================ switch-libpng ================================================ FILE: switch/libpng/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: carstene1ns - http://git.io/ctPKG # Contributor: Aaron Lindsay pkgname=switch-libpng pkgver=1.6.48 pkgrel=1 pkgdesc='PNG format graphic files library' arch=('any') url='http://www.libpng.org' license=('custom') options=(!strip libtool staticlibs) depends=('switch-zlib') groups=('switch-portlibs') makedepends=('switch-pkg-config' 'dkp-toolchain-vars') source=("https://download.sourceforge.net/libpng/libpng-$pkgver.tar.xz") build() { cd libpng-$pkgver source /opt/devkitpro/switchvars.sh ./configure --prefix="$DEVKITPRO/portlibs/switch" --host=aarch64-none-elf \ --disable-tools --disable-shared --enable-static } package() { cd libpng-$pkgver make LN_S=cp DESTDIR="$pkgdir" install # license install -Dm644 LICENSE "$pkgdir"/opt/devkitpro/portlibs/switch/licenses/$pkgname/LICENSE # remove useless stuff rm -r "$pkgdir"/opt/devkitpro/portlibs/switch/share } sha256sums=('46fd06ff37db1db64c0dc288d78a3f5efd23ad9ac41561193f983e20937ece03') ================================================ FILE: switch/libsamplerate/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=switch-libsamplerate pkgver=0.1.9 pkgrel=2 pkgdesc='Secret Rabbit Code (aka libsamplerate) is a Sample Rate Converter for audio (for Nintendo Switch homebrew development)' arch=('any') url="http://www.mega-nerd.com/libsamplerate" license=('BSD') options=(!strip libtool staticlibs) source=( "http://www.mega-nerd.com/libsamplerate/libsamplerate-${pkgver}.tar.gz" "libsamplerate-${pkgver}.patch" ) sha256sums=( '0a7eb168e2f21353fb6d84da152e4512126f7dc48ccb0be80578c565413444c1' 'e11521959e926907ffbceff2abd4c509bab2e8d777575effc05dab41264e967c' ) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') groups=('switch-portlibs') build() { cd libsamplerate-$pkgver patch -Np1 -i "$srcdir/libsamplerate-${pkgver}.patch" autoreconf -i source /opt/devkitpro/devkita64.sh source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { cd libsamplerate-$pkgver source /opt/devkitpro/devkita64.sh source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING } ================================================ FILE: switch/libsamplerate/libsamplerate-0.1.9.patch ================================================ diff -Naur libsamplerate-0.1.9.old/Cfg/config.guess libsamplerate-0.1.9/Cfg/config.guess --- libsamplerate-0.1.9.old/Cfg/config.guess 2010-03-16 14:26:14.000000000 +0000 +++ libsamplerate-0.1.9/Cfg/config.guess 2018-03-29 14:12:37.655650012 +0100 @@ -1,14 +1,12 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 -# Free Software Foundation, Inc. +# Copyright 1992-2014 Free Software Foundation, Inc. -timestamp='2009-04-27' +timestamp='2014-03-23' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -17,26 +15,22 @@ # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner. # -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. +# Please send patches with a ChangeLog entry to config-patches@gnu.org. + me=`echo "$0" | sed -e 's,.*/,,'` @@ -56,8 +50,7 @@ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -139,12 +132,33 @@ UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + ;; +esac + # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward @@ -170,7 +184,7 @@ arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null + | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? @@ -180,7 +194,7 @@ fi ;; *) - os=netbsd + os=netbsd ;; esac # The OS release @@ -201,6 +215,10 @@ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} @@ -223,7 +241,7 @@ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on @@ -269,7 +287,10 @@ # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit ;; + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead @@ -295,12 +316,12 @@ echo s390-ibm-zvmoe exit ;; *:OS400:*:*) - echo powerpc-ibm-os400 + echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) + arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) @@ -333,6 +354,9 @@ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" @@ -391,23 +415,23 @@ # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; @@ -477,8 +501,8 @@ echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ @@ -491,7 +515,7 @@ else echo i586-dg-dgux${UNAME_RELEASE} fi - exit ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; @@ -548,7 +572,7 @@ echo rs6000-ibm-aix3.2 fi exit ;; - *:AIX:*:[456]) + *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 @@ -591,52 +615,52 @@ 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac + esac ;; + esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa @@ -656,7 +680,7 @@ # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep __LP64__ >/dev/null + grep -q __LP64__ then HP_ARCH="hppa2.0w" else @@ -727,22 +751,22 @@ exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit ;; + exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; @@ -766,14 +790,14 @@ exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} @@ -785,34 +809,39 @@ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) - case ${UNAME_MACHINE} in - pc98) - echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; + *:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; - *:Interix*:[3456]*) - case ${UNAME_MACHINE} in + *:Interix*:*) + case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; - EM64T | authenticamd | genuineintel) + authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) @@ -822,6 +851,9 @@ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we @@ -842,210 +874,157 @@ exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="gnulibc1" ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else - echo ${UNAME_MACHINE}-unknown-linux-gnueabi + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + else + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) - echo cris-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; frv:Linux:*:*) - echo frv-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - mips64:Linux:*:*) + mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU - #undef mips64 - #undef mips64el + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el + CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 + CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; - or32:Linux:*:*) - echo or32-unknown-linux-gnu - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu + openrisc*:Linux:*:*) + echo or1k-unknown-linux-${LIBC} exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + or32:Linux:*:* | or1k*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-gnu + echo sparc-unknown-linux-${LIBC} + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-${LIBC} + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-gnu + echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^LIBC/{ - s: ::g - p - }'`" - test x"${LIBC}" != x && { - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" - exit - } - test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } - ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both @@ -1053,11 +1032,11 @@ echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. + # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) @@ -1074,7 +1053,7 @@ i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) @@ -1089,7 +1068,7 @@ fi exit ;; i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. + # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; @@ -1117,13 +1096,13 @@ exit ;; pc:*:*:*) # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp - exit ;; + exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; @@ -1158,8 +1137,8 @@ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ @@ -1182,7 +1161,7 @@ rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) @@ -1202,10 +1181,10 @@ echo ns32k-sni-sysv fi exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm @@ -1231,11 +1210,11 @@ exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv${UNAME_RELEASE} else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv${UNAME_RELEASE} fi - exit ;; + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; @@ -1248,6 +1227,9 @@ BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; @@ -1274,9 +1256,31 @@ exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - unknown) UNAME_PROCESSOR=powerpc ;; - esac + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) @@ -1290,7 +1294,10 @@ *:QNX:*:4*) echo i386-pc-qnx exit ;; - NSE-?:NONSTOP_KERNEL:*:*) + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) @@ -1335,13 +1342,13 @@ echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` + UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; @@ -1359,158 +1366,10 @@ i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi +esac cat >&2 <. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. +# Please send patches with a ChangeLog entry to config-patches@gnu.org. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. @@ -72,8 +68,7 @@ version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -120,13 +115,18 @@ # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ - uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] @@ -149,10 +149,13 @@ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray) + -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; + -bluegene*) + os=-cnk + ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 @@ -167,10 +170,10 @@ os=-chorusos basic_machine=$1 ;; - -chorusrdb) - os=-chorusrdb + -chorusrdb) + os=-chorusrdb basic_machine=$1 - ;; + ;; -hiux*) os=-hiuxwe2 ;; @@ -215,6 +218,12 @@ -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; -lynx*) os=-lynxos ;; @@ -239,20 +248,28 @@ # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ + | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | be32 | be64 \ | bfin \ - | c4x | clipper \ + | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ + | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep | metag \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -266,36 +283,51 @@ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ - | nios | nios2 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ - | or32 \ + | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ + | riscv32 | riscv64 \ + | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ - | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; @@ -305,6 +337,21 @@ basic_machine=mt-unknown ;; + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. @@ -319,25 +366,31 @@ # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ + | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | be32-* | be64-* \ | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | craynv-* | cydra-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ + | k1om-* \ + | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ @@ -351,32 +404,41 @@ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ - | nios-* | nios2-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ - | romp-* | rs6000-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ | tron-* \ - | v850-* | v850e-* | vax-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) @@ -401,7 +463,7 @@ basic_machine=a29k-amd os=-udi ;; - abacus) + abacus) basic_machine=abacus-unknown ;; adobe68k) @@ -467,11 +529,24 @@ basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; c90) basic_machine=c90-cray os=-unicos ;; - cegcc) + cegcc) basic_machine=arm-unknown os=-cegcc ;; @@ -503,7 +578,7 @@ basic_machine=craynv-cray os=-unicosmp ;; - cr16) + cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; @@ -661,7 +736,6 @@ i370-ibm* | ibm*) basic_machine=i370-ibm ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 @@ -719,8 +793,15 @@ basic_machine=ns32k-utek os=-sysv ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; mingw32) - basic_machine=i386-pc + basic_machine=i686-pc os=-mingw32 ;; mingw32ce) @@ -748,6 +829,10 @@ basic_machine=powerpc-unknown os=-morphos ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; msdos) basic_machine=i386-pc os=-msdos @@ -755,10 +840,18 @@ ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; + msys) + basic_machine=i686-pc + os=-msys + ;; mvs) basic_machine=i370-ibm os=-mvs ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; ncr3000) basic_machine=i486-ncr os=-sysv4 @@ -823,6 +916,12 @@ np1) basic_machine=np1-gould ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -905,9 +1004,10 @@ ;; power) basic_machine=power-ibm ;; - ppc) basic_machine=powerpc-unknown + ppc | ppcbe) basic_machine=powerpc-unknown ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown @@ -932,7 +1032,11 @@ basic_machine=i586-unknown os=-pw32 ;; - rdos) + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) basic_machine=i386-pc os=-rdos ;; @@ -1001,6 +1105,9 @@ basic_machine=i860-stratus os=-sysv4 ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; sun2) basic_machine=m68000-sun ;; @@ -1057,20 +1164,8 @@ basic_machine=t90-cray os=-unicos ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; tile*) - basic_machine=tile-unknown + basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) @@ -1140,6 +1235,9 @@ xps | xps100) basic_machine=xps100-honeywell ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; ymp) basic_machine=ymp-cray os=-unicos @@ -1237,9 +1335,12 @@ if [ x"$os" != x"" ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. + # First match some system type aliases + # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; @@ -1260,30 +1361,31 @@ # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -kopensolaris* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -openbsd* | -solidbsd* \ + | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1322,7 +1424,7 @@ -opened*) os=-openedition ;; - -os400*) + -os400*) os=-os400 ;; -wince*) @@ -1371,7 +1473,7 @@ -sinix*) os=-sysv4 ;; - -tpf*) + -tpf*) os=-tpf ;; -triton*) @@ -1407,15 +1509,14 @@ -aros*) os=-aros ;; - -kaos*) - os=-kaos - ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; + -nacl*) + ;; -none) ;; *) @@ -1438,10 +1539,10 @@ # system, and we'll never get to this point. case $basic_machine in - score-*) + score-*) os=-elf ;; - spu-*) + spu-*) os=-elf ;; *-acorn) @@ -1453,8 +1554,23 @@ arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff + c4x-* | tic4x-*) + os=-coff + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff ;; # This must come before the *-dec entry. pdp10-*) @@ -1474,14 +1590,11 @@ ;; m68000-sun) os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 ;; m68*-cisco) os=-aout ;; - mep-*) + mep-*) os=-elf ;; mips*-cisco) @@ -1508,7 +1621,7 @@ *-ibm) os=-aix ;; - *-knuth) + *-knuth) os=-mmixware ;; *-wec) @@ -1613,7 +1726,7 @@ -sunos*) vendor=sun ;; - -aix*) + -cnk*|-aix*) vendor=ibm ;; -beos*) diff -Naur libsamplerate-0.1.9.old/Makefile.am libsamplerate-0.1.9/Makefile.am --- libsamplerate-0.1.9.old/Makefile.am 2014-11-30 10:44:50.000000000 +0000 +++ libsamplerate-0.1.9/Makefile.am 2018-03-29 14:12:10.620592278 +0100 @@ -2,7 +2,7 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-gcc-werror -SUBDIRS = M4 src doc examples tests +SUBDIRS = M4 src DIST_SUBDIRS = Win32 $(SUBDIRS) EXTRA_DIST = autogen.sh libsamplerate.spec.in samplerate.pc.in Make.bat ================================================ FILE: switch/libsodium/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: rsn8887 pkgname=switch-libsodium pkgver=1.0.20 pkgrel=1 pkgdesc='A modern and easy-to-use crypto library.' arch=('any') url='http://libsodium.org' license=('custom') options=(!strip libtool staticlibs) makedepends=('dkp-toolchain-vars') source=("https://download.libsodium.org/libsodium/releases/libsodium-$pkgver-stable.tar.gz") groups=('switch-portlibs') build() { cd libsodium-stable source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { cd libsodium-stable source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 LICENSE "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/LICENSE } sha256sums=('e6d3c91bbc08d3f5f548079bd88abd9e51de9c5b48b3f8b1d120b2160e6537d0') ================================================ FILE: switch/libssh2/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=switch-libssh2 pkgver=1.10.0 pkgrel=2 pkgdesc="A library implementing the SSH2 protocol as defined by Internet Drafts" url="https://github.com/libssh2/libssh2" license=('BSD') arch=('any') options=(!strip libtool staticlibs) depends=('switch-mbedtls' 'switch-zlib') groups=('switch-portlibs') source=("${url}/releases/download/libssh2-${pkgver}/libssh2-${pkgver}.tar.gz" "disable-tests.patch") sha256sums=( '2d64e90f3ded394b91d3a2e774ca203a4179f69aebee03003e5a6fa621e41d51' '829c4a08da7d29cd975e1837882cfe2defcb6f181bb10059bf19936fd3a19196' ) prepare() { cd "libssh2-${pkgver}" patch -Np1 -i "$srcdir/disable-tests.patch" } build() { cd "libssh2-${pkgver}" source /opt/devkitpro/switchvars.sh ./configure --prefix=${PORTLIBS_PREFIX} \ --disable-shared --enable-static \ --host=aarch64-none-elf \ --with-crypto=mbedtls \ --disable-examples-build \ --disable-tests-build make } package() { cd "libssh2-${pkgver}" source /opt/devkitpro/switchvars.sh make DESTDIR="${pkgdir}" install install -Dm644 COPYING "${pkgdir}/opt/devkitpro/portlibs/switch/licenses/${pkgname}/LICENSE" } ================================================ FILE: switch/libssh2/disable-tests.patch ================================================ --- a/configure +++ b/configure @@ -675,6 +675,8 @@ USE_OSSFUZZERS_FALSE USE_OSSFUZZERS_TRUE BUILD_EXAMPLES_FALSE BUILD_EXAMPLES_TRUE +BUILD_TESTS_FALSE +BUILD_TESTS_TRUE CPP LIBSREQUIRED LIBZ_PREFIX @@ -871,6 +873,7 @@ enable_clear_memory enable_debug enable_hidden_symbols enable_examples_build +enable_tests_build enable_ossfuzzers enable_werror ' @@ -1544,6 +1547,9 @@ Optional Features: --enable-examples-build Build example applications (this is the default) --disable-examples-build Do not build example applications + --enable-tests-build Build test applications (this is the default) + --disable-tests-build + Do not build test applications --enable-ossfuzzers Whether to generate the fuzzers for OSS-Fuzz --enable-werror Enable compiler warnings as errors --disable-werror Disable compiler warnings as errors @@ -23210,6 +23216,35 @@ else fi +# Build tests applications? +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build tests applications" >&5 +printf %s "checking whether to build tests applications... " >&6; } +# Check whether --enable-tests-build was given. +if test ${enable_tests_build+y} +then : + enableval=$enable_tests_build; case "$enableval" in + no | false) + build_tests='no' + ;; + *) + build_tests='yes' + ;; +esac +else $as_nop + build_tests='yes' +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $build_tests" >&5 +printf "%s\n" "$build_tests" >&6; } + if test "x$build_tests" != "xno"; then + BUILD_TESTS_TRUE= + BUILD_TESTS_FALSE='#' +else + BUILD_TESTS_TRUE='#' + BUILD_TESTS_FALSE= +fi + + # Build OSS fuzzing targets? # Check whether --enable-ossfuzzers was given. @@ -24183,6 +24218,10 @@ if test -z "${BUILD_EXAMPLES_TRUE}" && test -z "${BUILD_EXAMPLES_FALSE}"; then as_fn_error $? "conditional \"BUILD_EXAMPLES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${BUILD_TESTS_TRUE}" && test -z "${BUILD_TESTS_FALSE}"; then + as_fn_error $? "conditional \"BUILD_TESTS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${USE_OSSFUZZERS_TRUE}" && test -z "${USE_OSSFUZZERS_FALSE}"; then as_fn_error $? "conditional \"USE_OSSFUZZERS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -26634,6 +26673,7 @@ fi Clear memory: $enable_clear_memory Debug build: $enable_debug Build examples: $build_examples + Build tests: $build_tests Path to sshd: $ac_cv_path_SSHD (only for self-tests) zlib compression: ${found_libz} " >&5 @@ -26649,6 +26689,7 @@ printf "%s\n" "$as_me: summary of build options: Clear memory: $enable_clear_memory Debug build: $enable_debug Build examples: $build_examples + Build tests: $build_tests Path to sshd: $ac_cv_path_SSHD (only for self-tests) zlib compression: ${found_libz} " >&6;} --- a/Makefile.in +++ b/Makefile.in @@ -90,6 +90,7 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @BUILD_EXAMPLES_TRUE@am__append_1 = example +@BUILD_TESTS_TRUE@am__append_1 = tests subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \ @@ -396,7 +397,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign nostdinc -SUBDIRS = src tests docs $(am__append_1) +SUBDIRS = src docs $(am__append_1) pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libssh2.pc include_HEADERS = \ --- a/Makefile.am +++ b/Makefile.am @@ -1,9 +1,12 @@ AUTOMAKE_OPTIONS = foreign nostdinc -SUBDIRS = src tests docs +SUBDIRS = src docs if BUILD_EXAMPLES SUBDIRS += example endif +if BUILD_TESTS +SUBDIRS += tests +endif pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libssh2.pc ================================================ FILE: switch/libtheora/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=switch-libtheora pkgver=1.2.0alpha1 pkgrel=1 pkgdesc='Free and open video compression codec from the Xiph.org Foundation' arch=('any') url='https://www.theora.org/' license=(Xiph.org) options=(!strip libtool staticlibs) source=("https://ftp.osuosl.org/pub/xiph/releases/theora/libtheora-${pkgver}.tar.gz" "config.sub" "config.guess") sha256sums=( '538305e6efa484ba740616b521f0d8c4428a0a995193c5e6af9b20f488f3c497' '72e02ea93447038f8ced24f296b31e0f397bbcc6b32abdcf9b38c80f153433fd' 'fbc2337aa59a204f5d74743b82c8be7aab8b39853b4e54a888008f70430c4305' ) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') depends=('switch-libogg' 'switch-libvorbis' 'switch-libpng') groups=('switch-portlibs') build() { cd libtheora-$pkgver source /opt/devkitpro/switchvars.sh cp $srcdir/config.sub $srcdir/config.guess . ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static \ --disable-encode --disable-examples make } package() { cd libtheora-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install install -Dm644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING # remove useless documentation rm -r "$pkgdir"${PORTLIBS_PREFIX}/share/doc } ================================================ FILE: switch/libtheora/config.guess ================================================ #! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2015 Free Software Foundation, Inc. timestamp='2015-08-20' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ /sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || \ echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` machine=${arch}${endian}-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case "${UNAME_MACHINE_ARCH}" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; *:Sortix:*:*) echo ${UNAME_MACHINE}-unknown-sortix exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; e2k:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: ================================================ FILE: switch/libtheora/config.sub ================================================ #! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2015 Free Software Foundation, Inc. timestamp='2015-08-20' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | e2k | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; asmjs) basic_machine=asmjs-unknown ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; leon-*|leon[3-9]-*) basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: ================================================ FILE: switch/libtimidity/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: rsn8887 pkgname=switch-libtimidity pkgver=0.2.6 pkgrel=2 pkgdesc='A MIDI to WAVE converter library.' arch=('any') url='https://sf.net/p/libtimidity/' license=('LGPL v2.1') options=(!strip libtool staticlibs) makedepends=('dkp-toolchain-vars') source=("https://downloads.sourceforge.net/project/libtimidity/libtimidity/${pkgver}/libtimidity-${pkgver}.tar.gz") sha256sums=('d53d688335cc9327747a2a0456904c88ca2270538982dcee0ff11d902ae8575c') groups=('switch-portlibs') build() { cd libtimidity-${pkgver} source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static --disable-aotest --disable-ao make } package() { cd libtimidity-${pkgver} source /opt/devkitpro/switchvars.sh make DESTDIR="${pkgdir}" install } ================================================ FILE: switch/libvorbis/.gitignore ================================================ switch-vorbis ================================================ FILE: switch/libvorbis/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: cpasjuste pkgname=switch-libvorbis pkgver=1.3.7 pkgrel=1 pkgdesc='Vorbis is a patent-clear, fully open, general purpose audio encoding format standard that rivals or even surpasses the 'upcoming' generation of proprietary codecs (AAC and TwinVQ, also known as VQF).' arch=('any') url='https://wiki.xiph.org/Vorbis' license=(Xiph.org) options=(!strip libtool staticlibs) depends=('switch-libogg') makedepends=('dkp-toolchain-vars' 'switch-pkg-config') groups=('switch-portlibs') source=("https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-$pkgver.tar.gz") sha256sums=('0e982409a9c3fc82ee06e08205b1355e5c6aa4c36bca58146ef399621b0ce5ab') build() { cd libvorbis-$pkgver source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { cd libvorbis-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: switch/libvorbisidec/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=switch-libvorbisidec pkgver=1.2.1 pkgrel=2 pkgdesc='Fixed-point version of the Ogg Vorbis decoder (for Nintendo Switch homebrew development)' arch=('any') url="http://xiph.org" license=('LGPL') options=(!strip libtool staticlibs) source=("https://downloads.devkitpro.org/packages/sources/libvorbisidec-${pkgver}.tar.bz2") sha256sums=('1afbc18e0104ca8c9e9943cfcfa995ea0100bf246c425962770d455d4ad03c65') makedepends=('switch-pkg-config' 'dkp-toolchain-vars') depends=('switch-libogg') groups=('switch-portlibs') build() { cd libvorbisidec-$pkgver source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf make } package() { cd libvorbisidec-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING } ================================================ FILE: switch/libvpx/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: uyjulian pkgname=switch-libvpx pkgver=1.8.0 pkgrel=2 pkgdesc='A free software video codec library from Google and the Alliance for Open Media (AOMedia). It serves as the reference software implementation for the VP8 and VP9 video coding formats.' arch=('any') url='https://chromium.googlesource.com/webm/libvpx' license=('BSD') options=(!strip libtool staticlibs) makedepends=('dkp-toolchain-vars') source=("https://github.com/webmproject/libvpx/archive/v$pkgver.tar.gz" "libvpx.patch") sha256sums=( '86df18c694e1c06cc8f83d2d816e9270747a0ce6abe316e93a4f4095689373f6' 'b51f4661334646beda13d8fc9dd8fcc27eb91813ae9cd76ab4ac6914efb0c9da' ) groups=('switch-portlibs') build() { cd libvpx-$pkgver source /opt/devkitpro/switchvars.sh patch -p1 -i $srcdir/libvpx.patch CROSS=aarch64-none-elf- ./configure \ --prefix="${PORTLIBS_PREFIX}" --target=generic-gnu \ --disable-examples --disable-tools \ --disable-docs --disable-unit-tests \ --disable-shared --enable-static make } package() { cd libvpx-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: switch/libvpx/libvpx.patch ================================================ diff -burN libvpx-1.8.0.orig/vp8/common/generic/systemdependent.c libvpx-1.8.0/vp8/common/generic/systemdependent.c --- libvpx-1.8.0.orig/vp8/common/generic/systemdependent.c 2019-02-04 11:02:33.000000000 -0600 +++ libvpx-1.8.0/vp8/common/generic/systemdependent.c 2019-06-02 09:16:46.000000000 -0500 @@ -38,11 +38,15 @@ int core_count = 16; #if HAVE_UNISTD_H && !defined(__OS2__) +#if 1 + core_count = 4; +#else #if defined(_SC_NPROCESSORS_ONLN) core_count = (int)sysconf(_SC_NPROCESSORS_ONLN); #elif defined(_SC_NPROC_ONLN) core_count = (int)sysconf(_SC_NPROC_ONLN); #endif +#endif #elif defined(_WIN32) { #if _WIN32_WINNT >= 0x0501 diff -burN libvpx-1.8.0.orig/vpx_util/vpx_thread.c libvpx-1.8.0/vpx_util/vpx_thread.c --- libvpx-1.8.0.orig/vpx_util/vpx_thread.c 2019-02-04 11:02:33.000000000 -0600 +++ libvpx-1.8.0/vpx_util/vpx_thread.c 2019-06-01 23:37:12.000000000 -0500 @@ -81,7 +81,7 @@ worker->status_ = NOT_OK; } -static int sync(VPxWorker *const worker) { +static int _sync(VPxWorker *const worker) { #if CONFIG_MULTITHREAD change_state(worker, OK); #endif @@ -121,7 +121,7 @@ worker->status_ = OK; #endif } else if (worker->status_ > OK) { - ok = sync(worker); + ok = _sync(worker); } assert(!ok || (worker->status_ == OK)); return ok; @@ -160,7 +160,7 @@ //------------------------------------------------------------------------------ -static VPxWorkerInterface g_worker_interface = { init, reset, sync, +static VPxWorkerInterface g_worker_interface = { init, reset, _sync, launch, execute, end }; int vpx_set_worker_interface(const VPxWorkerInterface *const winterface) { ================================================ FILE: switch/libwebp/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: uyjulian pkgname=switch-libwebp pkgver=1.0.2 pkgrel=2 pkgdesc='WebP is a modern image format that provides superior lossless and lossy compression for images on the web. Using WebP, webmasters and web developers can create smaller, richer images that make the web faster.' arch=('any') url='https://developers.google.com/speed/webp/' license=('BSD') options=(!strip libtool staticlibs) makedepends=('dkp-toolchain-vars') source=("https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-$pkgver.tar.gz") sha256sums=('3d47b48c40ed6476e8047b2ddb81d93835e0ca1b8d3e8c679afbb3004dd564b1') groups=('switch-portlibs') build() { cd libwebp-$pkgver source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { cd libwebp-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: switch/libxml2/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Pablo Curiel pkgname=switch-libxml2 pkgver=2.9.8 pkgrel=4 pkgdesc='XML parsing library, version 2.' arch=('any') url='http://www.xmlsoft.org/' license=('MIT') options=(!strip libtool staticlibs) source=( "http://xmlsoft.org/sources/libxml2-${pkgver}.tar.gz" ) sha256sums=( '0b74e51595654f958148759cfef0993114ddccccbb6f31aee018f3558e8e2732' ) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') groups=('switch-portlibs') build() { cd libxml2-$pkgver source /opt/devkitpro/switchvars.sh export LIBS=-lnx export CFLAGS="${CFLAGS} -D__LINUX_ERRNO_EXTENSIONS__" # patch out compiling xmlcatalog & xmllint sed '/^bin_PROGRAMS/d' -i Makefile.in ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static --disable-maintainer-mode \ --enable-rebuild-docs=no --enable-ipv6=no \ --without-icu --without-python --without-lzma make } package() { cd libxml2-$pkgver make DESTDIR="$pkgdir" install #remove uneeded extras rm -fr $pkgdir/doc $pkgdir/man $pkgdir/gtk-doc } ================================================ FILE: switch/libzstd/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=switch-libzstd pkgver=1.5.7 pkgrel=1 pkgdesc='Zstd, short for Zstandard, is a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level compression ratio (for Nintendo Switch homebrew development)' arch=('any') url='https://zstd.net' license=('BSD and GPLv2') options=(!strip libtool staticlibs) source=("https://github.com/facebook/zstd/releases/download/v$pkgver/zstd-$pkgver.tar.gz") sha256sums=('eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3') makedepends=('dkp-toolchain-vars') groups=('switch-portlibs') build() { source /opt/devkitpro/switchvars.sh cd zstd-$pkgver aarch64-none-elf-cmake -B _build -S build/cmake -GNinja \ -DZSTD_BUILD_PROGRAMS=OFF \ -DZSTD_BUILD_STATIC=ON \ -DZSTD_BUILD_SHARED=OFF cmake --build _build } package() { source /opt/devkitpro/switchvars.sh cd zstd-$pkgver DESTDIR="$pkgdir" cmake --install _build install -d "$pkgdir"/opt/devkitpro/portlibs/switch/licenses/$pkgname install COPYING "$pkgdir"/opt/devkitpro/portlibs/switch/licenses/$pkgname/COPYING install LICENSE "$pkgdir"/opt/devkitpro/portlibs/switch/licenses/$pkgname/LICENSE } ================================================ FILE: switch/lua51/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgsuffix=51 pkgname=("switch-liblua${pkgsuffix}") pkgvermaj=5.1 pkgver=${pkgvermaj}.5 pkgrel=1 pkgdesc="Powerful lightweight programming language designed for extending applications" arch=('any') license=('MIT') url="https://www.lua.org/" options=(!strip libtool staticlibs) source=(${url}/ftp//lua-${pkgver}.tar.gz) makedepends=('devkitA64' 'switch-pkg-config' 'dkp-toolchain-vars') groups=('switch-portlibs') build() { source /opt/devkitpro/switchvars.sh make -C "${srcdir}/lua-${pkgver}" \ CC=aarch64-none-elf-gcc \ AR="aarch64-none-elf-ar rcu" \ RANLIB=aarch64-none-elf-ranlib \ LUA_A=liblua${pkgvermaj}.a \ ALL_T=liblua${pkgvermaj}.a \ CPPFLAGS="${CPPFLAGS} ${CFLAGS}" \ PLAT=generic } package() { source /opt/devkitpro/switchvars.sh cd ${srcdir}/lua-${pkgver} echo $pkgdir echo $PORTLIBS_PREFIX install -dm 755 ${pkgdir}/${PORTLIBS_PREFIX}/include/lua${pkgvermaj} install -m 644 src/lua.h src/luaconf.h src/lualib.h src/lauxlib.h ${pkgdir}/${PORTLIBS_PREFIX}/include/lua${pkgvermaj} sed -i "s,prefix= /usr/local,prefix= ${PORTLIBS_PREFIX}," etc/lua.pc sed -i "s,includedir=\${prefix}/include,includedir=\${prefix}/include/lua${pkgvermaj}," etc/lua.pc sed -i "s,-llua,-llua${pkgvermaj}," etc/lua.pc install -dm 755 ${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig install -m 644 etc/lua.pc ${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/lua${pkgsuffix}.pc install -m 644 src/liblua${pkgvermaj}.a ${pkgdir}/${PORTLIBS_PREFIX}/lib } sha256sums=('2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333') ================================================ FILE: switch/lwext4/PKGBUILD ================================================ # Maintainer: DarkMatterCore pkgname=switch-lwext4 pkgver=1.0.0 pkgcommithash=58bcf89a121b72d4fb66334f1693d3b30e4cb9c5 pkgrel=1 pkgdesc='ext2/ext3/ext4 filesystem library for microcontrollers' arch=('any') url='https://github.com/gkostka/lwext4' license=('GPL') options=(!strip libtool staticlibs) groups=('switch-portlibs') makedepends=('devkitA64' 'dkp-toolchain-vars' 'switch-cmake') source=( "lwext4-${pkgver}.tar.gz::${url}/archive/${pkgcommithash}.tar.gz" "lwext4-${pkgver}.patch" ) prepare() { cd "lwext4-${pkgcommithash}" patch -Np1 -i "${srcdir}/lwext4-${pkgver}.patch" source /opt/devkitpro/switchvars.sh make lib_only cp -fr build_lib_only/include/generated include/generated } build() { cd "lwext4-${pkgcommithash}" source /opt/devkitpro/switchvars.sh make -C build_lib_only } package() { cd "lwext4-${pkgcommithash}" source /opt/devkitpro/switchvars.sh for file in $(find include -type f -name *.h); do install -Dm644 ${file} "${pkgdir}${PORTLIBS_PREFIX}/${file}" done install -Dm644 build_lib_only/src/liblwext4.a "${pkgdir}${PORTLIBS_PREFIX}/lib/liblwext4.a" install -Dm644 LICENSE "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}/LICENSE" } sha256sums=('8f7cce20f5dad2719cb22982e64c75069af51741555c98d34a247a5d8f154890' '59d674ca846c0ccbef189d7153ba864bb8940d26be65826843fb00bdcc58b519') ================================================ FILE: switch/lwext4/lwext4-1.0.0.patch ================================================ diff --git a/CMakeLists.txt b/CMakeLists.txt index eec0993..ce64c51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,11 +30,21 @@ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL msp430g2210) add_definitions(-DCONFIG_DEBUG_ASSERT=0) #... elseif(LIB_ONLY) - add_definitions(-DCONFIG_DEBUG_PRINTF=0) - add_definitions(-DCONFIG_DEBUG_ASSERT=0) - add_definitions(-DCONFIG_HAVE_OWN_OFLAGS=1) + if (CMAKE_BUILD_TYPE STREQUAL Release) + add_definitions(-DCONFIG_DEBUG_PRINTF=0) + add_definitions(-DCONFIG_DEBUG_ASSERT=0) + else() + add_definitions(-DCONFIG_DEBUG_PRINTF=1) + add_definitions(-DCONFIG_DEBUG_ASSERT=1) + endif() + add_definitions(-DCONFIG_HAVE_OWN_ASSERT=0) add_definitions(-DCONFIG_HAVE_OWN_ERRNO=0) add_definitions(-DCONFIG_BLOCK_DEV_CACHE_SIZE=16) + add_definitions(-DCONFIG_EXT4_BLOCKDEVS_COUNT=8) + add_definitions(-DCONFIG_EXT4_MOUNTPOINTS_COUNT=8) + add_definitions(-DCONFIG_HAVE_OWN_OFLAGS=0) + add_definitions(-DCONFIG_UNALIGNED_ACCESS=1) + add_definitions(-DCONFIG_USE_USER_MALLOC=0) else() #Generic example target if (WIN32) @@ -74,8 +84,6 @@ macro(output_configure) endmacro() output_configure() -add_subdirectory(blockdev) - #Library build add_subdirectory(src) #Detect all possible warnings for lwext4 target diff --git a/Makefile b/Makefile index 12ee5c7..413317d 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ mingw: lib_only: rm -R -f build_lib_only mkdir build_lib_only - cd build_lib_only && cmake $(COMMON_DEFINITIONS) -DLIB_ONLY=TRUE .. + cd build_lib_only && aarch64-none-elf-cmake $(COMMON_DEFINITIONS) -DLIB_ONLY=TRUE .. all: generic diff --git a/src/ext4.c b/src/ext4.c index 90ce45e..2bdd520 100644 --- a/src/ext4.c +++ b/src/ext4.c @@ -461,14 +461,13 @@ int ext4_umount(const char *mount_point) if (r != EOK) goto Finish; - mp->mounted = 0; - ext4_bcache_cleanup(mp->fs.bdev->bc); ext4_bcache_fini_dynamic(mp->fs.bdev->bc); r = ext4_block_fini(mp->fs.bdev); Finish: mp->fs.bdev->fs = NULL; + memset(mp, 0, sizeof(struct ext4_mountpoint)); return r; } @@ -1616,7 +1615,7 @@ static int ext4_ftruncate_no_lock(ext4_file *file, uint64_t size) /*Sync file size*/ file->fsize = ext4_inode_get_size(&file->mp->fs.sb, ref.inode); if (file->fsize <= size) { - r = EOK; + r = ENOTSUP; goto Finish; } @@ -1659,11 +1658,12 @@ int ext4_ftruncate(ext4_file *f, uint64_t size) EXT4_MP_LOCK(f->mp); ext4_trans_start(f->mp); + r = ext4_ftruncate_no_lock(f, size); - if (r != EOK) - ext4_trans_abort(f->mp); - else + if (r == EOK || r == ENOTSUP) ext4_trans_stop(f->mp); + else + ext4_trans_abort(f->mp); EXT4_MP_UNLOCK(f->mp); return r; @@ -3146,8 +3146,10 @@ int ext4_dir_mk(const char *path) /*Check if exist.*/ r = ext4_generic_open(&f, path, "r", false, 0, 0); - if (r == EOK) + if (r == EOK) { + r = EEXIST; goto Finish; + } /*Create new directory.*/ r = ext4_generic_open(&f, path, "w", false, 0, 0); ================================================ FILE: switch/lz4/PKGBUILD ================================================ # Maintainer: TurtleP pkgname=switch-lz4 pkgver=1.9.3 pkgrel=1 pkgdesc="Very fast lossless compression algorithm" arch=("any") url="https://lz4.github.io/lz4/" license=("BSD" "GPL2") options=("staticlibs" "!strip") source=("https://github.com/lz4/lz4/archive/refs/tags/v${pkgver}.zip") sha256sums=("4ec935d99aa4950eadfefbd49c9fad863185ac24c32001162c44a683ef61b580") makedepends=("dkp-toolchain-vars") groups=("switch-portlibs") package() { source /opt/devkitpro/switchvars.sh cd lz4-${pkgver}/lib make BUILD_SHARED=no \ PREFIX=${PORTLIBS_PREFIX} \ DESTDIR=${pkgdir} \ install } ================================================ FILE: switch/mbedtls/PKGBUILD ================================================ _realname=mbedtls pkgname=switch-${_realname} pkgver=2.28.10 pkgrel=1 pkgdesc='An open source, portable, easy to use, readable and flexible SSL library' arch=('any') url='https://tls.mbed.org' license=('apache') options=(!strip libtool staticlibs) depends=(switch-zlib) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') source=( "https://github.com/Mbed-TLS/mbedtls/releases/download/mbedtls-${pkgver}/mbedtls-${pkgver}.tar.bz2" "mbedtls-${pkgver}.patch" ) groups=('switch-portlibs') sha256sums=('19e5b81fdac0fe22009b9e2bdcd52d7dcafbf62bc67fc59cf0a76b5b5540d149' '31cd10803cb47d7a4bb95124f59d997150e961f87ce2911ed25e1af120086311') build() { cd mbedtls-$pkgver patch -Np1 -i $srcdir/mbedtls-${pkgver}.patch ./scripts/config.pl set MBEDTLS_ENTROPY_HARDWARE_ALT ./scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY ./scripts/config.pl unset MBEDTLS_SELF_TEST source ${DEVKITPRO}/switchvars.sh aarch64-none-elf-cmake \ -DCMAKE_INSTALL_PREFIX=$PORTLIBS_PREFIX \ -DCMAKE_C_FLAGS="$CFLAGS $CPPFLAGS -fzero-init-padding-bits=unions" \ -DZLIB_ROOT="$PORTLIBS_PREFIX" \ -DENABLE_ZLIB_SUPPORT=TRUE -DENABLE_TESTING=FALSE -DENABLE_PROGRAMS=FALSE \ . make -j$(nproc) } package() { cd mbedtls-$pkgver make install DESTDIR="$pkgdir" install -d "$pkgdir"$PORTLIBS_PREFIX/licenses/$pkgname cp -v LICENSE "$pkgdir"$PORTLIBS_PREFIX/licenses/$pkgname } ================================================ FILE: switch/mbedtls/mbedtls-2.28.10.patch ================================================ diff --git a/library/entropy.c b/library/entropy.c index 339dc0e03..8b7f54ac7 100644 --- a/library/entropy.c +++ b/library/entropy.c @@ -95,6 +95,19 @@ void mbedtls_entropy_init(mbedtls_entropy_context *ctx) #endif /* MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES */ } +#ifdef __SWITCH__ + #include + int mbedtls_hardware_poll( void *data, + unsigned char *output, size_t len, size_t *olen ) + { + (void)(data); + csrngGetRandomBytes(output, len); + if(olen) + *olen = len; + return 0; + } +#endif + void mbedtls_entropy_free(mbedtls_entropy_context *ctx) { /* If the context was already free, don't call free() again. diff --git a/library/net_sockets.c b/library/net_sockets.c index 5d985ef00..5d4620790 100644 --- a/library/net_sockets.c +++ b/library/net_sockets.c @@ -21,7 +21,7 @@ #if !defined(unix) && !defined(__unix__) && !defined(__unix) && \ !defined(__APPLE__) && !defined(_WIN32) && !defined(__QNXNTO__) && \ - !defined(__HAIKU__) && !defined(__midipix__) + !defined(__HAIKU__) && !defined(__midipix__) && !defined(__SWITCH__) #error "This module only works on Unix and Windows, see MBEDTLS_NET_C in config.h" #endif @@ -411,6 +411,7 @@ int mbedtls_net_accept(mbedtls_net_context *bind_ctx, } memcpy(client_ip, &addr4->sin_addr.s_addr, *cip_len); +#ifndef __SWITCH__ } else { struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) &client_addr; *cip_len = sizeof(addr6->sin6_addr.s6_addr); @@ -420,6 +421,7 @@ int mbedtls_net_accept(mbedtls_net_context *bind_ctx, } memcpy(client_ip, &addr6->sin6_addr.s6_addr, *cip_len); +#endif } } diff --git a/library/timing.c b/library/timing.c index b1f72fe1b..db67649df 100644 --- a/library/timing.c +++ b/library/timing.c @@ -19,7 +19,7 @@ #if !defined(unix) && !defined(__unix__) && !defined(__unix) && \ !defined(__APPLE__) && !defined(_WIN32) && !defined(__QNXNTO__) && \ - !defined(__HAIKU__) && !defined(__midipix__) + !defined(__HAIKU__) && !defined(__midipix__) && !defined(__SWITCH__) #error "This module only works on Unix and Windows, see MBEDTLS_TIMING_C in config.h" #endif @@ -52,6 +52,10 @@ struct _hr_time { }; #endif /* _WIN32 && !EFIX64 && !EFI32 */ +#ifdef __SWITCH__ +#include +#endif + #if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \ (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) @@ -193,6 +197,16 @@ unsigned long mbedtls_timing_hardclock(void) } #endif /* !HAVE_HARDCLOCK && _MSC_VER && !EFIX64 && !EFI32 */ +#if !defined(HAVE_HARDCLOCK) && defined(__SWITCH__) + +#define HAVE_HARDCLOCK +unsigned long mbedtls_timing_hardclock( void ) +{ + return armGetSystemTick(); +} + +#endif + #if !defined(HAVE_HARDCLOCK) #define HAVE_HARDCLOCK @@ -288,6 +302,51 @@ unsigned long mbedtls_timing_get_timer(struct mbedtls_timing_hr_time *val, int r } } +#ifdef __SWITCH__ +static bool timer_thread_created = false; +static unsigned int alarmSecs = 0; +static Thread timerThread; +static alignas(0x1000) char timerThreadStack[0x1000]; + +static void timer_thread_func(void *param) +{ + (void) param; + svcSleepThread((s64)alarmSecs * 1e9L); + mbedtls_timing_alarmed = 1; +} + +static void __attribute__((destructor)) cleanup_timer_thread() +{ + if(timer_thread_created) + { + threadWaitForExit(&timerThread); + threadClose(&timerThread); + } +} + +void mbedtls_set_alarm( int seconds ) +{ + if(seconds == 0) + { + mbedtls_timing_alarmed = 1; + return; + } + + mbedtls_timing_alarmed = 0; + alarmSecs = seconds; + + if(timer_thread_created) + { + threadWaitForExit(&timerThread); + threadClose(&timerThread); + } + + timer_thread_created = true; + + threadCreate(&timerThread, timer_thread_func, NULL, timerThreadStack, 0x1000, 0x3b, -2); + threadStart(&timerThread); +} +#else static void sighandler(int signum) { mbedtls_timing_alarmed = 1; @@ -305,7 +364,7 @@ void mbedtls_set_alarm(int seconds) mbedtls_timing_alarmed = 1; } } - +#endif #endif /* _WIN32 && !EFIX64 && !EFI32 */ /* ================================================ FILE: switch/mesa/OpenGLConfig.cmake ================================================ find_library(OPENGL_egl_LIBRARY EGL) find_library(_OPENGL_glapi_LIBRARY glapi) find_library(_OPENGL_drm_nouveau_LIBRARY drm_nouveau) find_path(_OPENGL_gl_gl_INCLUDE_DIR NAMES GL/gl.h) find_path(_OPENGL_gl_egl_INCLUDE_DIR NAMES EGL/egl.h) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(OpenGL REQUIRED_VARS OPENGL_egl_LIBRARY _OPENGL_glapi_LIBRARY _OPENGL_drm_nouveau_LIBRARY _OPENGL_gl_gl_INCLUDE_DIR ) set(OPENGL_FOUND ${OpenGL_FOUND}) set(OPENGL_XMESA_FOUND OFF) set(OPENGL_GLU_FOUND OFF) set(OPENGL_OpenGL_FOUND ${OpenGL_FOUND}) set(OpenGL_GLX_FOUND OFF) set(OpenGL_EGL_FOUND ${OpenGL_FOUND}) set(OPENGL_INCLUDE_DIR ${_OPENGL_gl_gl_INCLUDE_DIR}) set(OPENGL_EGL_INCLUDE_DIRS ${_OPENGL_gl_egl_INCLUDE_DIR}) set(OPENGL_LIBRARIES ${OPENGL_egl_LIBRARY} ${_OPENGL_glapi_LIBRARY} ${_OPENGL_drm_nouveau_LIBRARY}) set(OPENGL_LIBRARY ${OPENGL_LIBRARIES}) set(OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR}) if(OpenGL_FOUND) if(NOT TARGET OpenGL::EGL) add_library(OpenGL::EGL INTERFACE IMPORTED) set_target_properties(OpenGL::EGL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_OPENGL_gl_egl_INCLUDE_DIR}" INTERFACE_LINK_LIBRARIES "${OPENGL_egl_LIBRARY};${_OPENGL_glapi_LIBRARY};${_OPENGL_drm_nouveau_LIBRARY}" ) endif() if(NOT TARGET OpenGL::GL) add_library(OpenGL::GL INTERFACE IMPORTED) set_target_properties(OpenGL::GL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_OPENGL_gl_gl_INCLUDE_DIR}" INTERFACE_LINK_LIBRARIES "${OPENGL_egl_LIBRARY};${_OPENGL_glapi_LIBRARY};${_OPENGL_drm_nouveau_LIBRARY}" ) endif() endif() ================================================ FILE: switch/mesa/PKGBUILD ================================================ # Maintainer: fincs pkgbasename=mesa pkgname=switch-$pkgbasename pkgver=20.1.0 pkgrel=5 pkgdesc='The Mesa 3D Graphics Library' arch=('any') url='https://mesa.freedesktop.org/archive' license=(MIT) options=(!strip libtool staticlibs) source=( "${pkgbasename}-${pkgver}.tar.xz::${url}/${pkgbasename}-${pkgver}-rc3.tar.xz" "${pkgname}-${pkgver}-${pkgrel}.patch" gl_XML.py.patch glX_XML.py.patch OpenGLConfig.cmake ) makedepends=('switch-pkg-config' 'dkp-toolchain-vars' 'dkp-meson-scripts') depends=('switch-libdrm_nouveau') groups=('switch-portlibs') build() { cd ${pkgbasename}-${pkgver}-rc3 patch -p1 -i ${srcdir}/${pkgname}-${pkgver}-${pkgrel}.patch patch -p1 -i ${srcdir}/gl_XML.py.patch patch -p1 -i ${srcdir}/glX_XML.py.patch /opt/devkitpro/meson-cross.sh switch ../crossfile.txt build -Db_ndebug=true ninja -C build } package() { cd ${pkgbasename}-${pkgver}-rc3 DESTDIR="$pkgdir" ninja -C build install sed -i "s,-lEGL,-lEGL -ldrm_nouveau," ${pkgdir}/opt/devkitpro/portlibs/switch/lib/pkgconfig/egl.pc install -Dm644 $srcdir/OpenGLConfig.cmake $pkgdir/opt/devkitpro/portlibs/switch/lib/cmake/OpenGL/OpenGLConfig.cmake } sha256sums=('c90b75ea34302ebde9b81b87c5642fa864c40fe9c4ad34ce0793170c1413168d' '950f93d3e5b6ae9c5a42c2918623fe9a80d7ee398d92d2e73abec86b62d75916' 'a9bc326195b3fe29709e079466a8b2162a2ac9409f694eaad5494490155e2dd4' '1475defcdf8600690eaddeee28d8f01310635c1273fb541f668e8789714d36ca' '016b39536fa560b38cbb456e3e9146439401c0ea29f26400ea065bb9d76f2518') ================================================ FILE: switch/mesa/glX_XML.py.patch ================================================ --- mesa-20.1.0-rc3/src/mapi/glapi/gen/glX_XML.py.orig 2025-07-04 16:42:20.934970341 +0100 +++ mesa-20.1.0-rc3/src/mapi/glapi/gen/glX_XML.py 2025-07-04 16:43:56.488512496 +0100 @@ -48,7 +48,7 @@ self.functions = {} - for child in element.getchildren(): + for child in list(element): if child.tag == "size": n = child.get( "name" ) c = child.get( "count" ) @@ -130,7 +130,7 @@ self.counter_list.append(param.counter) - for child in element.getchildren(): + for child in list(element): if child.tag == "glx": rop = child.get( 'rop' ) sop = child.get( 'sop' ) ================================================ FILE: switch/mesa/gl_XML.py.patch ================================================ --- mesa-20.1.0-rc3/src/mapi/glapi/gen/gl_XML.py.orig 2020-05-13 18:41:14.886004200 +0100 +++ mesa-20.1.0-rc3/src/mapi/glapi/gen/gl_XML.py 2025-07-04 16:25:01.736192731 +0100 @@ -716,7 +716,7 @@ parameters = [] return_type = "void" - for child in element.getchildren(): + for child in list(element): if child.tag == "return": return_type = child.get( "type", "void" ) elif child.tag == "param": @@ -746,7 +746,7 @@ if param.is_image(): self.images.append( param ) - if element.getchildren(): + if list(element): self.initialized = 1 self.entry_point_parameters[name] = parameters else: @@ -876,7 +876,7 @@ def process_OpenGLAPI(self, file_name, element): - for child in element.getchildren(): + for child in list(element): if child.tag == "category": self.process_category( child ) elif child.tag == "OpenGLAPI": @@ -896,7 +896,7 @@ [cat_type, key] = classify_category(cat_name, cat_number) self.categories[cat_type][key] = [cat_name, cat_number] - for child in cat.getchildren(): + for child in list(cat): if child.tag == "function": func_name = real_function_name( child ) ================================================ FILE: switch/mesa/switch-mesa-20.1.0-5.patch ================================================ diff --git a/include/EGL/eglplatform.h b/include/EGL/eglplatform.h index 939539e640e..1ce16b2e109 100644 --- a/include/EGL/eglplatform.h +++ b/include/EGL/eglplatform.h @@ -152,6 +152,12 @@ typedef void *EGLNativeDisplayType; typedef khronos_uintptr_t EGLNativePixmapType; typedef khronos_uintptr_t EGLNativeWindowType; +#elif defined(__SWITCH__) + +typedef void *EGLNativeDisplayType; +typedef khronos_uint8_t *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + #else #error "Platform not recognized" #endif diff --git a/include/c11/threads.h b/include/c11/threads.h index 3c3f23a8ab8..b512521535f 100644 --- a/include/c11/threads.h +++ b/include/c11/threads.h @@ -37,6 +37,32 @@ #include "c99_compat.h" /* for `inline` */ +#ifdef _ISOC11_SOURCE +#include +#include + +/*-------------------- 7.25.7 Time functions --------------------*/ +// 7.25.6.1 +#ifndef HAVE_TIMESPEC_GET +#include + +static inline int +timespec_get(struct timespec *ts, int base) +{ + if (!ts) return 0; + if (base == TIME_UTC) { + struct timeval tv; + gettimeofday(&tv, NULL); + ts->tv_sec = tv.tv_sec; + ts->tv_nsec = tv.tv_usec * 1000; + return base; + } + return 0; +} +#endif + +#else + /*---------------------------- types ----------------------------*/ typedef void (*tss_dtor_t)(void*); typedef int (*thrd_start_t)(void*); @@ -68,6 +94,6 @@ enum { #error Not supported on this platform. #endif - +#endif #endif /* EMULATED_THREADS_H_INCLUDED_ */ diff --git a/include/c99_alloca.h b/include/c99_alloca.h index 5a3b8c19abb..5c4b6510e8d 100644 --- a/include/c99_alloca.h +++ b/include/c99_alloca.h @@ -35,7 +35,7 @@ # define alloca _alloca -#elif defined(__sun) || defined(__CYGWIN__) +#elif defined(__sun) || defined(__CYGWIN__) || defined(_GNU_SOURCE) # include diff --git a/meson.build b/meson.build index ba4fdb2a59f..0ed24fd6fcc 100644 --- a/meson.build +++ b/meson.build @@ -146,7 +146,7 @@ if dri_drivers.contains('auto') error('Unknown architecture @0@. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.'.format( host_machine.cpu_family())) endif - elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system()) + elif ['darwin', 'windows', 'cygwin', 'haiku', 'horizon'].contains(host_machine.system()) # only swrast would make sense here, but gallium swrast is a much better default dri_drivers = [] else @@ -182,6 +182,8 @@ if gallium_drivers.contains('auto') error('Unknown architecture @0@. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.'.format( host_machine.cpu_family())) endif + elif ['horizon'].contains(host_machine.system()) + gallium_drivers = ['nouveau'] elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system()) gallium_drivers = ['swrast'] else @@ -234,7 +236,7 @@ if _vulkan_drivers.contains('auto') error('Unknown architecture @0@. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.'.format( host_machine.cpu_family())) endif - elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system()) + elif ['darwin', 'windows', 'cygwin', 'haiku', 'horizon'].contains(host_machine.system()) # No vulkan driver supports windows or macOS currently _vulkan_drivers = [] else @@ -285,6 +287,8 @@ if _platforms.contains('auto') _platforms = ['haiku'] elif host_machine.system() == 'windows' _platforms = ['windows'] + elif ['horizon'].contains(host_machine.system()) + _platforms = ['switch'] else error('Unknown OS @0@. Please pass -Dplatforms to set platforms. Patches gladly accepted to fix this.'.format( host_machine.system())) @@ -296,6 +300,7 @@ with_platform_x11 = _platforms.contains('x11') with_platform_wayland = _platforms.contains('wayland') with_platform_drm = _platforms.contains('drm') with_platform_haiku = _platforms.contains('haiku') +with_platform_switch = _platforms.contains('switch') with_platform_surfaceless = _platforms.contains('surfaceless') with_platform_windows = _platforms.contains('windows') @@ -320,7 +325,7 @@ with_glx = get_option('glx') if with_glx == 'auto' if with_dri with_glx = 'dri' - elif with_platform_haiku + elif with_platform_haiku or with_platform_switch with_glx = 'disabled' elif host_machine.system() == 'windows' with_glx = 'disabled' @@ -363,11 +368,11 @@ _egl = get_option('egl') if _egl == 'auto' with_egl = ( not ['darwin', 'windows'].contains(host_machine.system()) and - with_dri and with_shared_glapi and with_platforms + (with_dri or with_platform_switch) and with_shared_glapi and with_platforms ) elif _egl == 'true' - if not with_dri - error('EGL requires dri') + if not (with_dri or with_platform_switch) + error('EGL requires dri or -Dplatforms=switch') elif not with_shared_glapi error('EGL requires shared-glapi') elif not with_platforms @@ -791,6 +796,9 @@ endif if with_platform_haiku pre_args += '-DHAVE_HAIKU_PLATFORM' endif +if with_platform_switch + pre_args += '-DHAVE_SWITCH_PLATFORM' +endif if meson.version().version_compare('>=0.50') prog_python = import('python').find_installation('python3') @@ -825,7 +833,7 @@ endif with_shader_cache = false _shader_cache = get_option('shader-cache') if _shader_cache != 'false' - if host_machine.system() == 'windows' + if ['windows','horizon'].contains(host_machine.system()) if _shader_cache == 'true' error('Shader Cache does not currently work on Windows') endif @@ -887,7 +895,7 @@ if cc.compiles('__uint128_t foo(void) { return 0; }', endif # TODO: this is very incomplete -if ['linux', 'cygwin', 'gnu', 'freebsd', 'gnu/kfreebsd'].contains(host_machine.system()) +if ['linux', 'cygwin', 'gnu', 'freebsd', 'gnu/kfreebsd', 'horizon'].contains(host_machine.system()) pre_args += '-D_GNU_SOURCE' elif host_machine.system() == 'sunos' pre_args += '-D__EXTENSIONS__' @@ -912,6 +920,10 @@ elif host_machine.system() == 'windows' endif endif +if ['horizon'].contains(host_machine.system()) + pre_args += '-D_ISOC11_SOURCE' +endif + # Check for generic C arguments c_args = [] c_vis_args = [] @@ -1017,6 +1029,16 @@ else cpp_vis_args += '-fvisibility=hidden' endif + if host_machine.system() == 'horizon' + # Disable exceptions/rtti support on Switch in order to save on code size. + # Disable usage of __cxa_atexit since newlib only supports 32 atexit functions + # and mesa wants to register around 200 objects worth of global destructors. + cpp_args += [ + '-fno-exceptions', + '-fno-rtti', + '-fno-use-cxa-atexit', + ] + endif endif # set linker arguments @@ -1243,7 +1265,7 @@ ld_args_build_id = cc.get_supported_link_arguments('-Wl,--build-id=sha1') # check for dl support dep_dl = null_dep if not cc.has_function('dlopen') - dep_dl = cc.find_library('dl', required : host_machine.system() != 'windows') + dep_dl = cc.find_library('dl', required : not ['windows','horizon'].contains(host_machine.system())) endif if cc.has_function('dladdr', dependencies : dep_dl) # This is really only required for megadrivers @@ -1265,42 +1287,50 @@ else dep_clock = cc.find_library('rt') endif -# TODO: some of these may be conditional -dep_zlib = dependency('zlib', version : '>= 1.2.3', fallback : ['zlib', 'zlib_dep']) -pre_args += '-DHAVE_ZLIB' - -_zstd = get_option('zstd') -if _zstd != 'false' - dep_zstd = dependency('libzstd', required : _zstd == 'true') - if dep_zstd.found() - pre_args += '-DHAVE_ZSTD' - endif -else - dep_zstd = null_dep -endif +if host_machine.system() != 'horizon' + # TODO: some of these may be conditional + dep_zlib = dependency('zlib', version : '>= 1.2.3', fallback : ['zlib', 'zlib_dep']) + pre_args += '-DHAVE_ZLIB' -dep_thread = dependency('threads') -if dep_thread.found() and host_machine.system() != 'windows' - pre_args += '-DHAVE_PTHREAD' - if cc.has_function( - 'pthread_setaffinity_np', - dependencies : dep_thread, - prefix : '#include ', - args : '-D_GNU_SOURCE') - pre_args += '-DHAVE_PTHREAD_SETAFFINITY' + _zstd = get_option('zstd') + if _zstd != 'false' + dep_zstd = dependency('libzstd', required : _zstd == 'true') + if dep_zstd.found() + pre_args += '-DHAVE_ZSTD' + endif + else + dep_zstd = null_dep + endif + + dep_thread = dependency('threads') + if dep_thread.found() and host_machine.system() != 'windows' + pre_args += '-DHAVE_PTHREAD' + if cc.has_function( + 'pthread_setaffinity_np', + dependencies : dep_thread, + prefix : '#include ', + args : '-D_GNU_SOURCE') + pre_args += '-DHAVE_PTHREAD_SETAFFINITY' + endif + if cc.has_function( + 'pthread_setaffinity_np', + dependencies : dep_thread, + prefix : '#include ') + pre_args += '-DPTHREAD_SETAFFINITY_IN_NP_HEADER' + endif endif - if cc.has_function( - 'pthread_setaffinity_np', - dependencies : dep_thread, - prefix : '#include ') - pre_args += '-DPTHREAD_SETAFFINITY_IN_NP_HEADER' + if host_machine.system() != 'windows' + dep_expat = dependency('expat', fallback : ['expat', 'expat_dep']) + else + dep_expat = null_dep endif -endif -if host_machine.system() != 'windows' - dep_expat = dependency('expat', fallback : ['expat', 'expat_dep']) else + dep_zlib = null_dep + dep_zstd = null_dep + dep_thread = null_dep dep_expat = null_dep endif + # this only exists on linux so either this is linux and it will be found, or # it's not linux and wont dep_m = cc.find_library('m', required : false) @@ -1419,7 +1449,7 @@ endif dep_llvm = null_dep with_llvm = false -if _llvm != 'false' +if _llvm != 'false' and not ['horizon'].contains(host_machine.system()) dep_llvm = dependency( 'llvm', version : _llvm_version, diff --git a/meson_options.txt b/meson_options.txt index ab43150669b..349ae5efd27 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -24,7 +24,7 @@ option( value : ['auto'], choices : [ '', 'auto', 'x11', 'wayland', 'drm', 'surfaceless', 'haiku', 'android', - 'windows', + 'windows', 'switch', ], description : 'window systems to support. If this is set to `auto`, all platforms applicable will be enabled.' ) diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll index 7d7ee0c00ff..289e6da3e62 100644 --- a/src/compiler/glsl/glsl_lexer.ll +++ b/src/compiler/glsl/glsl_lexer.ll @@ -21,6 +21,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ + #include #include #include "util/strtod.h" @@ -174,7 +175,7 @@ literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state, else lval->n = (int)value; - if (is_long && !is_uint && base == 10 && value > (uint64_t)LLONG_MAX + 1) { + if (is_long && !is_uint && base == 10 && value > (uint64_t)INT64_MAX + 1) { /* Tries to catch unintentionally providing a negative value. */ _mesa_glsl_warning(lloc, state, "signed literal value `%s' is interpreted as %lld", diff --git a/src/egl/drivers/switch/egl_switch.c b/src/egl/drivers/switch/egl_switch.c new file mode 100644 index 00000000000..af56ca6fcef --- /dev/null +++ b/src/egl/drivers/switch/egl_switch.c @@ -0,0 +1,750 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2014 Adrián Arroyo Calle + * Copyright (C) 2018 Jules Blok + * Copyright (C) 2018-2019 fincs + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include + +#include "eglconfig.h" +#include "eglcontext.h" +#include "egldisplay.h" +#include "egldriver.h" +#include "eglcurrent.h" +#include "egllog.h" +#include "eglsurface.h" +#include "eglimage.h" +#include "egltypedefs.h" + +#include + +#include "target-helpers/inline_debug_helper.h" + +#include "nouveau/switch/nouveau_switch_public.h" + +#include "pipe/p_context.h" +#include "pipe/p_screen.h" +#include "pipe/p_state.h" + +#include "util/u_atomic.h" +#include "util/u_box.h" +#include "util/u_debug.h" +#include "util/format/u_format.h" +#include "util/u_inlines.h" +#include "util/u_memory.h" + +#include "state_tracker/st_api.h" +#include "state_tracker/st_gl_api.h" +#include "state_tracker/drm_driver.h" + +#include "mapi/glapi/glapi.h" + +#define NUM_BUFFERS 3 + +#ifdef DEBUG +# define TRACE(x...) _eglLog(_EGL_DEBUG, "egl_switch: " x) +# define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__) +#else +# define TRACE(x...) +# define CALLED() +#endif +#define ERROR(x...) _eglLog(_EGL_FATAL, "egl_switch: " x) + +_EGL_DRIVER_STANDARD_TYPECASTS(switch_egl) + +struct switch_egl_display +{ + struct st_manager *stmgr; + struct st_api *stapi; +}; + +struct switch_egl_config +{ + _EGLConfig base; + struct st_visual stvis; +}; + +struct switch_egl_context +{ + _EGLContext base; + struct st_context_iface *stctx; +}; + +struct switch_egl_surface +{ + _EGLSurface base; + struct st_framebuffer_iface *stfbi; + struct pipe_resource *attachments[ST_ATTACHMENT_COUNT]; + + NWindow* nw; + s32 cur_slot; + struct pipe_resource *buffers[NUM_BUFFERS]; + NvFence fences[NUM_BUFFERS]; +}; + +struct switch_framebuffer +{ + struct st_framebuffer_iface base; + struct switch_egl_display* display; + struct switch_egl_surface* surface; + struct pipe_resource template; +}; + +static inline struct switch_framebuffer * +switch_framebuffer(struct st_framebuffer_iface *stfbi) +{ + return (struct switch_framebuffer *)stfbi; +} + +//----------------------------------------------------------------------------- +// switch_framebuffer methods +//----------------------------------------------------------------------------- + +static uint32_t drifb_ID = 0; + +// Called via st_manager_flush_frontbuffer. Users of this function include: +// - st_context_flush with ST_FLUSH_FRONT +// - glFlush +// - glFinish +// We don't support rendering to the front buffer, so our implementation is dummy. +static bool +switch_st_framebuffer_flush_front(struct st_context_iface *stctx, struct st_framebuffer_iface *stfbi, enum st_attachment_type statt) +{ + return true; +} + +// Called via st_framebuffer_validate. +static bool +switch_st_framebuffer_validate(struct st_context_iface *stctx, struct st_framebuffer_iface *stfbi, + const enum st_attachment_type *statts, unsigned count, struct pipe_resource **out) +{ + struct switch_framebuffer *fb = switch_framebuffer(stfbi); + struct switch_egl_surface *surface = fb->surface; + struct pipe_screen *screen = stfbi->state_manager->screen; + enum st_attachment_type i; + CALLED(); + + for (i = 0; i < count; i++) + { + struct pipe_resource* res = surface->attachments[statts[i]]; + if (!res) + { + switch (statts[i]) + { + case ST_ATTACHMENT_BACK_LEFT: + { + Result rc = nwindowDequeueBuffer(surface->nw, &surface->cur_slot, NULL); + if (R_FAILED(rc)) fatalThrow(rc); + + // Use the dequeued buffer as the back buffer + res = surface->buffers[surface->cur_slot]; + break; + } + case ST_ATTACHMENT_DEPTH_STENCIL: + case ST_ATTACHMENT_ACCUM: + { + // Configure format/bind parameters + if (statts[i] == ST_ATTACHMENT_DEPTH_STENCIL) + { + fb->template.format = stfbi->visual->depth_stencil_format; + fb->template.bind = PIPE_BIND_DEPTH_STENCIL; + } else if (statts[i] == ST_ATTACHMENT_ACCUM) + { + fb->template.format = stfbi->visual->accum_format; + fb->template.bind = PIPE_BIND_RENDER_TARGET; + } + + // Create the requested resource + res = screen->resource_create(screen, &fb->template); + break; + } + default: + break; + } + + // Register the attachment for future calls + surface->attachments[statts[i]] = res; + } + pipe_resource_reference(&out[i], res); + } + + return true; +} + +// Called via st_manager_flush_swapbuffers, which itself is only used during glFinish. +// We don't actually want to swap the buffers during glFinish, so our implementation is dummy. +static bool +switch_st_framebuffer_flush_swapbuffers(struct st_context_iface *stctx, struct st_framebuffer_iface *stfbi) +{ + return true; +} + +//----------------------------------------------------------------------------- +// EGL driver methods +//----------------------------------------------------------------------------- + +static void +switch_egl_surface_cleanup(struct switch_egl_surface *surface) +{ + u32 i; + + for (i = 0; i < ST_ATTACHMENT_COUNT; i ++) + { + if (i == ST_ATTACHMENT_FRONT_LEFT || i == ST_ATTACHMENT_BACK_LEFT) + continue; + pipe_resource_reference(&surface->attachments[i], NULL); + } + + if (surface->nw) + { + if (surface->cur_slot >= 0) + nwindowCancelBuffer(surface->nw, surface->cur_slot, NULL); + nwindowReleaseBuffers(surface->nw); + } + + for (i = 0; i < NUM_BUFFERS; i ++) + pipe_resource_reference(&surface->buffers[i], NULL); + + if (surface->stfbi) + free(surface->stfbi); + + free(surface); +} + +// Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). +static _EGLSurface * +switch_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, void *native_window, const EGLint *attrib_list) +{ + struct switch_egl_surface *surface; + struct switch_framebuffer *fb; + struct switch_egl_display *display = switch_egl_display(dpy); + struct switch_egl_config *config = switch_egl_config(conf); + u32 width, height, i; + CALLED(); + + surface = (struct switch_egl_surface*) calloc(1, sizeof (*surface)); + if (!surface) + { + _eglError(EGL_BAD_ALLOC, "switch_create_window_surface: failed to allocate switch_egl_surface"); + return NULL; + } + + if (!_eglInitSurface(&surface->base, dpy, EGL_WINDOW_BIT, conf, attrib_list, native_window)) + goto cleanup; + + fb = (struct switch_framebuffer *) calloc(1, sizeof (*fb)); + if (!fb) + { + _eglError(EGL_BAD_ALLOC, "switch_create_window_surface: failed to allocate switch_framebuffer"); + goto cleanup; + } + + // Use the specified native window, and check its validity + surface->nw = (NWindow*)native_window; + if (!nwindowIsValid(surface->nw)) + { + _eglError(EGL_BAD_NATIVE_WINDOW, "switch_create_window_surface: not a valid native window reference"); + goto cleanup; + } + + // Allocate framebuffers and attach them to the native window + nwindowGetDimensions(surface->nw, &width, &height); + fb->display = display; + fb->surface = surface; + fb->template.target = PIPE_TEXTURE_RECT; + fb->template.format = config->stvis.color_format; + fb->template.width0 = (u16)width; + fb->template.height0 = (u16)height; + fb->template.depth0 = 1; + fb->template.array_size = 1; + fb->template.usage = PIPE_USAGE_DEFAULT; + fb->template.bind = PIPE_BIND_RENDER_TARGET; + for (i = 0; i < NUM_BUFFERS; i ++) + { + // Allocate a framebuffer + surface->fences[i].id = UINT32_MAX; + surface->buffers[i] = display->stmgr->screen->resource_create(display->stmgr->screen, &fb->template); + if (!surface->buffers[i]) + { + _eglError(EGL_BAD_ALLOC, "switch_create_window_surface: failed to allocate framebuffers"); + goto cleanup; + } + + // Retrieve the native graphic buffer struct associated with this framebuffer + NvGraphicBuffer grbuf; + int err = nouveau_switch_resource_get_buffer(surface->buffers[i], &grbuf); + if (err != 0) + { + _eglError(EGL_BAD_ALLOC, "switch_create_window_surface: nouveau_switch_resource_get_buffer failed"); + goto cleanup; + } + + // Attach the framebuffer to the native window + Result rc = nwindowConfigureBuffer(surface->nw, i, &grbuf); + if (R_FAILED(rc)) fatalThrow(rc); + } + + surface->stfbi = &fb->base; + surface->cur_slot = -1; + + // Setup the st_framebuffer_iface + fb->base.visual = &config->stvis; + fb->base.flush_front = switch_st_framebuffer_flush_front; + fb->base.validate = switch_st_framebuffer_validate; + fb->base.flush_swapbuffers = switch_st_framebuffer_flush_swapbuffers; + p_atomic_set(&fb->base.stamp, 0); + fb->base.ID = p_atomic_inc_return(&drifb_ID); + fb->base.state_manager = display->stmgr; + + return &surface->base; + +cleanup: + switch_egl_surface_cleanup(surface); + return NULL; +} + + +static _EGLSurface * +switch_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp, + _EGLConfig *conf, void *native_pixmap, const EGLint *attrib_list) +{ + CALLED(); + return NULL; +} + + +static _EGLSurface * +switch_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp, + _EGLConfig *conf, const EGLint *attrib_list) +{ + CALLED(); + return NULL; +} + + +static EGLBoolean +switch_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) +{ + struct switch_egl_surface* surface = switch_egl_surface(surf); + CALLED(); + + if (_eglPutSurface(surf)) + switch_egl_surface_cleanup(surface); + + return EGL_TRUE; +} + + +static EGLBoolean +switch_add_config(_EGLDisplay *dpy, EGLint *id, enum pipe_format colorfmt, enum pipe_format depthfmt) +{ + CALLED(); + + struct switch_egl_config* conf; + conf = (struct switch_egl_config*) calloc(1, sizeof (*conf)); + if (!conf) + return _eglError(EGL_BAD_ALLOC, "switch_add_config failed to alloc"); + + TRACE("Initializing config\n"); + _eglInitConfig(&conf->base, dpy, ++*id); + + // General configuration + conf->base.NativeRenderable = EGL_TRUE; + conf->base.SurfaceType = EGL_WINDOW_BIT; // we only support creating window surfaces + conf->base.RenderableType = EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT_KHR; + conf->base.Conformant = conf->base.RenderableType; + conf->base.MinSwapInterval = 0; + conf->base.MaxSwapInterval = INT32_MAX; + + // Color buffer configuration + conf->base.RedSize = util_format_get_component_bits(colorfmt, UTIL_FORMAT_COLORSPACE_RGB, 0); + conf->base.GreenSize = util_format_get_component_bits(colorfmt, UTIL_FORMAT_COLORSPACE_RGB, 1); + conf->base.BlueSize = util_format_get_component_bits(colorfmt, UTIL_FORMAT_COLORSPACE_RGB, 2); + conf->base.AlphaSize = util_format_get_component_bits(colorfmt, UTIL_FORMAT_COLORSPACE_RGB, 3); + conf->base.BufferSize = conf->base.RedSize+conf->base.GreenSize+conf->base.BlueSize+conf->base.AlphaSize; + + // Depth/stencil buffer configuration + if (depthfmt != PIPE_FORMAT_NONE) { + conf->base.DepthSize = util_format_get_component_bits(depthfmt, UTIL_FORMAT_COLORSPACE_ZS, 0); + conf->base.StencilSize = util_format_get_component_bits(depthfmt, UTIL_FORMAT_COLORSPACE_ZS, 1); + } + + // Visual + conf->stvis.buffer_mask = ST_ATTACHMENT_FRONT_LEFT_MASK | ST_ATTACHMENT_BACK_LEFT_MASK; + conf->stvis.color_format = colorfmt; + conf->stvis.depth_stencil_format = depthfmt; + conf->stvis.accum_format = PIPE_FORMAT_R16G16B16A16_FLOAT; + conf->stvis.render_buffer = ST_ATTACHMENT_BACK_LEFT_MASK; + + if (!_eglValidateConfig(&conf->base, EGL_FALSE)) { + _eglLog(_EGL_DEBUG, "Switch: failed to validate config"); + free(conf); + return EGL_FALSE; + } + + _eglLinkConfig(&conf->base); + return EGL_TRUE; +} + + +static EGLBoolean +switch_add_configs_for_visuals(_EGLDisplay *dpy) +{ + CALLED(); + + // List of supported color buffer formats + static const enum pipe_format colorfmts[] = { + PIPE_FORMAT_R8G8B8A8_UNORM, + //PIPE_FORMAT_R8G8B8X8_UNORM, + //PIPE_FORMAT_B5G6R5_UNORM, + }; + + // List of supported depth buffer formats + static const enum pipe_format depthfmts[] = { + PIPE_FORMAT_NONE, + PIPE_FORMAT_S8_UINT, + PIPE_FORMAT_Z16_UNORM, + PIPE_FORMAT_Z24X8_UNORM, + PIPE_FORMAT_Z24_UNORM_S8_UINT, + PIPE_FORMAT_Z32_FLOAT, + PIPE_FORMAT_Z32_FLOAT_S8X24_UINT, + }; + + // Add all combinations of color/depth buffer formats + EGLint config_id = 0; + EGLint i, j; + for (i = 0; i < sizeof(colorfmts)/sizeof(colorfmts[0]); i ++) { + for (j = 0; j < sizeof(depthfmts)/sizeof(depthfmts[0]); j ++) { + EGLBoolean rc = switch_add_config(dpy, &config_id, colorfmts[i], depthfmts[j]); + if (!rc) + return rc; + } + } + + return EGL_TRUE; +} + +// Called from st_api_create_context. This is only ever used for detecting +// whether the ST_MANAGER_BROKEN_INVALIDATE workaround is required. +static int +switch_st_get_param(struct st_manager *stmgr, enum st_manager_param param) +{ + return 0; +} + +static EGLBoolean +switch_initialize(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct switch_egl_display *display; + struct st_manager *stmgr; + struct pipe_screen *screen; + CALLED(); + + if (!switch_add_configs_for_visuals(dpy)) + return EGL_FALSE; + + display = (struct switch_egl_display*) calloc(1, sizeof (*display)); + if (!display) { + _eglError(EGL_BAD_ALLOC, "switch_initialize"); + return EGL_FALSE; + } + dpy->DriverData = display; + dpy->Version = 14; + + dpy->ClientAPIs = 0; + if (_eglIsApiValid(EGL_OPENGL_API)) + dpy->ClientAPIs |= EGL_OPENGL_BIT; + if (_eglIsApiValid(EGL_OPENGL_ES_API)) + dpy->ClientAPIs |= EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT_KHR; + + dpy->Extensions.KHR_create_context = EGL_TRUE; + dpy->Extensions.KHR_surfaceless_context = EGL_TRUE; + + stmgr = CALLOC_STRUCT(st_manager); + if (!stmgr) { + _eglError(EGL_BAD_ALLOC, "switch_initialize"); + return EGL_FALSE; + } + + stmgr->get_param = switch_st_get_param; + + // Create nouveau screen + TRACE("Creating nouveau screen\n"); + screen = nouveau_switch_screen_create(); + if (!screen) + { + TRACE("Failed to create nouveau screen\n"); + return EGL_FALSE; + } + + // Inject optional trace/debug/etc wrappers + TRACE("Wrapping screen\n"); + stmgr->screen = debug_screen_wrap(screen); + + display->stmgr = stmgr; + display->stapi = st_gl_api_create(); + return EGL_TRUE; +} + + +static EGLBoolean +switch_terminate(_EGLDriver* drv, _EGLDisplay* dpy) +{ + struct switch_egl_display *display = switch_egl_display(dpy); + CALLED(); + + // Release all non-current Context/Surfaces + _eglReleaseDisplayResources(drv, dpy); + + _eglCleanupDisplay(dpy); + + display->stapi->destroy(display->stapi); + + display->stmgr->screen->destroy(display->stmgr->screen); + free(display->stmgr); + free(display); + + return EGL_TRUE; +} + + +static _EGLContext* +switch_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, + _EGLContext *share_list, const EGLint *attrib_list) +{ + struct switch_egl_context *context; + struct switch_egl_display *display = switch_egl_display(dpy); + struct switch_egl_config *config = switch_egl_config(conf); + CALLED(); + + context = (struct switch_egl_context*) calloc(1, sizeof (*context)); + if (!context) { + _eglError(EGL_BAD_ALLOC, "switch_create_context"); + return NULL; + } + + if (!_eglInitContext(&context->base, dpy, conf, attrib_list)) + goto cleanup; + + struct st_context_attribs attribs; + memset(&attribs, 0, sizeof(attribs)); + + attribs.major = context->base.ClientMajorVersion; + attribs.minor = context->base.ClientMinorVersion; + attribs.visual = config->stvis; + + switch (eglQueryAPI()) { + case EGL_OPENGL_API: + switch (context->base.Profile) { + case EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR: + /* There are no profiles before OpenGL 3.2. The + * EGL_KHR_create_context spec says: + * + * "If the requested OpenGL version is less than 3.2, + * EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR is ignored and the functionality + * of the context is determined solely by the requested version.." + */ + + if (attribs.major > 3 || (attribs.major == 3 && attribs.minor >= 2)) { + attribs.profile = ST_PROFILE_OPENGL_CORE; + break; + } + /* fall-through */ + case EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR: + attribs.profile = ST_PROFILE_DEFAULT; + break; + default: + _eglError(EGL_BAD_CONFIG, "switch_create_context"); + goto cleanup; + } + break; + case EGL_OPENGL_ES_API: + switch (context->base.ClientMajorVersion) { + case 1: + attribs.profile = ST_PROFILE_OPENGL_ES1; + break; + case 2: + case 3: // ST_PROFILE_OPENGL_ES2 is used for OpenGL ES 3.x too + attribs.profile = ST_PROFILE_OPENGL_ES2; + break; + default: + _eglError(EGL_BAD_CONFIG, "switch_create_context"); + goto cleanup; + } + break; + default: + _eglError(EGL_BAD_CONFIG, "switch_create_context"); + goto cleanup; + } + + enum st_context_error error; + context->stctx = display->stapi->create_context(display->stapi, display->stmgr, &attribs, &error, NULL); + if (error != ST_CONTEXT_SUCCESS) { + _eglError(EGL_BAD_MATCH, "switch_create_context"); + goto cleanup; + } + + return &context->base; + +cleanup: + free(context); + return NULL; +} + + +static EGLBoolean +switch_destroy_context(_EGLDriver* drv, _EGLDisplay *disp, _EGLContext* ctx) +{ + struct switch_egl_context* context = switch_egl_context(ctx); + CALLED(); + + if (_eglPutContext(ctx)) + { + context->stctx->destroy(context->stctx); + free(context); + ctx = NULL; + } + return EGL_TRUE; +} + + +static EGLBoolean +switch_make_current(_EGLDriver* drv, _EGLDisplay* dpy, _EGLSurface *dsurf, + _EGLSurface *rsurf, _EGLContext *ctx) +{ + struct switch_egl_display* disp = switch_egl_display(dpy); + struct switch_egl_context* cont = switch_egl_context(ctx); + struct switch_egl_surface* draw_surf = switch_egl_surface(dsurf); + struct switch_egl_surface* read_surf = switch_egl_surface(rsurf); + CALLED(); + + _EGLContext *old_ctx; + _EGLSurface *old_dsurf, *old_rsurf; + + if (!_eglBindContext(ctx, dsurf, rsurf, &old_ctx, &old_dsurf, &old_rsurf)) + return EGL_FALSE; + + EGLBoolean ret = disp->stapi->make_current(disp->stapi, cont ? cont->stctx : NULL, + draw_surf ? draw_surf->stfbi : NULL, read_surf ? read_surf->stfbi : NULL); + + if (old_ctx) { + if (old_dsurf) { + switch_destroy_surface(drv, dpy, old_dsurf); + } + if (old_rsurf) { + switch_destroy_surface(drv, dpy, old_rsurf); + } + switch_destroy_context(drv, dpy, old_ctx); + } + + return ret; +} + + +static EGLBoolean +switch_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval) +{ + CALLED(); + struct switch_egl_surface* surface = switch_egl_surface(surf); + + nwindowSetSwapInterval(surface->nw, interval); + return EGL_TRUE; +} + + +static EGLBoolean +switch_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) +{ + CALLED(); + struct switch_egl_surface* surface = switch_egl_surface(surf); + struct switch_egl_context* context = switch_egl_context(surface->base.CurrentContext); + + if (surface->cur_slot < 0) { + TRACE("Nothing to do\n"); + return EGL_TRUE; + } + + TRACE("Flushing context\n"); + context->stctx->flush(context->stctx, ST_FLUSH_END_OF_FRAME, NULL, NULL, NULL); + + NvMultiFence mf = {0}; + NvFence fence; + struct pipe_resource *old_back = surface->attachments[ST_ATTACHMENT_BACK_LEFT]; + fence.id = nouveau_switch_resource_get_syncpoint(old_back, &fence.value); + if ((int)fence.id >= 0) { + NvFence* surf_fence = &surface->fences[surface->cur_slot]; + if (surf_fence->id != fence.id || surf_fence->value != fence.value) { + TRACE("Using fence: {%d,%u}\n", (int)fence.id, fence.value); + *surf_fence = fence; + nvMultiFenceCreate(&mf, &fence); + } + } + + TRACE("Queuing buffer\n"); + Result rc = nwindowQueueBuffer(surface->nw, surface->cur_slot, &mf); + if (R_FAILED(rc)) fatalThrow(rc); + + // Update framebuffer state + surface->cur_slot = -1; + surface->attachments[ST_ATTACHMENT_BACK_LEFT] = NULL; + surface->attachments[ST_ATTACHMENT_FRONT_LEFT] = old_back; + p_atomic_inc(&surface->stfbi->stamp); + return EGL_TRUE; +} + + +/* + * Called from eglGetProcAddress() via drv->API.GetProcAddress(). + */ +static _EGLProc +switch_get_proc_address(_EGLDriver *drv, const char *procname) +{ + return _glapi_get_proc_address(procname); +} + + +/** + * This is the main entrypoint into the driver, called by libEGL. + * Create a new _EGLDriver object and init its dispatch table. + */ +void +_eglInitDriver(_EGLDriver *driver) +{ + CALLED(); + + driver->API.Initialize = switch_initialize; + driver->API.Terminate = switch_terminate; + driver->API.CreateContext = switch_create_context; + driver->API.DestroyContext = switch_destroy_context; + driver->API.MakeCurrent = switch_make_current; + driver->API.CreateWindowSurface = switch_create_window_surface; + driver->API.CreatePixmapSurface = switch_create_pixmap_surface; + driver->API.CreatePbufferSurface = switch_create_pbuffer_surface; + driver->API.DestroySurface = switch_destroy_surface; + driver->API.SwapInterval = switch_swap_interval; + driver->API.SwapBuffers = switch_swap_buffers; + driver->API.GetProcAddress = switch_get_proc_address; +} diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index 29be4268025..aa9d02fe34c 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -39,21 +39,23 @@ /* a fallback thread info to guarantee that every thread always has one */ static _EGLThreadInfo dummy_thread; -static mtx_t _egl_TSDMutex = _MTX_INITIALIZER_NP; -static EGLBoolean _egl_TSDInitialized; -static tss_t _egl_TSD; -static void _eglDestroyThreadInfo(_EGLThreadInfo *t); #ifdef USE_ELF_TLS static __thread const _EGLThreadInfo *_egl_TLS __attribute__ ((tls_model("initial-exec"))); +#else +static mtx_t _egl_TSDMutex = _MTX_INITIALIZER_NP; +static EGLBoolean _egl_TSDInitialized; +static tss_t _egl_TSD; +static void (*_egl_FreeTSD)(_EGLThreadInfo *); #endif static inline void _eglSetTSD(const _EGLThreadInfo *t) { - tss_set(_egl_TSD, (void *) t); #ifdef USE_ELF_TLS _egl_TLS = t; +#else + tss_set(_egl_TSD, (void *) t); #endif } @@ -68,6 +70,7 @@ static inline _EGLThreadInfo *_eglGetTSD(void) static inline void _eglFiniTSD(void) { +#ifndef USE_ELF_TLS mtx_lock(&_egl_TSDMutex); if (_egl_TSDInitialized) { _EGLThreadInfo *t = _eglGetTSD(); @@ -77,10 +80,12 @@ static inline void _eglFiniTSD(void) tss_delete(_egl_TSD); } mtx_unlock(&_egl_TSDMutex); +#endif } static inline EGLBoolean _eglInitTSD() { +#ifndef USE_ELF_TLS if (!_egl_TSDInitialized) { mtx_lock(&_egl_TSDMutex); @@ -96,7 +101,7 @@ static inline EGLBoolean _eglInitTSD() mtx_unlock(&_egl_TSDMutex); } - +#endif return EGL_TRUE; } diff --git a/src/egl/main/egldevice.c b/src/egl/main/egldevice.c index 415b0508888..d7665cb6174 100644 --- a/src/egl/main/egldevice.c +++ b/src/egl/main/egldevice.c @@ -25,6 +25,7 @@ * **************************************************************************/ +#include #ifdef HAVE_LIBDRM #include #endif diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index f6e85c79aa9..582e9e3e06c 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -73,6 +73,7 @@ static const struct { { _EGL_PLATFORM_DRM, "drm" }, { _EGL_PLATFORM_ANDROID, "android" }, { _EGL_PLATFORM_HAIKU, "haiku" }, + { _EGL_PLATFORM_SWITCH, "switch" }, { _EGL_PLATFORM_SURFACELESS, "surfaceless" }, { _EGL_PLATFORM_DEVICE, "device" }, }; @@ -382,7 +383,7 @@ EGLBoolean _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *disp) { _EGLResource *list = disp->ResourceLists[type]; - + if (!res) return EGL_FALSE; diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 02ac4fb9a9d..2d8cff739f0 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -49,6 +49,7 @@ enum _egl_platform_type { _EGL_PLATFORM_DRM, _EGL_PLATFORM_ANDROID, _EGL_PLATFORM_HAIKU, + _EGL_PLATFORM_SWITCH, _EGL_PLATFORM_SURFACELESS, _EGL_PLATFORM_DEVICE, diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 6811048bdf7..3f67dac321e 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -135,7 +135,11 @@ EGLBoolean _eglPointerIsDereferencable(void *p) { uintptr_t addr = (uintptr_t) p; +#ifndef __SWITCH__ const long page_size = getpagesize(); +#else + const long page_size = 0x1000; +#endif #ifdef HAVE_MINCORE unsigned char valid = 0; diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index fc3b6bd62a7..4db07f65918 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -31,6 +31,7 @@ #ifndef EGLGLOBALS_INCLUDED #define EGLGLOBALS_INCLUDED +#include #include #include "c11/threads.h" diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c index 6a91952577f..5aed9b0588b 100644 --- a/src/egl/main/egllog.c +++ b/src/egl/main/egllog.c @@ -56,6 +56,10 @@ #endif /* HAVE_ANDROID_PLATFORM */ +#ifdef HAVE_SWITCH_PLATFORM +#include +#endif + #define MAXSTRING 1000 #define FALLBACK_LOG_LEVEL _EGL_WARNING @@ -85,7 +89,7 @@ static const char *level_strings[] = { static void _eglDefaultLogger(EGLint level, const char *msg) { -#ifdef HAVE_ANDROID_PLATFORM +#if defined(HAVE_ANDROID_PLATFORM) static const int egl2alog[] = { [_EGL_FATAL] = ANDROID_LOG_ERROR, [_EGL_WARNING] = ANDROID_LOG_WARN, @@ -94,6 +98,9 @@ _eglDefaultLogger(EGLint level, const char *msg) }; LOG_PRI(egl2alog[level], LOG_TAG, "%s", msg); #else +#if defined(HAVE_SWITCH_PLATFORM) + svcOutputDebugString(msg, strlen(msg) + 1); +#endif fprintf(stderr, "libEGL %s: %s\n", level_strings[level], msg); #endif /* HAVE_ANDROID_PLATFORM */ } diff --git a/src/egl/meson.build b/src/egl/meson.build index 12d74ec37fa..47fdfa74bca 100644 --- a/src/egl/meson.build +++ b/src/egl/meson.build @@ -22,6 +22,7 @@ inc_egl = include_directories('.', 'main') inc_egl_dri2 = include_directories('drivers/dri2') c_args_for_egl = [] +objs_for_egl = [] link_for_egl = [] deps_for_egl = [] incs_for_egl = [inc_include, inc_src, inc_egl] @@ -137,6 +138,20 @@ elif with_platform_haiku files_egl += files('drivers/haiku/egl_haiku.cpp') link_for_egl += libgl deps_for_egl += cpp.find_library('be') +elif with_platform_switch + incs_for_egl += [inc_gallium, inc_gallium_aux, inc_gallium_winsys, inc_mesa] + files_egl += files('drivers/switch/egl_switch.c') + objs_for_egl += [ + libmesa_common.extract_all_objects(), + libmesa_gallium.extract_all_objects(), + libglsl.extract_all_objects(), + libglcpp.extract_all_objects(), + libcompiler.extract_all_objects(), + libgallium.extract_all_objects(), + libgalliumvl_stub.extract_all_objects(), + libnouveauwinsys.extract_all_objects(), + libnouveau.extract_all_objects() + ] endif if cc.has_function('mincore') @@ -158,7 +173,11 @@ else ) endif -libegl = shared_library( +if not with_platform_switch + link_for_egl += libmesa_util +endif + +libegl = library( egl_lib_name, files_egl, c_args : [ @@ -167,6 +186,7 @@ libegl = shared_library( '-D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_@0@'.format(egl_native_platform.to_upper()), ], include_directories : incs_for_egl, + objects : objs_for_egl, link_with : [link_for_egl, libglapi], link_args : [ld_args_bsymbolic, ld_args_gc_sections], dependencies : [deps_for_egl, dep_dl, dep_libdrm, dep_clock, dep_thread, idep_mesautil], diff --git a/src/gallium/auxiliary/driver_ddebug/dd_util.h b/src/gallium/auxiliary/driver_ddebug/dd_util.h index 4c77cbcc163..0996525b083 100644 --- a/src/gallium/auxiliary/driver_ddebug/dd_util.h +++ b/src/gallium/auxiliary/driver_ddebug/dd_util.h @@ -38,7 +38,7 @@ #include "util/u_string.h" #include "pipe/p_config.h" -#if defined(PIPE_OS_UNIX) +#if defined(PIPE_OS_UNIX) || defined(PIPE_OS_SWITCH) #include #include #elif defined(PIPE_OS_WINDOWS) diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index 1e2b948e348..b9a7ce1b336 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -1014,7 +1014,7 @@ static void strcat_without_spaces(char *dst, const char *src) } -#ifdef PIPE_OS_WINDOWS +#if defined(PIPE_OS_WINDOWS) || defined(PIPE_OS_SWITCH) #define W_OK 0 static int access(const char *pathname, int mode) @@ -1022,6 +1022,9 @@ access(const char *pathname, int mode) /* no-op */ return 0; } +#endif + +#if defined(PIPE_OS_WINDOWS) #define PATH_SEP "\\" diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h index f2629c5ffe5..7f5718e567f 100644 --- a/src/gallium/auxiliary/os/os_thread.h +++ b/src/gallium/auxiliary/os/os_thread.h @@ -117,6 +117,8 @@ pipe_semaphore_wait(pipe_semaphore *sema) * Thread-specific data. */ +#if !defined(GLX_USE_TLS) + typedef struct { tss_t key; int initMagic; @@ -155,7 +157,7 @@ pipe_tsd_set(pipe_tsd *tsd, void *value) } } - +#endif /* * Thread statistics. diff --git a/src/gallium/auxiliary/target-helpers/inline_debug_helper.h b/src/gallium/auxiliary/target-helpers/inline_debug_helper.h index 08aea330710..eaf07647b5f 100644 --- a/src/gallium/auxiliary/target-helpers/inline_debug_helper.h +++ b/src/gallium/auxiliary/target-helpers/inline_debug_helper.h @@ -27,6 +27,7 @@ extern "C" { static inline struct pipe_screen * debug_screen_wrap(struct pipe_screen *screen) { +#ifdef DEBUG screen = ddebug_screen_create(screen); screen = rbug_screen_create(screen); screen = trace_screen_create(screen); @@ -34,6 +35,7 @@ debug_screen_wrap(struct pipe_screen *screen) if (debug_get_bool_option("GALLIUM_TESTS", FALSE)) util_run_tests(screen); +#endif return screen; } diff --git a/src/gallium/auxiliary/util/u_network.c b/src/gallium/auxiliary/util/u_network.c index 31139f2983f..47ceca7cf1c 100644 --- a/src/gallium/auxiliary/util/u_network.c +++ b/src/gallium/auxiliary/util/u_network.c @@ -9,7 +9,7 @@ # include # include # include -#elif defined(PIPE_OS_UNIX) +#elif defined(PIPE_OS_UNIX) || defined(PIPE_OS_SWITCH) # include # include # include diff --git a/src/gallium/auxiliary/util/u_tests.c b/src/gallium/auxiliary/util/u_tests.c index 00f75906173..19dce75af52 100644 --- a/src/gallium/auxiliary/util/u_tests.c +++ b/src/gallium/auxiliary/util/u_tests.c @@ -587,7 +587,7 @@ test_sync_file_fences(struct pipe_context *ctx) pass = pass && screen->fence_finish(screen, NULL, final_fence, 0); /* Cleanup. */ -#ifndef PIPE_OS_WINDOWS +#if !defined(PIPE_OS_WINDOWS) && !defined(PIPE_OS_SWITCH) if (buf_fd >= 0) close(buf_fd); if (tex_fd >= 0) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp index c65853578f6..f89962d1afa 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp @@ -1305,9 +1305,11 @@ nv50_ir_generate_code(struct nv50_ir_prog_info *info) prog->optLevel = info->optLevel; switch (info->bin.sourceRep) { +#ifndef __SWITCH__ case PIPE_SHADER_IR_NIR: ret = prog->makeFromNIR(info) ? 0 : -2; break; +#endif case PIPE_SHADER_IR_TGSI: ret = prog->makeFromTGSI(info) ? 0 : -2; break; diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp index b6e35dd0ee4..e91a2de6d44 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_emit_nvc0.cpp @@ -24,6 +24,8 @@ namespace nv50_ir { +#ifndef __SWITCH__ + // Argh, all these assertions ... class CodeEmitterNVC0 : public CodeEmitter @@ -3535,4 +3537,6 @@ TargetNVC0::getCodeEmitter(Program::Type type) return createCodeEmitterNVC0(type); } +#endif + } // namespace nv50_ir diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_target.cpp index 5c6d0570ae2..c2c2fce1699 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_target.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_target.cpp @@ -153,6 +153,7 @@ Target *Target::create(unsigned int chipset) case 0x120: case 0x130: return getTargetGM107(chipset); +#ifndef __SWITCH__ case 0xc0: case 0xd0: case 0xe0: @@ -164,6 +165,7 @@ Target *Target::create(unsigned int chipset) case 0x90: case 0xa0: return getTargetNV50(chipset); +#endif default: ERROR("unsupported target: NV%x\n", chipset); return 0; diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp index 60134b445db..0274338e10f 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp @@ -24,11 +24,15 @@ namespace nv50_ir { +#ifndef __SWITCH__ + Target *getTargetNVC0(unsigned int chipset) { return new TargetNVC0(chipset); } +#endif + TargetNVC0::TargetNVC0(unsigned int card) : Target(card < 0x110, false, card >= 0xe4) { diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.h index 2077207bb23..87d30720794 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.h +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.h @@ -40,7 +40,9 @@ public: void initProps(const struct opProperties *props, int size); +#ifndef __SWITCH__ virtual CodeEmitter *getCodeEmitter(Program::Type); +#endif CodeEmitter *createCodeEmitterNVC0(Program::Type); CodeEmitter *createCodeEmitterGK110(Program::Type); diff --git a/src/gallium/drivers/nouveau/nouveau_debug.h b/src/gallium/drivers/nouveau/nouveau_debug.h index 546a4ad0af3..9bd2046914d 100644 --- a/src/gallium/drivers/nouveau/nouveau_debug.h +++ b/src/gallium/drivers/nouveau/nouveau_debug.h @@ -16,7 +16,7 @@ #define NOUVEAU_DEBUG 0 #define NOUVEAU_ERR(fmt, args...) \ - fprintf(stderr, "%s:%d - " fmt, __FUNCTION__, __LINE__, ##args) + debug_printf("%s:%d - " fmt, __FUNCTION__, __LINE__, ##args) #define NOUVEAU_DBG(ch, args...) \ if ((NOUVEAU_DEBUG) & (NOUVEAU_DEBUG_##ch)) \ diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index de9cce3812a..22fdb9f8ccd 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -92,18 +92,12 @@ nouveau_screen_fence_finish(struct pipe_screen *screen, struct nouveau_bo * nouveau_screen_bo_from_handle(struct pipe_screen *pscreen, struct winsys_handle *whandle, - unsigned *out_stride) + unsigned *out_stride, unsigned *out_offset) { struct nouveau_device *dev = nouveau_screen(pscreen)->device; struct nouveau_bo *bo = 0; int ret; - if (whandle->offset != 0) { - debug_printf("%s: attempt to import unsupported winsys offset %d\n", - __FUNCTION__, whandle->offset); - return NULL; - } - if (whandle->type != WINSYS_HANDLE_TYPE_SHARED && whandle->type != WINSYS_HANDLE_TYPE_FD) { debug_printf("%s: attempt to import unsupported handle type %d\n", @@ -123,6 +117,7 @@ nouveau_screen_bo_from_handle(struct pipe_screen *pscreen, } *out_stride = whandle->stride; + *out_offset = whandle->offset; return bo; } @@ -131,9 +126,11 @@ bool nouveau_screen_bo_get_handle(struct pipe_screen *pscreen, struct nouveau_bo *bo, unsigned stride, + unsigned offset, struct winsys_handle *whandle) { whandle->stride = stride; + whandle->offset = offset; if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) { return nouveau_bo_name_get(bo, &whandle->handle) == 0; @@ -163,9 +160,11 @@ nouveau_disk_cache_create(struct nouveau_screen *screen) _mesa_sha1_final(&ctx, sha1); disk_cache_format_hex_id(cache_id, sha1, 20 * 2); +#ifndef __SWITCH__ if (screen->prefer_nir) driver_flags |= NOUVEAU_SHADER_CACHE_FLAGS_IR_NIR; else +#endif driver_flags |= NOUVEAU_SHADER_CACHE_FLAGS_IR_TGSI; screen->disk_shader_cache = @@ -188,7 +187,11 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) if (nv_dbg) nouveau_mesa_debug = atoi(nv_dbg); +#ifndef __SWITCH__ screen->prefer_nir = debug_get_bool_option("NV50_PROG_USE_NIR", false); +#else + screen->prefer_nir = false; +#endif screen->force_enable_cl = debug_get_bool_option("NOUVEAU_ENABLE_CL", false); if (screen->force_enable_cl) glsl_type_singleton_init_or_ref(); @@ -225,17 +228,23 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) ret = nouveau_object_new(&dev->object, 0, NOUVEAU_FIFO_CHANNEL_CLASS, data, size, &screen->channel); - if (ret) + if (ret) { + debug_printf("nouveau_object_new: failed with %d\n", ret); return ret; + } ret = nouveau_client_new(screen->device, &screen->client); - if (ret) + if (ret) { + debug_printf("nouveau_client_new: failed with %d\n", ret); return ret; + } ret = nouveau_pushbuf_new(screen->client, screen->channel, 4, 512 * 1024, 1, &screen->pushbuf); - if (ret) + if (ret) { + debug_printf("nouveau_pushbuf_new: failed with %d\n", ret); return ret; + } /* getting CPU time first appears to be more accurate */ screen->cpu_gpu_time_delta = os_time_get(); @@ -282,8 +291,6 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) void nouveau_screen_fini(struct nouveau_screen *screen) { - int fd = screen->drm->fd; - if (screen->force_enable_cl) glsl_type_singleton_decref(); @@ -297,7 +304,6 @@ nouveau_screen_fini(struct nouveau_screen *screen) nouveau_device_del(&screen->device); nouveau_drm_del(&screen->drm); - close(fd); disk_cache_destroy(screen->disk_shader_cache); } diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h index 40464225c75..b6785a7f2bf 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.h +++ b/src/gallium/drivers/nouveau/nouveau_screen.h @@ -137,11 +137,12 @@ bool nouveau_screen_bo_get_handle(struct pipe_screen *pscreen, struct nouveau_bo *bo, unsigned stride, + unsigned offset, struct winsys_handle *whandle); struct nouveau_bo * nouveau_screen_bo_from_handle(struct pipe_screen *pscreen, struct winsys_handle *whandle, - unsigned *out_stride); + unsigned *out_stride, unsigned *out_offset); int nouveau_screen_init(struct nouveau_screen *, struct nouveau_device *); diff --git a/src/gallium/drivers/nouveau/nouveau_vp3_video.c b/src/gallium/drivers/nouveau/nouveau_vp3_video.c index b28d31e0079..a5027515399 100644 --- a/src/gallium/drivers/nouveau/nouveau_vp3_video.c +++ b/src/gallium/drivers/nouveau/nouveau_vp3_video.c @@ -20,10 +20,10 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include #include #include #include +#include #include @@ -293,7 +293,7 @@ nouveau_vp3_load_firmware(struct nouveau_vp3_decoder *dec, if (nouveau_bo_map(dec->fw_bo, NOUVEAU_BO_WR, dec->client)) return 1; - fd = open(path, O_RDONLY | O_CLOEXEC); + fd = open(path, O_RDONLY); if (fd < 0) { fprintf(stderr, "opening firmware file %s failed: %m\n", path); return 1; @@ -347,8 +347,7 @@ nouveau_vp3_load_firmware(struct nouveau_vp3_decoder *dec, default: return 1; } - munmap(dec->fw_bo->map, dec->fw_bo->size); - dec->fw_bo->map = NULL; + nouveau_bo_unmap(dec->fw_bo); return 0; } diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h index e0ed0af3eaa..3a686bd8f6c 100644 --- a/src/gallium/drivers/nouveau/nouveau_winsys.h +++ b/src/gallium/drivers/nouveau/nouveau_winsys.h @@ -6,7 +6,6 @@ #include "pipe/p_defines.h" -#include "drm-uapi/drm.h" #include #ifndef NV04_PFIFO_MAX_PACKET_LEN diff --git a/src/gallium/drivers/nouveau/nv30/nv30_miptree.c b/src/gallium/drivers/nouveau/nv30/nv30_miptree.c index e4ed0dbd2a8..231e06c2048 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_miptree.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_miptree.c @@ -52,14 +52,15 @@ nv30_miptree_get_handle(struct pipe_screen *pscreen, struct winsys_handle *handle) { struct nv30_miptree *mt = nv30_miptree(pt); - unsigned stride; + unsigned stride, offset; if (!mt || !mt->base.bo) return false; stride = mt->level[0].pitch; + offset = mt->level[0].offset; - return nouveau_screen_bo_get_handle(pscreen, mt->base.bo, stride, handle); + return nouveau_screen_bo_get_handle(pscreen, mt->base.bo, stride, offset, handle); } static void @@ -513,7 +514,7 @@ nv30_miptree_from_handle(struct pipe_screen *pscreen, struct winsys_handle *handle) { struct nv30_miptree *mt; - unsigned stride; + unsigned stride, offset; /* only supports 2D, non-mipmapped textures for the moment */ if ((tmpl->target != PIPE_TEXTURE_2D && @@ -527,7 +528,7 @@ nv30_miptree_from_handle(struct pipe_screen *pscreen, if (!mt) return NULL; - mt->base.bo = nouveau_screen_bo_from_handle(pscreen, handle, &stride); + mt->base.bo = nouveau_screen_bo_from_handle(pscreen, handle, &stride, &offset); if (mt->base.bo == NULL) { FREE(mt); return NULL; @@ -539,7 +540,7 @@ nv30_miptree_from_handle(struct pipe_screen *pscreen, mt->base.base.screen = pscreen; mt->uniform_pitch = stride; mt->level[0].pitch = mt->uniform_pitch; - mt->level[0].offset = 0; + mt->level[0].offset = offset; /* no need to adjust bo reference count */ return &mt->base.base; diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c index c4b514cfa61..5c8d300cfe4 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c @@ -23,7 +23,6 @@ * */ -#include #include #include "util/format/u_format.h" #include "util/format/u_format_s3tc.h" diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c index 400ce6c9326..6248e369116 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c @@ -184,16 +184,18 @@ nv50_miptree_get_handle(struct pipe_screen *pscreen, struct winsys_handle *whandle) { struct nv50_miptree *mt = nv50_miptree(pt); - unsigned stride; + unsigned stride, offset; if (!mt || !mt->base.bo) return false; stride = mt->level[0].pitch; + offset = mt->level[0].offset; return nouveau_screen_bo_get_handle(pscreen, mt->base.bo, stride, + offset, whandle); } @@ -403,7 +405,7 @@ nv50_miptree_from_handle(struct pipe_screen *pscreen, struct winsys_handle *whandle) { struct nv50_miptree *mt; - unsigned stride; + unsigned stride, offset; /* only supports 2D, non-mipmapped textures for the moment */ if ((templ->target != PIPE_TEXTURE_2D && @@ -417,7 +419,7 @@ nv50_miptree_from_handle(struct pipe_screen *pscreen, if (!mt) return NULL; - mt->base.bo = nouveau_screen_bo_from_handle(pscreen, whandle, &stride); + mt->base.bo = nouveau_screen_bo_from_handle(pscreen, whandle, &stride, &offset); if (mt->base.bo == NULL) { FREE(mt); return NULL; @@ -430,7 +432,7 @@ nv50_miptree_from_handle(struct pipe_screen *pscreen, pipe_reference_init(&mt->base.base.reference, 1); mt->base.base.screen = pscreen; mt->level[0].pitch = stride; - mt->level[0].offset = 0; + mt->level[0].offset = offset; mt->level[0].tile_mode = mt->base.bo->config.nv50.tile_mode; NOUVEAU_DRV_STAT(nouveau_screen(pscreen), tex_obj_current_count, 1); diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c index e61d00c0b42..81009059d0b 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c @@ -21,7 +21,6 @@ */ #include -#include #include #include "util/format/u_format.h" #include "util/format/u_format_s3tc.h" diff --git a/src/gallium/drivers/nouveau/nv50/nv84_video.c b/src/gallium/drivers/nouveau/nv50/nv84_video.c index 0b5ebd48cc9..60676d0ac8f 100644 --- a/src/gallium/drivers/nouveau/nv50/nv84_video.c +++ b/src/gallium/drivers/nouveau/nv50/nv84_video.c @@ -20,7 +20,6 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include #include #include #include @@ -34,7 +33,7 @@ static int nv84_copy_firmware(const char *path, void *dest, ssize_t len) { - int fd = open(path, O_RDONLY | O_CLOEXEC); + int fd = open(path, O_RDONLY); ssize_t r; if (fd < 0) { fprintf(stderr, "opening firmware file %s failed: %m\n", path); @@ -88,8 +87,7 @@ nv84_load_firmwares(struct nouveau_device *dev, struct nv84_decoder *dec, ret = nv84_copy_firmware(fw1, fw->map, size1); if (fw2 && !ret) ret = nv84_copy_firmware(fw2, fw->map + dec->vp_fw2_offset, size2); - munmap(fw->map, fw->size); - fw->map = NULL; + nouveau_bo_unmap(fw); if (!ret) return fw; error: diff --git a/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c b/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c index f1cdf168ed4..eb09bbc5ca1 100644 --- a/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c +++ b/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c @@ -21,7 +21,6 @@ */ #include "nv50/nv98_video.h" -#include #if NOUVEAU_VP3_DEBUG_FENCE static void dump_comm_vp(struct nouveau_vp3_decoder *dec, struct comm *comm, u32 comm_seq, @@ -50,8 +49,7 @@ static void dump_comm_vp(struct nouveau_vp3_decoder *dec, struct comm *comm, u32 for (i = 0; i < comm->byte_ofs + slice_size; i += 0x10) { debug_printf("%05x: %08x %08x %08x %08x\n", i, map[i/4], map[i/4+1], map[i/4+2], map[i/4+3]); } - munmap(inter_bo->map, inter_bo->size); - inter_bo->map = NULL; + nouveau_bo_unmap(inter_bo); } assert((comm->pvp_stage & 0xff) == 0xff); } diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c index 32aa82d168c..4cbe3cb8184 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c @@ -587,9 +587,11 @@ nvc0_program_translate(struct nvc0_program *prog, uint16_t chipset, case PIPE_SHADER_IR_TGSI: info->bin.source = (void *)prog->pipe.tokens; break; +#ifndef __SWITCH__ case PIPE_SHADER_IR_NIR: info->bin.source = (void *)nir_shader_clone(NULL, prog->pipe.ir.nir); break; +#endif default: assert(!"unsupported IR!"); free(info); @@ -722,8 +724,10 @@ nvc0_program_translate(struct nvc0_program *prog, uint16_t chipset, #endif out: +#ifndef __SWITCH__ if (info->bin.sourceRep == PIPE_SHADER_IR_NIR) ralloc_free((void *)info->bin.source); +#endif FREE(info); return !ret; } diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c index 7abbf762af2..5fa47ec8266 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c @@ -20,7 +20,6 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include #include #include #include "util/format/u_format.h" @@ -440,6 +439,7 @@ nvc0_screen_get_shader_param(struct pipe_screen *pscreen, } switch (param) { +#ifndef __SWITCH__ case PIPE_SHADER_CAP_PREFERRED_IR: return screen->prefer_nir ? PIPE_SHADER_IR_NIR : PIPE_SHADER_IR_TGSI; case PIPE_SHADER_CAP_SUPPORTED_IRS: { @@ -449,6 +449,12 @@ nvc0_screen_get_shader_param(struct pipe_screen *pscreen, irs |= 1 << PIPE_SHADER_IR_NIR_SERIALIZED; return irs; } +#else + case PIPE_SHADER_CAP_PREFERRED_IR: + return PIPE_SHADER_IR_TGSI; + case PIPE_SHADER_CAP_SUPPORTED_IRS: + return 1 << PIPE_SHADER_IR_TGSI; +#endif case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: @@ -939,6 +945,8 @@ nvc0_screen_bind_cb_3d(struct nvc0_screen *screen, bool *can_serialize, IMMED_NVC0(push, NVC0_3D(CB_BIND(stage)), (index << 4) | (size >= 0)); } +#ifndef __SWITCH__ + static const nir_shader_compiler_options nir_options = { .lower_fdiv = false, .lower_ffma = false, @@ -1010,6 +1018,8 @@ nvc0_screen_get_compiler_options(struct pipe_screen *pscreen, return NULL; } +#endif + #define FAIL_SCREEN_INIT(str, err) \ do { \ NOUVEAU_ERR(str, err); \ @@ -1052,6 +1062,7 @@ nvc0_screen_create(struct nouveau_device *dev) ret = nouveau_screen_init(&screen->base, dev); if (ret) FAIL_SCREEN_INIT("Base screen init failed: %d\n", ret); + chan = screen->base.channel; push = screen->base.pushbuf; push->user_priv = screen; @@ -1084,8 +1095,10 @@ nvc0_screen_create(struct nouveau_device *dev) pscreen->get_sample_pixel_grid = nvc0_screen_get_sample_pixel_grid; pscreen->get_driver_query_info = nvc0_screen_get_driver_query_info; pscreen->get_driver_query_group_info = nvc0_screen_get_driver_query_group_info; +#ifndef __SWITCH__ /* nir stuff */ pscreen->get_compiler_options = nvc0_screen_get_compiler_options; +#endif nvc0_screen_init_resource_functions(pscreen); @@ -1103,8 +1116,7 @@ nvc0_screen_create(struct nouveau_device *dev) screen->fence.map = screen->fence.bo->map; screen->base.fence.emit = nvc0_screen_fence_emit; screen->base.fence.update = nvc0_screen_fence_update; - - +#if 0 // TODO: Support queries ret = nouveau_object_new(chan, (dev->chipset < 0xe0) ? 0x1f906e : 0x906e, NVIF_CLASS_SW_GF100, NULL, 0, &screen->nvsw); if (ret) @@ -1112,7 +1124,7 @@ nvc0_screen_create(struct nouveau_device *dev) BEGIN_NVC0(push, SUBC_SW(NV01_SUBCHAN_OBJECT), 1); PUSH_DATA (push, screen->nvsw->handle); - +#endif switch (dev->chipset & ~0xf) { case 0x130: case 0x120: @@ -1135,9 +1147,9 @@ nvc0_screen_create(struct nouveau_device *dev) BEGIN_NVC0(push, SUBC_M2MF(NV01_SUBCHAN_OBJECT), 1); PUSH_DATA (push, screen->m2mf->oclass); - if (screen->m2mf->oclass == NVE4_P2MF_CLASS) { + if (screen->m2mf->oclass >= NVE4_P2MF_CLASS) { BEGIN_NVC0(push, SUBC_COPY(NV01_SUBCHAN_OBJECT), 1); - PUSH_DATA (push, 0xa0b5); + PUSH_DATA (push, screen->m2mf->oclass >= NVF0_P2MF_CLASS ? 0xb0b5 : 0xa0b5); } ret = nouveau_object_new(chan, 0xbeef902d, NVC0_2D_CLASS, NULL, 0, diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c index 5cb07609dae..a2cb6f3400f 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c @@ -602,9 +602,11 @@ nvc0_sp_state_create(struct pipe_context *pipe, case PIPE_SHADER_IR_TGSI: prog->pipe.tokens = tgsi_dup_tokens(cso->tokens); break; +#ifndef __SWITCH__ case PIPE_SHADER_IR_NIR: prog->pipe.ir.nir = cso->ir.nir; break; +#endif default: assert(!"unsupported IR!"); free(prog); @@ -630,8 +632,10 @@ nvc0_sp_state_delete(struct pipe_context *pipe, void *hwcso) if (prog->pipe.type == PIPE_SHADER_IR_TGSI) FREE((void *)prog->pipe.tokens); +#ifndef __SWITCH__ else if (prog->pipe.type == PIPE_SHADER_IR_NIR) ralloc_free(prog->pipe.ir.nir); +#endif FREE(prog); } @@ -735,6 +739,7 @@ nvc0_cp_state_create(struct pipe_context *pipe, case PIPE_SHADER_IR_TGSI: prog->pipe.tokens = tgsi_dup_tokens((const struct tgsi_token *)cso->prog); break; +#ifndef __SWITCH__ case PIPE_SHADER_IR_NIR: prog->pipe.ir.nir = (nir_shader *)cso->prog; break; @@ -747,6 +752,7 @@ nvc0_cp_state_create(struct pipe_context *pipe, prog->pipe.type = PIPE_SHADER_IR_NIR; break; } +#endif default: assert(!"unsupported IR!"); free(prog); diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c b/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c index 3de4ec14867..8b481f0a640 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c @@ -21,7 +21,6 @@ */ #include "nvc0/nvc0_video.h" -#include #if NOUVEAU_VP3_DEBUG_FENCE static void dump_comm_vp(struct nouveau_vp3_decoder *dec, struct comm *comm, u32 comm_seq, @@ -50,8 +49,7 @@ static void dump_comm_vp(struct nouveau_vp3_decoder *dec, struct comm *comm, u32 for (i = 0; i < comm->byte_ofs + slice_size; i += 0x10) { debug_printf("%05x: %08x %08x %08x %08x\n", i, map[i/4], map[i/4+1], map[i/4+2], map[i/4+3]); } - munmap(inter_bo->map, inter_bo->size); - inter_bo->map = NULL; + nouveau_bo_unmap(inter_bo); } assert((comm->pvp_stage & 0xff) == 0xff); } diff --git a/src/gallium/include/pipe/p_config.h b/src/gallium/include/pipe/p_config.h index 2c1698d0e9c..d717103a9cf 100644 --- a/src/gallium/include/pipe/p_config.h +++ b/src/gallium/include/pipe/p_config.h @@ -1,8 +1,8 @@ /************************************************************************** - * + * * Copyright 2008 VMware, Inc. * All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -10,11 +10,11 @@ * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. @@ -22,24 +22,24 @@ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * + * **************************************************************************/ /** * @file * Gallium configuration defines. - * - * This header file sets several defines based on the compiler, processor - * architecture, and operating system being used. These defines should be used - * throughout the code to facilitate porting to new platforms. It is likely that - * this file is auto-generated by an autoconf-like tool at some point, as some - * things cannot be determined by pre-defined environment alone. - * + * + * This header file sets several defines based on the compiler, processor + * architecture, and operating system being used. These defines should be used + * throughout the code to facilitate porting to new platforms. It is likely that + * this file is auto-generated by an autoconf-like tool at some point, as some + * things cannot be determined by pre-defined environment alone. + * * See also: * - http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html * - echo | gcc -dM -E - | sort * - http://msdn.microsoft.com/en-us/library/b0084kay.aspx - * + * * @author José Fonseca */ @@ -65,8 +65,8 @@ * - 1400: Visual C++ 2005 * - 1310: Visual C++ .NET 2003 * - 1300: Visual C++ .NET 2002 - * - * __MSC__ seems to be an old macro -- it is not pre-defined on recent MSVC + * + * __MSC__ seems to be an old macro -- it is not pre-defined on recent MSVC * versions. */ #if defined(_MSC_VER) || defined(__MSC__) @@ -145,6 +145,10 @@ #define PIPE_OS_ANDROID #endif +#if DETECT_OS_SWITCH +#define PIPE_OS_SWITCH +#endif + #if DETECT_OS_FREEBSD #define PIPE_OS_FREEBSD #endif diff --git a/src/gallium/meson.build b/src/gallium/meson.build index 1f81fcf1fd5..b15a01a3e46 100644 --- a/src/gallium/meson.build +++ b/src/gallium/meson.build @@ -78,7 +78,11 @@ else driver_radeonsi = declare_dependency() endif if with_gallium_nouveau - subdir('winsys/nouveau/drm') + if with_dri + subdir('winsys/nouveau/drm') + elif with_platform_switch + subdir('winsys/nouveau/switch') + endif subdir('drivers/nouveau') else driver_nouveau = declare_dependency() diff --git a/src/gallium/winsys/nouveau/switch/meson.build b/src/gallium/winsys/nouveau/switch/meson.build new file mode 100644 index 00000000000..22c45281367 --- /dev/null +++ b/src/gallium/winsys/nouveau/switch/meson.build @@ -0,0 +1,29 @@ +# Copyright © 2019 fincs + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +libnouveauwinsys = static_library( + 'nouveauwinsys', + files('nouveau_switch_public.h', 'nouveau_switch_winsys.c'), + include_directories : [ + inc_src, inc_include, inc_gallium, inc_gallium_aux, inc_gallium_drivers, + ], + c_args : [c_vis_args], + dependencies : [dep_libdrm_nouveau], +) diff --git a/src/gallium/winsys/nouveau/switch/nouveau_switch_public.h b/src/gallium/winsys/nouveau/switch/nouveau_switch_public.h new file mode 100644 index 00000000000..33b35885818 --- /dev/null +++ b/src/gallium/winsys/nouveau/switch/nouveau_switch_public.h @@ -0,0 +1,13 @@ + +#ifndef __NOUVEAU_SWITCH_PUBLIC_H__ +#define __NOUVEAU_SWITCH_PUBLIC_H__ +#include + +struct pipe_screen; +struct pipe_resource; + +struct pipe_screen *nouveau_switch_screen_create(void); +int nouveau_switch_resource_get_syncpoint(struct pipe_resource *resource, unsigned int *out_threshold); +int nouveau_switch_resource_get_buffer(struct pipe_resource *resource, NvGraphicBuffer *buffer); + +#endif diff --git a/src/gallium/winsys/nouveau/switch/nouveau_switch_winsys.c b/src/gallium/winsys/nouveau/switch/nouveau_switch_winsys.c new file mode 100644 index 00000000000..87b9eff8017 --- /dev/null +++ b/src/gallium/winsys/nouveau/switch/nouveau_switch_winsys.c @@ -0,0 +1,206 @@ +#include +#include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "pipe/p_screen.h" +#include "util/format/u_format.h" +#include "util/u_memory.h" +#include "util/u_inlines.h" +#include "util/u_hash_table.h" +#include "os/os_thread.h" + +#include "state_tracker/drm_driver.h" +#include "drm-uapi/drm_fourcc.h" + +#include "nouveau_switch_public.h" + +#include "nouveau/nouveau_winsys.h" +#include "nouveau/nouveau_screen.h" +#include "nouveau/nouveau_buffer.h" + +#include +#include + +static mtx_t nouveau_screen_mutex = _MTX_INITIALIZER_NP; + +bool nouveau_drm_screen_unref(struct nouveau_screen *screen) +{ + int ret; + if (screen->refcount == -1) + return true; + + mtx_lock(&nouveau_screen_mutex); + ret = --screen->refcount; + assert(ret >= 0); + mtx_unlock(&nouveau_screen_mutex); + return ret == 0; +} + +PUBLIC struct pipe_screen * +nouveau_switch_screen_create(void) +{ + struct nouveau_drm *drm = NULL; + struct nouveau_device *dev = NULL; + struct nouveau_screen *(*init)(struct nouveau_device *); + struct nouveau_screen *screen = NULL; + int ret; + + mtx_lock(&nouveau_screen_mutex); + + ret = nouveau_drm_new(0, &drm); + if (ret) + goto err; + + ret = nouveau_device_new(&drm->client, NV_DEVICE, + &(struct nv_device_v0) { + .device = ~0ULL, + }, sizeof(struct nv_device_v0), &dev); + if (ret) + goto err; + + switch (dev->chipset & ~0xf) { +#if 0 + case 0x30: + case 0x40: + case 0x60: + init = nv30_screen_create; + break; + case 0x50: + case 0x80: + case 0x90: + case 0xa0: + init = nv50_screen_create; + break; +#endif + case 0xc0: + case 0xd0: + case 0xe0: + case 0xf0: + case 0x100: + case 0x110: + case 0x120: + case 0x130: + init = nvc0_screen_create; + break; + default: + debug_printf("%s: unknown chipset nv%02x\n", __func__, + dev->chipset); + goto err; + } + + screen = init(dev); + if (!screen || !screen->base.context_create) + goto err; + + screen->refcount = 1; + mtx_unlock(&nouveau_screen_mutex); + return &screen->base; + +err: + if (screen) { + screen->base.destroy(&screen->base); + } else { + nouveau_device_del(&dev); + nouveau_drm_del(&drm); + } + mtx_unlock(&nouveau_screen_mutex); + return NULL; +} + +PUBLIC int +nouveau_switch_resource_get_syncpoint(struct pipe_resource *resource, unsigned int *out_threshold) +{ + struct nv04_resource* priv = nv04_resource(resource); + return nouveau_bo_get_syncpoint(priv->bo, out_threshold); +} + +PUBLIC int +nouveau_switch_resource_get_buffer(struct pipe_resource *resource, NvGraphicBuffer *buffer) +{ + struct winsys_handle whandle = {0}; + + if ((resource->target != PIPE_TEXTURE_2D && resource->target != PIPE_TEXTURE_RECT) || resource->last_level != 0 || resource->depth0 != 1 || resource->array_size > 1) { + debug_printf("%s: unsupported resource type\n", __func__); + return -1; + } + + whandle.type = WINSYS_HANDLE_TYPE_SHARED; + if (!resource->screen->resource_get_handle(resource->screen, NULL, resource, &whandle, 0)) { + debug_printf("%s: resource_get_handle failed\n", __func__); + return -2; + } + + u32 block_height_log2; + switch (whandle.modifier) { + case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_ONE_GOB: + block_height_log2 = 0; + break; + case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_TWO_GOB: + block_height_log2 = 1; + break; + case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_FOUR_GOB: + block_height_log2 = 2; + break; + case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_EIGHT_GOB: + block_height_log2 = 3; + break; + case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_SIXTEEN_GOB: + block_height_log2 = 4; + break; + case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_THIRTYTWO_GOB: + block_height_log2 = 5; + break; + default: + debug_printf("%s: unsupported resource layout\n", __func__); + return -3; + } + + u32 format; + NvColorFormat colorfmt; + switch (resource->format) { + case PIPE_FORMAT_R8G8B8A8_UNORM: + format = PIXEL_FORMAT_RGBA_8888; + colorfmt = NvColorFormat_A8B8G8R8; + break; + case PIPE_FORMAT_R8G8B8X8_UNORM: + format = PIXEL_FORMAT_RGBX_8888; + colorfmt = NvColorFormat_X8B8G8R8; + break; + case PIPE_FORMAT_B5G6R5_UNORM: + format = PIXEL_FORMAT_RGB_565; + colorfmt = NvColorFormat_R5G6B5; + break; + default: + debug_printf("%s: unsupported resource format\n", __func__); + return -4; + } + + const u32 bytes_per_pixel = ((u64)colorfmt >> 3) & 0x1F; + const u32 block_height = 8 * (1U << block_height_log2); + const u32 width_aligned = whandle.stride / bytes_per_pixel; + const u32 height_aligned = (resource->height0 + block_height - 1) &~ (block_height - 1); + const u32 fb_size = whandle.stride*height_aligned; + + memset(buffer, 0, sizeof(*buffer)); + buffer->header.num_ints = (sizeof(NvGraphicBuffer) - sizeof(NativeHandle)) / 4; + buffer->unk0 = -1; + buffer->nvmap_id = whandle.handle; + buffer->magic = 0xDAFFCAFF; + buffer->pid = 42; + buffer->usage = GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE; + buffer->format = format; + buffer->ext_format = format; + buffer->stride = width_aligned; + buffer->total_size = fb_size; + buffer->num_planes = 1; + buffer->planes[0].width = resource->width0; + buffer->planes[0].height = resource->height0; + buffer->planes[0].color_format = colorfmt; + buffer->planes[0].layout = NvLayout_BlockLinear; + buffer->planes[0].pitch = whandle.stride; + buffer->planes[0].offset = whandle.offset; + buffer->planes[0].kind = NvKind_Generic_16BX2; + buffer->planes[0].block_height_log2 = block_height_log2; + buffer->planes[0].size = fb_size; + + return 0; +} diff --git a/src/loader/loader.c b/src/loader/loader.c index 8548cbdfedb..058a38af1d2 100644 --- a/src/loader/loader.c +++ b/src/loader/loader.c @@ -26,7 +26,9 @@ * Rob Clark */ +#ifdef HAVE_DLFCN_H #include +#endif #include #include #include @@ -515,6 +517,7 @@ loader_get_extensions_name(const char *driver_name) return name; } +#ifdef HAVE_DLFCN_H /** * Opens a DRI driver using its driver name, returning the __DRIextension * entrypoints. @@ -602,3 +605,4 @@ loader_open_driver(const char *driver_name, *out_driver_handle = driver; return extensions; } +#endif diff --git a/src/mapi/es1api/meson.build b/src/mapi/es1api/meson.build index 711048421b8..c83a862bec3 100644 --- a/src/mapi/es1api/meson.build +++ b/src/mapi/es1api/meson.build @@ -32,7 +32,7 @@ if with_platform_windows _es1_c_args += ['-D_GDI32_', '-DBUILD_GL32'] endif -libglesv1_cm = shared_library( +libglesv1_cm = library( 'GLESv1_CM' + get_option('gles-lib-suffix'), ['../entry.c', es1_glapi_mapi_tmp_h], c_args : [ diff --git a/src/mapi/es2api/meson.build b/src/mapi/es2api/meson.build index ac79aa66f89..3ba80c96248 100644 --- a/src/mapi/es2api/meson.build +++ b/src/mapi/es2api/meson.build @@ -32,7 +32,7 @@ if with_platform_windows _es2_c_args += ['-D_GDI32_', '-DBUILD_GL32'] endif -libgles2 = shared_library( +libgles2 = library( 'GLESv2' + get_option('gles-lib-suffix'), ['../entry.c', es2_glapi_mapi_tmp_h], c_args : [ diff --git a/src/mapi/shared-glapi/meson.build b/src/mapi/shared-glapi/meson.build index 5b9db0c081a..315b72e65de 100644 --- a/src/mapi/shared-glapi/meson.build +++ b/src/mapi/shared-glapi/meson.build @@ -41,7 +41,7 @@ if with_platform_windows _glapi_c_args += ['-D_GLAPI_DLL_EXPORTS'] endif -libglapi = shared_library( +libglapi = library( 'glapi', [files_mapi_glapi, files_mapi_util, shared_glapi_mapi_tmp_h], c_args : [ @@ -61,6 +61,15 @@ libglapi = shared_library( install : true, ) +pkg.generate( + name : 'glapi', + filebase : 'glapi', + description : 'Mesa OpenGL shared library', + version : meson.project_version(), + libraries : libglapi, + libraries_private : gl_priv_libs, +) + if with_any_opengl and with_tests test( 'shared-glapi-test', diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 2b8becb806d..3038ac3641b 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1233,7 +1233,7 @@ _mesa_initialize_context(struct gl_context *ctx, * has errors so don't enable it for setuid processes. */ if (env_var_as_boolean("MESA_NO_ERROR", false)) { -#if !defined(_WIN32) +#if !defined(_WIN32) && !defined(__SWITCH__) if (geteuid() == getuid()) #endif ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR; diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 91988f183f8..eeaefde0960 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -36,6 +36,10 @@ #include "context.h" #include "debug_output.h" +#if defined(__SWITCH__) +#include +#endif + static FILE *LogFile = NULL; @@ -81,13 +85,17 @@ output_if_debug(const char *prefixString, const char *outputString, fprintf(LogFile, "\n"); fflush(LogFile); -#if defined(_WIN32) +#if defined(_WIN32) || defined(__SWITCH__) /* stderr from windows applications without console is not usually * visible, so communicate with the debugger instead */ { char buf[4096]; snprintf(buf, sizeof(buf), "%s: %s%s", prefixString, outputString, newline ? "\n" : ""); +#ifdef __SWITCH__ + svcOutputDebugString(buf, sizeof(buf)); +#else OutputDebugStringA(buf); +#endif } #endif } diff --git a/src/mesa/main/execmem.c b/src/mesa/main/execmem.c index b2018b5e767..823fe406f76 100644 --- a/src/mesa/main/execmem.c +++ b/src/mesa/main/execmem.c @@ -133,6 +133,7 @@ _mesa_exec_free(void *addr) #else +#include /* * Just use regular memory. diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c index 64daf54ec42..6386d5315bb 100644 --- a/src/mesa/main/glspirv.c +++ b/src/mesa/main/glspirv.c @@ -325,6 +325,7 @@ _mesa_SpecializeShaderARB(GLuint shader, return; } +#ifndef __SWITCH__ sh = _mesa_lookup_shader_err(ctx, shader, "glSpecializeShaderARB"); if (!sh) return; @@ -417,4 +418,5 @@ _mesa_SpecializeShaderARB(GLuint shader, end: free(spec_entries); +#endif } diff --git a/src/mesa/main/hash.h b/src/mesa/main/hash.h index 0a3996a7d00..a1d4aa98a34 100644 --- a/src/mesa/main/hash.h +++ b/src/mesa/main/hash.h @@ -34,6 +34,7 @@ #include #include +#include #include "glheader.h" #include "c11/threads.h" diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index e38f44ed78b..4419be0eaac 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -1,9 +1,9 @@ /************************************************************************** - * + * * Copyright 2007 VMware, Inc. * All Rights Reserved. * Copyright 2009 VMware, Inc. All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -11,11 +11,11 @@ * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. @@ -23,7 +23,7 @@ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * + * **************************************************************************/ /* @@ -110,9 +110,13 @@ static inline void set_fragment_shader(struct st_context *st) { struct pipe_screen *pscreen = st->pipe->screen; +#ifndef __SWITCH__ bool use_nir = PIPE_SHADER_IR_NIR == pscreen->get_shader_param(pscreen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_PREFERRED_IR); +#else + const bool use_nir = false; +#endif if (!st->clear.fs) { if (use_nir) { @@ -164,9 +168,13 @@ static inline void set_vertex_shader(struct st_context *st) { struct pipe_screen *pscreen = st->pipe->screen; +#ifndef __SWITCH__ bool use_nir = PIPE_SHADER_IR_NIR == pscreen->get_shader_param(pscreen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_PREFERRED_IR); +#else + const bool use_nir = false; +#endif /* vertex shader - still required to provide the linkage between * fragment shader input semantics and vertex_element/buffers. @@ -198,9 +206,13 @@ set_vertex_shader_layered(struct st_context *st) { struct pipe_context *pipe = st->pipe; struct pipe_screen *pscreen = pipe->screen; +#ifndef __SWITCH__ bool use_nir = PIPE_SHADER_IR_NIR == pscreen->get_shader_param(pscreen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_PREFERRED_IR); +#else + const bool use_nir = false; +#endif if (!pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_INSTANCEID)) { assert(!"Got layered clear, but VS instancing is unsupported"); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 3f84b22154d..9278f6ebb9f 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -284,9 +284,13 @@ get_drawpix_z_stencil_program(struct st_context *st, return st->drawpix.zs_shaders[shaderIndex]; } +#ifndef __SWITCH__ enum pipe_shader_ir preferred_ir = pscreen->get_shader_param(pscreen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_PREFERRED_IR); +#else + const enum pipe_shader_ir preferred_ir = PIPE_SHADER_IR_TGSI; +#endif if (preferred_ir == PIPE_SHADER_IR_NIR) cso = make_drawpix_z_stencil_program_nir(st, write_depth, write_stencil); @@ -312,9 +316,13 @@ st_make_passthrough_vertex_shader(struct st_context *st) if (st->passthrough_vs) return; +#ifndef __SWITCH__ enum pipe_shader_ir preferred_ir = screen->get_shader_param(screen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_PREFERRED_IR); +#else + const enum pipe_shader_ir preferred_ir = PIPE_SHADER_IR_TGSI; +#endif if (preferred_ir == PIPE_SHADER_IR_NIR) { unsigned inputs[] = diff --git a/src/mesa/state_tracker/st_cb_drawtex.c b/src/mesa/state_tracker/st_cb_drawtex.c index 4960a55e986..deb95d247e7 100644 --- a/src/mesa/state_tracker/st_cb_drawtex.c +++ b/src/mesa/state_tracker/st_cb_drawtex.c @@ -126,9 +126,13 @@ lookup_shader(struct st_context *st, CachedShaders[i].semantic_indexes[j] = semantic_indexes[j]; } +#ifndef __SWITCH__ enum pipe_shader_ir preferred_ir = screen->get_shader_param(screen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_PREFERRED_IR); +#else + const enum pipe_shader_ir preferred_ir = PIPE_SHADER_IR_TGSI; +#endif if (preferred_ir == PIPE_SHADER_IR_NIR) { unsigned inputs[2 + MAX_TEXTURE_UNITS]; diff --git a/src/mesa/state_tracker/st_cb_memoryobjects.c b/src/mesa/state_tracker/st_cb_memoryobjects.c index d81c7692c1f..7d2c3d7396b 100644 --- a/src/mesa/state_tracker/st_cb_memoryobjects.c +++ b/src/mesa/state_tracker/st_cb_memoryobjects.c @@ -80,7 +80,7 @@ st_import_memoryobj_fd(struct gl_context *ctx, &whandle, obj->Dedicated); -#if !defined(_WIN32) +#if !defined(_WIN32) && !defined(__SWITCH__) /* We own fd, but we no longer need it. So get rid of it */ close(fd); #endif diff --git a/src/mesa/state_tracker/st_cb_semaphoreobjects.c b/src/mesa/state_tracker/st_cb_semaphoreobjects.c index 7a32d9b138f..88b41dc9047 100644 --- a/src/mesa/state_tracker/st_cb_semaphoreobjects.c +++ b/src/mesa/state_tracker/st_cb_semaphoreobjects.c @@ -68,7 +68,7 @@ st_import_semaphoreobj_fd(struct gl_context *ctx, pipe->create_fence_fd(pipe, &st_obj->fence, fd, PIPE_FD_TYPE_SYNCOBJ); -#if !defined(_WIN32) +#if !defined(_WIN32) && !defined(__SWITCH__) /* We own fd, but we no longer need it. So get rid of it */ close(fd); #endif diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 4f7fd242741..848d075dd41 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -453,7 +453,9 @@ st_destroy_context_priv(struct st_context *st, bool destroy_pipe) uint i; st_destroy_atoms(st); +#ifndef __SWITCH__ st_destroy_draw(st); +#endif st_destroy_clear(st); st_destroy_bitmap(st); st_destroy_drawpix(st); @@ -773,9 +775,13 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].PositionAlwaysInvariant = options->vs_position_always_invariant; +#ifndef __SWITCH__ enum pipe_shader_ir preferred_ir = (enum pipe_shader_ir) screen->get_shader_param(screen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_PREFERRED_IR); +#else + const enum pipe_shader_ir preferred_ir = PIPE_SHADER_IR_TGSI; +#endif ctx->Const.UseNIRGLSLLinker = preferred_ir == PIPE_SHADER_IR_NIR; if (ctx->Const.GLSLVersion < 400) { @@ -901,14 +907,18 @@ st_init_driver_functions(struct pipe_screen *screen, st_init_bitmap_functions(functions); st_init_copy_image_functions(functions); st_init_drawpixels_functions(functions); +#ifndef __SWITCH__ st_init_rasterpos_functions(functions); +#endif st_init_drawtex_functions(functions); st_init_eglimage_functions(functions); st_init_fbo_functions(functions); +#ifndef __SWITCH__ st_init_feedback_functions(functions); +#endif st_init_memoryobject_functions(functions); st_init_msaa_functions(functions); st_init_perfmon_functions(functions); @@ -943,9 +953,13 @@ st_init_driver_functions(struct pipe_screen *screen, /* GL_ARB_get_program_binary */ functions->GetProgramBinaryDriverSHA1 = st_get_program_binary_driver_sha1; +#ifndef __SWITCH__ enum pipe_shader_ir preferred_ir = (enum pipe_shader_ir) screen->get_shader_param(screen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_PREFERRED_IR); +#else + const enum pipe_shader_ir preferred_ir = PIPE_SHADER_IR_TGSI; +#endif if (preferred_ir == PIPE_SHADER_IR_NIR) { functions->ShaderCacheSerializeDriverBlob = st_serialise_nir_program; functions->ProgramBinarySerializeDriverBlob = @@ -1062,8 +1076,10 @@ st_destroy_context(struct st_context *st) */ _mesa_make_current(ctx, NULL, NULL); +#ifndef __SWITCH__ /* This must be called first so that glthread has a chance to finish */ _mesa_glthread_destroy(ctx); +#endif _mesa_HashWalk(ctx->Shared->TexObjects, destroy_tex_sampler_cb, st); diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index cbc8b139dbb..551879efc8d 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -347,6 +347,7 @@ st_init_draw_functions(struct dd_function_table *functions) functions->DrawIndirect = st_indirect_draw_vbo; } +#ifndef __SWITCH__ void st_destroy_draw(struct st_context *st) @@ -380,6 +381,8 @@ st_get_draw_context(struct st_context *st) return st->draw; } +#endif + /** * Draw a quad with given position, texcoords and color. */ diff --git a/src/mesa/state_tracker/st_glsl_to_ir.cpp b/src/mesa/state_tracker/st_glsl_to_ir.cpp index e450fec6d99..1d1fb4ec2a5 100644 --- a/src/mesa/state_tracker/st_glsl_to_ir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_ir.cpp @@ -47,9 +47,13 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) { struct pipe_screen *pscreen = ctx->st->pipe->screen; +#ifndef __SWITCH__ enum pipe_shader_ir preferred_ir = (enum pipe_shader_ir) pscreen->get_shader_param(pscreen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_PREFERRED_IR); +#else + const enum pipe_shader_ir preferred_ir = PIPE_SHADER_IR_TGSI; +#endif bool use_nir = preferred_ir == PIPE_SHADER_IR_NIR; /* Return early if we are loading the shader from on-disk cache */ @@ -59,11 +63,13 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) assert(prog->data->LinkStatus); +#ifndef __SWITCH__ /* Skip the GLSL steps when using SPIR-V. */ if (prog->data->spirv) { assert(use_nir); return st_link_nir(ctx, prog); } +#endif for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i] == NULL) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 8eb0dda9fae..2c8acb33176 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -4243,7 +4243,7 @@ glsl_to_tgsi_visitor::canonicalize_gather_offset(st_src_reg offset) return offset; } - + bool glsl_to_tgsi_visitor::handle_bound_deref(ir_dereference *ir) { diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp index e54bb7b9f4d..5db79283a18 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp @@ -126,11 +126,13 @@ #include "program/prog_instruction.h" #include "util/u_math.h" -#include #include #include +#ifndef NDEBUG +#include #include +#endif #include "st_glsl_to_tgsi_array_merge.h" @@ -302,6 +304,7 @@ void array_live_range::set_target(array_live_range *target) target_array = target; } +#ifndef NDEBUG void array_live_range::print(std::ostream& os) const { os << "[id:" << id @@ -312,6 +315,7 @@ void array_live_range::print(std::ostream& os) const << ", nc:" << (int)used_component_count << "]"; } +#endif bool array_live_range::time_doesnt_overlap(const array_live_range& other) const { @@ -388,6 +392,7 @@ uint16_t array_remapping::map_swizzles(uint16_t old_swizzle) const return out_swizzle; } +#ifndef NDEBUG void array_remapping::print(std::ostream& os) const { if (is_valid()) { @@ -399,6 +404,7 @@ void array_remapping::print(std::ostream& os) const os << "[unused]"; } } +#endif /* Required by the unit tests */ bool operator == (const array_remapping& lhs, const array_remapping& rhs) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_private.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi_private.cpp index f259442cc37..5b235fe3129 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi_private.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi_private.cpp @@ -28,6 +28,10 @@ #include "mesa/program/prog_instruction.h" #include "mesa/program/prog_print.h" +#ifndef NDEBUG +#include +#endif + static int swizzle_for_type(const glsl_type *type, int component = 0) { unsigned num_elements = 4; @@ -223,6 +227,7 @@ bool operator == (const st_src_reg& lhs, const st_src_reg& rhs) static const char swz_txt[] = "xyzw"; +#ifndef NDEBUG std::ostream& operator << (std::ostream& os, const st_src_reg& reg) { if (reg.negate) @@ -258,6 +263,7 @@ std::ostream& operator << (std::ostream& os, const st_src_reg& reg) os << "|"; return os; } +#endif st_dst_reg::st_dst_reg(st_src_reg reg) { @@ -363,6 +369,7 @@ bool operator == (const st_dst_reg& lhs, const st_dst_reg& rhs) return result; } +#ifndef NDEBUG std::ostream& operator << (std::ostream& os, const st_dst_reg& reg) { os << _mesa_register_file_name(reg.file); @@ -421,3 +428,4 @@ void glsl_to_tgsi_instruction::print(std::ostream& os) const } } } +#endif diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_private.h b/src/mesa/state_tracker/st_glsl_to_tgsi_private.h index 0b24e2ea774..2abab643f94 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi_private.h +++ b/src/mesa/state_tracker/st_glsl_to_tgsi_private.h @@ -31,7 +31,7 @@ #include "compiler/glsl_types.h" #include "compiler/glsl/ir.h" #include "tgsi/tgsi_info.h" -#include +#include int swizzle_for_size(int size); diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index cc1572bcc31..b96e7931d3b 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -994,8 +994,10 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi, st->iface.teximage = st_context_teximage; st->iface.copy = st_context_copy; st->iface.share = st_context_share; +#ifndef __SWITCH__ st->iface.start_thread = st_start_thread; st->iface.thread_finish = st_thread_finish; +#endif st->iface.st_context_private = (void *) smapi; st->iface.cso_context = st->cso_context; st->iface.pipe = st->pipe; diff --git a/src/mesa/state_tracker/st_pbo.c b/src/mesa/state_tracker/st_pbo.c index ee5ee2df598..3ebb149b6aa 100644 --- a/src/mesa/state_tracker/st_pbo.c +++ b/src/mesa/state_tracker/st_pbo.c @@ -293,6 +293,7 @@ void * st_pbo_create_vs(struct st_context *st) { struct pipe_screen *pscreen = st->pipe->screen; +#ifndef __SWITCH__ bool use_nir = PIPE_SHADER_IR_NIR == pscreen->get_shader_param(pscreen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_PREFERRED_IR); @@ -306,6 +307,7 @@ st_pbo_create_vs(struct st_context *st) st->pbo.layers ? 2 : 1, inputs, outputs, NULL, (1 << 1)); } +#endif struct ureg_program *ureg; struct ureg_src in_pos; @@ -726,6 +728,7 @@ create_fs(struct st_context *st, bool download, enum pipe_texture_target target, enum st_pbo_conversion conversion) { +#ifndef __SWITCH__ struct pipe_screen *pscreen = st->pipe->screen; bool use_nir = PIPE_SHADER_IR_NIR == pscreen->get_shader_param(pscreen, PIPE_SHADER_VERTEX, @@ -733,6 +736,7 @@ create_fs(struct st_context *st, bool download, if (use_nir) return create_fs_nir(st, download, target, conversion); +#endif return create_fs_tgsi(st, download, target, conversion); } diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index cb9fcfdbdd6..47b746bfd6a 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -225,8 +225,10 @@ delete_variant(struct st_context *st, struct st_variant *v, GLenum target) if (v->driver_shader) { if (target == GL_VERTEX_PROGRAM_ARB && ((struct st_common_variant*)v)->key.is_draw_shader) { +#ifndef __SWITCH__ /* Draw shader. */ draw_delete_vertex_shader(st->draw, v->driver_shader); +#endif } else if (st->has_shareable_shaders || v->st == st) { /* The shader's context matches the calling context, or we * don't care. @@ -351,6 +353,8 @@ st_release_program(struct st_context *st, struct st_program **p) st_reference_prog(st, p, NULL); } +#ifndef __SWITCH__ + void st_finalize_nir_before_variants(struct nir_shader *nir) { @@ -402,6 +406,8 @@ st_translate_prog_to_nir(struct st_context *st, struct gl_program *prog, return nir; } +#endif + void st_prepare_vertex_program(struct st_program *stp) { @@ -509,6 +515,7 @@ st_translate_vertex_program(struct st_context *st, if (stp->Base.Parameters->NumParameters) stp->affected_states |= ST_NEW_VS_CONSTANTS; +#ifndef __SWITCH__ /* Translate to NIR if preferred. */ if (st->pipe->screen->get_shader_param(st->pipe->screen, PIPE_SHADER_VERTEX, @@ -550,6 +557,7 @@ st_translate_vertex_program(struct st_context *st, return true; } } +#endif } st_prepare_vertex_program(stp); @@ -645,6 +653,8 @@ st_translate_vertex_program(struct st_context *st, return stp->state.tokens != NULL; } +#ifndef __SWITCH__ + static struct nir_shader * get_nir_shader(struct st_context *st, struct st_program *stp) { @@ -668,6 +678,8 @@ get_nir_shader(struct st_context *st, struct st_program *stp) return nir_deserialize(NULL, options, &blob_reader); } +#endif + static const gl_state_index16 depth_range_state[STATE_LENGTH] = { STATE_DEPTH_RANGE }; @@ -689,6 +701,7 @@ st_create_vp_variant(struct st_context *st, state.stream_output = stvp->state.stream_output; +#ifndef __SWITCH__ if (stvp->state.type == PIPE_SHADER_IR_NIR && (!key->is_draw_shader || draw_has_llvm())) { bool finalize = false; @@ -756,6 +769,7 @@ st_create_vp_variant(struct st_context *st, return vpv; } +#endif state.type = PIPE_SHADER_IR_TGSI; state.tokens = tgsi_dup_tokens(stvp->state.tokens); @@ -792,9 +806,11 @@ st_create_vp_variant(struct st_context *st, if (ST_DEBUG & DEBUG_PRINT_IR) tgsi_dump(state.tokens, 0); +#ifndef __SWITCH__ if (key->is_draw_shader) vpv->base.driver_shader = draw_create_vertex_shader(st->draw, &state); else +#endif vpv->base.driver_shader = pipe->create_vs_state(pipe, &state); if (state.tokens) { @@ -881,6 +897,7 @@ st_translate_fragment_program(struct st_context *st, ST_NEW_FS_SAMPLERS; } +#ifndef __SWITCH__ /* Translate to NIR. */ if (!stfp->ati_fs && st->pipe->screen->get_shader_param(st->pipe->screen, @@ -899,6 +916,7 @@ st_translate_fragment_program(struct st_context *st, stfp->Base.nir = nir; return true; } +#endif } ubyte outputMapping[2 * FRAG_RESULT_MAX]; @@ -1248,6 +1266,7 @@ st_create_fp_variant(struct st_context *st, if (!variant) return NULL; +#ifndef __SWITCH__ if (stfp->state.type == PIPE_SHADER_IR_NIR) { bool finalize = false; @@ -1384,6 +1403,7 @@ st_create_fp_variant(struct st_context *st, return variant; } +#endif state.tokens = stfp->state.tokens; @@ -1780,6 +1800,7 @@ st_get_common_variant(struct st_context *st, v = (struct st_variant*)CALLOC_STRUCT(st_common_variant); if (v) { if (prog->state.type == PIPE_SHADER_IR_NIR) { +#ifndef __SWITCH__ bool finalize = false; state.type = PIPE_SHADER_IR_NIR; @@ -1799,6 +1820,7 @@ st_get_common_variant(struct st_context *st, if (ST_DEBUG & DEBUG_PRINT_IR) nir_print_shader(state.ir.nir, stderr); +#endif } else { if (key->lower_depth_clamp) { struct gl_program_parameter_list *params = prog->Base.Parameters; @@ -1838,9 +1860,11 @@ st_get_common_variant(struct st_context *st, cs.ir_type = state.type; cs.req_local_mem = prog->Base.info.cs.shared_size; +#ifndef __SWITCH__ if (state.type == PIPE_SHADER_IR_NIR) cs.prog = state.ir.nir; else +#endif cs.prog = state.tokens; v->driver_shader = pipe->create_compute_state(pipe, &cs); @@ -2021,6 +2045,8 @@ st_precompile_shader_variant(struct st_context *st, } } +#ifndef __SWITCH__ + void st_serialize_nir(struct st_program *stp) { @@ -2035,6 +2061,8 @@ st_serialize_nir(struct st_program *stp) } } +#endif + void st_finalize_program(struct st_context *st, struct gl_program *prog) { @@ -2045,6 +2073,7 @@ st_finalize_program(struct st_context *st, struct gl_program *prog) st->dirty |= ((struct st_program *)prog)->affected_states; } +#ifndef __SWITCH__ if (prog->nir) { nir_sweep(prog->nir); @@ -2054,6 +2083,7 @@ st_finalize_program(struct st_context *st, struct gl_program *prog) */ st_serialize_nir(st_program(prog)); } +#endif /* Create Gallium shaders now instead of on demand. */ if (ST_DEBUG & DEBUG_PRECOMPILE || diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c index 000d1c2688b..3382b6539ab 100644 --- a/src/mesa/state_tracker/st_shader_cache.c +++ b/src/mesa/state_tracker/st_shader_cache.c @@ -72,6 +72,8 @@ write_tgsi_to_cache(struct blob *blob, const struct tgsi_token *tokens, copy_blob_to_driver_cache_blob(blob, prog); } +#ifndef __SWITCH__ + static void write_nir_to_cache(struct blob *blob, struct gl_program *prog) { @@ -85,6 +87,8 @@ write_nir_to_cache(struct blob *blob, struct gl_program *prog) copy_blob_to_driver_cache_blob(blob, prog); } +#endif + static void st_serialise_ir_program(struct gl_context *ctx, struct gl_program *prog, bool nir) @@ -113,9 +117,11 @@ st_serialise_ir_program(struct gl_context *ctx, struct gl_program *prog, prog->info.stage == MESA_SHADER_GEOMETRY) write_stream_out_to_cache(&blob, &stp->state); +#ifndef __SWITCH__ if (nir) write_nir_to_cache(&blob, prog); else +#endif write_tgsi_to_cache(&blob, stp->state.tokens, prog); blob_finish(&blob); @@ -207,6 +213,7 @@ st_deserialise_ir_program(struct gl_context *ctx, read_stream_out_from_cache(&blob_reader, &stp->state); if (nir) { +#ifndef __SWITCH__ assert(prog->nir == NULL); assert(stp->serialized_nir == NULL); @@ -215,6 +222,7 @@ st_deserialise_ir_program(struct gl_context *ctx, stp->serialized_nir = malloc(stp->serialized_nir_size); blob_copy_bytes(&blob_reader, stp->serialized_nir, stp->serialized_nir_size); stp->shader_program = shProg; +#endif } else { read_tgsi_from_cache(&blob_reader, &stp->state.tokens); } @@ -292,6 +300,8 @@ st_deserialise_tgsi_program(struct gl_context *ctx, st_deserialise_ir_program(ctx, shProg, prog, false); } +#ifndef __SWITCH__ + void st_serialise_nir_program(struct gl_context *ctx, struct gl_program *prog) { @@ -313,3 +323,5 @@ st_deserialise_nir_program(struct gl_context *ctx, { st_deserialise_ir_program(ctx, shProg, prog, true); } + +#endif diff --git a/src/meson.build b/src/meson.build index bdc6a54cc3f..88b607c8a77 100644 --- a/src/meson.build +++ b/src/meson.build @@ -23,6 +23,7 @@ inc_mapi = include_directories('mapi') inc_src = include_directories('.') inc_gallium = include_directories('gallium/include') inc_gallium_aux = include_directories('gallium/auxiliary') +inc_gallium_winsys = include_directories('gallium/winsys') inc_amd_common = include_directories('amd/common') inc_amd_common_llvm = include_directories('amd/llvm') @@ -99,9 +100,6 @@ if with_gbm else inc_gbm = [] endif -if with_egl - subdir('egl') -endif if with_gallium subdir('gallium') # This has to be here since it requires libgallium, and subdir cannot @@ -110,6 +108,9 @@ if with_gallium subdir('mesa/state_tracker/tests') endif endif +if with_egl + subdir('egl') +endif # This must be after at least mesa, glx, and gallium, since libgl will be # defined in one of those subdirs depending on the glx provider. diff --git a/src/util/detect_os.h b/src/util/detect_os.h index 6506948e035..5f81ec6e72e 100644 --- a/src/util/detect_os.h +++ b/src/util/detect_os.h @@ -28,6 +28,10 @@ #define DETECT_OS_ANDROID 1 #endif +#if defined(__SWITCH__) +#define DETECT_OS_SWITCH 1 +#endif + #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #define DETECT_OS_FREEBSD 1 #define DETECT_OS_BSD 1 diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h index 09b316e6e8d..e5dca8e7137 100644 --- a/src/util/disk_cache.h +++ b/src/util/disk_cache.h @@ -91,10 +91,10 @@ disk_cache_format_hex_id(char *buf, const uint8_t *hex_id, unsigned size) return buf; } -#ifdef HAVE_DLADDR static inline bool disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp) { +#ifdef HAVE_DLADDR Dl_info info; struct stat st; if (!dladdr(ptr, &info) || !info.dli_fname) { @@ -131,8 +131,16 @@ disk_cache_get_function_identifier(void *ptr, struct mesa_sha1 *ctx) } else return false; return true; +#else + return false; } + +static inline bool +disk_cache_get_function_identifier(void *ptr, struct mesa_sha1 *ctx) +{ + return false; #endif +} /* Provide inlined stub functions if the shader cache is disabled. */ diff --git a/src/util/macros.h b/src/util/macros.h index fcace4e351d..079e78cb1a4 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -152,11 +152,13 @@ do { \ /* Used to optionally mark structures with misaligned elements or size as * packed, to trade off performance for space. */ +#ifndef PACKED #ifdef HAVE_FUNC_ATTRIBUTE_PACKED #define PACKED __attribute__((__packed__)) #else #define PACKED #endif +#endif /* Attribute pure is used for functions that have no effects other than their * return value. As a result, calls to it can be dead code eliminated. diff --git a/src/util/os_memory_aligned.h b/src/util/os_memory_aligned.h index 08f12062a7f..48b21e50925 100644 --- a/src/util/os_memory_aligned.h +++ b/src/util/os_memory_aligned.h @@ -1,8 +1,8 @@ /************************************************************************** - * + * * Copyright 2008-2010 VMware, Inc. * All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -10,11 +10,11 @@ * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. @@ -22,7 +22,7 @@ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * + * **************************************************************************/ @@ -48,7 +48,17 @@ add_overflow_size_t(size_t a, size_t b, size_t *res) } -#if defined(HAVE_POSIX_MEMALIGN) +#if defined(_ISOC11_SOURCE) + +static inline void * +os_malloc_aligned(size_t size, size_t alignment) +{ + return aligned_alloc(alignment, (size + alignment - 1) &~ (alignment - 1)); +} + +#define os_free_aligned(_ptr) free(_ptr) + +#elif defined(HAVE_POSIX_MEMALIGN) static inline void * os_malloc_aligned(size_t size, size_t alignment) diff --git a/src/util/os_memory_stdc.h b/src/util/os_memory_stdc.h index bda5715998f..b9b7fa91e5a 100644 --- a/src/util/os_memory_stdc.h +++ b/src/util/os_memory_stdc.h @@ -1,8 +1,8 @@ /************************************************************************** - * + * * Copyright 2008-2010 VMware, Inc. * All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -10,11 +10,11 @@ * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. @@ -22,7 +22,7 @@ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * + * **************************************************************************/ diff --git a/src/util/os_misc.c b/src/util/os_misc.c index e6894731b63..c4df72a657e 100644 --- a/src/util/os_misc.c +++ b/src/util/os_misc.c @@ -60,6 +60,8 @@ # include #elif DETECT_OS_WINDOWS # include +#elif DETECT_OS_SWITCH +# include #else #error unexpected platform in os_sysinfo.c #endif @@ -104,6 +106,8 @@ os_log_message(const char *message) fputs(message, fout); fflush(fout); } +#elif DETECT_OS_SWITCH + svcOutputDebugString(message, __builtin_strlen(message) + 1); #else /* !DETECT_OS_WINDOWS */ fflush(stdout); fputs(message, fout); @@ -177,6 +181,8 @@ os_get_total_physical_memory(uint64_t *size) ret = GlobalMemoryStatusEx(&status); *size = status.ullTotalPhys; return (ret == TRUE); +#elif DETECT_OS_SWITCH + return R_SUCCEEDED(svcGetInfo(size, InfoType_TotalMemorySize, CUR_PROCESS_HANDLE, 0)); #else #error unexpected platform in os_sysinfo.c return false; diff --git a/src/util/os_time.c b/src/util/os_time.c index 92fc3638ddb..2896b200d58 100644 --- a/src/util/os_time.c +++ b/src/util/os_time.c @@ -28,7 +28,7 @@ /** * @file * OS independent time-manipulation functions. - * + * * @author Jose Fonseca */ @@ -36,8 +36,9 @@ #include "detect_os.h" #include "util/u_atomic.h" +#include "c11/threads.h" -#if DETECT_OS_UNIX +#if DETECT_OS_UNIX || DETECT_OS_SWITCH # include /* usleep */ # include /* timeval */ # include /* timeval */ @@ -49,6 +50,10 @@ # error Unsupported OS #endif +#if defined(DETECT_OS_SWITCH) +# include +#endif + int64_t os_time_get_nano(void) @@ -59,7 +64,7 @@ os_time_get_nano(void) clock_gettime(CLOCK_MONOTONIC, &tv); return tv.tv_nsec + tv.tv_sec*INT64_C(1000000000); -#elif DETECT_OS_UNIX +#elif DETECT_OS_UNIX || DETECT_OS_SWITCH struct timeval tv; gettimeofday(&tv, NULL); @@ -108,6 +113,8 @@ os_time_sleep(int64_t usecs) if (dwMilliseconds) { Sleep(dwMilliseconds); } +#elif DETECT_OS_SWITCH + svcSleepThread((u64)usecs * 1000); #else # error Unsupported OS #endif @@ -146,9 +153,7 @@ os_wait_until_zero(volatile int *var, uint64_t timeout) if (timeout == OS_TIMEOUT_INFINITE) { while (p_atomic_read(var)) { -#if DETECT_OS_UNIX - sched_yield(); -#endif + thrd_yield(); } return true; } @@ -160,9 +165,7 @@ os_wait_until_zero(volatile int *var, uint64_t timeout) if (os_time_timeout(start_time, end_time, os_time_get_nano())) return false; -#if DETECT_OS_UNIX - sched_yield(); -#endif + thrd_yield(); } return true; } @@ -182,9 +185,7 @@ os_wait_until_zero_abs_timeout(volatile int *var, int64_t timeout) if (os_time_get_nano() >= timeout) return false; -#if DETECT_OS_UNIX - sched_yield(); -#endif + thrd_yield(); } return true; } diff --git a/src/util/slab.c b/src/util/slab.c index 62634034fdc..cfe0ddcf0d0 100644 --- a/src/util/slab.c +++ b/src/util/slab.c @@ -27,6 +27,7 @@ #include #include #include +#include #define SLAB_MAGIC_ALLOCATED 0xcafe4321 #define SLAB_MAGIC_FREE 0x7ee01234 diff --git a/src/util/u_endian.h b/src/util/u_endian.h index 6bbae3c444c..fd9e02f1daa 100644 --- a/src/util/u_endian.h +++ b/src/util/u_endian.h @@ -1,8 +1,8 @@ /************************************************************************** - * + * * Copyright 2007-2008 VMware, Inc. * All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -10,11 +10,11 @@ * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. @@ -22,7 +22,7 @@ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * + * **************************************************************************/ #ifndef U_ENDIAN_H #define U_ENDIAN_H @@ -73,7 +73,7 @@ # define UTIL_ARCH_BIG_ENDIAN 1 #endif -#elif defined(_WIN32) || defined(ANDROID) +#elif defined(_WIN32) || defined(ANDROID) || defined(__SWITCH__) #define UTIL_ARCH_LITTLE_ENDIAN 1 #define UTIL_ARCH_BIG_ENDIAN 0 ================================================ FILE: switch/miniupnpc/PKGBUILD ================================================ # Contributor: Ezekiel Bethel pkgname=switch-miniupnpc pkgver=2.1.20190824 pkgrel=1 pkgdesc='UPNP support library (for Nintendo Switch homebrew development)' arch=('any') url="http://miniupnp.free.fr/" license=('BSD') options=(!strip libtool staticlibs) source=("http://miniupnp.free.fr/files/download.php?file=miniupnpc-${pkgver}.tar.gz" "miniupnpc.patch") sha256sums=('1fadefea0ecdceb3e35bb5d901f0db880c826740e93148ddfb087b4b4389e165' 'a9e84bdd286f738f6022b5c04160bdf9e4a5a0bd034a9ec55dba0c41ce523852') makedepends=('switch-pkg-config' 'dkp-toolchain-vars') groups=('switch-portlibs') build() { cd miniupnpc-$pkgver source /opt/devkitpro/switchvars.sh export CC=aarch64-none-elf-gcc export CXX=aarch64-none-elf-g++ export LD=aarch64-none-elf-gcc export LDLIBS=$LIBS patch -p1 -i $srcdir/miniupnpc.patch export OVERRIDE_OS_STRING=Horizon/NX HAVE_IPV6=no make } package() { cd miniupnpc-$pkgver source /opt/devkitpro/switchvars.sh make PREFIX=/opt/devkitpro/portlibs/switch DESTDIR="$pkgdir" install } ================================================ FILE: switch/miniupnpc/miniupnpc.patch ================================================ diff -Naur miniupnpc-2.1.20190824/Makefile miniupnpc-2.1.20190824-patched/Makefile --- miniupnpc-2.1.20190824/Makefile 2018-04-06 11:53:30.000000000 +0100 +++ miniupnpc-2.1.20190824-patched/Makefile 2019-10-09 00:12:41.576580022 +0100 @@ -85,9 +85,11 @@ connecthostport.o portlistingparse.o receivedata.o upnpdev.o ifeq (, $(findstring amiga, $(OS))) +ifeq (, $(findstring aarch64-none-elf, $(OS))) ifeq (, $(findstring mingw, $(OS))$(findstring cygwin, $(OS))$(findstring msys, $(OS))) CFLAGS := -fPIC $(CFLAGS) endif +endif LIBOBJS := $(LIBOBJS) minissdpc.o endif @@ -116,6 +118,7 @@ endif endif +ifeq (, $(findstring aarch64-none-elf, $(OS))) EXECUTABLES = upnpc-static listdevices EXECUTABLES_ADDTESTS = testminixml minixmlvalid testupnpreplyparse \ testigddescparse testminiwget testportlistingparse @@ -132,12 +135,15 @@ miniupnpc.o miniwget.o upnpcommands.o upnpreplyparse.o \ minisoap.o connecthostport.o receivedata.o \ portlistingparse.o +endif ifeq (, $(findstring amiga, $(OS))) +ifeq (, $(findstring aarch64-none-elf, $(OS))) EXECUTABLES := $(EXECUTABLES) upnpc-shared TESTMINIWGETOBJS := $(TESTMINIWGETOBJS) minissdpc.o TESTIGDDESCPARSE := $(TESTIGDDESCPARSE) minissdpc.o endif +endif LIBDIR ?= lib # install directories @@ -154,8 +160,12 @@ FILESTOINSTALL = $(LIBRARY) $(EXECUTABLES) ifeq (, $(findstring amiga, $(OS))) +ifneq (, $(findstring aarch64-none-elf, $(OS))) +FILESTOINSTALL := $(FILESTOINSTALL) miniupnpc.pc +else FILESTOINSTALL := $(FILESTOINSTALL) $(SHAREDLIBRARY) miniupnpc.pc endif +endif .PHONY: install clean depend all check test everything \ @@ -237,11 +247,14 @@ $(INSTALL) -d $(DESTDIR)$(INSTALLDIRLIB) $(INSTALL) -m 644 $(LIBRARY) $(DESTDIR)$(INSTALLDIRLIB) ifeq (, $(findstring amiga, $(OS))) +ifeq (, $(findstring aarch64-none-elf, $(OS))) $(INSTALL) -m 644 $(SHAREDLIBRARY) $(DESTDIR)$(INSTALLDIRLIB)/$(SONAME) ln -fs $(SONAME) $(DESTDIR)$(INSTALLDIRLIB)/$(SHAREDLIBRARY) +endif $(INSTALL) -d $(DESTDIR)$(PKGCONFIGDIR) $(INSTALL) -m 644 miniupnpc.pc $(DESTDIR)$(PKGCONFIGDIR) endif +ifeq (, $(findstring aarch64-none-elf, $(OS))) $(INSTALL) -d $(DESTDIR)$(INSTALLDIRBIN) ifneq (, $(findstring amiga, $(OS))) $(INSTALL) -m 755 upnpc-static $(DESTDIR)$(INSTALLDIRBIN)/upnpc @@ -256,6 +269,7 @@ gzip -f $(DESTDIR)$(INSTALLDIRMAN)/man3/miniupnpc.3 endif endif +endif install-static: updateversion $(FILESTOINSTALL) $(INSTALL) -d $(DESTDIR)$(INSTALLDIRINC) diff -Naur miniupnpc-2.1.20190824/minissdpc.c miniupnpc-2.1.20190824-patched/minissdpc.c --- miniupnpc-2.1.20190824/minissdpc.c 2019-06-25 22:30:51.000000000 +0100 +++ miniupnpc-2.1.20190824-patched/minissdpc.c 2019-10-09 00:12:41.576580022 +0100 @@ -52,7 +52,16 @@ #include #include #include +#ifdef __SWITCH__ +/* Hack */ +#define UNIX_PATH_LEN 108 +struct sockaddr_un { + uint16_t sun_family; + char sun_path[UNIX_PATH_LEN]; +}; +#else #include +#endif #include #include #include @@ -62,7 +71,7 @@ #include "miniupnpc_socketdef.h" -#if !defined(__DragonFly__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__sun) && !defined(__GNU__) && !defined(__FreeBSD_kernel__) +#if !defined(__DragonFly__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__sun) && !defined(__GNU__) && !defined(__FreeBSD_kernel__) && !defined(__SWITCH__) #define HAS_IP_MREQN #endif @@ -93,7 +102,7 @@ #include "miniupnpc.h" #include "receivedata.h" -#if !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__)) +#if !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__) || defined(__SWITCH__)) #include "codelength.h" @@ -375,7 +384,7 @@ return devlist; } -#endif /* !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__)) */ +#endif /* !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__) || defined(__SWITCH__)) */ /* parseMSEARCHReply() * the last 4 arguments are filled during the parsing : @@ -667,7 +676,7 @@ if(multicastif) { if(ipv6) { -#if !defined(_WIN32) +#if !defined(_WIN32) && !defined(__SWITCH__) /* according to MSDN, if_nametoindex() is supported since * MS Windows Vista and MS Windows Server 2008. * http://msdn.microsoft.com/en-us/library/bb408409%28v=vs.85%29.aspx */ @@ -705,7 +714,7 @@ { PRINT_SOCKET_ERROR("setsockopt IP_MULTICAST_IF"); } -#elif !defined(_WIN32) +#elif !defined(_WIN32) && !defined(__SWITCH__) struct ifreq ifr; int ifrlen = sizeof(ifr); strncpy(ifr.ifr_name, multicastif, IFNAMSIZ); diff -Naur miniupnpc-2.1.20190824/minissdpc.h miniupnpc-2.1.20190824-patched/minissdpc.h --- miniupnpc-2.1.20190824/minissdpc.h 2019-02-10 12:30:19.000000000 +0000 +++ miniupnpc-2.1.20190824-patched/minissdpc.h 2019-10-09 00:12:41.576580022 +0100 @@ -23,7 +23,7 @@ extern "C" { #endif -#if !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__)) +#if !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__) && defined(__SWITCH__)) MINIUPNP_LIBSPEC struct UPNPDev * getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath, int * error); diff -Naur miniupnpc-2.1.20190824/miniupnpc.c miniupnpc-2.1.20190824-patched/miniupnpc.c --- miniupnpc-2.1.20190824/miniupnpc.c 2019-04-30 10:45:52.000000000 +0100 +++ miniupnpc-2.1.20190824-patched/miniupnpc.c 2019-10-09 00:12:41.576580022 +0100 @@ -297,7 +297,7 @@ if(error) *error = UPNPDISCOVER_UNKNOWN_ERROR; -#if !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) +#if !defined(_WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) && !defined(__SWITCH__) /* first try to get infos from minissdpd ! */ if(!minissdpdsock) minissdpdsock = "/var/run/minissdpd.sock"; @@ -419,7 +419,7 @@ char * s; const char * base; char * p; -#if defined(IF_NAMESIZE) && !defined(_WIN32) +#if defined(IF_NAMESIZE) && !defined(_WIN32) && !defined(__SWITCH__) char ifname[IF_NAMESIZE]; #else /* defined(IF_NAMESIZE) && !defined(_WIN32) */ char scope_str[8]; @@ -444,7 +444,7 @@ if(url[0] != '/') l++; if(scope_id != 0) { -#if defined(IF_NAMESIZE) && !defined(_WIN32) +#if defined(IF_NAMESIZE) && !defined(_WIN32) && !defined(__SWITCH__) if(if_indextoname(scope_id, ifname)) { l += 3 + strlen(ifname); /* 3 == strlen(%25) */ } @@ -463,7 +463,7 @@ p = strchr(s, ']'); if(p) { /* insert %25 into URL */ -#if defined(IF_NAMESIZE) && !defined(_WIN32) +#if defined(IF_NAMESIZE) && !defined(_WIN32) && !defined(__SWITCH__) memmove(p + 3 + strlen(ifname), p, strlen(p) + 1); memcpy(p, "%25", 3); memcpy(p + 3, ifname, strlen(ifname)); diff -Naur miniupnpc-2.1.20190824/miniwget.c miniupnpc-2.1.20190824-patched/miniwget.c --- miniupnpc-2.1.20190824/miniwget.c 2019-02-10 13:25:00.000000000 +0000 +++ miniupnpc-2.1.20190824-patched/miniwget.c 2019-10-09 00:12:41.579913360 +0100 @@ -540,7 +540,7 @@ p2 = strchr(p1, ']'); if(p2 && scope && scope < p2 && scope_id) { /* parse scope */ -#ifdef IF_NAMESIZE +#if defined(IF_NAMESIZE) && !defined(__SWITCH__) char tmp[IF_NAMESIZE]; int l; scope++; diff -Naur miniupnpc-2.1.20190824/updateminiupnpcstrings.sh miniupnpc-2.1.20190824-patched/updateminiupnpcstrings.sh --- miniupnpc-2.1.20190824/updateminiupnpcstrings.sh 2011-01-27 17:50:40.000000000 +0000 +++ miniupnpc-2.1.20190824-patched/updateminiupnpcstrings.sh 2019-10-09 00:15:20.116793159 +0100 @@ -40,10 +40,16 @@ MINIUPNPC_VERSION=`cat VERSION` echo "MiniUPnPc version [${MINIUPNPC_VERSION}]" +if [ -z $OVERRIDE_OS_STRING ]; then EXPR="s|OS_STRING \".*\"|OS_STRING \"${OS_NAME}/${OS_VERSION}\"|" +echo "setting OS_STRING macro value to ${OS_NAME}/${OS_VERSION} in $FILE." +else +EXPR="s|OS_STRING \".*\"|OS_STRING \"${OVERRIDE_OS_STRING}\"|" +echo "setting OS_STRING macro value to ${OVERRIDE_OS_STRING} in $FILE." +fi + #echo $EXPR test -f ${FILE}.in -echo "setting OS_STRING macro value to ${OS_NAME}/${OS_VERSION} in $FILE." sed -e "$EXPR" < $TEMPLATE_FILE > $TMPFILE EXPR="s|MINIUPNPC_VERSION_STRING \".*\"|MINIUPNPC_VERSION_STRING \"${MINIUPNPC_VERSION}\"|" ================================================ FILE: switch/mpg123/.gitignore ================================================ switch-mpg123 mpg123-1.25.10.patch ================================================ FILE: switch/mpg123/PKGBUILD ================================================ # Maintainer: Gabriel Kind pkgname=switch-mpg123 pkgver=1.31.3 pkgrel=3 pkgdesc="A real time MPEG audio decoder for layer 1, 2 and 3" arch=('any') url="http://sourceforge.net/projects/mpg123" license=('LGPL2.1') options=(!strip libtool staticlibs) source=( "http://downloads.sourceforge.net/sourceforge/mpg123/mpg123-${pkgver}.tar.bz2" "mpg123-${pkgver}.patch" ) sha256sums=('6c1337aee2e4bf993299851c70b7db11faec785303cfca3a5c3eb5f329ba7023' '444e46951f6270d926698718b3e52ec548088f1374f56bcd766d5b9783a41051') makedepends=('dkp-toolchain-vars' 'switch-pkg-config') groups=('switch-portlibs') build() { cd mpg123-$pkgver source /opt/devkitpro/switchvars.sh patch -Np1 -i "$srcdir"/mpg123-${pkgver}.patch autoreconf -fi LIBS="-lnx -lm" ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static --enable-fifo=no \ --enable-ipv6=no --enable-network=no --enable-int-quality=no \ --with-cpu=generic --with-default-audio=dummy make } package() { cd mpg123-$pkgver source /opt/devkitpro/devkita64.sh make DESTDIR="$pkgdir" install # remove useless stuff rm -rf "$pkgdir"${PORTLIBS_PREFIX}/bin "$pkgdir"${PORTLIBS_PREFIX}/share } sha256sums=('1ca77d3a69a5ff845b7a0536f783fee554e1041139a6b978f6afe14f5814ad1a' '9af6c4c39d4cc58c5b81bf6e26a95fe9bf8322f583a98ec73f0362214a3c3b89') sha256sums=('1ca77d3a69a5ff845b7a0536f783fee554e1041139a6b978f6afe14f5814ad1a' '99e86f82aa5c53769747c7e104f6d2f3a679b29481df38386321beb6f7ef0b70') ================================================ FILE: switch/mpg123/mpg123-1.31.3.patch ================================================ diff -NBaur mpg123-1.31.3.orig/configure.ac mpg123-1.31.3/configure.ac --- mpg123-1.31.3.orig/configure.ac 2023-03-17 17:10:06.000000000 +0000 +++ mpg123-1.31.3/configure.ac 2023-08-30 19:13:29.093284185 +0100 @@ -1350,6 +1350,20 @@ # Optionally use platform macros for byte swapping. AC_CHECK_HEADERS([byteswap.h]) +if test x"$ac_cv_header_sys_signal_h" = xyes; then + AC_CHECK_FUNCS( sigemptyset sigaddset sigprocmask sigaction ) + if test x"$ac_cv_func_sigemptyset" = xno || + test x"$ac_cv_func_sigaddset" = xno || + test x"$ac_cv_func_sigprocmask" = xno || + test x"$ac_cv_func_sigaction" = xno; then + AC_DEFINE(DONT_CATCH_SIGNALS, 1, [ Signal handling is not supported on this platform ]) + fi +else + AC_DEFINE(DONT_CATCH_SIGNALS, 1, [ Signal handling is not supported on this platform ]) +fi + +AC_CHECK_FUNCS( sleep, [ have_sleep=yes ], [ have_sleep=no ] ) + dnl ############## Choose compiler flags and CPU # do not assume gcc here, so no flags by default diff -NBaur mpg123-1.31.3.orig/libmpg123.pc.in mpg123-1.31.3/libmpg123.pc.in --- mpg123-1.31.3.orig/libmpg123.pc.in 2023-03-15 08:02:58.000000000 +0000 +++ mpg123-1.31.3/libmpg123.pc.in 2023-08-30 19:13:29.093284185 +0100 @@ -7,6 +7,6 @@ Description: An optimised MPEG Audio decoder Requires: Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lmpg123 +Libs: -L${libdir} -lmpg123 -lm Libs.private: @LIBMPG123_LIBS@ Cflags: -I${includedir} diff -NBaur mpg123-1.31.3.orig/libout123.pc.in mpg123-1.31.3/libout123.pc.in --- mpg123-1.31.3.orig/libout123.pc.in 2023-03-15 08:02:58.000000000 +0000 +++ mpg123-1.31.3/libout123.pc.in 2023-08-30 19:13:29.093284185 +0100 @@ -7,6 +7,6 @@ Description: A streaming audio output API derived from mpg123 Requires: Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lout123 +Libs: -L${libdir} -lout123 -lm Libs.private: @LIBOUT123_LIBS@ @LIBDL@ Cflags: -I${includedir} diff -NBaur mpg123-1.31.3.orig/src/control_generic.c mpg123-1.31.3/src/control_generic.c --- mpg123-1.31.3.orig/src/control_generic.c 2023-03-15 08:20:01.000000000 +0000 +++ mpg123-1.31.3/src/control_generic.c 2023-08-30 19:13:29.093284185 +0100 @@ -28,8 +28,10 @@ #include #if !defined (_WIN32) || defined (__CYGWIN__) #include +#ifdef NETWORK #include #endif +#endif #include #include diff -NBaur mpg123-1.31.3.orig/src/Makemodule.am mpg123-1.31.3/src/Makemodule.am --- mpg123-1.31.3.orig/src/Makemodule.am 2023-03-15 08:02:57.000000000 +0000 +++ mpg123-1.31.3/src/Makemodule.am 2023-08-30 19:16:12.291812289 +0100 @@ -1,34 +1,10 @@ # Module for non-recursive mpg123 build system. -include src/tests/Makemodule.am include src/compat/Makemodule.am include src/libmpg123/Makemodule.am include src/libout123/Makemodule.am include src/libsyn123/Makemodule.am -bin_PROGRAMS += \ - src/mpg123 \ - src/out123 \ - src/mpg123-id3dump \ - src/mpg123-strip - -src_mpg123_LDADD = \ - src/compat/libcompat.la \ - src/libmpg123/libmpg123.la \ - src/libout123/libout123.la \ - src/libsyn123/libsyn123.la \ - @PROG_LIBS@ - -src_mpg123_LDFLAGS = @EXEC_LT_LDFLAGS@ - -src_out123_LDADD = \ - src/compat/libcompat.la \ - src/libsyn123/libsyn123.la \ - src/libout123/libout123.la \ - @PROG_LIBS@ - -src_out123_LDFLAGS = @EXEC_LT_LDFLAGS@ - EXTRA_DIST += \ src/intsym.h \ src/mpg123-with-modules \ @@ -36,118 +12,3 @@ CLEANFILES += src/*.a -src_mpg123_id3dump_LDADD = \ - src/compat/libcompat.la \ - src/libmpg123/libmpg123.la \ - @PROG_LIBS@ - -src_mpg123_strip_LDADD = \ - src/compat/libcompat.la \ - src/libmpg123/libmpg123.la \ - @PROG_LIBS@ - -src_mpg123_SOURCES = \ - src/audio.c \ - src/audio.h \ - src/common.c \ - src/common.h \ - src/sysutil.c \ - src/sysutil.h \ - src/control_generic.c \ - src/equalizer.c \ - src/getlopt.c \ - src/getlopt.h \ - src/httpget.c \ - src/httpget.h \ - src/resolver.c \ - src/resolver.h \ - src/genre.h \ - src/genre.c \ - src/mpg123.c \ - src/mpg123app.h \ - src/metaprint.c \ - src/metaprint.h \ - src/local.h \ - src/local.c \ - src/playlist.c \ - src/playlist.h \ - src/streamdump.h \ - src/streamdump.c \ - src/term.c \ - src/term.h \ - src/terms.h \ - src/win32_support.h - -# Does that finally work to build/link the correct object file? -src_mpg123_SOURCES += - -# Replace common.h by sysutil.h! -src_out123_SOURCES = \ - src/sysutil.c \ - src/sysutil.h \ - src/common.h \ - src/getlopt.c \ - src/getlopt.h \ - src/local.h \ - src/local.c \ - src/filters.h \ - src/filters.c \ - src/out123.c \ - src/mpg123app.h \ - src/win32_support.h - -src_mpg123_id3dump_SOURCES = \ - src/mpg123-id3dump.c \ - src/getlopt.c \ - src/getlopt.h - -src_mpg123_strip_SOURCES = \ - src/mpg123-strip.c \ - src/getlopt.c \ - src/getlopt.h - -if TERM_POSIX -src_mpg123_SOURCES += src/term_posix.c -endif - -if TERM_WIN32 -src_mpg123_SOURCES += src/term_win32.c -endif - -if TERM_NONE -src_mpg123_SOURCES += src/term_none.c -endif - -if NET123 -src_mpg123_SOURCES += src/net123.h -endif - -if NET123_EXEC -src_mpg123_SOURCES += src/net123_exec.c -endif - -if NET123_WINHTTP -src_mpg123_SOURCES += src/net123_winhttp.c -src_mpg123_LDADD += -lwinhttp -endif - -if NET123_WININET -src_mpg123_SOURCES += src/net123_wininet.c -src_mpg123_LDADD += -lwininet -endif - -if WIN32_CODES -src_mpg123_SOURCES += \ - src/win32_support.c - -if NETWORK_WINSOCK -src_mpg123_SOURCES += src/win32_net.c -src_mpg123_LDADD += -lws2_32 -endif - -src_out123_SOURCES+= \ - src/win32_support.c - -src_mpg123_id3dump_SOURCES += \ - src/win32_support.c -endif diff -NBaur mpg123-1.31.3.orig/src/mpg123.c mpg123-1.31.3/src/mpg123.c --- mpg123-1.31.3.orig/src/mpg123.c 2023-03-15 08:02:57.000000000 +0000 +++ mpg123-1.31.3/src/mpg123.c 2023-08-30 19:13:29.093284185 +0100 @@ -1334,6 +1334,8 @@ if(param.verbose > 2) fprintf(stderr, "Note: pausing %i seconds before next track.\n", param.delay); #ifdef WIN32 Sleep(param.delay*1000); +#elif !defined(HAVE_SLEEP) + fprintf(stderr, "sleep not supported on this platform\n"); #else sleep(param.delay); #endif ================================================ FILE: switch/mupdf/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Julian Uy pkgname=switch-mupdf pkgver=1.17.0 pkgrel=1 pkgdesc='MuPDF is a lightweight PDF, XPS, and E-book viewer.' arch=('any') url='https://www.mupdf.com/' license=('AGPL') options=(!strip libtool staticlibs) depends=("switch-freetype" "switch-libjpeg-turbo" "switch-zlib" ) makedepends=('dkp-toolchain-vars') source=("https://www.mupdf.com/downloads/archive/mupdf-$pkgver-source.tar.xz" "mupdf.patch") groups=('switch-portlibs') sha256sums=( 'c935fb2593d9a28d9b56b59dad6e3b0716a6790f8a257a68fa7dcb4430bc6086' '5641105980d95c2cb77cf053a13d2255c422767b5c9ec4c2a13c1aa14d1e18bb' ) build() { cd mupdf-$pkgver-source patch --strip=1 --input=$srcdir/mupdf.patch make generate source /opt/devkitpro/switchvars.sh make build=release \ OS=switch \ libs } package() { cd mupdf-$pkgver-source make build=release \ prefix="${PORTLIBS_PREFIX}" DESTDIR="$pkgdir" \ OS=switch \ TOOL_APPS=/dev/null \ VIEW_APPS= \ install } ================================================ FILE: switch/mupdf/mupdf.patch ================================================ diff --git a/Makerules b/Makerules index b96fc7138..91b853208 100644 --- a/Makerules +++ b/Makerules @@ -201,3 +201,18 @@ ifeq "$(OS)" "ios" LD = xcrun ld RANLIB = xcrun ranlib endif + +ifeq "$(OS)" "switch" + CC = $(TOOL_PREFIX)gcc + CXX = $(TOOL_PREFIX)g++ + AR = $(TOOL_PREFIX)ar + LD = $(TOOL_PREFIX)ld + RANLIB = $(TOOL_PREFIX)ranlib + XCFLAGS = $(CPPFLAGS) '-Dtimegm(x)=-1' + USE_SYSTEM_FREETYPE = yes + SYS_FREETYPE_CFLAGS = $(shell freetype-config --cflags) + SYS_FREETYPE_LIBS = $(shell freetype-config --libs) + USE_SYSTEM_LIBJPEG = yes + USE_SYSTEM_ZLIB = yes +endif + diff --git a/source/fitz/string.c b/source/fitz/string.c index 2918c3f16..c8b709c2f 100644 --- a/source/fitz/string.c +++ b/source/fitz/string.c @@ -158,7 +158,11 @@ char *fz_realpath(const char *path, char buf[PATH_MAX]) char *fz_realpath(const char *path, char buf[PATH_MAX]) { +#ifdef __SWITCH__ + return NULL; +#else return realpath(path, buf); +#endif } #endif Submodule thirdparty/harfbuzz contains modified content diff --git a/thirdparty/harfbuzz/src/hb.hh b/thirdparty/harfbuzz/src/hb.hh index fcbd3305..ff36ef63 100644 --- a/thirdparty/harfbuzz/src/hb.hh +++ b/thirdparty/harfbuzz/src/hb.hh @@ -182,6 +182,7 @@ #include #include #include +#include #if (defined(_MSC_VER) && _MSC_VER >= 1500) || defined(__MINGW32__) #ifdef __MINGW32_VERSION Submodule thirdparty/lcms2 05db680de...29b0d7953 (commits not present) Submodule thirdparty/libjpeg 9a532f2d5...cae42f6ea (commits not present) ================================================ FILE: switch/ntfs-3g/PKGBUILD ================================================ # Maintainer: Rhys Koedijk # Maintainer: DarkMatterCore pkgname=switch-ntfs-3g pkgver=2022.10.3 pkgrel=4 pkgdesc='An open source, freely available read/write NTFS driver' arch=('any') url='https://www.tuxera.com/community/open-source-ntfs-3g/' license=('GPL') options=(!strip libtool staticlibs) groups=('switch-portlibs') makedepends=('devkitA64' 'dkp-toolchain-vars') source=( https://tuxera.com/opensource/ntfs-3g_ntfsprogs-${pkgver}.tgz ntfs-3g-${pkgver}.patch ) prepare() { cd ntfs-3g_ntfsprogs-${pkgver} patch -Np1 -i ${srcdir}/ntfs-3g-${pkgver}.patch sed -i 's#$(MAKE) $(AM_MAKEFLAGS) install-exec-hook#$(MAKE) $(AM_MAKEFLAGS)#' libntfs-3g/Makefile.in } build() { cd ntfs-3g_ntfsprogs-${pkgver} source /opt/devkitpro/switchvars.sh CPPFLAGS=-I/opt/devkitpro/libnx/include ./configure --prefix="${PORTLIBS_PREFIX}" \ --host=aarch64-none-elf \ --disable-shared \ --enable-static \ --disable-ntfsprogs \ --disable-ntfs-3g \ --disable-device-default-io-ops \ --disable-plugins \ --without-uuid \ --without-hd make } package() { cd ntfs-3g_ntfsprogs-${pkgver} source /opt/devkitpro/switchvars.sh make install DESTDIR="${pkgdir}" install -Dm644 COPYING "${pkgdir}${PORTLIBS_PREFIX}/licenses/${pkgname}/COPYING" install -Dm644 config.h "${pkgdir}${PORTLIBS_PREFIX}/include/ntfs-3g/config.h" rm -fr "${pkgdir}${PORTLIBS_PREFIX}/share" } sha256sums=('f20e36ee68074b845e3629e6bced4706ad053804cbaf062fbae60738f854170c' 'a37bd1ce5e8e9f8471bbc521a6e4b268d74db6d5ca07607fdab3b09084d5f415') ================================================ FILE: switch/ntfs-3g/ntfs-3g-2022.10.3.patch ================================================ diff --git a/include/ntfs-3g/ntfstime.h b/include/ntfs-3g/ntfstime.h index f3a89dd8..80e163f8 100644 --- a/include/ntfs-3g/ntfstime.h +++ b/include/ntfs-3g/ntfstime.h @@ -39,7 +39,7 @@ /* * assume "struct timespec" is not defined if st_mtime is not defined */ -#if !defined(st_mtime) & !defined(__timespec_defined) +#if !defined(st_mtime) struct timespec { time_t tv_sec; long tv_nsec; diff --git a/libntfs-3g/ioctl.c b/libntfs-3g/ioctl.c index b059a53f..a3a56722 100644 --- a/libntfs-3g/ioctl.c +++ b/libntfs-3g/ioctl.c @@ -48,7 +48,9 @@ #ifdef HAVE_LIMITS_H #include #endif +#ifdef HAVE_SYSLOG_H #include +#endif #ifdef HAVE_SYS_TYPES_H #include #endif ================================================ FILE: switch/ode/PKGBUILD ================================================ # Maintainer: davidgfnet pkgname=switch-ode pkgver=0.16.4 pkgrel=1 pkgdesc='High performance library for simulating rigid body dynamics' arch=('any') url='http://ode.org/' license=('BSD') options=(!strip libtool staticlibs) source=("https://bitbucket.org/odedevs/ode/downloads/ode-${pkgver}.tar.gz") makedepends=('dkp-toolchain-vars') groups=('switch-portlibs') build() { cd ode-$pkgver source /opt/devkitpro/switchvars.sh # Demos depend on GL and X11, disable since they are not useful to us. ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-demos --enable-static } package() { cd ode-$pkgver source /opt/devkitpro/switchvars.sh make install DESTDIR="$pkgdir" } sha256sums=('71037b8281c6c86b0a55729f90d5db697abe4cbec1d8118157e00d48ec253467') ================================================ FILE: switch/oniguruma/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: uyjulian pkgname=switch-oniguruma pkgver=6.9.2 pkgrel=2 pkgdesc='Oniguruma is a modern and flexible regular expressions library. It encompasses features from different regular expression implementations that traditionally exist in different languages.' arch=('any') url='https://github.com/kkos/oniguruma/' license=('BSD') options=(!strip libtool staticlibs) makedepends=('dkp-toolchain-vars') groups=('switch-portlibs') source=("https://github.com/kkos/oniguruma/releases/download/v$pkgver/onig-$pkgver.tar.gz") sha256sums=('db7addb196ecb34e9f38d8f9c97b29a3e962c0e17ea9636127b3e3c42f24976a') build() { cd onig-$pkgver source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { cd onig-$pkgver make DESTDIR="$pkgdir" install } ================================================ FILE: switch/openal-soft/PKGBUILD ================================================ # Maintainer: Mary Strodl pkgname=switch-openal-soft pkgver=1.21.1 pkgrel=5 pkgdesc='OpenAL Soft is a software implementation of the OpenAL 3D audio API.' arch=('any') url='https://openal-soft.org/' license=(LGPL) options=(!strip libtool staticlibs) source=( "https://openal-soft.org/openal-releases/openal-soft-$pkgver.tar.bz2" "avoid-readlink.patch" ) sha256sums=( 'c8ad767e9a3230df66756a21cc8ebf218a9d47288f2514014832204e666af5d8' '7dcacf0ce7179276aee5c07e7b18ead1e1c23933b11506ccb74ce3513983ec9a' ) makedepends=('switch-pkg-config' 'dkp-toolchain-vars' 'switch-cmake') depends=('switch-sdl2') groups=('switch-portlibs') prepare() { cd openal-soft-${pkgver} patch -Np1 -i ${srcdir}/avoid-readlink.patch sed -i 's#SDL2/##' alc/backends/sdl2.cpp } build() { cd openal-soft-${pkgver}/build source "${DEVKITPRO}/switchvars.sh" aarch64-none-elf-cmake -G"Unix Makefiles" \ -DUSE_SWITCH=ON -DALSOFT_UTILS=OFF -DLIBTYPE=STATIC -DALSOFT_EXAMPLES=OFF \ -DALSOFT_REQUIRE_SDL2=ON -DALSOFT_BACKEND_SDL2=ON \ -DSDL2_INCLUDE_DIR="${PORTLIBS_PREFIX}/include" \ -DCMAKE_INSTALL_PREFIX="${PORTLIBS_PREFIX}" \ ../ make } package() { cd openal-soft-${pkgver}/build make install DESTDIR="${pkgdir}" } ================================================ FILE: switch/openal-soft/avoid-readlink.patch ================================================ diff --git a/alc/helpers.cpp b/alc/helpers.cpp index 8c1c8562..fe967f7f 100644 --- a/alc/helpers.cpp +++ b/alc/helpers.cpp @@ -205,9 +205,8 @@ void SetRTPriority(void) const PathNamePair &GetProcBinary() { - static PathNamePair ret; - if(!ret.fname.empty() || !ret.path.empty()) - return ret; + static al::optional procbin; + if(procbin) return *procbin; al::vector pathname; #ifdef __FreeBSD__ @@ -241,6 +240,7 @@ const PathNamePair &GetProcBinary() pathname.insert(pathname.end(), procpath, procpath+strlen(procpath)); } #endif +#ifndef __SWITCH__ if(pathname.empty()) { static const char SelfLinkNames[][32]{ @@ -269,25 +269,25 @@ const PathNamePair &GetProcBinary() if(len <= 0) { WARN("Failed to readlink %s: %s\n", selfname, strerror(errno)); - return ret; + len = 0; } pathname.resize(static_cast(len)); } +#endif while(!pathname.empty() && pathname.back() == 0) pathname.pop_back(); auto sep = std::find(pathname.crbegin(), pathname.crend(), '/'); if(sep != pathname.crend()) - { - ret.path = std::string(pathname.cbegin(), sep.base()-1); - ret.fname = std::string(sep.base(), pathname.cend()); - } + procbin = al::make_optional(std::string(pathname.cbegin(), sep.base()-1), + std::string(sep.base(), pathname.cend())); else - ret.fname = std::string(pathname.cbegin(), pathname.cend()); + procbin = al::make_optional(std::string{}, + std::string(pathname.cbegin(), pathname.cend())); - TRACE("Got binary: %s, %s\n", ret.path.c_str(), ret.fname.c_str()); - return ret; + TRACE("Got binary: \"%s\", \"%s\"\n", procbin->path.c_str(), procbin->fname.c_str()); + return *procbin; } namespace { ================================================ FILE: switch/opusfile/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=switch-opusfile pkgver=0.11 pkgrel=1 pkgdesc='Library for opening, seeking, and decoding .opus files' arch=('any') url='https://opus-codec.org/' license=(BSD) options=(!strip libtool staticlibs) source=("https://downloads.xiph.org/releases/opus/opusfile-$pkgver.tar.gz") sha256sums=('74ce9b6cf4da103133e7b5c95df810ceb7195471e1162ed57af415fabf5603bf') makedepends=('switch-pkg-config' 'dkp-toolchain-vars') depends=('switch-libogg' 'switch-libopus') groups=('switch-portlibs') build() { cd opusfile-$pkgver source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --enable-fixed-point --disable-shared --enable-static make } package() { cd opusfile-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: switch/physfs/PKGBUILD ================================================ # Maintainer: Ezekiel Bethel _realname=physfs pkgname=switch-${_realname} pkgver=3.2.0 pkgrel=3 pkgdesc='A library to provide abstract access to various archives.' arch=('any') url='https://icculus.org/physfs/' license=('zlib') options=(!strip libtool staticlibs) source=( "${_realname}-${pkgver}.tar.gz::https://github.com/icculus/physfs/archive/refs/tags/release-${pkgver}.tar.gz" "physfs-${pkgver}.patch") makedepends=('devkitA64' 'dkp-toolchain-vars' 'switch-cmake') groups=('switch-portlibs') build() { cd physfs-release-$pkgver patch -Np1 -i "$srcdir"/physfs-${pkgver}.patch source ${DEVKITPRO}/switchvars.sh aarch64-none-elf-cmake -G"Unix Makefiles" \ -DCMAKE_INSTALL_PREFIX=/opt/devkitpro/portlibs/switch \ -DPHYSFS_BUILD_STATIC=ON -DPHYSFS_BUILD_SHARED=OFF \ -DPHYSFS_BUILD_TEST=OFF \ . make } package() { cd physfs-release-$pkgver make install DESTDIR="$pkgdir" } sha256sums=('1991500eaeb8d5325e3a8361847ff3bf8e03ec89252b7915e1f25b3f8ab5d560' '12e6df2b53f2ee51a205f363d51b4b01f92e4a67159bb63628a6d1cec482985f') ================================================ FILE: switch/physfs/physfs-3.2.0.patch ================================================ diff -NBaur physfs-release-3.2.0/CMakeLists.txt physfs-release-3.2.0.patch/CMakeLists.txt --- physfs-release-3.2.0/CMakeLists.txt 2022-09-30 21:13:07.000000000 +0100 +++ physfs-release-3.2.0.patch/CMakeLists.txt 2023-04-06 08:40:21.147542456 +0100 @@ -81,6 +81,7 @@ src/physfs_platform_unix.c src/physfs_platform_windows.c src/physfs_platform_os2.c + src/physfs_platform_switch.c src/physfs_platform_qnx.c src/physfs_platform_android.c src/physfs_archiver_dir.c diff -NBaur physfs-release-3.2.0/src/physfs_internal.h physfs-release-3.2.0.patch/src/physfs_internal.h --- physfs-release-3.2.0/src/physfs_internal.h 2022-09-30 21:13:07.000000000 +0100 +++ physfs-release-3.2.0.patch/src/physfs_internal.h 2023-04-06 08:39:25.297655401 +0100 @@ -108,6 +108,10 @@ const void *__PHYSFS_winrtCalcPrefDir(void); #endif +#ifdef PHYSFS_PLATFORM_SWITCH +char *__PHYSFS_switchCalcUserDir(void); +#endif + /* atomic operations. */ /* increment/decrement operations return the final incremented/decremented value. */ #if defined(_MSC_VER) && (_MSC_VER >= 1500) diff -NBaur physfs-release-3.2.0/src/physfs_platform_posix.c physfs-release-3.2.0.patch/src/physfs_platform_posix.c --- physfs-release-3.2.0/src/physfs_platform_posix.c 2022-09-30 21:13:07.000000000 +0100 +++ physfs-release-3.2.0.patch/src/physfs_platform_posix.c 2023-04-06 08:39:25.297655401 +0100 @@ -58,6 +58,9 @@ static char *getUserDirByUID(void) { +#ifdef PHYSFS_PLATFORM_SWITCH + return __PHYSFS_switchCalcUserDir(); +#else uid_t uid = getuid(); struct passwd *pw; char *retval = NULL; @@ -78,13 +81,17 @@ } /* if */ } /* if */ } /* if */ - + return retval; +#endif } /* getUserDirByUID */ char *__PHYSFS_platformCalcUserDir(void) { +#ifdef PHYSFS_PLATFORM_SWITCH + return __PHYSFS_switchCalcUserDir(); +#endif char *retval = NULL; char *envr = getenv("HOME"); @@ -362,7 +369,12 @@ st->createtime = statbuf.st_ctime; st->accesstime = statbuf.st_atime; +#ifdef PHYSFS_PLATFORM_SWITCH + /* shortcut */ + st->readonly = !(statbuf.st_mode & S_IWRITE); +#else st->readonly = (access(fname, W_OK) == -1); +#endif return 1; } /* __PHYSFS_platformStat */ diff -NBaur physfs-release-3.2.0/src/physfs_platforms.h physfs-release-3.2.0.patch/src/physfs_platforms.h --- physfs-release-3.2.0/src/physfs_platforms.h 2022-09-30 21:13:07.000000000 +0100 +++ physfs-release-3.2.0.patch/src/physfs_platforms.h 2023-04-06 08:39:25.297655401 +0100 @@ -72,6 +72,10 @@ #elif defined(unix) || defined(__unix__) # define PHYSFS_PLATFORM_UNIX 1 # define PHYSFS_PLATFORM_POSIX 1 +#elif defined(__SWITCH__) +# define PHYSFS_PLATFORM_POSIX 1 +# define PHYSFS_PLATFORM_SWITCH 1 +# define PHYSFS_NO_CDROM_SUPPORT 1 #else # error Unknown platform. #endif diff -NBaur physfs-release-3.2.0/src/physfs_platform_switch.c physfs-release-3.2.0.patch/src/physfs_platform_switch.c --- physfs-release-3.2.0/src/physfs_platform_switch.c 1970-01-01 01:00:00.000000000 +0100 +++ physfs-release-3.2.0.patch/src/physfs_platform_switch.c 2023-04-06 08:39:25.297655401 +0100 @@ -0,0 +1,106 @@ +/* + * Nintendo Switch support routines for PhysicsFS. + * + * Please see the file LICENSE.txt in the source's root directory. + * + */ + + +#define __PHYSICSFS_INTERNAL__ +#include "physfs_platforms.h" + +#ifdef PHYSFS_PLATFORM_SWITCH + +#include + +// for getcwd +#include +// for PATH_MAX +#include + +#include "physfs_internal.h" + +int __PHYSFS_platformInit(void) +{ + return 1; /* always succeed. */ +} /* __PHYSFS_platformInit */ + + +void __PHYSFS_platformDeinit(void) +{ + /* no-op */ +} /* __PHYSFS_platformDeinit */ + + +void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data) +{ + /* no-op */ +} + +char *__PHYSFS_switchCalcUserDir(void) +{ + /* Use the jail directory (hopefully) found before. */ + return __PHYSFS_strdup(PHYSFS_getBaseDir()); +} + +char *__PHYSFS_platformCalcBaseDir(const char *argv0) +{ + char *retval = NULL; + /* As there is no system-specific directory, directly inspect argv0. */ + if (argv0 == NULL) + { + /* User did not provide a path, just use the current working directory. + * As physfs should be initialized soon after application start, this + * should give us a useable directory. + */ + char fullpath[PATH_MAX]; + if (getcwd(fullpath, sizeof(fullpath)) != NULL) + { + const size_t cwdlen = strlen(fullpath); + /* getcwd does not provide a trailing slash, add it. */ + retval = (char*) allocator.Malloc(cwdlen + 2); + BAIL_IF(!retval, PHYSFS_ERR_OUT_OF_MEMORY, NULL); + strncpy(retval, fullpath, cwdlen); + retval[cwdlen] = '/'; + retval[cwdlen + 1] = '\0'; + } + } + else + { + /* nx-hbmenu should give us the full path of the application, this may + * reside in a subfolder. Higher level code will strip away the name + * and extension. + */ + return NULL; + } + + if (!retval) + /* Last resort: use `/switch` directory. */ + retval = __PHYSFS_strdup("/switch/"); + + return retval; +} /* __PHYSFS_platformCalcBaseDir */ + +char *__PHYSFS_platformCalcPrefDir(const char *org, const char *app) +{ + char *retval = NULL; + size_t len = 0; + + /* Use the jail directory (hopefully) found before. This way we do not + * need to add an application folder, because it is exclusive. + */ + const char *envr = __PHYSFS_getUserDir(); + BAIL_IF_ERRPASS(!envr, NULL); + const char *append = ".config/"; + len = strlen(envr) + strlen(append) + 1; + retval = (char *) allocator.Malloc(len); + BAIL_IF(!retval, PHYSFS_ERR_OUT_OF_MEMORY, NULL); + snprintf(retval, len, "%s%s", envr, append); + + return retval; +} /* __PHYSFS_platformCalcPrefDir */ + + +#endif /* PHYSFS_PLATFORM_SWITCH */ + +/* end of physfs_platform_switch.cpp ... */ ================================================ FILE: switch/pkg-config/.gitignore ================================================ switch-pkg-config ================================================ FILE: switch/pkg-config/PKGBUILD ================================================ \ # Maintainer: WinterMute pkgname=switch-pkg-config pkgver=0.28 pkgrel=4 pkgdesc='pkg-config wrapper (for Nintendo Switch homebrew development)' arch=('any') url='http://devkitpro.org/' source=('pkg-config.in') sha256sums=('7669a9c9c6b739a63d08d631cb252e91b4180f5644e1ed482bf80d1a6e8570fe') groups=('switch-dev') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/switch/bin cp "$srcdir"/pkg-config.in "$pkgdir"/opt/devkitpro/portlibs/switch/bin/aarch64-none-elf-pkg-config } ================================================ FILE: switch/pkg-config/pkg-config.in ================================================ #!/usr/bin/env bash command -v pkg-config >/dev/null 2>&1 || { echo >&2 "I require pkg-config but it's not installed. Aborting."; exit 1; } # reset pkg-config variables to ensure we're not polluted by host libraries export PKG_CONFIG_DIR= export PKG_CONFIG_PATH= export PKG_CONFIG_SYSROOT_DIR= export PKG_CONFIG_LIBDIR=${DEVKITPRO}/portlibs/switch/lib/pkgconfig [[ "$1" == '--version' ]] && exec pkg-config --version exec pkg-config --static "$@" ================================================ FILE: switch/smpeg2/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: uyjulian pkgname=switch-smpeg2 pkgver=2.0.0 pkgrel=1 pkgdesc="SDL2 MPEG Player Library" arch=('any') url="https://icculus.org/smpeg/" license=("LGPL") options=(!strip libtool staticlibs) makedepends=('switch-pkg-config' 'dkp-toolchain-vars') depends=('switch-sdl2') source=("https://www.libsdl.org/projects/smpeg/release/smpeg2-${pkgver}.tar.gz" "smpeg2-${pkgver}.patch" "config.sub" "config.guess") sha256sums=( '979a65b211744a44fa641a9b6e4d64e64a12ff703ae776bafe3c4c4cd85494b3' 'a5bff7b522640160cfb8bac5b8ab029ef1881fd0a9fb85b1ac98b6916b6c4318' '72e02ea93447038f8ced24f296b31e0f397bbcc6b32abdcf9b38c80f153433fd' 'fbc2337aa59a204f5d74743b82c8be7aab8b39853b4e54a888008f70430c4305' ) groups=('switch-portlibs' 'switch-sdl2') build() { cp config.sub smpeg2-$pkgver cp config.guess smpeg2-$pkgver cd smpeg2-$pkgver patch -p1 -i $srcdir/smpeg2-$pkgver.patch ./autogen.sh source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" \ --host=aarch64-none-elf \ --enable-mmx=no \ --disable-shared --enable-static \ --disable-sdltest \ --with-sdl-prefix="${PORTLIBS_PREFIX}" make } package() { cd smpeg2-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install } ================================================ FILE: switch/smpeg2/config.guess ================================================ #! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2015 Free Software Foundation, Inc. timestamp='2015-08-20' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ /sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || \ echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` machine=${arch}${endian}-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case "${UNAME_MACHINE_ARCH}" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; *:Sortix:*:*) echo ${UNAME_MACHINE}-unknown-sortix exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; e2k:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: ================================================ FILE: switch/smpeg2/config.sub ================================================ #! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2015 Free Software Foundation, Inc. timestamp='2015-08-20' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | e2k | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; asmjs) basic_machine=asmjs-unknown ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; leon-*|leon[3-9]-*) basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: ================================================ FILE: switch/smpeg2/smpeg2-2.0.0.patch ================================================ diff -burN smpeg2-2.0.0.orig/Makefile.am smpeg2-2.0.0/Makefile.am --- smpeg2-2.0.0.orig/Makefile.am 2013-06-01 12:07:34.000000000 -0500 +++ smpeg2-2.0.0/Makefile.am 2019-09-05 00:40:57.171582582 -0500 @@ -89,13 +89,6 @@ video/32bit_mmx.lo: video/32bit_mmx.cpp $(CXX) -c -o $@ $^ $(CXXFLAGS) -bin_PROGRAMS = plaympeg - -# Sources for plaympeg -man_MANS = plaympeg.1 -plaympeg_SOURCES = plaympeg.c -plaympeg_LDADD = libsmpeg2.la - # M4 macro file for inclusion with autoconf m4datadir = $(datadir)/aclocal m4data_DATA = smpeg2.m4 diff -burN smpeg2-2.0.0.orig/audio/hufftable.cpp smpeg2-2.0.0/audio/hufftable.cpp --- smpeg2-2.0.0.orig/audio/hufftable.cpp 2013-06-01 10:19:04.000000000 -0500 +++ smpeg2-2.0.0/audio/hufftable.cpp 2019-09-05 00:34:53.829039491 -0500 @@ -9,6 +9,7 @@ #include "config.h" #endif +#include #include "MPEGaudio.h" static const unsigned int @@ -550,11 +551,11 @@ const HUFFMANCODETABLE MPEGaudio::ht[HTN]= { - { 0, 0-1, 0-1, 0, 0, htd33}, + { 0, UINT_MAX, UINT_MAX, 0, 0, htd33}, { 1, 2-1, 2-1, 0, 7,htd01}, { 2, 3-1, 3-1, 0, 17,htd02}, { 3, 3-1, 3-1, 0, 17,htd03}, - { 4, 0-1, 0-1, 0, 0, htd33}, + { 4, UINT_MAX, UINT_MAX, 0, 0, htd33}, { 5, 4-1, 4-1, 0, 31,htd05}, { 6, 4-1, 4-1, 0, 31,htd06}, { 7, 6-1, 6-1, 0, 71,htd07}, @@ -564,7 +565,7 @@ {11, 8-1, 8-1, 0,127,htd11}, {12, 8-1, 8-1, 0,127,htd12}, {13,16-1,16-1, 0,511,htd13}, - {14, 0-1, 0-1, 0, 0, htd33}, + {14, UINT_MAX, UINT_MAX, 0, 0, htd33}, {15,16-1,16-1, 0,511,htd15}, {16,16-1,16-1, 1,511,htd16}, {17,16-1,16-1, 2,511,htd16}, ================================================ FILE: switch/wslay/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=switch-wslay pkgver=1.1.0 pkgrel=1 pkgdesc='Wslay is a WebSocket library written in C.' arch=('any') url="https://github.com/tatsuhiro-t/wslay" license=('MIT') options=(!strip libtool staticlibs) source=("https://github.com/tatsuhiro-t/wslay/releases/download/release-${pkgver}/wslay-${pkgver}.tar.gz") sha256sums=('0de975a31818f1c660fa3c674b17bbcbda6ad9c866402ac8ab46a1847325118e') makedepends=('dkp-toolchain-vars') groups=('switch-portlibs') build() { cd wslay-$pkgver source /opt/devkitpro/switchvars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { cd wslay-$pkgver source /opt/devkitpro/switchvars.sh make DESTDIR="$pkgdir" install # license install -Dm644 COPYING "$pkgdir"${PORTLIBS_PREFIX}/licenses/$pkgname/COPYING # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share } ================================================ FILE: switch/xxhash/PKGBUILD ================================================ # Contributor: averne pkgbasename=xxhash pkgname=switch-${pkgbasename} pkgver=0.8.2 pkgrel=1 pkgdesc='Extremely fast non-cryptographic hash algorithm' arch=('any') url="http://www.xxhash.com/" license=('BSD') options=(!strip libtool staticlibs) source=("https://github.com/Cyan4973/xxHash/archive/refs/tags/v${pkgver}.zip") makedepends=('dkp-toolchain-vars') groups=('switch-portlibs') build() { cd xxHash-$pkgver source /opt/devkitpro/switchvars.sh make libxxhash.a } package() { cd xxHash-$pkgver source /opt/devkitpro/switchvars.sh make PREFIX="$PORTLIBS_PREFIX" DESTDIR="$pkgdir" install_libxxhash.a install_libxxhash.includes install_libxxhash.pc install -Dm644 LICENSE "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/LICENSE" } sha256sums=('a33d7e8798bebb297095b715f93a71c5e535919434ce27ddc65e72e4e0fda3b9') ================================================ FILE: switch/zlib/.gitignore ================================================ switch-zlib ================================================ FILE: switch/zlib/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=switch-zlib pkgver=1.3.1 pkgrel=1 pkgdesc='Deflate compression method library' arch=('any') url='http://www.zlib.net' license=('zlib') options=(!strip libtool staticlibs) source=("${url}/zlib-$pkgver.tar.xz") sha256sums=( '8a9ba2898e1d0d774eca6ba5b4627a11e5588ba85c8851336eb38de4683050a7' ) makedepends=('dkp-toolchain-vars') groups=('switch-portlibs') build() { source /opt/devkitpro/switchvars.sh cd zlib-$pkgver CFLAGS="-g -O2 -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec" \ CHOST=aarch64-none-elf \ ./configure --prefix="/opt/devkitpro/portlibs/switch" --static make libz.a # only build library, no programs # libminizip cd contrib/minizip autoreconf --force --verbose --install CFLAGS="${CFLAGS} -DUSE_FILE32API" ./configure --prefix="${PORTLIBS_PREFIX}" --host=aarch64-none-elf \ --disable-shared --enable-static make } package() { source /opt/devkitpro/switchvars.sh cd zlib-$pkgver # zlib make DESTDIR="$pkgdir" install # license install -d "$pkgdir"/opt/devkitpro/portlibs/switch/licenses/$pkgname tail -n 31 README > "$pkgdir"/opt/devkitpro/portlibs/switch/licenses/$pkgname/LICENSE # remove useless stuff rm -r "$pkgdir"/opt/devkitpro/portlibs/switch/share # libminizip cd contrib/minizip make DESTDIR="$pkgdir" install } sha256sums=('38ef96b8dfe510d42707d9c781877914792541133e1870841463bfa73f883e32') ================================================ FILE: switch/zziplib/PKGBUILD ================================================ # Maintainer: COMP Omega pkgname=switch-zziplib pkgver=0.13.78 pkgrel=1 pkgdesc='The ZZIPlib provides read access on ZIP-archives and unpacked data. It features an additional simplified API following the standard Posix API for file access' arch=('any') url='https://github.com/gdraheim/zziplib/' license=('LGPL') options=(!strip libtool staticlibs) source=( "zziplib-${pkgver}.tar.gz::https://github.com/gdraheim/zziplib/archive/v${pkgver}.tar.gz" zziplib-${pkgver}.patch ) depends=('switch-zlib') makedepends=('devkitA64' 'dkp-toolchain-vars') groups=('switch-portlibs') prepare() { cd zziplib-${pkgver} patch -Np1 -i ${srcdir}/zziplib-${pkgver}.patch } build() { cd zziplib-${pkgver} /opt/devkitpro/portlibs/switch/bin/aarch64-none-elf-cmake -B _build -S . \ -DZZIPMMAPPED=OFF \ -DZZIPWRAP=OFF \ -DZZIPSDL=OFF \ -DZZIPBINS=OFF \ -DZZIPTEST=OFF \ -DZZIPDOCS=OFF \ -DZZIP_PKGCONFIG=ON cmake --build _build } package() { cd zziplib-$pkgver DESTDIR="$pkgdir" cmake --install _build } sha256sums=('feaeee7c34f18aa27bd3da643cc6a47d04d2c41753a59369d09102d79b9b0a31' '3d9f795c6999ac8fcfc8a6a68cfa7b4a847c3511ed24c8f5eaf7c4dd85ad0e6c') ================================================ FILE: switch/zziplib/zziplib-0.13.78.patch ================================================ diff --git a/zzip/CMakeLists.txt b/zzip/CMakeLists.txt index 28f03aa..050fea2 100644 --- a/zzip/CMakeLists.txt +++ b/zzip/CMakeLists.txt @@ -149,7 +149,6 @@ endif() # Zlib library needed find_package ( ZLIB REQUIRED ) -set(CMAKE_POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}) add_definitions ( -DHAVE_CONFIG_H ) set(RELNUM "${PROJECT_VERSION_MAJOR}") ================================================ FILE: switch-examples/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('switch-examples') pkgver=20260201 pkgrel=1 pkgdesc="Nintendo Switch example code." arch=('any') license=('custom') url="http://github.com/switchbrew/switch-examples" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz) sha256sums=('2df8541173eb417d73c924c83ae587a59256337bc7130f72e34c2ea2fd116037') makedepends=('devkitA64') groups=('switch-dev') package() { mkdir -p $pkgdir/opt/devkitpro/examples/switch cp -R $srcdir/$pkgname-$pkgver/* $pkgdir/opt/devkitpro/examples/switch } sha256sums=('f50dfc9ece054ac3df0049193862e5a6782794d939f8630af27ccda6103a3b48') ================================================ FILE: wii/SDL/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Sergio Padrino pkgname=wii-sdl pkgver=1.2.15 pkgrel=21 pkgdesc="A library for portable low-level access to a video framebuffer, audio output, mouse, and keyboard" arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) makedepends=('wii-pkg-config' 'dkp-toolchain-vars') depends=('wii-opengx' 'libogc') source=("${url}/release/SDL-${pkgver}.tar.gz" "SDL-1.2.15.patch" "config.site") groups=('wii-portlibs' 'wii-sdl-libs') build() { cd SDL-$pkgver source /opt/devkitpro/wiivars.sh patch -p1 -i $srcdir/SDL-1.2.15.patch ./autogen.sh CONFIG_SITE=${srcdir}/config.site ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static --enable-nintendo-wii make } package() { cd SDL-$pkgver source /opt/devkitpro/wiivars.sh make DESTDIR="$pkgdir" install # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share sed -i'' -e "s/-lOpenGL//" "$pkgdir"${PORTLIBS_PREFIX}/lib/pkgconfig/sdl.pc } sha256sums=('d6d316a793e5e348155f0dd93b979798933fb98aa1edebcc108829d6474aad00' '01c7184f7f8db37ae0faa04c3fc59c99bfeb2aa6de9101fe81bf0ba9a959e82f' '7a5c15f9024100ed893689133746ca9e3ac2613fef9ee82339ac0a41c0192b1f') ================================================ FILE: wii/SDL/SDL-1.2.15.patch ================================================ diff --git a/README.ogc b/README.ogc new file mode 100644 index 0000000000..ccda9877c4 --- /dev/null +++ b/README.ogc @@ -0,0 +1,37 @@ +# SDL port for Nintendo GameCube/Wii + +This port uses the libogc library and the devkitPPC toolchain, available from +http://www.devkitpro.org + + +## Installation instructions + +We highly recommend using the devkitPro pre-built packages provided via pacman +(https://devkitpro.org/wiki/devkitPro_pacman) unless intending to contribute +changes to this port. + + +## Build instructions + +If you need to hack on libSDL itself then the best way to start is by cloning +the package repo at https://github.com/devkitPro/pacman-packages. The GameCube +package is found under gamecube/SDL and the wii one, surprisingly, under +wii/SDL. cd to the appropriate directory and run makepkg PKGDEST=. there +(on systems without a native pacman this will be dkp-pacman). This will produce +a .pkg.tar.zst file in the current directory which can then be installed for +testing with (dkp-)pacman -U ./.pkg.tar.zst. Once that's done you can +modify the code under src/SDL-1.2.15/. To build with your changes first source +the appropriate toolchain vars script - either /opt/devkitpro/wiivars.sh or +/opt/devkitpro/cubevars.sh then run make. To install you can run sudo -E make +install. + +The easiest way to contribute changes is to fork our SDL repo at +https://github.com/devkitPro/SDL/ then clone that to src/SDL-1.2.15, replacing +the extracted source. This port is on the ogc-sdl-1.2 branch. Create your own +branch from that, commit your changes and make a PR request to the devkitPro +repo. + +If you need further assistance with this then please ask on the forums at +https://devkitpro.org/viewforum.php?f=40 + +Happy hacking! \ No newline at end of file diff --git a/configure.in b/configure.in index 08c8e1e97c..be3f073d64 100644 --- a/configure.in +++ b/configure.in @@ -925,6 +925,99 @@ AC_HELP_STRING([--enable-ipod], [configure SDL to work with iPodLinux [[default= fi } +CheckOpenGX() +{ + AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + AC_MSG_CHECKING(for opengx) + if test x$PKG_CONFIG != xno; then + OPENGX_CFLAGS=`$PKG_CONFIG --cflags opengl` + OPENGX_LIBS=`$PKG_CONFIG --libs opengl` + opengx=yes + AC_DEFINE(SDL_VIDEO_OPENGL) + fi + AC_MSG_RESULT($opengx) +} + +CheckNintendoWii() +{ + AC_ARG_ENABLE(nintendo-wii, +AC_HELP_STRING([--enable-nintendo-wii], [configure SDL to work with Nintendo Wii [[default=no]]]), + , enable_nintendo_wii=no) + if test x$enable_nintendo_wii = xyes; then + ARCH=nintendo-wii + WII_CFLAGS="-mrvl -mcpu=750 -meabi -mhard-float \ + -Wall -O2 \ + -I${DEVKITPRO}/libogc/include -DGEKKO \ + -I${DEVKITPRO}/portlibs/wii/include \ + -I${DEVKITPRO}/portlibs/ppc/include" + EXTRA_CFLAGS="$EXTRA_CFLAGS $WII_CFLAGS" + CFLAGS="$CFLAGS $WII_CFLAGS $OPENGX_CFLAGS" + SDL_CFLAGS="$SDL_CFLAGS $WII_CFLAGS" + SDL_LIBS="-mrvl -mcpu=750 -meabi -mhard-float \ + -L${DEVKITPRO}/portlibs/wii/lib \ + -L${DEVKITPRO}/portlibs/ppc/lib -lSDLmain $SDL_LIBS $OPENGX_LIBS \ + -L${DEVKITPRO}/libogc/lib/wii -laesnd -lwiiuse -lbte -lwiikeyboard -lfat -lopengx -logc -lm" + AC_DEFINE(SDL_TIMER_OGC) + SOURCES="$SOURCES $srcdir/src/timer/ogc/*.c" + have_timers=yes + AC_DEFINE(SDL_AUDIO_DRIVER_OGC) + SOURCES="$SOURCES $srcdir/src/audio/ogc/*.c" + have_audio=yes + AC_DEFINE(SDL_JOYSTICK_OGC) + SOURCES="$SOURCES $srcdir/src/joystick/ogc/*.c" + have_joystick=yes + AC_DEFINE(SDL_THREAD_OGC) + SOURCES="$SOURCES $srcdir/src/thread/ogc/*.c" + have_threads=yes + AC_DEFINE(SDL_VIDEO_DRIVER_OGC) + SOURCES="$SOURCES $srcdir/src/video/wii/*.c" + SOURCES="$SOURCES $srcdir/src/video/ogc/*.c" + SDLMAIN_SOURCES="$srcdir/src/main/wii/*.c" + SDLMAIN_LDFLAGS="-static" + have_video=yes + fi +} + +CheckNintendoGamecube() +{ + AC_ARG_ENABLE(nintendo-gamecube, +AC_HELP_STRING([--enable-nintendo-gamecube], [configure SDL to work with Nintendo Gamecube [[default=no]]]), + , enable_nintendo_wii=no) + if test x$enable_nintendo_gamecube = xyes; then + ARCH=nintendo-gamecube + GAMECUBE_CFLAGS="-mogc -mcpu=750 -meabi -mhard-float \ + -Wall -O2 \ + -I${DEVKITPRO}/libogc/include -DGEKKO \ + -I${DEVKITPRO}/portlibs/gamecube/include \ + -I${DEVKITPRO}/portlibs/ppc/include" + EXTRA_CFLAGS="$EXTRA_CFLAGS $GAMECUBE_CFLAGS" + CFLAGS="$CFLAGS $GAMECUBE_CFLAGS $OPENGX_CFLAGS" + SDL_CFLAGS="$SDL_CFLAGS $GAMECUBE_CFLAGS" + SDL_LIBS="-mogc -mcpu=750 -meabi -mhard-float \ + -L${DEVKITPRO}/portlibs/gamecube/lib \ + -L${DEVKITPRO}/portlibs/ppc/lib -lSDLmain $SDL_LIBS $OPENGX_LIBS \ + -L${DEVKITPRO}/libogc/lib/cube -laesnd -lfat -logc -lm" + AC_DEFINE(SDL_TIMER_OGC) + SOURCES="$SOURCES $srcdir/src/timer/ogc/*.c" + have_timers=yes + AC_DEFINE(SDL_AUDIO_DRIVER_OGC) + SOURCES="$SOURCES $srcdir/src/audio/ogc/*.c" + have_audio=yes + AC_DEFINE(SDL_JOYSTICK_OGC) + SOURCES="$SOURCES $srcdir/src/joystick/ogc/*.c" + have_joystick=yes + AC_DEFINE(SDL_THREAD_OGC) + SOURCES="$SOURCES $srcdir/src/thread/ogc/*.c" + have_threads=yes + AC_DEFINE(SDL_VIDEO_DRIVER_OGC) + SOURCES="$SOURCES $srcdir/src/video/gamecube/*.c" + SOURCES="$SOURCES $srcdir/src/video/ogc/*.c" + SDLMAIN_SOURCES="$srcdir/src/main/gamecube/*.c" + SDLMAIN_LDFLAGS="-static" + have_video=yes + fi +} + dnl Find the nanox include and library directories CheckNANOX() { @@ -2314,6 +2407,11 @@ AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]] dnl Set up the configuration based on the host platform! case "$host" in + powerpc-*-eabi) + CheckOpenGX + CheckNintendoWii + CheckNintendoGamecube + ;; arm-*-elf*) # FIXME: Can we get more specific for iPodLinux? ARCH=linux CheckDummyVideo diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 8bb1773c0e..fa020eff5d 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -185,6 +185,7 @@ #undef SDL_AUDIO_DRIVER_SNDMGR #undef SDL_AUDIO_DRIVER_SUNAUDIO #undef SDL_AUDIO_DRIVER_WAVEOUT +#undef SDL_AUDIO_DRIVER_OGC /* Enable various cdrom drivers */ #undef SDL_CDROM_AIX @@ -215,6 +216,7 @@ #undef SDL_JOYSTICK_MINT #undef SDL_JOYSTICK_OS2 #undef SDL_JOYSTICK_RISCOS +#undef SDL_JOYSTICK_OGC #undef SDL_JOYSTICK_WINMM #undef SDL_JOYSTICK_USBHID #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H @@ -238,6 +240,7 @@ #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP #undef SDL_THREAD_SPROC +#undef SDL_THREAD_OGC #undef SDL_THREAD_WIN32 /* Enable various timer systems */ @@ -249,6 +252,7 @@ #undef SDL_TIMER_OS2 #undef SDL_TIMER_RISCOS #undef SDL_TIMER_UNIX +#undef SDL_TIMER_OGC #undef SDL_TIMER_WIN32 #undef SDL_TIMER_WINCE @@ -279,6 +283,7 @@ #undef SDL_VIDEO_DRIVER_SVGALIB #undef SDL_VIDEO_DRIVER_TOOLBOX #undef SDL_VIDEO_DRIVER_VGL +#undef SDL_VIDEO_DRIVER_OGC #undef SDL_VIDEO_DRIVER_WINDIB #undef SDL_VIDEO_DRIVER_WSCONS #undef SDL_VIDEO_DRIVER_X11 diff --git a/include/SDL_main.h b/include/SDL_main.h index ab50ef1e29..9824c50634 100644 --- a/include/SDL_main.h +++ b/include/SDL_main.h @@ -32,7 +32,8 @@ #if defined(__WIN32__) || \ (defined(__MWERKS__) && !defined(__BEOS__)) || \ defined(__MACOS__) || defined(__MACOSX__) || \ - defined(__SYMBIAN32__) || defined(QWS) + defined(__SYMBIAN32__) || defined(QWS) || \ + defined(__wii__) || defined(__gamecube__) #ifdef __cplusplus #define C_LINKAGE "C" diff --git a/src/SDL.c b/src/SDL.c index 87f1b1af2a..bcb53f7e0d 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -121,6 +121,10 @@ int SDL_InitSubSystem(Uint32 flags) if ( SDL_JoystickInit() < 0 ) { return(-1); } +// joystick 0 is used for mouse emulation on wii & cube. +#if defined (__wii__) || defined (__gamecube__) + SDL_JoystickOpen(0); +#endif SDL_initialized |= SDL_INIT_JOYSTICK; } #else @@ -155,6 +159,10 @@ int SDL_Init(Uint32 flags) } #endif +// On Wii & GameCube always initialise joysticks. +#if defined(__wii__) || defined (__gamecube__) + flags |= SDL_INIT_JOYSTICK; +#endif /* Clear the error message */ SDL_ClearError(); diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index beb26e0b4d..fbbeb459f7 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -112,6 +112,9 @@ static AudioBootStrap *bootstrap[] = { #endif #if SDL_AUDIO_DRIVER_EPOCAUDIO &EPOCAudio_bootstrap, +#endif +#if SDL_AUDIO_DRIVER_OGC + &OGCAUD_bootstrap, #endif NULL }; diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 74ac21df04..e701a570ac 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -179,6 +179,9 @@ extern AudioBootStrap DART_bootstrap; #if SDL_AUDIO_DRIVER_EPOCAUDIO extern AudioBootStrap EPOCAudio_bootstrap; #endif +#if SDL_AUDIO_DRIVER_OGC +extern AudioBootStrap OGCAUD_bootstrap; +#endif /* This is the current audio device */ extern SDL_AudioDevice *current_audio; diff --git a/src/audio/ogc/SDL_ogcAudio.c b/src/audio/ogc/SDL_ogcAudio.c new file mode 100644 index 0000000000..dab1c0134b --- /dev/null +++ b/src/audio/ogc/SDL_ogcAudio.c @@ -0,0 +1,293 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken at libsdl.or +*/ +#include "SDL_config.h" + +// Public includes. +#include "SDL_timer.h" + +// Audio internal includes. +#include "SDL_audio.h" +#include "../SDL_audiomem.h" +#include "../SDL_sysaudio.h" +#include "../SDL_audio_c.h" + +// Wii audio internal includes. +#include "SDL_ogcAudio.h" + +#include + +// for memalign +#include + +static const char OGCAUD_DRIVER_NAME[] = "ogc"; + +#define DMA_BUFFER_SIZE (SAMPLES_PER_DMA_BUFFER*2*sizeof(short)) + +static lwp_t athread; +static ogcAudio *current = NULL; + +/**************************************************************************** + * Audio Threading + ***************************************************************************/ +static void * +AudioThread (ogcAudio *private) +{ + u32 buffer_size; + Uint8 whichab = 1; + + while (1) + { + LWP_SuspendThread(athread); + if (private->stopaudio) + break; + + DCZeroRange(private->dma_buffers[whichab], DMA_BUFFER_SIZE); + buffer_size = DMA_BUFFER_SIZE; + + // Is the device ready? + if (current_audio && !current_audio->paused) + { + SDL_LockMutex(current_audio->mixer_lock); + + if (current_audio->convert.needed) + { + // Get the client to produce audio + current_audio->spec.callback( + current_audio->spec.userdata, + current_audio->convert.buf, + current_audio->convert.len); + + // Convert the audio + SDL_ConvertAudio(¤t_audio->convert); + + // Copy from SDL buffer to DMA buffer + memcpy(private->dma_buffers[whichab], current_audio->convert.buf, current_audio->convert.len_cvt); + buffer_size = current_audio->convert.len_cvt; + } else { + current_audio->spec.callback( + current_audio->spec.userdata, + (Uint8 *)(private->dma_buffers[whichab]), + DMA_BUFFER_SIZE); + buffer_size = DMA_BUFFER_SIZE; + } + + SDL_UnlockMutex(current_audio->mixer_lock); + } + else if (current_audio && (current_audio->spec.format&0x8000)==0) // hack + { + int i; + // if it's an unsigned format use 0x8000 for silence (16-bit) + short fill = 0x8000; + + // 0x80 for 8-bit formats + if (current_audio->spec.format&0x08) + fill |= 0x80; + + for (i=0; i < SAMPLES_PER_DMA_BUFFER*2; i++) + private->dma_buffers[whichab][i] = fill; + } + + AESND_SetVoiceBuffer(private->voice, private->dma_buffers[whichab], buffer_size); + whichab ^= 1; + } + return NULL; +} + +/**************************************************************************** + * DMACallback + * signal audio thread that more samples are required + ***************************************************************************/ +static void +DMACallback(AESNDPB *pb, u32 state) +{ + if (state == VOICE_STATE_STREAM) + LWP_ResumeThread(athread); +} + +void OGC_AudioStop(ogcAudio *private) +{ + if (private==NULL) { + if (current==NULL) + return; + private = current; + } + + if (private->voice) { + AESND_SetVoiceStop(private->voice, 1); + AESND_FreeVoice(private->voice); + private->voice = NULL; + } + + private->stopaudio = true; + if (athread != LWP_THREAD_NULL) { + LWP_ResumeThread(athread); + LWP_JoinThread(athread, NULL); + athread = LWP_THREAD_NULL; + } + + AESND_Pause(1); + // this function is broken + //AESND_Reset(); +} + +int OGC_AudioStart(ogcAudio *private) +{ + if (private==NULL) { + if (current==NULL) + return -1; + private = current; + } + + memset(private->dma_buffers, 0, sizeof(private->dma_buffers)); + private->stopaudio = false; + private->voice = AESND_AllocateVoice(DMACallback); + if (private->voice==NULL) + return -1; + + if (LWP_CreateThread(&athread, (void*(*)(void*))AudioThread, private, private->astack, AUDIOSTACK, 80) < 0) { + AESND_FreeVoice(private->voice); + private->voice = NULL; + return -1; + } + + // start audio + // this is retarded. Why isn't there one function to do all this shit? + AESND_SetVoiceFormat(private->voice, private->format); + AESND_SetVoiceFrequency(private->voice, private->freq); + AESND_SetVoiceBuffer(private->voice, private->dma_buffers[0], DMA_BUFFER_SIZE); + AESND_SetVoiceStream(private->voice, true); + AESND_SetVoiceStop(private->voice, 0); + AESND_Pause(0); + + current = private; + return 1; +} + +static int OGCAUD_OpenAudio(_THIS, SDL_AudioSpec *spec) +{ + u32 format; + ogcAudio *private = (ogcAudio*)(this->hidden); + + if (spec->freq <= 0 || spec->freq > 144000) + spec->freq = DSP_DEFAULT_FREQ; + + // default sample size = 1 byte (1 channel @ 8 bits) + spec->samples = DMA_BUFFER_SIZE; + + // no support for little endian or 16 bit unsigned + switch (spec->format) { + case AUDIO_U8: + format = VOICE_MONO8_UNSIGNED; + break; + case AUDIO_S8: + format = VOICE_MONO8; + break; + // anything else needs conversion to signed 16 big-endian + default: + case AUDIO_U16LSB: + case AUDIO_U16MSB: + case AUDIO_S16LSB: + spec->format = AUDIO_S16MSB; + // fallthrough + case AUDIO_S16MSB: + format = VOICE_MONO16; + // samples are 16 bits + spec->samples >>= 1; + } + + // support 2 channels max + if (spec->channels > 2) + spec->channels = 2; + + if (spec->channels == 2) { + ++format; + // 2 values for each sample + spec->samples >>= 1; + } + + spec->padding = 0; + SDL_CalculateAudioSpec(spec); + + private->format = format; + // AESND will convert frequency as required + private->freq = spec->freq; + + return OGC_AudioStart(private); +} + +static void OGCAUD_CloseAudio(_THIS) +{ + OGC_AudioStop((ogcAudio*)(this->hidden)); + current = NULL; +} + +static void OGCAUD_DeleteDevice(_THIS) +{ + OGC_AudioStop((ogcAudio*)(this->hidden)); + + free(this->hidden); + SDL_free(this); +} + +static SDL_AudioDevice *OGCAUD_CreateDevice(int devindex) +{ + SDL_AudioDevice *this; + + athread = LWP_THREAD_NULL; + + /* Initialize all variables that we clean on shutdown */ + this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); + if ( this ) { + SDL_memset(this, 0, (sizeof *this)); + this->hidden = (ogcAudio*)memalign(32, sizeof(ogcAudio)); + } + if ( (this == NULL) || (this->hidden == NULL) ) { + SDL_OutOfMemory(); + SDL_free(this); + return NULL; + } + SDL_memset(this->hidden, 0, sizeof(ogcAudio)); + + // Initialise the ogc side of the audio system + AESND_Init(); + AESND_Pause(1); + + /* Set the function pointers */ + this->OpenAudio = OGCAUD_OpenAudio; + //this->WaitAudio = WIIAUD_WaitAudio; + //this->PlayAudio = WIIAUD_PlayAudio; + //this->GetAudioBuf = WIIAUD_GetAudioBuf; + this->CloseAudio = OGCAUD_CloseAudio; + this->free = OGCAUD_DeleteDevice; + + return this; +} + +static int OGCAUD_Available(void) +{ + return 1; +} + +AudioBootStrap OGCAUD_bootstrap = { + OGCAUD_DRIVER_NAME, "SDL ogc audio driver", + OGCAUD_Available, OGCAUD_CreateDevice +}; diff --git a/src/audio/ogc/SDL_ogcAudio.h b/src/audio/ogc/SDL_ogcAudio.h new file mode 100644 index 0000000000..532db57424 --- /dev/null +++ b/src/audio/ogc/SDL_ogcAudio.h @@ -0,0 +1,49 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_ogcAudio_h +#define _SDL_ogcAudio_h + +#include +#include + +#include "../SDL_sysaudio.h" + +/* Hidden "this" pointer for the video functions */ +#define _THIS SDL_AudioDevice *this + +#define AUDIOSTACK 8192 +#define SAMPLES_PER_DMA_BUFFER (DSP_STREAMBUFFER_SIZE) + +typedef struct SDL_PrivateAudioData { + // these go first so they will be aligned + Uint8 astack[AUDIOSTACK]; + short dma_buffers[2][SAMPLES_PER_DMA_BUFFER*2]; + + AESNDPB* voice; + u32 format; + u32 freq; + volatile bool stopaudio; +} ogcAudio; + +#endif /* _SDL_dummyaudio_h */ diff --git a/src/joystick/ogc/SDL_sysjoystick.c b/src/joystick/ogc/SDL_sysjoystick.c new file mode 100644 index 0000000000..1ecf6df0ad --- /dev/null +++ b/src/joystick/ogc/SDL_sysjoystick.c @@ -0,0 +1,796 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org + */ +#include "SDL_config.h" + +#ifdef SDL_JOYSTICK_OGC + +#include "SDL_events.h" +#include "SDL_joystick.h" +#include "../SDL_sysjoystick.h" +#include "../SDL_joystick_c.h" + +#include +#include +#include +#include + +#define MAX_GC_JOYSTICKS 4 +#define MAX_WII_JOYSTICKS 4 + +#ifdef __wii__ +#define MAX_JOYSTICKS (MAX_GC_JOYSTICKS + MAX_WII_JOYSTICKS) +#else +#define MAX_JOYSTICKS MAX_GC_JOYSTICKS +#endif + +#define MAX_GC_AXES 6 +#define MAX_GC_BUTTONS 8 +#define MAX_GC_HATS 1 + +#define MAX_WII_AXES 9 +#define MAX_WII_BUTTONS 15 +#define MAX_WII_HATS 1 + +#define JOYNAMELEN 10 + +#define AXIS_MIN -32767 /* minimum value for axis coordinate */ +#define AXIS_MAX 32767 /* maximum value for axis coordinate */ + +extern SDL_Joystick **SDL_joysticks; + +typedef struct joystick_paddata_t +{ + u16 prev_buttons; + s8 stickX; + s8 stickY; + s8 substickX; + s8 substickY; + u8 triggerL; + u8 triggerR; +}joystick_paddata; + +typedef struct joystick_wpaddata_t +{ + u32 prev_buttons; + u32 exp; + s16 nunchuk_stickX; + s16 nunchuk_stickY; + s16 classicL_stickX; + s16 classicL_stickY; + s16 classicR_stickX; + s16 classicR_stickY; + u8 classic_triggerL; + u8 classic_triggerR; + u8 classic_calibrated; + s8 wiimote_pitch; + s8 wiimote_roll; + s8 wiimote_yaw; + s16 classic_cal[4][3]; // 4x axes, min/center/max +}joystick_wpaddata; + +static const u16 sdl_buttons_gc[] = +{ + PAD_BUTTON_A, + PAD_BUTTON_B, + PAD_BUTTON_X, + PAD_BUTTON_Y, + PAD_TRIGGER_L, + PAD_TRIGGER_R, + PAD_TRIGGER_Z, + PAD_BUTTON_START, +}; + +/* The private structure used to keep track of a joystick */ +typedef struct joystick_hwdata_t +{ + int index; + int type; +#ifdef __wii__ + union + { + joystick_paddata gamecube; + joystick_wpaddata wiimote; + }; +#else + joystick_paddata gamecube; +#endif +} joystick_hwdata; + +static const int __jspad_enabled = 1; +static const int __numgcjoysticks = 4; + +#ifdef __wii__ +#define GC_JOYSTICK_FROM_INDEX(index) (index - num_wii_joysticks) +#else +#define GC_JOYSTICK_FROM_INDEX(index) (index) +#endif + +#ifdef __wii__ +static const int __jswpad_enabled = 1; +static const int __numwiijoysticks = 4; +static int split_joysticks = 0; +static int num_wii_joysticks; + +static const u32 sdl_buttons_wii[] = +{ + WPAD_BUTTON_A|WPAD_CLASSIC_BUTTON_A, + WPAD_BUTTON_B|WPAD_CLASSIC_BUTTON_B, + WPAD_BUTTON_1, + WPAD_BUTTON_2, + WPAD_BUTTON_MINUS|WPAD_CLASSIC_BUTTON_MINUS, + WPAD_BUTTON_PLUS|WPAD_CLASSIC_BUTTON_PLUS, + WPAD_BUTTON_HOME|WPAD_CLASSIC_BUTTON_HOME, + WPAD_NUNCHUK_BUTTON_Z, /* 7 */ + WPAD_NUNCHUK_BUTTON_C, /* 8 */ + WPAD_CLASSIC_BUTTON_X, /* 9 */ + WPAD_CLASSIC_BUTTON_Y, + WPAD_CLASSIC_BUTTON_FULL_L, + WPAD_CLASSIC_BUTTON_FULL_R, + WPAD_CLASSIC_BUTTON_ZL, + WPAD_CLASSIC_BUTTON_ZR +}; +#define SDL_WII_NUM_BUTTONS_WII \ + (sizeof(sdl_buttons_wii) / sizeof(sdl_buttons_wii[0])) + +static const u32 sdl_buttons_wiimote[] = +{ + WPAD_BUTTON_A, + WPAD_BUTTON_B, + WPAD_BUTTON_1, + WPAD_BUTTON_2, + WPAD_BUTTON_MINUS, + WPAD_BUTTON_PLUS, + WPAD_BUTTON_HOME, +}; +#define SDL_WII_NUM_BUTTONS_WIIMOTE \ + (sizeof(sdl_buttons_wiimote) / sizeof(sdl_buttons_wiimote[0])) + +static const u32 sdl_buttons_nunchuck[] = +{ + WPAD_NUNCHUK_BUTTON_Z, + WPAD_NUNCHUK_BUTTON_C, +}; +#define SDL_WII_NUM_BUTTONS_NUNCHUCK \ + (sizeof(sdl_buttons_nunchuck) / sizeof(sdl_buttons_nunchuck[0])) + +static const u32 sdl_buttons_classic[] = +{ + WPAD_CLASSIC_BUTTON_A, + WPAD_CLASSIC_BUTTON_B, + WPAD_CLASSIC_BUTTON_X, + WPAD_CLASSIC_BUTTON_Y, + WPAD_CLASSIC_BUTTON_FULL_L, + WPAD_CLASSIC_BUTTON_FULL_R, + WPAD_CLASSIC_BUTTON_ZL, + WPAD_CLASSIC_BUTTON_ZR, + WPAD_CLASSIC_BUTTON_MINUS, + WPAD_CLASSIC_BUTTON_PLUS, + WPAD_CLASSIC_BUTTON_HOME, +}; +#define SDL_WII_NUM_BUTTONS_CLASSIC \ + (sizeof(sdl_buttons_classic) / sizeof(sdl_buttons_classic[0])) + +/* Helpers to separate nunchuk vs classic buttons which share the + * same scan codes. In particular, up on the classic controller is + * the same as Z on the nunchuk. The numbers refer to the sdl_buttons_wii + * list above. */ +static int wii_button_is_nunchuk(int idx) +{ + return idx == 7 || idx == 8; +} + +static int wii_button_is_classic(int idx) +{ + return idx >= 9; +} + +static s16 WPAD_Orient(WPADData *data, int motion) +{ + float out; + + if (motion == 0) + out = data->orient.pitch; + else if (motion == 1) + out = data->orient.roll; + else + out = data->orient.yaw; + + return (s16)((out / 180.0) * 128.0); +} + +static s16 WPAD_Pitch(WPADData *data) +{ + return WPAD_Orient(data, 0); +} + +static s16 WPAD_Roll(WPADData *data) +{ + return WPAD_Orient(data, 1); +} + +static s16 WPAD_Yaw(WPADData *data) +{ + return WPAD_Orient(data, 2); +} + +static s16 WPAD_Stick(s16 x, s16 min, s16 center, s16 max, int flip) +{ + s16 d; + int ret; + + x -= center; + + if (x < 0) + d = center - min; + else + d = max - center; + + if (center - min < 5) return 0; + if (max - center < 5) return 0; + + if (d) + ret = (x << 15) / d; + else + return 0; + + if (flip) + ret = -ret; + + if (ret < AXIS_MIN) + ret = AXIS_MIN; + else if (ret > AXIS_MAX) + ret = AXIS_MAX; + + return ret; +} + +static const u32 _buttons[8] = { + // wiimote + WPAD_BUTTON_UP, + WPAD_BUTTON_DOWN, + WPAD_BUTTON_LEFT, + WPAD_BUTTON_RIGHT, + // classic + WPAD_CLASSIC_BUTTON_UP, + WPAD_CLASSIC_BUTTON_DOWN, + WPAD_CLASSIC_BUTTON_LEFT, + WPAD_CLASSIC_BUTTON_RIGHT +}; + +static void HandleWiiHats(SDL_Joystick *joystick, + const u32 changed, const u32 pressed, + const u32 *buttons) +{ + if (changed & (buttons[0]|buttons[1]|buttons[2]|buttons[3])) + { + int hat = SDL_HAT_CENTERED; + + if (pressed & buttons[0]) hat |= SDL_HAT_UP; + if (pressed & buttons[1]) hat |= SDL_HAT_DOWN; + if (pressed & buttons[2]) hat |= SDL_HAT_LEFT; + if (pressed & buttons[3]) hat |= SDL_HAT_RIGHT; + SDL_PrivateJoystickHat(joystick, 0, hat); + } +} + +static void HandleWiiButtons(SDL_Joystick *joystick, + const u32 changed, + const WPADData *data, + const u32 *buttons, + size_t num_buttons) +{ + for (int i = 0; i < num_buttons; i++) + { + if (changed & buttons[i]) + { + if (!split_joysticks && + ((data->exp.type == WPAD_EXP_CLASSIC && wii_button_is_nunchuk(i)) || + (data->exp.type == WPAD_EXP_NUNCHUK && wii_button_is_classic(i)))) + continue; + + SDL_PrivateJoystickButton(joystick, i, + (data->btns_d & buttons[i]) ? SDL_PRESSED : SDL_RELEASED); + } + } +} + +static void HandleWiiMotion(SDL_Joystick* joystick, + joystick_hwdata *prev_state, + WPADData *data, + int start_index) +{ + int axis = WPAD_Pitch(data); + if(prev_state->wiimote.wiimote_pitch != axis) + { + SDL_PrivateJoystickAxis(joystick, start_index, -(axis << 8)); + prev_state->wiimote.wiimote_pitch = axis; + } + axis = WPAD_Roll(data); + if(prev_state->wiimote.wiimote_roll != axis) + { + SDL_PrivateJoystickAxis(joystick, start_index + 1, axis << 8); + prev_state->wiimote.wiimote_roll = axis; + } + axis = WPAD_Yaw(data); + if(prev_state->wiimote.wiimote_yaw != axis) + { + SDL_PrivateJoystickAxis(joystick, start_index + 2, axis << 8); + prev_state->wiimote.wiimote_yaw = axis; + } +} + +static void _HandleWiiJoystickUpdate(SDL_Joystick* joystick) +{ + u32 changed, pressed; + int axis, index; + joystick_hwdata *prev_state; + WPADData *data; + SDL_Joystick *joy_wiimote = NULL; + SDL_Joystick *joy_expansion = NULL; + + prev_state = (joystick_hwdata*)joystick->hwdata; + index = prev_state->index; + if (!WPAD_ReadPending(index, NULL)) + return; + data = WPAD_Data(index); + changed = data->btns_d | data->btns_u; + pressed = data->btns_d | data->btns_h; + + if (joystick->index >= __numwiijoysticks) { + /* we can get here if using the split joystick feature. But even in + * that case, we don't want to do anything here: the update operation + * on the wiimote must update the expansion joystick too. */ + return; + } + + if (split_joysticks) { + /* To find out the pointer to the linked joystick we use the knowledge + * that the SDL_Joystick structures are allocated in a continuous array + */ + joy_wiimote = joystick; + joy_expansion = SDL_joysticks[joystick->index + 4]; + } + + if (split_joysticks) { + HandleWiiHats(joy_wiimote, changed, pressed, _buttons); + if (data->exp.type == WPAD_EXP_CLASSIC) { // classic controller + HandleWiiHats(joy_expansion, changed, pressed, _buttons + 4); + } + } else { + if (data->exp.type == WPAD_EXP_CLASSIC) // classic controller + HandleWiiHats(joystick, changed, pressed, _buttons + 4); + HandleWiiHats(joystick, changed, pressed, _buttons); + } + + if (split_joysticks) { + HandleWiiButtons(joy_wiimote, changed, data, + sdl_buttons_wiimote, SDL_WII_NUM_BUTTONS_WIIMOTE); + if (data->exp.type == WPAD_EXP_CLASSIC) { + HandleWiiButtons(joy_expansion, changed, data, + sdl_buttons_classic, SDL_WII_NUM_BUTTONS_CLASSIC); + } else if (data->exp.type == WPAD_EXP_NUNCHUK) { + HandleWiiButtons(joy_expansion, changed, data, + sdl_buttons_nunchuck, SDL_WII_NUM_BUTTONS_NUNCHUCK); + } + } else { + HandleWiiButtons(joystick, changed, data, + sdl_buttons_wii, SDL_WII_NUM_BUTTONS_WII); + } + + if(data->exp.type == WPAD_EXP_CLASSIC) + { + if (prev_state->wiimote.exp != WPAD_EXP_CLASSIC) + { + prev_state->wiimote.classic_calibrated = 0; + prev_state->wiimote.classic_cal[0][0] = 5; // left x min + prev_state->wiimote.classic_cal[0][2] = 59; // left x max + prev_state->wiimote.classic_cal[1][0] = 5; // left y min + prev_state->wiimote.classic_cal[1][2] = 59; // left y max + prev_state->wiimote.classic_cal[2][0] = 5; // right x min + prev_state->wiimote.classic_cal[2][2] = 27; // right x max + prev_state->wiimote.classic_cal[3][0] = 5; // right y min + prev_state->wiimote.classic_cal[3][2] = 27; // right y max + + } + + // max/min checking + // left stick x + if (data->exp.classic.ljs.pos.x < prev_state->wiimote.classic_cal[0][0]) + prev_state->wiimote.classic_cal[0][0] = data->exp.classic.ljs.pos.x; + else if (data->exp.classic.ljs.pos.x > prev_state->wiimote.classic_cal[0][2]) + prev_state->wiimote.classic_cal[0][2] = data->exp.classic.ljs.pos.x; + // left stick y + if (data->exp.classic.ljs.pos.y < prev_state->wiimote.classic_cal[1][0]) + prev_state->wiimote.classic_cal[1][0] = data->exp.classic.ljs.pos.y; + else if (data->exp.classic.ljs.pos.y > prev_state->wiimote.classic_cal[1][2]) + prev_state->wiimote.classic_cal[1][2] = data->exp.classic.ljs.pos.y; + // right stick x + if (data->exp.classic.rjs.pos.x < prev_state->wiimote.classic_cal[2][0]) + prev_state->wiimote.classic_cal[2][0] = data->exp.classic.rjs.pos.x; + else if (data->exp.classic.rjs.pos.x > prev_state->wiimote.classic_cal[2][2]) + prev_state->wiimote.classic_cal[2][2] = data->exp.classic.rjs.pos.x; + // right stick y + if (data->exp.classic.rjs.pos.y < prev_state->wiimote.classic_cal[3][0]) + prev_state->wiimote.classic_cal[3][0] = data->exp.classic.rjs.pos.y; + else if (data->exp.classic.rjs.pos.y > prev_state->wiimote.classic_cal[3][2]) + prev_state->wiimote.classic_cal[3][2] = data->exp.classic.rjs.pos.y; + + // calibrate center positions + if (prev_state->wiimote.classic_calibrated < 5) + { + prev_state->wiimote.classic_cal[0][1] = data->exp.classic.ljs.pos.x; + prev_state->wiimote.classic_cal[1][1] = data->exp.classic.ljs.pos.y; + prev_state->wiimote.classic_cal[2][1] = data->exp.classic.rjs.pos.x; + prev_state->wiimote.classic_cal[3][1] = data->exp.classic.rjs.pos.y; + // this is zero if the expansion hasn't finished initializing + if (data->exp.classic.ljs.max.x) + prev_state->wiimote.classic_calibrated++; + } + } + + if (data->exp.type != prev_state->wiimote.exp) + { + SDL_Joystick *joy = split_joysticks ? joy_expansion : joystick; + // Reset the expansion axes + for (int i = 0; i < 6; i++) + SDL_PrivateJoystickAxis(joy, i, 0); + } + + if(data->exp.type == WPAD_EXP_CLASSIC) + { + SDL_Joystick *joy = split_joysticks ? joy_expansion : joystick; + + axis = WPAD_Stick(data->exp.classic.ljs.pos.x, prev_state->wiimote.classic_cal[0][0], + prev_state->wiimote.classic_cal[0][1], prev_state->wiimote.classic_cal[0][2], 0); + if(prev_state->wiimote.classicL_stickX != axis) + { + SDL_PrivateJoystickAxis(joy, 0, axis); + prev_state->wiimote.classicL_stickX = axis; + } + // y axes are reversed + axis = WPAD_Stick(data->exp.classic.ljs.pos.y, prev_state->wiimote.classic_cal[1][0], + prev_state->wiimote.classic_cal[1][1], prev_state->wiimote.classic_cal[1][2], 1); + if(prev_state->wiimote.classicL_stickY != axis) + { + SDL_PrivateJoystickAxis(joy, 1, axis); + prev_state->wiimote.classicL_stickY = axis; + } + axis = WPAD_Stick(data->exp.classic.rjs.pos.x, prev_state->wiimote.classic_cal[2][0], + prev_state->wiimote.classic_cal[2][1], prev_state->wiimote.classic_cal[2][2], 0); + if(prev_state->wiimote.classicR_stickX != axis) + { + SDL_PrivateJoystickAxis(joy, 2, axis); + prev_state->wiimote.classicR_stickX = axis; + } + axis = WPAD_Stick(data->exp.classic.rjs.pos.y, prev_state->wiimote.classic_cal[3][0], + prev_state->wiimote.classic_cal[3][1], prev_state->wiimote.classic_cal[3][2], 1); + if(prev_state->wiimote.classicR_stickY != axis) + { + SDL_PrivateJoystickAxis(joy, 3, axis); + prev_state->wiimote.classicR_stickY = axis; + } + axis = data->exp.classic.r_shoulder; + if(prev_state->wiimote.classic_triggerR != axis) + { + SDL_PrivateJoystickAxis(joy, 4, axis<<8); + prev_state->wiimote.classic_triggerR = axis; + } + axis = data->exp.classic.l_shoulder; + if(prev_state->wiimote.classic_triggerL != axis) + { + SDL_PrivateJoystickAxis(joy, 5, axis<<8); + prev_state->wiimote.classic_triggerL = axis; + } + } + else if(data->exp.type == WPAD_EXP_NUNCHUK) + { + SDL_Joystick *joy = split_joysticks ? joy_expansion : joystick; + + axis = WPAD_Stick(data->exp.nunchuk.js.pos.x, data->exp.nunchuk.js.min.x, + data->exp.nunchuk.js.center.x, data->exp.nunchuk.js.max.x, 0); + if(prev_state->wiimote.nunchuk_stickX != axis) + { + SDL_PrivateJoystickAxis(joy, 0, axis); + prev_state->wiimote.nunchuk_stickX = axis; + } + axis = WPAD_Stick(data->exp.nunchuk.js.pos.y, data->exp.nunchuk.js.min.y, + data->exp.nunchuk.js.center.y, data->exp.nunchuk.js.max.y, 1); + if(prev_state->wiimote.nunchuk_stickY != axis) + { + SDL_PrivateJoystickAxis(joy, 1, axis); + prev_state->wiimote.nunchuk_stickY = axis; + } + } + + prev_state->wiimote.exp = data->exp.type; + + if (split_joysticks) { + // also update the expansion + ((joystick_hwdata*)joy_expansion->hwdata)->wiimote.exp = data->exp.type; + } + + int start_index = split_joysticks ? 0 : 6; + HandleWiiMotion(split_joysticks ? joy_wiimote : joystick, prev_state, data, start_index); +} + +#endif + +/* Function to scan the system for joysticks. + * This function should return the number of available + * joysticks. Joystick 0 should be the system default joystick. + * It should return -1 on an unrecoverable fatal error. + */ +int SDL_SYS_JoystickInit(void) +{ +#ifdef __wii__ + const char *split_joystick_env = getenv("SDL_WII_JOYSTICK_SPLIT"); + split_joysticks = split_joystick_env && strcmp(split_joystick_env, "1") == 0; + /* Multiply by two because each wiimote might have an expansion connected */ + num_wii_joysticks = split_joysticks ? __numwiijoysticks * 2 : __numwiijoysticks; + return num_wii_joysticks + __numgcjoysticks; +#else + return MAX_JOYSTICKS; +#endif +} + +static char joy_name[64] = "Gamecube 0"; + +/* Function to get the device-dependent name of a joystick */ +const char *SDL_SYS_JoystickName(int index) +{ + if(index>=0) { +#ifdef __wii__ + if((__jswpad_enabled) && (index < num_wii_joysticks)) { + joystick_hwdata *hwdata = (joystick_hwdata*)SDL_joysticks[index]->hwdata; + char *name_ptr = joy_name; + if (index < __numwiijoysticks) { + name_ptr += sprintf(name_ptr, "Wiimote %d", index); + if (!split_joysticks) { + // Add expansion information + switch (hwdata->wiimote.exp) { + case WPAD_EXP_NUNCHUK: + strcpy(name_ptr, " + Nunchuk"); break; + case WPAD_EXP_CLASSIC: + strcpy(name_ptr, " + Classic"); break; + case WPAD_EXP_GUITARHERO3: + strcpy(name_ptr, " + Guitar Hero 3"); break; + case WPAD_EXP_WIIBOARD: + strcpy(name_ptr, " + Balance board"); break; + } + } + } else { + /* This is an expansion and we are using the split controllers + * option: show only the expansion name, then. */ + int idx = index - __numwiijoysticks; + switch (hwdata->wiimote.exp) { + case WPAD_EXP_NUNCHUK: + sprintf(name_ptr, "Nunchuk %d", idx); break; + case WPAD_EXP_CLASSIC: + sprintf(name_ptr, "Classic %d", idx); break; + case WPAD_EXP_GUITARHERO3: + sprintf(name_ptr, "Guitar Hero 3 %d", idx); break; + case WPAD_EXP_WIIBOARD: + sprintf(name_ptr, "Balance board %d", idx); break; + case WPAD_EXP_NONE: + strcpy(name_ptr, "Disconnected"); break; + default: + sprintf(name_ptr, "Unknown %d", idx); break; + } + } + } else if((__jspad_enabled) && (index < (num_wii_joysticks + __numgcjoysticks))) +#endif + sprintf(joy_name, "Gamecube %d", index); + } + return (const char *)joy_name; +} + +/* Function to open a joystick for use. + The joystick to open is specified by the index field of the joystick. + This should fill the nbuttons and naxes fields of the joystick structure. + It returns 0, or -1 if there is an error. + */ +int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) +{ + /* allocate memory for system specific hardware data */ + joystick->hwdata = SDL_malloc(sizeof(joystick_hwdata)); + if (joystick->hwdata == NULL) + { + SDL_OutOfMemory(); + return(-1); + } + SDL_memset(joystick->hwdata, 0, sizeof(joystick_hwdata)); +#ifdef __wii__ + if((joystick->index < num_wii_joysticks) && (__jswpad_enabled)) + { + int index = (joystick->index > __numwiijoysticks) ? (joystick->index - __numwiijoysticks) : joystick->index; + ((joystick_hwdata*)(joystick->hwdata))->index = index; + ((joystick_hwdata*)(joystick->hwdata))->type = 0; + if (split_joysticks) { + if (joystick->index < __numwiijoysticks) { + // wiimote + joystick->nbuttons = SDL_WII_NUM_BUTTONS_WIIMOTE; + joystick->naxes = 3; + joystick->nhats = 1; + } else { + // expansion + joystick->nbuttons = SDL_max(SDL_WII_NUM_BUTTONS_NUNCHUCK, + SDL_WII_NUM_BUTTONS_CLASSIC); + joystick->naxes = 6; + joystick->nhats = 1; + } + } else { + joystick->nbuttons = MAX_WII_BUTTONS; + joystick->naxes = MAX_WII_AXES; + joystick->nhats = MAX_WII_HATS; + } + } + else if((joystick->index < num_wii_joysticks + __numgcjoysticks) && (__jspad_enabled)) + { + ((joystick_hwdata*)(joystick->hwdata))->index = joystick->index - num_wii_joysticks; + ((joystick_hwdata*)(joystick->hwdata))->type = 1; + joystick->nbuttons = MAX_GC_BUTTONS; + joystick->naxes = MAX_GC_AXES; + joystick->nhats = MAX_GC_HATS; + } +#else + if((joystick->index < 4) && (__jspad_enabled)) + { + if(joystick->index < (__numgcjoysticks)) + { + ((joystick_hwdata*)(joystick->hwdata))->index = joystick->index - 4; + ((joystick_hwdata*)(joystick->hwdata))->type = 1; + joystick->nbuttons = MAX_GC_BUTTONS; + joystick->naxes = MAX_GC_AXES; + joystick->nhats = MAX_GC_HATS; + } + } +#endif + return(0); +} + + +static void _HandleGCJoystickUpdate(SDL_Joystick* joystick) +{ + u16 buttons, prev_buttons, changed; + int i; + int axis; + joystick_hwdata *prev_state; + int index = GC_JOYSTICK_FROM_INDEX(joystick->index); + + buttons = PAD_ButtonsHeld(index); + prev_state = (joystick_hwdata *)joystick->hwdata; + prev_buttons = prev_state->gamecube.prev_buttons; + changed = buttons ^ prev_buttons; + + if(changed & (PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT | PAD_BUTTON_DOWN | PAD_BUTTON_UP)) + { + int hat = SDL_HAT_CENTERED; + if(buttons & PAD_BUTTON_UP) hat |= SDL_HAT_UP; + if(buttons & PAD_BUTTON_DOWN) hat |= SDL_HAT_DOWN; + if(buttons & PAD_BUTTON_LEFT) hat |= SDL_HAT_LEFT; + if(buttons & PAD_BUTTON_RIGHT) hat |= SDL_HAT_RIGHT; + SDL_PrivateJoystickHat(joystick, 0, hat); + } + + for(i = 0; i < (sizeof(sdl_buttons_gc) / sizeof(sdl_buttons_gc[0])); i++) + { + if (changed & sdl_buttons_gc[i]) + SDL_PrivateJoystickButton(joystick, i, + (buttons & sdl_buttons_gc[i]) ? SDL_PRESSED : SDL_RELEASED); + } + prev_state->gamecube.prev_buttons = buttons; + axis = PAD_StickX(index); + if(prev_state->gamecube.stickX != axis) + { + SDL_PrivateJoystickAxis(joystick, 0, axis << 8); + prev_state->gamecube.stickX = axis; + } + + axis = PAD_StickY(index); + if(prev_state->gamecube.stickY != axis) + { + SDL_PrivateJoystickAxis(joystick, 1, (-axis) << 8); + prev_state->gamecube.stickY = axis; + } + + axis = PAD_SubStickX(index); + if(prev_state->gamecube.substickX != axis) + { + SDL_PrivateJoystickAxis(joystick, 2, axis << 8); + prev_state->gamecube.substickX = axis; + } + + axis = PAD_SubStickY(index); + if(prev_state->gamecube.substickY != axis) + { + SDL_PrivateJoystickAxis(joystick, 3, (-axis) << 8); + prev_state->gamecube.substickY = axis; + } + + axis = PAD_TriggerL(index); + if(prev_state->gamecube.triggerL != axis) + { + SDL_PrivateJoystickAxis(joystick, 4, axis << 7); + prev_state->gamecube.triggerL = axis; + } + + axis = PAD_TriggerR(index); + if(prev_state->gamecube.triggerR != axis) + { + SDL_PrivateJoystickAxis(joystick, 5, axis << 7); + prev_state->gamecube.triggerR = axis; + } +} + +/* Function to update the state of a joystick - called as a device poll. + * This function shouldn't update the joystick structure directly, + * but instead should call SDL_PrivateJoystick*() to deliver events + * and update joystick device state. + */ + +void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) +{ + if(!joystick || !joystick->hwdata) + return; + + PAD_ScanPads(); + + switch(((joystick_hwdata*)(joystick->hwdata))->type) + { +#ifdef __wii__ + case 0: + if(__jswpad_enabled) { + if (split_joysticks && joystick->index >= __numwiijoysticks) { + /* the actual joystick we want to update is always the wiimote + * one */ + joystick = SDL_joysticks[joystick->index - __numwiijoysticks]; + } + _HandleWiiJoystickUpdate(joystick); + } + break; +#endif + case 1: + if(__jspad_enabled) + _HandleGCJoystickUpdate(joystick); + break; + default: + break; + } +} + +/* Function to close a joystick after use */ +void SDL_SYS_JoystickClose(SDL_Joystick *joystick) +{ + if(!joystick || !joystick->hwdata) // joystick already closed + return; + + SDL_free(joystick->hwdata); + joystick->hwdata = NULL; +} + +/* Function to perform any system-specific joystick related cleanup */ +void SDL_SYS_JoystickQuit(void) +{ + +} + +#endif /* SDL_JOYSTICK_DC */ diff --git a/src/main/gamecube/SDL_gamecube_main.c b/src/main/gamecube/SDL_gamecube_main.c new file mode 100644 index 0000000000..1ad5a19bd5 --- /dev/null +++ b/src/main/gamecube/SDL_gamecube_main.c @@ -0,0 +1,26 @@ +/* Include the SDL main definition header */ +#include "SDL_main.h" +#undef main + +/* Standard includes */ +#include + +/* SDL includes */ +#include "../../video/ogc/SDL_ogc_video.h" + +/* OGC includes */ +#include +#include + +/* Do initialisation which has to be done first for the console to work */ +/* Entry point */ +int main(int argc, char *argv[]) +{ +// SYS_SetPowerCallback(ShutdownCB); +// SYS_SetResetCallback(ResetCB); + PAD_Init(); + OGC_InitVideoSystem(); + fatInitDefault(); + /* Call the user's main function */ + return(SDL_main(argc, argv)); +} diff --git a/src/main/wii/SDL_wii_main.c b/src/main/wii/SDL_wii_main.c new file mode 100644 index 0000000000..75851d4b1c --- /dev/null +++ b/src/main/wii/SDL_wii_main.c @@ -0,0 +1,76 @@ +/* Include the SDL main definition header */ +#include "SDL_main.h" +#undef main + +/* Standard includes */ +#include + +/* SDL includes */ +#include "../../video/ogc/SDL_ogc_video.h" + +/* OGC includes */ +#include +#include +#include +#include +#include + +bool TerminateRequested=false, ShutdownRequested=false, ResetRequested=false; + +void SDL_Quit(); +static void ShutdownCB() +{ + TerminateRequested = 1; + ShutdownRequested = 1; +} +static void ResetCB(u32, void*) +{ + TerminateRequested = 1; + ResetRequested = 1; +} +void ShutdownWii() +{ + TerminateRequested = 0; + SDL_Quit(); + SYS_ResetSystem(SYS_POWEROFF, 0, 0); +} +void RestartHomebrewChannel() +{ + TerminateRequested = 0; + SDL_Quit(); + exit(1); +} +void Terminate() +{ + if (ShutdownRequested) ShutdownWii(); + else if (ResetRequested) RestartHomebrewChannel(); +} + +/* Do initialisation which has to be done first for the console to work */ +/* Entry point */ +int main(int argc, char *argv[]) +{ + L2Enhance(); + u32 version = IOS_GetVersion(); + s32 preferred = IOS_GetPreferredVersion(); + + if(preferred > 0 && version != (u32)preferred) + IOS_ReloadIOS(preferred); + + // Wii Power/Reset buttons + WPAD_Init(); + WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB); + SYS_SetPowerCallback(ShutdownCB); + SYS_SetResetCallback(ResetCB); + PAD_Init(); + OGC_InitVideoSystem(); + WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); + WPAD_SetVRes(WPAD_CHAN_ALL, 640, 480); + + MOUSE_Init(); + KEYBOARD_Init(NULL); + fatInitDefault(); + /* Call the user's main function */ + return(SDL_main(argc, argv)); +} + diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index 8af6e52f41..e2c21bd6f6 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -43,6 +43,8 @@ #include "win32/SDL_systhread_c.h" #elif SDL_THREAD_SYMBIAN #include "symbian/SDL_systhread_c.h" +#elif SDL_THREAD_OGC +#include "ogc/SDL_systhread_c.h" #else #error Need thread implementation for this platform #include "generic/SDL_systhread_c.h" diff --git a/src/thread/ogc/SDL_syscond.c b/src/thread/ogc/SDL_syscond.c new file mode 100644 index 0000000000..70d76b97ec --- /dev/null +++ b/src/thread/ogc/SDL_syscond.c @@ -0,0 +1,139 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* An implementation of condition variables using semaphores and mutexes */ +/* + This implementation borrows heavily from the BeOS condition variable + implementation, written by Christopher Tate and Owen Smith. Thanks! + */ + +#include "SDL_thread.h" +#include "SDL_sysmutex_c.h" + +#include +#include + +struct SDL_cond +{ + cond_t cond; +}; + +/* Create a condition variable */ +SDL_cond * SDL_CreateCond(void) +{ + SDL_cond *cond; + + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); + if (cond) + { + if (LWP_CondInit(&(cond->cond)) < 0) + { + SDL_DestroyCond(cond); + cond = NULL; + } + } + else + { + SDL_OutOfMemory(); + } + return (cond); +} + +/* Destroy a condition variable */ +void SDL_DestroyCond(SDL_cond *cond) +{ + if (cond) + { + LWP_CondDestroy(cond->cond); + SDL_free(cond); + } +} + +/* Restart one of the threads that are waiting on the condition variable */ +int SDL_CondSignal(SDL_cond *cond) +{ + if (!cond) + { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + + return LWP_CondSignal(cond->cond) == 0 ? 0 : -1; + +} + +/* Restart all threads that are waiting on the condition variable */ +int SDL_CondBroadcast(SDL_cond *cond) +{ + if (!cond) + { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + + return LWP_CondBroadcast(cond->cond) == 0 ? 0 : -1; +} + +/* Wait on the condition variable for at most 'ms' milliseconds. + The mutex must be locked before entering this function! + The mutex is unlocked during the wait, and locked again after the wait. + + Typical use: + + Thread A: + SDL_LockMutex(lock); + while ( ! condition ) { + SDL_CondWait(cond); + } + SDL_UnlockMutex(lock); + + Thread B: + SDL_LockMutex(lock); + ... + condition = true; + ... + SDL_UnlockMutex(lock); + */ + + +int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) +{ + struct timespec time; + + if (!cond) + { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + //LWP_CondTimedWait expects relative timeout + time.tv_sec = (ms / 1000); + time.tv_nsec = (ms % 1000) * 1000000; + + return LWP_CondTimedWait(cond->cond, mutex->id, &time); +} + +/* Wait on the condition variable forever */ +int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) +{ + return LWP_CondWait(cond->cond, mutex->id); +} diff --git a/src/thread/ogc/SDL_sysmutex.c b/src/thread/ogc/SDL_sysmutex.c new file mode 100644 index 0000000000..9fc57496c8 --- /dev/null +++ b/src/thread/ogc/SDL_sysmutex.c @@ -0,0 +1,87 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* An implementation of mutexes using semaphores */ + +#include "SDL_thread.h" +#include "SDL_systhread_c.h" + +#include + +struct SDL_mutex +{ + u32 id; +}; + +/* Create a mutex */ +SDL_mutex *SDL_CreateMutex(void) +{ + SDL_mutex *mutex = NULL; + + /* Allocate mutex memory */ + mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); + if (mutex) + { + LWP_MutexInit(&mutex->id, 0); + } + else + { + SDL_OutOfMemory(); + } + return mutex; +} + +/* Free the mutex */ +void SDL_DestroyMutex(SDL_mutex *mutex) +{ + if (mutex) + { + LWP_MutexDestroy(mutex->id); + SDL_free(mutex); + } +} + +/* Lock the semaphore */ +int SDL_mutexP(SDL_mutex *mutex) +{ + if (mutex == NULL) + { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + return LWP_MutexLock(mutex->id); +} + +/* Unlock the mutex */ +int SDL_mutexV(SDL_mutex *mutex) +{ + if (mutex == NULL) + { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + return LWP_MutexUnlock(mutex->id); + +} diff --git a/src/thread/ogc/SDL_sysmutex_c.h b/src/thread/ogc/SDL_sysmutex_c.h new file mode 100644 index 0000000000..8fdac822a6 --- /dev/null +++ b/src/thread/ogc/SDL_sysmutex_c.h @@ -0,0 +1,26 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +struct SDL_mutex { + Uint32 id; +}; diff --git a/src/thread/ogc/SDL_syssem.c b/src/thread/ogc/SDL_syssem.c new file mode 100644 index 0000000000..4c68ac3ea9 --- /dev/null +++ b/src/thread/ogc/SDL_syssem.c @@ -0,0 +1,175 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* An implementation of semaphores using mutexes and condition variables */ + +#include "SDL_timer.h" +#include "SDL_thread.h" +#include "SDL_systhread_c.h" + +struct SDL_semaphore +{ + Uint32 count; + Uint32 waiters_count; + SDL_mutex *count_lock; + SDL_cond *count_nonzero; +}; + +SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) +{ + SDL_sem *sem; + + sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); + if (!sem) + { + SDL_OutOfMemory(); + return NULL; + } + sem->count = initial_value; + sem->waiters_count = 0; + + sem->count_lock = SDL_CreateMutex(); + sem->count_nonzero = SDL_CreateCond(); + if (!sem->count_lock || !sem->count_nonzero) + { + SDL_DestroySemaphore(sem); + return NULL; + } + + return sem; +} + +/* WARNING: + You cannot call this function when another thread is using the semaphore. + */ +void SDL_DestroySemaphore(SDL_sem *sem) +{ + if (sem) + { + sem->count = 0xFFFFFFFF; + while (sem->waiters_count > 0) + { + SDL_CondSignal(sem->count_nonzero); + SDL_Delay(10); + } + SDL_DestroyCond(sem->count_nonzero); + if (sem->count_lock) + { + SDL_mutexP(sem->count_lock); + SDL_mutexV(sem->count_lock); + SDL_DestroyMutex(sem->count_lock); + } + SDL_free(sem); + } +} + +int SDL_SemTryWait(SDL_sem *sem) +{ + int retval; + + if (!sem) + { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + retval = SDL_MUTEX_TIMEDOUT; + SDL_LockMutex(sem->count_lock); + if (sem->count > 0) + { + --sem->count; + retval = 0; + } + SDL_UnlockMutex(sem->count_lock); + + return retval; +} + +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) +{ + int retval; + + if (!sem) + { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + /* A timeout of 0 is an easy case */ + if (timeout == 0) + { + return SDL_SemTryWait(sem); + } + + SDL_LockMutex(sem->count_lock); + ++sem->waiters_count; + retval = 0; + while ((sem->count == 0) && (retval != SDL_MUTEX_TIMEDOUT)) + { + retval = SDL_CondWaitTimeout(sem->count_nonzero, sem->count_lock, + timeout); + } + --sem->waiters_count; + --sem->count; + SDL_UnlockMutex(sem->count_lock); + + return retval; +} + +int SDL_SemWait(SDL_sem *sem) +{ + return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); +} + +Uint32 SDL_SemValue(SDL_sem *sem) +{ + Uint32 value; + + value = 0; + if (sem) + { + SDL_LockMutex(sem->count_lock); + value = sem->count; + SDL_UnlockMutex(sem->count_lock); + } + return value; +} + +int SDL_SemPost(SDL_sem *sem) +{ + if (!sem) + { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + SDL_LockMutex(sem->count_lock); + if (sem->waiters_count > 0) + { + SDL_CondSignal(sem->count_nonzero); + } + ++sem->count; + SDL_UnlockMutex(sem->count_lock); + + return 0; +} diff --git a/src/thread/ogc/SDL_systhread.c b/src/thread/ogc/SDL_systhread.c new file mode 100644 index 0000000000..c546df05d0 --- /dev/null +++ b/src/thread/ogc/SDL_systhread.c @@ -0,0 +1,80 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* Thread management routines for SDL */ + +#include "SDL_thread.h" +#include "../SDL_systhread.h" +#include "../SDL_thread_c.h" + +#include + +/* +struct SDL_Thread { + Uint32 threadid; + SYS_ThreadHandle handle; + int status; + SDL_error errbuf; + void *data; +}; + + */ + +void *run_thread(void *data) +{ + SDL_RunThread(data); + return ((void *) 0); /* Prevent compiler warning */ +} + +int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) +{ + + if ( LWP_CreateThread(&thread->handle, run_thread, args, 0, 0, 16) != 0 ) { + SDL_SetError("Not enough resources to create thread"); + return(-1); + } + + return (0); +} + +void SDL_SYS_SetupThread(void) +{ + return; +} + +Uint32 SDL_ThreadID(void) +{ + return (Uint32) LWP_GetSelf(); +} + +void SDL_SYS_WaitThread(SDL_Thread *thread) +{ + void *v; + LWP_JoinThread(thread->handle, &v); + return; +} + +void SDL_SYS_KillThread(SDL_Thread *thread) +{ + return; +} diff --git a/src/thread/ogc/SDL_systhread_c.h b/src/thread/ogc/SDL_systhread_c.h new file mode 100644 index 0000000000..fc13572acc --- /dev/null +++ b/src/thread/ogc/SDL_systhread_c.h @@ -0,0 +1,26 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* Stub until we implement threads on this platform */ + +typedef Uint32 SYS_ThreadHandle; diff --git a/src/timer/ogc/SDL_systimer.c b/src/timer/ogc/SDL_systimer.c new file mode 100644 index 0000000000..144ad38df5 --- /dev/null +++ b/src/timer/ogc/SDL_systimer.c @@ -0,0 +1,105 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifdef SDL_TIMER_OGC + +#include +#include + +#include "SDL_timer.h" +#include "../SDL_timer_c.h" + +#include + +static Uint64 start; + +void SDL_StartTicks(void) +{ + start = gettime(); +} + +Uint32 SDL_GetTicks (void) +{ + const Uint64 ticks = gettime() - start; + const Uint64 ms = ticks / TB_TIMER_CLOCK; + return ms; +} + +void SDL_Delay (Uint32 ms) +{ + struct timespec elapsed, tv; + elapsed.tv_sec = ms/1000; + elapsed.tv_nsec = (ms%1000)*1000000; + tv.tv_sec = elapsed.tv_sec; + tv.tv_nsec = elapsed.tv_nsec; + nanosleep(&tv, &elapsed); +} + +#include "SDL_thread.h" + +/* Data to handle a single periodic alarm */ +static int timer_alive = 0; +static SDL_Thread *timer = NULL; + +static int RunTimer(void *unused) +{ + while ( timer_alive ) { + if ( SDL_timer_running ) { + SDL_ThreadedTimerCheck(); + } + SDL_Delay(1); + } + return(0); +} + +/* This is only called if the event thread is not running */ +int SDL_SYS_TimerInit(void) +{ + timer_alive = 1; + timer = SDL_CreateThread(RunTimer, NULL); + if ( timer == NULL ) + return(-1); + return(SDL_SetTimerThreaded(1)); +} + +void SDL_SYS_TimerQuit(void) +{ + timer_alive = 0; + if ( timer ) { + SDL_WaitThread(timer, NULL); + timer = NULL; + } +} + +int SDL_SYS_StartTimer(void) +{ + SDL_SetError("Internal logic error: threaded timer in use"); + return(-1); +} + +void SDL_SYS_StopTimer(void) +{ + return; +} + +#endif diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 436450e330..65d56a56bd 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -410,6 +410,9 @@ extern VideoBootStrap AALIB_bootstrap; #if SDL_VIDEO_DRIVER_CACA extern VideoBootStrap CACA_bootstrap; #endif +#if SDL_VIDEO_DRIVER_OGC +extern VideoBootStrap OGC_bootstrap; +#endif #if SDL_VIDEO_DRIVER_DUMMY extern VideoBootStrap DUMMY_bootstrap; #endif diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 46285c990e..bf379f4b61 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -126,6 +126,9 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_CACA &CACA_bootstrap, #endif +#if SDL_VIDEO_DRIVER_OGC + &OGC_bootstrap, +#endif #if SDL_VIDEO_DRIVER_DUMMY &DUMMY_bootstrap, #endif diff --git a/src/video/gamecube/SDL_gamecube_events.c b/src/video/gamecube/SDL_gamecube_events.c new file mode 100644 index 0000000000..e44a84a9eb --- /dev/null +++ b/src/video/gamecube/SDL_gamecube_events.c @@ -0,0 +1,13 @@ +#include "SDL_config.h" + + +#include "SDL.h" +#include "../../events/SDL_sysevents.h" +#include "../../events/SDL_events_c.h" + +#include "../ogc/SDL_ogc_video.h" +#include "SDL_gamecube_events_c.h" + +void GAMECUBE_PumpEvents(_THIS) {} + +void GAMECUBE_InitOSKeymap(_THIS) {} diff --git a/src/video/gamecube/SDL_gamecube_events_c.h b/src/video/gamecube/SDL_gamecube_events_c.h new file mode 100644 index 0000000000..5084d26f56 --- /dev/null +++ b/src/video/gamecube/SDL_gamecube_events_c.h @@ -0,0 +1,4 @@ +#include "SDL_config.h" + +extern void GAMECUBE_InitOSKeymap(_THIS); +extern void GAMECUBE_PumpEvents(_THIS); diff --git a/src/video/gamecube/SDL_gamecube_mouse.c b/src/video/gamecube/SDL_gamecube_mouse.c new file mode 100644 index 0000000000..9511d820b0 --- /dev/null +++ b/src/video/gamecube/SDL_gamecube_mouse.c @@ -0,0 +1,8 @@ +#include "SDL_config.h" + +#include "SDL_mouse.h" +#include "../../events/SDL_events_c.h" + +struct WMcursor { + int unused; +}; diff --git a/src/video/ogc/SDL_ogc_video.c b/src/video/ogc/SDL_ogc_video.c new file mode 100644 index 0000000000..69a3842c42 --- /dev/null +++ b/src/video/ogc/SDL_ogc_video.c @@ -0,0 +1,923 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Tantric, 2009 +*/ +#include "SDL_config.h" + +// Standard includes. +#include + +// SDL internal includes. +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "SDL_timer.h" +#include "SDL_thread.h" + +// SDL ogc specifics. +#include +#include +#include +#include +#include +#include "SDL_ogc_video.h" + +#ifdef __wii__ +#include "../wii/SDL_wiievents_c.h" +#endif + +#ifdef __gamecube__ +#include "../gamecube/SDL_gamecube_events_c.h" +#endif + + +#include + +static const char OGCVID_DRIVER_NAME[] = "ogc-video"; +static lwp_t videothread = LWP_THREAD_NULL; +static SDL_mutex *videomutex = NULL; +static SDL_cond *videocond = NULL; +static ogcVideo *current = NULL; + +int vresx=0, vresy=0; + +/*** SDL ***/ +static SDL_Rect mode_320, mode_640; +#ifdef __wii__ +static SDL_Rect mode_848; +#endif + +static SDL_Rect* modes_descending[] = +{ +#ifdef __wii__ + &mode_848, +#endif + &mode_640, + &mode_320, + NULL +}; + + +/*** 2D Video ***/ +#define HASPECT 320 +#define VASPECT 240 + +unsigned char *xfb = NULL; +GXRModeObj* vmode = 0; +static int quit_flip_thread = 0; +static GXTexObj texobj_a, texobj_b; +static GXTlutObj texpalette_a, texpalette_b; + +/*** GX ***/ +#define DEFAULT_FIFO_SIZE 256 * 1024 +static unsigned char gp_fifo[DEFAULT_FIFO_SIZE] __attribute__((aligned(32))); + +/* New texture based scaler */ +typedef struct tagcamera +{ + guVector pos; + guVector up; + guVector view; +} +camera; + +/*** Square Matrix + This structure controls the size of the image on the screen. + Think of the output as a -80 x 80 by -60 x 60 graph. +***/ +static s16 square[] ATTRIBUTE_ALIGN (32) = +{ + /* + * X, Y, Z + * Values set are for roughly 4:3 aspect + */ + -HASPECT, VASPECT, 0, // 0 + HASPECT, VASPECT, 0, // 1 + HASPECT, -VASPECT, 0, // 2 + -HASPECT, -VASPECT, 0 // 3 +}; + +static const f32 tex_pos[] ATTRIBUTE_ALIGN(32) = { + 0.0, 0.0, + 1.0, 0.0, + 1.0, 1.0, + 0.0, 1.0, +}; + +static camera cam = { + {0.0F, 0.0F, 0.0F}, + {0.0F, 0.5F, 0.0F}, + {0.0F, 0.0F, -0.5F} +}; + +/**************************************************************************** + * Scaler Support Functions + ***************************************************************************/ +static int currentwidth; +static int currentheight; +static int currentbpp; + +static void +draw_init(void *palette, void *tex) +{ + Mtx m, mv, view; + + GX_ClearVtxDesc (); + GX_SetVtxDesc (GX_VA_POS, GX_INDEX8); + GX_SetVtxDesc (GX_VA_TEX0, GX_INDEX8); + + GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0); + GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); + + GX_SetArray (GX_VA_POS, square, 3 * sizeof (s16)); + GX_SetArray (GX_VA_TEX0, (void*)tex_pos, 2 * sizeof (f32)); + GX_SetNumTexGens (1); + GX_SetNumChans (0); + + GX_SetTexCoordGen (GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); + + GX_SetTevOp (GX_TEVSTAGE0, GX_REPLACE); + GX_SetTevOrder (GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL); + + memset(&view, 0, sizeof (Mtx)); + guLookAt(view, &cam.pos, &cam.up, &cam.view); + guMtxIdentity(m); + guMtxTransApply(m, m, 0, 0, -100); + guMtxConcat(view, m, mv); + GX_LoadPosMtxImm(mv, GX_PNMTX0); + + GX_InvVtxCache (); // update vertex cache + + if (currentbpp == 8) { + GX_InitTlutObj(&texpalette_a, palette, GX_TL_IA8, 256); + GX_InitTlutObj(&texpalette_b, (Uint16*)palette+256, GX_TL_IA8, 256); + DCStoreRange(palette, sizeof(512*sizeof(Uint16))); + GX_LoadTlut(&texpalette_a, GX_TLUT0); + GX_LoadTlut(&texpalette_b, GX_TLUT1); + + GX_InitTexObjCI(&texobj_a, tex, currentwidth, currentheight, GX_TF_CI8, GX_CLAMP, GX_CLAMP, 0, GX_TLUT0); + GX_InitTexObjCI(&texobj_b, tex, currentwidth, currentheight, GX_TF_CI8, GX_CLAMP, GX_CLAMP, 0, GX_TLUT1); + GX_LoadTexObj(&texobj_b, GX_TEXMAP1); + + // Setup TEV to combine Red+Green and Blue paletted images + GX_SetTevColor(GX_TEVREG0, (GXColor){255, 255, 0, 0}); + GX_SetTevSwapModeTable(GX_TEV_SWAP1, GX_CH_RED, GX_CH_ALPHA, GX_CH_BLUE, GX_CH_ALPHA); + GX_SetTevSwapModeTable(GX_TEV_SWAP2, GX_CH_ALPHA, GX_CH_ALPHA, GX_CH_BLUE, GX_CH_ALPHA); + // first stage = red and green + GX_SetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP1); + GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_C0, GX_CC_ZERO); + // second stage = add blue (and opaque alpha) + GX_SetTevOp(GX_TEVSTAGE1, GX_BLEND); + GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD0, GX_TEXMAP1, GX_COLORNULL); + GX_SetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP2); + GX_SetTevColorIn(GX_TEVSTAGE1, GX_CC_TEXC, GX_CC_ZERO, GX_CC_ZERO, GX_CC_CPREV); + GX_SetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_KONST); + + GX_SetNumTevStages(2); + } + else if (currentbpp == 16) + GX_InitTexObj(&texobj_a, tex, currentwidth, currentheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); + else + GX_InitTexObj(&texobj_a, tex, currentwidth, currentheight, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); + + GX_LoadTexObj(&texobj_a, GX_TEXMAP0); // load texture object so its ready to use +} + +static inline void +draw_vert (u8 index) +{ + GX_Position1x8 (index); + GX_TexCoord1x8 (index); +} + +static inline void +draw_square () +{ + GX_Begin(GX_QUADS, GX_VTXFMT0, 4); + draw_vert(0); + draw_vert(1); + draw_vert(2); + draw_vert(3); + GX_End(); +} + +static void * flip_thread (void *arg) +{ + u32 *tex = (u32*)arg; + + GX_SetCurrentGXThread(); + + // clear EFB + GX_CopyDisp(xfb, GX_TRUE); + + SDL_mutexP(videomutex); + + while(!quit_flip_thread) + { + // update texture + DCStoreRange((void*)tex[0], tex[1]); + // clear texture objects + GX_InvalidateTexAll(); + draw_square(); // render textured quad + + VIDEO_WaitVSync(); + GX_CopyDisp(xfb, GX_FALSE); + + GX_DrawDone(); + + SDL_CondWait(videocond, videomutex); + } + SDL_mutexV(videomutex); + + return NULL; +} + +static void +SetupGX() +{ + Mtx44 p; + int df = 1; // deflicker on/off + + GX_SetCurrentGXThread(); + GX_SetViewport (0, 0, vmode->fbWidth, vmode->efbHeight, 0, 1); + GX_SetDispCopyYScale ((f32) vmode->xfbHeight / (f32) vmode->efbHeight); + GX_SetScissor (0, 0, vmode->fbWidth, vmode->efbHeight); + + GX_SetDispCopySrc(0, 0, vmode->fbWidth, vmode->efbHeight); + GX_SetDispCopyDst(vmode->fbWidth, vmode->xfbHeight); + GX_SetCopyFilter (vmode->aa, vmode->sample_pattern, (df == 1) ? GX_TRUE : GX_FALSE, vmode->vfilter); + + GX_SetFieldMode (vmode->field_rendering, ((vmode->viHeight == 2 * vmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); + GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR); + GX_SetDispCopyGamma (GX_GM_1_0); + GX_SetCullMode (GX_CULL_NONE); + GX_SetBlendMode(GX_BM_NONE,GX_BL_DSTALPHA,GX_BL_INVSRCALPHA,GX_LO_CLEAR); + + GX_SetZMode (GX_FALSE, GX_LEQUAL, GX_TRUE); + GX_SetColorUpdate (GX_TRUE); + GX_SetAlphaUpdate(GX_FALSE); + + guOrtho(p, VASPECT, -VASPECT, -HASPECT, HASPECT, 100, 1000); // matrix, t, b, l, r, n, f + GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC); + GX_Flush(); +} + +static void +StartVideoThread(void *args) +{ + if(videothread == LWP_THREAD_NULL) + { + quit_flip_thread = 0; + LWP_CreateThread(&videothread, flip_thread, args, NULL, 0, 68); + } +} + +void OGC_VideoStart(ogcVideo *private, Uint32 flags) +{ + if (private==NULL) { + if (current==NULL) + return; + private = current; + } + + SetupGX(); + draw_init(private->palette, private->texturemem); + if (!(flags & SDL_OPENGL)) { + StartVideoThread(&private->texturemem); + } +#ifdef __wii__ + WPAD_SetVRes(WPAD_CHAN_0, vresx+vresx/4, vresy+vresy/4); +#endif + current = private; +} + +void OGC_VideoStop() +{ + if(videothread == LWP_THREAD_NULL) + return; + + SDL_LockMutex(videomutex); + quit_flip_thread = 1; + SDL_CondSignal(videocond); + SDL_UnlockMutex(videomutex); + + LWP_JoinThread(videothread, NULL); + videothread = LWP_THREAD_NULL; +} + +static int OGC_VideoInit(_THIS, SDL_PixelFormat *vformat) +{ + // Set up the modes. +#ifdef __wii__ + mode_848.w = 848; + mode_848.h = 480; +#endif + mode_640.w = 640; + mode_640.h = 480; + mode_320.w = 320; + mode_320.h = 240; + + // Set the current format. + vformat->BitsPerPixel = 16; + vformat->BytesPerPixel = 2; + + this->hidden->buffer = NULL; + this->hidden->texturemem = NULL; + this->hidden->width = 0; + this->hidden->height = 0; + this->hidden->pitch = 0; + + this->gl_config.driver_loaded = 1; + this->gl_config.driver_path[0] = '\0'; + + /* We're done! */ + return 0; +} + +static SDL_Rect **OGC_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) +{ + return modes_descending; +} + +static SDL_Surface *OGC_SetVideoMode(_THIS, SDL_Surface *current, + int width, int height, int bpp, Uint32 flags) +{ + SDL_Rect* mode; + size_t bytes_per_pixel; + Uint32 r_mask = 0; + Uint32 b_mask = 0; + Uint32 g_mask = 0; + + // Find a mode big enough to store the requested resolution + mode = modes_descending[0]; + while (mode) + { + if (mode->w == width && mode->h == height) + break; + else + ++mode; + } + + // Didn't find a mode? + if (!mode) + { + SDL_SetError("Display mode (%dx%d) is unsupported.", + width, height); + return NULL; + } + + if(bpp != 8 && bpp != 16 && bpp != 24 && bpp != 32) + { + SDL_SetError("Resolution (%d bpp) is unsupported (8/16/24/32 bpp only).", + bpp); + return NULL; + } + + bytes_per_pixel = bpp / 8; + + OGC_VideoStop(); + + free(this->hidden->buffer); + free(this->hidden->texturemem); + + // Allocate the new buffer. + this->hidden->buffer = memalign(32, width * height * bytes_per_pixel); + if (!this->hidden->buffer ) + { + this->hidden->texturemem = NULL; + SDL_SetError("Couldn't allocate buffer for requested mode"); + return(NULL); + } + + // Allocate texture memory + if (bytes_per_pixel > 2) + this->hidden->texturemem_size = width * height * 4; + else + this->hidden->texturemem_size = width * height * bytes_per_pixel; + + this->hidden->texturemem = memalign(32, this->hidden->texturemem_size); + if (this->hidden->texturemem == NULL) + { + free(this->hidden->buffer); + this->hidden->buffer = NULL; + SDL_SetError("Couldn't allocate memory for texture"); + return NULL; + } + + // Allocate the new pixel format for the screen + if (!SDL_ReallocFormat(current, bpp, r_mask, g_mask, b_mask, 0)) + { + free(this->hidden->buffer); + this->hidden->buffer = NULL; + free(this->hidden->texturemem); + this->hidden->texturemem = NULL; + + SDL_UnlockMutex(videomutex); + SDL_SetError("Couldn't allocate new pixel format for requested mode"); + return NULL; + } + + // Clear the buffer + SDL_memset(this->hidden->buffer, 0, width * height * bytes_per_pixel); + SDL_memset(this->hidden->texturemem, 0, this->hidden->texturemem_size); + + // Set up the new mode framebuffer + current->flags = flags & (SDL_FULLSCREEN | SDL_HWPALETTE | SDL_NOFRAME | SDL_OPENGL); + // Our surface is always double buffered + current->flags |= SDL_PREALLOC | SDL_DOUBLEBUF; + current->w = width; + current->h = height; + current->pitch = current->w * bytes_per_pixel; + current->pixels = this->hidden->buffer; + + /* Set the hidden data */ + this->hidden->width = current->w; + this->hidden->height = current->h; + this->hidden->pitch = current->w * (bytes_per_pixel > 2 ? 4 : bytes_per_pixel); + + currentwidth = current->w; + currentheight = current->h; + currentbpp = bpp; + vresx = currentwidth; + vresy = currentheight; + + OGC_VideoStart(this->hidden, flags); + + return current; +} + +/* We don't actually allow hardware surfaces other than the main one */ +static int OGC_AllocHWSurface(_THIS, SDL_Surface *surface) +{ + return(-1); +} + +static void OGC_FreeHWSurface(_THIS, SDL_Surface *surface) +{ + return; +} + +static int OGC_LockHWSurface(_THIS, SDL_Surface *surface) +{ + return(0); +} + +static void OGC_UnlockHWSurface(_THIS, SDL_Surface *surface) +{ + return; +} + +static inline void Set_RGBAPixel(_THIS, int x, int y, u32 color) +{ + u8 *truc = this->hidden->texturemem; + int width = this->hidden->width; + u32 offset; + + offset = (((y >> 2) << 4) * width) + ((x >> 2) << 6) + ((((y & 3) << 2) + (x & 3)) << 1); + + *(truc + offset) = color; + *(truc + offset + 1) = color >> 24; + *(truc + offset + 32) = color >> 16; + *(truc + offset + 33) = color >> 8; +} + +static inline void Set_RGB565Pixel(_THIS, int x, int y, u16 color) +{ + u8 *truc = this->hidden->texturemem; + int width = this->hidden->width; + u32 offset; + + offset = (((y >> 2) << 3) * width) + ((x >> 2) << 5) + ((((y & 3) << 2) + (x & 3)) << 1); + + *(truc + offset) = color >> 8; + *(truc + offset + 1) = color; +} + +static inline void Set_PalPixel(_THIS, int x, int y, u8 color) +{ + u8 *truc = this->hidden->texturemem; + int width = this->hidden->pitch; + u32 offset; + + offset = ((y & ~3) * width) + ((x & ~7) << 2) + ((y & 3) << 3) + (x & 7); + + truc[offset] = color; +} + +static void UpdateRect_8(_THIS, SDL_Rect *rect) +{ + u8 *src; + u8 color; + int i, j; + + for (i = 0; i < rect->h; i++) + { + src = (this->hidden->buffer + (this->hidden->width * (i + rect->y)) + rect->x); + for (j = 0; j < rect->w; j++) + { + color = src[j]; + Set_PalPixel(this, rect->x + j, rect->y + i, color); + } + } +} + +static void UpdateRect_16(_THIS, SDL_Rect *rect) +{ + u8 *src; + u8 *ptr; + u16 color; + int i, j; + for (i = 0; i < rect->h; i++) + { + src = (this->hidden->buffer + (this->hidden->width * 2 * (i + rect->y)) + (rect->x * 2)); + for (j = 0; j < rect->w; j++) + { + ptr = src + (j * 2); + color = (ptr[0] << 8) | ptr[1]; + Set_RGB565Pixel(this, rect->x + j, rect->y + i, color); + } + } +} + +static void UpdateRect_24(_THIS, SDL_Rect *rect) +{ + u8 *src; + u8 *ptr; + u32 color; + int i, j; + for (i = 0; i < rect->h; i++) + { + src = (this->hidden->buffer + (this->hidden->width * 3 * (i + rect->y)) + (rect->x * 3)); + for (j = 0; j < rect->w; j++) + { + ptr = src + (j * 3); + color = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | 0xff; + Set_RGBAPixel(this, rect->x + j, rect->y + i, color); + } + } +} + +static void UpdateRect_32(_THIS, SDL_Rect *rect) +{ + u8 *src; + u8 *ptr; + u32 color; + int i, j; + for (i = 0; i < rect->h; i++) + { + src = (this->hidden->buffer + (this->hidden->width * 4 * (i + rect->y)) + (rect->x * 4)); + for (j = 0; j < rect->w; j++) + { + ptr = src + (j * 4); + color = (ptr[1] << 24) | (ptr[2] << 16) | (ptr[3] << 8) | ptr[0]; + Set_RGBAPixel(this, rect->x + j, rect->y + i, color); + } + } +} + +static void flipHWSurface_16_16(_THIS, const SDL_Surface* const surface) +{ + int h, w; + long long int *dst = (long long int *) this->hidden->texturemem; + long long int *src1 = (long long int *) this->hidden->buffer; + long long int *src2 = (long long int *) (this->hidden->buffer + (this->hidden->pitch * 1)); + long long int *src3 = (long long int *) (this->hidden->buffer + (this->hidden->pitch * 2)); + long long int *src4 = (long long int *) (this->hidden->buffer + (this->hidden->pitch * 3)); + int rowpitch = (this->hidden->pitch >> 3) * 3; + + SDL_mutexP(videomutex); + for (h = 0; h < this->hidden->height; h += 4) + { + for (w = 0; w < this->hidden->pitch; w += 8) + { + *dst++ = *src1++; + *dst++ = *src2++; + *dst++ = *src3++; + *dst++ = *src4++; + } + + src1 = src4; + src2 += rowpitch; + src3 += rowpitch; + src4 += rowpitch; + } + SDL_CondSignal(videocond); + SDL_mutexV(videomutex); +} + +static void OGC_UpdateRect(_THIS, SDL_Rect *rect) +{ + const SDL_Surface* const screen = this->screen; + + switch(screen->format->BytesPerPixel) { + case 1: + UpdateRect_8(this, rect); + break; + case 2: + UpdateRect_16(this, rect); + break; + case 3: + UpdateRect_24(this, rect); + break; + case 4: + UpdateRect_32(this, rect); + break; + default: + fprintf(stderr, "Invalid BPP %d\n", screen->format->BytesPerPixel); + break; + } +} + +static void OGC_UpdateRects(_THIS, int numrects, SDL_Rect *rects) +{ + int i; + + // note that this function doesn't lock - we don't care if this isn't + // rendered now, that's what Flip is for + + for (i = 0; i < numrects; i++) + { + OGC_UpdateRect(this, rects+i); + } + + SDL_CondSignal(videocond); +} + +static void flipHWSurface_24_16(_THIS, SDL_Surface *surface) +{ + SDL_Rect screen_rect = {0, 0, this->hidden->width, this->hidden->height}; + OGC_UpdateRects(this, 1, &screen_rect); +} + +static void flipHWSurface_32_16(_THIS, SDL_Surface *surface) +{ + SDL_Rect screen_rect = {0, 0, this->hidden->width, this->hidden->height}; + OGC_UpdateRects(this, 1, &screen_rect); +} + +static int OGC_FlipHWSurface(_THIS, SDL_Surface *surface) +{ + switch(surface->format->BytesPerPixel) + { + case 1: + case 2: + // 8 and 16 bit use the same tile format + flipHWSurface_16_16(this, surface); + break; + case 3: + flipHWSurface_24_16(this, surface); + break; + case 4: + flipHWSurface_32_16(this, surface); + break; + default: + return -1; + } + return 0; +} + +static int OGC_SetColors(_THIS, int first_color, int color_count, SDL_Color *colors) +{ + const int last_color = first_color + color_count; + Uint16* const palette = this->hidden->palette; + int component; + + SDL_LockMutex(videomutex); + + /* Build the RGB24 palette. */ + for (component = first_color; component != last_color; ++component, ++colors) + { + palette[component] = (colors->g << 8) | colors->r; + palette[component+256] = colors->b; + } + + DCStoreRangeNoSync(palette+first_color, color_count*sizeof(Uint16)); + DCStoreRange(palette+first_color+256, color_count*sizeof(Uint16)); + GX_LoadTlut(&texpalette_a, GX_TLUT0); + GX_LoadTlut(&texpalette_b, GX_TLUT1); + GX_LoadTexObj(&texobj_a, GX_TEXMAP0); + GX_LoadTexObj(&texobj_b, GX_TEXMAP1); + + SDL_UnlockMutex(videomutex); + + return(1); +} + +static void OGC_VideoQuit(_THIS) +{ + OGC_VideoStop(); + GX_AbortFrame(); + GX_Flush(); + + current = NULL; + + VIDEO_SetBlack(TRUE); + VIDEO_Flush(); + + free(this->hidden->buffer); + this->hidden->buffer = NULL; + free(this->hidden->texturemem); + this->hidden->texturemem = NULL; +} + +static void OGC_DeleteDevice(SDL_VideoDevice *device) +{ + free(device->hidden); + SDL_free(device); + + SDL_DestroyCond(videocond); + videocond = 0; + SDL_DestroyMutex(videomutex); + videomutex=0; +} + +/* Weak symbols for the opengx functions used by SDL, so that the client does + * not need to link to opengx, unless it actually uses OpenGL. */ +void __attribute__((weak)) ogx_initialize(void) +{ +} + +void __attribute__((weak)) *ogx_get_proc_address(const char *) +{ + return NULL; +} + +int SDL_OGC_GL_LoadLibrary(_THIS, const char *path) +{ + return 0; +} + +void *SDL_OGC_GL_GetProcAddress(_THIS, const char *proc) +{ + void *ptr = ogx_get_proc_address(proc); + if (!ptr) { + fprintf(stderr, "GetProcAddress %s\n", proc); + } + return ptr; +} + +int SDL_OGC_GL_MakeCurrent(_THIS) +{ + ogx_initialize(); + return 0; +} + +void SDL_OGC_GL_SwapBuffers(_THIS) +{ + VIDEO_WaitVSync(); + GX_CopyDisp(xfb, GX_FALSE); + + GX_DrawDone(); +} + +static SDL_VideoDevice *OGC_CreateDevice(int devindex) +{ + SDL_VideoDevice *device; + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); + if ( device ) { + SDL_memset(device, 0, (sizeof *device)); + device->hidden = (struct SDL_PrivateVideoData *) + memalign(32, sizeof(struct SDL_PrivateVideoData)); + } + if ( (device == NULL) || (device->hidden == NULL) ) { + SDL_OutOfMemory(); + if ( device ) { + SDL_free(device); + } + return(0); + } + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + + videomutex = SDL_CreateMutex(); + videocond = SDL_CreateCond(); + + /* Set the function pointers */ + device->VideoInit = OGC_VideoInit; + device->ListModes = OGC_ListModes; + device->SetVideoMode = OGC_SetVideoMode; + device->SetColors = OGC_SetColors; + device->UpdateRects = OGC_UpdateRects; + device->VideoQuit = OGC_VideoQuit; + device->AllocHWSurface = OGC_AllocHWSurface; + device->LockHWSurface = OGC_LockHWSurface; + device->UnlockHWSurface = OGC_UnlockHWSurface; + device->FlipHWSurface = OGC_FlipHWSurface; + device->FreeHWSurface = OGC_FreeHWSurface; +#ifdef __wii__ + device->InitOSKeymap = WII_InitOSKeymap; + device->PumpEvents = WII_PumpEvents; +#endif +#ifdef __gamecube__ + device->InitOSKeymap = GAMECUBE_InitOSKeymap; + device->PumpEvents = GAMECUBE_PumpEvents; +#endif + device->input_grab = SDL_GRAB_ON; + + device->GL_LoadLibrary = SDL_OGC_GL_LoadLibrary; + device->GL_GetProcAddress = SDL_OGC_GL_GetProcAddress; + device->GL_MakeCurrent = SDL_OGC_GL_MakeCurrent; + device->GL_SwapBuffers = SDL_OGC_GL_SwapBuffers; + + device->free = OGC_DeleteDevice; + + OGC_InitVideoSystem(); + return device; +} + +static int OGC_Available(void) +{ + return(1); +} + +VideoBootStrap OGC_bootstrap = { + OGCVID_DRIVER_NAME, "ogc video driver", + OGC_Available, OGC_CreateDevice +}; + +void +OGC_InitVideoSystem() +{ + /* Initialise the video system */ + VIDEO_Init(); + vmode = VIDEO_GetPreferredMode(NULL); + + /* Set up the video system with the chosen mode */ + if (vmode == &TVPal528IntDf) + vmode = &TVPal576IntDfScale; + + VIDEO_Configure(vmode); + + // Allocate the video buffer + if (xfb) free(MEM_K1_TO_K0(xfb)); + xfb = (unsigned char*) MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode)); + + VIDEO_ClearFrameBuffer(vmode, xfb, COLOR_BLACK); + VIDEO_SetNextFramebuffer(xfb); + + // Show the screen. + VIDEO_SetBlack(FALSE); + VIDEO_Flush(); + VIDEO_WaitVSync(); VIDEO_WaitVSync(); + + //CON_Init(xfb,20,20,vmode->fbWidth,vmode->xfbHeight,vmode->fbWidth*VI_DISPLAY_PIX_SZ); + + /*** Clear out FIFO area ***/ + memset(&gp_fifo, 0, DEFAULT_FIFO_SIZE); + + /*** Initialise GX ***/ + GX_Init(&gp_fifo, DEFAULT_FIFO_SIZE); + + GXColor background = { 0, 0, 0, 0xff }; + GX_SetCopyClear (background, GX_MAX_Z24); + + SetupGX(); +} + +void OGC_SetWidescreen(int wide) +{ + int width; + if(wide) { + width = 678; + } + else + width = 640; + + vmode->viWidth = width; + vmode->viXOrigin = (VI_MAX_WIDTH_NTSC - width) / 2; + + VIDEO_Configure (vmode); + + if (xfb) + VIDEO_ClearFrameBuffer(vmode, xfb, COLOR_BLACK); + + VIDEO_Flush(); + + VIDEO_WaitVSync(); VIDEO_WaitVSync(); +} + +void OGC_ChangeSquare(int xscale, int yscale, int xshift, int yshift) +{ + square[6] = square[3] = xscale + xshift; + square[0] = square[9] = -xscale + xshift; + square[4] = square[1] = yscale - yshift; + square[7] = square[10] = -yscale - yshift; + DCFlushRange (square, 32); // update memory BEFORE the GPU accesses it! + GX_InvVtxCache(); +} diff --git a/src/video/ogc/SDL_ogc_video.h b/src/video/ogc/SDL_ogc_video.h new file mode 100644 index 0000000000..a86ad89b45 --- /dev/null +++ b/src/video/ogc/SDL_ogc_video.h @@ -0,0 +1,37 @@ +#include "SDL_config.h" + +#ifndef _SDL_ogc_video_h +#define _SDL_ogc_video_h + +/* SDL internal includes */ +#include "../SDL_sysvideo.h" + +/* OGC includes */ +#include + +/* Hidden "this" pointer for the video functions */ +#define _THIS SDL_VideoDevice *this + +/* Private display data */ +typedef struct SDL_PrivateVideoData +{ + // 2x256x16bit palettes = 1x256x24(32)bit palette + // first 256 entries are for Red/Green + // last 256 entries are for Green + Uint16 palette[2*256]; + + Uint8* buffer; + + // these two fields MUST be in this order + Uint8* texturemem; + size_t texturemem_size; + + int width; + int height; + int pitch; +} ogcVideo; + +void OGC_InitVideoSystem(); +void OGC_ChangeSquare(int xscale, int yscale, int xshift, int yshift); + +#endif /* _SDL_wiivideo_h */ diff --git a/src/video/wii/SDL_wiievents.c b/src/video/wii/SDL_wiievents.c new file mode 100644 index 0000000000..2688bda3f2 --- /dev/null +++ b/src/video/wii/SDL_wiievents.c @@ -0,0 +1,264 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + + Yohanes Nugroho (yohanes@gmail.com) + Tantric +*/ +#include "SDL_config.h" + +#include "../../events/SDL_sysevents.h" +#include "../../events/SDL_events_c.h" +#include +#include +#include +#include +#include +#include + +#include "SDL_wiievents_c.h" + +static SDLKey keymap[232]; + +static int posted; + +extern bool TerminateRequested; +extern void Terminate(); +extern int vresx, vresy; + +void PumpEvents() +{ + s32 stat; +#ifdef HW_RVL + keyboard_event ke; + mouse_event me; + + if (TerminateRequested) Terminate(); +#endif + + // this will only work if Joystick 0 has been opened and has been polled + WPADData *wd = WPAD_Data(WPAD_CHAN_0); + + static Uint8 lastButtonStateA = SDL_RELEASED; + static Uint8 lastButtonStateB = SDL_RELEASED; + + Uint8 stateA = (wd->btns_h & WPAD_BUTTON_A) ? SDL_PRESSED : SDL_RELEASED; + Uint8 stateB = (wd->btns_h & WPAD_BUTTON_B) ? SDL_PRESSED : SDL_RELEASED; + + if (stateA != lastButtonStateA) + { + lastButtonStateA = stateA; + posted += SDL_PrivateMouseButton(stateA, SDL_BUTTON_LEFT, 0, 0); + } + + if (stateB != lastButtonStateB) + { + lastButtonStateB = stateB; + posted += SDL_PrivateMouseButton(stateB, SDL_BUTTON_RIGHT, 0, 0); + } + + + if (wd && wd->exp.type != WPAD_EXP_CLASSIC && wd->ir.valid) { + + // use SDL_BUTTON_X2 to signal that this is the wiimote acting as a mouse + Uint8 Buttons = SDL_GetMouseState(NULL, NULL)|SDL_BUTTON_X2MASK; + + if (wd->ir.x < vresx/8) + wd->ir.x = vresx/8; + else if (wd->ir.x > (vresx + vresx/8)) + wd->ir.x = vresx + vresx/8; + if (wd->ir.y < vresy/8) + wd->ir.y = vresy/8; + else if (wd->ir.y > (vresy + vresy/8)) + wd->ir.y = vresy + vresy/8; + posted += SDL_PrivateMouseMotion(Buttons, 0, wd->ir.x - vresx/8, wd->ir.y - vresy/8); + // most apps will ignore this (hopefully) + posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_X2, 0, 0); + wd->ir.valid = 0; + } + + stat = KEYBOARD_GetEvent(&ke); + if (stat && (ke.type == KEYBOARD_RELEASED || ke.type == KEYBOARD_PRESSED)) + { + SDL_keysym keysym; + memset(&keysym, 0, sizeof(keysym)); + Uint8 keystate = (ke.type == KEYBOARD_PRESSED) ? SDL_PRESSED : SDL_RELEASED; + keysym.sym = keymap[ke.keycode]; + keysym.unicode = ke.symbol; + keysym.mod = 0; + posted += SDL_PrivateKeyboard(keystate, &keysym); + } + + stat = MOUSE_GetEvent(&me); + if (stat) + { + u8 button = me.button; + Uint8 mouse_state = SDL_GetMouseState(NULL, NULL); + + posted += SDL_PrivateMouseMotion(0, 1, me.rx*2, me.ry*2); + + if (button & 0x1) { + if (!(mouse_state & SDL_BUTTON_LMASK)) + posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); + } + else if (mouse_state & SDL_BUTTON_LMASK) + posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); + + if (button & 0x2) { + if (!(mouse_state & SDL_BUTTON_RMASK)) + posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0); + } + else if (mouse_state & SDL_BUTTON_RMASK) + posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0); + + if (button & 0x4) { + if (!(mouse_state & SDL_BUTTON_MMASK)) + posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0); + } + else if (mouse_state & SDL_BUTTON_MMASK) + posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0); + + // mouse wheel actions are single events (rz==1(up) or rz==-1(down)) + // send SDL_PRESSED immediately followed by SDL_RELEASED + if (me.rz > 0) { + posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0); + posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0); + } + else if (me.rz < 0) { + posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0); + posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0); + } + } +} + +void WII_PumpEvents(_THIS) +{ + do + { + posted = 0; + PumpEvents(); + usleep(100); + } while (posted); +} + +void WII_InitOSKeymap(_THIS) +{ + int i; + + for (i = 0; i < 232; ++i) + keymap[i] = SDLK_UNKNOWN; + + // a-z + for (i = 0; i < 27; i++) + keymap[4 + i] = SDLK_a + i; + + // 1-9 + for (i = 0; i < 9; i++) + keymap[30 + i] = SDLK_1 + i; + + keymap[39] = SDLK_0; + keymap[40] = SDLK_RETURN; + keymap[41] = SDLK_ESCAPE; + keymap[42] = SDLK_BACKSPACE; + keymap[43] = SDLK_TAB; + keymap[44] = SDLK_SPACE; + keymap[45] = SDLK_MINUS; + keymap[46] = SDLK_EQUALS; + keymap[47] = SDLK_LEFTBRACKET; + keymap[48] = SDLK_RIGHTBRACKET; + keymap[49] = SDLK_BACKSLASH; + keymap[50] = SDLK_UNKNOWN; // unused + keymap[51] = SDLK_SEMICOLON; + keymap[52] = SDLK_QUOTE; + keymap[53] = SDLK_BACKQUOTE; + keymap[54] = SDLK_COMMA; + keymap[55] = SDLK_PERIOD; + keymap[56] = SDLK_SLASH; + keymap[57] = SDLK_CAPSLOCK; + + // F1 to F12 + for (i = 0; i < 12; i++) + keymap[58 + i] = SDLK_F1 + i; + + keymap[70] = SDLK_PRINT; + keymap[71] = SDLK_SCROLLOCK; + keymap[72] = SDLK_PAUSE; + keymap[73] = SDLK_INSERT; + keymap[74] = SDLK_HOME; + keymap[75] = SDLK_PAGEUP; + keymap[76] = SDLK_DELETE; + keymap[77] = SDLK_END; + keymap[78] = SDLK_PAGEDOWN; + + keymap[79] = SDLK_RIGHT; + keymap[80] = SDLK_LEFT; + keymap[81] = SDLK_DOWN; + keymap[82] = SDLK_UP; + keymap[83] = SDLK_NUMLOCK; + + keymap[84] = SDLK_KP_DIVIDE; + keymap[85] = SDLK_KP_MULTIPLY; + keymap[86] = SDLK_KP_MINUS; + keymap[87] = SDLK_KP_PLUS; + + keymap[88] = SDLK_KP_ENTER; + + // keypad 1-9 + for (i = 0; i < 9; i++) + keymap[89 + i] = SDLK_KP1 + i; + + keymap[98] = SDLK_KP0; + keymap[99] = SDLK_KP_PERIOD; + keymap[100] = SDLK_UNKNOWN; // unused + keymap[101] = SDLK_UNKNOWN; // Applic + keymap[102] = SDLK_POWER; + keymap[103] = SDLK_KP_EQUALS; + keymap[104] = SDLK_F13; + keymap[105] = SDLK_F14; + keymap[106] = SDLK_F15; + keymap[107] = SDLK_UNKNOWN; // F16 + keymap[108] = SDLK_UNKNOWN; // F17 + keymap[109] = SDLK_UNKNOWN; // F18 + keymap[110] = SDLK_UNKNOWN; // F19 + keymap[111] = SDLK_UNKNOWN; // F20 + keymap[112] = SDLK_UNKNOWN; // F21 + keymap[113] = SDLK_UNKNOWN; // F22 + keymap[114] = SDLK_UNKNOWN; // F23 + keymap[115] = SDLK_UNKNOWN; // F24 + keymap[116] = SDLK_UNKNOWN; // Execute + keymap[117] = SDLK_HELP; + keymap[118] = SDLK_MENU; + keymap[119] = SDLK_UNKNOWN; // Select + keymap[120] = SDLK_UNKNOWN; // Stop + keymap[121] = SDLK_UNKNOWN; // Again + keymap[122] = SDLK_UNDO; + + keymap[134] = SDLK_KP_EQUALS; + // 135-143 - International + // 144-152 - Language + keymap[154] = SDLK_SYSREQ; + + keymap[224] = SDLK_LCTRL; + keymap[225] = SDLK_LSHIFT; + keymap[226] = SDLK_LALT; + keymap[227] = SDLK_LMETA; + keymap[228] = SDLK_RCTRL; + keymap[229] = SDLK_RSHIFT; + keymap[230] = SDLK_RALT; + keymap[231] = SDLK_RMETA; +} diff --git a/src/video/wii/SDL_wiievents_c.h b/src/video/wii/SDL_wiievents_c.h new file mode 100644 index 0000000000..030cb06c09 --- /dev/null +++ b/src/video/wii/SDL_wiievents_c.h @@ -0,0 +1,33 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "../ogc/SDL_ogc_video.h" + +/* Variables and functions exported by SDL_sysevents.c to other parts + of the native video subsystem (SDL_sysvideo.c) +*/ +extern void WII_InitOSKeymap(_THIS); +extern void WII_PumpEvents(_THIS); + +/* end of SDL_wiievents_c.h ... */ + diff --git a/src/video/wii/SDL_wiimouse.c b/src/video/wii/SDL_wiimouse.c new file mode 100644 index 0000000000..cd41fbf7b6 --- /dev/null +++ b/src/video/wii/SDL_wiimouse.c @@ -0,0 +1,33 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_mouse.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_wiimouse_c.h" + + +/* The implementation dependent data for the window manager cursor */ +struct WMcursor { + int unused; +}; diff --git a/src/video/wii/SDL_wiimouse_c.h b/src/video/wii/SDL_wiimouse_c.h new file mode 100644 index 0000000000..b4c260e6f1 --- /dev/null +++ b/src/video/wii/SDL_wiimouse_c.h @@ -0,0 +1,26 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "../ogc/SDL_ogc_video.h" + +/* Functions to be exported */ diff --git a/src/video/wincommon/SDL_sysevents.c b/src/video/wincommon/SDL_sysevents.c index 090f6f161c..76c67a1ccd 100644 --- a/src/video/wincommon/SDL_sysevents.c +++ b/src/video/wincommon/SDL_sysevents.c @@ -310,8 +310,8 @@ LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if ( WINDIB_FULLSCREEN() ) { appstate |= SDL_APPMOUSEFOCUS; SDL_RestoreDesktopMode(); - /* A fullscreen app gets hidden but will not get a minimize event */ - appstate |= (SDL_APPACTIVE | SDL_APPMOUSEFOCUS); + /* A fullscreen app gets hidden but will not get a minimize event */ + appstate |= (SDL_APPACTIVE | SDL_APPMOUSEFOCUS); #if defined(_WIN32_WCE) LoadAygshell(); if( SHFullScreen ) ================================================ FILE: wii/SDL/config.site ================================================ ac_cv_header_signal=no ac_cv_header_signal_h=no ac_cv_func_sigaction=no ac_cv_func_iconv=no ================================================ FILE: wii/SDL2/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=wii-sdl2 pkgver=2.28.5 pkgrel=17 pkgdesc="A library for portable low-level access to a video framebuffer, audio output, mouse, and keyboard" arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) makedepends=('wii-pkg-config' 'dkp-toolchain-vars') depends=('wii-opengx' 'libogc') source=("${url}/release/SDL2-${pkgver}.tar.gz" "SDL2-${pkgver}.patch") groups=('wii-portlibs' 'wii-sdl2-libs') build() { cd SDL2-$pkgver source /opt/devkitpro/wiivars.sh patch -Np1 -i $srcdir/SDL2-${pkgver}.patch /opt/devkitpro/portlibs/wii/bin/powerpc-eabi-cmake -S. -B _build -DCMAKE_BUILD_TYPE=Release -G Ninja cmake --build _build --parallel } package() { cd SDL2-$pkgver source /opt/devkitpro/wiivars.sh DESTDIR=${pkgdir} cmake --install _build # remove useless stuff rm -r "$pkgdir"${PORTLIBS_PREFIX}/share } sha256sums=('332cb37d0be20cb9541739c61f79bae5a477427d79ae85e352089afdaf6666e4' '605c3065e6848a7f9754229ef675e10f9a5d9f99d8a1f46eea147c85d6e62d94') ================================================ FILE: wii/SDL2/SDL2-2.28.5.patch ================================================ diff --git a/.github/workflows/ngc.yml b/.github/workflows/ngc.yml new file mode 100644 index 0000000000..aeaf6b9269 --- /dev/null +++ b/.github/workflows/ngc.yml @@ -0,0 +1,47 @@ +name: Build (Nintendo GameCube) + +on: [push, pull_request] + +jobs: + ngcn: + runs-on: ubuntu-latest + container: + image: devkitpro/devkitppc:latest + steps: + - uses: actions/checkout@v4 + - name: Install build requirements + run: | + apt update + apt install ninja-build + - name: Configure CMake + run: | + /opt/devkitpro/portlibs/gamecube/bin/powerpc-eabi-cmake -S . -B build -G Ninja \ + -DCMAKE_INSTALL_PREFIX=prefix + - name: Build + run: cmake --build build --verbose --parallel + - name: Install CMake + run: | + echo "SDL2_DIR=$(pwd)/prefix" >> $GITHUB_ENV + cmake --install build/ + ( cd prefix; find ) | LC_ALL=C sort -u + - name: Verify CMake configuration files + run: | + /opt/devkitpro/portlibs/gamecube/bin/powerpc-eabi-cmake -S cmake/test -B cmake_config_build -G Ninja \ + -DTEST_SHARED=FALSE \ + -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} \ + -DCMAKE_BUILD_TYPE=Release + cmake --build cmake_config_build --verbose + - name: Extract CC/CXX/CFLAGS/CXXFLAGS from CMake toolchain + run: | + /opt/devkitpro/portlibs/gamecube/bin/powerpc-eabi-cmake -S .github/cmake -B /tmp/cmake_extract \ + -DCMAKE_BUILD_TYPE=Release \ + -DVAR_PATH=/tmp/ngc_env.txt + cat /tmp/ngc_env.txt >> $GITHUB_ENV + - name: Verify sdl2-config + run: | + export PATH=${{ env.SDL2_DIR }}/bin:$PATH + cmake/test/test_sdlconfig.sh + - name: Verify sdl2.pc + run: | + export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig + cmake/test/test_pkgconfig.sh diff --git a/.github/workflows/nwii.yml b/.github/workflows/nwii.yml new file mode 100644 index 0000000000..625de93b93 --- /dev/null +++ b/.github/workflows/nwii.yml @@ -0,0 +1,47 @@ +name: Build (Nintendo Wii) + +on: [push, pull_request] + +jobs: + nwii: + runs-on: ubuntu-latest + container: + image: devkitpro/devkitppc:latest + steps: + - uses: actions/checkout@v4 + - name: Install build requirements + run: | + apt update + apt install ninja-build + - name: Configure CMake + run: | + /opt/devkitpro/portlibs/wii/bin/powerpc-eabi-cmake -S . -B build -G Ninja \ + -DCMAKE_INSTALL_PREFIX=prefix + - name: Build + run: cmake --build build --verbose --parallel + - name: Install CMake + run: | + echo "SDL2_DIR=$(pwd)/prefix" >> $GITHUB_ENV + cmake --install build/ + ( cd prefix; find ) | LC_ALL=C sort -u + - name: Verify CMake configuration files + run: | + /opt/devkitpro/portlibs/wii/bin/powerpc-eabi-cmake -S cmake/test -B cmake_config_build -G Ninja \ + -DTEST_SHARED=FALSE \ + -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} \ + -DCMAKE_BUILD_TYPE=Release + cmake --build cmake_config_build --verbose + - name: Extract CC/CXX/CFLAGS/CXXFLAGS from CMake toolchain + run: | + /opt/devkitpro/portlibs/wii/bin/powerpc-eabi-cmake -S .github/cmake -B /tmp/cmake_extract \ + -DCMAKE_BUILD_TYPE=Release \ + -DVAR_PATH=/tmp/ngc_env.txt + cat /tmp/ngc_env.txt >> $GITHUB_ENV + - name: Verify sdl2-config + run: | + export PATH=${{ env.SDL2_DIR }}/bin:$PATH + cmake/test/test_sdlconfig.sh + - name: Verify sdl2.pc + run: | + export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig + cmake/test/test_pkgconfig.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index b38a8bbc11..b127adb242 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,7 @@ check_cpu_architecture(x64 SDL_CPU_X64) check_cpu_architecture(arm32 SDL_CPU_ARM32) check_cpu_architecture(arm64 SDL_CPU_ARM64) check_cpu_architecture(loongarch64 SDL_CPU_LOONGARCH64) +check_cpu_architecture(powerpc SDL_CPU_POWERPC) # Check for 64 or 32 bit set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P}) @@ -238,7 +239,7 @@ if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC) endif() # Default option knobs -if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS) +if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS OR OGC) set(OPT_DEF_LIBC ON) endif() @@ -350,7 +351,7 @@ if(EMSCRIPTEN) set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF) endif() -if(VITA OR PSP OR PS2 OR N3DS) +if(VITA OR PSP OR PS2 OR N3DS OR OGC) set(SDL_SHARED_ENABLED_BY_DEFAULT OFF) set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF) endif() @@ -840,7 +841,7 @@ if(SDL_ASSEMBLY) check_include_file("immintrin.h" HAVE_IMMINTRIN_H) - if(SDL_ALTIVEC) + if(SDL_ALTIVEC AND NOT OGC) set(CMAKE_REQUIRED_FLAGS "-maltivec") check_c_source_compiles(" #include @@ -1082,7 +1083,7 @@ if(SDL_LIBC) endforeach() if(HAVE_LIBM) set(CMAKE_REQUIRED_LIBRARIES) - if(NOT VITA) + if(NOT VITA AND NOT NINTENDO_SWITCH AND NOT NINTENDO_WII) list(APPEND EXTRA_LIBS m) endif() endif() @@ -2883,6 +2884,75 @@ elseif(N3DS) endif() list(APPEND EXTRA_LIBS ${lib}) endforeach() + +elseif(OGC) + if(CMAKE_SYSTEM_NAME MATCHES "NintendoWii") + file(GLOB OGC_MAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/wii/*.c) + else() + file(GLOB OGC_MAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/gamecube/*.c) + endif() + set(SDLMAIN_SOURCES ${SDLMAIN_SOURCES} ${OGC_MAIN_SOURCES}) + + if(SDL_AUDIO) + set(SDL_AUDIO_DRIVER_OGC 1) + file(GLOB OGC_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/ogc/*.c) + list(APPEND SOURCE_FILES ${OGC_AUDIO_SOURCES}) + set(HAVE_SDL_AUDIO TRUE) + list(APPEND EXTRA_LIBS "aesnd") + endif() + + if(SDL_FILESYSTEM) + set(SDL_FILESYSTEM_OGC 1) + file(GLOB OGC_FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/ogc/*.c) + list(APPEND SOURCE_FILES ${OGC_FILESYSTEM_SOURCES}) + set(HAVE_SDL_FILESYSTEM TRUE) + endif() + + if(SDL_JOYSTICK) + set(SDL_JOYSTICK_OGC 1) + file(GLOB OGC_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/ogc/*.c) + list(APPEND SOURCE_FILES ${OGC_JOYSTICK_SOURCES}) + set(HAVE_SDL_JOYSTICK TRUE) + endif() + + if(SDL_TIMERS) + set(SDL_TIMER_OGC 1) + file(GLOB OGC_TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/ogc/*.c) + list(APPEND SOURCE_FILES ${OGC_TIMER_SOURCES}) + set(HAVE_SDL_TIMERS TRUE) + endif() + + if(SDL_VIDEO) + set(SDL_VIDEO_DRIVER_OGC 1) + set(SDL_VIDEO_RENDER_OGC 1) + file(GLOB OGC_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/ogc/*.c ${SDL2_SOURCE_DIR}/src/render/ogc/*.c) + list(APPEND SOURCE_FILES ${OGC_VIDEO_SOURCES}) + set(SDL_VIDEO_OPENGL 0) + set(HAVE_SDL_VIDEO TRUE) + if(SDL_OPENGL) + pkg_search_module(OPENGX opengl REQUIRED IMPORTED_TARGET) + set(SDL_VIDEO_OPENGL 1) + set(HAVE_OPENGL TRUE) + list(APPEND EXTRA_LIBS "opengx") + target_include_directories(sdl-build-options INTERFACE ${OPENGX_INCLUDE_DIRS}) + endif() + endif() + + set(SDL_PTHREADS ON) + set(SDL_THREADS ON) + set(PTHREADS_SEM ON) + message(STATUS "pthread") + CheckPTHREAD() + + if(NOT SDL2_DISABLE_SDL2MAIN) + list(INSERT SDL_LIBS 0 "-lSDL2main") + list(APPEND EXTRA_LIBS "fat") + endif() + list(APPEND EXTRA_LDFLAGS "${OGC_ARCH_SETTINGS} ${OGC_LINKER_FLAGS}") + if(NINTENDO_WII) + list(APPEND EXTRA_LIBS "wiiuse;bte;wiikeyboard") + endif() + list(APPEND EXTRA_LIBS "ogc;m") endif() if(HAVE_VULKAN AND NOT SDL_LOADSO) diff --git a/cmake/CheckCPUArchitecture.cmake b/cmake/CheckCPUArchitecture.cmake index 7e3e459470..64ddea7440 100644 --- a/cmake/CheckCPUArchitecture.cmake +++ b/cmake/CheckCPUArchitecture.cmake @@ -34,6 +34,8 @@ function(check_cpu_architecture ARCH VARIABLE) _internal_check_cpu_architecture("defined(__aarch64__) || defined(_M_ARM64)" arm64 ${VARIABLE}) elseif(ARCH STREQUAL "loongarch64") _internal_check_cpu_architecture("defined(__loongarch64)" loongarch64 ${VARIABLE}) + elseif(ARCH STREQUAL "powerpc") + _internal_check_cpu_architecture("defined(PPC)" powerpc ${VARIABLE}) else() message(WARNING "Unknown CPU architectures (${ARCH}).") set(${VARIABLE} FALSE) diff --git a/cmake/sdlplatform.cmake b/cmake/sdlplatform.cmake index 6d8ece6ac5..ea0b7dd8d6 100644 --- a/cmake/sdlplatform.cmake +++ b/cmake/sdlplatform.cmake @@ -50,6 +50,8 @@ macro(SDL_DetectCMakePlatform) set(SDL_CMAKE_PLATFORM HAIKU) elseif(NINTENDO_3DS) set(SDL_CMAKE_PLATFORM N3DS) + elseif(CMAKE_SYSTEM_NAME MATCHES "NintendoWii|NintendoGameCube") + set(SDL_CMAKE_PLATFORM OGC) elseif(OS2) set(SDL_CMAKE_PLATFORM OS2) endif() diff --git a/docs/README-ogc.md b/docs/README-ogc.md new file mode 100644 index 0000000000..619c87a0dc --- /dev/null +++ b/docs/README-ogc.md @@ -0,0 +1,22 @@ +# Nintendo GameCube/Nintendo Wii + +SDL port for the Nintendo GameCube and Nintendo Wii [Homebrew toolchain](https://devkitpro.org/). + +Credits to: + +- The awesome people who ported SDL to other homebrew platforms. +- The Devkitpro team for making all the tools necessary to achieve this. + +## Building + +To build for the Nintendo GameCube or Wii, make sure you have devkitPPC and cmake installed and run: + +```bash +cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/Wii.cmake" -DCMAKE_BUILD_TYPE=Release +cmake --build build +cmake --install build +``` + +## Notes + +- Currently only software rendering is supported. diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index 35923d0207..13f9a6022f 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -329,6 +329,7 @@ #cmakedefine SDL_AUDIO_DRIVER_PSP @SDL_AUDIO_DRIVER_PSP@ #cmakedefine SDL_AUDIO_DRIVER_PS2 @SDL_AUDIO_DRIVER_PS2@ #cmakedefine SDL_AUDIO_DRIVER_N3DS @SDL_AUDIO_DRIVER_N3DS@ +#cmakedefine SDL_AUDIO_DRIVER_OGC @SDL_AUDIO_DRIVER_OGC@ /* Enable various input drivers */ #cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@ @@ -355,6 +356,7 @@ #cmakedefine SDL_JOYSTICK_PSP @SDL_JOYSTICK_PSP@ #cmakedefine SDL_JOYSTICK_PS2 @SDL_JOYSTICK_PS2@ #cmakedefine SDL_JOYSTICK_N3DS @SDL_JOYSTICK_N3DS@ +#cmakedefine SDL_JOYSTICK_OGC @SDL_JOYSTICK_OGC@ #cmakedefine SDL_HAPTIC_DUMMY @SDL_HAPTIC_DUMMY@ #cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@ #cmakedefine SDL_HAPTIC_IOKIT @SDL_HAPTIC_IOKIT@ @@ -390,6 +392,7 @@ #cmakedefine SDL_THREAD_PSP @SDL_THREAD_PSP@ #cmakedefine SDL_THREAD_PS2 @SDL_THREAD_PS2@ #cmakedefine SDL_THREAD_N3DS @SDL_THREAD_N3DS@ +#cmakedefine SDL_THREAD_OGC @SDL_THREAD_OGC@ /* Enable various timer systems */ #cmakedefine SDL_TIMER_HAIKU @SDL_TIMER_HAIKU@ @@ -401,6 +404,7 @@ #cmakedefine SDL_TIMER_PSP @SDL_TIMER_PSP@ #cmakedefine SDL_TIMER_PS2 @SDL_TIMER_PS2@ #cmakedefine SDL_TIMER_N3DS @SDL_TIMER_N3DS@ +#cmakedefine SDL_TIMER_OGC @SDL_TIMER_OGC@ /* Enable various video drivers */ #cmakedefine SDL_VIDEO_DRIVER_ANDROID @SDL_VIDEO_DRIVER_ANDROID@ @@ -455,6 +459,7 @@ #cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM @SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM@ #cmakedefine SDL_VIDEO_DRIVER_VITA @SDL_VIDEO_DRIVER_VITA@ #cmakedefine SDL_VIDEO_DRIVER_N3DS @SDL_VIDEO_DRIVER_N3DS@ +#cmakedefine SDL_VIDEO_DRIVER_OGC @SDL_VIDEO_DRIVER_OGC@ #cmakedefine SDL_VIDEO_RENDER_D3D @SDL_VIDEO_RENDER_D3D@ #cmakedefine SDL_VIDEO_RENDER_D3D11 @SDL_VIDEO_RENDER_D3D11@ @@ -467,6 +472,7 @@ #cmakedefine SDL_VIDEO_RENDER_VITA_GXM @SDL_VIDEO_RENDER_VITA_GXM@ #cmakedefine SDL_VIDEO_RENDER_PS2 @SDL_VIDEO_RENDER_PS2@ #cmakedefine SDL_VIDEO_RENDER_PSP @SDL_VIDEO_RENDER_PSP@ +#cmakedefine SDL_VIDEO_RENDER_OGC @SDL_VIDEO_RENDER_OGC@ /* Enable OpenGL support */ #cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@ @@ -514,6 +520,7 @@ #cmakedefine SDL_FILESYSTEM_PSP @SDL_FILESYSTEM_PSP@ #cmakedefine SDL_FILESYSTEM_PS2 @SDL_FILESYSTEM_PS2@ #cmakedefine SDL_FILESYSTEM_N3DS @SDL_FILESYSTEM_N3DS@ +#cmakedefine SDL_FILESYSTEM_OGC @SDL_FILESYSTEM_OGC@ /* Enable misc subsystem */ #cmakedefine SDL_MISC_DUMMY @SDL_MISC_DUMMY@ diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index d6460b783e..026c63bad9 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -355,6 +355,7 @@ /* Enable various threading systems */ #undef SDL_THREAD_GENERIC_COND_SUFFIX +#undef SDL_THREAD_OGC #undef SDL_THREAD_PTHREAD #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP diff --git a/include/SDL_main.h b/include/SDL_main.h index 5cc8e5913a..8416fb2df7 100644 --- a/include/SDL_main.h +++ b/include/SDL_main.h @@ -117,6 +117,14 @@ */ #define SDL_MAIN_AVAILABLE +#elif defined(__wii__) || defined(__gamecube__) +/* + On Wii and GameCube, SDL provides a main function that sets up the system. + + If you provide this yourself, you may define SDL_MAIN_HANDLED +*/ +#define SDL_MAIN_AVAILABLE + #endif #endif /* SDL_MAIN_HANDLED */ diff --git a/src/SDL.c b/src/SDL.c index 56049adf0b..6d164b2485 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -610,6 +610,10 @@ const char *SDL_GetPlatform(void) return "Nokia N-Gage"; #elif __3DS__ return "Nintendo 3DS"; +#elif defined(__gamecube__) + return "Nintendo GameCube"; +#elif defined(__wii__) + return "Nintendo Wii"; #else return "Unknown (see SDL_platform.h)"; #endif diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 60242e60a0..0dd55916d4 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -108,6 +108,9 @@ static const AudioBootStrap *const bootstrap[] = { #if SDL_AUDIO_DRIVER_N3DS &N3DSAUDIO_bootstrap, #endif +#if SDL_AUDIO_DRIVER_OGC + &OGCAUDIO_bootstrap, +#endif #if SDL_AUDIO_DRIVER_EMSCRIPTEN &EMSCRIPTENAUDIO_bootstrap, #endif diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index c755d43415..9da933290b 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -207,6 +207,7 @@ extern AudioBootStrap PS2AUDIO_bootstrap; extern AudioBootStrap PSPAUDIO_bootstrap; extern AudioBootStrap VITAAUD_bootstrap; extern AudioBootStrap N3DSAUDIO_bootstrap; +extern AudioBootStrap OGCAUDIO_bootstrap; extern AudioBootStrap EMSCRIPTENAUDIO_bootstrap; extern AudioBootStrap OS2AUDIO_bootstrap; diff --git a/src/audio/ogc/SDL_ogcaudio.c b/src/audio/ogc/SDL_ogcaudio.c new file mode 100644 index 0000000000..7a770f1abc --- /dev/null +++ b/src/audio/ogc/SDL_ogcaudio.c @@ -0,0 +1,270 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_AUDIO_DRIVER_OGC + +#include "SDL_audio.h" + +/* OGC Audio driver */ + +#include "../SDL_sysaudio.h" +#include "SDL_ogcaudio.h" +#include "SDL_timer.h" + +#include + +#define OGCAUDIO_DRIVER_NAME "ogc" + +/** + * Cleans up all allocated memory, safe to call with null pointers + */ +static void FreePrivateData(_THIS) +{ + if (!this->hidden) { + return; + } + + SDL_free(this->hidden); + this->hidden = NULL; +} + +static int FindAudioFormat(_THIS) +{ + SDL_bool found_valid_format = SDL_FALSE; + Uint16 test_format = SDL_FirstAudioFormat(this->spec.format); + + while (!found_valid_format && test_format) { + this->spec.format = test_format; + SDL_LogDebug(SDL_LOG_CATEGORY_AUDIO, "Trying format %x", test_format); + switch (test_format) { + case AUDIO_S8: + this->hidden->format = VOICE_MONO8; + this->hidden->bytes_per_sample = this->spec.channels; + found_valid_format = SDL_TRUE; + break; + case AUDIO_U8: + this->hidden->format = VOICE_MONO8_UNSIGNED; + this->hidden->bytes_per_sample = this->spec.channels; + found_valid_format = SDL_TRUE; + break; + case AUDIO_S16LSB: + case AUDIO_S16MSB: + this->hidden->format = VOICE_MONO16; + this->hidden->bytes_per_sample = this->spec.channels * 2; + this->spec.format = AUDIO_S16MSB; + found_valid_format = SDL_TRUE; + break; + case AUDIO_U16LSB: + case AUDIO_U16MSB: + this->hidden->format = VOICE_MONO16_UNSIGNED; + this->hidden->bytes_per_sample = this->spec.channels * 2; + this->spec.format = AUDIO_U16MSB; + found_valid_format = SDL_TRUE; + break; + default: + test_format = SDL_NextAudioFormat(); + break; + } + } + + if (found_valid_format && this->spec.channels == 2) { + this->hidden->format++; + } + + return found_valid_format ? 0 : -1; +} + +/* fully local functions related to the wavebufs / DSP, not the same as the SDL-wide mixer lock */ +static SDL_INLINE void contextLock(_THIS) +{ + LWP_MutexLock(this->hidden->lock); +} + +static SDL_INLINE void contextUnlock(_THIS) +{ + LWP_MutexUnlock(this->hidden->lock); +} + +static void audio_frame_finished(AESNDPB *pb, u32 state, void *arg) +{ + SDL_AudioDevice *this = (SDL_AudioDevice *)arg; + + if (state == VOICE_STATE_STREAM) { + const size_t buffer_size = DMA_BUFFER_SIZE; + s8 playing_buffer; + void *buffer; + + /* Immediately send the next buffer to the DSP. It's important that + * AESND_SetVoiceBuffer() gets called before this callback returns, or + * some audio gaps might be audible. */ + contextLock(this); + playing_buffer = (this->hidden->playing_buffer + 1) % NUM_BUFFERS; + buffer = this->hidden->dma_buffers[playing_buffer]; + AESND_SetVoiceBuffer(pb, buffer, buffer_size); + this->hidden->playing_buffer = playing_buffer; + contextUnlock(this); + + /* If a frame has finished playing, it means that the corresponding + * buffer is no longer in use and can be filled up again. We signal + * this event to the audio thread via a semaphore. */ + LWP_SemPost(this->hidden->available_buffers); + } if (state == VOICE_STATE_STOPPED) { + contextLock(this); + this->hidden->playing_buffer = -1; + contextUnlock(this); + } +} + +static int OGCAUDIO_OpenDevice(_THIS, const char *devname) +{ + struct SDL_PrivateAudioData *hidden = + memalign(32, sizeof(struct SDL_PrivateAudioData)); + if (!hidden) { + return SDL_OutOfMemory(); + } + + SDL_LogDebug(SDL_LOG_CATEGORY_AUDIO, + "OGCAUDIO_OpenDevice, name=%s, freq=%d, channels=%d\n", + devname, this->spec.freq, this->spec.channels); + + memset(hidden, 0, sizeof(*hidden)); + hidden->playing_buffer = -1; + this->hidden = hidden; + + AESND_Init(); + AESND_Pause(1); + + /* Initialise internal state */ + LWP_MutexInit(&hidden->lock, false); + /* We set the initial number of available buffers to NUM_BUFFERS - 1, since + * SDL first calls GetDeviceBuf() and starts filling it without first + * calling WaitDevice(). So we consider the first buffer to be busy already + * at start. */ + LWP_SemInit(&hidden->available_buffers, NUM_BUFFERS - 1, NUM_BUFFERS); + + if (this->spec.freq <= 0 || this->spec.freq > 144000) + this->spec.freq = DSP_DEFAULT_FREQ; + + if (this->spec.channels > 2) { + this->spec.channels = 2; + } + + /* Should not happen but better be safe. */ + if (FindAudioFormat(this) < 0) { + return SDL_SetError("No supported audio format found."); + } + + this->spec.samples = DMA_BUFFER_SIZE / this->hidden->bytes_per_sample; + + /* Update the fragment size as size in bytes */ + SDL_CalculateAudioSpec(&this->spec); + + hidden->voice = AESND_AllocateVoiceWithArg(audio_frame_finished, this); + if (hidden->voice == NULL) + return -1; + + // start audio + AESND_SetVoiceFormat(hidden->voice, hidden->format); + AESND_SetVoiceFrequency(hidden->voice, this->spec.freq); + AESND_SetVoiceBuffer(hidden->voice, hidden->dma_buffers[0], DMA_BUFFER_SIZE); + AESND_SetVoiceStream(hidden->voice, true); + AESND_SetVoiceStop(hidden->voice, 0); + AESND_Pause(0); + + return 0; +} + +static void OGCAUDIO_PlayDevice(_THIS) +{ + void *buffer; + + /* This only sends the first audio buffer. The following ones will always + * be send from the audio_frame_finished() callback, without having to + * switch between threads. */ + contextLock(this); + if (this->hidden->playing_buffer < 0) { + buffer = this->hidden->dma_buffers[++this->hidden->playing_buffer]; + AESND_SetVoiceBuffer(this->hidden->voice, buffer, DMA_BUFFER_SIZE); + } + contextUnlock(this); +} + +static void OGCAUDIO_WaitDevice(_THIS) +{ + s8 nextbuf; + + /* This will block until at least one buffer is available for writing. */ + LWP_SemWait(this->hidden->available_buffers); + + nextbuf = this->hidden->nextbuf; + this->hidden->nextbuf = (nextbuf + 1) % NUM_BUFFERS; +} + +static Uint8 *OGCAUDIO_GetDeviceBuf(_THIS) +{ + return this->hidden->dma_buffers[this->hidden->nextbuf]; +} + +static void OGCAUDIO_CloseDevice(_THIS) +{ + struct SDL_PrivateAudioData *hidden = this->hidden; + + LWP_SemDestroy(hidden->available_buffers); + if (hidden->voice) { + AESND_SetVoiceStop(hidden->voice, true); + AESND_FreeVoice(hidden->voice); + hidden->voice = NULL; + } + + AESND_Pause(1); + FreePrivateData(this); +} + +static void OGCAUDIO_ThreadInit(_THIS) +{ + LWP_SetThreadPriority(LWP_THREAD_NULL, 80); +} + +static SDL_bool OGCAUDIO_Init(SDL_AudioDriverImpl *impl) +{ + /* Set the function pointers */ + impl->OpenDevice = OGCAUDIO_OpenDevice; + impl->PlayDevice = OGCAUDIO_PlayDevice; + impl->WaitDevice = OGCAUDIO_WaitDevice; + impl->GetDeviceBuf = OGCAUDIO_GetDeviceBuf; + impl->CloseDevice = OGCAUDIO_CloseDevice; + impl->ThreadInit = OGCAUDIO_ThreadInit; + impl->OnlyHasDefaultOutputDevice = SDL_TRUE; + + return SDL_TRUE; /* this audio target is available. */ +} + +AudioBootStrap OGCAUDIO_bootstrap = { + OGCAUDIO_DRIVER_NAME, + "SDL OGC audio driver", + OGCAUDIO_Init, + 0 +}; + +#endif /* SDL_AUDIO_DRIVER_OGC */ + +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/audio/ogc/SDL_ogcaudio.h b/src/audio/ogc/SDL_ogcaudio.h new file mode 100644 index 0000000000..a575ac5aaa --- /dev/null +++ b/src/audio/ogc/SDL_ogcaudio.h @@ -0,0 +1,54 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_ogcaudio_h_ +#define _SDL_ogcaudio_h_ + +#include +#include + +#include +#include + +/* Hidden "this" pointer for the audio functions */ +#define _THIS SDL_AudioDevice *this + +#define NUM_BUFFERS 4 /* -- Minimum 2! */ +#define SAMPLES_PER_DMA_BUFFER (DSP_STREAMBUFFER_SIZE) +#define DMA_BUFFER_SIZE (SAMPLES_PER_DMA_BUFFER * 2 * sizeof(short)) + +struct SDL_PrivateAudioData +{ + /* these go first so they will be aligned */ + Uint8 dma_buffers[NUM_BUFFERS][DMA_BUFFER_SIZE]; + AESNDPB *voice; + + /* Speaker data */ + Uint32 format; + Uint8 bytes_per_sample; + s8 nextbuf; + s8 playing_buffer; + mutex_t lock; + sem_t available_buffers; +}; + +#endif /* _SDL_ogcaudio_h_ */ +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/dynapi/SDL_dynapi.h b/src/dynapi/SDL_dynapi.h index 99ca08008f..d261a33f07 100644 --- a/src/dynapi/SDL_dynapi.h +++ b/src/dynapi/SDL_dynapi.h @@ -67,6 +67,8 @@ #define SDL_DYNAMIC_API 0 /* The N-Gage doesn't support dynamic linking either */ #elif defined(__3DS__) #define SDL_DYNAMIC_API 0 /* devkitARM doesn't support dynamic linking */ +#elif defined(__wii__) || defined(__gamecube__) +#define SDL_DYNAMIC_API 0 /* devkitPPC doesn't support dynamic linking */ #elif defined(DYNAPI_NEEDS_DLOPEN) && !defined(HAVE_DLOPEN) #define SDL_DYNAMIC_API 0 /* we need dlopen(), but don't have it.... */ #endif diff --git a/src/filesystem/ogc/SDL_sysfilesystem.c b/src/filesystem/ogc/SDL_sysfilesystem.c new file mode 100644 index 0000000000..cf42b99f1e --- /dev/null +++ b/src/filesystem/ogc/SDL_sysfilesystem.c @@ -0,0 +1,86 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_FILESYSTEM_OGC + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include +#include +#include + +#include "SDL_error.h" +#include "SDL_filesystem.h" + +static inline int create_dir(const char *dirname) +{ + int result = mkdir(dirname, 0666); + + if (result == -1 && errno != EEXIST) { + return SDL_SetError("Failed to create '%s' (%s)", dirname, strerror(errno)); + } + return 0; +} + +char *SDL_GetBasePath(void) +{ + char buffer[256]; + size_t len; + + if (!getcwd(buffer, sizeof(buffer) - 1)) { + return "/"; + } + + len = strlen(buffer); + if (len > 0 && buffer[len - 1] != '/') { + buffer[len] = '/'; + buffer[len + 1] = '\0'; + } + + return SDL_strdup(buffer); +} + +char *SDL_GetPrefPath(const char *org, const char *app) +{ + char *pref_path = NULL; + if (!app) { + SDL_InvalidParamError("app"); + return NULL; + } + + SDL_asprintf(&pref_path, "/apps/%s/", app); + if (!pref_path) { + return NULL; + } + + if (create_dir(pref_path) < 0) { + SDL_free(pref_path); + return NULL; + } + + return pref_path; +} + +#endif /* SDL_FILESYSTEM_OGC */ + +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 834e83d99e..65dc3ce685 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -105,6 +105,9 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = { #ifdef SDL_JOYSTICK_N3DS &SDL_N3DS_JoystickDriver #endif +#ifdef SDL_JOYSTICK_OGC + &SDL_OGC_JoystickDriver +#endif #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED) &SDL_DUMMY_JoystickDriver #endif diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h index a93fa662ca..3d3329ae5a 100644 --- a/src/joystick/SDL_sysjoystick.h +++ b/src/joystick/SDL_sysjoystick.h @@ -249,6 +249,7 @@ extern SDL_JoystickDriver SDL_PS2_JoystickDriver; extern SDL_JoystickDriver SDL_PSP_JoystickDriver; extern SDL_JoystickDriver SDL_VITA_JoystickDriver; extern SDL_JoystickDriver SDL_N3DS_JoystickDriver; +extern SDL_JoystickDriver SDL_OGC_JoystickDriver; /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/src/joystick/ogc/SDL_sysjoystick.c b/src/joystick/ogc/SDL_sysjoystick.c new file mode 100644 index 0000000000..56d5beccc4 --- /dev/null +++ b/src/joystick/ogc/SDL_sysjoystick.c @@ -0,0 +1,1328 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" + +#ifdef SDL_JOYSTICK_OGC + +#include "../SDL_joystick_c.h" +#include "../SDL_sysjoystick.h" +#include "../usb_ids.h" +#include "SDL_events.h" +#include "SDL_hints.h" +#include "../../SDL_hints_c.h" +#include "SDL_joystick.h" + +#include +#include +#include +#include + +#define PI 3.14159265f + +#define MAX_GC_JOYSTICKS 4 +#define MAX_WII_JOYSTICKS 4 + +#define GC_JOYSTICKS_START 0 +#define GC_JOYSTICKS_END MAX_GC_JOYSTICKS +#define WII_JOYSTICKS_START GC_JOYSTICKS_END +#define WII_WIIMOTES_START WII_JOYSTICKS_START +#define WII_WIIMOTES_END (WII_WIIMOTES_START + MAX_WII_JOYSTICKS) +#define WII_EXP_START WII_WIIMOTES_END +#define WII_EXP_END (WII_EXP_START + MAX_WII_JOYSTICKS) +#define WII_JOYSTICKS_END WII_EXP_END + +#define MAX_JOYSTICKS WII_EXP_END + +#define MAX_GC_AXES 6 +#define MAX_GC_BUTTONS 8 +#define MAX_GC_HATS 1 + +#define MAX_WII_AXES 9 +#define MAX_WII_BUTTONS 15 +#define MAX_WII_HATS 1 + +#define JOYNAMELEN 10 + +#define AXIS_MIN -32767 /* minimum value for axis coordinate */ +#define AXIS_MAX 32767 /* maximum value for axis coordinate */ + +#define MAX_RUMBLE 8 + +typedef struct joystick_paddata_t +{ + u16 prev_buttons; + s8 stickX; + s8 stickY; + s8 substickX; + s8 substickY; + u8 triggerL; + u8 triggerR; +} joystick_paddata; + +typedef struct joystick_wpaddata_t +{ + u32 prev_buttons; + u32 exp; + s16 nunchuk_stickX; + s16 nunchuk_stickY; + s16 classicL_stickX; + s16 classicL_stickY; + s16 classicR_stickX; + s16 classicR_stickY; + u8 classic_triggerL; + u8 classic_triggerR; + u8 classic_calibrated; + s8 wiimote_pitch; + s8 wiimote_roll; + s8 wiimote_yaw; + s16 classic_cal[4][3]; // 4x axes, min/center/max +} joystick_wpaddata; + +/* The private structure used to keep track of a joystick */ +typedef struct joystick_hwdata +{ + int index; + char sensors_disabled; + /* This must be big enough for MAX_RUMBLE */ + char rumble_intensity; + u16 rumble_loop; + union + { + joystick_paddata gamecube; + joystick_wpaddata wiimote; + }; +} joystick_hwdata; + +#ifdef __wii__ +static const u32 sdl_buttons_wii[] = { + WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, + WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, + WPAD_BUTTON_1, + WPAD_BUTTON_2, + WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, + WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, + WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, + WPAD_NUNCHUK_BUTTON_Z, /* 7 */ + WPAD_NUNCHUK_BUTTON_C, /* 8 */ + WPAD_CLASSIC_BUTTON_X, /* 9 */ + WPAD_CLASSIC_BUTTON_Y, + WPAD_CLASSIC_BUTTON_FULL_L, + WPAD_CLASSIC_BUTTON_FULL_R, + WPAD_CLASSIC_BUTTON_ZL, + WPAD_CLASSIC_BUTTON_ZR +}; +#define SDL_WII_NUM_BUTTONS_WII \ + (sizeof(sdl_buttons_wii) / sizeof(sdl_buttons_wii[0])) + +static const u32 sdl_buttons_wiimote[] = { + WPAD_BUTTON_A, + WPAD_BUTTON_B, + WPAD_BUTTON_1, + WPAD_BUTTON_2, + WPAD_BUTTON_MINUS, + WPAD_BUTTON_PLUS, + WPAD_BUTTON_HOME, +}; +#define SDL_WII_NUM_BUTTONS_WIIMOTE \ + (sizeof(sdl_buttons_wiimote) / sizeof(sdl_buttons_wiimote[0])) + +static const u32 sdl_buttons_nunchuck[] = { + WPAD_NUNCHUK_BUTTON_Z, + WPAD_NUNCHUK_BUTTON_C, +}; +#define SDL_WII_NUM_BUTTONS_NUNCHUCK \ + (sizeof(sdl_buttons_nunchuck) / sizeof(sdl_buttons_nunchuck[0])) + +static const u32 sdl_buttons_classic[] = { + WPAD_CLASSIC_BUTTON_A, + WPAD_CLASSIC_BUTTON_B, + WPAD_CLASSIC_BUTTON_X, + WPAD_CLASSIC_BUTTON_Y, + WPAD_CLASSIC_BUTTON_FULL_L, + WPAD_CLASSIC_BUTTON_FULL_R, + WPAD_CLASSIC_BUTTON_ZL, + WPAD_CLASSIC_BUTTON_ZR, + WPAD_CLASSIC_BUTTON_MINUS, + WPAD_CLASSIC_BUTTON_PLUS, + WPAD_CLASSIC_BUTTON_HOME, +}; +#define SDL_WII_NUM_BUTTONS_CLASSIC \ + (sizeof(sdl_buttons_classic) / sizeof(sdl_buttons_classic[0])) +#endif /* __wii__ */ + +static const u16 sdl_buttons_gc[] = { + PAD_BUTTON_A, + PAD_BUTTON_B, + PAD_BUTTON_X, + PAD_BUTTON_Y, + PAD_TRIGGER_L, + PAD_TRIGGER_R, + PAD_TRIGGER_Z, + PAD_BUTTON_START, +}; + +static int split_joysticks = 0; + +static SDL_JoystickID s_connected_instances[MAX_JOYSTICKS]; +/* Value is 0 if controller is not present, otherwise 1 + extension enum */ +static char s_detected_devices[MAX_JOYSTICKS]; +static char s_gc_failed_reads = 0; +static u32 s_gc_last_scanpads = 0; +static bool s_hardware_queried = false; + + +#ifdef __wii__ +static bool s_wii_has_new_data[MAX_WII_JOYSTICKS]; +static bool s_accelerometers_as_axes = false; +static bool s_wiimote_sideways = false; + +static void SDLCALL +on_hint_accel_as_joystick_cb(void *userdata, const char *name, + const char *oldValue, const char *hint) +{ + s_accelerometers_as_axes = SDL_GetStringBoolean(hint, SDL_FALSE); +} + +#endif + +/* Joypad index is 0-11: 4 GC, 4 Wiimotes and (if split_joysticks) 4 expansions + */ +static int device_index_to_joypad_index(int device_index) +{ + int count = 0; + + for (int i = 0; i < MAX_JOYSTICKS; i++) { + if (s_connected_instances[i] >= 0) { + if (count == device_index) + return i; + count++; + } + } + + SDL_LogError(SDL_LOG_CATEGORY_INPUT, + "Cannot find device index %d", device_index); + return -1; +} + +static int device_index_to_instance(int device_index) +{ + int index = device_index_to_joypad_index(device_index); + if (index < 0) + return -1; + return s_connected_instances[index]; +} + +static void scan_hardware(void) +{ + /* Scan the GameCube and Wii controllers, but only if this was not done + * before during this update cycle. + * The Detect() callback, resets the s_hardware_queried variable. */ + if (!s_hardware_queried) { + s_gc_last_scanpads = PAD_ScanPads(); +#ifdef __wii__ + for (int i = 0; i < MAX_WII_JOYSTICKS; i++) { + s_wii_has_new_data[i] = WPAD_ReadPending(i, NULL); + } +#endif + s_hardware_queried = true; + } +} + +static void report_joystick(int index, int connected) +{ + printf("Controller %d was %s (%d)\n", + index, connected ? "connected" : "removed", connected); + + /* First, if the joystick was connected with a different expansion, remove + * it */ + if (s_connected_instances[index] >= 0) { + SDL_PrivateJoystickRemoved(s_connected_instances[index]); + s_connected_instances[index] = -1; + } + + if (connected) { + s_connected_instances[index] = SDL_GetNextJoystickInstanceID(); + SDL_PrivateJoystickAdded(s_connected_instances[index]); + } +} + +static inline bool enable_rumble(int index, bool enable) +{ + if (index >= GC_JOYSTICKS_START && index < GC_JOYSTICKS_END) { + PAD_ControlMotor(index - GC_JOYSTICKS_START, + enable ? PAD_MOTOR_RUMBLE : PAD_MOTOR_STOP); + return true; +#ifdef __wii__ + } else if (index >= WII_WIIMOTES_START && index < WII_JOYSTICKS_END) { + WPAD_Rumble(index - WII_WIIMOTES_START, enable); + return true; +#endif + } else { + return false; + } +} + +static void update_rumble(SDL_Joystick *joystick) +{ + char intensity = joystick->hwdata->rumble_intensity; + s16 loop; + int rest_frames; + bool rumble; + if (intensity == 0 || intensity == MAX_RUMBLE - 1) return; + + loop = ++joystick->hwdata->rumble_loop; + + /* The rest_frames constant should probably be set according to the current + * framerate; or we should rework the logic to be completely time-based. + * It may also be that we need different values depending on the controller + * type. */ + rest_frames = 2; + if (loop == 1) { + rumble = false; + } else if (loop > (MAX_RUMBLE - 1 - intensity) * rest_frames) { + rumble = true; + joystick->hwdata->rumble_loop = 0; + } else { + /* Keep the engine stopped until our time comes again */ + return; + } + + enable_rumble(joystick->hwdata->index, rumble); +} + +/* Function to scan the system for joysticks. + * This function should return the number of available + * joysticks. Joystick 0 should be the system default joystick. + * It should return -1 on an unrecoverable fatal error. + */ +static int OGC_JoystickInit(void) +{ + const char *split_joystick_env = getenv("SDL_WII_JOYSTICK_SPLIT"); + split_joysticks = split_joystick_env && strcmp(split_joystick_env, "1") == 0; + + PAD_Init(); + /* We don't call WPAD_Init() here, since it's already been called by + * SDL_main for the Wii */ + +#ifdef __wii__ + SDL_AddHintCallback(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, + on_hint_accel_as_joystick_cb, NULL); + /* If this is set, the Wiimote directional keys will be translated. */ + { + const char *sideways_joystick_env = getenv("SDL_WII_JOYSTICK_SIDEWAYS"); + s_wiimote_sideways = + sideways_joystick_env && strcmp(sideways_joystick_env, "1") == 0; + } +#endif + + /* Initialize the needed variables */ + for (int i = 0; i < MAX_JOYSTICKS; i++) { + s_connected_instances[i] = -1; + } + return 0; +} + +static int OGC_JoystickGetCount(void) +{ + int count = 0; + + for (int i = 0; i < MAX_JOYSTICKS; i++) { + if (s_connected_instances[i] >= 0) + count++; + } + return count; +} + +static void OGC_JoystickDetect(void) +{ + scan_hardware(); + + /* Ignore individual disconnected statuses, since they might just + * happen because the controller is not ready. */ + if (s_gc_last_scanpads == 0 && s_gc_failed_reads < 4) { + s_gc_failed_reads++; + s_hardware_queried = false; + } else { + s_gc_failed_reads = 0; + for (int i = 0; i < MAX_GC_JOYSTICKS; i++) { + bool connected = s_gc_last_scanpads & (1 << i); + bool was_connected = s_detected_devices[i]; + if (connected == was_connected) + continue; + + report_joystick(i, connected); + s_detected_devices[i] = connected; + } + } + +#ifdef __wii__ + for (int i = 0; i < MAX_WII_JOYSTICKS; i++) { + int connected, was_connected, index; + WPADData *data; + + if (!s_wii_has_new_data[i]) + continue; + + data = WPAD_Data(i); + index = WII_JOYSTICKS_START + i; + connected = data->err != WPAD_ERR_NO_CONTROLLER && + data->data_present != 0; + if (split_joysticks) { + int exp_index = WII_EXP_START + i; + int exp_connected = + (connected && data->exp.type != WPAD_EXP_NONE) ? (1 + data->exp.type) : 0; + int exp_was_connected = s_detected_devices[exp_index]; + if (exp_connected != exp_was_connected) { + s_detected_devices[exp_index] = exp_connected; + report_joystick(exp_index, exp_connected); + } + } else if (connected) { + connected += data->exp.type; + } + + was_connected = s_detected_devices[index]; + if (connected != was_connected) { + s_detected_devices[index] = connected; + report_joystick(index, connected); + } + } +#endif + + /* This is to force a refresh, the next time that Update() or Detect() are + * called. This relies on the fact that SDL calls Detect() after Update(). + */ + s_hardware_queried = false; +} + +static char joy_name[128]; + +/* Function to get the device-dependent name of a joystick */ +static const char *OGC_JoystickGetDeviceName(int device_index) +{ + int index = device_index_to_joypad_index(device_index); + if (index < 0) + return NULL; + + if (index >= GC_JOYSTICKS_START && index < GC_JOYSTICKS_END) { + sprintf(joy_name, "Gamecube %d", index); +#ifdef __wii__ + } else if (index >= WII_WIIMOTES_START && index < WII_WIIMOTES_END) { + char *name_ptr = joy_name; + int expansion = s_detected_devices[index] - 1; + name_ptr += sprintf(name_ptr, "Wiimote %d", index - WII_WIIMOTES_START); + if (!split_joysticks) { + // Add expansion information + switch (expansion) { + case WPAD_EXP_NUNCHUK: + strcpy(name_ptr, " + Nunchuk"); + break; + case WPAD_EXP_CLASSIC: + strcpy(name_ptr, " + Classic"); + break; + case WPAD_EXP_GUITARHERO3: + strcpy(name_ptr, " + Guitar Hero 3"); + break; + case WPAD_EXP_WIIBOARD: + strcpy(name_ptr, " + Balance board"); + break; + } + } + } else if (split_joysticks) { + /* This is an expansion and we are using the split controllers + * option: show only the expansion name, then. */ + int expansion = s_detected_devices[index] - 1; + int idx = index - WII_EXP_START; + switch (expansion) { + case WPAD_EXP_NUNCHUK: + sprintf(joy_name, "Nunchuk %d", idx); + break; + case WPAD_EXP_CLASSIC: + sprintf(joy_name, "Classic %d", idx); + break; + case WPAD_EXP_GUITARHERO3: + sprintf(joy_name, "Guitar Hero 3 %d", idx); + break; + case WPAD_EXP_WIIBOARD: + sprintf(joy_name, "Balance board %d", idx); + break; + case WPAD_EXP_NONE: + strcpy(joy_name, "Disconnected"); + break; + default: + sprintf(joy_name, "Unknown %d", idx); + break; + } +#endif + } else { + sprintf(joy_name, "Invalid device index: %d", device_index); + } + return joy_name; +} + +static const char *OGC_JoystickGetDevicePath(int index) +{ + return NULL; +} + +static int OGC_JoystickGetDevicePlayerIndex(int device_index) +{ + return -1; +} + +static void OGC_JoystickSetDevicePlayerIndex(int device_index, int player_index) +{ +} + +static SDL_JoystickGUID OGC_JoystickGetDeviceGUID(int device_index) +{ + int index = device_index_to_joypad_index(device_index); + Uint16 bus, product, version; + Uint8 driver_signature, driver_data; + const char *name; + + /* We invent our own product IDs, to tell our joysticks apart. + * Since we want the gamepads to appear with the numeric ID in their + * name, we make them unique by assigning a different product depending on + * the port. */ + product = (index + 1) << 8; + if (index >= GC_JOYSTICKS_START && index < GC_JOYSTICKS_END) { + bus = SDL_HARDWARE_BUS_UNKNOWN; + } else { + bus = SDL_HARDWARE_BUS_BLUETOOTH; + product += s_detected_devices[index]; + } + version = 1; + driver_signature = 0; + driver_data = 0; + + name = OGC_JoystickGetDeviceName(device_index); + return SDL_CreateJoystickGUID(bus, USB_VENDOR_NINTENDO, product, version, + name, driver_signature, driver_data); +} + +static SDL_JoystickID OGC_JoystickGetDeviceInstanceID(int device_index) +{ + return device_index_to_instance(device_index); +} + +static int OGC_JoystickOpen(SDL_Joystick *joystick, int device_index) +{ + int index = device_index_to_joypad_index(device_index); + + printf("Open joystick %d (our index: %d)\n", device_index, index); + + if (index < 0) + return -1; + + /* allocate memory for system specific hardware data */ + joystick->hwdata = SDL_malloc(sizeof(joystick_hwdata)); + if (joystick->hwdata == NULL) { + SDL_OutOfMemory(); + return -1; + } + joystick->instance_id = s_connected_instances[index]; + + SDL_memset(joystick->hwdata, 0, sizeof(joystick_hwdata)); + joystick->hwdata->index = index; + if (index >= GC_JOYSTICKS_START && index < GC_JOYSTICKS_END) { + joystick->nbuttons = MAX_GC_BUTTONS; + joystick->naxes = MAX_GC_AXES; + joystick->nhats = MAX_GC_HATS; +#ifdef __wii__ + } else { + if (split_joysticks) { + if (index < WII_WIIMOTES_END) { + // wiimote + joystick->nbuttons = SDL_WII_NUM_BUTTONS_WIIMOTE; + joystick->naxes = 3; + joystick->nhats = 1; + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 100.0f); + } else { + // expansion + joystick->nbuttons = SDL_max(SDL_WII_NUM_BUTTONS_NUNCHUCK, + SDL_WII_NUM_BUTTONS_CLASSIC); + joystick->naxes = 6; + joystick->nhats = 1; + if (s_detected_devices[index] == 1 + WPAD_EXP_NUNCHUK) { + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL_L, 100.0f); + } + } + } else { + joystick->nbuttons = MAX_WII_BUTTONS; + joystick->naxes = MAX_WII_AXES; + joystick->nhats = MAX_WII_HATS; + /* Add the accelerometer only if there is no expansion connected */ + if (s_detected_devices[index] == 1) { + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 100.0f); + } else if (s_detected_devices[index] == 1 + WPAD_EXP_NUNCHUK) { + /* Or, if the nunchuck is connected, add the wiimote, and the + * nunchuk on the left */ + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 100.0f); + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL_L, 100.0f); + } + } +#endif + } + return 0; +} + +static int OGC_JoystickRumble(SDL_Joystick *joystick, + Uint16 low_frequency_rumble, + Uint16 high_frequency_rumble) +{ + int index = joystick->hwdata->index; + /* The Wii and GameCube controllers do not support setting the frequency of + * the rumble, so we use a hack where we periodically stop and start the + * motors during Update(). */ + char intensity = MAX_RUMBLE * + ((low_frequency_rumble + high_frequency_rumble) / 2) / + 0xffff; + /* We don't accept MAX_RUMBLE itself */ + if (intensity >= MAX_RUMBLE) + intensity = MAX_RUMBLE - 1; + + /* If it's the same as the current value, do nothing */ + if (intensity == joystick->hwdata->rumble_intensity) { + return 0; + } + + if (!enable_rumble(index, intensity > 0)) { + return SDL_Unsupported(); + } + + /* Save the current rumble status, we need it in update_rumble() */ + joystick->hwdata->rumble_intensity = intensity; + joystick->hwdata->rumble_loop = 0; + + return 0; +} + +static int OGC_JoystickRumbleTriggers(SDL_Joystick *joystick, + Uint16 left_rumble, Uint16 right_rumble) +{ + return SDL_Unsupported(); +} + +static Uint32 OGC_JoystickGetCapabilities(SDL_Joystick *joystick) +{ + Uint32 capabilities = 0; + + int index = joystick->hwdata->index; + if ((index >= GC_JOYSTICKS_START && index < GC_JOYSTICKS_END) || + /* Rumble is supported on the wiimotes, but it makes sense only if no + * expansion is attached, of if we are in split mode. */ + (index >= WII_WIIMOTES_START && index < WII_WIIMOTES_END && + (s_detected_devices[index] == 1 || split_joysticks))) { + capabilities |= SDL_JOYCAP_RUMBLE; + } + return capabilities; +} + +static int OGC_JoystickSetLED(SDL_Joystick *joystick, + Uint8 red, Uint8 green, Uint8 blue) +{ + return SDL_Unsupported(); +} + +static int OGC_JoystickSendEffect(SDL_Joystick *joystick, + const void *data, int size) +{ + return SDL_Unsupported(); +} + +static int OGC_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +{ + int index = joystick->hwdata->index; + if (index >= WII_WIIMOTES_START && index < WII_WIIMOTES_END) { + joystick->hwdata->sensors_disabled = !enabled; + return 0; + } + return SDL_Unsupported(); +} + +#ifdef __wii__ + +static s16 WPAD_Orient(WPADData *data, int motion) +{ + float out; + + if (motion == 0) + out = data->orient.pitch; + else if (motion == 1) + out = data->orient.roll; + else + out = data->orient.yaw; + + return (s16)((out / 180.0) * 128.0); +} + +static s16 WPAD_Pitch(WPADData *data) +{ + return WPAD_Orient(data, 0); +} + +static s16 WPAD_Roll(WPADData *data) +{ + return WPAD_Orient(data, 1); +} + +static s16 WPAD_Yaw(WPADData *data) +{ + return WPAD_Orient(data, 2); +} + +static s16 WPAD_Stick(s16 x, s16 min, s16 center, s16 max, int flip) +{ + s16 d; + int ret; + + x -= center; + + if (x < 0) + d = center - min; + else + d = max - center; + + if (center - min < 5) + return 0; + if (max - center < 5) + return 0; + + if (d) + ret = (x << 15) / d; + else + return 0; + + if (flip) + ret = -ret; + + if (ret < AXIS_MIN) + ret = AXIS_MIN; + else if (ret > AXIS_MAX) + ret = AXIS_MAX; + + return ret; +} + +static const u32 _buttons[8] = { + // wiimote + WPAD_BUTTON_UP, + WPAD_BUTTON_DOWN, + WPAD_BUTTON_LEFT, + WPAD_BUTTON_RIGHT, + // classic + WPAD_CLASSIC_BUTTON_UP, + WPAD_CLASSIC_BUTTON_DOWN, + WPAD_CLASSIC_BUTTON_LEFT, + WPAD_CLASSIC_BUTTON_RIGHT +}; + +static void HandleWiiHats(SDL_Joystick *joystick, + const u32 changed, const u32 pressed, + const u32 *buttons) +{ + if (changed & (buttons[0] | buttons[1] | buttons[2] | buttons[3])) { + int hat = SDL_HAT_CENTERED; + + if (pressed & buttons[0]) + hat |= s_wiimote_sideways ? SDL_HAT_LEFT : SDL_HAT_UP; + if (pressed & buttons[1]) + hat |= s_wiimote_sideways ? SDL_HAT_RIGHT : SDL_HAT_DOWN; + if (pressed & buttons[2]) + hat |= s_wiimote_sideways ? SDL_HAT_DOWN : SDL_HAT_LEFT; + if (pressed & buttons[3]) + hat |= s_wiimote_sideways ? SDL_HAT_UP : SDL_HAT_RIGHT; + SDL_PrivateJoystickHat(joystick, 0, hat); + } +} + +/* Helpers to separate nunchuk vs classic buttons which share the + * same scan codes. In particular, up on the classic controller is + * the same as Z on the nunchuk. The numbers refer to the sdl_buttons_wii + * list above. */ +static int wii_button_is_nunchuk(int idx) +{ + return idx == 7 || idx == 8; +} + +static int wii_button_is_classic(int idx) +{ + return idx >= 9; +} + +static void HandleWiiButtons(SDL_Joystick *joystick, + const u32 changed, + const WPADData *data, + const u32 *buttons, + size_t num_buttons) +{ + for (int i = 0; i < num_buttons; i++) { + if (changed & buttons[i]) { + if (!split_joysticks && + ((data->exp.type == WPAD_EXP_CLASSIC && wii_button_is_nunchuk(i)) || + (data->exp.type == WPAD_EXP_NUNCHUK && wii_button_is_classic(i)))) + continue; + + SDL_PrivateJoystickButton(joystick, i, + (data->btns_d & buttons[i]) ? SDL_PRESSED : SDL_RELEASED); + } + } +} + +static void HandleWiiMotion(SDL_Joystick *joystick, + joystick_hwdata *prev_state, + WPADData *data, + int start_index) +{ + int axis = WPAD_Pitch(data); + if (prev_state->wiimote.wiimote_pitch != axis) { + SDL_PrivateJoystickAxis(joystick, start_index, -(axis << 8)); + prev_state->wiimote.wiimote_pitch = axis; + } + axis = WPAD_Roll(data); + if (prev_state->wiimote.wiimote_roll != axis) { + SDL_PrivateJoystickAxis(joystick, start_index + 1, axis << 8); + prev_state->wiimote.wiimote_roll = axis; + } + axis = WPAD_Yaw(data); + if (prev_state->wiimote.wiimote_yaw != axis) { + SDL_PrivateJoystickAxis(joystick, start_index + 2, axis << 8); + prev_state->wiimote.wiimote_yaw = axis; + } +} + +static void HandleNunchuckSensors(SDL_Joystick *joystick, + const nunchuk_t *data) +{ + float values[3]; + SDL_SensorType type; + + if (joystick->hwdata->sensors_disabled) return; + + type = split_joysticks ? SDL_SENSOR_ACCEL : SDL_SENSOR_ACCEL_L; + values[0] = data->gforce.x * SDL_STANDARD_GRAVITY; + values[1] = data->gforce.z * SDL_STANDARD_GRAVITY; + values[2] = -data->gforce.y * SDL_STANDARD_GRAVITY; + SDL_PrivateJoystickSensor(joystick, type, 0, values, 3); +} + +static void HandleWiimoteSensors(SDL_Joystick *joystick, + WPADData *data) +{ + float values[3]; + + if (joystick->hwdata->sensors_disabled) return; + + values[0] = data->gforce.x * SDL_STANDARD_GRAVITY; + values[1] = data->gforce.z * SDL_STANDARD_GRAVITY; + values[2] = -data->gforce.y * SDL_STANDARD_GRAVITY; + SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_ACCEL, 0, values, 3); +} + +static void _HandleWiiJoystickUpdate(SDL_Joystick *joystick) +{ + u32 changed, pressed; + int axis, wpad_index; + joystick_hwdata *prev_state; + WPADData *data; + bool update_wiimote, update_expansion; + + prev_state = joystick->hwdata; + if (split_joysticks) { + if (joystick->hwdata->index >= WII_EXP_START) { + wpad_index = joystick->hwdata->index - WII_EXP_START; + update_wiimote = false; + update_expansion = true; + } else { + wpad_index = joystick->hwdata->index - WII_WIIMOTES_START; + update_wiimote = true; + update_expansion = false; + } + } else { + wpad_index = joystick->hwdata->index - WII_WIIMOTES_START; + update_wiimote = true; + update_expansion = true; + } + + if (update_wiimote) { + update_rumble(joystick); + } + + if (!s_wii_has_new_data[wpad_index]) + return; + + data = WPAD_Data(wpad_index); + changed = data->btns_d | data->btns_u; + pressed = data->btns_d | data->btns_h; + + if (update_wiimote) { + HandleWiiHats(joystick, changed, pressed, _buttons); + } + if (update_expansion) { + if (data->exp.type == WPAD_EXP_CLASSIC) { + HandleWiiHats(joystick, changed, pressed, _buttons + 4); + } + } + + if (split_joysticks) { + if (update_wiimote) { + HandleWiiButtons(joystick, changed, data, + sdl_buttons_wiimote, SDL_WII_NUM_BUTTONS_WIIMOTE); + } + if (update_expansion) { + if (data->exp.type == WPAD_EXP_CLASSIC) { + HandleWiiButtons(joystick, changed, data, + sdl_buttons_classic, SDL_WII_NUM_BUTTONS_CLASSIC); + } else if (data->exp.type == WPAD_EXP_NUNCHUK) { + HandleWiiButtons(joystick, changed, data, + sdl_buttons_nunchuck, SDL_WII_NUM_BUTTONS_NUNCHUCK); + } + } + } else { + HandleWiiButtons(joystick, changed, data, + sdl_buttons_wii, SDL_WII_NUM_BUTTONS_WII); + } + + if (update_expansion) { + if (data->exp.type == WPAD_EXP_CLASSIC) { + if (prev_state->wiimote.exp != WPAD_EXP_CLASSIC) { + prev_state->wiimote.classic_calibrated = 0; + prev_state->wiimote.classic_cal[0][0] = 5; // left x min + prev_state->wiimote.classic_cal[0][2] = 59; // left x max + prev_state->wiimote.classic_cal[1][0] = 5; // left y min + prev_state->wiimote.classic_cal[1][2] = 59; // left y max + prev_state->wiimote.classic_cal[2][0] = 5; // right x min + prev_state->wiimote.classic_cal[2][2] = 27; // right x max + prev_state->wiimote.classic_cal[3][0] = 5; // right y min + prev_state->wiimote.classic_cal[3][2] = 27; // right y max + } + + // max/min checking + // left stick x + if (data->exp.classic.ljs.pos.x < prev_state->wiimote.classic_cal[0][0]) + prev_state->wiimote.classic_cal[0][0] = data->exp.classic.ljs.pos.x; + else if (data->exp.classic.ljs.pos.x > prev_state->wiimote.classic_cal[0][2]) + prev_state->wiimote.classic_cal[0][2] = data->exp.classic.ljs.pos.x; + // left stick y + if (data->exp.classic.ljs.pos.y < prev_state->wiimote.classic_cal[1][0]) + prev_state->wiimote.classic_cal[1][0] = data->exp.classic.ljs.pos.y; + else if (data->exp.classic.ljs.pos.y > prev_state->wiimote.classic_cal[1][2]) + prev_state->wiimote.classic_cal[1][2] = data->exp.classic.ljs.pos.y; + // right stick x + if (data->exp.classic.rjs.pos.x < prev_state->wiimote.classic_cal[2][0]) + prev_state->wiimote.classic_cal[2][0] = data->exp.classic.rjs.pos.x; + else if (data->exp.classic.rjs.pos.x > prev_state->wiimote.classic_cal[2][2]) + prev_state->wiimote.classic_cal[2][2] = data->exp.classic.rjs.pos.x; + // right stick y + if (data->exp.classic.rjs.pos.y < prev_state->wiimote.classic_cal[3][0]) + prev_state->wiimote.classic_cal[3][0] = data->exp.classic.rjs.pos.y; + else if (data->exp.classic.rjs.pos.y > prev_state->wiimote.classic_cal[3][2]) + prev_state->wiimote.classic_cal[3][2] = data->exp.classic.rjs.pos.y; + + // calibrate center positions + if (prev_state->wiimote.classic_calibrated < 5) { + prev_state->wiimote.classic_cal[0][1] = data->exp.classic.ljs.pos.x; + prev_state->wiimote.classic_cal[1][1] = data->exp.classic.ljs.pos.y; + prev_state->wiimote.classic_cal[2][1] = data->exp.classic.rjs.pos.x; + prev_state->wiimote.classic_cal[3][1] = data->exp.classic.rjs.pos.y; + // this is zero if the expansion hasn't finished initializing + if (data->exp.classic.ljs.max.x) + prev_state->wiimote.classic_calibrated++; + } + } + + if (data->exp.type != prev_state->wiimote.exp) { + // Reset the expansion axes + for (int i = 0; i < 6; i++) + SDL_PrivateJoystickAxis(joystick, i, 0); + } + + if (data->exp.type == WPAD_EXP_CLASSIC) { + axis = WPAD_Stick(data->exp.classic.ljs.pos.x, prev_state->wiimote.classic_cal[0][0], + prev_state->wiimote.classic_cal[0][1], prev_state->wiimote.classic_cal[0][2], 0); + if (prev_state->wiimote.classicL_stickX != axis) { + SDL_PrivateJoystickAxis(joystick, 0, axis); + prev_state->wiimote.classicL_stickX = axis; + } + // y axes are reversed + axis = WPAD_Stick(data->exp.classic.ljs.pos.y, prev_state->wiimote.classic_cal[1][0], + prev_state->wiimote.classic_cal[1][1], prev_state->wiimote.classic_cal[1][2], 1); + if (prev_state->wiimote.classicL_stickY != axis) { + SDL_PrivateJoystickAxis(joystick, 1, axis); + prev_state->wiimote.classicL_stickY = axis; + } + axis = WPAD_Stick(data->exp.classic.rjs.pos.x, prev_state->wiimote.classic_cal[2][0], + prev_state->wiimote.classic_cal[2][1], prev_state->wiimote.classic_cal[2][2], 0); + if (prev_state->wiimote.classicR_stickX != axis) { + SDL_PrivateJoystickAxis(joystick, 2, axis); + prev_state->wiimote.classicR_stickX = axis; + } + axis = WPAD_Stick(data->exp.classic.rjs.pos.y, prev_state->wiimote.classic_cal[3][0], + prev_state->wiimote.classic_cal[3][1], prev_state->wiimote.classic_cal[3][2], 1); + if (prev_state->wiimote.classicR_stickY != axis) { + SDL_PrivateJoystickAxis(joystick, 3, axis); + prev_state->wiimote.classicR_stickY = axis; + } + axis = data->exp.classic.r_shoulder; + if (prev_state->wiimote.classic_triggerR != axis) { + SDL_PrivateJoystickAxis(joystick, 4, axis << 8); + prev_state->wiimote.classic_triggerR = axis; + } + axis = data->exp.classic.l_shoulder; + if (prev_state->wiimote.classic_triggerL != axis) { + SDL_PrivateJoystickAxis(joystick, 5, axis << 8); + prev_state->wiimote.classic_triggerL = axis; + } + } else if (data->exp.type == WPAD_EXP_NUNCHUK) { + axis = WPAD_Stick(data->exp.nunchuk.js.pos.x, data->exp.nunchuk.js.min.x, + data->exp.nunchuk.js.center.x, data->exp.nunchuk.js.max.x, 0); + if (prev_state->wiimote.nunchuk_stickX != axis) { + SDL_PrivateJoystickAxis(joystick, 0, axis); + prev_state->wiimote.nunchuk_stickX = axis; + } + axis = WPAD_Stick(data->exp.nunchuk.js.pos.y, data->exp.nunchuk.js.min.y, + data->exp.nunchuk.js.center.y, data->exp.nunchuk.js.max.y, 1); + if (prev_state->wiimote.nunchuk_stickY != axis) { + SDL_PrivateJoystickAxis(joystick, 1, axis); + prev_state->wiimote.nunchuk_stickY = axis; + } + + HandleNunchuckSensors(joystick, &data->exp.nunchuk); + } + } + + prev_state->wiimote.exp = data->exp.type; + + if (update_wiimote) { + if (s_accelerometers_as_axes) { + int start_index = split_joysticks ? 0 : 6; + HandleWiiMotion(joystick, prev_state, data, start_index); + } + HandleWiimoteSensors(joystick, data); + } +} +#endif /* __wii__ */ + +static void _HandleGCJoystickUpdate(SDL_Joystick *joystick) +{ + u16 buttons, prev_buttons, changed; + int i; + int axis; + joystick_hwdata *prev_state; + int index = joystick->hwdata->index - GC_JOYSTICKS_START; + + update_rumble(joystick); + + buttons = PAD_ButtonsHeld(index); + prev_state = joystick->hwdata; + prev_buttons = prev_state->gamecube.prev_buttons; + changed = buttons ^ prev_buttons; + + if (changed & (PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT | PAD_BUTTON_DOWN | PAD_BUTTON_UP)) { + int hat = SDL_HAT_CENTERED; + if (buttons & PAD_BUTTON_UP) + hat |= SDL_HAT_UP; + if (buttons & PAD_BUTTON_DOWN) + hat |= SDL_HAT_DOWN; + if (buttons & PAD_BUTTON_LEFT) + hat |= SDL_HAT_LEFT; + if (buttons & PAD_BUTTON_RIGHT) + hat |= SDL_HAT_RIGHT; + SDL_PrivateJoystickHat(joystick, 0, hat); + } + + for (i = 0; i < (sizeof(sdl_buttons_gc) / sizeof(sdl_buttons_gc[0])); i++) { + if (changed & sdl_buttons_gc[i]) + SDL_PrivateJoystickButton(joystick, i, + (buttons & sdl_buttons_gc[i]) ? SDL_PRESSED : SDL_RELEASED); + } + prev_state->gamecube.prev_buttons = buttons; + axis = PAD_StickX(index); + if (prev_state->gamecube.stickX != axis) { + SDL_PrivateJoystickAxis(joystick, 0, axis << 8); + prev_state->gamecube.stickX = axis; + } + + axis = PAD_StickY(index); + if (prev_state->gamecube.stickY != axis) { + SDL_PrivateJoystickAxis(joystick, 1, (-axis) << 8); + prev_state->gamecube.stickY = axis; + } + + axis = PAD_SubStickX(index); + if (prev_state->gamecube.substickX != axis) { + SDL_PrivateJoystickAxis(joystick, 2, axis << 8); + prev_state->gamecube.substickX = axis; + } + + axis = PAD_SubStickY(index); + if (prev_state->gamecube.substickY != axis) { + SDL_PrivateJoystickAxis(joystick, 3, (-axis) << 8); + prev_state->gamecube.substickY = axis; + } + + axis = PAD_TriggerL(index); + if (prev_state->gamecube.triggerL != axis) { + SDL_PrivateJoystickAxis(joystick, 4, axis << 7); + prev_state->gamecube.triggerL = axis; + } + + axis = PAD_TriggerR(index); + if (prev_state->gamecube.triggerR != axis) { + SDL_PrivateJoystickAxis(joystick, 5, axis << 7); + prev_state->gamecube.triggerR = axis; + } +} + +static void OGC_JoystickUpdate(SDL_Joystick *joystick) +{ + if (!joystick || !joystick->hwdata) + return; + + scan_hardware(); + + if (joystick->hwdata->index >= GC_JOYSTICKS_START && + joystick->hwdata->index < GC_JOYSTICKS_END) { + _HandleGCJoystickUpdate(joystick); +#ifdef __wii__ + } else { + _HandleWiiJoystickUpdate(joystick); +#endif + } +} + +static void OGC_JoystickClose(SDL_Joystick *joystick) +{ + if (!joystick || !joystick->hwdata) // joystick already closed + return; + + SDL_free(joystick->hwdata); + joystick->hwdata = NULL; +} + +void OGC_JoystickQuit(void) +{ +#ifdef __wii__ + SDL_DelHintCallback(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, + on_hint_accel_as_joystick_cb, NULL); +#endif +} + +static SDL_bool OGC_JoystickGetGamepadMapping(int device_index, + SDL_GamepadMapping *out) +{ + int index = device_index_to_joypad_index(device_index); + SDL_bool is_gamepad = SDL_FALSE; + + if (index >= GC_JOYSTICKS_START && index < GC_JOYSTICKS_END) { + *out = (SDL_GamepadMapping){ + .a = { EMappingKind_Button, 0 }, + .b = { EMappingKind_Button, 2 }, + .x = { EMappingKind_Button, 1 }, + .y = { EMappingKind_Button, 3 }, + .back = { EMappingKind_Button, 6 }, + .guide = { EMappingKind_None, 255 }, + .start = { EMappingKind_Button, 7 }, + .leftstick = { EMappingKind_None, 255 }, + .rightstick = { EMappingKind_None, 255 }, + .leftshoulder = { EMappingKind_Button, 4 }, + .rightshoulder = { EMappingKind_Button, 5 }, + .dpup = { EMappingKind_Hat, 0x01 }, + .dpdown = { EMappingKind_Hat, 0x04 }, + .dpleft = { EMappingKind_Hat, 0x08 }, + .dpright = { EMappingKind_Hat, 0x02 }, + .misc1 = { EMappingKind_None, 255 }, + .paddle1 = { EMappingKind_None, 255 }, + .paddle2 = { EMappingKind_None, 255 }, + .paddle3 = { EMappingKind_None, 255 }, + .paddle4 = { EMappingKind_None, 255 }, + .leftx = { EMappingKind_Axis, 0 }, + .lefty = { EMappingKind_Axis, 1 }, + .rightx = { EMappingKind_Axis, 2 }, + .righty = { EMappingKind_Axis, 3 }, + .lefttrigger = { EMappingKind_Axis, 4 }, + .righttrigger = { EMappingKind_Axis, 5 }, + }; + is_gamepad = SDL_TRUE; +#ifdef __wii__ + } else if (index >= WII_WIIMOTES_START && index < WII_WIIMOTES_END) { + int expansion = s_detected_devices[index] - 1; + if (split_joysticks || expansion == 0) { + /* Wiimote alone; assume it's being held sideways */ + *out = (SDL_GamepadMapping){ + .a = { EMappingKind_Button, 2 }, + .b = { EMappingKind_Button, 3 }, + .x = { EMappingKind_Button, 0 }, + .y = { EMappingKind_Button, 1 }, + .back = { EMappingKind_Button, 6 }, + .guide = { EMappingKind_Button, 4 }, + .start = { EMappingKind_Button, 5 }, + .leftstick = { EMappingKind_None, 255 }, + .rightstick = { EMappingKind_None, 255 }, + .leftshoulder = { EMappingKind_None, 255 }, + .rightshoulder = { EMappingKind_None, 255 }, + .dpup = { EMappingKind_Hat, 0x02 }, + .dpdown = { EMappingKind_Hat, 0x08 }, + .dpleft = { EMappingKind_Hat, 0x01 }, + .dpright = { EMappingKind_Hat, 0x04 }, + .misc1 = { EMappingKind_None, 255 }, + .paddle1 = { EMappingKind_None, 255 }, + .paddle2 = { EMappingKind_None, 255 }, + .paddle3 = { EMappingKind_None, 255 }, + .paddle4 = { EMappingKind_None, 255 }, + .leftx = { EMappingKind_Axis, 0 }, + .lefty = { EMappingKind_Axis, 1 }, + .rightx = { EMappingKind_None, 255 }, + .righty = { EMappingKind_None, 255 }, + .lefttrigger = { EMappingKind_None, 255 }, + .righttrigger = { EMappingKind_None, 255 }, + }; + is_gamepad = SDL_TRUE; + } else if (expansion == WPAD_EXP_NUNCHUK) { + /* Wiimote with nunchuck; assume nunchuck on left hand, wiimote + * pointed at screen */ + *out = (SDL_GamepadMapping){ + .a = { EMappingKind_Button, 0 }, + .b = { EMappingKind_Button, 1 }, + .x = { EMappingKind_Button, 7 }, + .y = { EMappingKind_Button, 8 }, + .back = { EMappingKind_Button, 6 }, + .guide = { EMappingKind_Button, 4 }, + .start = { EMappingKind_Button, 5 }, + .leftstick = { EMappingKind_None, 255 }, + .rightstick = { EMappingKind_None, 255 }, + .leftshoulder = { EMappingKind_None, 255 }, + .rightshoulder = { EMappingKind_None, 255 }, + .dpup = { EMappingKind_Hat, 0x01 }, + .dpdown = { EMappingKind_Hat, 0x04 }, + .dpleft = { EMappingKind_Hat, 0x08 }, + .dpright = { EMappingKind_Hat, 0x02 }, + .misc1 = { EMappingKind_None, 255 }, + .paddle1 = { EMappingKind_None, 255 }, + .paddle2 = { EMappingKind_None, 255 }, + .paddle3 = { EMappingKind_None, 255 }, + .paddle4 = { EMappingKind_None, 255 }, + .leftx = { EMappingKind_Axis, 0 }, + .lefty = { EMappingKind_Axis, 1 }, + .rightx = { EMappingKind_Axis, 2 }, + .righty = { EMappingKind_Axis, 3 }, + .lefttrigger = { EMappingKind_None, 255 }, + .righttrigger = { EMappingKind_None, 255 }, + }; + is_gamepad = SDL_TRUE; + } else if (expansion == WPAD_EXP_CLASSIC) { + *out = (SDL_GamepadMapping){ + .a = { EMappingKind_Button, 1 }, + .b = { EMappingKind_Button, 0 }, + .x = { EMappingKind_Button, 10 }, + .y = { EMappingKind_Button, 9 }, + .back = { EMappingKind_Button, 6 }, + .guide = { EMappingKind_Button, 4 }, + .start = { EMappingKind_Button, 5 }, + .leftstick = { EMappingKind_None, 255 }, + .rightstick = { EMappingKind_None, 255 }, + .leftshoulder = { EMappingKind_Button, 11 }, + .rightshoulder = { EMappingKind_Button, 12 }, + .dpup = { EMappingKind_Hat, 0x01 }, + .dpdown = { EMappingKind_Hat, 0x04 }, + .dpleft = { EMappingKind_Hat, 0x08 }, + .dpright = { EMappingKind_Hat, 0x02 }, + .misc1 = { EMappingKind_None, 255 }, + .paddle1 = { EMappingKind_None, 255 }, + .paddle2 = { EMappingKind_None, 255 }, + .paddle3 = { EMappingKind_None, 255 }, + .paddle4 = { EMappingKind_None, 255 }, + .leftx = { EMappingKind_Axis, 0 }, + .lefty = { EMappingKind_Axis, 1 }, + .rightx = { EMappingKind_Axis, 2 }, + .righty = { EMappingKind_Axis, 3 }, + .lefttrigger = { EMappingKind_Button, 13 }, + .righttrigger = { EMappingKind_Button, 14 }, + }; + is_gamepad = SDL_TRUE; + } + } else if (index >= WII_EXP_START && index < WII_EXP_END) { + /* Wiimote + Extension: only support the classic controller, any other + * device is useless as a gamepad. */ + int expansion = s_detected_devices[index] - 1; + if (expansion != WPAD_EXP_CLASSIC) + return SDL_FALSE; + *out = (SDL_GamepadMapping){ + .a = { EMappingKind_Button, 1 }, + .b = { EMappingKind_Button, 0 }, + .x = { EMappingKind_Button, 3 }, + .y = { EMappingKind_Button, 2 }, + .back = { EMappingKind_Button, 10 }, + .guide = { EMappingKind_Button, 8 }, + .start = { EMappingKind_Button, 9 }, + .leftstick = { EMappingKind_None, 255 }, + .rightstick = { EMappingKind_None, 255 }, + .leftshoulder = { EMappingKind_Button, 4 }, + .rightshoulder = { EMappingKind_Button, 5 }, + .dpup = { EMappingKind_Hat, 0x01 }, + .dpdown = { EMappingKind_Hat, 0x04 }, + .dpleft = { EMappingKind_Hat, 0x08 }, + .dpright = { EMappingKind_Hat, 0x02 }, + .misc1 = { EMappingKind_None, 255 }, + .paddle1 = { EMappingKind_None, 255 }, + .paddle2 = { EMappingKind_None, 255 }, + .paddle3 = { EMappingKind_None, 255 }, + .paddle4 = { EMappingKind_None, 255 }, + .leftx = { EMappingKind_Axis, 0 }, + .lefty = { EMappingKind_Axis, 1 }, + .rightx = { EMappingKind_Axis, 2 }, + .righty = { EMappingKind_Axis, 3 }, + .lefttrigger = { EMappingKind_Button, 6 }, + .righttrigger = { EMappingKind_Button, 7 }, + }; + is_gamepad = SDL_TRUE; +#endif /* __wii__ */ + } + return is_gamepad; +} + +SDL_JoystickDriver SDL_OGC_JoystickDriver = { + .Init = OGC_JoystickInit, + .GetCount = OGC_JoystickGetCount, + .Detect = OGC_JoystickDetect, + .GetDeviceName = OGC_JoystickGetDeviceName, + .GetDevicePath = OGC_JoystickGetDevicePath, + .GetDevicePlayerIndex = OGC_JoystickGetDevicePlayerIndex, + .SetDevicePlayerIndex = OGC_JoystickSetDevicePlayerIndex, + .GetDeviceGUID = OGC_JoystickGetDeviceGUID, + .GetDeviceInstanceID = OGC_JoystickGetDeviceInstanceID, + .Open = OGC_JoystickOpen, + .Rumble = OGC_JoystickRumble, + .RumbleTriggers = OGC_JoystickRumbleTriggers, + .GetCapabilities = OGC_JoystickGetCapabilities, + .SetLED = OGC_JoystickSetLED, + .SendEffect = OGC_JoystickSendEffect, + .SetSensorsEnabled = OGC_JoystickSetSensorsEnabled, + .Update = OGC_JoystickUpdate, + .Close = OGC_JoystickClose, + .Quit = OGC_JoystickQuit, + .GetGamepadMapping = OGC_JoystickGetGamepadMapping +}; + +#endif /* SDL_JOYSTICK_OGC */ + +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/main/gamecube/SDL_gamecube_main.c b/src/main/gamecube/SDL_gamecube_main.c new file mode 100644 index 0000000000..f0d42bed96 --- /dev/null +++ b/src/main/gamecube/SDL_gamecube_main.c @@ -0,0 +1,54 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" + +#ifdef __gamecube__ + +#include "SDL_main.h" + +#ifdef main +#undef main +#endif + +/* Standard includes */ +#include + +/* OGC includes */ +#include +#include + +/* Do initialisation which has to be done first for the console to work */ +/* Entry point */ +int main(int argc, char *argv[]) +{ + // SYS_SetPowerCallback(ShutdownCB); + // SYS_SetResetCallback(ResetCB); + fatInitDefault(); + /* Temporarily while developing SDL */ + SDL_LogSetAllPriority(SDL_LOG_PRIORITY_DEBUG); + /* Call the user's main function */ + return (SDL_main(argc, argv)); +} + +#endif /* __gamecube__ */ + +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/main/wii/SDL_wii_main.c b/src/main/wii/SDL_wii_main.c new file mode 100644 index 0000000000..ec6329d5f0 --- /dev/null +++ b/src/main/wii/SDL_wii_main.c @@ -0,0 +1,91 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" + +#ifdef __wii__ + +#include "SDL_main.h" + +#include "../../video/ogc/SDL_ogcevents_c.h" + +#ifdef main +#undef main +#endif + +/* Standard includes */ +#include + +/* OGC includes */ +#include +#include +#include +#include +#include + +static void ShutdownCB() +{ + OGC_PowerOffRequested = true; +} + +static void ResetCB(u32, void *) +{ + OGC_ResetRequested = true; +} + +int main(int argc, char *argv[]) +{ + u32 version; + s32 preferred; + + L2Enhance(); + version = IOS_GetVersion(); + preferred = IOS_GetPreferredVersion(); + + if (preferred > 0 && version != (u32)preferred) + IOS_ReloadIOS(preferred); + + // Wii Power/Reset buttons + WPAD_Init(); + WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB); + SYS_SetPowerCallback(ShutdownCB); + SYS_SetResetCallback(ResetCB); + // TODO OGC_InitVideoSystem(); + WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR); + WPAD_SetVRes(WPAD_CHAN_ALL, 640, 480); + + MOUSE_Init(); + KEYBOARD_Init(NULL); + fatInitDefault(); + + /* Call the user's main function. Make sure that argv contains at least one + * element. */ + if (!argv || argv[0] == NULL) { + static const char *dummy_argv[2] = { "app", NULL }; + argc = 1; + argv = (char**)dummy_argv; + } + return SDL_main(argc, argv); +} + +#endif /* __wii__ */ + +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index b650c6ac40..dc7a5b0b26 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -124,6 +124,9 @@ static const SDL_RenderDriver *render_drivers[] = { #if SDL_VIDEO_RENDER_VITA_GXM &VITA_GXM_RenderDriver, #endif +#ifdef SDL_VIDEO_RENDER_OGC + &OGC_RenderDriver, +#endif #if SDL_VIDEO_RENDER_SW &SW_RenderDriver #endif diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h index 36e9555bb1..d3db2b3879 100644 --- a/src/render/SDL_sysrender.h +++ b/src/render/SDL_sysrender.h @@ -307,6 +307,7 @@ extern SDL_RenderDriver PS2_RenderDriver; extern SDL_RenderDriver PSP_RenderDriver; extern SDL_RenderDriver SW_RenderDriver; extern SDL_RenderDriver VITA_GXM_RenderDriver; +extern SDL_RenderDriver OGC_RenderDriver; /* Blend mode functions */ extern SDL_BlendFactor SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode); diff --git a/src/render/ogc/SDL_render_ogc.c b/src/render/ogc/SDL_render_ogc.c new file mode 100644 index 0000000000..39996c8aec --- /dev/null +++ b/src/render/ogc/SDL_render_ogc.c @@ -0,0 +1,786 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_VIDEO_RENDER_OGC + +#include "../SDL_sysrender.h" +#include "SDL_hints.h" + +#include "../../video/ogc/SDL_ogcgxcommon.h" +#include "../../video/ogc/SDL_ogcpixels.h" +#include "../../video/ogc/SDL_ogcvideo.h" + +#include +#include +#include +#include + +#define MAX_EFB_WIDTH 640 +#define MAX_EFB_HEIGHT 528 + +typedef struct +{ + SDL_BlendMode current_blend_mode; + int ops_after_present; + bool vsync; + u8 efb_pixel_format; + SDL_Texture *render_target; + SDL_Texture *saved_efb_texture; +} OGC_RenderData; + +typedef struct +{ + void *texels; + void *pixels; + SDL_Rect pixels_rect; + u16 pitch; + u16 pixels_pitch; + u8 format; + u8 needed_stages; // Normally 1, set to 2 for palettized formats +} OGC_TextureData; + +static void OGC_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); + +static void OGC_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) +{ +} + +static void set_blend_mode_real(SDL_Renderer *renderer, SDL_BlendMode blend_mode) +{ + switch (blend_mode) { + case SDL_BLENDMODE_NONE: + GX_SetBlendMode(GX_BM_NONE, GX_BL_ONE, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + break; + case SDL_BLENDMODE_BLEND: + GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + break; + case SDL_BLENDMODE_ADD: + GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_ONE, GX_LO_CLEAR); + break; + case SDL_BLENDMODE_MOD: + GX_SetBlendMode(GX_BM_BLEND, GX_BL_DSTCLR, GX_BL_ZERO, GX_LO_CLEAR); + break; + case SDL_BLENDMODE_MUL: + GX_SetBlendMode(GX_BM_BLEND, GX_BL_DSTCLR, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + break; + default: + return; + } +} + +static inline void OGC_SetBlendMode(SDL_Renderer *renderer, SDL_BlendMode blend_mode) +{ + OGC_RenderData *data = renderer->driverdata; + + if (blend_mode == data->current_blend_mode) { + /* Nothing to do */ + return; + } + + set_blend_mode_real(renderer, blend_mode); + data->current_blend_mode = blend_mode; +} + +static void load_efb_from_texture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + OGC_TextureData *ogc_tex = texture->driverdata; + + OGC_load_texture(ogc_tex->texels, texture->w, texture->h, + ogc_tex->format, SDL_ScaleModeNearest); + OGC_SetBlendMode(renderer, SDL_BLENDMODE_NONE); + + /* The viewport is reset when OGC_SetRenderTarget() returns. */ + OGC_set_viewport(0, 0, texture->w, texture->h); + + GX_ClearVtxDesc(); + GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_S16, 0); + + GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_U8, 0); + GX_SetNumTexGens(1); + GX_SetNumChans(0); + + GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); + GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL); + GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE); + GX_SetNumTevStages(1); + + GX_Begin(GX_QUADS, GX_VTXFMT0, 4); + GX_Position2s16(0, 0); + GX_TexCoord2u8(0, 0); + GX_Position2s16(texture->w, 0); + GX_TexCoord2u8(1, 0); + GX_Position2s16(texture->w, texture->h); + GX_TexCoord2u8(1, 1); + GX_Position2s16(0, texture->h); + GX_TexCoord2u8(0, 1); + GX_End(); +} + +static void save_efb_to_texture(SDL_Texture *texture, bool must_clear) +{ + OGC_TextureData *ogc_tex = texture->driverdata; + u32 texture_size; + + texture_size = GX_GetTexBufferSize(texture->w, texture->h, ogc_tex->format, + GX_FALSE, 0); + DCInvalidateRange(ogc_tex->texels, texture_size); + + GX_SetTexCopySrc(0, 0, texture->w, texture->h); + GX_SetTexCopyDst(texture->w, texture->h, ogc_tex->format, GX_FALSE); + GX_CopyTex(ogc_tex->texels, must_clear ? GX_TRUE : GX_FALSE); + GX_PixModeSync(); +} + +static void update_texture(SDL_Texture *texture, const SDL_Rect *rect, + const void *pixels, int pitch) +{ + OGC_TextureData *ogc_tex = texture->driverdata; + u32 texture_size; + + OGC_pixels_to_texture((void*)pixels, texture->format, rect, + pitch, ogc_tex->texels, texture->w); + texture_size = GX_GetTexBufferSize(texture->w, texture->h, ogc_tex->format, + GX_FALSE, 0); + /* It would be more effective if we updated only the changed range here, + * but the complexity is probably not worth the effort. */ + DCStoreRange(ogc_tex->texels, texture_size); + GX_InvalidateTexAll(); +} + +static int OGC_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + u32 texture_size; + OGC_TextureData *ogc_tex; + + ogc_tex = SDL_calloc(1, sizeof(OGC_TextureData)); + if (!ogc_tex) { + return SDL_OutOfMemory(); + } + + ogc_tex->format = OGC_texture_format_from_SDL(texture->format); + ogc_tex->needed_stages = (ogc_tex->format == GX_TF_CI8) ? 2 : 1; + texture_size = GX_GetTexBufferSize(texture->w, texture->h, ogc_tex->format, + GX_FALSE, 0); + ogc_tex->texels = memalign(32, texture_size); + if (!ogc_tex->texels) { + SDL_free(ogc_tex); + return SDL_OutOfMemory(); + } + + texture->driverdata = ogc_tex; + return 0; +} + +static int OGC_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch) +{ + OGC_TextureData *ogc_tex = texture->driverdata; + + ogc_tex->pixels = SDL_malloc(rect->w * rect->h * SDL_BYTESPERPIXEL(texture->format)); + ogc_tex->pixels_pitch = rect->w * SDL_BYTESPERPIXEL(texture->format); + ogc_tex->pixels_rect = *rect; + *pixels = ogc_tex->pixels; + *pitch = ogc_tex->pixels_pitch; + return 0; +} + +static void OGC_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + OGC_TextureData *ogc_tex = texture->driverdata; + + update_texture(texture, &ogc_tex->pixels_rect, + ogc_tex->pixels, ogc_tex->pixels_pitch); + + if (ogc_tex->pixels) { + SDL_free(ogc_tex->pixels); + ogc_tex->pixels = NULL; + } +} + +static int OGC_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *pixels, int pitch) +{ + update_texture(texture, rect, pixels, pitch); + return 0; +} + +static void OGC_SetTextureScaleMode(SDL_Renderer *renderer, + SDL_Texture *texture, + SDL_ScaleMode scaleMode) +{ + /* Nothing to do here: the scale mode is applied to the texture when + * loading it in OGC_load_texture(). */ +} + +static SDL_Texture *create_efb_texture(OGC_RenderData *data, SDL_Window *window) +{ + /* Note: we do return a SDL_Texture, but not via SDL's API, since that does + * a bunch of other stuffs we don't care about. We create this texture for + * our internal use, so we initialize only those fields we care about. */ + SDL_Texture *texture; + OGC_TextureData *ogc_tex; + u32 texture_size; + + texture = SDL_calloc(1, sizeof(*texture)); + if (!texture) goto fail_texture_alloc; + + ogc_tex = SDL_calloc(1, sizeof(OGC_TextureData)); + if (!ogc_tex) goto fail_ogc_tex_alloc; + + ogc_tex->format = data->efb_pixel_format == GX_PF_RGBA6_Z24 ? + GX_TF_RGBA8 : GX_TF_RGB565; + texture->w = window->w; + texture->h = window->h; + texture_size = GX_GetTexBufferSize(texture->w, texture->h, ogc_tex->format, + GX_FALSE, 0); + ogc_tex->texels = memalign(32, texture_size); + if (!ogc_tex->texels) goto fail_texels_alloc; + + texture->driverdata = ogc_tex; + return texture; + +fail_texels_alloc: + SDL_free(ogc_tex->texels); +fail_ogc_tex_alloc: + SDL_free(texture); +fail_texture_alloc: + SDL_OutOfMemory(); + return NULL; +} + +static int OGC_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) +{ + OGC_RenderData *data = renderer->driverdata; + u8 desired_efb_pixel_format = GX_PF_RGB8_Z24; + + if (data->render_target) { + save_efb_to_texture(data->render_target, false); + } else if (data->ops_after_present > 0) { + /* Save the current EFB contents if we already drew something onto + * it. We'll restore it later, when the rendering target is reset + * to NULL (the screen). */ + if (!data->saved_efb_texture) + data->saved_efb_texture = create_efb_texture(data, renderer->window); + save_efb_to_texture(data->saved_efb_texture, false); + } + + if (texture) { + if (texture->w > MAX_EFB_WIDTH || texture->h > MAX_EFB_HEIGHT) { + return SDL_SetError("Render target (%dx%d) bigger than EFB", texture->w, texture->h); + } + + if (SDL_ISPIXELFORMAT_ALPHA(texture->format)) { + desired_efb_pixel_format = GX_PF_RGBA6_Z24; + } + } + + data->render_target = texture; + + if (desired_efb_pixel_format != data->efb_pixel_format) { + data->efb_pixel_format = desired_efb_pixel_format; + GX_SetPixelFmt(data->efb_pixel_format, GX_ZC_LINEAR); + } + + if (texture) { + load_efb_from_texture(renderer, texture); + } else if (data->saved_efb_texture) { + /* Restore the EFB to how it was before the we started to render to a + * texture. */ + load_efb_from_texture(renderer, data->saved_efb_texture); + /* We don't free data->saved_efb_texture, it will be reused */ + } + + return 0; +} + +static int OGC_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +{ + return 0; /* nothing to do in this backend. */ +} + +static int OGC_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, + const SDL_FPoint *points, int count) +{ + size_t size = count * sizeof(SDL_FPoint); + SDL_FPoint *vertices = SDL_AllocateRenderVertices(renderer, size, + 4, &cmd->data.draw.first); + if (!vertices) { + return -1; + } + + cmd->data.draw.count = count; + SDL_memcpy(vertices, points, size); + return 0; +} + +static int OGC_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, + const SDL_FRect *rects, int count) +{ + size_t size = count * sizeof(SDL_FPoint) * 4; + SDL_FPoint *vertices = SDL_AllocateRenderVertices(renderer, size, + 4, &cmd->data.draw.first); + if (!vertices) { + return -1; + } + + cmd->data.draw.count = count; + for (int i = 0; i < count; i++) { + vertices[i].x = rects[i].x; + vertices[i].y = rects[i].y; + vertices[i+1].x = rects[i].x + rects[i].w; + vertices[i+1].y = rects[i].y; + vertices[i+2].x = rects[i].x + rects[i].w; + vertices[i+2].y = rects[i].y + rects[i].h; + vertices[i+3].x = rects[i].x; + vertices[i+3].y = rects[i].y + rects[i].h; + } + return 0; +} + +static int OGC_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, + const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) +{ + int i; + int count = indices ? num_indices : num_vertices; + size_t size_per_element; + char *vertices; + + cmd->data.draw.count = count; + size_indices = indices ? size_indices : 0; + + size_per_element = sizeof(SDL_FPoint) + sizeof(SDL_Color); + if (texture) { + size_per_element += sizeof(SDL_FPoint); + } + + vertices = SDL_AllocateRenderVertices(renderer, count * size_per_element, + 4, &cmd->data.draw.first); + if (!vertices) { + return -1; + } + + for (i = 0; i < count; i++) { + int j; + float *xy_; + float *uv_; + SDL_Color col; + char *vertex; + SDL_FPoint *vertex_xy; + if (size_indices == 4) { + j = ((const Uint32 *)indices)[i]; + } else if (size_indices == 2) { + j = ((const Uint16 *)indices)[i]; + } else if (size_indices == 1) { + j = ((const Uint8 *)indices)[i]; + } else { + j = i; + } + + xy_ = (float *)((char *)xy + j * xy_stride); + col = *(SDL_Color *)((char *)color + j * color_stride); + uv_ = (float *)((char *)uv + j * uv_stride); + + vertex = vertices + size_per_element * i; + + vertex_xy = (SDL_FPoint *)vertex; + vertex_xy->x = xy_[0] * scale_x; + vertex_xy->y = xy_[1] * scale_x; + + *(SDL_Color *)(vertex + sizeof(SDL_FPoint)) = col; + + if (texture) { + SDL_FPoint *vertex_uv = (SDL_FPoint *)(vertex + sizeof(SDL_FPoint) + sizeof(SDL_Color)); + vertex_uv->x = uv_[0]; + vertex_uv->y = uv_[1]; + } + } + + return 0; +} + +static int OGC_RenderSetViewPort(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +{ + const SDL_Rect *viewport = &cmd->data.viewport.rect; + + OGC_set_viewport(viewport->x, viewport->y, viewport->w, viewport->h); + return 0; +} + +static int OGC_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +{ + const SDL_Rect *rect = &cmd->data.cliprect.rect; + + if (cmd->data.cliprect.enabled) { + GX_SetScissor(renderer->viewport.x + rect->x, + renderer->viewport.y + rect->y, + rect->w, rect->h); + } else { + GX_SetScissor(renderer->viewport.x, + renderer->viewport.y, + renderer->viewport.w, + renderer->viewport.h); + } + + return 0; +} + +static int OGC_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +{ + OGC_RenderData *data = renderer->driverdata; + + GXColor c = { + cmd->data.color.r, + cmd->data.color.g, + cmd->data.color.b, + cmd->data.color.a + }; + int16_t x1 = 0; + int16_t y1 = 0; + int16_t x2 = renderer->window->w; + int16_t y2 = renderer->window->h; + OGC_set_viewport(0, 0, renderer->window->w, renderer->window->h); + OGC_SetBlendMode(renderer, SDL_BLENDMODE_NONE); + + GX_ClearVtxDesc(); + GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_S16, 0); + GX_SetTevColor(GX_TEVREG0, c); + GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_C0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO); + GX_SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO); + GX_SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GX_SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GX_SetNumTevStages(1); + GX_SetNumChans(0); + + GX_Begin(GX_QUADS, GX_VTXFMT0, 4); + GX_Position2s16(x1, y1); + GX_Position2s16(x2, y1); + GX_Position2s16(x2, y2); + GX_Position2s16(x1, y2); + GX_End(); + data->ops_after_present++; + + /* Restore the viewport */ + OGC_set_viewport(renderer->viewport.x, renderer->viewport.y, + renderer->viewport.w, renderer->viewport.h); + return 0; +} + +static int OGC_RenderGeometry(SDL_Renderer *renderer, void *vertices, + SDL_RenderCommand *cmd) +{ + OGC_RenderData *data = renderer->driverdata; + const size_t count = cmd->data.draw.count; + SDL_Texture *texture = cmd->data.draw.texture; + size_t size_per_element; + + data->ops_after_present++; + OGC_SetBlendMode(renderer, cmd->data.draw.blend); + + size_per_element = sizeof(SDL_FPoint) + sizeof(SDL_Color); + + GX_ClearVtxDesc(); + GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); + GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_F32, 0); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); + if (texture) { + OGC_TextureData *ogc_tex = texture->driverdata; + u8 stage; + + size_per_element += sizeof(SDL_FPoint); + OGC_load_texture(ogc_tex->texels, texture->w, texture->h, + ogc_tex->format, texture->scaleMode); + stage = GX_TEVSTAGE0 + ogc_tex->needed_stages - 1; + + GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); + GX_SetNumTexGens(1); + + GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); + GX_SetTevOrder(stage, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); + GX_SetTevOp(stage, GX_MODULATE); + GX_SetNumTevStages(stage - GX_TEVSTAGE0 + 1); + } else { + GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); + GX_SetNumTevStages(1); + } + GX_SetNumChans(1); + + GX_Begin(GX_TRIANGLES, GX_VTXFMT0, count); + for (int i = 0; i < count; i++) { + void *vertex = vertices + cmd->data.draw.first + size_per_element * i; + SDL_FPoint *vertex_xy = vertex; + SDL_Color *c = (SDL_Color*)(vertex + sizeof(SDL_FPoint)); + + GX_Position2f32(vertex_xy->x, vertex_xy->y); + GX_Color4u8(c->r, c->g, c->b, c->a); + if (texture) { + SDL_FPoint *vertex_uv = (SDL_FPoint *)(vertex + sizeof(SDL_FPoint) + sizeof(SDL_Color)); + GX_TexCoord2f32(vertex_uv->x, vertex_uv->y); + } + } + GX_End(); + return 0; +} + +int OGC_RenderPrimitive(SDL_Renderer *renderer, u8 primitive, + void *vertices, SDL_RenderCommand *cmd) +{ + OGC_RenderData *data = renderer->driverdata; + size_t count = cmd->data.draw.count; + const SDL_FPoint *verts = (SDL_FPoint *)(vertices + cmd->data.draw.first); + Mtx mv; + bool did_change_matrix = false; + GXColor c = { + cmd->data.draw.r, + cmd->data.draw.g, + cmd->data.draw.b, + cmd->data.draw.a + }; + + data->ops_after_present++; + OGC_SetBlendMode(renderer, cmd->data.draw.blend); + + if (primitive == GX_LINESTRIP || primitive == GX_POINTS) { + float adjustment = 0.5; + guMtxIdentity(mv); + guMtxTransApply(mv, mv, adjustment, adjustment, 0); + GX_LoadPosMtxImm(mv, GX_PNMTX0); + did_change_matrix = true; + } + + /* TODO: optimize state changes. */ + GX_SetTevColor(GX_TEVREG0, c); + GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_C0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO); + GX_SetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO); + GX_SetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GX_SetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + + GX_ClearVtxDesc(); + GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_F32, 0); + + if (primitive == GX_QUADS) count *= 4; + + GX_Begin(primitive, GX_VTXFMT0, count); + for (int i = 0; i < count; i++) { + GX_Position2f32(verts[i].x, verts[i].y); + } + GX_End(); + + /* The last point is not drawn */ + if (primitive == GX_LINESTRIP) { + GX_Begin(GX_POINTS, GX_VTXFMT0, count); + for (int i = 0; i < count; i++) { + GX_Position2f32(verts[i].x, verts[i].y); + } + GX_End(); + } + + if (did_change_matrix) { + guMtxIdentity(mv); + GX_LoadPosMtxImm(mv, GX_PNMTX0); + } + + return 0; +} + +static int OGC_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +{ + while (cmd) { + switch (cmd->command) { + case SDL_RENDERCMD_SETVIEWPORT: + OGC_RenderSetViewPort(renderer, cmd); + break; + case SDL_RENDERCMD_SETCLIPRECT: + OGC_RenderSetClipRect(renderer, cmd); + break; + case SDL_RENDERCMD_SETDRAWCOLOR: + /* This is a no-op, since every command carries the color, and + * setting it on the FIFO is not expensive. */ + break; + case SDL_RENDERCMD_CLEAR: + OGC_RenderClear(renderer, cmd); + break; + case SDL_RENDERCMD_DRAW_POINTS: + OGC_RenderPrimitive(renderer, GX_POINTS, vertices, cmd); + break; + case SDL_RENDERCMD_DRAW_LINES: + OGC_RenderPrimitive(renderer, GX_LINESTRIP, vertices, cmd); + break; + case SDL_RENDERCMD_FILL_RECTS: + OGC_RenderPrimitive(renderer, GX_QUADS, vertices, cmd); + break; + case SDL_RENDERCMD_COPY: /* unused */ + break; + case SDL_RENDERCMD_COPY_EX: /* unused */ + break; + case SDL_RENDERCMD_GEOMETRY: + OGC_RenderGeometry(renderer, vertices, cmd); + break; + case SDL_RENDERCMD_NO_OP: + break; + } + cmd = cmd->next; + } + + GX_DrawDone(); + return 0; +} + +static int OGC_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 format, void *pixels, int pitch) +{ + return SDL_Unsupported(); +} + +static int OGC_RenderPresent(SDL_Renderer *renderer) +{ + OGC_RenderData *data = renderer->driverdata; + + GX_DrawDone(); + + OGC_video_flip(SDL_GetVideoDevice(), data->vsync); + + /* Mouse cursor and OSK can change the blending mode; restore it. */ + set_blend_mode_real(renderer, data->current_blend_mode); + + data->ops_after_present = 0; + return 0; +} + +static void OGC_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + OGC_TextureData *ogc_tex = texture->driverdata; + + if (ogc_tex) { + free(ogc_tex->texels); + SDL_free(ogc_tex); + texture->driverdata = NULL; + } +} + +static void OGC_DestroyRenderer(SDL_Renderer *renderer) +{ + OGC_RenderData *data = renderer->driverdata; + + if (data) { + GX_DrawDone(); + if (data->saved_efb_texture) { + OGC_DestroyTexture(renderer, data->saved_efb_texture); + SDL_free(data->saved_efb_texture); + } + + SDL_free(data); + } + + SDL_free(renderer); +} + +static int OGC_SetVSync(SDL_Renderer *renderer, const int vsync) +{ + OGC_RenderData *data = (OGC_RenderData *)renderer->driverdata; + data->vsync = vsync ? 1 : 0; + return 0; +} + +static SDL_Renderer *OGC_CreateRenderer(SDL_Window *window, Uint32 flags) +{ + SDL_Renderer *renderer; + OGC_RenderData *data; + + renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + data = (OGC_RenderData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + OGC_DestroyRenderer(renderer); + SDL_OutOfMemory(); + return NULL; + } + + data->efb_pixel_format = GX_PF_RGB8_Z24; + data->current_blend_mode = SDL_BLENDMODE_INVALID; + data->vsync = true; + + renderer->WindowEvent = OGC_WindowEvent; + renderer->CreateTexture = OGC_CreateTexture; + renderer->UpdateTexture = OGC_UpdateTexture; + renderer->LockTexture = OGC_LockTexture; + renderer->UnlockTexture = OGC_UnlockTexture; + renderer->SetTextureScaleMode = OGC_SetTextureScaleMode; + renderer->SetRenderTarget = OGC_SetRenderTarget; + renderer->QueueSetViewport = OGC_QueueSetViewport; + renderer->QueueSetDrawColor = OGC_QueueSetViewport; + renderer->QueueDrawPoints = OGC_QueueDrawPoints; + renderer->QueueDrawLines = OGC_QueueDrawPoints; + renderer->QueueFillRects = OGC_QueueFillRects; + renderer->QueueGeometry = OGC_QueueGeometry; + renderer->RunCommandQueue = OGC_RunCommandQueue; + renderer->RenderReadPixels = OGC_RenderReadPixels; + renderer->RenderPresent = OGC_RenderPresent; + renderer->DestroyTexture = OGC_DestroyTexture; + renderer->DestroyRenderer = OGC_DestroyRenderer; + renderer->SetVSync = OGC_SetVSync; + renderer->info = OGC_RenderDriver.info; + renderer->driverdata = data; + renderer->window = window; + + if (!SDL_GetHint(SDL_HINT_RENDER_LINE_METHOD)) { + /* SDL sets the default one to point drawing, but we prefer lines */ + SDL_SetHint(SDL_HINT_RENDER_LINE_METHOD, "2"); + } + + return renderer; +} + +SDL_RenderDriver OGC_RenderDriver = { + .CreateRenderer = OGC_CreateRenderer, + .info = { + .name = "ogc", + .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE, + .num_texture_formats = 5, + .texture_formats = { + [0] = SDL_PIXELFORMAT_RGB565, + [1] = SDL_PIXELFORMAT_RGBA8888, + [2] = SDL_PIXELFORMAT_ARGB8888, + [3] = SDL_PIXELFORMAT_RGB24, + [4] = SDL_PIXELFORMAT_XRGB8888, + // TODO: add more + }, + .max_texture_width = 1024, + .max_texture_height = 1024, + } +}; + +#endif /* SDL_VIDEO_RENDER_OGC */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index 278a680268..f2791f1ffa 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -32,7 +32,9 @@ #include "pthread/SDL_systhread_c.h" #elif SDL_THREAD_WINDOWS #include "windows/SDL_systhread_c.h" -#elif SDL_THREAD_PS2 +#elif defined(SDL_THREAD_OGC) +#include "ogc/SDL_systhread_c.h" +#elif defined(SDL_THREAD_PS2) #include "ps2/SDL_systhread_c.h" #elif SDL_THREAD_PSP #include "psp/SDL_systhread_c.h" diff --git a/src/thread/ogc/SDL_syscond.c b/src/thread/ogc/SDL_syscond.c new file mode 100644 index 0000000000..352fd7bf66 --- /dev/null +++ b/src/thread/ogc/SDL_syscond.c @@ -0,0 +1,131 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* An implementation of condition variables using semaphores and mutexes */ +/* + This implementation borrows heavily from the BeOS condition variable + implementation, written by Christopher Tate and Owen Smith. Thanks! + */ + +#include "SDL_thread.h" +#include "SDL_sysmutex_c.h" + +#include +#include + +struct SDL_cond +{ + cond_t cond; +}; + +/* Create a condition variable */ +SDL_cond * SDL_CreateCond(void) +{ + SDL_cond *cond; + + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); + if (cond) { + if (LWP_CondInit(&(cond->cond)) < 0) { + SDL_DestroyCond(cond); + cond = NULL; + } + } else { + SDL_OutOfMemory(); + } + return (cond); +} + +/* Destroy a condition variable */ +void SDL_DestroyCond(SDL_cond *cond) +{ + if (cond) { + LWP_CondDestroy(cond->cond); + SDL_free(cond); + } +} + +/* Restart one of the threads that are waiting on the condition variable */ +int SDL_CondSignal(SDL_cond *cond) +{ + if (!cond) { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + + return LWP_CondSignal(cond->cond) == 0 ? 0 : -1; + +} + +/* Restart all threads that are waiting on the condition variable */ +int SDL_CondBroadcast(SDL_cond *cond) +{ + if (!cond) { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + + return LWP_CondBroadcast(cond->cond) == 0 ? 0 : -1; +} + +/* Wait on the condition variable for at most 'ms' milliseconds. + The mutex must be locked before entering this function! + The mutex is unlocked during the wait, and locked again after the wait. + + Typical use: + + Thread A: + SDL_LockMutex(lock); + while ( ! condition ) { + SDL_CondWait(cond); + } + SDL_UnlockMutex(lock); + + Thread B: + SDL_LockMutex(lock); + ... + condition = true; + ... + SDL_UnlockMutex(lock); + */ + + +int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) +{ + struct timespec time; + + if (!cond) { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + //LWP_CondTimedWait expects relative timeout + time.tv_sec = (ms / 1000); + time.tv_nsec = (ms % 1000) * 1000000; + + return LWP_CondTimedWait(cond->cond, mutex->id, &time); +} + +/* Wait on the condition variable forever */ +int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) +{ + return LWP_CondWait(cond->cond, mutex->id); +} diff --git a/src/thread/ogc/SDL_sysmutex.c b/src/thread/ogc/SDL_sysmutex.c new file mode 100644 index 0000000000..be3ba470ae --- /dev/null +++ b/src/thread/ogc/SDL_sysmutex.c @@ -0,0 +1,81 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* An implementation of mutexes using semaphores */ + +#include "SDL_thread.h" +#include "SDL_systhread_c.h" + +#include + +struct SDL_mutex +{ + u32 id; +}; + +/* Create a mutex */ +SDL_mutex *SDL_CreateMutex(void) +{ + SDL_mutex *mutex = NULL; + + /* Allocate mutex memory */ + mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); + if (mutex) { + LWP_MutexInit(&mutex->id, 1); + } else { + SDL_OutOfMemory(); + } + return mutex; +} + +/* Free the mutex */ +void SDL_DestroyMutex(SDL_mutex *mutex) +{ + if (mutex) { + LWP_MutexDestroy(mutex->id); + SDL_free(mutex); + } +} + +/* Lock the semaphore */ +int SDL_mutexP(SDL_mutex *mutex) +{ + if (mutex == NULL) { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + return LWP_MutexLock(mutex->id); +} + +/* Unlock the mutex */ +int SDL_mutexV(SDL_mutex *mutex) +{ + if (mutex == NULL) { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + return LWP_MutexUnlock(mutex->id); + +} diff --git a/src/thread/ogc/SDL_sysmutex_c.h b/src/thread/ogc/SDL_sysmutex_c.h new file mode 100644 index 0000000000..fe692acc05 --- /dev/null +++ b/src/thread/ogc/SDL_sysmutex_c.h @@ -0,0 +1,26 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +struct SDL_mutex { + Uint32 id; +}; diff --git a/src/thread/ogc/SDL_syssem.c b/src/thread/ogc/SDL_syssem.c new file mode 100644 index 0000000000..825de911fb --- /dev/null +++ b/src/thread/ogc/SDL_syssem.c @@ -0,0 +1,162 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* An implementation of semaphores using mutexes and condition variables */ + +#include "SDL_timer.h" +#include "SDL_thread.h" +#include "SDL_systhread_c.h" + +struct SDL_semaphore +{ + Uint32 count; + Uint32 waiters_count; + SDL_mutex *count_lock; + SDL_cond *count_nonzero; +}; + +SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) +{ + SDL_sem *sem; + + sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); + if (!sem) { + SDL_OutOfMemory(); + return NULL; + } + sem->count = initial_value; + sem->waiters_count = 0; + + sem->count_lock = SDL_CreateMutex(); + sem->count_nonzero = SDL_CreateCond(); + if (!sem->count_lock || !sem->count_nonzero) { + SDL_DestroySemaphore(sem); + return NULL; + } + + return sem; +} + +/* WARNING: + You cannot call this function when another thread is using the semaphore. + */ +void SDL_DestroySemaphore(SDL_sem *sem) +{ + if (sem) { + sem->count = 0xFFFFFFFF; + while (sem->waiters_count > 0) { + SDL_CondSignal(sem->count_nonzero); + SDL_Delay(10); + } + SDL_DestroyCond(sem->count_nonzero); + if (sem->count_lock) { + SDL_mutexP(sem->count_lock); + SDL_mutexV(sem->count_lock); + SDL_DestroyMutex(sem->count_lock); + } + SDL_free(sem); + } +} + +int SDL_SemTryWait(SDL_sem *sem) +{ + int retval; + + if (!sem) { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + retval = SDL_MUTEX_TIMEDOUT; + SDL_LockMutex(sem->count_lock); + if (sem->count > 0) { + --sem->count; + retval = 0; + } + SDL_UnlockMutex(sem->count_lock); + + return retval; +} + +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) +{ + int retval; + + if (!sem) { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + /* A timeout of 0 is an easy case */ + if (timeout == 0) { + return SDL_SemTryWait(sem); + } + + SDL_LockMutex(sem->count_lock); + ++sem->waiters_count; + retval = 0; + while ((sem->count == 0) && (retval != SDL_MUTEX_TIMEDOUT)) { + retval = SDL_CondWaitTimeout(sem->count_nonzero, sem->count_lock, + timeout); + } + --sem->waiters_count; + --sem->count; + SDL_UnlockMutex(sem->count_lock); + + return retval; +} + +int SDL_SemWait(SDL_sem *sem) +{ + return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); +} + +Uint32 SDL_SemValue(SDL_sem *sem) +{ + Uint32 value; + + value = 0; + if (sem) { + SDL_LockMutex(sem->count_lock); + value = sem->count; + SDL_UnlockMutex(sem->count_lock); + } + return value; +} + +int SDL_SemPost(SDL_sem *sem) +{ + if (!sem) { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + SDL_LockMutex(sem->count_lock); + if (sem->waiters_count > 0) { + SDL_CondSignal(sem->count_nonzero); + } + ++sem->count; + SDL_UnlockMutex(sem->count_lock); + + return 0; +} diff --git a/src/thread/ogc/SDL_systhread.c b/src/thread/ogc/SDL_systhread.c new file mode 100644 index 0000000000..558cce7e9f --- /dev/null +++ b/src/thread/ogc/SDL_systhread.c @@ -0,0 +1,92 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* Thread management routines for SDL */ + +#include "SDL_thread.h" +#include "../SDL_systhread.h" +#include "../SDL_thread_c.h" + +#include + +void *run_thread(void *data) +{ + SDL_RunThread(data); + return (void *) 0; /* Prevent compiler warning */ +} + +int SDL_SYS_CreateThread(SDL_Thread *thread) +{ + if (LWP_CreateThread(&thread->handle, run_thread, + thread, 0, 0, 64) != 0 ) { + SDL_SetError("Not enough resources to create thread"); + return -1; + } + + return 0; +} + +void SDL_SYS_SetupThread(const char *name) +{ +} + +int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) +{ + u8 value; + + /* Range is 0 (lowest) to 127 (highest) */ + if (priority == SDL_THREAD_PRIORITY_LOW) { + value = 0; + } else if (priority == SDL_THREAD_PRIORITY_HIGH) { + value = 80; + } else if (priority == SDL_THREAD_PRIORITY_TIME_CRITICAL) { + value = 127; + } else { + value = 64; + } + LWP_SetThreadPriority(LWP_THREAD_NULL, value); + return 0; +} + +SDL_threadID SDL_ThreadID(void) +{ + return (SDL_threadID)LWP_GetSelf(); +} + +void SDL_SYS_WaitThread(SDL_Thread *thread) +{ + void *v; + LWP_JoinThread(thread->handle, &v); + return; +} + +void SDL_SYS_DetachThread(SDL_Thread *thread) +{ + /* Do nothing. */ + thread->handle = LWP_THREAD_NULL; +} + +void SDL_SYS_KillThread(SDL_Thread *thread) +{ + return; +} diff --git a/src/thread/ogc/SDL_systhread_c.h b/src/thread/ogc/SDL_systhread_c.h new file mode 100644 index 0000000000..43caca7ebc --- /dev/null +++ b/src/thread/ogc/SDL_systhread_c.h @@ -0,0 +1,24 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +typedef Uint32 SYS_ThreadHandle; diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index 5316807058..0effd6138e 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -162,7 +162,7 @@ void SDL_SYS_SetupThread(const char *name) } /* NativeClient does not yet support signals.*/ -#if !defined(__NACL__) +#if !defined(__NACL__) && !defined(__wii__) && !defined(__gamecube__) /* Mask asynchronous signals for this thread */ sigemptyset(&mask); for (i = 0; sig_list[i]; ++i) { @@ -188,7 +188,7 @@ SDL_threadID SDL_ThreadID(void) int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { -#if __NACL__ || __RISCOS__ || __OS2__ +#if __NACL__ || __RISCOS__ || __OS2__ || __wii__ || __gamecube__ /* FIXME: Setting thread priority does not seem to be supported in NACL */ return 0; #else diff --git a/src/timer/ogc/SDL_systimer.c b/src/timer/ogc/SDL_systimer.c new file mode 100644 index 0000000000..664e495c5f --- /dev/null +++ b/src/timer/ogc/SDL_systimer.c @@ -0,0 +1,76 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" + +#ifdef SDL_TIMER_OGC + +#include +#include + +static SDL_bool ticks_started = SDL_FALSE; +static u64 start; + +void SDL_TicksInit(void) +{ + if (ticks_started) { + return; + } + ticks_started = SDL_TRUE; + + start = gettime(); +} + +void SDL_TicksQuit(void) +{ + ticks_started = SDL_FALSE; +} + +Uint64 SDL_GetTicks64(void) +{ + const u64 ticks = gettime() - start; + const u64 ms = ticks / TB_TIMER_CLOCK; + return ms; +} + +Uint64 SDL_GetPerformanceCounter(void) +{ + return gettime(); +} + +Uint64 SDL_GetPerformanceFrequency(void) +{ + return secs_to_ticks(1); +} + +void SDL_Delay(Uint32 ms) +{ + struct timespec elapsed, tv; + elapsed.tv_sec = ms / 1000; + elapsed.tv_nsec = (ms % 1000) * 1000000; + tv.tv_sec = elapsed.tv_sec; + tv.tv_nsec = elapsed.tv_nsec; + nanosleep(&tv, &elapsed); +} + +#endif /* SDL_TIMER_OGC */ + +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index d7a42cc64d..db2cb54c85 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -468,6 +468,7 @@ extern VideoBootStrap PSP_bootstrap; extern VideoBootStrap VITA_bootstrap; extern VideoBootStrap RISCOS_bootstrap; extern VideoBootStrap N3DS_bootstrap; +extern VideoBootStrap OGC_bootstrap; extern VideoBootStrap RPI_bootstrap; extern VideoBootStrap KMSDRM_bootstrap; extern VideoBootStrap KMSDRM_LEGACY_bootstrap; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 8065a0b8cf..e5412450c7 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -110,6 +110,9 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_N3DS &N3DS_bootstrap, #endif +#if SDL_VIDEO_DRIVER_OGC + &OGC_bootstrap, +#endif #if SDL_VIDEO_DRIVER_KMSDRM &KMSDRM_bootstrap, #endif diff --git a/src/video/ogc/SDL_ogccursors.h b/src/video/ogc/SDL_ogccursors.h new file mode 100644 index 0000000000..24d0608c37 --- /dev/null +++ b/src/video/ogc/SDL_ogccursors.h @@ -0,0 +1,480 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +typedef struct _OGC_Cursor { + uint16_t width; + uint16_t height; + uint8_t hot_x; + uint8_t hot_y; + uint8_t bytes_per_pixel; + uint8_t pixel_data[]; +} OGC_Cursor; + +static const OGC_Cursor OGC_cursor_hand = { + 37, 52, 11, 0, 4, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000Q\000" + "\000\000\262\000\000\000\337\000\000\000\345\000\000\000\313\000\000\000\203\000\000\000\032\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\005" + "\000\000\000\224\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000" + "\000\000\330\000\000\000\062\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\177\000\000\000\377\000\000\000\377\026\026\026\377bbb\377ttt\377" + "<<<\377\000\000\000\377\000\000\000\377\000\000\000\334\000\000\000\030\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000%\000\000\000\364\000\000\000\377...\377\327\327" + "\327\377\377\377\377\377\377\377\377\377\373\373\373\377\177\177\177\377" + "\000\000\000\377\000\000\000\377\000\000\000\206\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000n\000\000\000\377\005\005\005\377\277\277\277\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377BBB\377\000" + "\000\000\377\000\000\000\323\000\000\000\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\225\000\000\000\377###\377\366\366\366\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\206\206\206\377\000\000" + "\000\377\000\000\000\356\000\000\000\033\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\231\000\000\000\377+++\377\370\370\370\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\217\217\217\377\000\000\000\377" + "\000\000\000\361\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\230\000\000\000\377***\377\367\367\367\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\215\215\215\377\000\000\000\377\000" + "\000\000\360\000\000\000\037\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230" + "\000\000\000\377***\377\367\367\367\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000" + "\360\000\000\000\037\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000" + "\000\000\377***\377\367\367\367\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000\360" + "\000\000\000\037\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000" + "\377***\377\367\367\367\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000\360\000\000" + "\000\037\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000\377" + "***\377\367\367\367\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000\360\000\000\000\037" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000\377***\377" + "\367\367\367\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000\360\000\000\000\037\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000\377***\377\367" + "\367\367\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000\357\000\000\000\026\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000\377***\377\367\367" + "\367\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000\370\000\000\000\244\000\000\000\223" + "\000\000\000e\000\000\000\032\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000\377***\377\367\367" + "\367\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\215\215\215\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + "\000\000\000\377\000\000\000\340\000\000\000Z\000\000\000\000\000\000\000\003\000\000\000\022\000\000\000\006\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000\377***\377\367" + "\367\367\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\215\215\215\377\000\000\000\377\001\001\001\377%%%\377\036\036\036" + "\377\000\000\000\377\000\000\000\377\000\000\000\373\000\000\000\244\000\000\000\310\000\000\000\341\000\000\000\320" + "\000\000\000\220\000\000\000*\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\000\000\000" + "\377***\377\367\367\367\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\210\210\210\377\022\022\022\377\270\270\270" + "\377\356\356\356\377\351\351\351\377\236\236\236\377\022\022\022\377\000\000\000\377" + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\357\000\000\000[\000\000\000" + "\030\000\000\000<\000\000\000B\000\000\000(\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\227\000\000\000\377***\377\367\367\367\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\202\202\202\377\065\065\065\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\246\246\246\377\001\001\001\377\003\003\003\377@@@\377iii\377DD" + "D\377\002\002\002\377\000\000\000\377\000\000\000\372\000\000\000\342\000\000\000\375\000\000\000\377\000\000\000\360" + "\000\000\000\264\000\000\000:\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\233\000\000\000\377***\377\367\367\367\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\203\203\203\377\061\061\061" + "\377\375\375\375\377\377\377\377\377\377\377\377\377\377\377\377\377\372" + "\372\372\377\036\036\036\377kkk\377\375\375\375\377\377\377\377\377\377\377" + "\377\377\253\253\253\377\015\015\015\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000" + "\377\000\000\000\377\000\000\000\377\000\000\000\366\000\000\000U\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\016" + "\000\000\000n\000\000\000\272\000\000\000\360\000\000\000\377***\377\367\367\367\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\203" + "\203\203\377\061\061\061\377\375\375\375\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\376\376\376\377\063\063\063\377\211\211\211\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\177\177\177\377\000\000" + "\000\377AAA\377\236\236\236\377\256\256\256\377lll\377\011\011\011\377\000\000\000\377" + "\000\000\000\360\000\000\000)\000\000\000\000\000\000\000!\000\000\000\304\000\000\000\377\000\000\000\377\000\000\000\377" + "\000\000\000\377***\377\367\367\367\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\203\203\203\377\061\061\061\377\375" + "\375\375\377\377\377\377\377\377\377\377\377\377\377\377\377\375\375\375" + "\377\061\061\061\377\203\203\203\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\304\304\304\377\011\011\011\377\327\327\327\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\247\247\247\377\006\006\006\377\000" + "\000\000\377\000\000\000\225\000\000\000\016\000\000\000\312\000\000\000\377\000\000\000\377(((\377aaa\377\067" + "\067\067\377'''\377\366\366\366\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\203\203\203\377\061\061\061\377\375" + "\375\375\377\377\377\377\377\377\377\377\377\377\377\377\377\375\375\375" + "\377\061\061\061\377\203\203\203\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\313\313\313\377\015\015\015\377\323\323\323\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377NNN\377\000\000\000" + "\377\000\000\000\324\000\000\000s\000\000\000\377\000\000\000\377fff\377\357\357\357\377\377\377" + "\377\377\244\244\244\377###\377\365\365\365\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377|||\377&&&\377\375\375" + "\375\377\377\377\377\377\377\377\377\377\377\377\377\377\375\375\375\377" + "&&&\377|||\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\306\306\306\377\001\001\001\377\317\317\317\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\200\200\200\377\000\000\000\377\000\000\000\345" + "\000\000\000\305\000\000\000\377\062\062\062\377\371\371\371\377\377\377\377\377\377\377" + "\377\377\235\235\235\377###\377\365\365\365\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\274\274\274\377\221" + "\221\221\377\376\376\376\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\376\376\376\377\221\221\221\377\274\274\274\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\342\342\340\377\200\200\200" + "\377\347\347\347\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\202\202\202\377\000\000\000\377\000\000\000\345\000\000\000\342\000\000\000\377www\377" + "\377\377\377\377\376\376\376\377\377\377\377\377\235\235\235\377!##\377\365" + "\365\365\377\377\377\377\377\374\376\376\377\374\376\376\377\374\376\376" + "\377\374\376\376\377\377\377\377\377\377\377\377\377\374\376\376\377\374" + "\376\376\377\374\376\376\377\374\376\376\377\374\376\376\377\377\377\377" + "\377\377\377\377\377\374\376\376\377\374\376\376\377\374\376\376\377\374" + "\376\376\377\377\377\377\377\377\377\377\377\377\377\377\377\374\376\376" + "\377\374\376\376\377\374\376\376\377\377\377\377\377\201\201\201\377\000\000" + "\000\377\000\000\000\345\000\000\000\346\000\000\000\377\203\203\203\377\377\377\377\377\375" + "\373\375\377\377\377\377\377\233\233\235\377!!#\377\363\363\365\377\377\377" + "\377\377\373\373\376\377\373\373\376\377\373\373\376\377\373\373\376\377" + "\373\373\376\377\373\373\376\377\373\373\376\377\373\373\375\377\373\373" + "\376\377\373\373\376\377\373\373\376\377\373\373\375\377\373\373\376\377" + "\373\373\376\377\373\373\376\377\373\373\376\377\373\373\376\377\373\373" + "\376\377\373\373\375\377\373\373\375\377\373\373\375\377\373\373\376\377" + "\373\374\376\377\377\377\377\377\201\201\201\377\000\000\000\377\000\000\000\345\000\000" + "\000\345\000\000\000\377\177\201\201\377\377\377\377\377\371\373\376\377\377\377" + "\377\377\233\233\235\377\"\"\"\377\361\363\366\377\375\377\377\377\371\373" + "\376\377\371\373\376\377\371\373\376\377\367\372\376\377\367\372\376\377" + "\371\371\376\377\371\371\376\377\371\373\376\377\371\373\376\377\371\373" + "\376\377\371\373\376\377\367\372\376\377\367\372\376\377\371\373\376\377" + "\367\372\376\377\367\372\376\377\371\373\376\377\367\372\376\377\371\373" + "\376\377\371\373\376\377\367\372\376\377\367\372\376\377\371\373\376\377" + "\377\377\377\377\177\201\201\377\000\000\000\377\000\000\000\345\000\000\000\345\000\000\000\377" + "\177\177\201\377\377\377\377\377\365\370\377\377\377\377\377\377\234\234" + "\234\377\"\"\"\377\356\361\365\377\372\375\377\377\365\370\375\377\365\370" + "\375\377\365\370\375\377\365\370\375\377\365\370\375\377\365\370\375\377" + "\365\370\375\377\365\370\375\377\365\370\375\377\365\370\375\377\365\370" + "\375\377\365\370\375\377\365\370\375\377\365\370\375\377\365\370\375\377" + "\365\370\375\377\365\370\375\377\365\370\375\377\365\370\375\377\365\370" + "\375\377\365\370\375\377\365\370\375\377\366\371\376\377\377\377\377\377" + "\177\177\201\377\000\000\000\377\000\000\000\345\000\000\000\345\000\000\000\377}\200\202\377\377" + "\377\377\377\363\366\375\377\377\377\377\377\232\234\234\377\"\"\"\377\355" + "\357\364\377\370\372\377\377\363\366\375\377\363\366\375\377\363\366\375" + "\377\363\366\375\377\363\366\375\377\363\366\375\377\363\366\375\377\363" + "\366\375\377\363\366\375\377\363\366\375\377\363\366\375\377\363\366\375" + "\377\363\366\375\377\363\366\375\377\363\366\375\377\363\366\375\377\363" + "\366\375\377\363\366\375\377\363\366\375\377\363\366\375\377\363\366\375" + "\377\363\366\375\377\364\367\376\377\377\377\377\377~\177\201\377\000\000\000\377" + "\000\000\000\345\000\000\000\345\000\000\000\377|~\201\377\377\377\377\377\357\362\374\377" + "\377\377\377\377\231\232\234\377\"\"\"\377\352\355\364\377\364\370\377\377" + "\357\362\374\377\357\364\374\377\357\364\374\377\357\364\374\377\357\362" + "\374\377\357\364\374\377\357\364\374\377\357\364\374\377\357\364\374\377" + "\357\362\374\377\357\364\374\377\357\364\374\377\357\364\374\377\357\364" + "\374\377\357\364\374\377\357\364\374\377\357\364\374\377\357\364\374\377" + "\357\364\374\377\357\364\374\377\357\362\374\377\357\364\374\377\360\363" + "\375\377\377\377\377\377|~\201\377\000\000\000\377\000\000\000\345\000\000\000\345\000\000\000\377" + "z|\201\377\377\377\377\377\353\360\374\377\375\377\377\377\230\232\235\377" + "\"\"\"\377\347\352\364\377\360\364\377\377\353\360\374\377\355\360\374\377" + "\355\360\374\377\355\360\374\377\353\360\374\377\355\360\374\377\353\360" + "\374\377\353\360\374\377\353\360\374\377\355\360\374\377\355\360\374\377" + "\355\360\374\377\355\362\374\377\355\360\374\377\353\360\374\377\353\360" + "\374\377\355\360\374\377\353\360\374\377\355\360\374\377\355\360\374\377" + "\355\360\374\377\353\360\374\377\355\362\374\377\377\377\377\377z|\201\377" + "\000\000\000\377\000\000\000\345\000\000\000\345\000\000\000\377y{\201\377\377\377\377\377\351\356" + "\372\377\373\377\377\377\220\223\230\377\026\026\026\377\344\351\363\377\353" + "\362\377\377\350\357\374\377\350\357\372\377\350\357\372\377\350\357\374" + "\377\350\357\374\377\350\357\372\377\350\357\374\377\350\357\372\377\350" + "\357\372\377\350\357\374\377\350\357\374\377\350\357\374\377\350\357\372" + "\377\350\357\372\377\350\357\372\377\350\357\374\377\350\357\374\377\350" + "\357\372\377\350\357\372\377\350\357\372\377\350\357\372\377\350\357\372" + "\377\351\360\373\377\377\377\377\377y{\201\377\000\000\000\377\000\000\000\345\000\000\000" + "\345\000\000\000\377xz\200\377\375\377\377\377\346\354\373\377\352\362\376\377" + "\304\313\325\377\226\233\243\377\343\353\370\377\345\355\374\377\345\355" + "\372\377\345\355\372\377\345\353\372\377\345\353\372\377\345\355\372\377" + "\345\355\372\377\345\353\372\377\345\353\372\377\345\353\372\377\345\355" + "\372\377\345\355\372\377\345\353\372\377\345\353\372\377\345\353\372\377" + "\345\353\372\377\345\353\372\377\345\353\372\377\345\353\372\377\345\353" + "\372\377\345\353\372\377\345\353\372\377\345\353\372\377\344\354\373\377" + "\375\377\377\377xz\200\377\000\000\000\377\000\000\000\345\000\000\000\345\000\000\000\377ux\201" + "\377\373\377\377\377\342\352\373\377\340\350\371\377\350\360\377\377\362" + "\370\377\377\341\351\373\377\341\351\372\377\341\351\372\377\341\351\372" + "\377\341\351\372\377\341\351\372\377\341\351\372\377\341\351\372\377\341" + "\351\372\377\341\351\372\377\341\351\372\377\341\351\372\377\341\351\372" + "\377\341\351\372\377\341\351\372\377\341\351\372\377\341\351\372\377\341" + "\351\372\377\341\351\372\377\341\351\372\377\341\351\372\377\341\351\372" + "\377\341\351\372\377\341\351\372\377\342\352\373\377\373\377\377\377ux\201" + "\377\000\000\000\377\000\000\000\345\000\000\000\345\000\000\000\377ty\200\377\367\375\377\377\336" + "\346\372\377\334\346\372\377\334\346\372\377\334\346\370\377\335\345\371" + "\377\335\345\371\377\335\345\371\377\335\345\371\377\335\345\371\377\335" + "\345\371\377\335\345\371\377\335\345\371\377\335\345\371\377\335\345\371" + "\377\335\345\371\377\335\345\371\377\335\345\371\377\334\346\372\377\335" + "\345\371\377\335\345\371\377\335\345\371\377\335\345\371\377\335\345\371" + "\377\335\345\371\377\335\345\371\377\334\346\372\377\335\345\371\377\335" + "\345\371\377\335\347\373\377\367\375\377\377ty\200\377\000\000\000\377\000\000\000\345" + "\000\000\000\345\000\000\000\377sx\200\377\366\373\377\377\334\344\372\377\331\344\370" + "\377\330\343\371\377\331\344\370\377\330\343\371\377\330\343\371\377\331" + "\344\370\377\331\344\370\377\331\344\370\377\331\344\370\377\330\343\371" + "\377\331\344\370\377\331\344\370\377\331\344\370\377\331\344\370\377\331" + "\344\370\377\330\343\371\377\330\343\371\377\330\343\371\377\331\344\370" + "\377\331\344\370\377\331\344\370\377\330\343\371\377\330\342\371\377\331" + "\344\370\377\331\343\370\377\331\344\370\377\331\343\370\377\334\344\370" + "\377\366\373\377\377sx\200\377\000\000\000\377\000\000\000\345\000\000\000\346\000\000\000\377QV" + "[\377\365\373\377\377\334\346\372\377\325\341\370\377\325\337\370\377\325" + "\341\370\377\325\341\370\377\325\341\370\377\325\341\370\377\325\341\370" + "\377\325\341\370\377\325\341\370\377\325\341\370\377\325\341\370\377\325" + "\341\370\377\325\341\370\377\325\341\370\377\325\341\370\377\325\341\370" + "\377\325\341\370\377\325\341\370\377\325\341\370\377\325\341\370\377\325" + "\341\370\377\325\341\370\377\325\341\370\377\325\341\370\377\325\341\370" + "\377\324\341\370\377\324\341\370\377\334\346\372\377\365\373\377\377PU\\" + "\377\000\000\000\377\000\000\000\346\000\000\000\314\000\000\000\377\012\012\014\377\254\264\301\377" + "\362\370\377\377\325\341\370\377\321\335\367\377\320\335\370\377\320\335" + "\370\377\320\335\370\377\320\335\370\377\320\335\370\377\320\335\370\377" + "\320\335\370\377\320\335\370\377\321\335\367\377\320\335\370\377\320\335" + "\370\377\320\335\370\377\320\335\370\377\320\335\370\377\321\335\367\377" + "\321\335\367\377\320\335\370\377\320\335\370\377\320\335\370\377\320\335" + "\370\377\320\335\370\377\321\335\367\377\320\335\370\377\321\335\367\377" + "\326\340\371\377\362\370\377\377\254\264\301\377\012\012\014\377\000\000\000\377\000" + "\000\000\314\000\000\000d\000\000\000\377\000\000\000\377\024\025\027\377\262\274\314\377\355\365" + "\377\377\323\336\367\377\315\334\366\377\315\334\366\377\314\333\367\377" + "\315\334\366\377\314\333\367\377\314\333\367\377\314\333\367\377\314\333" + "\367\377\316\333\367\377\314\333\367\377\314\333\367\377\315\334\366\377" + "\315\334\366\377\315\334\366\377\316\333\367\377\316\333\367\377\314\333" + "\367\377\314\333\367\377\315\334\366\377\315\334\366\377\314\333\367\377" + "\314\333\367\377\314\333\367\377\323\340\367\377\356\365\377\377\262\274" + "\314\377\024\025\027\377\000\000\000\377\000\000\000\377\000\000\000d\000\000\000\002\000\000\000\220\000\000\000" + "\377\000\000\000\377\025\027\032\377\261\273\315\377\352\362\377\377\317\333\367\377" + "\311\326\366\377\311\330\366\377\311\330\366\377\311\330\366\377\311\330" + "\366\377\311\330\366\377\311\330\366\377\311\330\366\377\311\330\366\377" + "\311\330\366\377\311\330\366\377\311\330\366\377\311\330\366\377\311\330" + "\366\377\311\330\366\377\311\330\366\377\311\330\366\377\311\330\366\377" + "\311\330\366\377\311\330\366\377\311\330\366\377\317\333\367\377\352\362" + "\377\377\261\271\315\377\025\027\032\377\000\000\000\377\000\000\000\377\000\000\000\220\000\000\000" + "\002\000\000\000\000\000\000\000\002\000\000\000\224\000\000\000\377\000\000\000\377\025\030\032\377\257\272\320" + "\377\346\356\377\377\313\330\366\377\305\325\365\377\305\324\365\377\305" + "\324\365\377\305\325\365\377\305\324\365\377\305\324\365\377\305\325\365" + "\377\305\325\365\377\305\324\365\377\305\325\365\377\305\325\365\377\305" + "\324\365\377\305\325\365\377\305\325\365\377\305\325\365\377\305\325\365" + "\377\305\325\365\377\305\324\365\377\305\324\365\377\313\332\366\377\346" + "\356\377\377\257\272\320\377\025\027\032\377\000\000\000\377\000\000\000\377\000\000\000\224\000" + "\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\235\000\000\000\377\000\000\000\377\031\032" + "\034\377\267\304\335\377\327\345\377\377\307\326\365\377\302\322\365\377\302" + "\322\365\377\302\322\365\377\302\322\365\377\302\322\365\377\302\322\365" + "\377\302\322\365\377\302\322\365\377\302\322\365\377\302\322\365\377\302" + "\322\365\377\302\322\365\377\302\322\365\377\302\322\365\377\302\322\365" + "\377\302\322\365\377\302\322\365\377\305\326\367\377\327\343\377\377\267" + "\304\335\377\031\032\034\377\000\000\000\377\000\000\000\377\000\000\000\235\000\000\000\004\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\006\000\000\000\241\000\000\000\377\000\000\000\377GJV\377" + "\327\345\377\377\311\330\367\377\275\317\365\377\276\317\365\377\276\320" + "\365\377\276\320\365\377\276\320\365\377\276\320\365\377\276\320\365\377" + "\276\320\365\377\276\320\365\377\276\320\365\377\276\320\365\377\276\320" + "\365\377\276\320\365\377\276\320\365\377\276\320\365\377\276\320\365\377" + "\275\317\365\377\311\330\367\377\326\345\377\377GJV\377\000\000\000\377\000\000\000\377" + "\000\000\000\241\000\000\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\011\000\000\000\313\000\000\000\377\015\015\017\377\270\305\341\377\312\334\374" + "\377\271\315\364\377\272\314\364\377\272\316\364\377\272\316\364\377\272" + "\316\364\377\272\316\364\377\272\316\364\377\272\316\364\377\272\316\364" + "\377\272\316\364\377\272\316\364\377\272\316\364\377\272\316\364\377\272" + "\316\364\377\272\316\364\377\272\316\364\377\271\316\364\377\312\334\374" + "\377\270\305\341\377\015\015\017\377\000\000\000\377\000\000\000\313\000\000\000\011\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000s\000\000" + "\000\377\004\004\006\377\254\270\324\377\311\332\376\377\267\313\364\377\270\312" + "\363\377\270\314\363\377\270\314\363\377\270\314\363\377\270\314\363\377" + "\270\312\363\377\270\312\363\377\270\314\363\377\270\314\363\377\270\314" + "\363\377\270\314\363\377\270\312\363\377\270\314\363\377\270\314\363\377" + "\270\314\363\377\267\313\364\377\311\332\376\377\254\270\324\377\004\004\006\377" + "\000\000\000\377\000\000\000s\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000a\000\000\000\377\005\005\007\377\253\270\324\377\306\332" + "\376\377\263\310\363\377\264\311\363\377\264\311\363\377\264\311\363\377" + "\264\311\363\377\264\311\363\377\264\311\364\377\264\311\364\377\264\311" + "\363\377\264\311\363\377\264\311\363\377\264\311\363\377\264\311\363\377" + "\264\311\363\377\264\311\364\377\264\311\364\377\263\310\363\377\306\332" + "\376\377\253\270\324\377\005\005\007\377\000\000\000\377\000\000\000a\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000d\000\000\000\377" + "\005\005\007\377\255\274\332\377\306\330\376\377\261\306\363\377\262\307\362\377" + "\262\307\362\377\262\307\362\377\262\307\362\377\262\307\362\377\262\307" + "\362\377\262\307\362\377\262\307\362\377\262\307\362\377\262\307\362\377" + "\262\307\362\377\262\307\362\377\262\307\362\377\262\307\362\377\262\307" + "\362\377\261\306\363\377\306\330\376\377\255\274\332\377\005\005\007\377\000\000\000" + "\377\000\000\000d\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000W\000\000\000\377\002\002\002\377\205\220\251\377\341\354\377" + "\377\313\333\377\377\311\333\377\377\311\333\377\377\311\333\377\377\311" + "\333\377\377\311\333\377\377\311\333\377\377\311\333\377\377\311\333\377" + "\377\311\333\377\377\310\332\377\377\311\333\377\377\311\333\377\377\311" + "\333\377\377\310\332\377\377\310\332\377\377\313\333\377\377\340\354\377" + "\377\205\220\251\377\002\002\002\377\000\000\000\377\000\000\000W\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\034\000\000\000\354" + "\000\000\000\377\020\022\025\377RZi\377]ev\377Zdt\377Zdt\377[ct\377[ct\377Zdt\377" + "Zdt\377Zdt\377[ct\377[ct\377Zds\377[ct\377[ct\377Zdt\377[cr\377Zds\377]e" + "v\377RZi\377\020\022\025\377\000\000\000\377\000\000\000\354\000\000\000\034\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000f\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377" + "\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000" + "\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000\000\377\000\000" + "\000\377\000\000\000\377\000\000\000f\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000R\000\000\000\275\000" + "\000\000\344\000\000\000\345\000\000\000\344\000\000\000\344\000\000\000\344\000\000\000\344\000\000\000\344\000\000" + "\000\344\000\000\000\344\000\000\000\344\000\000\000\344\000\000\000\344\000\000\000\344\000\000\000\344\000\000\000" + "\344\000\000\000\344\000\000\000\344\000\000\000\345\000\000\000\344\000\000\000\275\000\000\000R\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", +}; + +static const OGC_Cursor OGC_cursor_arrow = { + 24, 31, 0, 0, 4, + "\002\002\002\337\000\000\000\224\000\000\000\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\000\000\000\377" + "\005\005\005\321\000\000\000$\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377ddd\377\037\037\037\373\003\003\003\364" + "\000\000\000V\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\377\225\225\225\377\361\361\361\377VVV\376\000\000\000\377" + "\002\002\002\243\000\000\000\012\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\377\225\225\225\377\377\377\377\377\377\377\377\377\241" + "\241\241\377\007\007\007\375\005\005\005\322\000\000\000%\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\225\225\225\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\315\315\315\377!!!\373\003\003\003\365\000\000\000Y\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\225\225\225\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\362\362\362\377" + "WWW\376\000\000\000\377\002\002\002\243\000\000\000\012\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\377\225\225\225\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\241\241\241\377\007\007\007\375\005" + "\005\005\331\000\000\000+\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\225\225\225\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\316\316\316\377!!!\373\003\003\003\365\000\000\000Z" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\377\225\225\225\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\362\362\362\377XXX\376\000\000\000\377\002\002\002\243\000\000\000" + "\012\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\377\225\225\225\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\375\375\377\377\373\374\376\377\235\236\240\377\007\007\007\374\005" + "\005\005\331\000\000\000+\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\377\225\225\225\377\377\377\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\375\375\377\377" + "\373\374\376\377\371\373\376\377\367\371\376\377\366\370\375\377\305\310" + "\314\377\037!\"\373\003\003\003\366\000\000\000[\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\377\225\225\225\377\377\377\377\377\377\377\377" + "\377\377\377\377\377\377\377\377\377\375\375\377\377\373\374\376\377\371" + "\373\376\377\367\371\376\377\366\370\375\377\364\367\375\377\362\365\375" + "\377\360\364\374\377\342\347\357\377QSW\376\000\000\000\377\002\002\002\243\000\000\000\012" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\225\225\225\377\377\377" + "\377\377\377\377\377\377\375\375\377\377\373\374\376\377\371\373\376\377" + "\367\371\376\377\366\370\375\377\364\367\375\377\362\365\375\377\360\364" + "\374\377\356\363\374\377\354\362\374\377\353\360\374\377\351\357\373\377" + "\222\226\236\377\007\007\007\374\004\005\005\331\000\000\000+\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\377\225\225\225\377\375\375\377\377\373\374\376\377\371\373\376" + "\377\367\371\376\377\366\370\375\377\364\367\375\377\362\365\375\377\360" + "\364\374\377\356\363\374\377\354\362\374\377\353\360\374\377\351\357\373" + "\377\347\356\373\377\345\354\373\377\343\353\372\377\275\303\321\377#%'\373" + "\003\003\003\366\000\000\000[\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\223\223\224\377\371\373" + "\376\377\367\371\376\377\366\370\375\377\364\367\375\377\362\365\375\377" + "\360\364\374\377\356\363\374\377\354\362\374\377\353\360\374\377\351\357" + "\373\377\347\356\373\377\345\354\373\377\343\353\372\377\342\352\372\377" + "\340\350\372\377\336\347\371\377\321\332\354\377LOW\376\000\000\000\377\002\002\002\243" + "\000\000\000\012\000\000\000\000\000\000\000\377\220\221\224\377\366\370\375\377\364\367\375\377" + "\362\365\375\377\360\364\374\377\356\363\374\377\354\362\374\377\353\360" + "\374\377\351\357\373\377\347\356\373\377\345\354\373\377\343\353\372\377" + "\342\352\372\377\340\350\372\377\336\347\371\377\334\346\371\377\332\344" + "\371\377\330\343\370\377\327\342\370\377\206\215\235\377\006\006\007\374\004\004\005" + "\332\000\000\000,\000\000\000\377\217\220\224\377\362\365\375\377\360\364\374\377\356" + "\363\374\377\354\361\374\377\353\360\374\377\351\357\373\377\347\356\373" + "\377\345\354\373\377\343\353\372\377\342\352\372\377\340\350\372\377\336" + "\347\371\377\334\346\371\377\332\344\371\377\330\343\370\377\327\342\370" + "\377\325\340\370\377\323\337\370\377\321\336\367\377pw\206\377\000\000\000\377" + "\001\001\001\347\000\000\000\377\214\217\223\377\356\363\374\377\354\361\374\377\353" + "\360\374\377\351\357\373\377\347\356\373\377\345\354\373\377\343\353\372" + "\377\342\352\372\377\340\350\372\377\336\347\371\377\334\346\371\377\332" + "\344\371\377\330\343\370\377\327\342\370\377\325\340\370\377\323\337\370" + "\377\321\336\367\377\225\236\261\377,/\065\374\000\000\000\377\004\004\005\316\000\000\000F" + "\000\000\000\377\212\215\223\377\353\360\374\377\351\357\373\377\347\356\373\377" + "\345\354\373\377\343\353\372\377\342\352\372\377\340\350\372\377\336\347" + "\371\377\334\346\371\377\332\344\371\377\330\343\370\377\327\342\370\377" + "\325\340\370\377\323\337\370\377\321\336\367\377\236\250\275\377\062\065<\374" + "\000\000\000\377\002\004\004\323\000\000\000U\000\000\000\001\000\000\000\000\000\000\000\377\210\214\223\377\347" + "\356\373\377\345\354\373\377\343\353\372\377\342\352\372\377\340\350\372" + "\377\336\347\371\377\334\346\371\377\332\344\371\377\330\343\370\377\327" + "\342\370\377\325\340\370\377\323\337\370\377\321\336\367\377\230\241\265" + "\377,/\064\374\000\000\000\377\002\004\004\323\000\000\000U\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\377\206\212\223\377\343\353\372\377\341\352\372\377\340\350\372\377" + "\336\347\371\377\334\346\371\377\332\344\371\377\330\343\370\377\327\342" + "\370\377\325\340\370\377\323\337\370\377\321\336\367\377\317\334\367\377" + "DHQ\374\000\000\000\377\004\004\004\314\000\000\000J\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\377\203\211\222\377\340\350\372\377\336\347\371\377\334" + "\346\371\377\332\344\371\377\330\343\370\377\327\342\370\377\325\340\370" + "\377\323\337\370\377\321\336\367\377\317\334\367\377\315\333\367\377\314" + "\332\366\377JOZ\376\002\002\003\362\000\000\000\012\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\202\207\221\377\334\346\371\377\332\344" + "\371\377\330\343\370\377\327\342\370\377\325\340\370\377\323\337\370\377" + "\321\336\367\377\316\333\366\377\315\333\367\377\314\332\366\377\312\330" + "\366\377\310\327\366\377\250\266\320\377\002\002\002\376\000\000\000r\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\177\205\221\377\330\343" + "\370\377\327\342\370\377\325\340\370\377\323\337\370\377\321\336\367\377" + "\223\234\257\377),\062\374\036\040$\374\306\324\361\377\310\327\366\377\306" + "\326\365\377\304\324\365\377\303\323\365\377FLX\376\003\003\004\354\000\000\000\012\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377~\204\221\377\325" + "\340\370\377\323\337\370\377\321\336\367\377\222\233\256\377)-\063\374\000\000" + "\000\377\002\004\004\321\000\000\000\376y\203\226\377\304\324\365\377\303\323\365\377\301" + "\322\364\377\277\320\364\377\242\261\321\377\001\002\002\376\000\000\000s\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377{\202\221\377\321\336\367\377" + "\222\233\256\377),\062\374\000\000\000\377\004\004\005\313\000\000\000I\000\000\000\000\001\001\003\263\026" + "\030\034\373\275\316\357\377\277\320\364\377\275\317\364\377\273\316\364\377" + "\271\314\363\377CJY\376\003\003\004\354\000\000\000\012\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\377INW\377)+\061\373\000\000\000\377\004\004\004\312\000\000\000H\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\062\000\000\000\376t\177\225\377\273\316\364\377\271\314\363" + "\377\270\313\363\377\212\232\271\377(,\066\375\000\000\000\377\000\000\000F\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\000\000\000\377\004\004\004\311\000\000\000H\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\003\003\262\025\027\034\373\264\307" + "\356\377\212\232\271\377.\063>\374\000\000\000\377\004\004\005\330\000\000\000V\000\000\000\001\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000t\000\000\000G\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\062\000\000\000\376\032\035$\375" + "\000\000\000\377\004\004\005\327\000\000\000V\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\003\003\247\004\004\005\325\000\000\000U\000\000\000\002\000\000" + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", +}; + diff --git a/src/video/ogc/SDL_ogcevents.c b/src/video/ogc/SDL_ogcevents.c new file mode 100644 index 0000000000..4e4440d12d --- /dev/null +++ b/src/video/ogc/SDL_ogcevents.c @@ -0,0 +1,113 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_OGC + +#include "SDL.h" + +#include "../../events/SDL_events_c.h" + +#include "SDL_ogcevents_c.h" +#include "SDL_ogckeyboard.h" +#include "SDL_ogcmouse.h" +#include "SDL_ogcvideo.h" + +#include +#include + +/* These variables can be set from the handlers registered in SDL_main() */ +bool OGC_PowerOffRequested = false; +bool OGC_ResetRequested = false; + +#ifdef __wii__ +#define MAX_WII_MOUSE_BUTTONS 2 +static const struct { + int wii; + int mouse; +} s_mouse_button_map[MAX_WII_MOUSE_BUTTONS] = { + { WPAD_BUTTON_B, SDL_BUTTON_LEFT }, + { WPAD_BUTTON_A, SDL_BUTTON_RIGHT }, +}; + +static void pump_ir_events(_THIS) +{ + int screen_w, screen_h; + + if (!_this->windows) return; + + if (!SDL_WasInit(SDL_INIT_JOYSTICK)) { + /* Get events from WPAD; we don't need to do this if the joystick + * system was initialized, because in that case this operation is done + * there at every event loop iteration. */ + WPAD_ReadPending(WPAD_CHAN_ALL, NULL); + } + + screen_w = _this->displays[0].current_mode.w; + screen_h = _this->displays[0].current_mode.h; + + for (int i = 0; i < 4; i++) { + WPADData *data = WPAD_Data(i); + + if (!data->ir.valid) continue; + + SDL_SendMouseMotion(_this->windows, i, 0, + data->ir.x * screen_w / 640, + data->ir.y * screen_h / 480); + + for (int b = 0; b < MAX_WII_MOUSE_BUTTONS; b++) { + if (data->btns_d & s_mouse_button_map[b].wii) { + SDL_SendMouseButton(_this->windows, i, + SDL_PRESSED, s_mouse_button_map[b].mouse); + } + if (data->btns_u & s_mouse_button_map[b].wii) { + SDL_SendMouseButton(_this->windows, i, + SDL_RELEASED, s_mouse_button_map[b].mouse); + } + } + } + + if (OGC_prep_draw_cursor(_this)) { + OGC_video_flip(_this, false); + } +} +#endif + +void OGC_PumpEvents(_THIS) +{ + if (OGC_ResetRequested || OGC_PowerOffRequested) { + SDL_Event ev; + ev.type = SDL_QUIT; + SDL_PushEvent(&ev); + if (OGC_PowerOffRequested) { + SYS_ResetSystem(SYS_POWEROFF, 0, 0); + } + } + +#ifdef __wii__ + pump_ir_events(_this); + OGC_PumpKeyboardEvents(_this); +#endif +} + +#endif /* SDL_VIDEO_DRIVER_OGC */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcevents_c.h b/src/video/ogc/SDL_ogcevents_c.h new file mode 100644 index 0000000000..6bc6b91e68 --- /dev/null +++ b/src/video/ogc/SDL_ogcevents_c.h @@ -0,0 +1,36 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_ogcevents_c_h_ +#define SDL_ogcevents_c_h_ + +#include "../../SDL_internal.h" + +#include "SDL_ogcvideo.h" + +extern bool OGC_ResetRequested; +extern bool OGC_PowerOffRequested; + +extern void OGC_PumpEvents(_THIS); + +#endif /* SDL_ogcevents_c_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcframebuffer.c b/src/video/ogc/SDL_ogcframebuffer.c new file mode 100644 index 0000000000..21fb7ee0cb --- /dev/null +++ b/src/video/ogc/SDL_ogcframebuffer.c @@ -0,0 +1,129 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_OGC + +#include "../SDL_sysvideo.h" +#include "SDL_ogcframebuffer_c.h" +#include "SDL_ogcgxcommon.h" +#include "SDL_ogcpixels.h" +#include "SDL_ogcvideo.h" + +#include +#include +#include +#include +#include + +static void draw_screen_rect(SDL_Window *window) +{ + s16 z = 0; + + GX_Begin(GX_QUADS, GX_VTXFMT0, 4); + GX_Position3s16(0, 0, z); + GX_TexCoord1x8(0); + GX_Position3s16(window->w, 0, z); + GX_TexCoord1x8(1); + GX_Position3s16(window->w, window->h, z); + GX_TexCoord1x8(2); + GX_Position3s16(0, window->h, z); + GX_TexCoord1x8(3); + GX_End(); +} + +static void free_window_data(SDL_Window *window) +{ + SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata; + if (windowdata) { + if (windowdata->pixels) { + SDL_free(windowdata->pixels); + } + if (windowdata->texels) { + free(windowdata->texels); + } + SDL_free(windowdata); + window->driverdata = NULL; + } +} + +int SDL_OGC_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) +{ + SDL_WindowData *windowdata; + int bytes_per_pixel = 4; + size_t texture_size; + int w, h; + + free_window_data(window); + windowdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); + if (!windowdata) { + SDL_OutOfMemory(); + return -1; + } + + w = window->w; + h = window->h; + windowdata->pixels = SDL_malloc(w * h * bytes_per_pixel); + texture_size = GX_GetTexBufferSize(w, h, GX_TF_RGBA8, GX_FALSE, 0); + windowdata->texels = memalign(32, texture_size); + windowdata->surface_format = SDL_PIXELFORMAT_RGBA8888; + window->driverdata = windowdata; + + *pitch = w * bytes_per_pixel; + *format = windowdata->surface_format; + *pixels = windowdata->pixels; + return 0; +} + +int SDL_OGC_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects) +{ + SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata; + u32 texture_size; + u8 gx_format; + + gx_format = OGC_texture_format_from_SDL(windowdata->surface_format); + for (int i = 0; i < numrects; i++) { + OGC_pixels_to_texture(windowdata->pixels, windowdata->surface_format, &rects[i], + window->surface->pitch, windowdata->texels, window->w); + } + texture_size = GX_GetTexBufferSize(window->w, window->h, gx_format, + GX_FALSE, 0); + DCStoreRange(windowdata->texels, texture_size); + GX_InvalidateTexAll(); + OGC_load_texture(windowdata->texels, window->w, window->h, gx_format, + SDL_ScaleModeNearest); + draw_screen_rect(window); + GX_DrawDone(); + + OGC_video_flip(_this, true); + + return 0; +} + +void SDL_OGC_DestroyWindowFramebuffer(_THIS, SDL_Window *window) +{ + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Destroying window"); + free_window_data(window); +} + +#endif /* SDL_VIDEO_DRIVER_OGC */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcframebuffer_c.h b/src/video/ogc/SDL_ogcframebuffer_c.h new file mode 100644 index 0000000000..af58bbcc14 --- /dev/null +++ b/src/video/ogc/SDL_ogcframebuffer_c.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_ogcframebuffer_c_h_ +#define SDL_ogcframebuffer_c_h_ + +#include "../../SDL_internal.h" + +extern int SDL_OGC_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch); +extern int SDL_OGC_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void SDL_OGC_DestroyWindowFramebuffer(_THIS, SDL_Window *window); + +#endif /* SDL_ogcframebuffer_c_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcgl.c b/src/video/ogc/SDL_ogcgl.c new file mode 100644 index 0000000000..fd26d690e9 --- /dev/null +++ b/src/video/ogc/SDL_ogcgl.c @@ -0,0 +1,134 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_OGC) && defined(SDL_VIDEO_OPENGL) + +#include "../SDL_sysvideo.h" + +#include "SDL_ogcgl.h" +#include "SDL_ogcvideo.h" + +#include + +typedef struct +{ + SDL_Window *window; + int swap_interval; +} OGC_GL_Context; + +/* Weak symbols for the opengx functions used by SDL, so that the client does + * not need to link to opengx, unless it actually uses OpenGL. */ +void __attribute__((weak)) ogx_initialize(void) +{ + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "%s() called but opengx not used in build!", __func__); +} + +void __attribute__((weak)) ogx_stencil_create(OgxStencilFlags) +{ + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "%s() called but opengx not used in build!", __func__); +} + +void __attribute__((weak)) *ogx_get_proc_address(const char *) +{ + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "%s() called but opengx not used in build!", __func__); + return NULL; +} + +int __attribute__((weak)) ogx_prepare_swap_buffers() +{ + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "%s() called but opengx not used in build!", __func__); + return 0; +} + +int SDL_OGC_GL_LoadLibrary(_THIS, const char *path) +{ + return 0; +} + +void *SDL_OGC_GL_GetProcAddress(_THIS, const char *proc) +{ + return ogx_get_proc_address(proc); +} + +void SDL_OGC_GL_UnloadLibrary(_THIS) +{ + // nothing to do +} + +SDL_GLContext SDL_OGC_GL_CreateContext(_THIS, SDL_Window * window) +{ + OGC_GL_Context *context = SDL_calloc(1, sizeof(*context)); + context->window = window; + context->swap_interval = 1; + ogx_initialize(); + if (_this->gl_config.stencil_size > 0) { + OgxStencilFlags flags = 0; /* Don't care if Z gets dirty on discarded fragments */ + if (_this->gl_config.stencil_size > 4) flags |= OGX_STENCIL_8BIT; + ogx_stencil_create(flags); + } + return context; +} + +int SDL_OGC_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) +{ + return 0; +} + +int SDL_OGC_GL_SetSwapInterval(_THIS, int interval) +{ + OGC_GL_Context *context = _this->current_glctx; + context->swap_interval = interval; + return 0; +} + +int SDL_OGC_GL_GetSwapInterval(_THIS) +{ + OGC_GL_Context *context = _this->current_glctx; + return context->swap_interval; +} + +int SDL_OGC_GL_SwapWindow(_THIS, SDL_Window * window) +{ + OGC_GL_Context *context = _this->current_glctx; + + bool vsync = context->swap_interval == 1; + OGC_video_flip(_this, vsync); + return 0; +} + +void SDL_OGC_GL_DeleteContext(_THIS, SDL_GLContext context) +{ + SDL_free(context); +} + +void SDL_OGC_GL_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor) +{ + *mask = SDL_GL_CONTEXT_PROFILE_COMPATIBILITY; + *major = 1; + *minor = 1; +} + +#endif /* SDL_VIDEO_DRIVER_OGC */ diff --git a/src/video/ogc/SDL_ogcgl.h b/src/video/ogc/SDL_ogcgl.h new file mode 100644 index 0000000000..dcaee41880 --- /dev/null +++ b/src/video/ogc/SDL_ogcgl.h @@ -0,0 +1,44 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_OGC_gl_h_ +#define SDL_OGC_gl_h_ + +#ifdef SDL_VIDEO_OPENGL + +#include "../SDL_sysvideo.h" + +int SDL_OGC_GL_LoadLibrary(_THIS, const char *path); +void *SDL_OGC_GL_GetProcAddress(_THIS, const char *proc); +void SDL_OGC_GL_UnloadLibrary(_THIS); +SDL_GLContext SDL_OGC_GL_CreateContext(_THIS, SDL_Window * window); +int SDL_OGC_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +int SDL_OGC_GL_SetSwapInterval(_THIS, int interval); +int SDL_OGC_GL_GetSwapInterval(_THIS); +int SDL_OGC_GL_SwapWindow(_THIS, SDL_Window * window); +void SDL_OGC_GL_DeleteContext(_THIS, SDL_GLContext context); +void SDL_OGC_GL_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor); + +#endif /* SDL_VIDEO_OPENGL */ + +#endif /* SDL_OGC_gl_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcgxcommon.c b/src/video/ogc/SDL_ogcgxcommon.c new file mode 100644 index 0000000000..ed7e096369 --- /dev/null +++ b/src/video/ogc/SDL_ogcgxcommon.c @@ -0,0 +1,129 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_OGC + +#include "SDL_ogcgxcommon.h" +#include "SDL_ogcpixels.h" + +#include +#include +#include + +static const f32 tex_pos[] __attribute__((aligned(32))) = { + 0.0, + 0.0, + 1.0, + 0.0, + 1.0, + 1.0, + 0.0, + 1.0, +}; + +void OGC_set_viewport(int x, int y, int w, int h) +{ + Mtx44 proj; + + GX_SetViewport(x, y, w, h, 0, 1); + GX_SetScissor(x, y, w, h); + + // matrix, t, b, l, r, n, f + guOrtho(proj, 0, h, 0, w, 0, 1); + GX_LoadProjectionMtx(proj, GX_ORTHOGRAPHIC); +} + +void OGC_draw_init(int w, int h) +{ + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "OGC_draw_init called with %d, %d", w, h); + + GX_ClearVtxDesc(); + GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); + GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX8); + + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); + + GX_SetArray(GX_VA_TEX0, (void *)tex_pos, 2 * sizeof(f32)); + GX_SetNumTexGens(1); + GX_SetNumChans(1); + GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, 0, + GX_DF_NONE, GX_AF_NONE); + + GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); + + GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE); + GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); + + OGC_set_viewport(0, 0, w, h); + + GX_InvVtxCache(); // update vertex cache +} + +void OGC_load_texture(void *texels, int w, int h, u8 format, + SDL_ScaleMode scale_mode) +{ + GXTexObj texobj_a, texobj_b; + + if (format == GX_TF_CI8) { + GX_InitTexObjCI(&texobj_a, texels, w, h, GX_TF_CI8, GX_CLAMP, GX_CLAMP, 0, GX_TLUT0); + GX_InitTexObjCI(&texobj_b, texels, w, h, GX_TF_CI8, GX_CLAMP, GX_CLAMP, 0, GX_TLUT1); + GX_LoadTexObj(&texobj_b, GX_TEXMAP1); + + // Setup TEV to combine Red+Green and Blue paletted images + GX_SetTevColor(GX_TEVREG0, (GXColor){ 255, 255, 0, 0 }); + GX_SetTevSwapModeTable(GX_TEV_SWAP1, GX_CH_RED, GX_CH_ALPHA, GX_CH_BLUE, GX_CH_ALPHA); + GX_SetTevSwapModeTable(GX_TEV_SWAP2, GX_CH_ALPHA, GX_CH_ALPHA, GX_CH_BLUE, GX_CH_ALPHA); + // first stage = red and green + GX_SetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP1); + GX_SetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_C0, GX_CC_ZERO); + // second stage = add blue (and opaque alpha) + GX_SetTevOp(GX_TEVSTAGE1, GX_BLEND); + GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD0, GX_TEXMAP1, GX_COLORNULL); + GX_SetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP2); + GX_SetTevColorIn(GX_TEVSTAGE1, GX_CC_TEXC, GX_CC_ZERO, GX_CC_ZERO, GX_CC_CPREV); + GX_SetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_KONST); + + GX_SetNumTevStages(2); + } else { + GX_InitTexObj(&texobj_a, texels, w, h, format, GX_CLAMP, GX_CLAMP, GX_FALSE); + } + + switch (scale_mode) { + case SDL_ScaleModeLinear: + GX_InitTexObjLOD(&texobj_a, GX_LINEAR, GX_LINEAR, + 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); + break; + case SDL_ScaleModeBest: + GX_InitTexObjLOD(&texobj_a, GX_LIN_MIP_LIN, GX_LINEAR, + 0.0f, 10.0f, 0.0f, 0, GX_ENABLE, GX_ANISO_4); + break; + default: + GX_InitTexObjLOD(&texobj_a, GX_NEAR, GX_NEAR, + 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); + } + GX_LoadTexObj(&texobj_a, GX_TEXMAP0); // load texture object so its ready to use +} + +#endif /* SDL_VIDEO_DRIVER_OGC */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcgxcommon.h b/src/video/ogc/SDL_ogcgxcommon.h new file mode 100644 index 0000000000..1b2ed5b321 --- /dev/null +++ b/src/video/ogc/SDL_ogcgxcommon.h @@ -0,0 +1,39 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifndef SDL_ogcgxcommon_h_ +#define SDL_ogcgxcommon_h_ + +#include "SDL_render.h" + +#include + +#define GX_COLOR_AS_U32(c) *((u32*)&c) + +void OGC_draw_init(int w, int h); +void OGC_set_viewport(int x, int y, int w, int h); +void OGC_load_texture(void *texels, int w, int h, u8 gx_format, + SDL_ScaleMode scale_mode); + +#endif /* SDL_ogcgxcommon_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogckeyboard.c b/src/video/ogc/SDL_ogckeyboard.c new file mode 100644 index 0000000000..1ebf0f8fc5 --- /dev/null +++ b/src/video/ogc/SDL_ogckeyboard.c @@ -0,0 +1,59 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_ogckeyboard.h" +#include "../../events/SDL_keyboard_c.h" + +#if defined(SDL_VIDEO_DRIVER_OGC) && defined(__wii__) +#include +#include + +void OGC_PumpKeyboardEvents(_THIS) { + keyboard_event ke; + + s32 res = KEYBOARD_GetEvent(&ke); + if (res && (ke.type == KEYBOARD_RELEASED || ke.type == KEYBOARD_PRESSED)) { + SDL_SendKeyboardKey((ke.type == KEYBOARD_PRESSED) ? SDL_PRESSED : SDL_RELEASED, (SDL_Scancode)ke.keycode); + + if (ke.type == KEYBOARD_PRESSED) { + const Uint16 symbol = ke.symbol; + char utf8[4] = {'\0'}; + + /* ignore private symbols, used by wiikeyboard for special keys */ + if ((symbol >= 0xE000 && symbol <= 0xF8FF) || symbol == 0xFFFF) + return; + + /* convert UCS-2 to UTF-8 */ + if (symbol < 0x80) { + utf8[0] = symbol; + } else if (symbol < 0x800) { + utf8[0] = 0xC0 | (symbol >> 6); + utf8[1] = 0x80 | (symbol & 0x3F); + } else { + utf8[0] = 0xE0 | (symbol >> 12); + utf8[1] = 0x80 | ((symbol >> 6) & 0x3F); + utf8[2] = 0x80 | (symbol & 0x3F); + } + + SDL_SendKeyboardText(utf8); + } + } +} +#endif diff --git a/src/video/ogc/SDL_ogckeyboard.h b/src/video/ogc/SDL_ogckeyboard.h new file mode 100644 index 0000000000..ca8c0464df --- /dev/null +++ b/src/video/ogc/SDL_ogckeyboard.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_OGC_keyboard_h_ +#define SDL_OGC_keyboard_h_ + +#include "../../SDL_internal.h" +#include "SDL_ogcvideo.h" + +#ifdef __wii__ +void OGC_PumpKeyboardEvents(_THIS); +#endif + +#endif /* SDL_OGC_keyboard_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcmouse.c b/src/video/ogc/SDL_ogcmouse.c new file mode 100644 index 0000000000..6e3bda2565 --- /dev/null +++ b/src/video/ogc/SDL_ogcmouse.c @@ -0,0 +1,416 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_OGC) && defined(__wii__) + +#include "SDL_surface.h" +#include "SDL_hints.h" + +#include "SDL_ogccursors.h" +#include "SDL_ogcgxcommon.h" +#include "SDL_ogcmouse.h" +#include "SDL_ogcpixels.h" + +#include "../SDL_sysvideo.h" +#include "../../render/SDL_sysrender.h" + +#include +#include +#include +#include +#include +#include +#include + +typedef struct _OGC_CursorData +{ + void *texels; + int hot_x, hot_y; + int w, h; +} OGC_CursorData; + +typedef struct +{ + void *texels; + int16_t x, y; + uint16_t w, h, maxside; +} OGC_CursorBackground; + +static OGC_CursorBackground s_cursor_background; +static int s_draw_counter = 0; +static bool s_extra_draw_enabled = false; +static bool s_2d_viewport_setup = false; + +static void draw_rect(s16 x, s16 y, u16 w, u16 h) +{ + GX_Begin(GX_QUADS, GX_VTXFMT0, 4); + GX_Position2s16(x, y); + GX_TexCoord2u8(0, 0); + GX_Position2s16(x + w, y); + GX_TexCoord2u8(1, 0); + GX_Position2s16(x + w, h + y); + GX_TexCoord2u8(1, 1); + GX_Position2s16(x, h + y); + GX_TexCoord2u8(0, 1); + GX_End(); +} + +static void draw_cursor_rect(OGC_CursorData *curdata) +{ + draw_rect(-curdata->hot_x, -curdata->hot_y, curdata->w, curdata->h); +} + +static void setup_2d_viewport(_THIS) +{ + int screen_w, screen_h; + + if (s_2d_viewport_setup) return; + + screen_w = _this->displays[0].current_mode.w; + screen_h = _this->displays[0].current_mode.h; + + OGC_set_viewport(0, 0, screen_w, screen_h); + + GX_ClearVtxDesc(); + GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); + GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_S16, 0); + GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_U8, 0); + GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); + + GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE); + GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); + GX_SetNumTevStages(1); + GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GX_SetZMode(GX_DISABLE, GX_ALWAYS, GX_FALSE); + GX_SetCullMode(GX_CULL_NONE); + GX_SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0); + + GX_SetNumTexGens(1); + GX_SetCurrentMtx(GX_PNMTX1); + + s_2d_viewport_setup = true; +} + +/* Create a cursor from a surface */ +static SDL_Cursor *OGC_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) +{ + OGC_CursorData *curdata; + SDL_Cursor *cursor; + u32 texture_size; + SDL_Rect rect; + + SDL_assert(surface->pitch == surface->w * 4); + + cursor = SDL_calloc(1, sizeof(*cursor)); + if (!cursor) { + SDL_OutOfMemory(); + return NULL; + } + + curdata = SDL_calloc(1, sizeof(*curdata)); + if (!curdata) { + SDL_OutOfMemory(); + SDL_free(cursor); + return NULL; + } + + curdata->hot_x = hot_x; + curdata->hot_y = hot_y; + curdata->w = surface->w; + curdata->h = surface->h; + + texture_size = GX_GetTexBufferSize(surface->w, surface->h, GX_TF_RGBA8, + GX_FALSE, 0); + curdata->texels = memalign(32, texture_size); + if (!curdata->texels) { + SDL_OutOfMemory(); + SDL_free(curdata); + SDL_free(cursor); + return NULL; + } + + rect.x = rect.y = 0; + rect.w = surface->w; + rect.h = surface->h; + OGC_pixels_to_texture(surface->pixels, surface->format->format, &rect, + surface->pitch, curdata->texels, surface->w); + DCStoreRange(curdata->texels, texture_size); + GX_InvalidateTexAll(); + + cursor->driverdata = curdata; + + return cursor; +} + +SDL_Cursor *OGC_CreateSystemCursor(SDL_SystemCursor id) +{ + const OGC_Cursor *cursor; + SDL_Surface *surface; + SDL_Cursor *c; + + switch (id) { + case SDL_SYSTEM_CURSOR_ARROW: + cursor = &OGC_cursor_arrow; + break; + case SDL_SYSTEM_CURSOR_HAND: + cursor = &OGC_cursor_hand; + break; + default: + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "System cursor %d not implemented", id); + return NULL; + } + surface = + SDL_CreateRGBSurfaceWithFormatFrom((void*)cursor->pixel_data, + cursor->width, + cursor->height, + cursor->bytes_per_pixel * 8, + cursor->width * cursor->bytes_per_pixel, + SDL_PIXELFORMAT_RGBA8888); + c = OGC_CreateCursor(surface, cursor->hot_x, cursor->hot_y); + SDL_FreeSurface(surface); + return c; +} + +/* Free a window manager cursor */ +static void OGC_FreeCursor(SDL_Cursor *cursor) +{ + OGC_CursorData *curdata = cursor->driverdata; + + if (curdata) { + if (curdata->texels) { + free(curdata->texels); + } + SDL_free(curdata); + } + + SDL_free(cursor); +} + +void OGC_InitMouse(_THIS) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->CreateCursor = OGC_CreateCursor; + mouse->CreateSystemCursor = OGC_CreateSystemCursor; + mouse->FreeCursor = OGC_FreeCursor; + + SDL_SetDefaultCursor(OGC_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND)); +} + +void OGC_QuitMouse(_THIS) +{ +} + +void OGC_draw_cursor(_THIS) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + OGC_CursorData *curdata; + Mtx mv; + int screen_w, screen_h; + float angle = 0.0f; + + s_draw_counter++; + + /* mark the texture as invalid */ + s_cursor_background.x = SHRT_MIN; + + if (!mouse || !mouse->cursor_shown || + !mouse->cur_cursor || !mouse->cur_cursor->driverdata) { + return; + } + + /* If this is the default cursor, rotate it, and if it's not pointed at the + * screen, hide it */ + if (mouse->cur_cursor == mouse->def_cursor) { + WPADData *data = WPAD_Data(mouse->mouseID); + angle = data->ir.angle; + if (!data->ir.valid) return; + } + + screen_w = _this->displays[0].current_mode.w; + screen_h = _this->displays[0].current_mode.h; + + curdata = mouse->cur_cursor->driverdata; + + if (s_extra_draw_enabled) { + /* Save the are behind the cursor. We could use GX_ReadBoundingBox() to + * figure out which area to save, but that would require calling the + * drawing function once mode. So, let's just take a guess at the area, + * taking into account possible cursor rotation. */ + s16 x, y; + u16 w, h, radius, side; + u32 texture_size; + + /* +1 is for the rounding of x and y */ + radius = MAX(curdata->w, curdata->h) + 1; + x = mouse->x - radius; + y = mouse->y - radius; + /* x and y must be multiples of 2 */ + if (x % 2) x--; + if (y % 2) y--; + w = h = side = radius * 2; + if (x < 0) { + w += x; + x = 0; + } else if (x + w > screen_w) { + w = screen_w - x; + } + + if (y < 0) { + h += y; + y = 0; + } else if (y + h > screen_h) { + h = screen_h - y; + } + + /* Make sure all our variables are properly aligned */ + while (side % 4) side++; + while (w % 4) w++; + while (h % 4) h++; + + if (w > 0 && h > 0) { + texture_size = GX_GetTexBufferSize(side, side, GX_TF_RGBA8, + GX_FALSE, 0); + if (!s_cursor_background.texels || side > s_cursor_background.maxside) { + free(s_cursor_background.texels); + s_cursor_background.texels = memalign(32, texture_size); + s_cursor_background.maxside = side; + } + DCInvalidateRange(s_cursor_background.texels, texture_size); + GX_SetTexCopySrc(x, y, w, h); + GX_SetTexCopyDst(w, h, GX_TF_RGBA8, GX_FALSE); + GX_CopyTex(s_cursor_background.texels, GX_FALSE); + s_cursor_background.x = x; + s_cursor_background.y = y; + s_cursor_background.w = w; + s_cursor_background.h = h; + } + } + + OGC_load_texture(curdata->texels, curdata->w, curdata->h, GX_TF_RGBA8, + SDL_ScaleModeNearest); + + guMtxIdentity(mv); + guMtxScaleApply(mv, mv, screen_w / 640.0f, screen_h / 480.0f, 1.0f); + if (angle != 0.0f) { + Mtx rot; + guMtxRotDeg(rot, 'z', angle); + guMtxConcat(mv, rot, mv); + } + guMtxTransApply(mv, mv, mouse->x, mouse->y, 0); + GX_LoadPosMtxImm(mv, GX_PNMTX1); + + setup_2d_viewport(_this); + + draw_cursor_rect(curdata); + GX_DrawDone(); +} + +void OGC_restore_viewport(_THIS) +{ + /* Restore default state for SDL (opengx restores it at every frame, so we + * don't care about it) */ + s_2d_viewport_setup = false; + GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); + GX_SetCurrentMtx(GX_PNMTX0); + if (_this->windows) { + /* Restore previous viewport for the renderer */ + SDL_Renderer *renderer = SDL_GetRenderer(_this->windows); + if (renderer) { + OGC_set_viewport(renderer->viewport.x, renderer->viewport.y, + renderer->viewport.w, renderer->viewport.h); + } + } +} + +bool OGC_prep_draw_cursor(_THIS) +{ + GXTexObj background; + Mtx mv; + static u32 last_draw_ms = 0; + u32 current_time_ms, elapsed_ms; + static int call_counter = 0; + static int last_draw_counter = 0; + + /* Ignore calls when a render target is set or OpenGL is not ready to swap + * the framebuffer */ + SDL_Renderer *renderer = SDL_GetRenderer(_this->windows); + if (renderer && renderer->target) return false; + + if (_this->gl_config.driver_loaded && + ogx_prepare_swap_buffers() < 0) return false; + + /* If this function is called repeatedly during the same frame, we assume + * that this is one of those applications that call SDL_OGC_GL_SwapWindow, + * SDL_UpdateWindowSurface or SDL_RenderPresent only if the video contents + * have actually changed. + * If that's the case, we toggle a flag that makes us redraw the screen + * when the mouse position has changed. + */ + if (!s_extra_draw_enabled) { + if (last_draw_counter != s_draw_counter) { + call_counter = 1; + last_draw_counter = s_draw_counter; + return false; + } + + if (call_counter++ > 10) { + s_extra_draw_enabled = true; + } else { + return false; + } + } + + /* Avoid drawing too often. 30 FPS should be enough */ + current_time_ms = gettime() / TB_TIMER_CLOCK; + elapsed_ms = current_time_ms - last_draw_ms; + if (elapsed_ms < 33) return false; + + /* If we have a texture for the cursor background, restore it; otherwise, + * we shouldn't draw the cursor. */ + if (!s_cursor_background.texels) return false; + + if (s_cursor_background.x != SHRT_MIN) { + setup_2d_viewport(_this); + + GX_PixModeSync(); + GX_InitTexObj(&background, s_cursor_background.texels, + s_cursor_background.w, s_cursor_background.h, + GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); + GX_InitTexObjLOD(&background, GX_NEAR, GX_NEAR, + 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); + GX_LoadTexObj(&background, GX_TEXMAP0); + GX_InvalidateTexAll(); + + guMtxIdentity(mv); + GX_LoadPosMtxImm(mv, GX_PNMTX1); + draw_rect(s_cursor_background.x, s_cursor_background.y, + s_cursor_background.w, s_cursor_background.h); + last_draw_ms = current_time_ms; + } + return true; +} +#endif /* SDL_VIDEO_DRIVER_OGC */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcmouse.h b/src/video/ogc/SDL_ogcmouse.h new file mode 100644 index 0000000000..aa9ff173fe --- /dev/null +++ b/src/video/ogc/SDL_ogcmouse.h @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_OGC_mouse_h_ +#define SDL_OGC_mouse_h_ + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_mouse_c.h" + +void OGC_InitMouse(_THIS); +void OGC_QuitMouse(_THIS); +void OGC_draw_cursor(_THIS); +void OGC_restore_viewport(_THIS); +bool OGC_prep_draw_cursor(_THIS); +SDL_Cursor *OGC_CreateSystemCursor(SDL_SystemCursor id); + +#endif /* SDL_OGC_mouse_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcpixels.c b/src/video/ogc/SDL_ogcpixels.c new file mode 100644 index 0000000000..2d87b40d95 --- /dev/null +++ b/src/video/ogc/SDL_ogcpixels.c @@ -0,0 +1,355 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#include "SDL_ogcpixels.h" + +#include + +#define PIXELS_TO_TEXTURE_32(format_func) \ + static void pixels_to_texture_ ## format_func( \ + void *pixels, const SDL_Rect *rect, int16_t pitch, void *texture, int16_t tex_width) \ + { \ + int16_t tex_pitch = (tex_width + 3) / 4 * 4; \ + for (int row = 0; row < rect->h; row++) { \ + int y = rect->y + row; \ + u32 *src = (u32 *)((u8 *)pixels + pitch * row); \ + for (int col = 0; col < rect->w; col++) { \ + int x = rect->x + col; \ + u32 offset = (((y >> 2) << 4) * tex_pitch) + \ + ((x >> 2) << 6) + (((y % 4 << 2) + x % 4) << 1); \ + set_pixel_to_texture_ ## format_func(texture, offset, *src++); \ + } \ + } \ + } + +#define PIXELS_FROM_TEXTURE_32(format_func) \ + static void pixels_from_texture_ ## format_func( \ + void *pixels, int16_t w, int16_t h, int16_t pitch, void *texture) \ + { \ + int tex_width = (w + 3) / 4 * 4; \ + for (int y = 0; y < h; y++) { \ + u32 *dst = (u32 *)((u8 *)pixels + pitch * y); \ + for (int x = 0; x < w; x++) { \ + u32 offset = (((y >> 2) << 4) * tex_width) + \ + ((x >> 2) << 6) + (((y % 4 << 2) + x % 4) << 1); \ + *dst++ = get_pixel_from_texture_ ## format_func(texture, offset); \ + } \ + } \ + } + +static u8 texture_format_from_SDL(const SDL_PixelFormatEnum format) +{ + switch (format) { + case SDL_PIXELFORMAT_INDEX8: + return GX_TF_CI8; + case SDL_PIXELFORMAT_RGB565: + return GX_TF_RGB565; + case SDL_PIXELFORMAT_RGB24: + case SDL_PIXELFORMAT_RGBA8888: + case SDL_PIXELFORMAT_ARGB8888: + case SDL_PIXELFORMAT_XRGB8888: + return GX_TF_RGBA8; + default: + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, + "(texture_format_from_SDL) Unsupported SDL pixel format %d", + format); + } + return 0xff; // invalid +} + +static inline void set_pixel_to_texture_ARGB(void *texture, u32 offset, u32 color) +{ + *(u16*)(texture + offset) = color >> 16; + *(u16*)(texture + offset + 32) = color; +} + +static inline u32 get_pixel_from_texture_ARGB(void *texture, u32 offset) +{ + return *(u16*)(texture + offset) << 16 | + *(u16*)(texture + offset + 32); +} + +static inline void set_pixel_to_texture_RGBA(void *texture, u32 offset, u32 color) +{ + set_pixel_to_texture_ARGB(texture, offset, (color << 24) | (color >> 8)); +} + +static inline u32 get_pixel_from_texture_32(int x, int y, void *texture, int tex_width) +{ + u8 *tex = texture; + u32 offset; + + offset = (((y >> 2) << 4) * tex_width) + ((x >> 2) << 6) + (((y % 4 << 2) + x % 4) << 1); + + return *(tex + offset) | + *(tex + offset + 1) << 24 | + *(tex + offset + 32) << 16 | + *(tex + offset + 33) << 8; +} + +PIXELS_TO_TEXTURE_32(RGBA) + +static void pixels_RGBA_from_texture(void *pixels, int16_t w, int16_t h, + int16_t pitch, void *texture) +{ + u32 *dst = pixels; + + int tex_width = (w + 3) / 4 * 4; + for (int y = 0; y < h; y++) { + dst = (u32 *)((u8 *)pixels + pitch * y); + for (int x = 0; x < w; x++) { + *dst++ = get_pixel_from_texture_32(x, y, texture, tex_width); + } + } +} + +PIXELS_TO_TEXTURE_32(ARGB) +PIXELS_FROM_TEXTURE_32(ARGB) + +static inline void set_pixel_to_texture_XRGB(void *texture, u32 offset, u32 color) +{ + set_pixel_to_texture_ARGB(texture, offset, 0xff000000 | color); +} + +PIXELS_TO_TEXTURE_32(XRGB) + +static void pixels_XRGB_from_texture(void *pixels, int16_t w, int16_t h, + int16_t pitch, void *texture) +{ + u32 *dst = pixels; + + int tex_width = (w + 3) / 4 * 4; + for (int y = 0; y < h; y++) { + dst = (u32 *)((u8 *)pixels + pitch * y); + for (int x = 0; x < w; x++) { + *dst++ = get_pixel_from_texture_32(x, y, texture, tex_width) >> 8; + } + } +} + +static void pixels_RGB_to_texture(void *pixels, const SDL_Rect *rect, + int16_t pitch, void *texture, int16_t tex_width) +{ + u8 *src = pixels; + + int tex_pitch = (tex_width + 3) / 4 * 4; + for (int row = 0; row < rect->h; row++) { + int y = rect->y + row; + src = (u8 *)pixels + pitch * row; + for (int col = 0; col < rect->w; col++) { + int x = rect->x + col; + u32 offset = (((y >> 2) << 4) * tex_pitch) + + ((x >> 2) << 6) + (((y % 4 << 2) + x % 4) << 1); + u8 r = *src++; + u8 g = *src++; + u8 b = *src++; + set_pixel_to_texture_ARGB(texture, offset, 0xff000000 | r << 16 | g << 8 | b); + } + } +} + +static void pixels_RGB_from_texture(void *pixels, int16_t w, int16_t h, + int16_t pitch, void *texture) +{ + u8 *dst = pixels; + + int tex_width = (w + 3) / 4 * 4; + for (int y = 0; y < h; y++) { + dst = (u8 *)pixels + pitch * y; + for (int x = 0; x < w; x++) { + u32 color = get_pixel_from_texture_32(x, y, texture, tex_width); + *dst++ = color >> 24; + *dst++ = color >> 16; + *dst++ = color >> 8; + } + } +} + +static void pixels_16_to_texture(void *pixels, const SDL_Rect *rect, int16_t pitch, + void *texture, int16_t tex_width) +{ + /* We only support coordinates multiple of 4. While we don't add support + * for arbitrary coordinates (TODO), let's restrict the paint area to the + * full 4x4 cells covered by the rect. In the future we can add code to + * fill up the remaining borders. */ + int x0 = (rect->x + 3) & ~0x3; + int x1 = (rect->x + rect->w) & ~0x3; + int y0 = (rect->y + 3) & ~0x3; + int y1 = (rect->y + rect->h) & ~0x3; + int skipped_bytes_left = (x0 - rect->x) * 2; + int tex_pitch = tex_width * 2; + + + for (int row = 0; row < y1 - y0; row += 4) { + u64 *src1 = pixels + (skipped_bytes_left + row * pitch); + u64 *src2 = (void*)src1 + (pitch * 1); + u64 *src3 = (void*)src1 + (pitch * 2); + u64 *src4 = (void*)src1 + (pitch * 3); + u64 *dst = texture + (x0 * 8 + (y0 + row) * tex_pitch); + for (int col = x0; col < x1; col += 4) { + *dst++ = *src1++; + *dst++ = *src2++; + *dst++ = *src3++; + *dst++ = *src4++; + } + } +} + +static void pixels_16_from_texture(void *pixels, int16_t pitch, int16_t h, + void *texture) +{ + long long int *src = texture; + long long int *dst1 = pixels; + long long int *dst2 = (long long int *)((char *)pixels + (pitch * 1)); + long long int *dst3 = (long long int *)((char *)pixels + (pitch * 2)); + long long int *dst4 = (long long int *)((char *)pixels + (pitch * 3)); + int rowpitch = (pitch >> 3) * 3; + + for (int y = 0; y < h; y += 4) { + for (int x = 0; x < pitch; x += 8) { + *dst1++ = *src++; + *dst2++ = *src++; + *dst3++ = *src++; + *dst4++ = *src++; + } + + dst1 = dst4; + dst2 += rowpitch; + dst3 += rowpitch; + dst4 += rowpitch; + } +} + +static inline void set_pixel_8_to_texture(int x, int y, u8 color, void *texture, int tex_width) +{ + u8 *tex = texture; + u32 offset; + + offset = ((y & ~3) * tex_width) + ((x & ~7) << 2) + ((y & 3) << 3) + (x & 7); + + tex[offset] = color; +} + +static inline u8 get_pixel_8_from_texture(int x, int y, void *texture, int tex_width) +{ + u8 *tex = texture; + u32 offset; + + offset = ((y & ~3) * tex_width) + ((x & ~7) << 2) + ((y & 3) << 3) + (x & 7); + + return tex[offset]; +} + +static void pixels_8_to_texture(void *pixels, int16_t w, int16_t h, + int16_t pitch, void *texture) +{ + u8 *src = pixels; + int tex_width = (w + 7) / 8 * 8; + + for (int y = 0; y < h; y++) { + src = (u8 *)pixels + pitch * y; + for (int x = 0; x < w; x++) { + set_pixel_8_to_texture(x, y, *src++, texture, tex_width); + } + } +} + +static void pixels_8_from_texture(void *pixels, int16_t w, int16_t h, + int16_t pitch, void *texture) +{ + u8 *dst = pixels; + int tex_width = (w + 7) / 8 * 8; + + for (int y = 0; y < h; y++) { + dst = (u8 *)pixels + pitch * y; + for (int x = 0; x < w; x++) { + *dst++ = get_pixel_8_from_texture(x, y, texture, tex_width); + } + } +} + +void OGC_pixels_to_texture(void *pixels, const SDL_PixelFormatEnum format, + const SDL_Rect *rect, int16_t pitch, + void *texture, int16_t tex_width) +{ + switch (format) { + case SDL_PIXELFORMAT_INDEX8: + pixels_8_to_texture(pixels, rect->w, rect->h, pitch, texture); + break; + case SDL_PIXELFORMAT_RGB565: + pixels_16_to_texture(pixels, rect, pitch, texture, tex_width); + break; + case SDL_PIXELFORMAT_RGB24: + pixels_RGB_to_texture(pixels, rect, pitch, texture, tex_width); + break; + case SDL_PIXELFORMAT_RGBA8888: + pixels_to_texture_RGBA(pixels, rect, pitch, texture, tex_width); + break; + case SDL_PIXELFORMAT_ARGB8888: + pixels_to_texture_ARGB(pixels, rect, pitch, texture, tex_width); + break; + case SDL_PIXELFORMAT_XRGB8888: + pixels_to_texture_XRGB(pixels, rect, pitch, texture, tex_width); + break; + default: + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, + "ptt: unsupported SDL pixel format %d", format); + // TODO support more formats + } +} + +void OGC_pixels_from_texture(void *pixels, const SDL_PixelFormatEnum format, + int16_t w, int16_t h, int16_t pitch, + void *texture) +{ + switch (format) { + case SDL_PIXELFORMAT_INDEX8: + pixels_8_from_texture(pixels, w, h, pitch, texture); + break; + case SDL_PIXELFORMAT_RGB565: + pixels_16_from_texture(pixels, pitch, h, texture); + break; + case SDL_PIXELFORMAT_RGB24: + pixels_RGB_from_texture(pixels, w, h, pitch, texture); + break; + case SDL_PIXELFORMAT_RGBA8888: + pixels_RGBA_from_texture(pixels, w, h, pitch, texture); + break; + case SDL_PIXELFORMAT_ARGB8888: + pixels_from_texture_ARGB(pixels, w, h, pitch, texture); + break; + case SDL_PIXELFORMAT_XRGB8888: + pixels_XRGB_from_texture(pixels, w, h, pitch, texture); + break; + default: + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, + "pft: unsupported SDL pixel format %d", format); + // TODO support more formats + } +} + +u8 OGC_texture_format_from_SDL(const SDL_PixelFormatEnum format) +{ + return texture_format_from_SDL(format); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcpixels.h b/src/video/ogc/SDL_ogcpixels.h new file mode 100644 index 0000000000..c92d032aa4 --- /dev/null +++ b/src/video/ogc/SDL_ogcpixels.h @@ -0,0 +1,42 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifndef SDL_ogcpixels_h_ +#define SDL_ogcpixels_h_ + +#include "SDL_pixels.h" +#include "SDL_rect.h" + +#include + +void OGC_pixels_to_texture(void *pixels, SDL_PixelFormatEnum format, + const SDL_Rect *rect, int16_t pitch, + void *texels, int16_t tex_width); +void OGC_pixels_from_texture(void *pixels, SDL_PixelFormatEnum format, + int16_t w, int16_t h, int16_t pitch, + void *texels); + +u8 OGC_texture_format_from_SDL(const SDL_PixelFormatEnum format); + +#endif /* SDL_ogcpixels_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcvideo.c b/src/video/ogc/SDL_ogcvideo.c new file mode 100644 index 0000000000..5653700f73 --- /dev/null +++ b/src/video/ogc/SDL_ogcvideo.c @@ -0,0 +1,380 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_OGC + +#include "../../events/SDL_events_c.h" +#include "../SDL_pixels_c.h" +#include "../SDL_sysvideo.h" +#include "SDL_mouse.h" +#include "SDL_video.h" + +#include "SDL_hints.h" +#include "SDL_ogcevents_c.h" +#include "SDL_ogcframebuffer_c.h" +#include "SDL_ogcgl.h" +#include "SDL_ogcgxcommon.h" +#include "SDL_ogcmouse.h" +#include "SDL_ogcvideo.h" + +#include +#include +#include +#include +#include + +#include + +#define DEFAULT_FIFO_SIZE 256 * 1024 + +// Inverse of the VI_TVMODE macro +#define VI_FORMAT_FROM_MODE(tvmode) (tvmode >> 2) + +/* A video mode with a 320 width; we'll build it programmatically. */ +static GXRModeObj s_mode320; + +static const GXRModeObj *s_ntsc_modes[] = { + &TVNtsc240Ds, + &TVNtsc480Prog, + NULL, +}; + +static const GXRModeObj *s_mpal_modes[] = { + &TVMpal240Ds, + &TVMpal480Prog, + NULL, +}; + +static const GXRModeObj *s_eurgb60_modes[] = { + &TVEurgb60Hz240Ds, + &TVEurgb60Hz480Prog, + // Also add some PAL modes, since EURGB60 supports them too + &TVPal264Ds, + &TVPal528Prog, + &TVPal576ProgScale, + NULL, +}; + +static const GXRModeObj *s_pal_modes[] = { + &TVPal264Ds, + &TVPal528Prog, + &TVPal576ProgScale, + NULL, +}; + +/* Initialization/Query functions */ +static int OGC_VideoInit(_THIS); +static void OGC_VideoQuit(_THIS); + +static void init_display_mode(SDL_DisplayMode *mode, const GXRModeObj *vmode) +{ + u32 format = VI_FORMAT_FROM_MODE(vmode->viTVMode); + + /* Use a fake 32-bpp desktop mode */ + SDL_zero(*mode); + mode->format = SDL_PIXELFORMAT_ARGB8888; + mode->w = vmode->fbWidth; + mode->h = vmode->efbHeight; + switch (format) { + case VI_DEBUG: + case VI_NTSC: + case VI_EURGB60: + case VI_MPAL: + mode->refresh_rate = 60; + break; + case VI_PAL: + case VI_DEBUG_PAL: + mode->refresh_rate = 50; + break; + } + mode->driverdata = (GXRModeObj*)vmode; +} + +static void add_supported_modes(SDL_VideoDisplay *display, u32 tv_format) +{ + const GXRModeObj **gx_modes; + SDL_DisplayMode mode; + + switch (tv_format) { + case VI_DEBUG: + case VI_NTSC: + gx_modes = s_ntsc_modes; + break; + case VI_MPAL: + gx_modes = s_mpal_modes; + break; + case VI_EURGB60: + gx_modes = s_eurgb60_modes; + break; + case VI_PAL: + case VI_DEBUG_PAL: + gx_modes = s_pal_modes; + break; + default: + return; + } + + /* All libogc video modes are 640 pixel wide, even the 240p ones. While + * this can be useful for some applications, others might prefer a video + * mode with less elongated pixels, such as 320x240. Therefore, let's + * create one: we take the first video mode in the array (which has always + * a height of approximately 240p) and we use it as template to build the + * "mode320": we just set the fbWidth field to 320: the VI interface will + * take care of the horizontal scale for us. */ + memcpy(&s_mode320, gx_modes[0], sizeof(s_mode320)); + s_mode320.fbWidth = 320; + init_display_mode(&mode, &s_mode320); + SDL_AddDisplayMode(display, &mode); + + /* Now add all the "standard" modes from libogc */ + while (*gx_modes) { + init_display_mode(&mode, *gx_modes); + SDL_AddDisplayMode(display, &mode); + gx_modes++; + } +} + +static void setup_video_mode(_THIS, GXRModeObj *vmode) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; + + VIDEO_SetBlack(true); + VIDEO_Configure(vmode); + + /* Allocate the XFB */ + videodata->xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode)); + videodata->xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode)); + + VIDEO_ClearFrameBuffer(vmode, videodata->xfb[0], COLOR_BLACK); + VIDEO_SetNextFramebuffer(videodata->xfb[0]); + VIDEO_SetBlack(false); + VIDEO_Flush(); + + VIDEO_WaitVSync(); + if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); + + /* Setup the EFB -> XFB copy operation */ + GX_SetDispCopySrc(0, 0, vmode->fbWidth, vmode->efbHeight); + GX_SetDispCopyDst(vmode->fbWidth, vmode->xfbHeight); + GX_SetDispCopyYScale((f32)vmode->xfbHeight / (f32)vmode->efbHeight); + GX_SetCopyFilter(vmode->aa, vmode->sample_pattern, GX_FALSE, vmode->vfilter); + GX_SetFieldMode(vmode->field_rendering, + ((vmode->viHeight == 2 * vmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); + + OGC_draw_init(vmode->fbWidth, vmode->efbHeight); +} + +static int OGC_SetDisplayMode(_THIS, SDL_VideoDisplay *display, + SDL_DisplayMode *mode) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; + /* The GX video mode is stored in the driverdata pointer */ + GXRModeObj *vmode = mode->driverdata; + + if (videodata->xfb[0]) + free(MEM_K1_TO_K0(videodata->xfb[0])); + if (videodata->xfb[1]) + free(MEM_K1_TO_K0(videodata->xfb[1])); + + setup_video_mode(_this, vmode); + return 0; +} + +static void OGC_ShowWindow(_THIS, SDL_Window *window) +{ + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); +} + +static int OGC_ShowMessageBox(_THIS, const SDL_MessageBoxData *messageboxdata, + int *buttonid) +{ + /* Unimplemented, but at least show the message in the log */ + SDL_SetError("ShowMessageBox unimplemented: \"%s\", \"%s\"", + messageboxdata->title, messageboxdata->message); + return 0; +} + +/* OGC driver bootstrap functions */ + +static void OGC_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_free(device->driverdata); + SDL_free(device); +} + +static SDL_VideoDevice *OGC_CreateDevice(void) +{ + SDL_VideoDevice *device; + SDL_VideoData *videodata; + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + SDL_OutOfMemory(); + return NULL; + } + + videodata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); + if (!videodata) { + SDL_OutOfMemory(); + SDL_free(device); + return NULL; + } + + device->driverdata = videodata; + + /* Set the function pointers */ + device->VideoInit = OGC_VideoInit; + device->VideoQuit = OGC_VideoQuit; + device->SetDisplayMode = OGC_SetDisplayMode; + device->PumpEvents = OGC_PumpEvents; + device->ShowWindow = OGC_ShowWindow; + device->CreateWindowFramebuffer = SDL_OGC_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = SDL_OGC_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = SDL_OGC_DestroyWindowFramebuffer; + device->ShowMessageBox = OGC_ShowMessageBox; + +#ifdef SDL_VIDEO_OPENGL + device->GL_LoadLibrary = SDL_OGC_GL_LoadLibrary; + device->GL_GetProcAddress = SDL_OGC_GL_GetProcAddress; + device->GL_UnloadLibrary = SDL_OGC_GL_UnloadLibrary; + device->GL_CreateContext = SDL_OGC_GL_CreateContext; + device->GL_MakeCurrent = SDL_OGC_GL_MakeCurrent; + device->GL_SetSwapInterval = SDL_OGC_GL_SetSwapInterval; + device->GL_GetSwapInterval = SDL_OGC_GL_GetSwapInterval; + device->GL_SwapWindow = SDL_OGC_GL_SwapWindow; + device->GL_DeleteContext = SDL_OGC_GL_DeleteContext; + device->GL_DefaultProfileConfig = SDL_OGC_GL_DefaultProfileConfig; +#endif + + device->free = OGC_DeleteDevice; + + return device; +} + +VideoBootStrap OGC_bootstrap = { + "ogc-video", "ogc video driver", + OGC_CreateDevice +}; + +int OGC_VideoInit(_THIS) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; + SDL_DisplayMode mode; + GXRModeObj *vmode; + static const GXColor background = { 0, 0, 0, 255 }; + + VIDEO_Init(); + + vmode = VIDEO_GetPreferredMode(NULL); + + videodata->gp_fifo = memalign(32, DEFAULT_FIFO_SIZE); + memset(videodata->gp_fifo, 0, DEFAULT_FIFO_SIZE); + GX_Init(videodata->gp_fifo, DEFAULT_FIFO_SIZE); + + setup_video_mode(_this, vmode); + GX_SetCopyClear(background, GX_MAX_Z24); + + GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); + GX_SetCullMode(GX_CULL_NONE); + GX_SetBlendMode(GX_BM_NONE, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + + GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); + + GX_Flush(); + + init_display_mode(&mode, vmode); + if (SDL_AddBasicVideoDisplay(&mode) < 0) { + return -1; + } + + SDL_AddDisplayMode(&_this->displays[0], &mode); + add_supported_modes(&_this->displays[0], VI_FORMAT_FROM_MODE(vmode->viTVMode)); + + videodata->vmode = vmode; + +#ifdef __wii__ + OGC_InitMouse(_this); +#endif + return 0; +} + +void OGC_VideoQuit(_THIS) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; + SDL_VideoDisplay *display; + +#ifdef __wii__ + OGC_QuitMouse(_this); +#endif + + SDL_free(videodata->gp_fifo); + if (videodata->xfb[0]) + free(MEM_K1_TO_K0(videodata->xfb[0])); + if (videodata->xfb[1]) + free(MEM_K1_TO_K0(videodata->xfb[1])); + + /* During shutdown, SDL_ResetDisplayModes() will be called and will invoke + * SDL_free() on driverdata. Nullify the pointers in order to avoid a + * crash, since we didn't actually allocate this memory. */ + display = &_this->displays[0]; + for (int i = display->num_display_modes; i--;) { + display->display_modes[i].driverdata = NULL; + } + display->desktop_mode.driverdata = NULL; +} + +void *OGC_video_get_xfb(_THIS) +{ + SDL_VideoData *videodata = _this->driverdata; + return videodata->xfb[videodata->fb_index]; +} + +void OGC_video_flip(_THIS, bool vsync) +{ + SDL_VideoData *videodata = _this->driverdata; + void *xfb = OGC_video_get_xfb(_this); + + if (_this->gl_config.driver_loaded && + ogx_prepare_swap_buffers() < 0) return; + +#ifdef __wii__ + OGC_draw_cursor(_this); + OGC_restore_viewport(_this); +#endif + GX_CopyDisp(xfb, GX_FALSE); + GX_DrawDone(); + GX_Flush(); + + VIDEO_SetNextFramebuffer(xfb); + VIDEO_Flush(); + if (vsync) { + VIDEO_WaitVSync(); + } + + videodata->fb_index ^= 1; +} + +#endif /* SDL_VIDEO_DRIVER_OGC */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/ogc/SDL_ogcvideo.h b/src/video/ogc/SDL_ogcvideo.h new file mode 100644 index 0000000000..3821d1966c --- /dev/null +++ b/src/video/ogc/SDL_ogcvideo.h @@ -0,0 +1,50 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2023 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifndef SDL_ogcvideo_h_ +#define SDL_ogcvideo_h_ + +#include "../SDL_sysvideo.h" + +#include + +typedef struct SDL_VideoData +{ + GXRModeObj *vmode; + u8 *gp_fifo; + void *xfb[2]; + u8 fb_index; +} SDL_VideoData; + +typedef struct SDL_WindowData +{ + void *pixels; + u8 *texels; + SDL_PixelFormatEnum surface_format; +} SDL_WindowData; + +void *OGC_video_get_xfb(SDL_VideoDevice *device); +void OGC_video_flip(SDL_VideoDevice *device, bool vsync); + +#endif /* SDL_ogcvideo_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 52a268561c..4cf924dd90 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -36,6 +36,10 @@ if(N3DS) link_libraries(SDL2::SDL2main) endif() +if(OGC) + link_libraries(SDL2::SDL2main) +endif() + if(PSP) link_libraries( SDL2::SDL2main ================================================ FILE: wii/SDL2_gfx/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: TurtleP pkgname=wii-sdl2_gfx pkgver=1.0.4 pkgrel=3 pkgdesc="SDL2 graphics drawing primitives." arch=('any') url="https://libsdl.org" license=("zlib") options=(!strip libtool staticlibs) makedepends=('wii-pkg-config' 'dkp-toolchain-vars') depends=('wii-sdl2') source=("http://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-1.0.4.tar.gz") groups=('wii-portlibs' 'wii-sdl2-libs') build() { cd SDL2_gfx-$pkgver source /opt/devkitpro/wiivars.sh ./configure --prefix="${PORTLIBS_PREFIX}" \ --enable-mmx=no \ --host=powerpc-eabi \ --disable-shared --enable-static \ --with-sdl-prefix=${PORTLIBS_PREFIX} make } package() { cd SDL2_gfx-$pkgver source /opt/devkitpro/wiivars.sh make DESTDIR="$pkgdir" install } sha256sums=('63e0e01addedc9df2f85b93a248f06e8a04affa014a835c2ea34bfe34e576262') ================================================ FILE: wii/SDL2_image/Makefile.in.patch ================================================ --- Makefile.in.orig 2018-10-31 09:59:00.000000000 -0500 +++ Makefile.in 2019-06-26 01:23:45.000000000 -0500 @@ -95,7 +95,6 @@ host_triplet = @host@ @USE_VERSION_RC_FALSE@libSDL2_image_la_DEPENDENCIES = \ @USE_VERSION_RC_FALSE@ $(am__DEPENDENCIES_1) -noinst_PROGRAMS = showimage$(EXEEXT) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude/libtool.m4 \ @@ -164,9 +163,6 @@ libSDL2_image_la_LINK = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(OBJCLD) $(AM_OBJCFLAGS) \ $(OBJCFLAGS) $(libSDL2_image_la_LDFLAGS) $(LDFLAGS) -o $@ -showimage_SOURCES = showimage.c -showimage_OBJECTS = showimage.$(OBJEXT) -showimage_DEPENDENCIES = libSDL2_image.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -476,7 +472,6 @@ @USE_VERSION_RC_TRUE@libSDL2_image_la_DEPENDENCIES = version.o pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = SDL2_image.pc -showimage_LDADD = libSDL2_image.la all: all-am .SUFFIXES: @@ -566,10 +561,6 @@ libSDL2_image.la: $(libSDL2_image_la_OBJECTS) $(libSDL2_image_la_DEPENDENCIES) $(EXTRA_libSDL2_image_la_DEPENDENCIES) $(AM_V_OBJCLD)$(libSDL2_image_la_LINK) -rpath $(libdir) $(libSDL2_image_la_OBJECTS) $(libSDL2_image_la_LIBADD) $(LIBS) -showimage$(EXEEXT): $(showimage_OBJECTS) $(showimage_DEPENDENCIES) $(EXTRA_showimage_DEPENDENCIES) - @rm -f showimage$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(showimage_OBJECTS) $(showimage_LDADD) $(LIBS) - mostlyclean-compile: -rm -f *.$(OBJEXT) ================================================ FILE: wii/SDL2_image/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Cpasjuste # Contributor: carstene1ns pkgname=wii-sdl2_image pkgver=2.8.2 pkgrel=1 pkgdesc="SDL2 image loading library." arch=('any') url="https://libsdl.org/projects/SDL_image/" license=("zlib") options=(!strip libtool staticlibs) makedepends=('wii-pkg-config' 'dkp-toolchain-vars') depends=( 'wii-sdl2' 'ppc-libpng' 'ppc-libjpeg-turbo' ) source=("${url}release/SDL2_image-${pkgver}.tar.gz") groups=('wii-portlibs' 'wii-sdl2-libs') build() { cd SDL2_image-$pkgver source ${DEVKITPRO}/wiivars.sh sed '/^noinst_PROGRAMS/d' -i Makefile.in ./configure --prefix="${PORTLIBS_PREFIX}" \ --host=powerpc-eabi --disable-shared --enable-static \ --disable-sdltest \ --with-sdl-prefix=${PORTLIBS_PREFIX} make } package() { cd SDL2_image-$pkgver source /opt/devkitpro/wiivars.sh make DESTDIR="$pkgdir" install # add our static libs echo "Requires.private: libpng libjpeg" >> "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/SDL2_image.pc" # License #install -Dm644 "COPYING.txt" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/COPYING.txt" } sha256sums=('8f486bbfbcf8464dd58c9e5d93394ab0255ce68b51c5a966a918244820a76ddc') ================================================ FILE: wii/SDL2_mixer/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=wii-sdl2_mixer pkgver=2.6.3 pkgrel=2 pkgdesc="A sample multi-channel audio mixer library." arch=('any') url="https://libsdl.org/projects/SDL_mixer/" license=("zlib") options=(!strip libtool staticlibs) makedepends=('wii-pkg-config' 'dkp-toolchain-vars') depends=( 'wii-sdl2' 'ppc-flac' 'ppc-libvorbisidec' 'ppc-libmodplug' 'ppc-mpg123' 'ppc-opusfile' ) source=( "${url}release/SDL2_mixer-${pkgver}.tar.gz" "sdl2_mixer-config.cmake.in.patch" ) groups=('wii-portlibs' 'wii-sdl2-libs') build() { cd SDL2_mixer-$pkgver source /opt/devkitpro/wiivars.sh # patch out compiling playwave and playmus sed 's|\$(objects)/play.*mus\$(EXE)||' -i Makefile.in patch -Np0 -i ${srcdir}/sdl2_mixer-config.cmake.in.patch LIBS="-lm" ./configure --prefix="${PORTLIBS_PREFIX}" \ --host=powerpc-eabi --disable-shared --enable-static \ --disable-music-cmd \ --enable-music-ogg-tremor \ --enable-music-mod-modplug make } package() { cd SDL2_mixer-$pkgver source /opt/devkitpro/wiivars.sh make DESTDIR="$pkgdir" install # add our static libs echo "Requires.private: vorbisidec libmodplug libmpg123 opusfile flac" >> "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/SDL2_mixer.pc" # License install -Dm644 "LICENSE.txt" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/LICENSE.txt" } sha256sums=('7a6ba86a478648ce617e3a5e9277181bc67f7ce9876605eea6affd4a0d6eea8f' '124baf871d39dbceb31ff71beccd2c4f0497ae7cfcfd9f11d99b57e28a151da1') ================================================ FILE: wii/SDL2_mixer/sdl2_mixer-config.cmake.in.patch ================================================ --- sdl2_mixer-config.cmake.in.orig 2024-11-03 13:41:46.831470270 +0000 +++ sdl2_mixer-config.cmake.in 2024-11-03 13:42:39.540513604 +0000 @@ -79,7 +79,7 @@ set(_sdl2mixer_incdir "${includedir}/SDL2") # Convert _sdl2mixer_extra_static_libraries to list and keep only libraries -string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._]+))|(-Wl,[^ ]*framework[^ ]*)" _sdl2mixer_extra_static_libraries "${_sdl2mixer_extra_static_libraries}") +string(REGEX MATCHALL "(-[lm]([-a-zA-Z0-9._+]+))|(-Wl,[^ ]*framework[^ ]*)" _sdl2mixer_extra_static_libraries "${_sdl2mixer_extra_static_libraries}") string(REGEX REPLACE "^-l" "" _sdl2mixer_extra_static_libraries "${_sdl2mixer_extra_static_libraries}") string(REGEX REPLACE ";-l" ";" _sdl2mixer_extra_static_libraries "${_sdl2mixer_extra_static_libraries}") ================================================ FILE: wii/SDL2_ttf/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Cpasjuste # Contributor: carstene1ns pkgname=wii-sdl2_ttf pkgver=2.22.0 pkgrel=2 pkgdesc="SDL2 TrueType font library." arch=('any') url="https://libsdl.org/projects/SDL_ttf/" license=("zlib") options=(!strip libtool staticlibs) makedepends=('wii-pkg-config' 'dkp-toolchain-vars') depends=( 'wii-sdl2' 'ppc-freetype' 'ppc-harfbuzz' ) source=("${url}release/SDL2_ttf-${pkgver}.tar.gz") sha256sums=('a9eceb1ad88c1f1545cd7bd28e7cbc0b2c14191d40238f531a15b01b1b22cd33') groups=('wii-portlibs' 'wii-sdl2-libs') build() { cd SDL2_ttf-$pkgver source ${DEVKITPRO}/wiivars.sh # patch out compiling showfont and glfont sed '/^noinst_PROGRAMS/d' -i Makefile.in ./configure --prefix="${PORTLIBS_PREFIX}" \ --host=powerpc-eabi --disable-shared --enable-static \ --disable-harfbuzz-builtin \ --disable-freetype-builtin \ --disable-sdltest --without-x make } package() { cd SDL2_ttf-$pkgver source /opt/devkitpro/wiivars.sh make DESTDIR="$pkgdir" install # License #install -Dm644 "COPYING.txt" "${pkgdir}/${PORTLIBS_PREFIX}/licenses/${pkgname}/COPYING.txt" } sha256sums=('d48cbd1ce475b9e178206bf3b72d56b66d84d44f64ac05803328396234d67723') ================================================ FILE: wii/SDL_gfx/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=wii-sdl_gfx pkgver=2.0.27 pkgrel=1 pkgdesc="Graphics drawing primitives and other support functions wrapped up in an add-on, C-based library for the Simple Direct Media (SDL) cross-platform API layer" arch=('any') url="http://www.ferzkopp.net/wordpress/2016/01/02/sdl_gfx-sdl2_gfx/" license=("LGPL") options=(!strip libtool staticlibs) depends=( 'wii-sdl' ) makedepends=( 'wii-pkg-config' 'dkp-toolchain-vars' ) source=( "https://sourceforge.net/projects/sdlgfx/files/SDL_gfx-${pkgver}.tar.gz" ) groups=('wii-portlibs' 'wii-sdl-libs') build() { cd SDL_gfx-$pkgver source /opt/devkitpro/wiivars.sh ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static \ --disable-mmx make } package() { cd SDL_gfx-$pkgver source /opt/devkitpro/wiivars.sh make DESTDIR="$pkgdir" install } sha256sums=('dfb15ac5f8ce7a4952dc12d2aed9747518c5e6b335c0e31636d23f93c630f419') ================================================ FILE: wii/SDL_image/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=wii-sdl_image pkgver=1.2.12 pkgrel=6 pkgdesc="A simple library to load images of various formats as SDL surfaces." arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) depends=( 'wii-sdl' 'ppc-libpng' 'ppc-libjpeg-turbo' ) makedepends=( 'wii-pkg-config' 'dkp-toolchain-vars' ) groups=('wii-portlibs' 'wii-sdl-libs') source=("${url}/projects/SDL_image/release/SDL_image-${pkgver}.tar.gz") sha256sums=( '0b90722984561004de84847744d566809dbb9daf732a9e503b91a1b5a84e5699' ) build() { cd SDL_image-$pkgver sed -i 's,showimage\$(EXEEXT),,g' Makefile.in source /opt/devkitpro/wiivars.sh CPPFLAGS="${CPPFLAGS} -Wno-incompatible-pointer-types" \ ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static make } package() { cd SDL_image-$pkgver source /opt/devkitpro/wiivars.sh make DESTDIR="$pkgdir" install # add our static libs echo "Requires.private: libpng libjpeg" >> "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/SDL_image.pc" } ================================================ FILE: wii/SDL_mixer/PKGBUILD ================================================ # Maintainer: Dave Murphy # Contributor: Sergio Padrino pkgname=wii-sdl_mixer pkgver=1.2.12 pkgrel=10 pkgdesc="A sample multi-channel audio mixer library (Nintendo Gamecube/Wii port)" arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) depends=( 'wii-sdl' 'ppc-libvorbis' 'ppc-libogg' 'ppc-libmad' 'ppc-libmodplug' ) groups=('wii-portlibs' 'wii-sdl-libs') makedepends=( 'wii-pkg-config' 'dkp-toolchain-vars' ) source=("${url}/projects/SDL_mixer/release/SDL_mixer-${pkgver}.tar.gz" "SDL_mixer-1.2.12.patch") sha256sums=( '1644308279a975799049e4826af2cfc787cad2abb11aa14562e402521f86992a' 'fb64421673349aeefe8071e6aad0b1d69345bff9227ba5dfb9ba077c9acb7312' ) build() { cd SDL_mixer-$pkgver source /opt/devkitpro/wiivars.sh patch -p1 -i $srcdir/SDL_mixer-1.2.12.patch ./autogen.sh LIBS="-lvorbis -logg -lm" ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static \ --enable-music-ogg \ --disable-music-cmd \ --enable-music-mod-modplug \ --enable-music-mp3-mad-gpl make } package() { cd SDL_mixer-$pkgver source /opt/devkitpro/wiivars.sh make DESTDIR="$pkgdir" install # add our static libs echo "Requires.private: libmodplug mad vorbisfile vorbis ogg" >> "${pkgdir}/${PORTLIBS_PREFIX}/lib/pkgconfig/SDL_mixer.pc" } ================================================ FILE: wii/SDL_mixer/SDL_mixer-1.2.12.patch ================================================ diff --git a/Makefile.in b/Makefile.in index 3d10565..833ef35 100644 --- a/Makefile.in +++ b/Makefile.in @@ -47,7 +47,7 @@ LT_RELEASE = @LT_RELEASE@ LT_REVISION = @LT_REVISION@ LT_LDFLAGS = -no-undefined -rpath $(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET) $(objects)/playwave$(EXE) $(objects)/playmus$(EXE) +all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET) $(srcdir)/configure: $(srcdir)/configure.in @echo "Warning, configure.in is out of date" @@ -60,18 +60,12 @@ Makefile: $(srcdir)/Makefile.in $(objects): $(SHELL) $(auxdir)/mkinstalldirs $@ -.PHONY: all install install-hdrs install-lib install-bin uninstall uninstall-hdrs uninstall-lib uninstall-bin clean distclean dist +.PHONY: all install install-hdrs install-lib uninstall uninstall-hdrs uninstall-lib clean distclean dist $(objects)/$(TARGET): $(OBJECTS) $(VERSION_OBJECTS) $(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS) -$(objects)/playwave$(EXE): $(objects)/playwave.lo $(objects)/$(TARGET) - $(LIBTOOL) --mode=link $(CC) -o $@ $(objects)/playwave.lo $(SDL_CFLAGS) $(SDL_LIBS) $(objects)/$(TARGET) - -$(objects)/playmus$(EXE): $(objects)/playmus.lo $(objects)/$(TARGET) - $(LIBTOOL) --mode=link $(CC) -o $@ $(objects)/playmus.lo $(SDL_CFLAGS) $(SDL_LIBS) $(objects)/$(TARGET) - -install: all install-hdrs install-lib #install-bin +install: all install-hdrs install-lib install-hdrs: $(SHELL) $(auxdir)/mkinstalldirs $(includedir)/SDL for src in $(srcdir)/SDL_mixer.h; do \ @@ -83,12 +77,8 @@ install-hdrs: install-lib: $(objects) $(objects)/$(TARGET) $(SHELL) $(auxdir)/mkinstalldirs $(libdir) $(LIBTOOL) --mode=install $(INSTALL) $(objects)/$(TARGET) $(libdir)/$(TARGET) -install-bin: - $(SHELL) $(auxdir)/mkinstalldirs $(bindir) - $(LIBTOOL) --mode=install $(INSTALL) -m 755 $(objects)/playwave$(EXE) $(bindir)/playwave$(EXE) - $(LIBTOOL) --mode=install $(INSTALL) -m 755 $(objects)/playmus$(EXE) $(bindir)/playmus$(EXE) -uninstall: uninstall-hdrs uninstall-lib uninstall-bin +uninstall: uninstall-hdrs uninstall-lib uninstall-hdrs: for src in $(srcdir)/SDL_mixer.h; do \ file=`echo $$src | sed -e 's|^.*/||'`; \ @@ -99,9 +89,6 @@ uninstall-hdrs: -rmdir $(libdir)/pkgconfig uninstall-lib: $(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(TARGET) -uninstall-bin: - rm -f $(bindir)/playwave$(EXE) - rm -f $(bindir)/playmus$(EXE) clean: rm -rf $(objects) diff --git a/load_ogg.c b/load_ogg.c index 2d0ee65..1e94fa6 100644 --- a/load_ogg.c +++ b/load_ogg.c @@ -105,7 +105,7 @@ SDL_AudioSpec *Mix_LoadOGG_RW (SDL_RWops *src, int freesrc, *audio_len = 0; memset(spec, '\0', sizeof (SDL_AudioSpec)); - spec->format = AUDIO_S16; + spec->format = AUDIO_S16SYS; spec->channels = info->channels; spec->freq = info->rate; spec->samples = 4096; /* buffer size */ @@ -124,9 +124,9 @@ SDL_AudioSpec *Mix_LoadOGG_RW (SDL_RWops *src, int freesrc, read > 0; read = vorbis.ov_read(&vf, (char *)buf, to_read, &bitstream)) #else - for (read = vorbis.ov_read(&vf, (char *)buf, to_read, 0/*LE*/, 2/*16bit*/, 1/*signed*/, &bitstream); + for (read = vorbis.ov_read(&vf, (char *)buf, to_read, SDL_BYTEORDER == SDL_BIG_ENDIAN/*BE?*/, 2/*16bit*/, 1/*signed*/, &bitstream); read > 0; - read = vorbis.ov_read(&vf, (char *)buf, to_read, 0, 2, 1, &bitstream)) + read = vorbis.ov_read(&vf, (char *)buf, to_read, SDL_BYTEORDER == SDL_BIG_ENDIAN, 2, 1, &bitstream)) #endif { if (read == OV_HOLE || read == OV_EBADLINK) diff --git a/music_modplug.h b/music_modplug.h index 92cbafd..555227b 100644 --- a/music_modplug.h +++ b/music_modplug.h @@ -1,6 +1,6 @@ #ifdef MODPLUG_MUSIC -#include "modplug.h" +#include #include "SDL_rwops.h" #include "SDL_audio.h" #include "SDL_mixer.h" diff --git a/music_ogg.c b/music_ogg.c index 18a094b..269a197 100644 --- a/music_ogg.c +++ b/music_ogg.c @@ -135,7 +135,7 @@ static void OGG_getsome(OGG_music *music) #ifdef OGG_USE_TREMOR len = vorbis.ov_read(&music->vf, data, sizeof(data), §ion); #else - len = vorbis.ov_read(&music->vf, data, sizeof(data), 0, 2, 1, §ion); + len = vorbis.ov_read(&music->vf, data, sizeof(data), SDL_BYTEORDER == SDL_BIG_ENDIAN, 2, 1, §ion); #endif if ( len <= 0 ) { if ( len == 0 ) { @@ -148,7 +148,7 @@ static void OGG_getsome(OGG_music *music) vorbis_info *vi; vi = vorbis.ov_info(&music->vf, -1); - SDL_BuildAudioCVT(cvt, AUDIO_S16, vi->channels, vi->rate, + SDL_BuildAudioCVT(cvt, AUDIO_S16SYS, vi->channels, vi->rate, mixer.format,mixer.channels,mixer.freq); if ( cvt->buf ) { SDL_free(cvt->buf); ================================================ FILE: wii/SDL_ttf/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=wii-sdl_ttf pkgver=2.0.11 pkgrel=6 pkgdesc="A sample library which allows you to use TrueType fonts in your SDL applications" arch=('any') url="https://libsdl.org" license=("LGPL") options=(!strip libtool staticlibs) depends=( 'ppc-freetype' 'wii-sdl' ) makedepends=( 'wii-pkg-config' 'dkp-toolchain-vars' ) source=( "${url}/projects/SDL_ttf/release/SDL_ttf-${pkgver}.tar.gz" SDL_ttf-${pkgver}.patch ) groups=('wii-portlibs' 'wii-sdl-libs') build() { cd SDL_ttf-$pkgver source /opt/devkitpro/wiivars.sh patch -p1 -i ${srcdir}/SDL_ttf-${pkgver}.patch ./autogen.sh sed '/^noinst_PROGRAMS/d' -i Makefile.in ./configure --prefix="${PORTLIBS_PREFIX}" --host=powerpc-eabi \ --disable-shared --enable-static make } package() { cd SDL_ttf-$pkgver source /opt/devkitpro/wiivars.sh make DESTDIR="$pkgdir" install } sha256sums=('724cd895ecf4da319a3ef164892b72078bd92632a5d812111261cde248ebcdb7' 'd0076b03127a5e74cc03677d44a6d74a2201a1809c0a4b44e7a136c5ca6ec975') ================================================ FILE: wii/SDL_ttf/SDL_ttf-2.0.11.patch ================================================ diff -NBaur SDL_ttf-2.0.11.old/configure.in SDL_ttf-2.0.11.new/configure.in --- SDL_ttf-2.0.11.old/configure.in 2012-01-15 04:44:08.000000000 +0000 +++ SDL_ttf-2.0.11.new/configure.in 2026-01-27 03:21:46.888291721 +0000 @@ -91,39 +91,13 @@ AM_CONDITIONAL(USE_VERSION_RC, test x$use_version_rc = xtrue) dnl Check for the FreeType 2 library -dnl -dnl Get the cflags and libraries from the freetype-config script -dnl -AC_ARG_WITH(freetype-prefix,[ --with-freetype-prefix=PFX Prefix where FREETYPE is -installed (optional)], - freetype_prefix="$withval", freetype_prefix="") -AC_ARG_WITH(freetype-exec-prefix,[ --with-freetype-exec-prefix=PFX Exec prefix -where FREETYPE is installed (optional)], - freetype_exec_prefix="$withval", freetype_exec_prefix="") - -if test x$freetype_exec_prefix != x ; then - freetype_args="$freetype_args --exec-prefix=$freetype_exec_prefix" - if test x${FREETYPE_CONFIG+set} != xset ; then - FREETYPE_CONFIG=$freetype_exec_prefix/bin/freetype-config - fi -fi -if test x$freetype_prefix != x ; then - freetype_args="$freetype_args --prefix=$freetype_prefix" - if test x${FREETYPE_CONFIG+set} != xset ; then - FREETYPE_CONFIG=$freetype_prefix/bin/freetype-config - fi -fi -AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no) -no_freetype="" -if test "$FREETYPE_CONFIG" = "no" ; then - AC_MSG_ERROR([ -*** Unable to find FreeType2 library (http://www.freetype.org/) -]) -else - CFLAGS="$CFLAGS `$FREETYPE_CONFIG $freetypeconf_args --cflags`" - LIBS="$LIBS `$FREETYPE_CONFIG $freetypeconf_args --libs`" -fi +PKG_CHECK_MODULES([FT2], + [freetype2],,AC_MSG_ERROR([*** freetype2 not found!]) +) +CFLAGS="$CFLAGS $FT2_CFLAGS" +LIBS="$LIBS $FT2_LIBS" +AC_SUBST(FT2_LIBS) dnl Check for SDL SDL_VERSION=1.2.4 AC_SUBST(SDL_VERSION) diff -NBaur SDL_ttf-2.0.11.old/SDL_ttf.pc.in SDL_ttf-2.0.11.new/SDL_ttf.pc.in --- SDL_ttf-2.0.11.old/SDL_ttf.pc.in 2012-01-15 04:44:08.000000000 +0000 +++ SDL_ttf-2.0.11.new/SDL_ttf.pc.in 2026-01-27 03:22:14.604837684 +0000 @@ -7,6 +7,7 @@ Description: ttf library for Simple DirectMedia Layer with FreeType 2 support Version: @VERSION@ Requires: sdl >= @SDL_VERSION@ -Libs: -L${libdir} -lSDL_ttf +Libs: -L${libdir} -lSDL_ttf @FT2_LIBS@ +Libs.private: -L${libdir} -lSDL_ttf @FT2_LIBS@ Cflags: -I${includedir}/SDL ================================================ FILE: wii/freeglut/PKGBUILD ================================================ _realname=freeglut pkgname=wii-${_realname} pkgver=3.6.0 pkgrel=4 pkgdesc='wii freeglut' arch=('any') url='https://github.com/freeglut/freeglut/' license=('MIT') options=(!strip libtool staticlibs) makedepends=('catnip') depends=('libogc' 'wii-opengx' 'wii-glu') groups=('wii-portlibs') source=( "${_realname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz" "freeglut-3.6.0.patch" ) build() { cd ${_realname}-${pkgver} patch -Np1 -i $srcdir/freeglut-${pkgver}.patch catnip -t wii -DFREEGLUT_BUILD_DEMOS=OFF } package() { cd ${_realname}-${pkgver} DESTDIR=${pkgdir} catnip install } sha256sums=('16de4f51dc1efd663a1a58ba5552e54f8783b77478289c95dca474a4d39ddd02' 'a2f17db1bf0d52fb72b1d2abff431946d579310e41582c3532bf2bb9d993bd18') ================================================ FILE: wii/freeglut/freeglut-3.6.0.patch ================================================ diff --git a/src/mswin/fg_spaceball_mswin.c b/src/mswin/fg_spaceball_mswin.c index 5cb97450..fce4acdb 100644 --- a/src/mswin/fg_spaceball_mswin.c +++ b/src/mswin/fg_spaceball_mswin.c @@ -36,12 +36,12 @@ * six degree of freedom navigator. */ -#if(_WIN32_WINNT >= 0x0501) - #include #include #include "../fg_internal.h" +#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0501) + enum { SPNAV_EVENT_ANY, SPNAV_EVENT_MOTION_TRANSLATION, @@ -66,28 +66,40 @@ struct fgRAWHID { }; +typedef BOOL(*RegRawInpDevFunc)(PCRAWINPUTDEVICE, UINT, UINT); +typedef UINT(*GetRawInpDataFunc)(HRAWINPUT, UINT, LPVOID, PUINT, UINT); +typedef UINT(*GetRawInpDevInfoFunc)(HANDLE, UINT, LPVOID, PUINT); + +static RegRawInpDevFunc fgRegisterRawInputDevices; +static GetRawInpDataFunc fgGetRawInputData; +static GetRawInpDevInfoFunc fgGetRawInputDeviceInfo; + + void fgPlatformInitializeSpaceball(void) { - HWND hwnd; - fg_sball_initialized = 1; - if (!fgStructure.CurrentWindow) - { - fg_sball_initialized = 0; + HMODULE dllmod; + + if(!fgStructure.CurrentWindow) return; + + if(!(dllmod = GetModuleHandle("user32.dll"))) { return; } - hwnd = fgStructure.CurrentWindow->Window.Handle; + fgRegisterRawInputDevices = (RegRawInpDevFunc)GetProcAddress(dllmod, "RegisterRawInputDevices"); + fgGetRawInputData = (GetRawInpDataFunc)GetProcAddress(dllmod, "GetRawInputData"); + fgGetRawInputDeviceInfo = (GetRawInpDevInfoFunc)GetProcAddress(dllmod, "GetRawInputDeviceInfoA"); - { - BOOL ok; - UINT cbSize = sizeof(__fgSpaceball); - __fgSpaceball.hwndTarget = hwnd; - ok = RegisterRawInputDevices(&__fgSpaceball, 1, cbSize); + if(!fgRegisterRawInputDevices || !fgGetRawInputData || !fgGetRawInputDeviceInfo) { + return; + } - if (!ok){ - __fgSpaceball.hwndTarget = NULL; - fg_sball_initialized = 0; - } + __fgSpaceball.hwndTarget = fgStructure.CurrentWindow->Window.Handle; + + if(!fgRegisterRawInputDevices(&__fgSpaceball, 1, sizeof __fgSpaceball)) { + __fgSpaceball.hwndTarget = NULL; + return; } + + fg_sball_initialized = 1; } void fgPlatformSpaceballClose(void) @@ -115,98 +127,142 @@ int fgIsSpaceballWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam) return 0; } +#define VID_LOGITECH 0x46d +#define VID_3DCONN 0x256f + void fgSpaceballHandleWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam) { - #define LOGITECH_VENDOR_ID 0x46d + int i, x, y, z; + short *dataptr; + unsigned long keystate; HRAWINPUT hRawInput = (HRAWINPUT)lParam; UINT size; BYTE *rawInputBuffer; PRAWINPUT pRawInput; - UINT res; RID_DEVICE_INFO sRidDeviceInfo; + SFG_Window *window; - if (!fg_sball_initialized) - { + if(!fg_sball_initialized) { fgPlatformInitializeSpaceball(); - if (!fg_sball_initialized) - { - return; - } + if(!fg_sball_initialized) return; } - res = GetRawInputData(hRawInput, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)); - if (res == -1) + if(fgGetRawInputData(hRawInput, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)) == -1) { return; + } - rawInputBuffer = malloc(size * sizeof *rawInputBuffer); + if(!(rawInputBuffer = malloc(size * sizeof *rawInputBuffer))) { + return; + } pRawInput = (PRAWINPUT)rawInputBuffer; - res = GetRawInputData(hRawInput, RID_INPUT, pRawInput, &size, sizeof(RAWINPUTHEADER)); - if (res == -1) + if(fgGetRawInputData(hRawInput, RID_INPUT, pRawInput, &size, sizeof(RAWINPUTHEADER)) == -1) { + free(rawInputBuffer); return; - if (pRawInput->header.dwType != RIM_TYPEHID) + } + if(pRawInput->header.dwType != RIM_TYPEHID) { + free(rawInputBuffer); return; + } sRidDeviceInfo.cbSize = sizeof(RID_DEVICE_INFO); size = sizeof(RID_DEVICE_INFO); - res = GetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICEINFO, &sRidDeviceInfo, &size); - if (res == -1) + if(fgGetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICEINFO, &sRidDeviceInfo, &size) == -1) { + free(rawInputBuffer); return; - { - SFG_Window* window = fgWindowByHandle(hwnd); - if ((window == NULL)) - return; - - if (sRidDeviceInfo.hid.dwVendorId == LOGITECH_VENDOR_ID) - { - /* see definition of fgRAWHID at the top of this file, for an - * explanation of why we're doing this. - */ - struct fgRAWHID *hid = (struct fgRAWHID*)&pRawInput->data.hid; - - /* Motion data comes in two parts: motion type and */ - /* displacement/rotation along three axis. */ - /* Orientation is a right handed coordinate system with */ - /* X goes right, Y goes up and Z goes towards viewer, e.g. */ - /* the one used in OpenGL */ - if (hid->bRawData[0] == SPNAV_EVENT_MOTION_TRANSLATION) - { /* Translation vector */ - short* pnData = (short*)(&hid->bRawData[1]); - short X = pnData[0]; - short Y = -pnData[2]; - short Z = pnData[1]; - INVOKE_WCB(*window, SpaceMotion, (X, Y, Z)); - } - else if (hid->bRawData[0] == SPNAV_EVENT_MOTION_ROTATION) - { /* Axis aligned rotation vector */ - short* pnData = (short*)(&hid->bRawData[1]); - short rX = pnData[0]; - short rY = -pnData[2]; - short rZ = pnData[1]; - INVOKE_WCB(*window, SpaceRotation, (rX, rY, rZ)); - } - else if (hid->bRawData[0] == SPNAV_EVENT_BUTTON) - { /* State of the keys */ - unsigned long dwKeystate = *(unsigned long*)(&hid->bRawData[1]); - if (FETCH_WCB(*window, SpaceButton)) - { - int i; - for (i = 0; i < 32; i++) - { - unsigned long stateBefore = __fgSpaceKeystate&(1 << i); - unsigned long stateNow = dwKeystate&(1 << i); - - if (stateBefore && !stateNow) - INVOKE_WCB(*window, SpaceButton, (stateBefore, GLUT_UP)); - if (!stateBefore && stateNow) - INVOKE_WCB(*window, SpaceButton, (stateNow, GLUT_DOWN)); + } + if(!(window = fgWindowByHandle(hwnd))) { + return; + } + + if(sRidDeviceInfo.hid.dwVendorId == VID_LOGITECH || sRidDeviceInfo.hid.dwVendorId == VID_3DCONN) { + /* see definition of fgRAWHID at the top of this file, for an + * explanation of why we're doing this. + */ + struct fgRAWHID *hid = (struct fgRAWHID*)&pRawInput->data.hid; + + /* Motion data comes in two parts: motion type and */ + /* displacement/rotation along three axis. */ + /* Orientation is a right handed coordinate system with */ + /* X goes right, Y goes up and Z goes towards viewer, e.g. */ + /* the one used in OpenGL */ + switch(hid->bRawData[0]) { + case SPNAV_EVENT_MOTION_TRANSLATION: + /* Translation vector */ + dataptr = (short*)(&hid->bRawData[1]); + x = dataptr[0]; + y = -dataptr[2]; + z = dataptr[1]; + INVOKE_WCB(*window, SpaceMotion, (x, y, z)); + break; + + case SPNAV_EVENT_MOTION_ROTATION: + /* Axis aligned rotation vector */ + dataptr = (short*)(&hid->bRawData[1]); + x = dataptr[0]; + y = -dataptr[2]; + z = dataptr[1]; + INVOKE_WCB(*window, SpaceRotation, (x, y, z)); + + case SPNAV_EVENT_BUTTON: + /* State of the keys */ + keystate = *(unsigned long*)(&hid->bRawData[1]); + if(FETCH_WCB(*window, SpaceButton)) { + for(i=0; i<32; i++) { + unsigned long stateBefore = __fgSpaceKeystate & (1 << i); + unsigned long stateNow = keystate & (1 << i); + + if(stateBefore && !stateNow) { + INVOKE_WCB(*window, SpaceButton, (stateBefore, GLUT_UP)); + } + if(!stateBefore && stateNow) { + INVOKE_WCB(*window, SpaceButton, (stateNow, GLUT_DOWN)); } } - __fgSpaceKeystate = dwKeystate; } + __fgSpaceKeystate = keystate; + break; } } } +#else +/* windows versions older than winxp don't have the raw HID support used by this + * spaceball implementation. For now just leave the functions blank to make it + * build without spaceball support on older versions of windows, until we can + * investigate a fallback route. + */ + +void fgPlatformInitializeSpaceball(void) +{ +} + +void fgPlatformSpaceballClose(void) +{ +} + +int fgPlatformHasSpaceball(void) +{ + return 0; +} + +int fgPlatformSpaceballNumButtons(void) +{ + return 0; +} + +void fgPlatformSpaceballSetWindow(SFG_Window *window) +{ +} + +int fgIsSpaceballWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + return 0; +} + +void fgSpaceballHandleWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam) +{ +} + #endif diff --git a/src/ogc/fg_display_ogc.c b/src/ogc/fg_display_ogc.c index e7a5a793..233818e0 100644 --- a/src/ogc/fg_display_ogc.c +++ b/src/ogc/fg_display_ogc.c @@ -47,6 +47,10 @@ void fgOgcDisplaySetupXfb() fgDisplay.pDisplay.xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode)); } + + if (fgState.DisplayMode & GLUT_STENCIL) { + ogx_stencil_create(OGX_STENCIL_DIRTY_Z); + } } void fgOgcDisplaySetupVideoMode() diff --git a/src/ogc/fg_main_ogc.c b/src/ogc/fg_main_ogc.c index 499ec8dc..502bcc4a 100644 --- a/src/ogc/fg_main_ogc.c +++ b/src/ogc/fg_main_ogc.c @@ -206,14 +206,21 @@ fg_time_t fgPlatformSystemTime(void) void fgPlatformSleepForEvents(fg_time_t ms) { - fgWarning("%s() : sleeping for %lld ms", __func__, ms); - /* FreeGlut does not offer a hook for redrawing the window in single-buffer * mode, so let's to it here. */ if (!(fgState.DisplayMode & GLUT_DOUBLE)) { fgOgcDisplayShowEFB(); } + /* If the mouse is active, reduce the sleep time to a few milliseconds + * only, since our mouse is emulated via the Wiimote, which must be + * regularly polled */ + if (ms > 10 && fgStructure.CurrentWindow && + (FETCH_WCB(*fgStructure.CurrentWindow, Motion) || + FETCH_WCB(*fgStructure.CurrentWindow, Mouse))) { + ms = 10; + } + struct timespec tv; tv.tv_sec = ms / 1000; tv.tv_nsec = (ms % 1000) * 1000000; @@ -261,7 +268,7 @@ void fgPlatformPosResZordWork(SFG_Window *window, unsigned int workMask) void fgPlatformVisibilityWork(SFG_Window *window) { - fgWarning("%s() : not implemented", __func__); + INVOKE_WCB(*window, WindowStatus, (GLUT_FULLY_RETAINED)); } void fgPlatformSetColor(int idx, float r, float g, float b) diff --git a/src/ogc/fg_state_ogc.c b/src/ogc/fg_state_ogc.c index 876644c9..91235498 100644 --- a/src/ogc/fg_state_ogc.c +++ b/src/ogc/fg_state_ogc.c @@ -29,6 +29,8 @@ int fgPlatformGlutDeviceGet(GLenum eWhat) int fgPlatformGlutGet(GLenum eWhat) { + GLint ret = -1; + switch (eWhat) { case GLUT_WINDOW_WIDTH: return fgStructure.CurrentWindow ? @@ -36,10 +38,13 @@ int fgPlatformGlutGet(GLenum eWhat) case GLUT_WINDOW_HEIGHT: return fgStructure.CurrentWindow ? fgStructure.CurrentWindow->State.Height : 0; + case GLUT_WINDOW_STENCIL_SIZE: + glGetIntegerv(GL_STENCIL_BITS, &ret); + break; default: fgWarning("%s() : not implemented for %d", __func__, eWhat); } - return -1; + return ret; } int *fgPlatformGlutGetModeValues(GLenum eWhat, int *size) diff --git a/src/ogc/fg_window_ogc.c b/src/ogc/fg_window_ogc.c index 34dca9d8..4051a2fe 100644 --- a/src/ogc/fg_window_ogc.c +++ b/src/ogc/fg_window_ogc.c @@ -37,7 +37,7 @@ void fgPlatformOpenWindow(SFG_Window *window, const char *title, window->State.Xpos = 0; window->State.Ypos = 0; - window->State.WorkMask |= GLUT_INIT_WORK; + window->State.WorkMask |= GLUT_INIT_WORK | GLUT_VISIBILITY_WORK; window->State.Visible = GL_TRUE; /* This sets up the XFB for the chosen buffering scheme */ diff --git a/src/x11/fg_spaceball_x11.c b/src/x11/fg_spaceball_x11.c index 155d24b1..eb825bb7 100644 --- a/src/x11/fg_spaceball_x11.c +++ b/src/x11/fg_spaceball_x11.c @@ -17,29 +17,29 @@ extern int fg_sball_initialized; enum { - SPNAV_EVENT_ANY, /* used by spnav_remove_events() */ - SPNAV_EVENT_MOTION, - SPNAV_EVENT_BUTTON /* includes both press and release */ + SPNAV_EVENT_ANY, /* used by spnav_remove_events() */ + SPNAV_EVENT_MOTION, + SPNAV_EVENT_BUTTON /* includes both press and release */ }; struct spnav_event_motion { - int type; - int x, y, z; - int rx, ry, rz; - unsigned int period; - int *data; + int type; + int x, y, z; + int rx, ry, rz; + unsigned int period; + int *data; }; struct spnav_event_button { - int type; - int press; - int bnum; + int type; + int press; + int bnum; }; typedef union spnav_event { - int type; - struct spnav_event_motion motion; - struct spnav_event_button button; + int type; + struct spnav_event_motion motion; + struct spnav_event_button button; } spnav_event; @@ -54,96 +54,97 @@ static SFG_Window *spnav_win; void fgPlatformInitializeSpaceball(void) { - Window w; - - fg_sball_initialized = 1; - if(!fgStructure.CurrentWindow) - { - fg_sball_initialized = -1; - return; - } - - w = fgStructure.CurrentWindow->Window.Handle; - if(spnav_x11_open(fgDisplay.pDisplay.Display, w) == -1) - { - fg_sball_initialized = -1; - return; - } + Window w; + + fg_sball_initialized = 1; + if(!fgStructure.CurrentWindow) + { + fg_sball_initialized = -1; + return; + } + + w = fgStructure.CurrentWindow->Window.Handle; + if(spnav_x11_open(fgDisplay.pDisplay.Display, w) == -1) + { + fg_sball_initialized = -1; + return; + } } -void fgPlatformSpaceballClose(void) +void fgPlatformSpaceballClose(void) { - spnav_close(); + spnav_close(); } -int fgPlatformHasSpaceball(void) +int fgPlatformHasSpaceball(void) { - /* XXX this function should somehow query the driver if there's a device - * plugged in, as opposed to just checking if there's a driver to talk to. - */ - return spnav_fd() == -1 ? 0 : 1; + /* XXX this function should somehow query the driver if there's a device + * plugged in, as opposed to just checking if there's a driver to talk to. + */ + return spnav_fd() == -1 ? 0 : 1; } -int fgPlatformSpaceballNumButtons(void) { - return 2; +int fgPlatformSpaceballNumButtons(void) +{ + return 2; } -void fgPlatformSpaceballSetWindow(SFG_Window *window) +void fgPlatformSpaceballSetWindow(SFG_Window *window) { - if(spnav_win != window) { - spnav_x11_window(window->Window.Handle); - spnav_win = window; - } + if(spnav_win != window) { + spnav_x11_window(window->Window.Handle); + spnav_win = window; + } } int fgIsSpaceballXEvent(const XEvent *xev) { - spnav_event sev; + spnav_event sev; - if(spnav_win != fgStructure.CurrentWindow) { - /* this will also initialize spaceball if needed (first call) */ - fgSpaceballSetWindow(fgStructure.CurrentWindow); - } + if(spnav_win != fgStructure.CurrentWindow) { + /* this will also initialize spaceball if needed (first call) */ + fgSpaceballSetWindow(fgStructure.CurrentWindow); + } - if(fg_sball_initialized != 1) { - return 0; - } + if(fg_sball_initialized != 1) { + return 0; + } - return spnav_x11_event(xev, &sev); + return spnav_x11_event(xev, &sev); } void fgSpaceballHandleXEvent(const XEvent *xev) { - spnav_event sev; - - if(fg_sball_initialized == 0) { - fgInitialiseSpaceball(); - if(fg_sball_initialized != 1) { - return; - } - } - - if(spnav_x11_event(xev, &sev)) { - switch(sev.type) { - case SPNAV_EVENT_MOTION: - if(sev.motion.x | sev.motion.y | sev.motion.z) { - INVOKE_WCB(*spnav_win, SpaceMotion, (sev.motion.x, sev.motion.y, sev.motion.z)); - } - if(sev.motion.rx | sev.motion.ry | sev.motion.rz) { - INVOKE_WCB(*spnav_win, SpaceRotation, (sev.motion.rx, sev.motion.ry, sev.motion.rz)); - } - spnav_remove_events(SPNAV_EVENT_MOTION); - break; - - case SPNAV_EVENT_BUTTON: - /* button numbers are 1-based in glutSpaceballButtonFunc */ - INVOKE_WCB(*spnav_win, SpaceButton, (sev.button.bnum + 1, sev.button.press ? GLUT_DOWN : GLUT_UP)); - break; - - default: - break; - } - } + spnav_event sev; + + if(fg_sball_initialized == 0) { + fgInitialiseSpaceball(); + if(fg_sball_initialized != 1) { + return; + } + } + + if(spnav_x11_event(xev, &sev)) { + switch(sev.type) { + case SPNAV_EVENT_MOTION: + if(sev.motion.x | sev.motion.y | sev.motion.z) { + INVOKE_WCB(*spnav_win, SpaceMotion, (sev.motion.x, sev.motion.y, sev.motion.z)); + } + if(sev.motion.rx | sev.motion.ry | sev.motion.rz) { + INVOKE_WCB(*spnav_win, SpaceRotation, (sev.motion.rx, sev.motion.ry, sev.motion.rz)); + } + spnav_remove_events(SPNAV_EVENT_MOTION); + break; + + case SPNAV_EVENT_BUTTON: + /* button numbers are 1-based in glutSpaceballButtonFunc */ + INVOKE_WCB(*spnav_win, SpaceButton, (sev.button.bnum + 1, sev.button.press ? GLUT_DOWN : GLUT_UP)); + break; + + default: + break; + } + } } /* @@ -188,226 +189,226 @@ static Window app_win; static Atom motion_event, button_press_event, button_release_event, command_event; enum { - CMD_APP_WINDOW = 27695, - CMD_APP_SENS + CMD_APP_WINDOW = 27695, + CMD_APP_SENS }; -#define IS_OPEN dpy +#define IS_OPEN dpy struct event_node { - spnav_event event; - struct event_node *next; + spnav_event event; + struct event_node *next; }; static int spnav_x11_open(Display *display, Window win) { - if(IS_OPEN) { - return -1; - } + if(IS_OPEN) { + return -1; + } - dpy = display; + dpy = display; - motion_event = XInternAtom(dpy, "MotionEvent", True); - button_press_event = XInternAtom(dpy, "ButtonPressEvent", True); - button_release_event = XInternAtom(dpy, "ButtonReleaseEvent", True); - command_event = XInternAtom(dpy, "CommandEvent", True); + motion_event = XInternAtom(dpy, "MotionEvent", True); + button_press_event = XInternAtom(dpy, "ButtonPressEvent", True); + button_release_event = XInternAtom(dpy, "ButtonReleaseEvent", True); + command_event = XInternAtom(dpy, "CommandEvent", True); - if(!motion_event || !button_press_event || !button_release_event || !command_event) { - dpy = 0; - return -1; /* daemon not started */ - } + if(!motion_event || !button_press_event || !button_release_event || !command_event) { + dpy = 0; + return -1; /* daemon not started */ + } - if(spnav_x11_window(win) == -1) { - dpy = 0; - return -1; /* daemon not started */ - } + if(spnav_x11_window(win) == -1) { + dpy = 0; + return -1; /* daemon not started */ + } - app_win = win; - return 0; + app_win = win; + return 0; } static int spnav_close(void) { - if(dpy) { - spnav_x11_window(DefaultRootWindow(dpy)); - app_win = 0; - dpy = 0; - return 0; - } - return -1; + if(dpy) { + spnav_x11_window(DefaultRootWindow(dpy)); + app_win = 0; + dpy = 0; + return 0; + } + return -1; } static int spnav_x11_window(Window win) { - int (*prev_xerr_handler)(Display*, XErrorEvent*); - XEvent xev; - Window daemon_win; - - if(!IS_OPEN) { - return -1; - } - - if(!(daemon_win = get_daemon_window(dpy))) { - return -1; - } - - prev_xerr_handler = XSetErrorHandler(catch_badwin); - - xev.type = ClientMessage; - xev.xclient.send_event = False; - xev.xclient.display = dpy; - xev.xclient.window = win; - xev.xclient.message_type = command_event; - xev.xclient.format = 16; - xev.xclient.data.s[0] = ((unsigned int)win & 0xffff0000) >> 16; - xev.xclient.data.s[1] = (unsigned int)win & 0xffff; - xev.xclient.data.s[2] = CMD_APP_WINDOW; - - XSendEvent(dpy, daemon_win, False, 0, &xev); - XSync(dpy, False); - - XSetErrorHandler(prev_xerr_handler); - return 0; + int (*prev_xerr_handler)(Display*, XErrorEvent*); + XEvent xev; + Window daemon_win; + + if(!IS_OPEN) { + return -1; + } + + if(!(daemon_win = get_daemon_window(dpy))) { + return -1; + } + + prev_xerr_handler = XSetErrorHandler(catch_badwin); + + xev.type = ClientMessage; + xev.xclient.send_event = False; + xev.xclient.display = dpy; + xev.xclient.window = win; + xev.xclient.message_type = command_event; + xev.xclient.format = 16; + xev.xclient.data.s[0] = ((unsigned int)win & 0xffff0000) >> 16; + xev.xclient.data.s[1] = (unsigned int)win & 0xffff; + xev.xclient.data.s[2] = CMD_APP_WINDOW; + + XSendEvent(dpy, daemon_win, False, 0, &xev); + XSync(dpy, False); + + XSetErrorHandler(prev_xerr_handler); + return 0; } static int spnav_fd(void) { - if(dpy) { - return ConnectionNumber(dpy); - } - return -1; + if(dpy) { + return ConnectionNumber(dpy); + } + return -1; } /*static int spnav_wait_event(spnav_event *event) { - if(dpy) { - for(;;) { - XEvent xev; - XNextEvent(dpy, &xev); - - if(spnav_x11_event(&xev, event) > 0) { - return event->type; - } - } - } - return 0; + if(dpy) { + for(;;) { + XEvent xev; + XNextEvent(dpy, &xev); + + if(spnav_x11_event(&xev, event) > 0) { + return event->type; + } + } + } + return 0; } static int spnav_poll_event(spnav_event *event) { - if(dpy) { - if(XPending(dpy)) { - XEvent xev; - XNextEvent(dpy, &xev); - - return spnav_x11_event(&xev, event); - } - } - return 0; + if(dpy) { + if(XPending(dpy)) { + XEvent xev; + XNextEvent(dpy, &xev); + + return spnav_x11_event(&xev, event); + } + } + return 0; }*/ static Bool match_events(Display *dpy, XEvent *xev, char *arg) { - int evtype = *(int*)arg; - - if(xev->type != ClientMessage) { - return False; - } - - if(xev->xclient.message_type == motion_event) { - return !evtype || evtype == SPNAV_EVENT_MOTION ? True : False; - } - if(xev->xclient.message_type == button_press_event || - xev->xclient.message_type == button_release_event) { - return !evtype || evtype == SPNAV_EVENT_BUTTON ? True : False; - } - return False; + int evtype = *(int*)arg; + + if(xev->type != ClientMessage) { + return False; + } + + if(xev->xclient.message_type == motion_event) { + return !evtype || evtype == SPNAV_EVENT_MOTION ? True : False; + } + if(xev->xclient.message_type == button_press_event || + xev->xclient.message_type == button_release_event) { + return !evtype || evtype == SPNAV_EVENT_BUTTON ? True : False; + } + return False; } static int spnav_remove_events(int type) { - int rm_count = 0; + int rm_count = 0; - if(dpy) { - XEvent xev; + if(dpy) { + XEvent xev; - while(XCheckIfEvent(dpy, &xev, match_events, (char*)&type)) { - rm_count++; - } - return rm_count; - } - return 0; + while(XCheckIfEvent(dpy, &xev, match_events, (char*)&type)) { + rm_count++; + } + return rm_count; + } + return 0; } static int spnav_x11_event(const XEvent *xev, spnav_event *event) { - int i; - int xmsg_type; - - if(xev->type != ClientMessage) { - return 0; - } - - xmsg_type = xev->xclient.message_type; - - if(xmsg_type != motion_event && xmsg_type != button_press_event && - xmsg_type != button_release_event) { - return 0; - } - - if(xmsg_type == motion_event) { - event->type = SPNAV_EVENT_MOTION; - event->motion.data = &event->motion.x; - - for(i=0; i<6; i++) { - event->motion.data[i] = xev->xclient.data.s[i + 2]; - } - event->motion.period = xev->xclient.data.s[8]; - } else { - event->type = SPNAV_EVENT_BUTTON; - event->button.press = xmsg_type == button_press_event ? 1 : 0; - event->button.bnum = xev->xclient.data.s[2]; - } - return event->type; + int i; + int xmsg_type; + + if(xev->type != ClientMessage) { + return 0; + } + + xmsg_type = xev->xclient.message_type; + + if(xmsg_type != motion_event && xmsg_type != button_press_event && + xmsg_type != button_release_event) { + return 0; + } + + if(xmsg_type == motion_event) { + event->type = SPNAV_EVENT_MOTION; + event->motion.data = &event->motion.x; + + for(i=0; i<6; i++) { + event->motion.data[i] = xev->xclient.data.s[i + 2]; + } + event->motion.period = xev->xclient.data.s[8]; + } else { + event->type = SPNAV_EVENT_BUTTON; + event->button.press = xmsg_type == button_press_event ? 1 : 0; + event->button.bnum = xev->xclient.data.s[2]; + } + return event->type; } static Window get_daemon_window(Display *dpy) { - Window win, root_win; - XTextProperty wname; - Atom type; - int fmt; - unsigned long nitems, bytes_after; - unsigned char *prop; + Window win, root_win; + XTextProperty wname; + Atom type; + int fmt; + unsigned long nitems, bytes_after; + unsigned char *prop; - root_win = DefaultRootWindow(dpy); + root_win = DefaultRootWindow(dpy); - XGetWindowProperty(dpy, root_win, command_event, 0, 1, False, AnyPropertyType, &type, &fmt, &nitems, &bytes_after, &prop); - if(!prop) { - return 0; - } + XGetWindowProperty(dpy, root_win, command_event, 0, 1, False, AnyPropertyType, &type, &fmt, &nitems, &bytes_after, &prop); + if(!prop) { + return 0; + } - win = *(Window*)prop; - XFree(prop); + win = *(Window*)prop; + XFree(prop); - if(!XGetWMName(dpy, win, &wname) || strcmp("Magellan Window", (char*)wname.value) != 0) { - return 0; - } + if(!XGetWMName(dpy, win, &wname) || strcmp("Magellan Window", (char*)wname.value) != 0) { + return 0; + } - return win; + return win; } static int catch_badwin(Display *dpy, XErrorEvent *err) { - char buf[256]; - - if(err->error_code == BadWindow) { - /* do nothing? */ - } else { - XGetErrorText(dpy, err->error_code, buf, sizeof buf); - fprintf(stderr, "Caught unexpected X error: %s\n", buf); - } - return 0; + char buf[256]; + + if(err->error_code == BadWindow) { + /* do nothing? */ + } else { + XGetErrorText(dpy, err->error_code, buf, sizeof buf); + fprintf(stderr, "Caught unexpected X error: %s\n", buf); + } + return 0; } ================================================ FILE: wii/glu/LICENSE ================================================ SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice including the dates of first publication and either this permission notice or a reference to http://oss.sgi.com/projects/FreeB/ shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of Silicon Graphics, Inc. shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Silicon Graphics, Inc. ================================================ FILE: wii/glu/PKGBUILD ================================================ pkgbasename=glu pkgname=wii-$pkgbasename pkgver=9.0.3 pkgrel=1 pkgdesc='SGI implementation of the OpenGL Utility library' arch=('any') url='https://mesa.freedesktop.org/archive/glu/' license=('custom') options=(!strip libtool staticlibs) source=( "${url}/${pkgbasename}-${pkgver}.tar.xz" "LICENSE" ) depends=('wii-opengx') makedepends=("wii-pkg-config" "dkp-toolchain-vars" "dkp-meson-scripts") groups=('wii-portlibs') build() { cd ${pkgbasename}-${pkgver} source /opt/devkitpro/wiivars.sh /opt/devkitpro/meson-cross.sh wii ../crossfile.txt \ build } package() { cd ${pkgbasename}-${pkgver} DESTDIR="$pkgdir" meson install -C build install -dm755 "$pkgdir"/opt/devkitpro/portlibs/wii/licenses/$pkgname install -m644 "${srcdir}"/LICENSE "$pkgdir"/opt/devkitpro/portlibs/wii/licenses/$pkgname/ } sha256sums=('bd43fe12f374b1192eb15fe20e45ff456b9bc26ab57f0eee919f96ca0f8a330f' '0d27597d42ef0c1ad0e52887de19d3c985608daa60581e9c075c1a978aa5bf40') ================================================ FILE: wii/opengx/PKGBUILD ================================================ pkgname=wii-opengx pkgver=0.17.0 pkgrel=2 pkgdesc='wii opengl/gx translation library' arch=('any') url='https://github.com/devkitPro/opengx' license=('BSD') options=(!strip libtool staticlibs) makedepends=('catnip') depends=('libogc') groups=('wii-portlibs') source=( "opengx-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz" ) build() { cd opengx-${pkgver} catnip -t wii } package() { cd opengx-${pkgver} DESTDIR=${pkgdir} catnip install } sha256sums=('cbf4cdc4df792e8ac1a0aa95b40008d14892faf23e9de882aad86676c3ea8474') ================================================ FILE: wii/physfs/PKGBUILD ================================================ # Maintainer: Ezekiel Bethel _realname=physfs pkgname=wii-${_realname} pkgver=3.2.0 pkgrel=3 pkgdesc='A library to provide abstract access to various archives.' arch=('any') url='https://icculus.org/physfs/' license=('zlib') options=(!strip libtool staticlibs) source=( "${_realname}-${pkgver}.tar.gz::https://github.com/icculus/physfs/archive/refs/tags/release-${pkgver}.tar.gz" "physfs-${pkgver}.patch") makedepends=('devkitPPC' 'dkp-toolchain-vars' 'wii-cmake') groups=('wii-portlibs') build() { cd physfs-release-$pkgver patch -Np1 -i "$srcdir"/physfs-${pkgver}.patch source ${DEVKITPRO}/wiivars.sh powerpc-eabi-cmake -GNinja \ -DPHYSFS_BUILD_STATIC=ON -DPHYSFS_BUILD_SHARED=OFF \ -DPHYSFS_BUILD_TEST=OFF \ -B _build -S . cmake --build _build } package() { cd physfs-release-$pkgver DESTDIR="$pkgdir" cmake --install _build } sha256sums=('1991500eaeb8d5325e3a8361847ff3bf8e03ec89252b7915e1f25b3f8ab5d560' '8e16519e12228cfb49152b4c042ccbae728df18c00b7a72e81d5e219bf5ebe3d') sha256sums=('1991500eaeb8d5325e3a8361847ff3bf8e03ec89252b7915e1f25b3f8ab5d560' '4f63dd63d38e8784ded3666403acffa3a128d888f656c0808df19e34794287ba') ================================================ FILE: wii/physfs/physfs-3.2.0.patch ================================================ diff --git a/CMakeLists.txt b/CMakeLists.txt index b3291cc..f017cca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,7 @@ set(PHYSFS_SRCS src/physfs_platform_posix.c src/physfs_platform_unix.c src/physfs_platform_windows.c + src/physfs_platform_ogc.c src/physfs_platform_os2.c src/physfs_platform_qnx.c src/physfs_platform_android.c diff --git a/src/physfs_internal.h b/src/physfs_internal.h index 2200d4d..5fb938c 100644 --- a/src/physfs_internal.h +++ b/src/physfs_internal.h @@ -38,7 +38,7 @@ #include #endif -#if defined(PHYSFS_PLATFORM_SOLARIS) || defined(PHYSFS_PLATFORM_LINUX) +#if defined(PHYSFS_PLATFORM_SOLARIS) || defined(PHYSFS_PLATFORM_LINUX) || defined(PHYSFS_PLATFORM_OGC) #include #endif diff --git a/src/physfs_platform_ogc.c b/src/physfs_platform_ogc.c new file mode 100644 index 0000000..53694cb --- /dev/null +++ b/src/physfs_platform_ogc.c @@ -0,0 +1,440 @@ +/* + * Wii/GameCube support routines for PhysicsFS. + * + * Please see the file LICENSE.txt in the source's root directory. + * + * This file written by Ryan C. Gordon. + */ + +#define __PHYSICSFS_INTERNAL__ +#include "physfs_platforms.h" + +#ifdef PHYSFS_PLATFORM_OGC + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include + +#include "physfs_internal.h" + + +static PHYSFS_ErrorCode errcodeFromErrnoError(const int err) +{ + switch (err) + { + case 0: return PHYSFS_ERR_OK; + case EACCES: return PHYSFS_ERR_PERMISSION; + case EPERM: return PHYSFS_ERR_PERMISSION; + case EDQUOT: return PHYSFS_ERR_NO_SPACE; + case EIO: return PHYSFS_ERR_IO; + case ELOOP: return PHYSFS_ERR_SYMLINK_LOOP; + case EMLINK: return PHYSFS_ERR_NO_SPACE; + case ENAMETOOLONG: return PHYSFS_ERR_BAD_FILENAME; + case ENOENT: return PHYSFS_ERR_NOT_FOUND; + case ENOSPC: return PHYSFS_ERR_NO_SPACE; + case ENOTDIR: return PHYSFS_ERR_NOT_FOUND; + case EISDIR: return PHYSFS_ERR_NOT_A_FILE; + case EROFS: return PHYSFS_ERR_READ_ONLY; + case ETXTBSY: return PHYSFS_ERR_BUSY; + case EBUSY: return PHYSFS_ERR_BUSY; + case ENOMEM: return PHYSFS_ERR_OUT_OF_MEMORY; + case ENOTEMPTY: return PHYSFS_ERR_DIR_NOT_EMPTY; + default: return PHYSFS_ERR_OS_ERROR; + } /* switch */ +} /* errcodeFromErrnoError */ + + +static inline PHYSFS_ErrorCode errcodeFromErrno(void) +{ + return errcodeFromErrnoError(errno); +} /* errcodeFromErrno */ + + +static inline char *buildSubdirPath(const char *subdir, size_t subdir_length) +{ + const char *baseDir; + char *retval; + size_t length; + + baseDir = PHYSFS_getBaseDir(); + length = strlen(baseDir); + + retval = allocator.Malloc(length + subdir_length); + BAIL_IF(!retval, PHYSFS_ERR_OUT_OF_MEMORY, NULL); + strcpy(retval, baseDir); + strcpy(retval + length, subdir); + + return retval; +} + +char *__PHYSFS_platformCalcUserDir(void) +{ + static const char subdir[] = "userdata/"; + + /* We don't have users on the Wii/GameCube. Just create a userdata folder + * in the application's directory. */ + return buildSubdirPath(subdir, sizeof(subdir)); +} /* __PHYSFS_platformCalcUserDir */ + + +PHYSFS_EnumerateCallbackResult __PHYSFS_platformEnumerate(const char *dirname, + PHYSFS_EnumerateCallback callback, + const char *origdir, void *callbackdata) +{ + DIR *dir; + struct dirent *ent; + PHYSFS_EnumerateCallbackResult retval = PHYSFS_ENUM_OK; + + dir = opendir(dirname); + BAIL_IF(dir == NULL, errcodeFromErrno(), PHYSFS_ENUM_ERROR); + + while ((retval == PHYSFS_ENUM_OK) && ((ent = readdir(dir)) != NULL)) + { + const char *name = ent->d_name; + if (name[0] == '.') /* ignore "." and ".." */ + { + if ((name[1] == '\0') || ((name[1] == '.') && (name[2] == '\0'))) + continue; + } /* if */ + + retval = callback(callbackdata, origdir, name); + if (retval == PHYSFS_ENUM_ERROR) + PHYSFS_setErrorCode(PHYSFS_ERR_APP_CALLBACK); + } /* while */ + + closedir(dir); + + return retval; +} /* __PHYSFS_platformEnumerate */ + + +int __PHYSFS_platformMkDir(const char *path) +{ + const int rc = mkdir(path, S_IRWXU); + BAIL_IF(rc == -1, errcodeFromErrno(), 0); + return 1; +} /* __PHYSFS_platformMkDir */ + + +#if !defined(O_CLOEXEC) && defined(FD_CLOEXEC) +static inline void set_CLOEXEC(int fildes) +{ + int flags = fcntl(fildes, F_GETFD); + if (flags != -1) { + fcntl(fildes, F_SETFD, flags | FD_CLOEXEC); + } +} +#endif + +static void *doOpen(const char *filename, int mode) +{ + const int appending = (mode & O_APPEND); + int fd; + int *retval; + + errno = 0; + + /* O_APPEND doesn't actually behave as we'd like. */ + mode &= ~O_APPEND; + +#ifdef O_CLOEXEC + /* Add O_CLOEXEC if defined */ + mode |= O_CLOEXEC; +#endif + + do { + fd = open(filename, mode, S_IRUSR | S_IWUSR); + } while ((fd < 0) && (errno == EINTR)); + BAIL_IF(fd < 0, errcodeFromErrno(), NULL); + +#if !defined(O_CLOEXEC) && defined(FD_CLOEXEC) + set_CLOEXEC(fd); +#endif + + if (appending) + { + if (lseek(fd, 0, SEEK_END) < 0) + { + const int err = errno; + close(fd); + BAIL(errcodeFromErrnoError(err), NULL); + } /* if */ + } /* if */ + + retval = (int *) allocator.Malloc(sizeof (int)); + if (!retval) + { + close(fd); + BAIL(PHYSFS_ERR_OUT_OF_MEMORY, NULL); + } /* if */ + + *retval = fd; + return ((void *) retval); +} /* doOpen */ + + +void *__PHYSFS_platformOpenRead(const char *filename) +{ + return doOpen(filename, O_RDONLY); +} /* __PHYSFS_platformOpenRead */ + + +void *__PHYSFS_platformOpenWrite(const char *filename) +{ + return doOpen(filename, O_WRONLY | O_CREAT | O_TRUNC); +} /* __PHYSFS_platformOpenWrite */ + + +void *__PHYSFS_platformOpenAppend(const char *filename) +{ + return doOpen(filename, O_WRONLY | O_CREAT | O_APPEND); +} /* __PHYSFS_platformOpenAppend */ + + +PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer, + PHYSFS_uint64 len) +{ + const int fd = *((int *) opaque); + ssize_t rc = 0; + + if (!__PHYSFS_ui64FitsAddressSpace(len)) + BAIL(PHYSFS_ERR_INVALID_ARGUMENT, -1); + + do { + rc = read(fd, buffer, (size_t) len); + } while ((rc == -1) && (errno == EINTR)); + BAIL_IF(rc == -1, errcodeFromErrno(), -1); + assert(rc >= 0); + assert(rc <= len); + return (PHYSFS_sint64) rc; +} /* __PHYSFS_platformRead */ + + +PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer, + PHYSFS_uint64 len) +{ + const int fd = *((int *) opaque); + ssize_t rc = 0; + + if (!__PHYSFS_ui64FitsAddressSpace(len)) + BAIL(PHYSFS_ERR_INVALID_ARGUMENT, -1); + + do { + rc = write(fd, (void *) buffer, (size_t) len); + } while ((rc == -1) && (errno == EINTR)); + BAIL_IF(rc == -1, errcodeFromErrno(), rc); + assert(rc >= 0); + assert(rc <= len); + return (PHYSFS_sint64) rc; +} /* __PHYSFS_platformWrite */ + + +int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos) +{ + const int fd = *((int *) opaque); + const off_t rc = lseek(fd, (off_t) pos, SEEK_SET); + BAIL_IF(rc == -1, errcodeFromErrno(), 0); + return 1; +} /* __PHYSFS_platformSeek */ + + +PHYSFS_sint64 __PHYSFS_platformTell(void *opaque) +{ + const int fd = *((int *) opaque); + PHYSFS_sint64 retval; + retval = (PHYSFS_sint64) lseek(fd, 0, SEEK_CUR); + BAIL_IF(retval == -1, errcodeFromErrno(), -1); + return retval; +} /* __PHYSFS_platformTell */ + + +PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque) +{ + const int fd = *((int *) opaque); + struct stat statbuf; + BAIL_IF(fstat(fd, &statbuf) == -1, errcodeFromErrno(), -1); + return ((PHYSFS_sint64) statbuf.st_size); +} /* __PHYSFS_platformFileLength */ + + +int __PHYSFS_platformFlush(void *opaque) +{ + const int fd = *((int *) opaque); + int rc = -1; + if ((fcntl(fd, F_GETFL) & O_ACCMODE) != O_RDONLY) { + do { + rc = fsync(fd); + } while ((rc == -1) && (errno == EINTR)); + BAIL_IF(rc == -1, errcodeFromErrno(), 0); + } + return 1; +} /* __PHYSFS_platformFlush */ + + +void __PHYSFS_platformClose(void *opaque) +{ + const int fd = *((int *) opaque); + int rc = -1; + do { + rc = close(fd); /* we don't check this. You should have used flush! */ + } while ((rc == -1) && (errno == EINTR)); + allocator.Free(opaque); +} /* __PHYSFS_platformClose */ + + +int __PHYSFS_platformDelete(const char *path) +{ + BAIL_IF(remove(path) == -1, errcodeFromErrno(), 0); + return 1; +} /* __PHYSFS_platformDelete */ + + +int __PHYSFS_platformStat(const char *fname, PHYSFS_Stat *st, const int follow) +{ + struct stat statbuf; + const int rc = follow ? stat(fname, &statbuf) : lstat(fname, &statbuf); + BAIL_IF(rc == -1, errcodeFromErrno(), 0); + + if (S_ISREG(statbuf.st_mode)) + { + st->filetype = PHYSFS_FILETYPE_REGULAR; + st->filesize = statbuf.st_size; + } /* if */ + + else if(S_ISDIR(statbuf.st_mode)) + { + st->filetype = PHYSFS_FILETYPE_DIRECTORY; + st->filesize = 0; + } /* else if */ + + else if(S_ISLNK(statbuf.st_mode)) + { + st->filetype = PHYSFS_FILETYPE_SYMLINK; + st->filesize = 0; + } /* else if */ + + else + { + st->filetype = PHYSFS_FILETYPE_OTHER; + st->filesize = statbuf.st_size; + } /* else */ + + st->modtime = statbuf.st_mtime; + st->createtime = statbuf.st_ctime; + st->accesstime = statbuf.st_atime; + + st->readonly = (access(fname, W_OK) == -1); + return 1; +} /* __PHYSFS_platformStat */ + + +void *__PHYSFS_platformGetThreadID(void) +{ + return (void *) LWP_GetSelf(); +} /* __PHYSFS_platformGetThreadID */ + + +void *__PHYSFS_platformCreateMutex(void) +{ + mutex_t m; + LWP_MutexInit(&m, true); + return (void *) m; +} /* __PHYSFS_platformCreateMutex */ + + +void __PHYSFS_platformDestroyMutex(void *mutex) +{ + mutex_t m = (mutex_t) mutex; + + LWP_MutexDestroy(m); +} /* __PHYSFS_platformDestroyMutex */ + + +int __PHYSFS_platformGrabMutex(void *mutex) +{ + mutex_t m = (mutex_t) mutex; + return LWP_MutexLock(m) == 0 ? 1 : 0; +} /* __PHYSFS_platformGrabMutex */ + + +void __PHYSFS_platformReleaseMutex(void *mutex) +{ + mutex_t m = (mutex_t) mutex; + LWP_MutexUnlock(m); +} /* __PHYSFS_platformReleaseMutex */ + + + +int __PHYSFS_platformInit(void) +{ + return 1; /* always succeed. */ +} /* __PHYSFS_platformInit */ + + +void __PHYSFS_platformDeinit(void) +{ + /* no-op */ +} /* __PHYSFS_platformDeinit */ + + +void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data) +{ +} /* __PHYSFS_platformDetectAvailableCDs */ + + +char *__PHYSFS_platformCalcBaseDir(const char *argv0) +{ + char *retval = NULL; + const size_t bufsize = 128; + + retval = allocator.Realloc(retval, bufsize); + if (retval) + { + if (getcwd(retval, bufsize - 1)) + { + /* Make sure the path is slash-terminated */ + size_t length = strlen(retval); + if (length > 0 && retval[length - 1] != '/') + { + retval[length++] = '/'; + retval[length] = '\0'; + } + } + else + { + strcpy(retval, "/"); + } + } + + return retval; +} /* __PHYSFS_platformCalcBaseDir */ + + +char *__PHYSFS_platformCalcPrefDir(const char *org, const char *app) +{ + static const char subdir[] = "data/"; + + /* We don't have users on the Wii/GameCube. Just create a userdata folder + * in the application's directory. */ + return buildSubdirPath(subdir, sizeof(subdir)); +} /* __PHYSFS_platformCalcPrefDir */ + +/* end of physfs_platform_unix.c ... */ + +#endif /* PHYSFS_PLATFORM_OGC */ + +/* end of physfs_platform_ogc.c ... */ + diff --git a/src/physfs_platforms.h b/src/physfs_platforms.h index 1ac17d9..36119b3 100644 --- a/src/physfs_platforms.h +++ b/src/physfs_platforms.h @@ -72,6 +72,9 @@ #elif defined(unix) || defined(__unix__) # define PHYSFS_PLATFORM_UNIX 1 # define PHYSFS_PLATFORM_POSIX 1 +#elif defined(__wii__) || defined(__gamecube__) +# define PHYSFS_PLATFORM_OGC 1 +# define PHYSFS_NO_CDROM_SUPPORT 1 // TODO #else # error Unknown platform. #endif ================================================ FILE: wii/pkg-config/PKGBUILD ================================================ # Maintainer: WinterMute pkgname=wii-pkg-config pkgver=0.28 pkgrel=5 pkgdesc='pkg-config wrapper (for Nintendo Wii homebrew development)' arch=('any') url='http://devkitpro.org/' source=('pkg-config.in') sha256sums=('7249d1313cc83a9997dc948e54831409857d2bccc461a4f20f9bc3eb840d2fc0') groups=('wii-dev') package() { install -d "$pkgdir"/opt/devkitpro/portlibs/wii/bin cp "$srcdir"/pkg-config.in "$pkgdir"/opt/devkitpro/portlibs/wii/bin/powerpc-eabi-pkg-config } ================================================ FILE: wii/pkg-config/pkg-config.in ================================================ #!/usr/bin/env bash command -v pkg-config >/dev/null 2>&1 || { echo >&2 "I require pkg-config but it's not installed. Aborting."; exit 1; } # reset pkg-config variables to ensure we're not polluted by host libraries export PKG_CONFIG_DIR= export PKG_CONFIG_PATH= export PKG_CONFIG_SYSROOT_DIR= export PKG_CONFIG_LIBDIR=/opt/devkitpro/portlibs/wii/lib/pkgconfig:/opt/devkitpro/portlibs/ppc/lib/pkgconfig [[ "$1" == '--version' ]] && exec pkg-config --version exec pkg-config --static "$@" ================================================ FILE: wii-examples/PKGBUILD ================================================ # Maintainer: Dave Murphy pkgname=('wii-examples') pkgver=20260125 pkgrel=1 pkgdesc="Nintendo Wii example code." arch=('any') license=('custom') url="http://github.com/devkitpro/${pkgname}" options=(!strip libtool staticlibs) source=(${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz) sha256sums=('19fc757d48f6a4beee799bfb870c46a6b7ef61897145f5c6fba7594aeddcc91a') depends=('devkitPPC' 'libogc') groups=('wii-dev') package() { mkdir -p "$pkgdir"/opt/devkitpro/examples/wii cp -R $srcdir/${pkgname}-${pkgver}/* "$pkgdir"/opt/devkitpro/examples/wii } sha256sums=('9490170c9595dacf5f13fd8070b36414bbe1af4792e47a37d199ec34b90b99f4')