Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 84 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Haiku")
set(Haiku TRUE CACHE BOOL "..." FORCE)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU")
set(GNU TRUE CACHE BOOL "..." FORCE)
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "MINT")
set(MINT TRUE CACHE BOOL "..." FORCE)
elseif(NOT APPLE AND NOT WIN32)
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
endif()
Expand Down Expand Up @@ -92,6 +94,7 @@ cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR ANDROID OR GNU"
cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_ELF "Enable libelf" ON "LINUX OR ANDROID OR DragonFly OR Haiku OR GNU" OFF)
cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF)
cmake_dependent_option(ENABLE_LIBZFS "Enable libzfs" ON "NOT MINT" OFF)

option(ENABLE_ZLIB "Enable zlib" ON)
option(ENABLE_SYSTEM_YYJSON "Use system provided (instead of fastfetch embedded) yyjson library" OFF)
Expand All @@ -105,7 +108,6 @@ option(INSTALL_LICENSE "Install license into /usr/share/licenses" ON)
option(ENABLE_EMBEDDED_PCIIDS "Embed pci.ids into fastfetch, requires `python`" OFF)
option(ENABLE_EMBEDDED_AMDGPUIDS "Embed amdgpu.ids into fastfetch, requires `python`" OFF)
option(ENABLE_WORDEXP "Enable using of wordexp(3) if available, instead of glob(3)" ON)
option(ENABLE_LIBZFS "Enable libzfs" ON)
if(WIN32 AND NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
option(ENABLE_WIN81_COMPAT "Enable legacy Windows compatibility (Windows 8.1 and later; Windows 7 unsupported)" ON)
endif()
Expand Down Expand Up @@ -1327,6 +1329,74 @@ elseif(GNU)
src/detection/wmtheme/wmtheme_linux.c
src/detection/camera/camera_nosupport.c
)
elseif(MINT)
list(APPEND LIBFASTFETCH_SRC
src/common/impl/dbus.c
src/common/impl/io_unix.c
src/common/impl/netif_nosupport.c
src/common/impl/networking_nosupport.c
src/common/impl/processing_linux.c
src/common/impl/FFPlatform_unix.c
src/common/impl/binary_linux.c
src/detection/battery/battery_nosupport.c
src/detection/bios/bios_mint.c
src/detection/board/board_mint.c
src/detection/bootmgr/bootmgr_nosupport.c
src/detection/brightness/brightness_nosupport.c
src/detection/btrfs/btrfs_nosupport.c
src/detection/chassis/chassis_nosupport.c
src/detection/cpu/cpu_mint.c
src/detection/cpucache/cpucache_nosupport.c
src/detection/cpuusage/cpuusage_nosupport.c
src/detection/cursor/cursor_nosupport.c
src/detection/bluetooth/bluetooth_nosupport.c
src/detection/bluetoothradio/bluetoothradio_nosupport.c
src/detection/disk/disk_nosupport.c
src/detection/dns/dns_linux.c
src/detection/physicaldisk/physicaldisk_nosupport.c
src/detection/physicalmemory/physicalmemory_nosupport.c
src/detection/diskio/diskio_nosupport.c
src/detection/displayserver/displayserver_aes.c
src/detection/font/font_nosupport.c
src/detection/gpu/gpu_nosupport.c
src/detection/gtk_qt/gtk.c
src/detection/host/host_nosupport.c
src/detection/icons/icons_nosupport.c
src/detection/initsystem/initsystem_nosupport.c
src/detection/keyboard/keyboard_nosupport.c
src/detection/libc/libc_nosupport.c
src/detection/lm/lm_nosupport.c
src/detection/loadavg/loadavg_linux.c
src/detection/locale/locale_linux.c
src/detection/localip/localip_nosupport.c
src/detection/gamepad/gamepad_nosupport.c
src/detection/media/media_nosupport.c
src/detection/memory/memory_linux.c
src/detection/mouse/mouse_nosupport.c
src/detection/netio/netio_nosupport.c
src/detection/opengl/opengl_nosupport.c
src/detection/os/os_linux.c
src/detection/packages/packages_nosupport.c
src/detection/poweradapter/poweradapter_nosupport.c
src/detection/processes/processes_nosupport.c
src/detection/gtk_qt/qt.c
src/detection/sound/sound_nosupport.c
src/detection/swap/swap_nosupport.c
src/detection/terminalfont/terminalfont_linux.c
src/detection/terminalshell/terminalshell_linux.c
src/detection/terminalsize/terminalsize_linux.c
src/detection/theme/theme_nosupport.c
src/detection/tpm/tpm_nosupport.c
src/detection/uptime/uptime_nosupport.c
src/detection/users/users_nosupport.c
src/detection/wallpaper/wallpaper_nosupport.c
src/detection/wifi/wifi_nosupport.c
src/detection/wm/wm_nosupport.c
src/detection/de/de_nosupport.c
src/detection/wmtheme/wmtheme_nosupport.c
src/detection/camera/camera_nosupport.c
src/detection/zpool/zpool.c
)
endif()

# Proprietary GPU driver APIs
Expand All @@ -1353,6 +1423,7 @@ if(NOT HAVE_WCWIDTH)
endif()
if(NOT WIN32)
check_function_exists(pipe2 HAVE_PIPE2)
check_function_exists(getaddrinfo HAVE_GETADDRINFO)
endif()
check_function_exists(memrchr HAVE_MEMRCHR)
if(NOT HAVE_MEMRCHR)
Expand Down Expand Up @@ -1466,6 +1537,9 @@ elseif(Haiku)
elseif(GNU)
# On Hurd PATH_MAX is not defined. Set an arbitrary limit as workaround.
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE PATH_MAX=4096 O_PATH=0)
elseif(MINT)
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE _POSIX_SOURCE)
set(BINARY_LINK_TYPE "static")
endif()

if(APPLE)
Expand Down Expand Up @@ -1839,16 +1913,25 @@ elseif(Haiku)
PRIVATE "be"
PRIVATE "gnu"
)
elseif(MINT)
target_link_libraries(libfastfetch
PRIVATE "cflib"
PRIVATE "gem"
PRIVATE "m"
#PRIVATE "mintlib"
)
endif()

target_include_directories(libfastfetch
PUBLIC ${PROJECT_BINARY_DIR}
PUBLIC ${PROJECT_SOURCE_DIR}/src
)

if(NOT MINT)
target_link_libraries(libfastfetch
PRIVATE ${CMAKE_DL_LIBS}
)
endif()

target_compile_options(libfastfetch PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti>)
Expand Down
34 changes: 34 additions & 0 deletions Toolchain-atari-NetSurf.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This Toolchain file is used to cross compile the windows
# version of Hatari under linux using mingw32
# use : cmake -DCMAKE_TOOLCHAIN_FILE=Toolchain-atari.cmake

# The name of the target operating system
SET(CMAKE_SYSTEM_NAME MINT)

# MINT versions of the different tools
# (change these depending on your system settings)
SET(CMAKE_C_COMPILER m68k-atari-mint-gcc)
SET(CMAKE_CXX_COMPILER m68k-atari-mint-g++)
SET(CMAKE_RC_COMPILER m68k-atari-mint-windres)
SET(CMAKE_ASM_COMPILER m68k-atari-mint-as)
SET(CMAKE_STRIP m68k-atari-mint-strip)

# Base directory for the target environment
SET(CMAKE_FIND_ROOT_PATH /opt/netsurf/m68k-atari-mint/env )

# FindSDL.cmake doesn't search correctly in CMAKE_FIND_ROOT_PATH
# so we force SDLDIR here
set ( ENV{SDLDIR} ${CMAKE_FIND_ROOT_PATH}/include/SDL )

# Adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

#
set(CMAKE_EXECUTABLE_SUFFIX .prg)
set(CMAKE_EXECUTABLE_SUFFIX_ASM .prg)
set(CMAKE_EXECUTABLE_SUFFIX_C .prg)
set(CMAKE_EXECUTABLE_SUFFIX_CXX .prg)
39 changes: 39 additions & 0 deletions Toolchain-atari.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This Toolchain file is used to cross compile the windows
# version of Hatari under linux using mingw32
# use : cmake -DCMAKE_TOOLCHAIN_FILE=Toolchain-atari.cmake

# The name of the target operating system
SET(CMAKE_SYSTEM_NAME MINT)

# MINT versions of the different tools
# (change these depending on your system settings)
SET(CMAKE_C_COMPILER m68k-atari-mintelf-gcc)
SET(CMAKE_CXX_COMPILER m68k-atari-mintelf-g++)
SET(CMAKE_RC_COMPILER m68k-atari-mintelf-windres)
SET(CMAKE_ASM_COMPILER m68k-atari-mintelf-as)
SET(CMAKE_STRIP m68k-atari-mintelf-strip)

# Base directory for the target environment
SET(CMAKE_FIND_ROOT_PATH /usr/m68k-atari-mintelf )

# FindSDL.cmake doesn't search correctly in CMAKE_FIND_ROOT_PATH
# so we force SDLDIR here
set ( ENV{SDLDIR} ${CMAKE_FIND_ROOT_PATH}/include/SDL )

# Force pkg-config search paths as there's no symlink
set ( ENV{PKG_CONFIG_LIBDIR} ${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig )
set ( ENV{PKG_CONFIG_SYSTEM_INCLUDE_PATH} ${CMAKE_FIND_ROOT_PATH}/include )
set ( ENV{PKG_CONFIG_SYSTEM_LIBRARY_PATH} ${CMAKE_FIND_ROOT_PATH}/lib )

# Adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

#
set(CMAKE_EXECUTABLE_SUFFIX .prg)
set(CMAKE_EXECUTABLE_SUFFIX_ASM .prg)
set(CMAKE_EXECUTABLE_SUFFIX_C .prg)
set(CMAKE_EXECUTABLE_SUFFIX_CXX .prg)
4 changes: 4 additions & 0 deletions src/common/arrayUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#include <assert.h>

#ifdef __MINT__
#define static_assert(x,y)
#endif

#ifdef __has_builtin
#if !__cplusplus && FF_SUPPORTS_COUNT_OF
#define ARRAY_SIZE(x) _Countof(x)
Expand Down
4 changes: 4 additions & 0 deletions src/common/attributes.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#pragma once

#ifdef __MINT__
#define static_assert(x,y)
#endif

#ifndef __has_attribute
#error Unsupported compiler
#define __attribute__(x)
Expand Down
6 changes: 6 additions & 0 deletions src/common/impl/FFPlatform_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#elif defined(__HAIKU__)
#include <image.h>
#include <OS.h>
#elif defined(__MINT__)
#include <mint/basepage.h>
#include <math.h>
#endif

static void getExePath(FFPlatform* platform) {
Expand Down Expand Up @@ -142,6 +145,9 @@ static void getExePath(FFPlatform* platform) {
break;
}
}
#elif defined(__MINT__)
size_t exePathLen = strnlen(_base->p_cmdlin, sizeof(_base->p_cmdlin) - 1);
exePathLen = strlcpy(exePath, _base->p_cmdlin, min(exePathLen, PATH_MAX));
#endif
if (exePathLen > 0) {
ffStrbufEnsureFree(&platform->exePath, PATH_MAX);
Expand Down
6 changes: 5 additions & 1 deletion src/common/impl/io_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,18 +280,22 @@ void listFilesRecursively(uint32_t baseLength, FFstrbuf* folder, uint8_t indenta
}

bool isDir = false;
#if !defined(__sun) && !defined(__HAIKU__)
#if !defined(__sun) && !defined(__HAIKU__) && !defined(__MINT__)
if (entry->d_type != DT_UNKNOWN && entry->d_type != DT_LNK) {
isDir = entry->d_type == DT_DIR;
} else
#endif
{
struct stat stbuf;
#ifndef __MINT__
if (fstatat(dfd, entry->d_name, &stbuf, 0) < 0) {
#endif
isDir = false;
#ifndef __MINT__
} else {
isDir = S_ISDIR(stbuf.st_mode);
}
#endif
}
if (isDir) {
ffStrbufAppendS(folder, entry->d_name);
Expand Down
7 changes: 7 additions & 0 deletions src/common/impl/netif_nosupport.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "common/netif.h"
#include "common/io.h"

bool ffNetifGetDefaultRouteImpl(char *iface, uint32_t* ifIndex)
{
return false;
}
13 changes: 13 additions & 0 deletions src/common/impl/networking_nosupport.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "fastfetch.h"
#include "common/networking.h"

const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* host, const char* path, const char* headers)
{
return "Not supported on this platform";
}

const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buffer)
{
return "Not supported on this platform";

}
4 changes: 2 additions & 2 deletions src/common/impl/processing_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <errno.h>
#include <sys/wait.h>

#if !(__ANDROID__ || __OpenBSD__)
#if !(__ANDROID__ || __OpenBSD__ || __MINT__)
#include <spawn.h>
#endif

Expand Down Expand Up @@ -66,7 +66,7 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFProcessHandle*
pid_t childPid = -1;
int nullFile = ffGetNullFD();

#if !(__ANDROID__ || __OpenBSD__)
#if !(__ANDROID__ || __OpenBSD__ || __MINT__)

// NetBSD / Darwin: native syscall
// Linux (glibc): clone3-execve
Expand Down
16 changes: 16 additions & 0 deletions src/common/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ HANDLE openat(HANDLE dfd, const char* fileName, int oflag);
HANDLE openatW(HANDLE dfd, const wchar_t* fileName, uint16_t fileNameLen, bool directory);
#endif

#ifdef __MINT__
#ifndef O_CLOEXEC
#warning "O_CLOEXEC missing"
#define O_CLOEXEC 0
#endif
#define openat(dfd, fileName, oflag) ({-1;})
#endif

static inline bool ffIsValidNativeFD(FFNativeFD fd) {
#ifndef _WIN32
return fd >= 0;
Expand Down Expand Up @@ -124,12 +132,16 @@ FF_A_NONNULL(1, 3) static inline ssize_t ffReadFileData(const char* fileName, si
}

FF_A_NONNULL(2, 4) static inline ssize_t ffReadFileDataRelative(FFNativeFD dfd, const char* fileName, size_t dataSize, void* data) {
#ifndef __MINT__
FFNativeFD FF_AUTO_CLOSE_FD fd = openat(dfd, fileName, O_RDONLY | O_CLOEXEC);
if (!ffIsValidNativeFD(fd)) {
#endif
return -1;
#ifndef __MINT__
}

return ffReadFDData(fd, dataSize, data);
#endif
}

FF_A_NONNULL(1, 2) static inline bool ffAppendFileBuffer(const char* fileName, FFstrbuf* buffer) {
Expand All @@ -148,12 +160,16 @@ FF_A_NONNULL(1, 2) static inline bool ffAppendFileBuffer(const char* fileName, F
}

FF_A_NONNULL(2, 3) static inline bool ffAppendFileBufferRelative(FFNativeFD dfd, const char* fileName, FFstrbuf* buffer) {
#ifndef __MINT__
FFNativeFD FF_AUTO_CLOSE_FD fd = openat(dfd, fileName, O_RDONLY | O_CLOEXEC);
if (!ffIsValidNativeFD(fd)) {
#endif
return false;
#ifndef __MINT__
}

return ffAppendFDBuffer(fd, buffer);
#endif
}

FF_A_NONNULL(2) static inline bool ffReadFDBuffer(FFNativeFD fd, FFstrbuf* buffer) {
Expand Down
6 changes: 6 additions & 0 deletions src/common/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ static inline double ffTimeGetTick(void) // In msec
return (double) start.QuadPart * ffQpcMultiplier;
#elif defined(__HAIKU__)
return (double) system_time() / 1000.;
#elif defined(__MINT__)
#warning TODO
return 0ull;
#else
struct timespec timeNow;
clock_gettime(CLOCK_MONOTONIC, &timeNow);
Expand All @@ -44,6 +47,9 @@ static inline uint64_t ffTimeGetNow(void) {
return ffFileTimeToUnixMs((uint64_t) timeNow);
#elif defined(__HAIKU__)
return (uint64_t) real_time_clock_usecs() / 1000u;
#elif defined(__MINT__)
#warning TODO
return 0ull;
#else
struct timespec timeNow;
clock_gettime(CLOCK_REALTIME, &timeNow);
Expand Down
Loading
Loading